blob: debd6e6992fdc5c39f1754d4fc38a945bcfdd067 [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
Girish Gowlidab72f12014-09-04 15:34:43 +0530228#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700229
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530230#ifdef FEATURE_OEM_DATA_SUPPORT
231#define WE_GET_OEM_DATA_CAP 13
232#endif
233
Jeff Johnson295189b2012-06-20 16:38:30 -0700234/* Private ioctls and their sub-ioctls */
235#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
236#define WE_CLEAR_STATS 1
237#define WE_INIT_AP 2
238#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530239#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700240#define WE_ENABLE_AMP 4
241#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530242#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700243#define WE_ENABLE_DXE_STALL_DETECT 6
244#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700245#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530246#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530247#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530248#define WE_DUMP_ROAM_TIMER_LOG 12
249#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530250#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530251#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530252
Jeff Johnson295189b2012-06-20 16:38:30 -0700253/* Private ioctls and their sub-ioctls */
254#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
255#define WE_LOG_DUMP_CMD 1
256
Jeff Johnson295189b2012-06-20 16:38:30 -0700257#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800258//IOCTL to configure MCC params
259#define WE_MCC_CONFIG_CREDENTIAL 3
260#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700261
Chilam NG571c65a2013-01-19 12:27:36 +0530262#ifdef FEATURE_WLAN_TDLS
263#define WE_TDLS_CONFIG_PARAMS 5
264#endif
265
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700266#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530267#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530268#define WE_CONFIGURE_MONITOR_MODE 10
269#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700270
Chilam Ng01120412013-02-19 18:32:21 -0800271#ifdef FEATURE_WLAN_TDLS
272#undef MAX_VAR_ARGS
273#define MAX_VAR_ARGS 10
274#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700275#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800276#endif
277
Jeff Johnson295189b2012-06-20 16:38:30 -0700278/* Private ioctls (with no sub-ioctls) */
279/* note that they must be odd so that they have "get" semantics */
280#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
281#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
282#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
283
Girish Gowli464c9c82014-06-09 19:47:53 +0530284/* (SIOCIWFIRSTPRIV + 8) is currently unused */
285/* (SIOCIWFIRSTPRIV + 16) is currently unused */
286/* (SIOCIWFIRSTPRIV + 10) is currently unused */
287/* (SIOCIWFIRSTPRIV + 12) is currently unused */
288/* (SIOCIWFIRSTPRIV + 14) is currently unused */
289/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700290
Jeff Johnsone7245742012-09-05 17:12:55 -0700291#ifdef FEATURE_OEM_DATA_SUPPORT
292/* Private ioctls for setting the measurement configuration */
293#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
294#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
295#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700296
297#ifdef WLAN_FEATURE_VOWIFI_11R
298#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
299#endif
300
301/* Private ioctl for setting the host offload feature */
302#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
303
304/* Private ioctl to get the statistics */
305#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
306
307/* Private ioctl to set the Keep Alive Params */
308#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
309#ifdef WLAN_FEATURE_PACKET_FILTERING
310/* Private ioctl to set the Packet Filtering Params */
311#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
312#endif
313
314#ifdef FEATURE_WLAN_SCAN_PNO
315/* Private ioctl to get the statistics */
316#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
317#endif
318
319#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
320
321#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
322#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700323/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700324
Jeff Johnson295189b2012-06-20 16:38:30 -0700325#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
326#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
327
328#define WLAN_STATS_INVALID 0
329#define WLAN_STATS_RETRY_CNT 1
330#define WLAN_STATS_MUL_RETRY_CNT 2
331#define WLAN_STATS_TX_FRM_CNT 3
332#define WLAN_STATS_RX_FRM_CNT 4
333#define WLAN_STATS_FRM_DUP_CNT 5
334#define WLAN_STATS_FAIL_CNT 6
335#define WLAN_STATS_RTS_FAIL_CNT 7
336#define WLAN_STATS_ACK_FAIL_CNT 8
337#define WLAN_STATS_RTS_SUC_CNT 9
338#define WLAN_STATS_RX_DISCARD_CNT 10
339#define WLAN_STATS_RX_ERROR_CNT 11
340#define WLAN_STATS_TX_BYTE_CNT 12
341
342#define WLAN_STATS_RX_BYTE_CNT 13
343#define WLAN_STATS_RX_RATE 14
344#define WLAN_STATS_TX_RATE 15
345
Jeff Johnsone7245742012-09-05 17:12:55 -0700346#define WLAN_STATS_RX_UC_BYTE_CNT 16
347#define WLAN_STATS_RX_MC_BYTE_CNT 17
348#define WLAN_STATS_RX_BC_BYTE_CNT 18
349#define WLAN_STATS_TX_UC_BYTE_CNT 19
350#define WLAN_STATS_TX_MC_BYTE_CNT 20
351#define WLAN_STATS_TX_BC_BYTE_CNT 21
352
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800353#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
354 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
355 { \
356 *__p++ = __type; \
357 *__p++ = __size; \
358 memcpy(__p, __val, __size); \
359 __p += __size; \
360 __tlen += __size + 2; \
361 } \
362 else \
363 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800364 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800365 } \
366 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700367
368#define VERSION_VALUE_MAX_LEN 32
369
370#define TX_PER_TRACKING_DEFAULT_RATIO 5
371#define TX_PER_TRACKING_MAX_RATIO 10
372#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
373
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530374#define WLAN_ADAPTER 0
375#define P2P_ADAPTER 1
376
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530377#define TX_PWR_MIN 6
378#define TX_PWR_MAX 22
379#define TX_PWR_DEF 50
380
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530381/*
382 * When supplicant sends SETBAND ioctl it queries for channels from
383 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
384 * This is not required if the return type from ioctl is
385 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
386 * event as part of regulatory_hint.
387 */
388enum {
389 SEND_CHANNEL_CHANGE_EVENT = 0,
390 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
391};
392
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800393/*MCC Configuration parameters */
394enum {
395 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
396 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
397 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
398 MCC_RX_DRAIN_TIME_CFG_PARAM,
399 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
400 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
401 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
402 MCC_MIN_AFTER_DTIM_CFG_PARAM,
403 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
404};
405
406int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
407 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
408
Jeff Johnson295189b2012-06-20 16:38:30 -0700409#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800410int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700411 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700412#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530413static int get_fwr_memdump(struct net_device *,
414 struct iw_request_info *,
415 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700416/**---------------------------------------------------------------------------
417
Arif Hussain0273cba2014-01-07 20:58:29 -0800418 \brief mem_alloc_copy_from_user_helper -
419
420 Helper function to allocate buffer and copy user data.
421
422 \param - wrqu - Pointer to IOCTL Data.
423 len - size
424
425 \return - On Success pointer to buffer, On failure NULL
426
427 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530428void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800429{
430 u8 *ptr = NULL;
431
432 /* in order to protect the code, an extra byte is post appended to the buffer
433 * and the null termination is added. However, when allocating (len+1) byte
434 * of memory, we need to make sure that there is no uint overflow when doing
435 * addition. In theory check len < UINT_MAX protects the uint overflow. For
436 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
437 * guess, now, it is assumed that the private command buffer size is no
438 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
439 */
440 if (len > MAX_USER_COMMAND_SIZE)
441 {
442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
443 "Invalid length");
444 return NULL;
445 }
446
447 ptr = kmalloc(len + 1, GFP_KERNEL);
448 if (NULL == ptr)
449 {
450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
451 "unable to allocate memory");
452 return NULL;
453 }
454
455 if (copy_from_user(ptr, wrqu_data, len))
456 {
457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
458 "%s: failed to copy data to user buffer", __func__);
459 kfree(ptr);
460 return NULL;
461 }
462 ptr[len] = '\0';
463 return ptr;
464}
465
Girish Gowli488ef492014-06-12 18:44:33 +0530466// Function to handle and get compatible struct iw_point passed to ioctl.
467int hdd_priv_get_data(struct iw_point *p_priv_data,
468 union iwreq_data *wrqu)
469{
470 if ((NULL == p_priv_data) || (NULL == wrqu))
471 {
472 return -EINVAL;
473 }
474
475#ifdef CONFIG_COMPAT
476 if (is_compat_task())
477 {
478 struct compat_iw_point *p_compat_priv_data;
479
480 // Compat task: typecast to campat structure and copy the members.
481 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
482
483 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
484 p_priv_data->length = p_compat_priv_data->length;
485 p_priv_data->flags = p_compat_priv_data->flags;
486 }//if(is_compat_task())
487 else
488 {
489#endif //#ifdef CONFIG_COMPAT
490
491 // Non compat task: directly copy the structure.
492 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
493
494#ifdef CONFIG_COMPAT
495 }//else of - if(is_compat_task())
496#endif //#ifdef CONFIG_COMPAT
497
498 return 0;
499}
500
Arif Hussain0273cba2014-01-07 20:58:29 -0800501/**---------------------------------------------------------------------------
502
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 \brief hdd_wlan_get_version() -
504
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800505 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700506
507 \param - pAdapter Pointer to the adapter.
508 wrqu - Pointer to IOCTL REQUEST Data.
509 extra - Pointer to char
510
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800511 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700512
513 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800514void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
515 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700516{
517 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800518 tSirVersionString wcnss_SW_version;
519 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530520 tSirVersionString iris_name;
521 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800522 char *pSWversion;
523 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700525
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800526 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
527 sizeof(wcnss_SW_version));
528 if (VOS_IS_STATUS_SUCCESS(status))
529 {
530 pSWversion = wcnss_SW_version;
531 }
532 else
533 {
534 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 }
536
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800537 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
538 sizeof(wcnss_HW_version));
539 if (VOS_IS_STATUS_SUCCESS(status))
540 {
541 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800543 else
544 {
545 pHWversion = "Unknown";
546 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700547
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530548 status = wcnss_get_iris_name(iris_name);
549
550 if (!status) {
551 pIRISversion = iris_name;
552 } else {
553 pIRISversion = "Unknown";
554 }
555
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700556 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530557 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800558 QWLAN_VERSIONSTR,
559 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530560 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800561
562 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700563}
564
Jeff Johnson295189b2012-06-20 16:38:30 -0700565int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
566{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530567 tHalHandle hHal;
568 hdd_context_t *pHddCtx;
569 v_U32_t threshold = 0;
570 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700571
572 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530573 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530574 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
576 "%s: Adapter is NULL",__func__);
577 return -EINVAL;
578 }
579
580 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
581 ret = wlan_hdd_validate_context(pHddCtx);
582 if (0 != ret)
583 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530584 return ret;
585 }
586
587 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
588 if (NULL == hHal)
589 {
590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
591 "%s: Hal Context is NULL",__func__);
592 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 }
594
595 if ( eHAL_STATUS_SUCCESS !=
596 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
597 {
c_hpothub8245442013-11-20 23:41:09 +0530598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
599 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 return -EIO;
601 }
602 wrqu->rts.value = threshold;
603
604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800605 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700606
607 EXIT();
608
609 return 0;
610}
611
612int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
613{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530614 tHalHandle hHal;
615 hdd_context_t *pHddCtx;
616 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700617
618 ENTER();
619
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530620 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530621 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
623 "%s: Adapter is NULL",__func__);
624 return -EINVAL;
625 }
626
627 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
628 status = wlan_hdd_validate_context(pHddCtx);
629 if (0 != status)
630 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530631 return status;
632 }
633
634 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
635 if (NULL == hHal)
636 {
637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
638 "%s: Hal Context is NULL",__func__);
639 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 }
641
642 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
643 != eHAL_STATUS_SUCCESS )
644 {
c_hpothub8245442013-11-20 23:41:09 +0530645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
646 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 return -EIO;
648 }
649 wrqu->frag.value = threshold;
650
651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800652 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700653
654 EXIT();
655
656 return 0;
657}
658
659int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
660{
Jeff Johnsone7245742012-09-05 17:12:55 -0700661 int i;
662 if (channel > 0)
663 {
664 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
665 {
666 if (channel == freq_chan_map[i].chan)
667 {
668 *pfreq = freq_chan_map[i].freq;
669 return 1;
670 }
671 }
672 }
673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800674 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700675 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700676}
677
678static v_BOOL_t
679hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
680{
681 v_BOOL_t rsnType = VOS_FALSE;
682 // is the authType supported?
683 switch (authType)
684 {
685 case eCSR_AUTH_TYPE_NONE: //never used
686 rsnType = eANI_BOOLEAN_FALSE;
687 break;
688 // MAC layer authentication types
689 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
690 rsnType = eANI_BOOLEAN_FALSE;
691 break;
692 case eCSR_AUTH_TYPE_SHARED_KEY:
693 rsnType = eANI_BOOLEAN_FALSE;
694 break;
695 case eCSR_AUTH_TYPE_AUTOSWITCH:
696 rsnType = eANI_BOOLEAN_FALSE;
697 break;
698
699 // Upper layer authentication types
700 case eCSR_AUTH_TYPE_WPA:
701 rsnType = eANI_BOOLEAN_TRUE;
702 break;
703 case eCSR_AUTH_TYPE_WPA_PSK:
704 rsnType = eANI_BOOLEAN_TRUE;
705 break;
706 case eCSR_AUTH_TYPE_WPA_NONE:
707 rsnType = eANI_BOOLEAN_TRUE;
708 break;
709#ifdef WLAN_FEATURE_VOWIFI_11R
710 case eCSR_AUTH_TYPE_FT_RSN:
711#endif
712 case eCSR_AUTH_TYPE_RSN:
713 rsnType = eANI_BOOLEAN_TRUE;
714 break;
715#ifdef WLAN_FEATURE_VOWIFI_11R
716 case eCSR_AUTH_TYPE_FT_RSN_PSK:
717#endif
718 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700719#ifdef WLAN_FEATURE_11W
720 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530721 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700722#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 rsnType = eANI_BOOLEAN_TRUE;
724 break;
725 //case eCSR_AUTH_TYPE_FAILED:
726 case eCSR_AUTH_TYPE_UNKNOWN:
727 rsnType = eANI_BOOLEAN_FALSE;
728 break;
729 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800730 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
731 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 rsnType = eANI_BOOLEAN_FALSE;
733 break;
734 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800735 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700736 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 return rsnType;
738}
739
740static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
741{
742 struct statsContext *pStatsContext;
743 hdd_adapter_t *pAdapter;
744
745 if (ioctl_debug)
746 {
747 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700748 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 }
750
751 if (NULL == pContext)
752 {
753 hddLog(VOS_TRACE_LEVEL_ERROR,
754 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700755 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 return;
757 }
758
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 pStatsContext = pContext;
760 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800761
762 /* there is a race condition that exists between this callback
763 function and the caller since the caller could time out either
764 before or while this code is executing. we use a spinlock to
765 serialize these actions */
766 spin_lock(&hdd_context_lock);
767
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
769 {
770 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800771 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 hddLog(VOS_TRACE_LEVEL_WARN,
773 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700774 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 if (ioctl_debug)
776 {
777 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700778 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 }
780 return;
781 }
782
Jeff Johnson72a40512013-12-19 10:14:15 -0800783 /* context is valid so caller is still waiting */
784
785 /* paranoia: invalidate the magic */
786 pStatsContext->magic = 0;
787
Sachin Ahujaa082b672015-10-05 19:51:31 +0530788 /* copy over the rssi.FW will return RSSI as -100
789 * if there are no samples to calculate the average
790 * RSSI
791 */
792 if (rssi != -100)
793 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530794 if (pAdapter->rssi > 0)
795 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800796 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800798
799 /* serialization is complete */
800 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700801}
802
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530803static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
804{
805 struct statsContext *pStatsContext;
806 hdd_adapter_t *pAdapter;
807
808 if (ioctl_debug)
809 {
810 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
811 __func__, (int)snr, (int)staId, pContext);
812 }
813
814 if (NULL == pContext)
815 {
816 hddLog(VOS_TRACE_LEVEL_ERROR,
817 "%s: Bad param, pContext [%p]",
818 __func__, pContext);
819 return;
820 }
821
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530822 pStatsContext = pContext;
823 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800824
825 /* there is a race condition that exists between this callback
826 function and the caller since the caller could time out either
827 before or while this code is executing. we use a spinlock to
828 serialize these actions */
829 spin_lock(&hdd_context_lock);
830
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530831 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
832 {
833 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800834 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530835 hddLog(VOS_TRACE_LEVEL_WARN,
836 "%s: Invalid context, pAdapter [%p] magic [%08x]",
837 __func__, pAdapter, pStatsContext->magic);
838 if (ioctl_debug)
839 {
840 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
841 __func__, pAdapter, pStatsContext->magic);
842 }
843 return;
844 }
845
Jeff Johnson72a40512013-12-19 10:14:15 -0800846 /* context is valid so caller is still waiting */
847
848 /* paranoia: invalidate the magic */
849 pStatsContext->magic = 0;
850
851 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530852 pAdapter->snr = snr;
853
Jeff Johnson72a40512013-12-19 10:14:15 -0800854 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530855 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800856
857 /* serialization is complete */
858 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530859}
860
Jeff Johnson295189b2012-06-20 16:38:30 -0700861VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
862{
863 struct statsContext context;
864 hdd_context_t *pHddCtx;
865 hdd_station_ctx_t *pHddStaCtx;
866 eHalStatus hstatus;
867 long lrc;
868
869 if (NULL == pAdapter)
870 {
871 hddLog(VOS_TRACE_LEVEL_WARN,
872 "%s: Invalid context, pAdapter", __func__);
873 return VOS_STATUS_E_FAULT;
874 }
875 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
876 {
877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
878 /* return a cached value */
879 *rssi_value = pAdapter->rssi;
880 return VOS_STATUS_SUCCESS;
881 }
882
883 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
884 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
885
mukul sharma8aec69b2015-06-10 22:28:43 +0530886 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
887 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
889 __func__, pAdapter->rssi_on_disconnect);
890 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +0530891 return VOS_STATUS_SUCCESS;
892 }
893
894 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
895 {
896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
897 "%s: Roaming in progress, hence return last cached RSSI", __func__);
898 *rssi_value = pAdapter->rssi;
899 return VOS_STATUS_SUCCESS;
900 }
901
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 init_completion(&context.completion);
903 context.pAdapter = pAdapter;
904 context.magic = RSSI_CONTEXT_MAGIC;
905
906 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
907 pHddStaCtx->conn_info.staId[ 0 ],
908 pHddStaCtx->conn_info.bssId,
909 &context, pHddCtx->pvosContext);
910 if (eHAL_STATUS_SUCCESS != hstatus)
911 {
912 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700913 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 /* we'll returned a cached value below */
915 }
916 else
917 {
918 /* request was sent -- wait for the response */
919 lrc = wait_for_completion_interruptible_timeout(&context.completion,
920 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 if (lrc <= 0)
922 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800923 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700924 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 /* we'll now returned a cached value below */
926 }
927 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800928
929 /* either we never sent a request, we sent a request and received a
930 response or we sent a request and timed out. if we never sent a
931 request or if we sent a request and got a response, we want to
932 clear the magic out of paranoia. if we timed out there is a
933 race condition such that the callback function could be
934 executing at the same time we are. of primary concern is if the
935 callback function had already verified the "magic" but had not
936 yet set the completion variable when a timeout occurred. we
937 serialize these activities by invalidating the magic while
938 holding a shared spinlock which will cause us to block if the
939 callback is currently executing */
940 spin_lock(&hdd_context_lock);
941 context.magic = 0;
942 spin_unlock(&hdd_context_lock);
943
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 *rssi_value = pAdapter->rssi;
945
946 return VOS_STATUS_SUCCESS;
947}
Siddharth Bhal64246172015-02-27 01:04:37 +0530948/**---------------------------------------------------------------------------
949
950 \brief wlan_hdd_get_frame_logs() -
951
952 This function use to get Frames log.
953
954 \param - pAdapter Pointer to the adapter.
955 flag - Specify type of request. Clear and Send request are
956 supported.
957
958 \return - none
959
960 --------------------------------------------------------------------------*/
961VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
962{
Siddharth Bhal64246172015-02-27 01:04:37 +0530963 hdd_context_t *pHddCtx;
964 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +0530965
966 if (NULL == pAdapter)
967 {
968 hddLog(VOS_TRACE_LEVEL_WARN,
969 "%s: Invalid context, pAdapter", __func__);
970 return VOS_STATUS_E_FAULT;
971 }
972
973 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
974 if (!pHddCtx->mgmt_frame_logging)
975 {
Abhishek Singha7d80b12016-02-03 15:27:20 +0530976 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +0530977 return VOS_STATUS_E_AGAIN;
978 }
979
Siddharth Bhal4507c262015-04-29 20:20:42 +0530980 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
981 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
982 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +0530983 {
984 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
985 return VOS_STATUS_E_INVAL;
986 }
987
Siddharth Bhal4507c262015-04-29 20:20:42 +0530988 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
989 (!pHddCtx->cfg_ini->enableBMUHWtracing))
990 {
991 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
992 return VOS_STATUS_E_INVAL;
993 }
994
Abhishek Singh611295e2015-07-09 11:11:54 +0530995 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +0530996 if (eHAL_STATUS_SUCCESS != hstatus)
997 {
998 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +0530999 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301000 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301001
1002 return VOS_STATUS_SUCCESS;
1003}
1004
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301005
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301006VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1007{
1008 struct statsContext context;
1009 hdd_context_t *pHddCtx;
1010 hdd_station_ctx_t *pHddStaCtx;
1011 eHalStatus hstatus;
1012 long lrc;
1013 int valid;
1014
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301015 ENTER();
1016
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301017 if (NULL == pAdapter)
1018 {
1019 hddLog(VOS_TRACE_LEVEL_ERROR,
1020 "%s: Invalid context, pAdapter", __func__);
1021 return VOS_STATUS_E_FAULT;
1022 }
1023
1024 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1025
1026 valid = wlan_hdd_validate_context(pHddCtx);
1027 if (0 != valid)
1028 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301029 return VOS_STATUS_E_FAULT;
1030 }
1031
1032 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1033 if (NULL == pHddStaCtx)
1034 {
1035 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1036 return VOS_STATUS_E_FAULT;
1037 }
1038
1039 init_completion(&context.completion);
1040 context.pAdapter = pAdapter;
1041 context.magic = SNR_CONTEXT_MAGIC;
1042
1043 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1044 pHddStaCtx->conn_info.staId[ 0 ],
1045 pHddStaCtx->conn_info.bssId,
1046 &context);
1047 if (eHAL_STATUS_SUCCESS != hstatus)
1048 {
1049 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1050 __func__);
1051 /* we'll returned a cached value below */
1052 }
1053 else
1054 {
1055 /* request was sent -- wait for the response */
1056 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1057 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301058 if (lrc <= 0)
1059 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001060 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301061 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301062 /* we'll now returned a cached value below */
1063 }
1064 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001065
1066 /* either we never sent a request, we sent a request and received a
1067 response or we sent a request and timed out. if we never sent a
1068 request or if we sent a request and got a response, we want to
1069 clear the magic out of paranoia. if we timed out there is a
1070 race condition such that the callback function could be
1071 executing at the same time we are. of primary concern is if the
1072 callback function had already verified the "magic" but had not
1073 yet set the completion variable when a timeout occurred. we
1074 serialize these activities by invalidating the magic while
1075 holding a shared spinlock which will cause us to block if the
1076 callback is currently executing */
1077 spin_lock(&hdd_context_lock);
1078 context.magic = 0;
1079 spin_unlock(&hdd_context_lock);
1080
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301081 *snr = pAdapter->snr;
1082
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301083 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301084 return VOS_STATUS_SUCCESS;
1085}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301086
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001087#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001088
1089static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1090{
1091 struct statsContext *pStatsContext;
1092 hdd_adapter_t *pAdapter;
1093 if (ioctl_debug)
1094 {
1095 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1096 __func__, (int)rssi, (int)staId, pContext);
1097 }
1098
1099 if (NULL == pContext)
1100 {
1101 hddLog(VOS_TRACE_LEVEL_ERROR,
1102 "%s: Bad param, pContext [%p]",
1103 __func__, pContext);
1104 return;
1105 }
1106
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001107 pStatsContext = pContext;
1108 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001109
1110 /* there is a race condition that exists between this callback
1111 function and the caller since the caller could time out either
1112 before or while this code is executing. we use a spinlock to
1113 serialize these actions */
1114 spin_lock(&hdd_context_lock);
1115
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001116 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1117 {
1118 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001119 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001120 hddLog(VOS_TRACE_LEVEL_WARN,
1121 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1122 __func__, pAdapter, pStatsContext->magic);
1123 if (ioctl_debug)
1124 {
1125 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1126 __func__, pAdapter, pStatsContext->magic);
1127 }
1128 return;
1129 }
1130
Jeff Johnson72a40512013-12-19 10:14:15 -08001131 /* context is valid so caller is still waiting */
1132
1133 /* paranoia: invalidate the magic */
1134 pStatsContext->magic = 0;
1135
Sachin Ahujaa082b672015-10-05 19:51:31 +05301136 /* copy over the rssi.FW will return RSSI as -100
1137 * if there are no samples to calculate the average
1138 * RSSI
1139 */
1140 if (rssi != -100)
1141 pAdapter->rssi = rssi;
1142
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301143 if (pAdapter->rssi > 0)
1144 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001145 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001146 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001147
1148 /* serialization is complete */
1149 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001150}
1151
1152
1153
1154VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1155{
1156 struct statsContext context;
1157 hdd_context_t *pHddCtx = NULL;
1158 hdd_station_ctx_t *pHddStaCtx = NULL;
1159 eHalStatus hstatus;
1160 long lrc;
1161
1162 if (NULL == pAdapter)
1163 {
1164 hddLog(VOS_TRACE_LEVEL_WARN,
1165 "%s: Invalid context, pAdapter", __func__);
1166 return VOS_STATUS_E_FAULT;
1167 }
1168 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1169 {
1170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1171 /* return a cached value */
1172 *rssi_value = pAdapter->rssi;
1173 return VOS_STATUS_SUCCESS;
1174 }
1175
1176 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1177 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1178
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301179 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001180 {
1181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1182 /* return a cached value */
1183 *rssi_value = 0;
1184 return VOS_STATUS_SUCCESS;
1185 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301186
1187 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1188 {
1189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1190 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1191 *rssi_value = pAdapter->rssi;
1192 return VOS_STATUS_SUCCESS;
1193 }
1194
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001195 init_completion(&context.completion);
1196 context.pAdapter = pAdapter;
1197 context.magic = RSSI_CONTEXT_MAGIC;
1198
1199 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1200 pHddStaCtx->conn_info.staId[ 0 ],
1201 pHddStaCtx->conn_info.bssId,
1202 &context, pHddCtx->pvosContext);
1203 if (eHAL_STATUS_SUCCESS != hstatus)
1204 {
1205 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1206 __func__);
1207 /* we'll returned a cached value below */
1208 }
1209 else
1210 {
1211 /* request was sent -- wait for the response */
1212 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1213 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001214 if (lrc <= 0)
1215 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001216 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001217 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001218 /* we'll now returned a cached value below */
1219 }
1220 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001221
1222 /* either we never sent a request, we sent a request and received a
1223 response or we sent a request and timed out. if we never sent a
1224 request or if we sent a request and got a response, we want to
1225 clear the magic out of paranoia. if we timed out there is a
1226 race condition such that the callback function could be
1227 executing at the same time we are. of primary concern is if the
1228 callback function had already verified the "magic" but had not
1229 yet set the completion variable when a timeout occurred. we
1230 serialize these activities by invalidating the magic while
1231 holding a shared spinlock which will cause us to block if the
1232 callback is currently executing */
1233 spin_lock(&hdd_context_lock);
1234 context.magic = 0;
1235 spin_unlock(&hdd_context_lock);
1236
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001237 *rssi_value = pAdapter->rssi;
1238
1239 return VOS_STATUS_SUCCESS;
1240}
1241#endif
1242
1243
Jeff Johnson295189b2012-06-20 16:38:30 -07001244void hdd_StatisticsCB( void *pStats, void *pContext )
1245{
1246 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1247 hdd_stats_t *pStatsCache = NULL;
1248 hdd_wext_state_t *pWextState;
1249 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1250
1251 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1252 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1253 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1254 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1255 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1256 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1257
1258 if (pAdapter!= NULL)
1259 pStatsCache = &pAdapter->hdd_stats;
1260
1261
1262 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1263 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1264 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1265 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1266 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1267 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1268
1269 if (pStatsCache!=NULL)
1270 {
1271 // and copy the stats into the cache we keep in the adapter instance structure
1272 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1273 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1274 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1275 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1276 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1277 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1278 }
1279
1280 if(pAdapter)
1281 {
1282 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1283 if(pWextState)
1284 {
1285 vos_status = vos_event_set(&pWextState->vosevent);
1286 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1287 {
1288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001289 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 return;
1291 }
1292 }
1293 }
1294}
1295
1296void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1297{
1298 v_CONTEXT_t pVosContext;
1299 hdd_context_t *pHddCtx;
1300 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1301#if 0
1302 hdd_wext_state_t *pWextState;
1303 v_U32_t roamId;
1304#endif
1305
1306 ENTER();
1307
1308 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1309
1310 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1311 if (NULL == pHddCtx)
1312 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001313 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 return;
1315 }
1316#if 0
1317 pWextState = pAdapter->pWextState;
1318#endif
1319
1320 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1321 {
1322 //TODO Verify is this is really used. If yes need to fix it.
1323 hdd_reconnect_all_adapters( pHddCtx );
1324#if 0
1325 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1326 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1327 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1328
1329 if(VOS_STATUS_SUCCESS == vosStatus)
1330 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1331 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1332
1333 sme_RoamConnect(halHandle,
1334 pAdapter->sessionId, &(pWextState->roamProfile),
1335 &roamId);
1336#endif
1337 }
1338
1339 EXIT();
1340
1341}
1342
1343void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1344{
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1346
1347 /* clear WPA/RSN/WSC IE information in the profile */
1348 pWextState->roamProfile.nWPAReqIELength = 0;
1349 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1350 pWextState->roamProfile.nRSNReqIELength = 0;
1351 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1352
Chet Lanctot186b5732013-03-18 10:26:30 -07001353#ifdef FEATURE_WLAN_WAPI
1354 pWextState->roamProfile.nWAPIReqIELength = 0;
1355 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1356#endif
1357
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001359 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301361 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1363 pWextState->roamProfile.nAddIEAssocLength = 0;
1364
1365 pWextState->roamProfile.EncryptionType.numEntries = 1;
1366 pWextState->roamProfile.EncryptionType.encryptionType[0]
1367 = eCSR_ENCRYPT_TYPE_NONE;
1368
1369 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1370 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1371 = eCSR_ENCRYPT_TYPE_NONE;
1372
1373 pWextState->roamProfile.AuthType.numEntries = 1;
1374 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1375
Chet Lanctot186b5732013-03-18 10:26:30 -07001376#ifdef WLAN_FEATURE_11W
1377 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1378 pWextState->roamProfile.MFPRequired = 0;
1379 pWextState->roamProfile.MFPCapable = 0;
1380#endif
1381
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 pWextState->authKeyMgmt = 0;
1383
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301384 vos_mem_zero(&pWextState->roamProfile.Keys,
1385 sizeof(pWextState->roamProfile.Keys));
1386
Jeff Johnson295189b2012-06-20 16:38:30 -07001387#ifdef FEATURE_WLAN_WAPI
1388 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1389 pAdapter->wapi_info.nWapiMode = 0;
1390#endif
1391
1392 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1393
1394}
1395
1396void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1397{
1398 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001399
Nirav Shahf6bd2672015-03-11 12:53:15 +05301400 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001401 {
1402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301403 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001404 }
1405 else
1406 {
1407 complete(&pAdapter->ula_complete);
1408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001409}
1410
1411VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1412{
1413 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001415 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001416
1417 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1418 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001419 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001420
1421 /*To avoid race condition between the set key and the last EAPOL
1422 packet, notify TL to finish upper layer authentication incase if the
1423 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001424 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001425
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001426 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 {
1428 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1429 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1430 __LINE__, vos_status );
1431 return vos_status;
1432
1433 }
1434
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001435 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301437 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001438 {
1439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301440 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001441 /* we'll still fall through and return success since the
1442 * connection may still get established but is just taking
1443 * too long for us to wait */
1444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001445 }
1446 return VOS_STATUS_SUCCESS;
1447}
1448
1449v_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)
1450{
1451
1452 int left = ie_len;
1453 v_U8_t *ptr = ie;
1454 v_U8_t elem_id,elem_len;
1455 v_U8_t eid = 0xDD;
1456
1457 if ( NULL == ie || 0 == ie_len )
1458 return NULL;
1459
1460 while(left >= 2)
1461 {
1462 elem_id = ptr[0];
1463 elem_len = ptr[1];
1464 left -= 2;
1465 if(elem_len > left)
1466 {
1467 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001468 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 eid,elem_len,left);
1470 return NULL;
1471 }
1472 if (elem_id == eid)
1473 {
1474 if(memcmp( &ptr[2], oui, oui_size)==0)
1475 return ptr;
1476 }
1477
1478 left -= elem_len;
1479 ptr += (elem_len + 2);
1480 }
1481 return NULL;
1482}
1483
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301484static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001485 union iwreq_data *wrqu, char *extra)
1486{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301487 hdd_adapter_t *pAdapter;
1488 hdd_context_t *pHddCtx;
1489 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301490
1491 ENTER();
1492
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301493 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1494 if (NULL == pAdapter)
1495 {
1496 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1497 "%s: pAdapter is NULL\n", __func__);
1498 return -EINVAL;
1499 }
1500 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1501 ret = wlan_hdd_validate_context(pHddCtx);
1502 if (0 != ret)
1503 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301504 return ret;
1505 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301506
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301508
1509 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301510 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001511}
1512
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301513static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1514 union iwreq_data *wrqu, char *extra)
1515{
1516 int ret;
1517
1518 vos_ssr_protect(__func__);
1519 ret = __iw_set_commit(dev, info, wrqu, extra);
1520 vos_ssr_unprotect(__func__);
1521
1522 return ret;
1523}
1524
1525static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 struct iw_request_info *info,
1527 char *wrqu, char *extra)
1528{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301529 hdd_adapter_t *pAdapter;
1530 hdd_context_t *pHddCtx;
1531 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301532
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301534 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1535 if (NULL == pAdapter)
1536 {
1537 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1538 "%s: pAdapter is NULL\n", __func__);
1539 return -EINVAL;
1540 }
1541 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1542 ret = wlan_hdd_validate_context(pHddCtx);
1543 if (0 != ret)
1544 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301545 return ret;
1546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1548 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301549 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001550}
1551
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301552static int iw_get_name(struct net_device *dev,
1553 struct iw_request_info *info,
1554 char *wrqu, char *extra)
1555{
1556 int ret;
1557
1558 vos_ssr_protect(__func__);
1559 ret = __iw_get_name(dev, info, wrqu, extra);
1560 vos_ssr_unprotect(__func__);
1561
1562 return ret;
1563}
1564
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301565static int __iw_set_mode(struct net_device *dev,
1566 struct iw_request_info *info,
1567 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001568{
1569 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301570 hdd_adapter_t *pAdapter;
1571 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 tCsrRoamProfile *pRoamProfile;
1573 eCsrRoamBssType LastBSSType;
1574 eMib_dot11DesiredBssType connectedBssType;
1575 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301577 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001578
1579 ENTER();
1580
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301581 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 if (NULL == pAdapter)
1583 {
1584 hddLog(VOS_TRACE_LEVEL_WARN,
1585 "%s: Invalid context, pAdapter", __func__);
1586 return 0;
1587 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301588 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1589 status = wlan_hdd_validate_context(pHddCtx);
1590 if (0 != status)
1591 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301592 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 }
1594
1595 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1596 if (pWextState == NULL)
1597 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301598 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 return -EINVAL;
1600 }
1601
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 pRoamProfile = &pWextState->roamProfile;
1604 LastBSSType = pRoamProfile->BSSType;
1605
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301606 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001607
1608 switch (wrqu->mode)
1609 {
1610 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301611 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1613 // Set the phymode correctly for IBSS.
1614 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1615 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001616 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 break;
1619 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301620 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 break;
1624 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301625 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1627 break;
1628 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301629 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 return -EOPNOTSUPP;
1631 }
1632
1633 if ( LastBSSType != pRoamProfile->BSSType )
1634 {
1635 //the BSS mode changed
1636 // We need to issue disconnect if connected or in IBSS disconnect state
1637 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1638 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1639 {
1640 VOS_STATUS vosStatus;
1641 // need to issue a disconnect to CSR.
1642 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1643 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1644 pAdapter->sessionId,
1645 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1646 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301647 {
1648 long ret;
1649 ret = wait_for_completion_interruptible_timeout(
1650 &pAdapter->disconnect_comp_var,
1651 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1652 if (ret <= 0)
1653 hddLog(VOS_TRACE_LEVEL_ERROR,
1654 FL("failed wait on disconnect_comp_var %ld"), ret);
1655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 }
1657 }
1658
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 EXIT();
1660 return 0;
1661}
1662
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301663static int iw_set_mode(struct net_device *dev,
1664 struct iw_request_info *info,
1665 union iwreq_data *wrqu, char *extra)
1666{
1667 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001668
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301669 vos_ssr_protect(__func__);
1670 ret = __iw_set_mode(dev, info, wrqu, extra);
1671 vos_ssr_unprotect(__func__);
1672
1673 return ret;
1674}
1675
1676static int __iw_get_mode(struct net_device *dev,
1677 struct iw_request_info *info,
1678 union iwreq_data *wrqu,
1679 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001680{
1681
1682 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301683 hdd_adapter_t *pAdapter;
1684 hdd_context_t *pHddCtx;
1685 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001686
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301687 ENTER();
1688
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301689 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001690 if (NULL == pAdapter)
1691 {
1692 hddLog(VOS_TRACE_LEVEL_WARN,
1693 "%s: Invalid context, pAdapter", __func__);
1694 return 0;
1695 }
1696
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301697 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1698 ret = wlan_hdd_validate_context(pHddCtx);
1699 if (0 != ret)
1700 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301701 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1704 if (pWextState == NULL)
1705 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301706 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 return -EINVAL;
1708 }
1709
1710 switch (pWextState->roamProfile.BSSType)
1711 {
1712 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001713 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301714 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 break;
1716 case eCSR_BSS_TYPE_IBSS:
1717 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001718 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301719 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 break;
1721 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001722 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301723 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 break;
1725 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001726 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 break;
1728 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301729
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301730 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 return 0;
1732}
1733
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301734static int iw_get_mode(struct net_device *dev,
1735 struct iw_request_info *info,
1736 union iwreq_data *wrqu,
1737 char *extra)
1738{
1739 int ret;
1740
1741 vos_ssr_protect(__func__);
1742 ret = __iw_get_mode(dev, info, wrqu, extra);
1743 vos_ssr_unprotect(__func__);
1744
1745 return ret;
1746}
1747
1748static int __iw_set_freq(struct net_device *dev,
1749 struct iw_request_info *info,
1750 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001751{
1752 v_U32_t numChans = 0;
1753 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1754 v_U32_t indx = 0;
1755 v_U32_t status = 0;
1756
1757 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301758 hdd_adapter_t *pAdapter;
1759 hdd_context_t *pHddCtx;
1760 tHalHandle hHal;
1761 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001762 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301763
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 ENTER();
1765
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301766 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1767 if (NULL == pAdapter)
1768 {
1769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1770 "%s:Invalid Adapter",__func__);
1771 return -EINVAL;
1772 }
1773
1774 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1775 status = wlan_hdd_validate_context(pHddCtx);
1776 if (0 != status)
1777 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 return status;
1779 }
1780
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301781 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1782 if (NULL == hHal)
1783 {
1784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1785 "%s: Hal Context is NULL",__func__);
1786 return -EINVAL;
1787 }
1788
1789 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1790 if (NULL == pHddStaCtx)
1791 {
1792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1793 "%s:STA context is NULL",__func__);
1794 return -EINVAL;
1795 }
1796
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301798 if (NULL == pWextState)
1799 {
1800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1801 "%s: pWextState is NULL",__func__);
1802 return -EINVAL;
1803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001804
1805 pRoamProfile = &pWextState->roamProfile;
1806
Arif Hussain6d2a3322013-11-17 19:50:10 -08001807 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001808
1809 /* Link is up then return cant set channel*/
1810 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1811 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1812 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001813 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 return -EOPNOTSUPP;
1815 }
1816
1817 /* Settings by Frequency as input */
1818 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1819 (wrqu->freq.m <= (tANI_U32)5.825e8))
1820 {
1821 tANI_U32 freq = wrqu->freq.m / 100000;
1822
1823 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1824 indx++;
1825 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1826 {
1827 return -EINVAL;
1828 }
1829 wrqu->freq.e = 0;
1830 wrqu->freq.m = freq_chan_map[indx].chan;
1831
1832 }
1833
1834 if (wrqu->freq.e == 0)
1835 {
1836 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1837 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1838 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001839 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001840 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1842 return -EINVAL;
1843 }
1844
1845 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1846
1847 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1848 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1850 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 return -EIO;
1852 }
1853
1854 for (indx = 0; indx < numChans; indx++) {
1855 if (wrqu->freq.m == validChan[indx]){
1856 break;
1857 }
1858 }
1859 }
1860 else{
1861
1862 return -EINVAL;
1863 }
1864
1865 if(indx >= numChans)
1866 {
1867 return -EINVAL;
1868 }
1869
1870 /* Set the Operational Channel */
1871 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1872 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1873 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1874
Arif Hussain6d2a3322013-11-17 19:50:10 -08001875 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001876
1877 EXIT();
1878
1879 return status;
1880}
1881
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301882static int iw_set_freq(struct net_device *dev,
1883 struct iw_request_info *info,
1884 union iwreq_data *wrqu, char *extra)
1885{
1886 int ret;
1887
1888 vos_ssr_protect(__func__);
1889 ret = __iw_set_freq(dev, info, wrqu, extra);
1890 vos_ssr_unprotect(__func__);
1891
1892 return ret;
1893}
1894
1895static int __iw_get_freq(struct net_device *dev,
1896 struct iw_request_info *info,
1897 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001898{
Jeff Johnsone7245742012-09-05 17:12:55 -07001899 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301900 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 tHalHandle hHal;
1902 hdd_wext_state_t *pWextState;
1903 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301904 hdd_station_ctx_t *pHddStaCtx;
1905 hdd_context_t *pHddCtx;
1906 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001907
1908 ENTER();
1909
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301910 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1911 if (NULL == pAdapter)
1912 {
1913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1914 "%s: Adapter is NULL", __func__);
1915 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301917 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1918 ret = wlan_hdd_validate_context(pHddCtx);
1919 if (0 != ret)
1920 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301921 return ret;
1922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301924 if (NULL == hHal)
1925 {
1926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1927 "%s: Hal Context is NULL",__func__);
1928 return -EINVAL;
1929 }
1930 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1931 if (NULL == pHddStaCtx)
1932 {
1933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1934 "%s: HddStaCtx is NULL", __func__);
1935 return -EINVAL;
1936 }
1937 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1938 if (NULL == pWextState)
1939 {
1940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1941 "%s: pWextState is NULL",__func__);
1942 return -EINVAL;
1943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 pRoamProfile = &pWextState->roamProfile;
1945
1946 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1947 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001948 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 {
c_hpothub8245442013-11-20 23:41:09 +05301950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1951 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 return -EIO;
1953 }
1954 else
1955 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001956 status = hdd_wlan_get_freq(channel, &freq);
1957 if( TRUE == status )
1958 {
1959 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1960 * iwlist & iwconfig command shows frequency into proper
1961 * format (2.412 GHz instead of 246.2 MHz)*/
1962 fwrq->m = freq;
1963 fwrq->e = MHZ;
1964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 }
1966 }
1967 else
1968 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001969 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1970 * iwlist & iwconfig command shows frequency into proper
1971 * format (2.412 GHz instead of 246.2 MHz)*/
1972 fwrq->m = 0;
1973 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301975
1976 EXIT();
1977 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001978}
1979
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301980static int iw_get_freq(struct net_device *dev,
1981 struct iw_request_info *info,
1982 struct iw_freq *fwrq, char *extra)
1983{
1984 int ret;
1985
1986 vos_ssr_protect(__func__);
1987 ret = __iw_get_freq(dev, info, fwrq, extra);
1988 vos_ssr_unprotect(__func__);
1989
1990 return ret;
1991}
1992
1993static int __iw_get_tx_power(struct net_device *dev,
1994 struct iw_request_info *info,
1995 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001996{
1997
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301998 hdd_adapter_t *pAdapter;
1999 hdd_context_t *pHddCtx;
2000 hdd_station_ctx_t *pHddStaCtx;
2001 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002002
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302003 ENTER();
2004
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302005 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2006 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2009 "%s: Adapter is NULL",__func__);
2010 return -EINVAL;
2011 }
2012 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2013 ret = wlan_hdd_validate_context(pHddCtx);
2014 if (0 != ret)
2015 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302016 return ret;
2017 }
2018
2019 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2020 if (NULL == pHddStaCtx)
2021 {
2022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2023 "%s: STA Context is NULL",__func__);
2024 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 }
2026
2027 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2028 {
2029 wrqu->txpower.value = 0;
2030 return 0;
2031 }
2032 wlan_hdd_get_classAstats(pAdapter);
2033 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2034
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302035 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 return 0;
2037}
2038
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302039static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002040 struct iw_request_info *info,
2041 union iwreq_data *wrqu, char *extra)
2042{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302043 int ret;
2044
2045 vos_ssr_protect(__func__);
2046 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2047 vos_ssr_unprotect(__func__);
2048
2049 return ret;
2050}
2051
2052static int __iw_set_tx_power(struct net_device *dev,
2053 struct iw_request_info *info,
2054 union iwreq_data *wrqu, char *extra)
2055{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302056 hdd_adapter_t *pAdapter;
2057 tHalHandle hHal;
2058 hdd_context_t *pHddCtx;
2059 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002060
2061 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302062 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2063 if (NULL == pAdapter)
2064 {
2065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2066 "%s: Adapter is NULL",__func__);
2067 return -EINVAL;
2068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002069
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302070 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2071 ret = wlan_hdd_validate_context(pHddCtx);
2072 if (0 != ret)
2073 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302074 return ret;
2075 }
2076
2077 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2078 if (NULL == hHal)
2079 {
2080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2081 "%s: Hal Context is NULL",__func__);
2082 return -EINVAL;
2083 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2085 {
c_hpothub8245442013-11-20 23:41:09 +05302086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2087 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 return -EIO;
2089 }
2090
2091 EXIT();
2092
2093 return 0;
2094}
2095
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302096static int iw_set_tx_power(struct net_device *dev,
2097 struct iw_request_info *info,
2098 union iwreq_data *wrqu, char *extra)
2099{
2100 int ret;
2101
2102 vos_ssr_protect(__func__);
2103 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2104 vos_ssr_unprotect(__func__);
2105
2106 return ret;
2107}
2108
2109static int __iw_get_bitrate(struct net_device *dev,
2110 struct iw_request_info *info,
2111 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002112{
2113 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2114 eHalStatus status = eHAL_STATUS_SUCCESS;
2115 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302116 hdd_adapter_t *pAdapter;
2117 hdd_context_t *pHddCtx;
2118 hdd_station_ctx_t *pHddStaCtx;
2119 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002120
2121 ENTER();
2122
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302123 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2124 if (NULL == pAdapter)
2125 {
2126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2127 "%s: Adapter is NULL",__func__);
2128 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 }
2130
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302131 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2132 ret = wlan_hdd_validate_context(pHddCtx);
2133 if (0 != ret)
2134 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302135 return ret;
2136 }
2137
2138 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2139 if (NULL == pHddStaCtx)
2140 {
2141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2142 "%s: STA Context is NULL",__func__);
2143 return -EINVAL;
2144 }
2145
2146 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 wrqu->bitrate.value = 0;
2148 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302149 else
2150 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002151 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2152 SME_SUMMARY_STATS |
2153 SME_GLOBAL_CLASSA_STATS |
2154 SME_GLOBAL_CLASSB_STATS |
2155 SME_GLOBAL_CLASSC_STATS |
2156 SME_GLOBAL_CLASSD_STATS |
2157 SME_PER_STA_STATS,
2158 hdd_StatisticsCB, 0, FALSE,
2159 pHddStaCtx->conn_info.staId[0], pAdapter );
2160
2161 if(eHAL_STATUS_SUCCESS != status)
2162 {
2163 hddLog(VOS_TRACE_LEVEL_ERROR,
2164 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002165 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 return status;
2167 }
2168
2169 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302170 if (NULL == pWextState)
2171 {
2172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2173 "%s: pWextState is NULL",__func__);
2174 return -EINVAL;
2175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002176
2177 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2178
2179 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2180 {
2181 hddLog(VOS_TRACE_LEVEL_ERROR,
2182 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002183 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 return VOS_STATUS_E_FAILURE;
2185 }
2186
2187 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2188 }
2189
2190 EXIT();
2191
2192 return vos_status;
2193}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302194
2195static int iw_get_bitrate(struct net_device *dev,
2196 struct iw_request_info *info,
2197 union iwreq_data *wrqu, char *extra)
2198{
2199 int ret;
2200
2201 vos_ssr_protect(__func__);
2202 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2203 vos_ssr_unprotect(__func__);
2204
2205 return ret;
2206}
2207
2208
Jeff Johnson295189b2012-06-20 16:38:30 -07002209/* ccm call back function */
2210
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302211static int __iw_set_bitrate(struct net_device *dev,
2212 struct iw_request_info *info,
2213 union iwreq_data *wrqu,
2214 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002215{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302216 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302218 hdd_station_ctx_t *pHddStaCtx;
2219 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2221 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2222 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2223 v_U32_t i, rate;
2224 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302225 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;
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 }
2235
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 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2244 if (NULL == pHddStaCtx)
2245 {
2246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2247 "%s: STA Context is NULL",__func__);
2248 return -EINVAL;
2249 }
2250
2251
Jeff Johnson295189b2012-06-20 16:38:30 -07002252 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302253 if (NULL == pWextState)
2254 {
2255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2256 "%s: pWextState is NULL",__func__);
2257 return -EINVAL;
2258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002259
2260 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2261 {
2262 return -ENXIO ;
2263 }
2264
2265 rate = wrqu->bitrate.value;
2266
2267 if (rate == -1)
2268 {
2269 rate = WNI_CFG_FIXED_RATE_AUTO;
2270 valid_rate = TRUE;
2271 }
2272 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2273 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2274 {
2275 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2276 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2277 {
2278 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2279 WNI_CFG_SUPPORTED_RATES_11A,
2280 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2281 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2282 WNI_CFG_SUPPORTED_RATES_11B,
2283 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2284 {
2285 for (i = 0; i < (b_len + a_len); ++i)
2286 {
2287 /* supported rates returned is double the actual rate so we divide it by 2 */
2288 if ((supp_rates[i]&0x7F)/2 == rate)
2289 {
2290 valid_rate = TRUE;
2291 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2292 break;
2293 }
2294 }
2295 }
2296 }
2297 }
2298 if (valid_rate != TRUE)
2299 {
2300 return -EINVAL;
2301 }
2302 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2303 WNI_CFG_FIXED_RATE, rate,
2304 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2305 {
c_hpothub8245442013-11-20 23:41:09 +05302306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2307 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 return -EIO;
2309 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302310
2311 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 return 0;
2313}
2314
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302315static int iw_set_bitrate(struct net_device *dev,
2316 struct iw_request_info *info,
2317 union iwreq_data *wrqu,
2318 char *extra)
2319{
2320 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002321
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302322 vos_ssr_protect(__func__);
2323 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2324 vos_ssr_unprotect(__func__);
2325
2326 return ret;
2327}
2328
2329static int __iw_set_genie(struct net_device *dev,
2330 struct iw_request_info *info,
2331 union iwreq_data *wrqu,
2332 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002333{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302334 hdd_adapter_t *pAdapter;
2335 hdd_context_t *pHddCtx;
2336 hdd_wext_state_t *pWextState;
2337 u_int8_t *genie = NULL;
2338 u_int8_t *base_genie = NULL;
2339 v_U16_t remLen;
2340 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002341
2342 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002343
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302344 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2345 if (NULL == pAdapter)
2346 {
2347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2348 "%s: Adapter is NULL",__func__);
2349 return -EINVAL;
2350 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002351
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302352 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2353 ret = wlan_hdd_validate_context(pHddCtx);
2354 if (0 != ret)
2355 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302356 return ret;
2357 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002358
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302359 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2360 if (NULL == pWextState)
2361 {
2362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2363 "%s: pWextState is NULL",__func__);
2364 return -EINVAL;
2365 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002366
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302367 if (!wrqu->data.length) {
2368 hdd_clearRoamProfileIe(pAdapter);
2369 EXIT();
2370 return 0;
2371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002372
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302373 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2374 wrqu->data.length);
2375 if (NULL == base_genie)
2376 {
2377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2378 "mem_alloc_copy_from_user_helper fail");
2379 return -ENOMEM;
2380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002381
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302382 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002383
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302384 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302386 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2387
2388 /* clear any previous genIE before this call */
2389 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2390
2391 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 {
2393 v_U16_t eLen = 0;
2394 v_U8_t elementId;
2395 elementId = *genie++;
2396 eLen = *genie++;
2397 remLen -= 2;
2398
Arif Hussain6d2a3322013-11-17 19:50:10 -08002399 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 __func__, elementId, eLen);
2401
2402 switch ( elementId )
2403 {
2404 case IE_EID_VENDOR:
2405 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002406 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302407 ret = -EINVAL;
2408 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002410
2411 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2412 {
2413 v_U16_t curGenIELen = pWextState->genIE.length;
2414 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2415 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2416
2417 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2418 {
2419 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002420 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302422 ret = -EINVAL;
2423 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 }
2425 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2426 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2427 pWextState->genIE.length += eLen + 2;
2428 }
2429 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2430 {
2431 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302432 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2433 {
2434 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2435 "Need bigger buffer space");
2436 ret = -EINVAL;
2437 VOS_ASSERT(0);
2438 goto exit;
2439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2441 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2442 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2443 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2444 }
2445 else /* any vendorId except WPA IE should be accumulated to genIE */
2446 {
2447 v_U16_t curGenIELen = pWextState->genIE.length;
2448 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2449 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2450
2451 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2452 {
2453 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002454 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302456 ret = -ENOMEM;
2457 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 }
2459 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2460 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2461 pWextState->genIE.length += eLen + 2;
2462 }
2463 break;
2464 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002465 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302466 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2467 {
2468 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2469 "Need bigger buffer space");
2470 ret = -EINVAL;
2471 VOS_ASSERT(0);
2472 goto exit;
2473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2475 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2476 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2477 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2478 break;
2479
2480 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002481 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302482 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 }
2484 genie += eLen;
2485 remLen -= eLen;
2486 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302487
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302488exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002490 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302491 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002492}
2493
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302494static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002495 struct iw_request_info *info,
2496 union iwreq_data *wrqu,
2497 char *extra)
2498{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302499 int ret;
2500
2501 vos_ssr_protect(__func__);
2502 ret = __iw_set_genie(dev, info, wrqu, extra);
2503 vos_ssr_unprotect(__func__);
2504
2505 return ret;
2506}
2507
2508static int __iw_get_genie(struct net_device *dev,
2509 struct iw_request_info *info,
2510 union iwreq_data *wrqu,
2511 char *extra)
2512{
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302514 hdd_context_t *pHddCtx;
2515 hdd_adapter_t *pAdapter;
2516 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 eHalStatus status;
2518 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2519 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2520
2521 ENTER();
2522
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302523 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2524 if (NULL == pAdapter)
2525 {
2526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2527 "%s: Adapter is NULL",__func__);
2528 return -EINVAL;
2529 }
2530 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2531 status = wlan_hdd_validate_context(pHddCtx);
2532 if (0 != status)
2533 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302534 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 }
2536
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302538 if (NULL == pWextState)
2539 {
2540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2541 "%s: pWextState is NULL",__func__);
2542 return -EINVAL;
2543 }
2544
2545 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2546 if (NULL == pHddStaCtx)
2547 {
2548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2549 "%s: STA Context is NULL",__func__);
2550 return -EINVAL;
2551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002552
2553 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2554 {
2555 return -ENXIO;
2556 }
2557
2558 // Return something ONLY if we are associated with an RSN or WPA network
2559 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2560 pWextState->roamProfile.negotiatedAuthType))
2561 {
2562 return -ENXIO;
2563 }
2564
2565 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2566 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2567 pAdapter->sessionId,
2568 &length,
2569 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002570 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2571 if (wrqu->data.length < length)
2572 {
2573 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2574 return -EFAULT;
2575 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002576 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002577 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002578
Arif Hussain6d2a3322013-11-17 19:50:10 -08002579 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002580
2581 EXIT();
2582
2583 return 0;
2584}
2585
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302586static int iw_get_genie(struct net_device *dev,
2587 struct iw_request_info *info,
2588 union iwreq_data *wrqu,
2589 char *extra)
2590{
2591 int ret;
2592
2593 vos_ssr_protect(__func__);
2594 ret = __iw_get_genie(dev, info, wrqu, extra);
2595 vos_ssr_unprotect(__func__);
2596
2597 return ret;
2598}
2599
2600
2601static int __iw_get_encode(struct net_device *dev,
2602 struct iw_request_info *info,
2603 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002604{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302605 hdd_adapter_t *pAdapter;
2606 hdd_context_t *pHddCtx;
2607 hdd_wext_state_t *pWextState;
2608 tCsrRoamProfile *pRoamProfile;
2609 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002611
2612 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302613 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2614 if (NULL == pAdapter)
2615 {
2616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2617 "%s: Adapter is NULL",__func__);
2618 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 }
2620
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302621 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2622 ret = wlan_hdd_validate_context(pHddCtx);
2623 if (0 != ret)
2624 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302625 return ret;
2626 }
2627 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2628 if (NULL == pWextState)
2629 {
2630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2631 "%s: pWextState is NULL",__func__);
2632 return -EINVAL;
2633 }
2634
2635 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 keyId = pRoamProfile->Keys.defaultIndex;
2637
2638 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2639 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002640 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 return -EINVAL;
2642 }
2643
2644 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2645 {
2646 dwrq->flags |= IW_ENCODE_ENABLED;
2647 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2648 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2649
2650 dwrq->flags |= (keyId + 1);
2651
2652 }
2653 else
2654 {
2655 dwrq->flags |= IW_ENCODE_DISABLED;
2656 }
2657
2658 for(i=0; i < MAX_WEP_KEYS; i++)
2659 {
2660 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2661 {
2662 continue;
2663 }
2664 else
2665 {
2666 break;
2667 }
2668 }
2669
2670 if(MAX_WEP_KEYS == i)
2671 {
2672 dwrq->flags |= IW_ENCODE_NOKEY;
2673 }
2674
2675 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2676
2677 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2678 {
2679 dwrq->flags |= IW_ENCODE_OPEN;
2680 }
2681 else
2682 {
2683 dwrq->flags |= IW_ENCODE_RESTRICTED;
2684 }
2685 EXIT();
2686 return 0;
2687}
2688
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302689static int iw_get_encode(struct net_device *dev,
2690 struct iw_request_info *info,
2691 struct iw_point *dwrq, char *extra)
2692{
2693 int ret;
2694
2695 vos_ssr_protect(__func__);
2696 ret = __iw_get_encode(dev, info, dwrq, extra);
2697 vos_ssr_unprotect(__func__);
2698
2699 return ret;
2700}
2701
Jeff Johnson295189b2012-06-20 16:38:30 -07002702#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2703#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2704
2705
2706/*
2707 * This function sends a single 'key' to LIM at all time.
2708 */
2709
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302710static int __iw_get_rts_threshold(struct net_device *dev,
2711 struct iw_request_info *info,
2712 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002713{
2714 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2715 v_U32_t status = 0;
2716
2717 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2718
2719 return status;
2720}
2721
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302722static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 struct iw_request_info *info,
2724 union iwreq_data *wrqu, char *extra)
2725{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302726 int ret;
2727
2728 vos_ssr_protect(__func__);
2729 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2730 vos_ssr_unprotect(__func__);
2731
2732 return ret;
2733}
2734
2735static int __iw_set_rts_threshold(struct net_device *dev,
2736 struct iw_request_info *info,
2737 union iwreq_data *wrqu, char *extra)
2738{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302739 hdd_adapter_t *pAdapter;
2740 hdd_context_t *pHddCtx;
2741 tHalHandle hHal;
2742 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002743
2744 ENTER();
2745
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302746 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2747 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002748 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2750 "%s: Adapter is NULL",__func__);
2751 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002752 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302753
2754 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2755 ret = wlan_hdd_validate_context(pHddCtx);
2756 if (0 != ret)
2757 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302758 return ret;
2759 }
2760
2761 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2762 if (NULL == hHal)
2763 {
2764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2765 "%s: Hal Context is NULL",__func__);
2766 return -EINVAL;
2767 }
2768
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2770 {
2771 return -EINVAL;
2772 }
2773
2774 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2775 {
c_hpothub8245442013-11-20 23:41:09 +05302776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2777 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 return -EIO;
2779 }
2780
2781 EXIT();
2782
2783 return 0;
2784}
2785
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302786static int iw_set_rts_threshold(struct net_device *dev,
2787 struct iw_request_info *info,
2788 union iwreq_data *wrqu, char *extra)
2789{
2790 int ret;
2791
2792 vos_ssr_protect(__func__);
2793 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2794 vos_ssr_unprotect(__func__);
2795
2796 return ret;
2797}
2798
2799static int __iw_get_frag_threshold(struct net_device *dev,
2800 struct iw_request_info *info,
2801 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002802{
2803 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2804 v_U32_t status = 0;
2805
2806 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2807
2808 return status;
2809}
2810
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302811static int iw_get_frag_threshold(struct net_device *dev,
2812 struct iw_request_info *info,
2813 union iwreq_data *wrqu, char *extra)
2814{
2815 int ret;
2816
2817 vos_ssr_protect(__func__);
2818 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2819 vos_ssr_unprotect(__func__);
2820
2821 return ret;
2822}
2823
2824static int __iw_set_frag_threshold(struct net_device *dev,
2825 struct iw_request_info *info,
2826 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002827{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302828 hdd_adapter_t *pAdapter;
2829 hdd_context_t *pHddCtx;
2830 tHalHandle hHal;
2831 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002832
2833 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302834 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2835 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002836 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2838 "%s: Adapter is NULL",__func__);
2839 return -EINVAL;
2840 }
2841
2842 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2843 ret = wlan_hdd_validate_context(pHddCtx);
2844 if (0 != ret)
2845 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302846 return ret;
2847 }
2848
2849 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2850 if (NULL == hHal)
2851 {
2852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2853 "%s: Hal Context is NULL",__func__);
2854 return -EINVAL;
2855 }
2856
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2858 {
2859 return -EINVAL;
2860 }
2861
2862 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2863 {
c_hpothub8245442013-11-20 23:41:09 +05302864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2865 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 return -EIO;
2867 }
2868
2869 EXIT();
2870
2871 return 0;
2872}
2873
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302874static int iw_set_frag_threshold(struct net_device *dev,
2875 struct iw_request_info *info,
2876 union iwreq_data *wrqu, char *extra)
2877{
2878 int ret;
2879
2880 vos_ssr_protect(__func__);
2881 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2882 vos_ssr_unprotect(__func__);
2883
2884 return ret;
2885}
2886
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302887static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 struct iw_request_info *info,
2889 union iwreq_data *wrqu, char *extra)
2890{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302891 hdd_adapter_t *pAdapter;
2892 hdd_context_t *pHddCtx;
2893 int ret = 0;
2894
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302896 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2897 if (NULL == pAdapter)
2898 {
2899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2900 "%s: Adapter is NULL",__func__);
2901 return -EINVAL;
2902 }
2903 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2904 ret = wlan_hdd_validate_context(pHddCtx);
2905 if (0 != ret)
2906 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302907 return ret;
2908 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302909
2910 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 return -EOPNOTSUPP;
2912}
2913
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302914static int iw_get_power_mode(struct net_device *dev,
2915 struct iw_request_info *info,
2916 union iwreq_data *wrqu, char *extra)
2917{
2918 int ret;
2919
2920 vos_ssr_protect(__func__);
2921 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2922 vos_ssr_unprotect(__func__);
2923
2924 return ret;
2925}
2926static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 struct iw_request_info *info,
2928 union iwreq_data *wrqu, char *extra)
2929{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302930 hdd_adapter_t *pAdapter;
2931 hdd_context_t *pHddCtx;
2932 int ret = 0;
2933
Jeff Johnson295189b2012-06-20 16:38:30 -07002934 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302935 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2936 if (NULL == pAdapter)
2937 {
2938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2939 "%s: Adapter is NULL",__func__);
2940 return -EINVAL;
2941 }
2942 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2943 ret = wlan_hdd_validate_context(pHddCtx);
2944 if (0 != ret)
2945 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302946 return ret;
2947 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302948
2949 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 return -EOPNOTSUPP;
2951}
2952
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302953static int iw_set_power_mode(struct net_device *dev,
2954 struct iw_request_info *info,
2955 union iwreq_data *wrqu, char *extra)
2956{
2957 int ret;
2958
2959 vos_ssr_protect(__func__);
2960 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2961 vos_ssr_unprotect(__func__);
2962
2963 return ret;
2964}
2965
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302966static int __iw_get_range(struct net_device *dev,
2967 struct iw_request_info *info,
2968 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002969{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302970 hdd_adapter_t *pAdapter;
2971 tHalHandle hHal;
2972 hdd_context_t *pHddCtx;
2973 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 struct iw_range *range = (struct iw_range *) extra;
2975
2976 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2977
2978 v_U32_t num_channels = sizeof(channels);
2979 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2980 v_U32_t a_len;
2981 v_U32_t b_len;
2982 v_U32_t active_phy_mode = 0;
2983 v_U8_t index = 0, i;
2984
2985 ENTER();
2986
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302987 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2988 if (NULL == pAdapter)
2989 {
2990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2991 "%s: pAdapter is NULL", __func__);
2992 return -EINVAL;
2993 }
2994 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2995 ret = wlan_hdd_validate_context(pHddCtx);
2996 if (0 != ret)
2997 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302998 return ret;
2999 }
3000 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3001 if (NULL == hHal)
3002 {
3003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3004 "%s: pAdapter is NULL", __func__);
3005 return -EINVAL;
3006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 wrqu->data.length = sizeof(struct iw_range);
3008 memset(range, 0, sizeof(struct iw_range));
3009
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 /*Get the phy mode*/
3011 if (ccmCfgGetInt(hHal,
3012 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3013 {
3014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003015 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003016
3017 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3018 {
3019 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003020 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 if (ccmCfgGetStr(hHal,
3022 WNI_CFG_SUPPORTED_RATES_11A,
3023 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3024 {
3025 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3026 {
3027 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3028 }
3029 for (i = 0; i < a_len; i++)
3030 {
3031 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3032 }
3033 range->num_bitrates = a_len;
3034 }
3035 else
3036 {
3037 return -EIO;
3038 }
3039 }
3040 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3041 {
3042 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003043 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 if (ccmCfgGetStr(hHal,
3045 WNI_CFG_SUPPORTED_RATES_11B,
3046 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3047 {
3048 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3049 {
3050 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3051 }
3052 for (i = 0; i < b_len; i++)
3053 {
3054 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3055 }
3056 range->num_bitrates = b_len;
3057 }
3058 else
3059 {
3060 return -EIO;
3061 }
3062 }
3063 }
3064
3065 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3066 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3067 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3068
3069 range->encoding_size[0] = 5;
3070 range->encoding_size[1] = 13;
3071 range->num_encoding_sizes = 2;
3072 range->max_encoding_tokens = MAX_WEP_KEYS;
3073
3074 // we support through Wireless Extensions 22
3075 range->we_version_compiled = WIRELESS_EXT;
3076 range->we_version_source = 22;
3077
3078 /*Supported Channels and Frequencies*/
3079 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3080 {
c_hpothub8245442013-11-20 23:41:09 +05303081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3082 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 return -EIO;
3084 }
3085 if (num_channels > IW_MAX_FREQUENCIES)
3086 {
3087 num_channels = IW_MAX_FREQUENCIES;
3088 }
3089
3090 range->num_channels = num_channels;
3091 range->num_frequency = num_channels;
3092
3093 for (index=0; index < num_channels; index++)
3094 {
3095 v_U32_t frq_indx = 0;
3096
3097 range->freq[index].i = channels[index];
3098 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3099 {
3100 if(channels[index] == freq_chan_map[frq_indx].chan)
3101 {
3102 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3103 range->freq[index].e = 1;
3104 break;
3105 }
3106 frq_indx++;
3107 }
3108 }
3109
3110 /* Event capability (kernel + driver) */
3111 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3112 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3113 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3114 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3115
3116 /*Encryption capability*/
3117 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3118 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3119
3120 /* Txpower capability */
3121 range->txpower_capa = IW_TXPOW_MWATT;
3122
3123 /*Scanning capability*/
3124 #if WIRELESS_EXT >= 22
3125 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3126 #endif
3127
3128 EXIT();
3129 return 0;
3130}
3131
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303132static int iw_get_range(struct net_device *dev,
3133 struct iw_request_info *info,
3134 union iwreq_data *wrqu, char *extra)
3135{
3136 int ret;
3137
3138 vos_ssr_protect(__func__);
3139 ret = __iw_get_range(dev, info, wrqu, extra);
3140 vos_ssr_unprotect(__func__);
3141
3142 return ret;
3143}
3144
Jeff Johnson295189b2012-06-20 16:38:30 -07003145/* Callback function registered with PMC to know status of PMC request */
3146static void iw_power_callback_fn (void *pContext, eHalStatus status)
3147{
3148 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003149
3150 if (NULL == pContext)
3151 {
3152 hddLog(VOS_TRACE_LEVEL_ERROR,
3153 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003154 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 return;
3156 }
3157
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003159
Jeff Johnson72a40512013-12-19 10:14:15 -08003160 /* there is a race condition that exists between this callback
3161 function and the caller since the caller could time out either
3162 before or while this code is executing. we use a spinlock to
3163 serialize these actions */
3164 spin_lock(&hdd_context_lock);
3165
3166 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 {
3168 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003169 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003171 "%s: Invalid context, magic [%08x]",
3172 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003173
3174 if (ioctl_debug)
3175 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003176 pr_info("%s: Invalid context, magic [%08x]\n",
3177 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 }
3179 return;
3180 }
3181
Jeff Johnson72a40512013-12-19 10:14:15 -08003182 /* context is valid so caller is still waiting */
3183
3184 /* paranoia: invalidate the magic */
3185 pStatsContext->magic = 0;
3186
3187 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003189
3190 /* serialization is complete */
3191 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003192}
3193
3194/* Callback function for tx per hit */
3195void hdd_tx_per_hit_cb (void *pCallbackContext)
3196{
3197 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3198 unsigned char tx_fail[16];
3199 union iwreq_data wrqu;
3200
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303201 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003203 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 return;
3205 }
3206 memset(&wrqu, 0, sizeof(wrqu));
3207 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3208 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3209}
3210
3211void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3212{
3213 struct statsContext *pStatsContext;
3214 tCsrGlobalClassAStatsInfo *pClassAStats;
3215 hdd_adapter_t *pAdapter;
3216
3217 if (ioctl_debug)
3218 {
3219 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003220 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 }
3222
3223 if ((NULL == pStats) || (NULL == pContext))
3224 {
3225 hddLog(VOS_TRACE_LEVEL_ERROR,
3226 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003227 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 return;
3229 }
3230
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 pClassAStats = pStats;
3232 pStatsContext = pContext;
3233 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003234
3235 /* there is a race condition that exists between this callback
3236 function and the caller since the caller could time out either
3237 before or while this code is executing. we use a spinlock to
3238 serialize these actions */
3239 spin_lock(&hdd_context_lock);
3240
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3242 {
3243 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003244 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 hddLog(VOS_TRACE_LEVEL_WARN,
3246 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003247 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 if (ioctl_debug)
3249 {
3250 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003251 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 }
3253 return;
3254 }
3255
Jeff Johnson72a40512013-12-19 10:14:15 -08003256 /* context is valid so caller is still waiting */
3257
3258 /* paranoia: invalidate the magic */
3259 pStatsContext->magic = 0;
3260
3261 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003262 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3263
Jeff Johnson72a40512013-12-19 10:14:15 -08003264 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003266
3267 /* serialization is complete */
3268 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003269}
3270
3271VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3272{
3273 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3274 eHalStatus hstatus;
3275 long lrc;
3276 struct statsContext context;
3277
3278 if (NULL == pAdapter)
3279 {
3280 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3281 return VOS_STATUS_E_FAULT;
3282 }
3283 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3284 {
3285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3286 return VOS_STATUS_SUCCESS;
3287 }
3288
3289 /* we are connected
3290 prepare our callback context */
3291 init_completion(&context.completion);
3292 context.pAdapter = pAdapter;
3293 context.magic = STATS_CONTEXT_MAGIC;
3294 /* query only for Class A statistics (which include link speed) */
3295 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3296 eCSR_HDD,
3297 SME_GLOBAL_CLASSA_STATS,
3298 hdd_GetClassA_statisticsCB,
3299 0, // not periodic
3300 FALSE, //non-cached results
3301 pHddStaCtx->conn_info.staId[0],
3302 &context);
3303 if (eHAL_STATUS_SUCCESS != hstatus)
3304 {
3305 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003306 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003307 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 /* we'll returned a cached value below */
3309 }
3310 else
3311 {
3312 /* request was sent -- wait for the response */
3313 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3314 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 if (lrc <= 0)
3316 {
3317 hddLog(VOS_TRACE_LEVEL_ERROR,
3318 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003319 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 }
3321 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003322
3323 /* either we never sent a request, we sent a request and received a
3324 response or we sent a request and timed out. if we never sent a
3325 request or if we sent a request and got a response, we want to
3326 clear the magic out of paranoia. if we timed out there is a
3327 race condition such that the callback function could be
3328 executing at the same time we are. of primary concern is if the
3329 callback function had already verified the "magic" but had not
3330 yet set the completion variable when a timeout occurred. we
3331 serialize these activities by invalidating the magic while
3332 holding a shared spinlock which will cause us to block if the
3333 callback is currently executing */
3334 spin_lock(&hdd_context_lock);
3335 context.magic = 0;
3336 spin_unlock(&hdd_context_lock);
3337
3338 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 return VOS_STATUS_SUCCESS;
3340}
3341
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003342static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3343{
3344 struct statsContext *pStatsContext;
3345 tCsrSummaryStatsInfo *pSummaryStats;
3346 tCsrGlobalClassAStatsInfo *pClassAStats;
3347 hdd_adapter_t *pAdapter;
3348
3349 if (ioctl_debug)
3350 {
3351 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003352 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003353 }
3354
3355 if ((NULL == pStats) || (NULL == pContext))
3356 {
3357 hddLog(VOS_TRACE_LEVEL_ERROR,
3358 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003359 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003360 return;
3361 }
3362
Jeff Johnson72a40512013-12-19 10:14:15 -08003363 /* there is a race condition that exists between this callback
3364 function and the caller since the caller could time out either
3365 before or while this code is executing. we use a spinlock to
3366 serialize these actions */
3367 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003368
3369 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3370 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3371 pStatsContext = pContext;
3372 pAdapter = pStatsContext->pAdapter;
3373 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3374 {
3375 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003376 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003377 hddLog(VOS_TRACE_LEVEL_WARN,
3378 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003379 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003380 if (ioctl_debug)
3381 {
3382 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003383 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003384 }
3385 return;
3386 }
3387
Jeff Johnson72a40512013-12-19 10:14:15 -08003388 /* context is valid so caller is still waiting */
3389
3390 /* paranoia: invalidate the magic */
3391 pStatsContext->magic = 0;
3392
3393 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003394 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3395 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3396
Jeff Johnson72a40512013-12-19 10:14:15 -08003397 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003398 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003399
3400 /* serialization is complete */
3401 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003402}
3403
3404VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3405{
3406 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3407 eHalStatus hstatus;
3408 long lrc;
3409 struct statsContext context;
3410
3411 if (NULL == pAdapter)
3412 {
3413 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3414 return VOS_STATUS_SUCCESS;
3415 }
3416
3417 /* we are connected
3418 prepare our callback context */
3419 init_completion(&context.completion);
3420 context.pAdapter = pAdapter;
3421 context.magic = STATS_CONTEXT_MAGIC;
3422
3423 /* query only for Summary & Class A statistics */
3424 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3425 eCSR_HDD,
3426 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303427 SME_GLOBAL_CLASSA_STATS |
3428 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003429 hdd_get_station_statisticsCB,
3430 0, // not periodic
3431 FALSE, //non-cached results
3432 pHddStaCtx->conn_info.staId[0],
3433 &context);
3434 if (eHAL_STATUS_SUCCESS != hstatus)
3435 {
3436 hddLog(VOS_TRACE_LEVEL_ERROR,
3437 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003438 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003439 /* we'll return with cached values */
3440 }
3441 else
3442 {
3443 /* request was sent -- wait for the response */
3444 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3445 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003446
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003447 if (lrc <= 0)
3448 {
3449 hddLog(VOS_TRACE_LEVEL_ERROR,
3450 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003451 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003452 }
3453 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003454
3455 /* either we never sent a request, we sent a request and received a
3456 response or we sent a request and timed out. if we never sent a
3457 request or if we sent a request and got a response, we want to
3458 clear the magic out of paranoia. if we timed out there is a
3459 race condition such that the callback function could be
3460 executing at the same time we are. of primary concern is if the
3461 callback function had already verified the "magic" but had not
3462 yet set the completion variable when a timeout occurred. we
3463 serialize these activities by invalidating the magic while
3464 holding a shared spinlock which will cause us to block if the
3465 callback is currently executing */
3466 spin_lock(&hdd_context_lock);
3467 context.magic = 0;
3468 spin_unlock(&hdd_context_lock);
3469
3470 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003471 return VOS_STATUS_SUCCESS;
3472}
3473
3474
Jeff Johnson295189b2012-06-20 16:38:30 -07003475/*
3476 * Support for the LINKSPEED private command
3477 * Per the WiFi framework the response must be of the form
3478 * "LinkSpeed xx"
3479 */
3480static int iw_get_linkspeed(struct net_device *dev,
3481 struct iw_request_info *info,
3482 union iwreq_data *wrqu, char *extra)
3483{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303484 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303485 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303487 int len = sizeof(v_U32_t) + 1;
3488 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303489 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303490 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303491 int rc, valid = 0;
3492
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303493 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303494 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3495 if (NULL == pAdapter)
3496 {
3497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3498 "%s: Adapter is NULL",__func__);
3499 return -EINVAL;
3500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003501
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303502 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303503 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303504 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003505 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303506 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003507 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303508 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3509 if (NULL == pHddStaCtx)
3510 {
3511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3512 "%s: STA Context is NULL",__func__);
3513 return -EINVAL;
3514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3516 {
3517 /* we are not connected so we don't have a classAstats */
3518 link_speed = 0;
3519 }
3520 else
3521 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303522 status = wlan_hdd_get_classAstats(pAdapter);
3523
3524 if (!VOS_IS_STATUS_SUCCESS(status ))
3525 {
3526 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3527 return -EINVAL;
3528 }
3529
3530 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3531 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3532 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3533 &link_speed);
3534
3535 link_speed = link_speed / 10;
3536
3537 if (0 == link_speed)
3538 {
3539 /* The linkspeed returned by HAL is in units of 500kbps.
3540 * converting it to mbps.
3541 * This is required to support legacy firmware which does
3542 * not return link capacity.
3543 */
3544 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3545 }
3546
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 }
3548
3549 wrqu->data.length = len;
3550 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003551 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 if ((rc < 0) || (rc >= len))
3553 {
3554 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303555 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 return -EIO;
3557 }
3558
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303559 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003561 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003562}
3563
Arif Hussain695279c2014-03-24 14:06:07 -07003564/*
3565 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3566 *
3567 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303568static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003569 struct iw_request_info *info,
3570 union iwreq_data *wrqu, char *extra)
3571{
3572 int rc;
3573
3574 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3575
3576 if (rc < 0)
3577 return rc;
3578
3579 /* a value is being successfully returned */
3580 return 0;
3581}
Jeff Johnson295189b2012-06-20 16:38:30 -07003582
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303583static int iw_get_linkspeed_priv(struct net_device *dev,
3584 struct iw_request_info *info,
3585 union iwreq_data *wrqu, char *extra)
3586{
3587 int ret;
3588
3589 vos_ssr_protect(__func__);
3590 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3591 vos_ssr_unprotect(__func__);
3592
3593 return ret;
3594}
3595
Jeff Johnson295189b2012-06-20 16:38:30 -07003596/*
3597 * Support for the RSSI & RSSI-APPROX private commands
3598 * Per the WiFi framework the response must be of the form
3599 * "<ssid> rssi <xx>"
3600 * unless we are not associated, in which case the response is
3601 * "OK"
3602 */
3603static int iw_get_rssi(struct net_device *dev,
3604 struct iw_request_info *info,
3605 union iwreq_data *wrqu, char *extra)
3606{
3607 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003608 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 int len = wrqu->data.length;
3610 v_S7_t s7Rssi = 0;
3611 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3612 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3613 VOS_STATUS vosStatus;
3614 int rc;
3615
3616 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3617 (0 == ssidlen) || (ssidlen >= len))
3618 {
3619 /* we are not connected or our SSID is too long
3620 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003621 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 }
3623 else
3624 {
3625 /* we are connected with a valid SSID
3626 so we can write the SSID into the return buffer
3627 (note that it is not NUL-terminated) */
3628 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3629
3630 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3631
3632 if (VOS_STATUS_SUCCESS == vosStatus)
3633 {
3634 /* append the rssi to the ssid in the format required by
3635 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003636 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303637 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 }
3639 else
3640 {
3641 rc = -1;
3642 }
3643 }
3644
3645 /* verify that we wrote a valid response */
3646 if ((rc < 0) || (rc >= len))
3647 {
3648 // encoding or length error?
3649 hddLog(VOS_TRACE_LEVEL_ERROR,
3650 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003651 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 return -EIO;
3653 }
3654
3655 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003656 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003657}
3658
3659/*
3660 * Support for SoftAP channel range private command
3661 */
3662static int iw_softap_set_channel_range( struct net_device *dev,
3663 int startChannel,
3664 int endChannel,
3665 int band)
3666{
Jeff Johnson43971f52012-07-17 12:26:56 -07003667 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003668 int ret = 0;
3669 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3670 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003671 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3672
Jeff Johnson295189b2012-06-20 16:38:30 -07003673
3674 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3675 if (VOS_STATUS_SUCCESS != status)
3676 {
3677 ret = -EINVAL;
3678 }
Yathish9f22e662012-12-10 14:21:35 -08003679 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 return ret;
3681}
3682
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303683static uint8 chartohex(char c)
3684{
3685 uint8 val = 0;
3686 if (c >= '0' && c <= '9')
3687 val = c - '0';
3688 else if (c >= 'a' && c <= 'f')
3689 val = c - 'a' + 10;
3690 else if (c >= 'A' && c <= 'F')
3691 val = c - 'A' + 10;
3692 else
3693 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3694
3695 return val;
3696}
3697
3698uint8 getByte(char **buf)
3699{
3700 uint8 byte = 0;
3701 char *temp = *buf;
3702 byte = chartohex(*temp) * 16;
3703 temp++;
3704 byte += chartohex(*temp);
3705 temp++;
3706 *buf = temp;
3707 return byte;
3708}
3709
3710static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3711{
3712 tSir80211Header *macHeader;
3713 int i = 0, j = 0, length = 0;
3714 uint8 byte = 0;
3715 char *temp = pBuffer;
3716 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303717 char *pHeader;
3718 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303719
3720 macHeader = &pkt->macHeader;
3721
3722 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3723
3724 temp++;
3725
3726 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3727 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3728 pkt->encParams.keyParams.key[0].keyId);
3729
3730 for (i = 0; i< 16; i++) {
3731 pkt->encParams.keyParams.key[0].key[i]
3732 = getByte(&temp);
3733 }
3734
3735 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3736 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3737
3738 for (i = 0; i< 6; i++) {
3739 pkt->encParams.pn[i]
3740 = getByte(&temp);
3741 }
3742
3743 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3744 &pkt->encParams.pn[0], 6, 0);
3745
3746 for (i = 0, j= 5; i< 3; i++, j--) {
3747 byte = pkt->encParams.pn[i];
3748 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3749 pkt->encParams.pn[j] = byte;
3750 }
3751
3752 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303753 if (length > sizeof(tSir80211Header))
3754 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303755
Srinivas Dasari2382de62015-01-22 15:00:04 +05303756 pHeader = temp;
3757 vos_mem_zero(&header, sizeof(tSir80211Header));
3758 for (i = 0; i < length; i++) {
3759 *((uint8 *)&header + i) = getByte(&pHeader);
3760 }
3761
3762 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3763 (char *)&header, length, 0);
3764
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303765 byte = getByte(&temp);
3766
3767 macHeader->frameCtrl.protVer = byte & 0x3;
3768 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3769 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3770
3771 byte = getByte(&temp);
3772 macHeader->frameCtrl.toDS = (byte) & 0x1;
3773 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3774 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3775 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3776 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3777 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3778 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3779 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3780
3781 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3782 "macHeader->frameCtrl.type : %x "
3783 "macHeader->frameCtrl.subType : %x "
3784 "macHeader->frameCtrl.toDS : %x "
3785 "macHeader->frameCtrl.fromDS : %x "
3786 "macHeader->frameCtrl.moreFrag : %x "
3787 "macHeader->frameCtrl.retry : %x "
3788 "macHeader->frameCtrl.powerMgmt : %x "
3789 "macHeader->frameCtrl.MoreData : %x "
3790 "macHeader->frameCtrl.wep : %x "
3791 "macHeader->frameCtrl.order : %x "
3792 , macHeader->frameCtrl.protVer
3793 , macHeader->frameCtrl.type
3794 , macHeader->frameCtrl.subType
3795 , macHeader->frameCtrl.toDS
3796 , macHeader->frameCtrl.fromDS
3797 , macHeader->frameCtrl.moreFrag
3798 , macHeader->frameCtrl.retry
3799 , macHeader->frameCtrl.powerMgmt
3800 , macHeader->frameCtrl.moreData
3801 , macHeader->frameCtrl.wep
3802 , macHeader->frameCtrl.order);
3803
3804
3805 macHeader->usDurationId = getByte(&temp);
3806 macHeader->usDurationId += getByte(&temp) << 8;
3807
3808 macHeader->vA1[0] = getByte(&temp);
3809 macHeader->vA1[1] = getByte(&temp);
3810 macHeader->vA1[2] = getByte(&temp);
3811 macHeader->vA1[3] = getByte(&temp);
3812 macHeader->vA1[4] = getByte(&temp);
3813 macHeader->vA1[5] = getByte(&temp);
3814
3815 macHeader->vA2[0] = getByte(&temp);
3816 macHeader->vA2[1] = getByte(&temp);
3817 macHeader->vA2[2] = getByte(&temp);
3818 macHeader->vA2[3] = getByte(&temp);
3819 macHeader->vA2[4] = getByte(&temp);
3820 macHeader->vA2[5] = getByte(&temp);
3821
3822 macHeader->vA3[0] = getByte(&temp);
3823 macHeader->vA3[1] = getByte(&temp);
3824 macHeader->vA3[2] = getByte(&temp);
3825 macHeader->vA3[3] = getByte(&temp);
3826 macHeader->vA3[4] = getByte(&temp);
3827 macHeader->vA3[5] = getByte(&temp);
3828
3829 macHeader->sSeqCtrl = getByte(&temp);
3830 fragNum = macHeader->sSeqCtrl & 0xF;
3831 macHeader->sSeqCtrl >>= 4;
3832
3833 macHeader->sSeqCtrl += getByte(&temp) << 4;
3834
3835 macHeader->sSeqCtrl |= fragNum << 12;
3836
3837 if (length == 30 || length == 32) {
3838 macHeader->optvA4[0] = getByte(&temp);
3839 macHeader->optvA4[1] = getByte(&temp);
3840 macHeader->optvA4[2] = getByte(&temp);
3841 macHeader->optvA4[3] = getByte(&temp);
3842 macHeader->optvA4[4] = getByte(&temp);
3843 macHeader->optvA4[5] = getByte(&temp);
3844 }
3845
3846 if (length == 26 || length == 32) {
3847 macHeader->usQosCtrl = getByte(&temp);
3848 macHeader->usQosCtrl += getByte(&temp) << 8;
3849 }
3850
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303851 //parse payload
3852 length = getByte(&temp);
3853 length += getByte(&temp) << 8;
3854 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3855
3856 pkt->data.length = length;
3857
3858 for (i = 0; i< length; i++) {
3859 pkt->data.data[i] = getByte(&temp);
3860 }
3861
3862 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3863 &pkt->data.data[0], pkt->data.length, 0);
3864}
3865
3866/**---------------------------------------------------------------------------
3867
3868 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3869 encrypt message request
3870 This is an asynchronous callback function from SME when the encrypted data
3871 is received
3872
3873 \pEncInfoRsp -> Encrypted data info
3874
3875 \return - 0 for success non-zero for failure
3876 --------------------------------------------------------------------------*/
3877static void
3878hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3879{
3880 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3881
3882 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3883
3884 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3885 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3886 pEncryptedDataRsp->encryptedPayload.length);
3887 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3888 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3889 pEncryptedDataRsp->encryptedPayload.data,
3890 pEncryptedDataRsp->encryptedPayload.length, 0);
3891}
3892
Jeff Johnson295189b2012-06-20 16:38:30 -07003893VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3894{
3895 struct statsContext context;
3896 eHalStatus status;
3897 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303898 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003899
3900 if (NULL == pAdapter)
3901 {
3902 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3903 return VOS_STATUS_E_FAULT;
3904 }
3905
3906 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3907 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303908 if (pHddCtx->isLogpInProgress) {
3909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3910 "%s:LOGP in Progress. Ignore!!!", __func__);
3911 return VOS_STATUS_E_FAILURE;
3912 }
3913
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 init_completion(&context.completion);
3915
3916 context.pAdapter = pAdapter;
3917 context.magic = POWER_CONTEXT_MAGIC;
3918
3919 if (DRIVER_POWER_MODE_ACTIVE == mode)
3920 {
3921 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3922 "Full Power", __func__);
3923 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3924 iw_power_callback_fn, &context,
3925 eSME_FULL_PWR_NEEDED_BY_HDD);
3926 // Enter Full power command received from GUI this means we are disconnected
3927 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3928 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3929 if (eHAL_STATUS_PMC_PENDING == status)
3930 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003931 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 int lrc = wait_for_completion_interruptible_timeout(
3933 &context.completion,
3934 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003935
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 if (lrc <= 0)
3937 {
3938 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003939 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003940 }
3941 }
3942 }
3943 else if (DRIVER_POWER_MODE_AUTO == mode)
3944 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303945 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
3946 * was already in BMPS state and thus either STA or P2P-CLI is in
3947 * associated state and authenticated, so even if STA connState is
3948 * not associated it can be assumed that P2P-CLI is associated and
3949 * authenticated. Thus driver can enter BMPS. And even if we try to enter
3950 * BMPS with no adaptor in associated state, pmcRequestBmps will check
3951 * if all condition are satisfied for entering BMPS.
3952 */
3953 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
3954 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303955 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303956 hddLog(LOGE,
3957 FL("Station is associated but, still not Authenticated ignore "
3958 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303959 return VOS_STATUS_E_AGAIN;
3960 }
3961
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3963 {
3964 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3965 __func__);
3966 // Enter BMPS command received from GUI this means DHCP is completed
3967 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3968 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3969 FALSE);
3970 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3971 iw_power_callback_fn, &context);
3972 if (eHAL_STATUS_PMC_PENDING == status)
3973 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003974 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 int lrc = wait_for_completion_interruptible_timeout(
3976 &context.completion,
3977 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 if (lrc <= 0)
3979 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003980 hddLog(VOS_TRACE_LEVEL_ERROR,
3981 "%s: SME %s while requesting BMPS",
3982 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 }
3984 }
3985 }
3986 else
3987 {
3988 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3989 "enabled in the cfg");
3990 }
3991 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003992
3993 /* either we never sent a request, we sent a request and received a
3994 response or we sent a request and timed out. if we never sent a
3995 request or if we sent a request and got a response, we want to
3996 clear the magic out of paranoia. if we timed out there is a
3997 race condition such that the callback function could be
3998 executing at the same time we are. of primary concern is if the
3999 callback function had already verified the "magic" but had not
4000 yet set the completion variable when a timeout occurred. we
4001 serialize these activities by invalidating the magic while
4002 holding a shared spinlock which will cause us to block if the
4003 callback is currently executing */
4004 spin_lock(&hdd_context_lock);
4005 context.magic = 0;
4006 spin_unlock(&hdd_context_lock);
4007
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 return VOS_STATUS_SUCCESS;
4009}
4010
4011VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4012 hdd_adapter_t *pAdapter)
4013{
4014 VOS_STATUS vos_Status;
4015
4016 if ((NULL == pAdapter) || (NULL == pHddCtx))
4017 {
4018 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4019 return VOS_STATUS_E_FAULT;
4020 }
4021
4022 /**Exit from Deep sleep or standby if we get the driver
4023 START cmd from android GUI
4024 */
4025 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4026 {
4027 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4028 "from Stand by",__func__);
4029 vos_Status = hdd_exit_standby(pHddCtx);
4030 }
4031 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4032 {
4033 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4034 "from deep sleep",__func__);
4035 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4036 }
4037 else
4038 {
4039 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4040 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4041 vos_Status = VOS_STATUS_SUCCESS;
4042 }
4043
4044 return vos_Status;
4045}
4046
4047VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4048{
4049 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4050
4051 if (NULL == pHddCtx)
4052 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304053 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 return VOS_STATUS_E_FAULT;
4055 }
4056
4057 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4058 {
4059 //Execute standby procedure.
4060 //Executing standby procedure will cause the STA to
4061 //disassociate first and then the chip will be put into standby.
4062 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4063 vos_Status = hdd_enter_standby(pHddCtx);
4064 }
4065 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4066 pHddCtx->cfg_ini->nEnableDriverStop)
4067 {
4068 //Execute deep sleep procedure
4069 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004070 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 //Deep sleep not supported
4072 vos_Status = hdd_enter_standby(pHddCtx);
4073 }
4074 else
4075 {
4076 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4077 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4078 vos_Status = VOS_STATUS_SUCCESS;
4079 }
4080
4081 return vos_Status;
4082}
4083
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004084
4085void* wlan_hdd_change_country_code_callback(void *pAdapter)
4086{
4087
4088 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004089 complete(&call_back_pAdapter->change_country_code);
4090
4091 return NULL;
4092}
4093
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304094static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 struct iw_request_info *info,
4096 union iwreq_data *wrqu, char *extra)
4097{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304098 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004099 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004100 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304101 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004102 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4103
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304104 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004105
4106 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304107
4108 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4109 if (NULL == pAdapter)
4110 {
4111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4112 "mem_alloc_copy_from_user_helper fail");
4113 return -EINVAL;
4114 }
4115 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4116 rc = wlan_hdd_validate_context(pHddCtx);
4117 if (0 != rc)
4118 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304119 return rc;
4120 }
4121
Arif Hussain24bfa702014-01-22 13:51:30 -08004122 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4123 wrqu->data.length);
4124 if (NULL == cmd)
4125 {
4126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4127 "mem_alloc_copy_from_user_helper fail");
4128 return -ENOMEM;
4129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004130
4131 if (ioctl_debug)
4132 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004133 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 }
4135
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004136 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4137 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004138
Arif Hussain24bfa702014-01-22 13:51:30 -08004139 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004141 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4143 "%s: Error in iw_set_scan!", __func__);
4144 rc = -EINVAL;
4145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 }
4147 else if( strcasecmp(cmd, "start") == 0 ) {
4148
Arif Hussain6d2a3322013-11-17 19:50:10 -08004149 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004151
Arif Hussain24bfa702014-01-22 13:51:30 -08004152 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4153 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 {
4155 union iwreq_data wrqu;
4156 char buf[10];
4157
4158 memset(&wrqu, 0, sizeof(wrqu));
4159 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4160 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4161 }
4162 else
4163 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004164 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4165 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 }
4167 goto done;
4168 }
4169 else if( strcasecmp(cmd, "stop") == 0 )
4170 {
4171 union iwreq_data wrqu;
4172 char buf[10];
4173
Arif Hussain6d2a3322013-11-17 19:50:10 -08004174 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004175
4176 wlan_hdd_enter_lowpower(pHddCtx);
4177 memset(&wrqu, 0, sizeof(wrqu));
4178 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4179 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 goto done;
4181 }
4182 else if (strcasecmp(cmd, "macaddr") == 0)
4183 {
4184 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4185 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4186 }
4187 else if (strcasecmp(cmd, "scan-active") == 0)
4188 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05304189 hddLog(LOG1,
4190 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004191 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 ret = snprintf(cmd, cmd_len, "OK");
4193 }
4194 else if (strcasecmp(cmd, "scan-passive") == 0)
4195 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05304196 hddLog(LOG1,
4197 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004198 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 ret = snprintf(cmd, cmd_len, "OK");
4200 }
4201 else if( strcasecmp(cmd, "scan-mode") == 0 )
4202 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004203 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 }
4205 else if( strcasecmp(cmd, "linkspeed") == 0 )
4206 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004207 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 }
4209 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4210 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004211 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004212 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004213
4214 country_code = cmd + 8;
4215
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004216 init_completion(&pAdapter->change_country_code);
4217
Arif Hussain24bfa702014-01-22 13:51:30 -08004218 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004219 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 country_code,
4221 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304222 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304223 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304224 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004225
4226 /* Wait for completion */
4227 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4228 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4229
4230 if (lrc <= 0)
4231 {
4232 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004233 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004234 }
4235
Arif Hussain24bfa702014-01-22 13:51:30 -08004236 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004238 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004239 "%s: SME Change Country code fail", __func__);
4240 kfree(cmd);
4241 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 }
4243 }
4244 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4245 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004246 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 }
4248 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4249 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004250 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004251
Wilson Yang1be3e652013-10-09 15:18:31 -07004252 if (9 < cmd_len)
4253 {
4254 ptr = (char*)(cmd + 9);
4255
4256 }else{
4257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4258 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004259 kfree(cmd);
4260 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004261 }
4262
4263 if (1 != sscanf(ptr,"%d",&mode))
4264 {
4265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4266 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004267 kfree(cmd);
4268 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004269 }
4270
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 wlan_hdd_enter_bmps(pAdapter, mode);
4272 /*TODO:Set the power mode*/
4273 }
4274 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4275 v_U32_t pmc_state;
4276 v_U16_t value;
4277
4278 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4279 if(pmc_state == BMPS) {
4280 value = DRIVER_POWER_MODE_AUTO;
4281 }
4282 else {
4283 value = DRIVER_POWER_MODE_ACTIVE;
4284 }
4285 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4286 }
4287 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004288 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 /*TODO: set the btcoexmode*/
4290 }
4291 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4292
Arif Hussain6d2a3322013-11-17 19:50:10 -08004293 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 /*TODO: Return the btcoex status*/
4295 }
4296 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4297
Arif Hussain6d2a3322013-11-17 19:50:10 -08004298 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004299
4300 /*TODO: Enable Rx data Filter*/
4301 }
4302 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4303
Arif Hussain6d2a3322013-11-17 19:50:10 -08004304 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004305
4306 /*TODO: Disable Rx data Filter*/
4307 }
4308 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4309
Arif Hussain6d2a3322013-11-17 19:50:10 -08004310 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 /*TODO: rxfilter-statistics*/
4312 }
4313 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4314
Arif Hussain6d2a3322013-11-17 19:50:10 -08004315 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 /*TODO: rxfilter-add*/
4317 }
4318 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4319
Arif Hussain6d2a3322013-11-17 19:50:10 -08004320 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 /*TODO: rxfilter-remove*/
4322 }
4323#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004324 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4325 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4326 /*TODO: support pnosetup*/
4327 }
4328 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4329 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4330 /*TODO: support pnoforce*/
4331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4333
Arif Hussain6d2a3322013-11-17 19:50:10 -08004334 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004335 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4336 kfree(cmd);
4337 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 }
4339 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004340 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004341 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4342 kfree(cmd);
4343 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 }
4345#endif /*FEATURE_WLAN_SCAN_PNO*/
4346 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004347 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004348 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4349 kfree(cmd);
4350 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 }
4352 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4353 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004354 char *ptr;
4355
4356 if (18 < cmd_len)
4357 {
4358 ptr = (char*)(cmd + 18);
4359 }else{
4360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4361 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004362 kfree(cmd);
4363 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004364 }
4365
Jeff Johnson02797792013-10-26 19:17:13 -07004366 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004367 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4368 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4369 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4370 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4371 {
4372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4373 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004374 kfree(cmd);
4375 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004377
4378 // parameters checking
4379 // period has to be larger than 0
4380 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4381 {
4382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004383 kfree(cmd);
4384 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 }
4386
4387 // use default value 5 is the input is not reasonable. in unit of 10%
4388 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4389 {
4390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4391 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4392 }
4393
4394 // default is 5
4395 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4396 {
4397 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4398 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4399 }
4400
Arif Hussain24bfa702014-01-22 13:51:30 -08004401 if (eHAL_STATUS_SUCCESS !=
4402 sme_SetTxPerTracking(pHddCtx->hHal,
4403 hdd_tx_per_hit_cb,
4404 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004406 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 }
4408 }
4409 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004410 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4411 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 }
4413done:
4414 /* many of the commands write information back into the command
4415 string using snprintf(). check the return value here in one
4416 place */
4417 if ((ret < 0) || (ret >= cmd_len))
4418 {
4419 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004420 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004422 else if (ret > 0)
4423 {
4424 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4425 {
4426 hddLog(VOS_TRACE_LEVEL_ERROR,
4427 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004428 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004429 return -EFAULT;
4430 }
4431 wrqu->data.length = ret;
4432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004433
4434 if (ioctl_debug)
4435 {
4436 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004437 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004439 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304440 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004441 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004442}
4443
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304444static int iw_set_priv(struct net_device *dev,
4445 struct iw_request_info *info,
4446 union iwreq_data *wrqu, char *extra)
4447{
4448 int ret;
4449 vos_ssr_protect(__func__);
4450 ret = __iw_set_priv(dev, info, wrqu, extra);
4451 vos_ssr_unprotect(__func__);
4452
4453 return ret;
4454}
4455
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304456static int __iw_set_nick(struct net_device *dev,
4457 struct iw_request_info *info,
4458 union iwreq_data *wrqu, char *extra)
4459{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304460 hdd_adapter_t *pAdapter;
4461 hdd_context_t *pHddCtx;
4462 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304463
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304464 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304465
4466 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4467 if (NULL == pAdapter)
4468 {
4469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4470 "%s: Adapter is NULL",__func__);
4471 return -EINVAL;
4472 }
4473
4474 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4475 ret = wlan_hdd_validate_context(pHddCtx);
4476 if (0 != ret)
4477 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304478 return ret;
4479 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304480 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304481 return 0;
4482}
4483
Jeff Johnson295189b2012-06-20 16:38:30 -07004484static int iw_set_nick(struct net_device *dev,
4485 struct iw_request_info *info,
4486 union iwreq_data *wrqu, char *extra)
4487{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304488 int ret;
4489
4490 vos_ssr_protect(__func__);
4491 ret = __iw_set_nick(dev, info, wrqu, extra);
4492 vos_ssr_unprotect(__func__);
4493
4494 return ret;
4495}
4496
4497static int __iw_get_nick(struct net_device *dev,
4498 struct iw_request_info *info,
4499 union iwreq_data *wrqu, char *extra)
4500{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304501 hdd_adapter_t *pAdapter;
4502 hdd_context_t *pHddCtx;
4503 int ret = 0;
4504
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304506
4507 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4508 if (NULL == pAdapter)
4509 {
4510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4511 "%s: Adapter is NULL",__func__);
4512 return -EINVAL;
4513 }
4514
4515 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4516 ret = wlan_hdd_validate_context(pHddCtx);
4517 if (0 != ret)
4518 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304519 return ret;
4520 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304521 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 return 0;
4523}
4524
4525static int iw_get_nick(struct net_device *dev,
4526 struct iw_request_info *info,
4527 union iwreq_data *wrqu, char *extra)
4528{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304529 int ret;
4530
4531 vos_ssr_protect(__func__);
4532 ret = __iw_get_nick(dev, info, wrqu, extra);
4533 vos_ssr_unprotect(__func__);
4534
4535 return ret;
4536}
4537
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304538/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304539static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4540{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304541 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4542 hdd_context_t *pHddCtx;
4543 hdd_station_ctx_t *pHddStaCtx;
4544 v_S7_t snr = 0, rssi = 0;
4545 eHalStatus status = eHAL_STATUS_SUCCESS;
4546
4547 ENTER();
4548
4549 if (NULL == pAdapter)
4550 {
4551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4552 "%s: Adapter is NULL",__func__);
4553 return NULL;
4554 }
4555
4556 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4557 status = wlan_hdd_validate_context(pHddCtx);
4558 if (0 != status)
4559 {
4560 return NULL;
4561 }
4562
4563 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4564 if (NULL == pHddStaCtx)
4565 {
4566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4567 "%s: STA Context is NULL",__func__);
4568 return NULL;
4569 }
4570
4571 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4572 {
4573 wlan_hdd_get_station_stats(pAdapter);
4574 wlan_hdd_get_snr(pAdapter, &snr);
4575 wlan_hdd_get_rssi(pAdapter, &rssi);
4576
4577 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4578 pAdapter->iwStats.status = 0;
4579 pAdapter->iwStats.qual.qual = snr;
4580 pAdapter->iwStats.qual.level = rssi;
4581 pAdapter->iwStats.qual.noise = rssi - snr;
4582 pAdapter->iwStats.discard.code = 0;
4583 pAdapter->iwStats.discard.retries= 0;
4584 pAdapter->iwStats.miss.beacon = 0;
4585 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4586 }
4587 else
4588 {
4589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4590 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4591 return NULL;
4592 }
4593
4594 EXIT();
4595 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004596}
4597
4598static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4599{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304600
4601 struct iw_statistics *stats;
4602
4603 vos_ssr_protect(__func__);
4604 stats = __get_wireless_stats(dev);
4605 vos_ssr_unprotect(__func__);
4606
4607 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004608}
4609
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304610static int __iw_set_encode(struct net_device *dev,
4611 struct iw_request_info *info,
4612 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004613
4614{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304615 hdd_adapter_t *pAdapter;
4616 hdd_station_ctx_t *pHddStaCtx;
4617 hdd_wext_state_t *pWextState;
4618 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004619 struct iw_point *encoderq = &(wrqu->encoding);
4620 v_U32_t keyId;
4621 v_U8_t key_length;
4622 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4623 v_BOOL_t fKeyPresent = 0;
4624 int i;
4625 eHalStatus status = eHAL_STATUS_SUCCESS;
4626
4627
4628 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304629 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4630 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4633 "%s: Adapter is NULL",__func__);
4634 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 }
4636
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304637 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4638 status = wlan_hdd_validate_context(pHddCtx);
4639 if (0 != status)
4640 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304641 return status;
4642 }
4643 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4644 if (NULL == pWextState)
4645 {
4646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4647 "%s: pWextState is NULL ",__func__);
4648 return -EINVAL;
4649 }
4650 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4651 if (NULL == pHddStaCtx)
4652 {
4653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4654 "%s: STA Context is NULL",__func__);
4655 return -EINVAL;
4656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004657
4658 keyId = encoderq->flags & IW_ENCODE_INDEX;
4659
4660 if(keyId)
4661 {
4662 if(keyId > MAX_WEP_KEYS)
4663 {
4664 return -EINVAL;
4665 }
4666
4667 fKeyPresent = 1;
4668 keyId--;
4669 }
4670 else
4671 {
4672 fKeyPresent = 0;
4673 }
4674
4675
4676 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4677 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 if(!fKeyPresent) {
4680
4681 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4682
4683 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4684 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4685 }
4686 }
4687 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4688 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4689 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4690 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4691
4692 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4693 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4694
4695 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4696 {
4697 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4698 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004699 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304700 {
4701 long ret;
4702 ret = wait_for_completion_interruptible_timeout(
4703 &pAdapter->disconnect_comp_var,
4704 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4705 if (ret <= 0)
4706 hddLog(VOS_TRACE_LEVEL_ERROR,
4707 FL("failed wait on disconnect_comp_var %ld"), ret);
4708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 }
4710
4711 return status;
4712
4713 }
4714
4715 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4716 {
4717 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4718
4719 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4720
4721 }
4722
4723
4724 if(wrqu->data.length > 0)
4725 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004726 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004727
4728 key_length = wrqu->data.length;
4729
4730 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4731
4732 if(5 == key_length)
4733 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004734 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004735
4736 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4737 {
4738 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4739 }
4740 else
4741 {
4742 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4743 }
4744 }
4745 else if(13 == key_length)
4746 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004747 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004748
4749 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4750 {
4751 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4752 }
4753 else
4754 {
4755 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4756 }
4757 }
4758 else
4759 {
4760 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004761 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 return -EINVAL;
4763 }
4764
4765 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4766 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4767 pWextState->roamProfile.EncryptionType.numEntries = 1;
4768 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4769 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4770 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4771
4772 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4773 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4774 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4775 {
4776
4777 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4778
4779 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4780 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4781
4782 return status;
4783 }
4784 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304785 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004786 return 0;
4787}
4788
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304789static int iw_set_encode(struct net_device *dev,
4790 struct iw_request_info *info,
4791 union iwreq_data *wrqu,char *extra)
4792{
4793 int ret;
4794
4795 vos_ssr_protect(__func__);
4796 ret = __iw_set_encode(dev, info, wrqu, extra);
4797 vos_ssr_unprotect(__func__);
4798
4799 return ret;
4800}
4801
4802static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 struct iw_request_info *info,
4804 struct iw_point *dwrq,
4805 char *extra)
4806{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304807 hdd_adapter_t *pAdapter;
4808 hdd_wext_state_t *pWextState;
4809 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 int keyId;
4811 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4812 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304813 int i, ret = 0;
4814 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004815
4816 ENTER();
4817
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304818 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4819 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004820 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4822 "%s: Adapter is NULL",__func__);
4823 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004824 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304825 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4826 ret = wlan_hdd_validate_context(pHddCtx);
4827 if (0 != ret)
4828 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304829 return ret;
4830 }
4831 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4832 if (NULL == pWextState)
4833 {
4834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4835 "%s: pWextState is NULL",__func__);
4836 return -EINVAL;
4837 }
4838 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004839
Jeff Johnson295189b2012-06-20 16:38:30 -07004840 keyId = pRoamProfile->Keys.defaultIndex;
4841
4842 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4843 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004844 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 return -EINVAL;
4846 }
4847
4848 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4849 {
4850 dwrq->flags |= IW_ENCODE_ENABLED;
4851 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304852 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4853 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 }
4855 else
4856 {
4857 dwrq->flags |= IW_ENCODE_DISABLED;
4858 }
4859
4860 for(i=0; i < MAX_WEP_KEYS; i++)
4861 {
4862 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4863 {
4864 continue;
4865 }
4866 else
4867 {
4868 break;
4869 }
4870 }
4871
4872 if(MAX_WEP_KEYS == i)
4873 {
4874 dwrq->flags |= IW_ENCODE_NOKEY;
4875 }
4876 else
4877 {
4878 dwrq->flags |= IW_ENCODE_ENABLED;
4879 }
4880
4881 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4882
4883 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4884 {
4885 dwrq->flags |= IW_ENCODE_DISABLED;
4886 }
4887
4888 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4889
4890 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4891 {
4892 dwrq->flags |= IW_ENCODE_OPEN;
4893 }
4894 else
4895 {
4896 dwrq->flags |= IW_ENCODE_RESTRICTED;
4897 }
4898 EXIT();
4899 return 0;
4900
4901}
4902
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304903static int iw_get_encodeext(struct net_device *dev,
4904 struct iw_request_info *info,
4905 struct iw_point *dwrq,
4906 char *extra)
4907{
4908 int ret;
4909 vos_ssr_protect(__func__);
4910 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4911 vos_ssr_unprotect(__func__);
4912
4913 return ret;
4914}
4915
4916static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 struct iw_request_info *info,
4918 union iwreq_data *wrqu, char *extra)
4919{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304920 hdd_adapter_t *pAdapter;
4921 hdd_station_ctx_t *pHddStaCtx;
4922 hdd_wext_state_t *pWextState;
4923 hdd_context_t *pHddCtx;
4924 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004925
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304926 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 v_U32_t status = 0;
4928
4929 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4930
4931 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4932
4933 int key_index;
4934 struct iw_point *encoding = &wrqu->encoding;
4935 tCsrRoamSetKey setKey;
4936 v_U32_t roamId= 0xFF;
4937 VOS_STATUS vos_status;
4938
4939 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304940 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4941 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4944 "%s: Adapter is NULL",__func__);
4945 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304947 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4948 status = wlan_hdd_validate_context(pHddCtx);
4949 if (0 != status)
4950 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304951 return status;
4952 }
4953 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4954 if (NULL == pHddStaCtx)
4955 {
4956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4957 "%s: STA Context is NULL",__func__);
4958 return -EINVAL;
4959 }
4960 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4961 if (NULL == pWextState)
4962 {
4963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4964 "%s: pWextState is NULL",__func__);
4965 return -EINVAL;
4966 }
4967 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 key_index = encoding->flags & IW_ENCODE_INDEX;
4969
4970 if(key_index > 0) {
4971
4972 /*Convert from 1-based to 0-based keying*/
4973 key_index--;
4974 }
4975 if(!ext->key_len) {
4976
4977 /*Set the encrytion type to NONE*/
4978 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4979 return status;
4980 }
4981
4982 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4983 (IW_ENCODE_ALG_WEP == ext->alg))
4984 {
4985 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4986
Agarwal Ashish971c2882013-10-30 20:11:12 +05304987 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4988 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 return -EINVAL;
4990 }
4991 else {
4992 /*Static wep, update the roam profile with the keys */
4993 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4994 key_index < CSR_MAX_NUM_KEY) {
4995 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4996 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4997
4998 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4999 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5000
5001 }
5002 }
5003 return status;
5004 }
5005
5006 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5007
5008 setKey.keyId = key_index;
5009 setKey.keyLength = ext->key_len;
5010
5011 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5012 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5013 }
5014
5015 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5016 /*Key direction for group is RX only*/
5017 setKey.keyDirection = eSIR_RX_ONLY;
5018 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5019 }
5020 else {
5021
5022 setKey.keyDirection = eSIR_TX_RX;
5023 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5024 }
5025
5026 /*For supplicant pae role is zero*/
5027 setKey.paeRole = 0;
5028
5029 switch(ext->alg)
5030 {
5031 case IW_ENCODE_ALG_NONE:
5032 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5033 break;
5034
5035 case IW_ENCODE_ALG_WEP:
5036 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5037 break;
5038
5039 case IW_ENCODE_ALG_TKIP:
5040 {
5041 v_U8_t *pKey = &setKey.Key[0];
5042
5043 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5044
5045 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5046
5047 /*Supplicant sends the 32bytes key in this order
5048
5049 |--------------|----------|----------|
5050 | Tk1 |TX-MIC | RX Mic |
5051 |--------------|----------|----------|
5052 <---16bytes---><--8bytes--><--8bytes-->
5053
5054 */
5055 /*Sme expects the 32 bytes key to be in the below order
5056
5057 |--------------|----------|----------|
5058 | Tk1 |RX-MIC | TX Mic |
5059 |--------------|----------|----------|
5060 <---16bytes---><--8bytes--><--8bytes-->
5061 */
5062 /* Copy the Temporal Key 1 (TK1) */
5063 vos_mem_copy(pKey,ext->key,16);
5064
5065 /*Copy the rx mic first*/
5066 vos_mem_copy(&pKey[16],&ext->key[24],8);
5067
5068 /*Copy the tx mic */
5069 vos_mem_copy(&pKey[24],&ext->key[16],8);
5070
5071 }
5072 break;
5073
5074 case IW_ENCODE_ALG_CCMP:
5075 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5076 break;
5077
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005078#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005079#define IW_ENCODE_ALG_KRK 6
5080 case IW_ENCODE_ALG_KRK:
5081 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5082 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005083#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005084
5085 default:
5086 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5087 break;
5088 }
5089
5090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005091 ("%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 -07005092
5093#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305094 /* The supplicant may attempt to set the PTK once pre-authentication
5095 is done. Save the key in the UMAC and include it in the ADD
5096 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305098 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305100 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5101 "%s: Update PreAuth Key success", __func__);
5102 return 0;
5103 }
5104 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5105 {
5106 hddLog(VOS_TRACE_LEVEL_ERROR,
5107 "%s: Update PreAuth Key failed", __func__);
5108 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005109 }
5110#endif /* WLAN_FEATURE_VOWIFI_11R */
5111
5112 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5113
5114 vos_status = wlan_hdd_check_ula_done(pAdapter);
5115 if ( vos_status != VOS_STATUS_SUCCESS )
5116 {
5117 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5118 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5119 __LINE__, vos_status );
5120
5121 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5122 }
5123
5124 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5125
5126 if ( halStatus != eHAL_STATUS_SUCCESS )
5127 {
5128 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5129 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5130 __LINE__, halStatus );
5131
5132 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5133 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305134 EXIT();
5135 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005136}
5137
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305138static int iw_set_encodeext(struct net_device *dev,
5139 struct iw_request_info *info,
5140 union iwreq_data *wrqu, char *extra)
5141{
5142 int ret;
5143
5144 vos_ssr_protect(__func__);
5145 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5146 vos_ssr_unprotect(__func__);
5147
5148 return ret;
5149}
5150
5151static int __iw_set_retry(struct net_device *dev,
5152 struct iw_request_info *info,
5153 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005154{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305155 hdd_adapter_t *pAdapter;
5156 tHalHandle hHal;
5157 hdd_context_t *pHddCtx;
5158 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005159
5160 ENTER();
5161
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305162 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5163 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005164 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5166 "%s: Adapter is NULL",__func__);
5167 return -EINVAL;
5168 }
5169
5170 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5171 ret = wlan_hdd_validate_context(pHddCtx);
5172 if (0 != ret)
5173 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305174 return ret;
5175 }
5176
5177 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5178 if (NULL == hHal)
5179 {
5180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5181 "%s: Hal Context is NULL",__func__);
5182 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005183 }
5184
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5186 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5187
Arif Hussain6d2a3322013-11-17 19:50:10 -08005188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005189
5190 return -EINVAL;
5191 }
5192
5193 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5194
5195 if((wrqu->retry.flags & IW_RETRY_LONG))
5196 {
5197 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5198 {
c_hpothub8245442013-11-20 23:41:09 +05305199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5200 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 return -EIO;
5202 }
5203 }
5204 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5205 {
5206 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5207 {
c_hpothub8245442013-11-20 23:41:09 +05305208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5209 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005210 return -EIO;
5211 }
5212 }
5213 }
5214 else
5215 {
5216 return -EOPNOTSUPP;
5217 }
5218
Arif Hussain6d2a3322013-11-17 19:50:10 -08005219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005220
5221 EXIT();
5222
5223 return 0;
5224
5225}
5226
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305227static int iw_set_retry(struct net_device *dev,
5228 struct iw_request_info *info,
5229 union iwreq_data *wrqu, char *extra)
5230{
5231 int ret;
5232
5233 vos_ssr_protect(__func__);
5234 ret = __iw_set_retry(dev, info, wrqu, extra);
5235 vos_ssr_unprotect(__func__);
5236
5237 return ret;
5238}
5239
5240static int __iw_get_retry(struct net_device *dev,
5241 struct iw_request_info *info,
5242 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005243{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305244 hdd_adapter_t *pAdapter;
5245 hdd_context_t *pHddCtx;
5246 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005247 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305248 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005249
5250 ENTER();
5251
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305252 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5253 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005254 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5256 "%s: Adapter is NULL",__func__);
5257 return -EINVAL;
5258 }
5259
5260 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5261 ret = wlan_hdd_validate_context(pHddCtx);
5262 if (0 != ret)
5263 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305264 return ret;
5265 }
5266
5267 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5268 if (NULL == hHal)
5269 {
5270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5271 "%s: Hal Context is NULL",__func__);
5272 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005273 }
5274
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 if((wrqu->retry.flags & IW_RETRY_LONG))
5276 {
5277 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5278
5279 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5280 {
c_hpothub8245442013-11-20 23:41:09 +05305281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5282 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 return -EIO;
5284 }
5285
5286 wrqu->retry.value = retry;
5287 }
5288 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5289 {
5290 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5291
5292 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5293 {
c_hpothub8245442013-11-20 23:41:09 +05305294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5295 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 return -EIO;
5297 }
5298
5299 wrqu->retry.value = retry;
5300 }
5301 else {
5302 return -EOPNOTSUPP;
5303 }
5304
Arif Hussain6d2a3322013-11-17 19:50:10 -08005305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005306
5307 EXIT();
5308
5309 return 0;
5310}
5311
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305312static int iw_get_retry(struct net_device *dev,
5313 struct iw_request_info *info,
5314 union iwreq_data *wrqu, char *extra)
5315{
5316 int ret;
5317
5318 vos_ssr_protect(__func__);
5319 ret = __iw_get_retry(dev, info, wrqu, extra);
5320 vos_ssr_unprotect(__func__);
5321
5322 return ret;
5323}
5324
5325static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005326 struct iw_request_info *info,
5327 union iwreq_data *wrqu,
5328 char *extra)
5329{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305330 hdd_adapter_t *pAdapter;
5331 hdd_context_t *pHddCtx;
5332 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5334 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305335 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005336
5337 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305338 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5339 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5342 "%s:Adapter is NULL",__func__);
5343 return -EINVAL;
5344 }
5345 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5346 ret = wlan_hdd_validate_context(pHddCtx);
5347 if (0 != ret)
5348 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305349 return ret;
5350 }
5351 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5352 if (NULL == pHddStaCtx)
5353 {
5354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5355 "%s:STA context is NULL",__func__);
5356 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005357 }
5358
5359 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5360 switch (mlme->cmd) {
5361 case IW_MLME_DISASSOC:
5362 case IW_MLME_DEAUTH:
5363
5364 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5365 {
5366 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5367
5368 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5369 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5370
5371 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5372 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5373
Jeff Johnson43971f52012-07-17 12:26:56 -07005374 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305375 {
5376 long ret;
5377 ret = wait_for_completion_interruptible_timeout(
5378 &pAdapter->disconnect_comp_var,
5379 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5380 if (ret <= 0)
5381 hddLog(VOS_TRACE_LEVEL_ERROR,
5382 FL("failed wait on disconnect_comp_var %ld"), ret);
5383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005385 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005386 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005387
5388 /* Resetting authKeyMgmt */
5389 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5390
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305391 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 netif_tx_disable(dev);
5393 netif_carrier_off(dev);
5394
5395 }
5396 else
5397 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005398 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 -07005399 }
5400 break;
5401 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005402 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 return -EINVAL;
5404 }//end of switch
5405
5406 EXIT();
5407
5408 return status;
5409
5410}
5411
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305412static int iw_set_mlme(struct net_device *dev,
5413 struct iw_request_info *info,
5414 union iwreq_data *wrqu,
5415 char *extra)
5416{
5417 int ret;
5418
5419 vos_ssr_protect(__func__);
5420 ret = __iw_set_mlme(dev, info, wrqu, extra);
5421 vos_ssr_unprotect(__func__);
5422
5423 return ret;
5424}
5425
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305426int wlan_hdd_set_proximity(int set_value)
5427{
5428 sHwCalValues hwCalValues;
5429 uint16 hwCalTxPower;
5430 uint8 txPwr = TX_PWR_DEF;
5431
5432 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5433
5434 if (TRUE == set_value) {
5435 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5436 NULL, sizeof(sHwCalValues) )
5437 != VOS_STATUS_SUCCESS) {
5438 return -EINVAL;
5439 }
5440 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5441
5442 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5443 hwCalTxPower, hwCalValues.calData.hwParam7);
5444
5445 txPwr = (int8)(hwCalTxPower & 0x00FF);
5446 txPwr = txPwr/10;
5447 if (txPwr < TX_PWR_MIN)
5448 txPwr = TX_PWR_MIN;
5449 if (txPwr > TX_PWR_MAX)
5450 txPwr = TX_PWR_MAX;
5451
5452 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr) !=
5453 eHAL_STATUS_SUCCESS) {
5454 hddLog(VOS_TRACE_LEVEL_ERROR,
5455 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5456 return -EIO;
5457 }
5458
5459 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5460 txPwr /= 10;
5461 if (txPwr < TX_PWR_MIN)
5462 txPwr = TX_PWR_MIN;
5463 if (txPwr > TX_PWR_MAX)
5464 txPwr = TX_PWR_MAX;
5465
5466 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr) !=
5467 eHAL_STATUS_SUCCESS) {
5468 hddLog(VOS_TRACE_LEVEL_ERROR,
5469 FL("setting tx power failed for 5GHz band %d"), txPwr);
5470 return -EIO;
5471 }
5472 }
5473 else if(FALSE == set_value) {
5474 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr) !=
5475 eHAL_STATUS_SUCCESS) {
5476 hddLog(VOS_TRACE_LEVEL_ERROR,
5477 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5478 return -EIO;
5479 }
5480
5481 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr) !=
5482 eHAL_STATUS_SUCCESS) {
5483 hddLog(VOS_TRACE_LEVEL_ERROR,
5484 FL("setting tx power failed for 5GHz band %d"), txPwr);
5485 return -EIO;
5486 }
5487 }
5488 else {
5489 return -EINVAL;
5490 }
5491
5492 return eHAL_STATUS_SUCCESS;
5493}
Jeff Johnson295189b2012-06-20 16:38:30 -07005494/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305495static int __iw_setint_getnone(struct net_device *dev,
5496 struct iw_request_info *info,
5497 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005498{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305499 hdd_adapter_t *pAdapter;
5500 tHalHandle hHal;
5501 hdd_wext_state_t *pWextState;
5502 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305503 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 int *value = (int *)extra;
5505 int sub_cmd = value[0];
5506 int set_value = value[1];
5507 int ret = 0; /* success */
5508 int enable_pbm, enable_mp;
5509#ifdef CONFIG_HAS_EARLYSUSPEND
5510 v_U8_t nEnableSuspendOld;
5511#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005512
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305513 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305514 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5515 if (NULL == pAdapter)
5516 {
5517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5518 "%s: Adapter is NULL",__func__);
5519 return -EINVAL;
5520 }
5521 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5522 ret = wlan_hdd_validate_context(pHddCtx);
5523 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005524 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305525 return ret;
5526 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305527
Katya Nigameae74b62015-05-28 17:19:16 +05305528 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305529 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305530 /* In monitor mode hHal is NULL */
5531 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5532 if (NULL == hHal)
5533 {
5534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5535 "%s: Hal Context is NULL",__func__);
5536 return -EINVAL;
5537 }
Katya Nigameae74b62015-05-28 17:19:16 +05305538 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5539 if (NULL == pWextState)
5540 {
5541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5542 "%s: pWextState is NULL",__func__);
5543 return -EINVAL;
5544 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005545
Katya Nigameae74b62015-05-28 17:19:16 +05305546 INIT_COMPLETION(pWextState->completion_var);
5547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 switch(sub_cmd)
5549 {
5550 case WE_SET_11D_STATE:
5551 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005552 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005553 memset(&smeConfig, 0x00, sizeof(smeConfig));
5554
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5556
5557 sme_GetConfigParam(hHal,&smeConfig);
5558 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5559
Arif Hussain6d2a3322013-11-17 19:50:10 -08005560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005561
5562 sme_UpdateConfig(hHal,&smeConfig);
5563 }
5564 else {
5565 return -EINVAL;
5566 }
5567 break;
5568 }
5569
5570 case WE_WOWL:
5571 {
5572 switch (set_value)
5573 {
5574 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305575 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 break;
5577 case 0x01:
5578 case 0x02:
5579 case 0x03:
5580 enable_mp = (set_value & 0x01) ? 1 : 0;
5581 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005582 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5584 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5585 break;
5586 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005587 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 ret = -EINVAL;
5589 break;
5590 }
5591
5592 break;
5593 }
5594 case WE_SET_POWER:
5595 {
5596 switch (set_value)
5597 {
5598 case 0: //Full Power
5599 {
5600 struct statsContext context;
5601 eHalStatus status;
5602
5603 init_completion(&context.completion);
5604
5605 context.pAdapter = pAdapter;
5606 context.magic = POWER_CONTEXT_MAGIC;
5607
5608 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5609 iw_power_callback_fn, &context,
5610 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005611 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 {
5613 int lrc = wait_for_completion_interruptible_timeout(
5614 &context.completion,
5615 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005616
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 if (lrc <= 0)
5618 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005619 hddLog(VOS_TRACE_LEVEL_ERROR,
5620 "%s: SME %s while requesting fullpower",
5621 __func__, (0 == lrc) ?
5622 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 }
5624 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005625 /* either we have a response or we timed out. if we timed
5626 out there is a race condition such that the callback
5627 function could be executing at the same time we are. of
5628 primary concern is if the callback function had already
5629 verified the "magic" but had not yet set the completion
5630 variable when a timeout occurred. we serialize these
5631 activities by invalidating the magic while holding a
5632 shared spinlock which will cause us to block if the
5633 callback is currently executing */
5634 spin_lock(&hdd_context_lock);
5635 context.magic = 0;
5636 spin_unlock(&hdd_context_lock);
5637
Arif Hussain6d2a3322013-11-17 19:50:10 -08005638 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 break;
5640 }
5641 case 1: //Enable BMPS
5642 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5643 break;
5644 case 2: //Disable BMPS
5645 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5646 break;
5647 case 3: //Request Bmps
5648 {
5649 struct statsContext context;
5650 eHalStatus status;
5651
5652 init_completion(&context.completion);
5653
5654 context.pAdapter = pAdapter;
5655 context.magic = POWER_CONTEXT_MAGIC;
5656
5657 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5658 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005659 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 {
5661 int lrc = wait_for_completion_interruptible_timeout(
5662 &context.completion,
5663 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 if (lrc <= 0)
5665 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005666 hddLog(VOS_TRACE_LEVEL_ERROR,
5667 "%s: SME %s while requesting BMPS",
5668 __func__, (0 == lrc) ? "timeout" :
5669 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 }
5671 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005672 /* either we have a response or we timed out. if we
5673 timed out there is a race condition such that the
5674 callback function could be executing at the same
5675 time we are. of primary concern is if the callback
5676 function had already verified the "magic" but had
5677 not yet set the completion variable when a timeout
5678 occurred. we serialize these activities by
5679 invalidating the magic while holding a shared
5680 spinlock which will cause us to block if the
5681 callback is currently executing */
5682 spin_lock(&hdd_context_lock);
5683 context.magic = 0;
5684 spin_unlock(&hdd_context_lock);
5685
Arif Hussain6d2a3322013-11-17 19:50:10 -08005686 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 break;
5688 }
5689 case 4: //Enable IMPS
5690 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5691 break;
5692 case 5: //Disable IMPS
5693 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5694 break;
5695 case 6: //Enable Standby
5696 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5697 break;
5698 case 7: //Disable Standby
5699 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5700 break;
5701 case 8: //Request Standby
5702#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005703#endif
5704 break;
5705 case 9: //Start Auto Bmps Timer
5706 sme_StartAutoBmpsTimer(hHal);
5707 break;
5708 case 10://Stop Auto BMPS Timer
5709 sme_StopAutoBmpsTimer(hHal);
5710 break;
5711#ifdef CONFIG_HAS_EARLYSUSPEND
5712 case 11://suspend to standby
5713#ifdef CONFIG_HAS_EARLYSUSPEND
5714 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5715 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5717#endif
5718 break;
5719 case 12://suspend to deep sleep
5720#ifdef CONFIG_HAS_EARLYSUSPEND
5721 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5722 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5724#endif
5725 break;
5726 case 13://resume from suspend
5727#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005728#endif
5729 break;
5730#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005732 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 ret = -EINVAL;
5734 break;
5735 }
5736 break;
5737 }
5738
5739 case WE_SET_MAX_ASSOC:
5740 {
5741 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5742 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5743 {
5744 ret = -EINVAL;
5745 }
5746 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5747 set_value, NULL, eANI_BOOLEAN_FALSE)
5748 != eHAL_STATUS_SUCCESS )
5749 {
c_hpothub8245442013-11-20 23:41:09 +05305750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5751 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 ret = -EIO;
5753 }
5754 break;
5755 }
5756
5757 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5758 {
5759 if( 0 == set_value )
5760 {
5761 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5762 }
5763 else if ( 1 == set_value )
5764 {
5765 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5766 }
5767 else
5768 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005769 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 ret = -EINVAL;
5771 }
5772 break;
5773 }
5774
5775 case WE_SET_DATA_INACTIVITY_TO:
5776 {
5777 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5778 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5779 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5780 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5781 set_value,
5782 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5783 {
5784 hddLog(LOGE,"Failure: Could not pass on "
5785 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005786 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005787 ret = -EINVAL;
5788 }
5789 break;
5790 }
5791 case WE_SET_MAX_TX_POWER:
5792 {
5793 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5794 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5795
5796 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5797 __func__, set_value);
5798 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5799 eHAL_STATUS_SUCCESS )
5800 {
5801 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5802 __func__);
5803 return -EIO;
5804 }
5805
5806 break;
5807 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005808 case WE_SET_MAX_TX_POWER_2_4:
5809 {
5810 hddLog(VOS_TRACE_LEVEL_INFO,
5811 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5812 __func__, set_value);
5813 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5814 eHAL_STATUS_SUCCESS)
5815 {
5816 hddLog(VOS_TRACE_LEVEL_ERROR,
5817 "%s: Setting maximum tx power failed for 2.4 GHz band",
5818 __func__);
5819 return -EIO;
5820 }
5821
5822 break;
5823 }
5824 case WE_SET_MAX_TX_POWER_5_0:
5825 {
5826 hddLog(VOS_TRACE_LEVEL_INFO,
5827 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5828 __func__, set_value);
5829 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5830 eHAL_STATUS_SUCCESS)
5831 {
5832 hddLog(VOS_TRACE_LEVEL_ERROR,
5833 "%s: Setting maximum tx power failed for 5.0 GHz band",
5834 __func__);
5835 return -EIO;
5836 }
5837
5838 break;
5839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 case WE_SET_HIGHER_DTIM_TRANSITION:
5841 {
5842 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5843 (set_value == eANI_BOOLEAN_TRUE)))
5844 {
5845 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5846 ret = -EINVAL;
5847 }
5848 else
5849 {
5850 if(pAdapter->higherDtimTransition != set_value)
5851 {
5852 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005853 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 }
5855 }
5856
5857 break;
5858 }
5859
5860 case WE_SET_TM_LEVEL:
5861 {
5862 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005863 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5865
5866 break;
5867 }
5868
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305869 case WE_ENABLE_STRICT_FCC_REG:
5870 {
5871 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5872 struct wiphy *wiphy = NULL;
5873 long lrc;
5874 int status;
5875
5876 wiphy = hddCtxt->wiphy;
5877 if(wiphy == NULL)
5878 {
5879 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5880 break;
5881 }
5882 init_completion(&hddCtxt->wiphy_channel_update_event);
5883
5884 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5885
5886 status = regulatory_hint(wiphy, "00");
5887 if(status < 0)
5888 {
5889 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5890 break;
5891 }
5892
5893 /* Wait for completion */
5894 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5895 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5896 if (lrc <= 0)
5897 {
5898 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5899 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5900 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5901 }
5902 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5903
5904 break;
5905 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005906 case WE_SET_DEBUG_LOG:
5907 {
5908 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5909 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5910 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5911 break;
5912 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305913#ifdef FEATURE_WLAN_TDLS
5914 case WE_SET_TDLS_OFF_CHAN:
5915 {
5916 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5918 __func__, set_value);
5919 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5920 break;
5921 }
5922 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5923 {
5924 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5926 __func__, set_value);
5927 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5928 break;
5929 }
5930 case WE_SET_TDLS_OFF_CHAN_MODE:
5931 {
5932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5933 __func__, set_value);
5934 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5935 break;
5936 }
5937#endif
Peng Xu2446a892014-09-05 17:21:18 +05305938 case WE_SET_SCAN_BAND_PREFERENCE:
5939 {
5940 tSmeConfigParams smeConfig;
5941 memset(&smeConfig, 0x00, sizeof(smeConfig));
5942 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5943 ret = -EINVAL;
5944 break;
5945 }
5946 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5947
5948 if (eCSR_BAND_ALL == set_value ||
5949 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5950 sme_GetConfigParam(hHal, &smeConfig);
5951 smeConfig.csrConfig.scanBandPreference = set_value;
5952
5953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5954 "set band scan preference = %d\n",
5955 smeConfig.csrConfig.scanBandPreference);
5956
5957 sme_UpdateConfig(hHal, &smeConfig);
5958 }
5959 else {
5960 ret = -EINVAL;
5961 }
5962 break;
5963 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305964 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5965 * connection happens so that the params can take effect during
5966 * association. Also this should not be used in STA+p2p concurrency
5967 * as the param will also effect the STA mode.
5968 */
5969 case WE_SET_MIRACAST_VENDOR_CONFIG:
5970 {
5971 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305972
Abhishek Singh01c73d12015-03-12 15:13:44 +05305973 hddLog(LOG1, FL(
5974 "Set Miracast vendor tuning %d"), set_value);
5975
5976 if (1 == set_value || 0 == set_value)
5977 {
5978 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5979 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5980 {
5981 hddLog( LOGE, FL("set vendor miracast config failed"));
5982 ret = -EIO;
5983 }
5984 }
5985 else
5986 {
5987 hddLog(LOGE,
5988 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5989 ret = -EINVAL;
5990 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305991 break;
5992 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305993
5994 case WE_GET_FRAME_LOG:
5995 {
5996 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5997 != VOS_STATUS_SUCCESS)
5998 {
5999 ret = -EINVAL;
6000 }
6001 break;
6002 }
6003
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306004 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6005 {
6006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6007 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
6008 if (set_value == 0 || set_value == 1)
6009 {
6010 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6011 set_value);
6012 }
6013 else
6014 ret = -EINVAL;
6015
6016 break;
6017 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306018 /* Bit mask value to enable RTS/CTS for different modes
6019 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6020 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6021 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6022 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6023 * for 5 GHz, VHT80 - 0x1000
6024 */
6025 case WE_SET_RTS_CTS_HTVHT:
6026 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306027
Abhishek Singh41988ba2015-05-25 19:42:29 +05306028 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6029
6030 if (eHAL_STATUS_SUCCESS !=
6031 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6032 {
6033 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6034 ret = -EINVAL;
6035 }
6036 break;
6037 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306038 case WE_SET_MONITOR_STATE:
6039 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306040 v_U32_t magic = 0;
6041 struct completion cmpVar;
6042 long waitRet = 0;
6043 tVOS_CON_MODE mode = hdd_get_conparam();
6044
6045 if( VOS_MONITOR_MODE != mode)
6046 {
6047 hddLog(LOGE, "invalid mode %d", mode);
6048 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306049 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306050 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306051
6052 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6053 if( pMonCtx == NULL )
6054 {
6055 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306056 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306057 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306058 }
6059 if (pMonCtx->state == set_value)
6060 {
6061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6062 FL("already in same mode curr_mode:%d req_mode: %d"),
6063 pMonCtx->state, set_value);
6064 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306065 }
6066 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306067 magic = MON_MODE_MSG_MAGIC;
6068 init_completion(&cmpVar);
6069 if (VOS_STATUS_SUCCESS !=
6070 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6071 pMonCtx, hdd_monPostMsgCb)) {
6072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6073 FL("failed to post MON MODE REQ"));
6074 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6075 MON_MODE_STOP : MON_MODE_START;
6076 magic = 0;
6077 ret = -EIO;
6078 break;
6079 }
6080 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6081 magic = 0;
6082 if (waitRet <= 0 ){
6083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6084 FL("failed to wait on monitor mode completion %ld"),
6085 waitRet);
6086 }
6087 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306088 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306089 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6090 {
6091 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6092 tAniWifiStartLog start_log;
6093 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6094 !vos_isPktStatsEnabled())
6095 {
6096 hddLog(LOGE, FL("per pkt stats not enabled"));
6097 return -EINVAL;
6098 }
6099 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6100
6101 if (1 == set_value || 0 == set_value)
6102 {
6103 start_log.ringId = RING_ID_PER_PACKET_STATS;
6104 start_log.flag = 0;
6105 if (set_value)
6106 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6107 else
6108 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6109
6110 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6111 }
6112 else
6113 {
6114 hddLog(LOGE,
6115 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6116 set_value);
6117 ret = -EINVAL;
6118 }
6119 break;
6120 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306121 case WE_SET_PROXIMITY_ENABLE:
6122 {
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05306123 ret = wlan_hdd_set_proximity(set_value);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306124 break;
6125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 default:
6127 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006128 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 sub_cmd, set_value);
6130 break;
6131 }
6132 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306133 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 return ret;
6135}
6136
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306137static int iw_setint_getnone(struct net_device *dev,
6138 struct iw_request_info *info,
6139 union iwreq_data *wrqu, char *extra)
6140{
6141 int ret;
6142
6143 vos_ssr_protect(__func__);
6144 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6145 vos_ssr_unprotect(__func__);
6146
6147 return 0;
6148}
Jeff Johnson295189b2012-06-20 16:38:30 -07006149/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306150static int __iw_setchar_getnone(struct net_device *dev,
6151 struct iw_request_info *info,
6152 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006153{
6154 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306155 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006157 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306158 hdd_adapter_t *pAdapter;
6159 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006160#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306161 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006162#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306163 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306164 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006165
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306166 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306167
6168 if (!capable(CAP_NET_ADMIN))
6169 {
6170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6171 FL("permission check failed"));
6172 return -EPERM;
6173 }
6174
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306175 pAdapter = (netdev_priv(dev));
6176 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006177 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6179 "%s: Adapter is NULL",__func__);
6180 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006181 }
6182
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306183 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6184 ret = wlan_hdd_validate_context(pHddCtx);
6185 if (0 != ret)
6186 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306187 return ret;
6188 }
6189#ifdef WLAN_FEATURE_VOWIFI
6190 pConfig = pHddCtx->cfg_ini;
6191#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306192 /* helper function to get iwreq_data with compat handling. */
6193 if (hdd_priv_get_data(&s_priv_data, wrqu))
6194 {
6195 return -EINVAL;
6196 }
6197
6198 /* make sure all params are correctly passed to function */
6199 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6200 {
6201 return -EINVAL;
6202 }
6203
6204 sub_cmd = s_priv_data.flags;
6205
Arif Hussain0273cba2014-01-07 20:58:29 -08006206 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306207 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6208 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006209 if (NULL == pBuffer)
6210 {
6211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6212 "mem_alloc_copy_from_user_helper fail");
6213 return -ENOMEM;
6214 }
6215
6216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306217 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6219 "%s: Received data %s", __func__, pBuffer);
6220
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 switch(sub_cmd)
6222 {
6223 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006225 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006226 break;
6227 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006229 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 break;
6231#if defined WLAN_FEATURE_VOWIFI
6232 case WE_NEIGHBOR_REPORT_REQUEST:
6233 {
6234 tRrmNeighborReq neighborReq;
6235 tRrmNeighborRspCallbackInfo callbackInfo;
6236
6237 if (pConfig->fRrmEnable)
6238 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306240 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 if( !neighborReq.no_ssid )
6242 {
Girish Gowli552fc072014-06-14 18:26:16 +05306243 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006244 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 }
6246
6247 callbackInfo.neighborRspCallback = NULL;
6248 callbackInfo.neighborRspCallbackContext = NULL;
6249 callbackInfo.timeout = 5000; //5 seconds
6250 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6251 }
6252 else
6253 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006254 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 ret = -EINVAL;
6256 }
6257 }
6258 break;
6259#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 case WE_SET_AP_WPS_IE:
6261 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306262 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006265 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 if (VOS_STATUS_SUCCESS != vstatus)
6267 {
6268 ret = -EINVAL;
6269 }
6270 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306271 case WE_SET_ENCRYPT_MSG:
6272 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6273 if (NULL == pkt)
6274 {
6275 hddLog(VOS_TRACE_LEVEL_ERROR,
6276 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306277 ret = -ENOMEM;
6278 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306279 }
6280
6281 memset(pkt, 0, sizeof(tSirpkt80211));
6282
6283 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6284 hddLog(VOS_TRACE_LEVEL_ERROR,
6285 FL("Firmware is not DISA capable"));
6286 ret = -EINVAL;
6287 vos_mem_free(pkt);
6288 break;
6289 }
6290
6291 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6292
6293 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6294 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6295 if (eHAL_STATUS_SUCCESS != ret) {
6296 hddLog(VOS_TRACE_LEVEL_ERROR,
6297 FL("SENDEncryptMSG: fail to post WDA cmd"));
6298 ret = -EINVAL;
6299 }
6300 vos_mem_free(pkt);
6301
6302 break;
6303
Jeff Johnson295189b2012-06-20 16:38:30 -07006304 default:
6305 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006306 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 ret = -EINVAL;
6308 break;
6309 }
6310 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006311 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306312
6313 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 return ret;
6315}
6316
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306317static int iw_setchar_getnone(struct net_device *dev,
6318 struct iw_request_info *info,
6319 union iwreq_data *wrqu, char *extra)
6320{
6321 int ret;
6322
6323 vos_ssr_protect(__func__);
6324 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6325 vos_ssr_unprotect(__func__);
6326
6327 return ret;
6328}
6329
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306330static void hdd_GetCurrentAntennaIndex(int antennaId, void *pContext)
6331{
6332 struct statsContext *context;
6333 hdd_adapter_t *pAdapter;
6334
6335 if (NULL == pContext)
6336 {
6337 hddLog(VOS_TRACE_LEVEL_ERROR,
6338 "%s: Bad param, pContext [%p]",
6339 __func__, pContext);
6340 return;
6341 }
6342
6343 context = pContext;
6344 pAdapter = context->pAdapter;
6345
6346 spin_lock(&hdd_context_lock);
6347
6348 if ((NULL == pAdapter) || (ANTENNA_CONTEXT_MAGIC != context->magic))
6349 {
6350 /* the caller presumably timed out so there is nothing we can do */
6351 spin_unlock(&hdd_context_lock);
6352 hddLog(VOS_TRACE_LEVEL_WARN,
6353 "%s: Invalid context, pAdapter [%p] magic [%08x]",
6354 __func__, pAdapter, context->magic);
6355 return;
6356 }
6357
6358 context->magic = 0;
6359 pAdapter->antennaIndex = antennaId;
6360
6361 complete(&context->completion);
6362 spin_unlock(&hdd_context_lock);
6363}
6364
6365static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6366 int *antennaIndex)
6367{
6368 hdd_context_t *pHddCtx;
6369 eHalStatus halStatus;
6370 struct statsContext context;
6371 long lrc;
6372
6373 ENTER();
6374 if (NULL == pAdapter)
6375 {
6376 hddLog(VOS_TRACE_LEVEL_WARN,
6377 "%s: Invalid context, pAdapter", __func__);
6378 return VOS_STATUS_E_FAULT;
6379 }
6380 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6381 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6382 {
6383 return VOS_STATUS_E_FAULT;
6384 }
6385 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6386 {
6387 hddLog(VOS_TRACE_LEVEL_ERROR,
6388 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6389 __func__);
6390 return VOS_STATUS_E_NOSUPPORT;
6391 }
6392 init_completion(&context.completion);
6393 context.pAdapter = pAdapter;
6394 context.magic = ANTENNA_CONTEXT_MAGIC;
6395
6396 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
6397 hdd_GetCurrentAntennaIndex,
6398 &context, pAdapter->sessionId);
6399 if (eHAL_STATUS_SUCCESS != halStatus)
6400 {
6401 spin_lock(&hdd_context_lock);
6402 context.magic = 0;
6403 spin_unlock(&hdd_context_lock);
6404 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6405 __func__);
6406 /* we'll returned a cached value below */
6407 *antennaIndex = -1;
6408 return VOS_STATUS_E_FAILURE;
6409 }
6410 else
6411 {
6412 /* request was sent -- wait for the response */
6413 lrc = wait_for_completion_interruptible_timeout(&context.completion,
6414 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
6415 if (lrc <= 0)
6416 {
6417 spin_lock(&hdd_context_lock);
6418 context.magic = 0;
6419 spin_unlock(&hdd_context_lock);
6420 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:SME %s while retrieving Antenna"
6421 " Index",
6422 __func__, (0 == lrc) ? "timeout" : "interrupt");
6423 *antennaIndex = -1;
6424 return VOS_STATUS_E_FAILURE;
6425 }
6426 }
6427 spin_lock(&hdd_context_lock);
6428 context.magic = 0;
6429 spin_unlock(&hdd_context_lock);
6430
6431 *antennaIndex = pAdapter->antennaIndex;
6432
6433 EXIT();
6434 return VOS_STATUS_SUCCESS;
6435}
6436
Jeff Johnson295189b2012-06-20 16:38:30 -07006437/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306438static int __iw_setnone_getint(struct net_device *dev,
6439 struct iw_request_info *info,
6440 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006441{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306442 hdd_adapter_t *pAdapter;
6443 tHalHandle hHal;
6444 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 int *value = (int *)extra;
6446 int ret = 0; /* success */
6447
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306448 ENTER();
6449
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306450 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6451 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006452 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6454 "%s: Adapter is NULL",__func__);
6455 return -EINVAL;
6456 }
6457 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6458 ret = wlan_hdd_validate_context(pHddCtx);
6459 if (0 != ret)
6460 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306461 return ret;
6462 }
6463 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6464 if (NULL == hHal)
6465 {
6466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6467 "%s: Hal Context is NULL",__func__);
6468 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006470
6471 switch (value[0])
6472 {
6473 case WE_GET_11D_STATE:
6474 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006475 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006476 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306477
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6479
Arif Hussain6d2a3322013-11-17 19:50:10 -08006480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006481
6482 break;
6483 }
6484
6485 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 break;
6488
6489 case WE_PMC_STATE:
6490 {
6491 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 break;
6494 }
6495 case WE_GET_WLAN_DBG:
6496 {
6497 vos_trace_display();
6498 *value = 0;
6499 break;
6500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006501 case WE_GET_MAX_ASSOC:
6502 {
6503 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6504 {
c_hpothub8245442013-11-20 23:41:09 +05306505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6506 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 ret = -EIO;
6508 }
Girish Gowli385be612014-09-18 11:17:20 +05306509#ifdef WLAN_SOFTAP_VSTA_FEATURE
6510 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6511 {
6512 if (*value > VSTA_NUM_ASSOC_STA)
6513 {
6514 *value = VSTA_NUM_ASSOC_STA;
6515 }
6516 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6517 (*value > (VSTA_NUM_ASSOC_STA -
6518 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6519 {
6520 *value = (VSTA_NUM_ASSOC_STA -
6521 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6522 }
6523 }
6524 else
6525#endif
6526 {
6527 if (*value > NUM_ASSOC_STA)
6528 {
6529 *value = NUM_ASSOC_STA;
6530 }
6531 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6532 (*value > (NUM_ASSOC_STA -
6533 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6534 {
6535 *value = (NUM_ASSOC_STA -
6536 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6537 }
6538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 break;
6540 }
6541
Jeff Johnson295189b2012-06-20 16:38:30 -07006542 case WE_GET_WDI_DBG:
6543 {
6544 wpalTraceDisplay();
6545 *value = 0;
6546 break;
6547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006548
6549 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6550 {
6551 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6552 break;
6553 }
6554 case WE_GET_CONCURRENCY_MODE:
6555 {
6556 *value = hdd_get_concurrency_mode ( );
6557
Arif Hussain6d2a3322013-11-17 19:50:10 -08006558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 break;
6560 }
6561
Peng Xu2446a892014-09-05 17:21:18 +05306562 case WE_GET_SCAN_BAND_PREFERENCE:
6563 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306564 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306565 sme_GetConfigParam(hHal, &smeConfig);
6566 *value = smeConfig.csrConfig.scanBandPreference;
6567
6568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6569 "scanBandPreference = %d\n", *value);
6570 break;
6571 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306572 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6573 {
6574 wlan_hdd_get_current_antenna_index(pAdapter, value);
6575 break;
6576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 default:
6578 {
6579 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6580 break;
6581 }
6582 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306583 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 return ret;
6585}
6586
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306587static int iw_setnone_getint(struct net_device *dev,
6588 struct iw_request_info *info,
6589 union iwreq_data *wrqu, char *extra)
6590{
6591 int ret;
6592
6593 vos_ssr_protect(__func__);
6594 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6595 vos_ssr_unprotect(__func__);
6596
6597 return ret;
6598
6599}
Jeff Johnson295189b2012-06-20 16:38:30 -07006600/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306601int __iw_set_three_ints_getnone(struct net_device *dev,
6602 struct iw_request_info *info,
6603 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006604{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306605 hdd_adapter_t *pAdapter;
6606 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 int *value = (int *)extra;
6608 int sub_cmd = value[0];
6609 int ret = 0;
6610
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306611 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306612
6613 if (!capable(CAP_NET_ADMIN))
6614 {
6615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6616 FL("permission check failed"));
6617 return -EPERM;
6618 }
6619
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306620 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6621 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006622 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6624 "%s: Adapter is NULL",__func__);
6625 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006626 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306627 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6628 ret = wlan_hdd_validate_context(pHddCtx);
6629 if (0 != ret)
6630 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306631 return ret;
6632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 switch(sub_cmd)
6634 {
6635 case WE_SET_WLAN_DBG:
6636 {
6637 vos_trace_setValue( value[1], value[2], value[3]);
6638 break;
6639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 case WE_SET_WDI_DBG:
6641 {
6642 wpalTraceSetLevel( value[1], value[2], value[3]);
6643 break;
6644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 case WE_SET_SAP_CHANNELS:
6646 {
6647 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6648 break;
6649 }
6650
6651 default:
6652 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006653 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 break;
6655 }
6656 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306657 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 return ret;
6659}
6660
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306661int iw_set_three_ints_getnone(struct net_device *dev,
6662 struct iw_request_info *info,
6663 union iwreq_data *wrqu, char *extra)
6664{
6665 int ret;
6666
6667 vos_ssr_protect(__func__);
6668 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6669 vos_ssr_unprotect(__func__);
6670
6671 return ret;
6672}
6673
6674static int __iw_get_char_setnone(struct net_device *dev,
6675 struct iw_request_info *info,
6676 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006677{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306678 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306680 hdd_context_t *pHddCtx;
6681 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006682#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006683 hdd_wext_state_t *pWextState;
6684#endif
6685
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306686 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306687 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006688 if (pAdapter == NULL)
6689 {
6690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6691 "%s: pAdapter is NULL!", __func__);
6692 return -EINVAL;
6693 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306694 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6695 ret = wlan_hdd_validate_context(pHddCtx);
6696 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006697 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306698 return ret;
6699 }
6700#ifdef WLAN_FEATURE_11W
6701 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6702 if (NULL == pWextState)
6703 {
6704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6705 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006706 return -EINVAL;
6707 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306708#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006709
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 switch(sub_cmd)
6711 {
6712 case WE_WLAN_VERSION:
6713 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006714 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 break;
6716 }
6717
6718 case WE_GET_STATS:
6719 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306720 tHalHandle hHal = NULL;
6721 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6723 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6724 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6725
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306726
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 snprintf(extra, WE_MAX_STR_LEN,
6728 "\nTransmit"
6729 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6730 "\n dropped BK %u, BE %u, VI %u, VO %u"
6731 "\n classified BK %u, BE %u, VI %u, VO %u"
6732 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6733 "\n queued BK %u, BE %u, VI %u, VO %u"
6734 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006735 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 "\n fetched BK %u, BE %u, VI %u, VO %u"
6737 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6738 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006739 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 "\n flushed BK %u, BE %u, VI %u, VO %u"
6741 "\n\nReceive"
6742 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6743 "\n\nResetsStats"
6744 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6745 "\n",
6746 pStats->txXmitCalled,
6747 pStats->txXmitDropped,
6748 pStats->txXmitBackPressured,
6749 pStats->txXmitQueued,
6750
6751 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6752 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6753 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6754 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6755
6756 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6757 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6758 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6759 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6760
6761 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6762 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6763 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6764 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6765
6766 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6767 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6768 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6769 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6770
6771 pStats->txFetched,
6772 pStats->txFetchEmpty,
6773 pStats->txFetchLowResources,
6774 pStats->txFetchDequeueError,
6775
6776 pStats->txFetchDequeued,
6777 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006778 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 pStats->txCompleted,
6780 pStats->txFlushed,
6781
6782 pStats->txFetchedAC[WLANTL_AC_BK],
6783 pStats->txFetchedAC[WLANTL_AC_BE],
6784 pStats->txFetchedAC[WLANTL_AC_VI],
6785 pStats->txFetchedAC[WLANTL_AC_VO],
6786
6787 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6788 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6789 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6790 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6791
6792 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6793 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6794 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6795 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6796
Ravi Joshi41914632013-10-21 23:02:21 -07006797 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6798 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6799 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6800 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6801
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 pStats->txFlushedAC[WLANTL_AC_BK],
6803 pStats->txFlushedAC[WLANTL_AC_BE],
6804 pStats->txFlushedAC[WLANTL_AC_VI],
6805 pStats->txFlushedAC[WLANTL_AC_VO],
6806
6807 pStats->rxChains,
6808 pStats->rxPackets,
6809 pStats->rxDropped,
6810 pStats->rxDelivered,
6811 pStats->rxRefused,
6812
6813 pResetStats->totalLogpResets,
6814 pResetStats->totalCMD53Failures,
6815 pResetStats->totalMutexReadFailures,
6816 pResetStats->totalMIFErrorFailures,
6817 pResetStats->totalFWHearbeatFailures,
6818 pResetStats->totalUnknownExceptions
6819 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306820 wrqu->data.length = strlen(extra);
6821
6822 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6823
6824 if (hHal)
6825 pMac = PMAC_STRUCT( hHal );
6826
6827 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6828 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6829 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306830 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6831 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6832 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6833 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306834 "\n",
6835 pMac->pmm.BmpscntSleep,
6836 pMac->pmm.BmpscntAwake,
6837 pMac->pmm.BmpsSleeReqFailCnt,
6838 pMac->pmm.BmpsWakeupReqFailCnt,
6839 pMac->pmm.ImpsCntSleep,
6840 pMac->pmm.ImpsCntAwake,
6841 pMac->pmm.ImpsSleepErrCnt,
6842 pMac->pmm.ImpsWakeupErrCnt,
6843 pMac->pmm.ImpsLastErr
6844 );
6845 }
6846
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 wrqu->data.length = strlen(extra)+1;
6848 break;
6849 }
6850
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306851/* The case prints the current state of the HDD, SME, CSR, PE, TL
6852 *it can be extended for WDI Global State as well.
6853 *And currently it only checks P2P_CLIENT adapter.
6854 *P2P_DEVICE and P2P_GO have not been added as of now.
6855*/
6856 case WE_GET_STATES:
6857 {
6858 int buf = 0, len = 0;
6859 int adapter_num = 0;
6860 int count = 0, check = 1;
6861
6862 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006863 tHalHandle hHal = NULL;
6864 tpAniSirGlobal pMac = NULL;
6865 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306866
6867 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6868 hdd_adapter_t *useAdapter = NULL;
6869
6870 /* Print wlan0 or p2p0 states based on the adapter_num
6871 *by using the correct adapter
6872 */
6873 while ( adapter_num < 2 )
6874 {
6875 if ( WLAN_ADAPTER == adapter_num )
6876 {
6877 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006878 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306879 "\n\n wlan0 States:-");
6880 len += buf;
6881 }
6882 else if ( P2P_ADAPTER == adapter_num )
6883 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006884 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306885 "\n\n p2p0 States:-");
6886 len += buf;
6887
6888 if( !pHddCtx )
6889 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006890 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306891 "\n pHddCtx is NULL");
6892 len += buf;
6893 break;
6894 }
6895
6896 /*Printing p2p0 states only in the case when the device is
6897 configured as a p2p_client*/
6898 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6899 if ( !useAdapter )
6900 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006901 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306902 "\n Device not configured as P2P_CLIENT.");
6903 len += buf;
6904 break;
6905 }
6906 }
6907
6908 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006909 if (!hHal) {
6910 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6911 "\n pMac is NULL");
6912 len += buf;
6913 break;
6914 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306915 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006916 if (!pMac) {
6917 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6918 "\n pMac is NULL");
6919 len += buf;
6920 break;
6921 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306922 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6923 if( !pHddStaCtx )
6924 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006925 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306926 "\n pHddStaCtx is NULL");
6927 len += buf;
6928 break;
6929 }
6930
6931 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6932
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006933 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306934 "\n HDD Conn State - %s "
6935 "\n \n SME State:"
6936 "\n Neighbour Roam State - %s"
6937 "\n CSR State - %s"
6938 "\n CSR Substate - %s"
6939 "\n \n TL STA %d State: %s",
6940 macTraceGetHDDWlanConnState(
6941 pHddStaCtx->conn_info.connState),
6942 macTraceGetNeighbourRoamState(
6943 pMac->roam.neighborRoamInfo.neighborRoamState),
6944 macTraceGetcsrRoamState(
6945 pMac->roam.curState[useAdapter->sessionId]),
6946 macTraceGetcsrRoamSubState(
6947 pMac->roam.curSubState[useAdapter->sessionId]),
6948 pHddStaCtx->conn_info.staId[0],
6949 macTraceGetTLState(tlState)
6950 );
6951 len += buf;
6952 adapter_num++;
6953 }
6954
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006955 if (pMac) {
6956 /* Printing Lim State starting with global lim states */
6957 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6958 "\n \n LIM STATES:-"
6959 "\n Global Sme State - %s "\
6960 "\n Global mlm State - %s "\
6961 "\n",
6962 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6963 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6964 );
6965 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306966
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006967 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05306968 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306969 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006970 if ( pMac->lim.gpSession[count].valid )
6971 {
6972 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6973 "\n Lim Valid Session %d:-"
6974 "\n PE Sme State - %s "
6975 "\n PE Mlm State - %s "
6976 "\n",
6977 check,
6978 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6979 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6980 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306981
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006982 len += buf;
6983 check++;
6984 }
6985 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306986 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306987 }
6988
6989 wrqu->data.length = strlen(extra)+1;
6990 break;
6991 }
6992
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 case WE_GET_CFG:
6994 {
6995 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6996 wrqu->data.length = strlen(extra)+1;
6997 break;
6998 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006999#ifdef WLAN_FEATURE_11AC
7000 case WE_GET_RSSI:
7001 {
7002 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307003 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007004 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7005 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7006 wrqu->data.length = strlen(extra)+1;
7007 break;
7008 }
7009#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307010
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007011#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007012 case WE_GET_ROAM_RSSI:
7013 {
7014 v_S7_t s7Rssi = 0;
7015 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7016 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7017 wrqu->data.length = strlen(extra)+1;
7018 break;
7019 }
7020#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 case WE_GET_WMM_STATUS:
7022 {
7023 snprintf(extra, WE_MAX_STR_LEN,
7024 "\nDir: 0=up, 1=down, 3=both\n"
7025 "|------------------------|\n"
7026 "|AC | ACM |Admitted| Dir |\n"
7027 "|------------------------|\n"
7028 "|VO | %d | %3s | %d |\n"
7029 "|VI | %d | %3s | %d |\n"
7030 "|BE | %d | %3s | %d |\n"
7031 "|BK | %d | %3s | %d |\n"
7032 "|------------------------|\n",
7033 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7034 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7035 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7036 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7037 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7038 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7039 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7040 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7041 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7042 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7043 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7044 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7045
Jeff Johnsone7245742012-09-05 17:12:55 -07007046
Jeff Johnson295189b2012-06-20 16:38:30 -07007047 wrqu->data.length = strlen(extra)+1;
7048 break;
7049 }
7050 case WE_GET_CHANNEL_LIST:
7051 {
7052 VOS_STATUS status;
7053 v_U8_t i, len;
7054 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307055 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7056 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7057 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007058 tChannelListInfo channel_list;
7059
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007060 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007062 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007064 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 return -EINVAL;
7066 }
7067 buf = extra;
7068
7069 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007070 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7071 * needed = 5 * number of channels. Check ifsufficient
7072 * buffer is available and then proceed to fill the buffer.
7073 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007074 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7075 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007076 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007077 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007078 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 return -EINVAL;
7080 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007081 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7082 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307083 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7084 {
7085 //Printing Country code in getChannelList
7086 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7087 {
7088 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7089 "%c ", pBuf[i]);
7090 }
7091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 for(i = 0 ; i < channel_list.num_channels; i++)
7093 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007094 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007096 }
7097 wrqu->data.length = strlen(extra)+1;
7098
7099 break;
7100 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007101#ifdef FEATURE_WLAN_TDLS
7102 case WE_GET_TDLS_PEERS:
7103 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007104 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007105 break;
7106 }
7107#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007108#ifdef WLAN_FEATURE_11W
7109 case WE_GET_11W_INFO:
7110 {
7111 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7112
7113 snprintf(extra, WE_MAX_STR_LEN,
7114 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7115 "\n Number of Unprotected Disassocs %d"
7116 "\n Number of Unprotected Deauths %d",
7117 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7118 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7119 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7120 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7121 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7122
7123 wrqu->data.length = strlen(extra)+1;
7124 break;
7125 }
7126#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307127 case WE_GET_SNR:
7128 {
7129 v_S7_t s7snr = 0;
7130 int status = 0;
7131 hdd_context_t *pHddCtx;
7132 hdd_station_ctx_t *pHddStaCtx;
7133
7134 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7135 status = wlan_hdd_validate_context(pHddCtx);
7136 if (0 != status)
7137 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307138 return status;
7139 }
7140
7141 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7142
7143 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7144 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7145 {
7146 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7147 " ConnectionState-%d", __func__,
7148 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7149 pHddStaCtx->conn_info.connState);
7150 return -ENONET;
7151 }
7152
7153 /*update the stats in TL*/
7154 wlan_hdd_get_station_stats(pAdapter);
7155 wlan_hdd_get_snr(pAdapter, &s7snr);
7156 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7157 wrqu->data.length = strlen(extra) + 1;
7158 break;
7159 }
7160
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307161#ifdef FEATURE_OEM_DATA_SUPPORT
7162 case WE_GET_OEM_DATA_CAP:
7163 {
7164 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7165 }
7166#endif /* FEATURE_OEM_DATA_SUPPORT */
7167
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307168 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007169 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007170 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 break;
7172 }
7173 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307174 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 return 0;
7176}
7177
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307178static int iw_get_char_setnone(struct net_device *dev,
7179 struct iw_request_info *info,
7180 union iwreq_data *wrqu, char *extra)
7181{
7182 int ret;
7183
7184 vos_ssr_protect(__func__);
7185 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7186 vos_ssr_unprotect(__func__);
7187
7188 return ret;
7189}
7190
Jeff Johnson295189b2012-06-20 16:38:30 -07007191/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307192static int __iw_setnone_getnone(struct net_device *dev,
7193 struct iw_request_info *info,
7194 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007195{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307196 hdd_adapter_t *pAdapter;
7197 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307198 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007199 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307200 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007201
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307202 ENTER();
7203
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307204 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7205 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007206 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7208 "%s: Adapter is NULL",__func__);
7209 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007210 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307211 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7212 ret = wlan_hdd_validate_context(pHddCtx);
7213 if (0 != ret)
7214 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307215 return ret;
7216 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307217 /* helper function to get iwreq_data with compat handling. */
7218 if (hdd_priv_get_data(&s_priv_data, wrqu))
7219 {
7220 return -EINVAL;
7221 }
7222
7223 sub_cmd = s_priv_data.flags;
7224
Jeff Johnson295189b2012-06-20 16:38:30 -07007225 switch (sub_cmd)
7226 {
7227 case WE_CLEAR_STATS:
7228 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007230 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7231 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7232 break;
7233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007234 case WE_INIT_AP:
7235 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307236 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7237
7238 /* As Soft AP mode might been changed to STA already with
7239 * killing of Hostapd, need to find the adpater by name
7240 * rather than mode */
7241 hdd_adapter_t* pAdapter_to_stop =
7242 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7243 if( pAdapter_to_stop )
7244 {
7245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7246 "Adapter with name softap.0 already "
7247 "exist, ignoring the request.\nRemove the "
7248 "adapter and try again\n");
7249 break;
7250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007251 pr_info("Init AP trigger\n");
7252 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7253 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7254 break;
7255 }
7256 case WE_STOP_AP:
7257 {
7258 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7259 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7260 * this is a dead code and need to find the adpater by name rather than mode */
7261 hdd_adapter_t* pAdapter_to_stop =
7262 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7263 if( pAdapter_to_stop )
7264 {
7265 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7266
7267 pr_info("Stopping AP mode\n");
7268
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307269 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7270 {
7271 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7272 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7273 }
7274
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307276 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307277 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007278 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7279
7280 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7281 pAdapter_to_stop->macAddressCurrent.bytes);
7282 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7283 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307284
7285 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7286 {
7287 /* put the device back into BMPS */
7288 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 }
7291 else
7292 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007293 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007294 }
7295
7296 break;
7297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007298#ifdef WLAN_BTAMP_FEATURE
7299 case WE_ENABLE_AMP:
7300 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 WLANBAP_RegisterWithHCI(pAdapter);
7303 break;
7304 }
7305 case WE_DISABLE_AMP:
7306 {
7307 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7308 VOS_STATUS status;
7309
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007311
7312 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7313 status = WLANBAP_StopAmp();
7314 if(VOS_STATUS_SUCCESS != status )
7315 {
7316 pHddCtx->isAmpAllowed = VOS_TRUE;
7317 hddLog(VOS_TRACE_LEVEL_FATAL,
7318 "%s: Failed to stop AMP", __func__);
7319 }
7320 else
7321 {
7322 //a state m/c implementation in PAL is TBD to avoid this delay
7323 msleep(500);
7324 pHddCtx->isAmpAllowed = VOS_FALSE;
7325 WLANBAP_DeregisterFromHCI();
7326 }
7327
7328 break;
7329 }
7330#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007331 case WE_ENABLE_DXE_STALL_DETECT:
7332 {
schang6295e542013-03-12 15:31:23 -07007333 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7334 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007335 break;
7336 }
7337 case WE_DISPLAY_DXE_SNAP_SHOT:
7338 {
schang6295e542013-03-12 15:31:23 -07007339 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7340 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007341 break;
7342 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307343 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7344 {
7345 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7346 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307347 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307348 break;
7349 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307350
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307351 case WE_SET_REASSOC_TRIGGER:
7352 {
7353 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7354 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7355 v_U32_t roamId = 0;
7356 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307357 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7358 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307359 return 0;
7360 }
7361
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307362 case WE_STOP_OBSS_SCAN:
7363 {
7364 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7365 2.OBSS scan is stopped by Firmware during the disassociation
7366 3.OBSS stop comamnd is added for debugging purpose*/
7367 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7368 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007369
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307370 if (pAdapter == NULL)
7371 {
7372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7373 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307374 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307375 }
7376 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7377 if (pMac == NULL)
7378 {
7379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7380 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307381 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307382 }
7383 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7384 }
7385 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307386 case WE_DUMP_ROAM_TIMER_LOG:
7387 {
7388 vos_dump_roam_time_log_service();
7389 break;
7390 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307391
Mukul Sharma84f27252014-07-14 18:11:42 +05307392 case WE_RESET_ROAM_TIMER_LOG:
7393 {
7394 vos_reset_roam_timer_log();
7395 break;
7396 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307397 case WE_GET_FW_LOGS:
7398 {
7399 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7400 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307401 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307402 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307403 break;
7404 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307405 case WE_GET_FW_MEMDUMP:
7406 {
7407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7408 "FW_MEM_DUMP requested ");
7409 get_fwr_memdump(dev,info,wrqu,extra);
7410 break;
7411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 default:
7413 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007414 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 break;
7416 }
7417 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307418 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007419 return ret;
7420}
7421
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307422static int iw_setnone_getnone(struct net_device *dev,
7423 struct iw_request_info *info,
7424 union iwreq_data *wrqu, char *extra)
7425{
7426 int ret;
7427
7428 vos_ssr_protect(__func__);
7429 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7430 vos_ssr_unprotect(__func__);
7431
7432 return ret;
7433}
7434
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307435void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7436{
7437 /*
7438 * Function to display HDD WMM information
7439 * for Tx Queues.
7440 * Prints globala as well as per client depending
7441 * whether the clients are registered or not.
7442 */
7443 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307444 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7445 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307446 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7447 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307448 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307449
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307450 for ( i=0; i< NUM_TX_QUEUES; i++)
7451 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307452 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307453 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307454 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307455 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307456
7457 for ( i=0; i< NUM_TX_QUEUES; i++) {
7458 if (tx_queue_count[i]) {
7459 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7460 i, tx_queue_count[i]);
7461 }
7462 }
7463
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307464 if(pSapCtx == NULL){
7465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7466 FL("psapCtx is NULL"));
7467 return;
7468 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307469
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307470 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307471 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7472 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307473 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307474 {
7475 hddLog(LOGE, "******STAIndex: %d*********", i);
7476 for ( j=0; j< NUM_TX_QUEUES; j++)
7477 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307478 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7479 {
7480 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307481 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7482 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307483 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7484 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307485 }
7486 }
7487 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307488 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307489
Katya Nigam1fd24402015-02-16 14:52:19 +05307490 if(pHddStaCtx == NULL){
7491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7492 FL("pHddStaCtx is NULL"));
7493 return;
7494 }
7495
7496 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7497 if(pPeerInfo == NULL){
7498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7499 FL("ppeerinfo is NULL"));
7500 return;
7501 }
7502
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307503 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7504 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7505 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7506 for (j = 0; j < NUM_TX_QUEUES; j++) {
7507 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7508 spin_lock_bh(
7509 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7510 hddLog(LOGE,
7511 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7512 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7513 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7514 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7515 spin_unlock_bh(
7516 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7517 }
7518 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307519 }
7520 }
7521
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307522}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307523
Girish Gowlifb9758e2014-11-19 15:19:17 +05307524static int __iw_set_var_ints_getnone(struct net_device *dev,
7525 struct iw_request_info *info,
7526 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007527{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307528 hdd_adapter_t *pAdapter;
7529 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307530 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307531 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007532 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307533 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307534 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007535 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307536 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007537 int cmd = 0;
7538 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307539 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007540
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307541 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307542 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307543 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7545 "%s: NULL extra buffer pointer", __func__);
7546 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307547 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307548 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7549 if (NULL == pAdapter)
7550 {
7551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7552 "%s: Adapter is NULL",__func__);
7553 return -EINVAL;
7554 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307555 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307556 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7557 ret = wlan_hdd_validate_context(pHddCtx);
7558 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007559 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307560 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007561 }
Katya Nigameae74b62015-05-28 17:19:16 +05307562 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307563 {
Katya Nigameae74b62015-05-28 17:19:16 +05307564 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7565 if (NULL == hHal)
7566 {
7567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7568 "%s: Hal Context is NULL",__func__);
7569 return -EINVAL;
7570 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307571 }
7572 sub_cmd = wrqu->data.flags;
7573
7574 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7575
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007576
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007577 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7578 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7579 {
7580 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7581 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7582 {
7583 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7584 staId = pStaCtx->conn_info.staId[0];
7585 }
7586 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7587 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7588 {
7589 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7590 staId = pAPCtx->uBCStaId;
7591 }
7592 else
7593 {
7594 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7595 return 0;
7596 }
7597 }
7598
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 switch (sub_cmd)
7600 {
7601 case WE_LOG_DUMP_CMD:
7602 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307603 if(apps_args[0] == 26) {
7604 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7605 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7606 return 0;
7607 }
7608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007609 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007610 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007611 apps_args[3], apps_args[4]);
7612
7613 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7614 apps_args[3], apps_args[4]);
7615
7616 }
7617 break;
7618
Jeff Johnson295189b2012-06-20 16:38:30 -07007619 case WE_P2P_NOA_CMD:
7620 {
7621 p2p_app_setP2pPs_t p2pNoA;
7622
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307623 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7624 hddLog(LOGE,
7625 FL("Setting NoA is not allowed in Device mode:%d"),
7626 pAdapter->device_mode);
7627 return -EINVAL;
7628 }
7629
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 p2pNoA.opp_ps = apps_args[0];
7631 p2pNoA.ctWindow = apps_args[1];
7632 p2pNoA.duration = apps_args[2];
7633 p2pNoA.interval = apps_args[3];
7634 p2pNoA.count = apps_args[4];
7635 p2pNoA.single_noa_duration = apps_args[5];
7636 p2pNoA.psSelection = apps_args[6];
7637
7638 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7639 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007640 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7642
7643 hdd_setP2pPs(dev, &p2pNoA);
7644
7645 }
7646 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007647
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307648 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7649 {
7650 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7651 __func__, apps_args[0], apps_args[1]);
7652 vosTraceEnable(apps_args[0], apps_args[1]);
7653 }
7654 break;
7655
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007656 case WE_MTRACE_DUMP_CMD:
7657 {
7658 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7659 "bitmask_of_module %d ",
7660 __func__, apps_args[0], apps_args[1], apps_args[2],
7661 apps_args[3]);
7662 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7663 apps_args[2], apps_args[3]);
7664
7665 }
7666 break;
7667
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007668 case WE_MCC_CONFIG_CREDENTIAL :
7669 {
7670 cmd = 287; //Command should be updated if there is any change
7671 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007672 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007673 {
7674 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7675 }
7676 else
7677 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007678 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007679 return 0;
7680 }
7681 }
7682 break;
7683
7684 case WE_MCC_CONFIG_PARAMS :
7685 {
7686 cmd = 288; //command Should be updated if there is any change
7687 // in the Riva dump command
7688 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7689 }
7690 break;
7691
Chilam NG571c65a2013-01-19 12:27:36 +05307692#ifdef FEATURE_WLAN_TDLS
7693 case WE_TDLS_CONFIG_PARAMS :
7694 {
7695 tdls_config_params_t tdlsParams;
7696
Chilam Ng01120412013-02-19 18:32:21 -08007697 tdlsParams.tdls = apps_args[0];
7698 tdlsParams.tx_period_t = apps_args[1];
7699 tdlsParams.tx_packet_n = apps_args[2];
7700 tdlsParams.discovery_period_t = apps_args[3];
7701 tdlsParams.discovery_tries_n = apps_args[4];
7702 tdlsParams.idle_timeout_t = apps_args[5];
7703 tdlsParams.idle_packet_n = apps_args[6];
7704 tdlsParams.rssi_hysteresis = apps_args[7];
7705 tdlsParams.rssi_trigger_threshold = apps_args[8];
7706 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307707
Chilam Ng01120412013-02-19 18:32:21 -08007708 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307709 }
7710 break;
7711#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307712 case WE_CONFIGURE_MONITOR_MODE:
7713 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307714 v_U32_t magic = 0;
7715 struct completion cmpVar;
7716 long waitRet = 0;
7717
Katya Nigamf0511f62015-05-05 16:40:57 +05307718 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7719 if( pMonCtx == NULL )
7720 {
7721 hddLog(LOGE, "Monitor Context NULL");
7722 break;
7723 }
7724 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7725 __func__, apps_args[0], apps_args[1], apps_args[2],
7726 apps_args[3], apps_args[4]);
7727 /* Input Validation part of FW */
7728 pMonCtx->ChannelNo = apps_args[0];
7729 pMonCtx->ChannelBW = apps_args[1];
7730 pMonCtx->crcCheckEnabled = apps_args[2];
7731 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7732 pMonCtx->is80211to803ConReq = apps_args[4];
7733 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7734 if( pMonCtx->is80211to803ConReq )
7735 pAdapter->dev->type = ARPHRD_ETHER;
7736 else
7737 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7738 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7739 {
7740 hddLog(LOGE, "%s: Filtering data packets as management and control"
7741 " cannot be converted to 802.3 ",__func__);
7742 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7743 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307744 if (MON_MODE_START == pMonCtx->state) {
7745 magic = MON_MODE_MSG_MAGIC;
7746 init_completion(&cmpVar);
7747 if (VOS_STATUS_SUCCESS !=
7748 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7749 pMonCtx, hdd_monPostMsgCb)) {
7750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7751 FL("failed to post MON MODE REQ"));
7752 magic = 0;
7753 ret = -EIO;
7754 break;
7755 }
7756 waitRet = wait_for_completion_timeout(&cmpVar,
7757 MON_MODE_MSG_TIMEOUT);
7758 magic = 0;
7759 if (waitRet <= 0 ) {
7760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7761 FL("failed to wait on monitor mode completion %ld"),
7762 waitRet);
7763 }
7764 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307765 }
7766 break;
7767
7768 case WE_SET_MONITOR_MODE_FILTER:
7769 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307770 v_U32_t magic = 0;
7771 struct completion cmpVar;
7772 long waitRet = 0;
7773
Katya Nigamf0511f62015-05-05 16:40:57 +05307774 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7775 if( pMonCtx == NULL )
7776 {
7777 hddLog(LOGE, "Monitor Context NULL");
7778 break;
7779 }
7780 /* Input Validation Part of FW */
7781 pMonCtx->numOfMacFilters=1;
7782 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7783 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7784 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7785 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7786 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7787 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7788 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7789 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7790 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7791 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7792 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7793 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307794 if (MON_MODE_START == pMonCtx->state) {
7795 magic = MON_MODE_MSG_MAGIC;
7796 init_completion(&cmpVar);
7797 if (VOS_STATUS_SUCCESS !=
7798 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7799 pMonCtx, hdd_monPostMsgCb)) {
7800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7801 FL("failed to post MON MODE REQ"));
7802 magic = 0;
7803 ret = -EIO;
7804 break;
7805 }
7806 waitRet = wait_for_completion_timeout(&cmpVar,
7807 MON_MODE_MSG_TIMEOUT);
7808 magic = 0;
7809 if (waitRet <= 0 ) {
7810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7811 FL("failed to wait on monitor mode completion %ld"),
7812 waitRet);
7813 }
7814 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307815 }
7816 break;
7817
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 default:
7819 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007820 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7821 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 }
7823 break;
7824 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307825 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 return 0;
7827}
7828
Girish Gowlifb9758e2014-11-19 15:19:17 +05307829static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7830 struct iw_request_info *info,
7831 union iwreq_data *wrqu, char *extra)
7832{
7833 int ret;
7834 union iwreq_data u_priv_wrqu;
7835 int apps_args[MAX_VAR_ARGS] = {0};
7836 int num_args;
7837
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05307838 if (!capable(CAP_NET_ADMIN))
7839 {
7840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7841 FL("permission check failed"));
7842 return -EPERM;
7843 }
7844
Girish Gowlifb9758e2014-11-19 15:19:17 +05307845 /* helper function to get iwreq_data with compat handling. */
7846 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7847 {
7848 return -EINVAL;
7849 }
7850
7851 if (NULL == u_priv_wrqu.data.pointer)
7852 {
7853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7854 "%s: NULL data pointer", __func__);
7855 return -EINVAL;
7856 }
7857
7858 num_args = u_priv_wrqu.data.length;
7859 if (num_args > MAX_VAR_ARGS)
7860 {
7861 num_args = MAX_VAR_ARGS;
7862 }
7863
7864 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7865 (sizeof(int)) * num_args))
7866 {
7867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7868 "%s: failed to copy data from user buffer", __func__);
7869 return -EFAULT;
7870 }
7871
7872 vos_ssr_protect(__func__);
7873 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7874 (char *)&apps_args);
7875 vos_ssr_unprotect(__func__);
7876
7877 return ret;
7878}
7879
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307880int iw_set_var_ints_getnone(struct net_device *dev,
7881 struct iw_request_info *info,
7882 union iwreq_data *wrqu, char *extra)
7883{
7884 int ret;
7885 vos_ssr_protect(__func__);
7886 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7887 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007888
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307889 return ret;
7890}
7891
7892static int __iw_add_tspec(struct net_device *dev,
7893 struct iw_request_info *info,
7894 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007895{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307896 hdd_adapter_t *pAdapter;
7897 hdd_station_ctx_t *pHddStaCtx;
7898 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7900 int params[HDD_WLAN_WMM_PARAM_COUNT];
7901 sme_QosWmmTspecInfo tSpec;
7902 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307903 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307904 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007905
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307906 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307907 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7908 if (NULL == pAdapter)
7909 {
7910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7911 "%s: Adapter is NULL",__func__);
7912 return -EINVAL;
7913 }
7914 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7915 ret = wlan_hdd_validate_context(pHddCtx);
7916 if (0 != ret)
7917 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307918 return ret;
7919 }
7920 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7921 if (NULL == pHddStaCtx)
7922 {
7923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7924 "%s: STA Context is NULL",__func__);
7925 return -EINVAL;
7926 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007927 // make sure the application is sufficiently priviledged
7928 // note that the kernel will do this for "set" ioctls, but since
7929 // this ioctl wants to return status to user space it must be
7930 // defined as a "get" ioctl
7931 if (!capable(CAP_NET_ADMIN))
7932 {
7933 return -EPERM;
7934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007935 // we must be associated in order to add a tspec
7936 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7937 {
7938 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7939 return 0;
7940 }
7941
7942 // since we are defined to be a "get" ioctl, and since the number
7943 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307944 // will pass down in the iwreq_data, we must copy the "set" params.
7945 // We must handle the compat for iwreq_data in 32U/64K environment.
7946
7947 // helper fucntion to get iwreq_data with compat handling.
7948 if (hdd_priv_get_data(&s_priv_data, wrqu))
7949 {
7950 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7951 return 0;
7952 }
7953
7954 // make sure all params are correctly passed to function
7955 if ((NULL == s_priv_data.pointer) ||
7956 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7957 {
7958 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7959 return 0;
7960 }
7961
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307963 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007964 {
7965 // hmmm, can't get them
7966 return -EIO;
7967 }
7968
7969 // clear the tspec
7970 memset(&tSpec, 0, sizeof(tSpec));
7971
7972 // validate the handle
7973 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7974 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7975 {
7976 // that one is reserved
7977 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7978 return 0;
7979 }
7980
7981 // validate the TID
7982 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7983 {
7984 // out of range
7985 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7986 return 0;
7987 }
7988 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7989
7990 // validate the direction
7991 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7992 {
7993 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7994 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7995 break;
7996
7997 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7998 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7999 break;
8000
8001 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8002 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8003 break;
8004
8005 default:
8006 // unknown
8007 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8008 return 0;
8009 }
8010
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308011 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8012
Jeff Johnson295189b2012-06-20 16:38:30 -07008013 // validate the user priority
8014 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8015 {
8016 // out of range
8017 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8018 return 0;
8019 }
8020 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308021 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8022 {
8023 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8024 return 0;
8025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008026
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8028 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8029 tSpec.ts_info.psb, tSpec.ts_info.up);
8030
Jeff Johnson295189b2012-06-20 16:38:30 -07008031 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8032 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8033 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8034 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8035 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8036 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8037 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8038 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8039 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8040 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8041 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8042 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8043
8044 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8045
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308046 // Save the expected UAPSD settings by application, this will be needed
8047 // when re-negotiating UAPSD settings during BT Coex cases.
8048 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8049
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 // validate the ts info ack policy
8051 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8052 {
8053 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8054 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8055 break;
8056
8057 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8058 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8059 break;
8060
8061 default:
8062 // unknown
8063 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8064 return 0;
8065 }
8066
8067 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308068
8069 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008070 return 0;
8071}
8072
8073
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308074static int iw_add_tspec(struct net_device *dev,
8075 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 union iwreq_data *wrqu, char *extra)
8077{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308078 int ret;
8079
8080 vos_ssr_protect(__func__);
8081 ret = __iw_add_tspec(dev, info, wrqu, extra);
8082 vos_ssr_unprotect(__func__);
8083
8084 return ret;
8085}
8086
8087static int __iw_del_tspec(struct net_device *dev,
8088 struct iw_request_info *info,
8089 union iwreq_data *wrqu, char *extra)
8090{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308091 hdd_adapter_t *pAdapter;
8092 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 int *params = (int *)extra;
8094 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8095 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308096 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008097
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308098 ENTER();
8099
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308100 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8101 if (NULL == pAdapter)
8102 {
8103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8104 "%s: Adapter is NULL",__func__);
8105 return -EINVAL;
8106 }
8107
8108 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8109 ret = wlan_hdd_validate_context(pHddCtx);
8110 if (0 != ret)
8111 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308112 return ret;
8113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008114 // make sure the application is sufficiently priviledged
8115 // note that the kernel will do this for "set" ioctls, but since
8116 // this ioctl wants to return status to user space it must be
8117 // defined as a "get" ioctl
8118 if (!capable(CAP_NET_ADMIN))
8119 {
8120 return -EPERM;
8121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 // although we are defined to be a "get" ioctl, the params we require
8123 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8124 // is no need to copy the params from user space
8125
8126 // validate the handle
8127 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8128 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8129 {
8130 // that one is reserved
8131 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8132 return 0;
8133 }
8134
8135 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308136
8137 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008138 return 0;
8139}
8140
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308141static int iw_del_tspec(struct net_device *dev,
8142 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 union iwreq_data *wrqu, char *extra)
8144{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308145 int ret;
8146
8147 vos_ssr_protect(__func__);
8148 ret = __iw_del_tspec(dev, info, wrqu, extra);
8149 vos_ssr_unprotect(__func__);
8150
8151 return ret;
8152}
8153
8154
8155static int __iw_get_tspec(struct net_device *dev,
8156 struct iw_request_info *info,
8157 union iwreq_data *wrqu, char *extra)
8158{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308159 hdd_adapter_t *pAdapter;
8160 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 int *params = (int *)extra;
8162 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8163 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308164 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008165
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308166 ENTER();
8167
Jeff Johnson295189b2012-06-20 16:38:30 -07008168 // although we are defined to be a "get" ioctl, the params we require
8169 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8170 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308171 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8172 if (NULL == pAdapter)
8173 {
8174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8175 "%s: Adapter is NULL",__func__);
8176 return -EINVAL;
8177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008178
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308179 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8180 ret = wlan_hdd_validate_context(pHddCtx);
8181 if (0 != ret)
8182 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308183 return ret;
8184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 // validate the handle
8186 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8187 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8188 {
8189 // that one is reserved
8190 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8191 return 0;
8192 }
8193
8194 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308195 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 return 0;
8197}
8198
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308199static int iw_get_tspec(struct net_device *dev,
8200 struct iw_request_info *info,
8201 union iwreq_data *wrqu, char *extra)
8202{
8203 int ret;
8204
8205 vos_ssr_protect(__func__);
8206 ret = __iw_get_tspec(dev, info, wrqu, extra);
8207 vos_ssr_unprotect(__func__);
8208
8209 return ret;
8210}
8211
Jeff Johnson295189b2012-06-20 16:38:30 -07008212#ifdef WLAN_FEATURE_VOWIFI_11R
8213//
8214//
8215// Each time the supplicant has the auth_request or reassoc request
8216// IEs ready. This is pushed to the driver. The driver will inturn use
8217// it to send out the auth req and reassoc req for 11r FT Assoc.
8218//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308219static int __iw_set_fties(struct net_device *dev,
8220 struct iw_request_info *info,
8221 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008222{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308223 hdd_adapter_t *pAdapter;
8224 hdd_station_ctx_t *pHddStaCtx;
8225 hdd_context_t *pHddCtx;
8226 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 //v_CONTEXT_t pVosContext;
8228
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308229 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308230 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8231 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008232 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8234 "%s: Adapter is NULL",__func__);
8235 return -EINVAL;
8236 }
8237 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8238 ret = wlan_hdd_validate_context(pHddCtx);
8239 if (0 != ret)
8240 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308241 return ret;
8242 }
8243 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8244 if (NULL == pHddStaCtx)
8245 {
8246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8247 "%s: STA Context is NULL",__func__);
8248 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 if (!wrqu->data.length)
8251 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008252 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008253 return -EINVAL;
8254 }
8255 if (wrqu->data.pointer == NULL)
8256 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008257 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008258 return -EINVAL;
8259 }
8260
8261 // Added for debug on reception of Re-assoc Req.
8262 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8263 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008264 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008266 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 }
8268
8269#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008270 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008271#endif
8272
8273 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008274 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 wrqu->data.length);
8276
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308277 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 return 0;
8279}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308280
8281static int iw_set_fties(struct net_device *dev,
8282 struct iw_request_info *info,
8283 union iwreq_data *wrqu, char *extra)
8284{
8285 int ret;
8286
8287 vos_ssr_protect(__func__);
8288 ret = __iw_set_fties(dev, info, wrqu, extra);
8289 vos_ssr_unprotect(__func__);
8290
8291 return ret;
8292}
Jeff Johnson295189b2012-06-20 16:38:30 -07008293#endif
8294
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308295static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008296 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008298{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308299 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008300 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308301 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008302 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308303 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008304 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8305 int idx;
8306 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008307
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308308 ENTER();
8309
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308310 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8311 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008312 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8314 "%s: Adapter is NULL",__func__);
8315 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008316 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308317 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8318 ret_val = wlan_hdd_validate_context(pHddCtx);
8319 if (0 != ret_val)
8320 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308321 return ret_val;
8322 }
8323 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8324 if (NULL == hHal)
8325 {
8326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8327 "%s: Hal Context is NULL",__func__);
8328 return -EINVAL;
8329 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308330 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8331 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308332#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008333
Amar Singhalf3a6e762013-02-19 15:06:50 -08008334 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8335 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008336 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008337 hddLog(VOS_TRACE_LEVEL_ERROR,
8338 "%s: vos_mem_alloc failed", __func__);
8339 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008340 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008341
8342 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8343
8344 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8345 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8346
8347 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8348 mc_addr_list_ptr->ulMulticastAddrCnt);
8349
8350 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008351 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008352 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8353 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8354
8355 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8356 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008357 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008358
Amar Singhalf3a6e762013-02-19 15:06:50 -08008359 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8360 vos_mem_free(mc_addr_list_ptr);
8361 if (eHAL_STATUS_SUCCESS != ret_val)
8362 {
8363 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8364 __func__);
8365 return -EINVAL;
8366 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308367#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308368 }
8369 else
8370 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008371
Amar Singhalf3a6e762013-02-19 15:06:50 -08008372 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8373 "%s: Set MC BC Filter Config request: %d suspend %d",
8374 __func__, pRequest->mcastBcastFilterSetting,
8375 pHddCtx->hdd_wlan_suspended);
8376
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308377 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008378
8379 if (pHddCtx->hdd_wlan_suspended)
8380 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008381 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8382 if (NULL == wlanRxpFilterParam)
8383 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308384 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008385 "%s: vos_mem_alloc failed", __func__);
8386 return -EINVAL;
8387 }
8388
Amar Singhalf3a6e762013-02-19 15:06:50 -08008389 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8390 pRequest->mcastBcastFilterSetting;
8391 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8392
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308393 hdd_conf_hostoffload(pAdapter, TRUE);
8394 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8395 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008396
8397 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8398 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308399 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008400 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8401 wlanRxpFilterParam->setMcstBcstFilter);
8402
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308403 if (eHAL_STATUS_SUCCESS !=
8404 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8405 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008406 {
8407 hddLog(VOS_TRACE_LEVEL_ERROR,
8408 "%s: Failure to execute set HW MC/BC Filter request",
8409 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008410 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008411 return -EINVAL;
8412 }
8413
c_hpothud3ce76d2014-10-28 10:34:13 +05308414 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8415 {
8416 pHddCtx->sus_res_mcastbcast_filter =
8417 pRequest->mcastBcastFilterSetting;
8418 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008419 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008421
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308422 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008423 return 0;
8424}
8425
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308426static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8427 struct iw_request_info *info,
8428 union iwreq_data *wrqu, char *extra)
8429{
8430 int ret;
8431
8432 vos_ssr_protect(__func__);
8433 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8434 vos_ssr_unprotect(__func__);
8435
8436 return ret;
8437}
8438
8439static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8440 struct iw_request_info *info,
8441 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008442{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308443 hdd_adapter_t *pAdapter;
8444 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308445 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308446 int ret = 0;
8447
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308448 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008449
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308450 if (!capable(CAP_NET_ADMIN))
8451 {
8452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8453 FL("permission check failed"));
8454 return -EPERM;
8455 }
8456
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308457 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8458 if (NULL == pAdapter)
8459 {
8460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8461 "%s: Adapter is NULL",__func__);
8462 return -EINVAL;
8463 }
8464
8465 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8466 ret = wlan_hdd_validate_context(pHddCtx);
8467 if (0 != ret)
8468 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308469 return ret;
8470 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308471 //Reset the filter to INI value as we have to clear the dynamic filter
8472 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008473
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308474 //Configure FW with new setting
8475 if (pHddCtx->hdd_wlan_suspended)
8476 {
8477 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8478 if (NULL == wlanRxpFilterParam)
8479 {
8480 hddLog(VOS_TRACE_LEVEL_ERROR,
8481 "%s: vos_mem_alloc failed", __func__);
8482 return -EINVAL;
8483 }
8484
8485 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8486 pHddCtx->configuredMcastBcastFilter;
8487 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8488
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308489 hdd_conf_hostoffload(pAdapter, TRUE);
8490 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8491 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308492
8493 if (eHAL_STATUS_SUCCESS !=
8494 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8495 wlanRxpFilterParam))
8496 {
8497 hddLog(VOS_TRACE_LEVEL_ERROR,
8498 "%s: Failure to execute set HW MC/BC Filter request",
8499 __func__);
8500 vos_mem_free(wlanRxpFilterParam);
8501 return -EINVAL;
8502 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308503
8504 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8505 {
8506 pHddCtx->sus_res_mcastbcast_filter =
8507 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8508 }
8509
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308510 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308511 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 return 0;
8513}
8514
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308515
8516static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8517 struct iw_request_info *info,
8518 union iwreq_data *wrqu, char *extra)
8519{
8520 int ret;
8521
8522 vos_ssr_protect(__func__);
8523 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8524 vos_ssr_unprotect(__func__);
8525
8526 return ret;
8527}
8528
8529static int __iw_set_host_offload(struct net_device *dev,
8530 struct iw_request_info *info,
8531 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008532{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308533 hdd_adapter_t *pAdapter;
8534 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008535 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008536 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308537 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008538
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308539 ENTER();
8540
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308541 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8542 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008543 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8545 "%s: Adapter is NULL",__func__);
8546 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008547 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308548 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8549 ret = wlan_hdd_validate_context(pHddCtx);
8550 if (0 != ret)
8551 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308552 return ret;
8553 }
8554
Jeff Johnson295189b2012-06-20 16:38:30 -07008555 /* Debug display of request components. */
8556 switch (pRequest->offloadType)
8557 {
8558 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008559 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 switch (pRequest->enableOrDisable)
8561 {
8562 case WLAN_OFFLOAD_DISABLE:
8563 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8564 break;
8565 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8566 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8567 case WLAN_OFFLOAD_ENABLE:
8568 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8569 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8570 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8571 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8572 }
8573 break;
8574
8575 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008576 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008577 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008578 switch (pRequest->enableOrDisable)
8579 {
8580 case WLAN_OFFLOAD_DISABLE:
8581 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8582 break;
8583 case WLAN_OFFLOAD_ENABLE:
8584 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8585 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8586 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8587 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8588 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8589 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8590 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8591 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8592 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8593 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8594 }
8595 }
8596
8597 /* Execute offload request. The reason that we can copy the request information
8598 from the ioctl structure to the SME structure is that they are laid out
8599 exactly the same. Otherwise, each piece of information would have to be
8600 copied individually. */
8601 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008602 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8603 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008604 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008605 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008606 __func__);
8607 return -EINVAL;
8608 }
8609
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308610 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008611 return 0;
8612}
8613
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308614static int iw_set_host_offload(struct net_device *dev,
8615 struct iw_request_info *info,
8616 union iwreq_data *wrqu, char *extra)
8617{
8618 int ret;
8619
8620 vos_ssr_protect(__func__);
8621 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8622 vos_ssr_unprotect(__func__);
8623
8624 return ret;
8625}
8626
8627static int __iw_set_keepalive_params(struct net_device *dev,
8628 struct iw_request_info *info,
8629 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008630{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308631 hdd_adapter_t *pAdapter;
8632 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008633 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308635 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008636
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308637 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308638 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8639 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008640 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8642 "%s: Adapter is NULL",__func__);
8643 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308645 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8646 ret = wlan_hdd_validate_context(pHddCtx);
8647 if (0 != ret)
8648 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308649 return ret;
8650 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008651 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008652 hddLog(VOS_TRACE_LEVEL_INFO,
8653 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8654 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008655
8656 switch (pRequest->packetType)
8657 {
8658 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008659 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 break;
8661
8662 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8663
Arif Hussain6d2a3322013-11-17 19:50:10 -08008664 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008665 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008666
8667 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8668 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8669 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8670
8671 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8672 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8673 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8674
8675 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8676 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8677 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8678 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8679 break;
8680
8681 }
8682
8683 /* Execute keep alive request. The reason that we can copy the request information
8684 from the ioctl structure to the SME structure is that they are laid out
8685 exactly the same. Otherwise, each piece of information would have to be
8686 copied individually. */
8687 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8688
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308689 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8690 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008691
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008692 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008693 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008694 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008695 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 __func__);
8697 return -EINVAL;
8698 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308699 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 return 0;
8701}
8702
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308703static int iw_set_keepalive_params(struct net_device *dev,
8704 struct iw_request_info *info,
8705 union iwreq_data *wrqu, char *extra)
8706{
8707 int ret;
8708 vos_ssr_protect(__func__);
8709 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8710 vos_ssr_unprotect(__func__);
8711
8712 return ret;
8713}
8714
Jeff Johnson295189b2012-06-20 16:38:30 -07008715#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008716int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008717 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008718{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008719 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8720 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 int i=0;
8722
8723 if (pHddCtx->cfg_ini->disablePacketFilter)
8724 {
8725 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008726 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 return 0;
8728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 /* Debug display of request components. */
8730 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008731 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008732
8733 switch (pRequest->filterAction)
8734 {
8735 case HDD_RCV_FILTER_SET:
8736 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008737 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008738
8739 packetFilterSetReq.filterId = pRequest->filterId;
8740 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8741 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008742 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 __func__, pRequest->numParams);
8744 return -EINVAL;
8745 }
8746 packetFilterSetReq.numFieldParams = pRequest->numParams;
8747 packetFilterSetReq.coalesceTime = 0;
8748 packetFilterSetReq.filterType = 1;
8749 for (i=0; i < pRequest->numParams; i++)
8750 {
8751 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8752 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8753 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8754 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8755 packetFilterSetReq.paramsData[i].reserved = 0;
8756
Arif Hussain6d2a3322013-11-17 19:50:10 -08008757 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8759 packetFilterSetReq.filterType);
8760
Arif Hussain6d2a3322013-11-17 19:50:10 -08008761 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008762 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05308763 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
8764 (pRequest->paramsData[i].dataLength))
8765 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008766
8767 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8768 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8769 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8770 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8771
Arif Hussain6d2a3322013-11-17 19:50:10 -08008772 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008773 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8774 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8775 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8776
Arif Hussain6d2a3322013-11-17 19:50:10 -08008777 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8779 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8780 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8781 }
8782
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008783 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008785 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 __func__);
8787 return -EINVAL;
8788 }
8789
8790 break;
8791
8792 case HDD_RCV_FILTER_CLEAR:
8793
Arif Hussain6d2a3322013-11-17 19:50:10 -08008794 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008795 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008796 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008797 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008798 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008799 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008800 __func__);
8801 return -EINVAL;
8802 }
8803 break;
8804
8805 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008806 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008807 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008808 return -EINVAL;
8809 }
8810 return 0;
8811}
8812
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308813int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8814 tANI_U8 sessionId)
8815{
8816 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8817 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8818
8819 if (NULL == pHddCtx)
8820 {
8821 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8822 return -EINVAL;
8823 }
8824
8825 if (pHddCtx->isLogpInProgress)
8826 {
8827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8828 "%s:LOGP in Progress. Ignore!!!", __func__);
8829 return -EBUSY;
8830 }
8831
8832 if (pHddCtx->cfg_ini->disablePacketFilter)
8833 {
8834 hddLog(VOS_TRACE_LEVEL_ERROR,
8835 "%s: Packet Filtering Disabled. Returning ",
8836 __func__ );
8837 return -EINVAL;
8838 }
8839
8840 switch (filterType)
8841 {
8842 /* For setting IPV6 MC and UC Filter we need to configure
8843 * 2 filters, one for MC and one for UC.
8844 * The Filter ID shouldn't be swapped, which results in making
8845 * UC Filter ineffective.
8846 * We have Hardcode all the values
8847 *
8848 * Reason for a seperate UC filter is because, driver need to
8849 * specify the FW that the specific filter is for unicast
8850 * otherwise FW will not pass the unicast frames by default
8851 * through the filter. This is required to avoid any performance
8852 * hits when no unicast filter is set and only MC/BC are set.
8853 * The way driver informs host is by using the MAC protocol
8854 * layer, CMP flag set to MAX, CMP Data set to 1.
8855 */
8856
8857 case HDD_FILTER_IPV6_MC_UC:
8858 /* Setting IPV6 MC Filter below
8859 */
8860 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8861 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8862 packetFilterSetReq.numFieldParams = 2;
8863 packetFilterSetReq.paramsData[0].protocolLayer =
8864 HDD_FILTER_PROTO_TYPE_MAC;
8865 packetFilterSetReq.paramsData[0].cmpFlag =
8866 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8867 packetFilterSetReq.paramsData[0].dataOffset =
8868 WLAN_HDD_80211_FRM_DA_OFFSET;
8869 packetFilterSetReq.paramsData[0].dataLength = 1;
8870 packetFilterSetReq.paramsData[0].compareData[0] =
8871 HDD_IPV6_MC_CMP_DATA;
8872
8873 packetFilterSetReq.paramsData[1].protocolLayer =
8874 HDD_FILTER_PROTO_TYPE_ARP;
8875 packetFilterSetReq.paramsData[1].cmpFlag =
8876 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8877 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8878 packetFilterSetReq.paramsData[1].dataLength = 2;
8879 packetFilterSetReq.paramsData[1].compareData[0] =
8880 HDD_IPV6_CMP_DATA_0;
8881 packetFilterSetReq.paramsData[1].compareData[1] =
8882 HDD_IPV6_CMP_DATA_1;
8883
8884
8885 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8886 &packetFilterSetReq, sessionId))
8887 {
8888 hddLog(VOS_TRACE_LEVEL_ERROR,
8889 "%s: Failure to execute Set IPv6 Mulicast Filter",
8890 __func__);
8891 return -EINVAL;
8892 }
8893
8894 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8895
8896 /*
8897 * Setting IPV6 UC Filter below
8898 */
8899 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8900 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8901 packetFilterSetReq.numFieldParams = 2;
8902 packetFilterSetReq.paramsData[0].protocolLayer =
8903 HDD_FILTER_PROTO_TYPE_MAC;
8904 packetFilterSetReq.paramsData[0].cmpFlag =
8905 HDD_FILTER_CMP_TYPE_MAX;
8906 packetFilterSetReq.paramsData[0].dataOffset = 0;
8907 packetFilterSetReq.paramsData[0].dataLength = 1;
8908 packetFilterSetReq.paramsData[0].compareData[0] =
8909 HDD_IPV6_UC_CMP_DATA;
8910
8911 packetFilterSetReq.paramsData[1].protocolLayer =
8912 HDD_FILTER_PROTO_TYPE_ARP;
8913 packetFilterSetReq.paramsData[1].cmpFlag =
8914 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8915 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8916 packetFilterSetReq.paramsData[1].dataLength = 2;
8917 packetFilterSetReq.paramsData[1].compareData[0] =
8918 HDD_IPV6_CMP_DATA_0;
8919 packetFilterSetReq.paramsData[1].compareData[1] =
8920 HDD_IPV6_CMP_DATA_1;
8921
8922 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8923 &packetFilterSetReq, sessionId))
8924 {
8925 hddLog(VOS_TRACE_LEVEL_ERROR,
8926 "%s: Failure to execute Set IPv6 Unicast Filter",
8927 __func__);
8928 return -EINVAL;
8929 }
8930
8931 break;
8932
8933 case HDD_FILTER_IPV6_MC:
8934 /*
8935 * IPV6 UC Filter might be already set,
8936 * clear the UC Filter. As the Filter
8937 * IDs are static, we can directly clear it.
8938 */
8939 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8940 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8941 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8942 &packetFilterClrReq, sessionId))
8943 {
8944 hddLog(VOS_TRACE_LEVEL_ERROR,
8945 "%s: Failure to execute Clear IPv6 Unicast Filter",
8946 __func__);
8947 return -EINVAL;
8948 }
8949
8950 /*
8951 * Setting IPV6 MC Filter below
8952 */
8953 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8954 packetFilterSetReq.numFieldParams = 2;
8955 packetFilterSetReq.paramsData[0].protocolLayer =
8956 HDD_FILTER_PROTO_TYPE_MAC;
8957 packetFilterSetReq.paramsData[0].cmpFlag =
8958 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8959 packetFilterSetReq.paramsData[0].dataOffset =
8960 WLAN_HDD_80211_FRM_DA_OFFSET;
8961 packetFilterSetReq.paramsData[0].dataLength = 1;
8962 packetFilterSetReq.paramsData[0].compareData[0] =
8963 HDD_IPV6_MC_CMP_DATA;
8964
8965 packetFilterSetReq.paramsData[1].protocolLayer =
8966 HDD_FILTER_PROTO_TYPE_ARP;
8967 packetFilterSetReq.paramsData[1].cmpFlag =
8968 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8969 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8970 packetFilterSetReq.paramsData[1].dataLength = 2;
8971 packetFilterSetReq.paramsData[1].compareData[0] =
8972 HDD_IPV6_CMP_DATA_0;
8973 packetFilterSetReq.paramsData[1].compareData[1] =
8974 HDD_IPV6_CMP_DATA_1;
8975
8976
8977 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8978 &packetFilterSetReq, sessionId))
8979 {
8980 hddLog(VOS_TRACE_LEVEL_ERROR,
8981 "%s: Failure to execute Set IPv6 Multicast Filter",
8982 __func__);
8983 return -EINVAL;
8984 }
8985 break;
8986
8987 default :
8988 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8989 "%s: Packet Filter Request: Invalid",
8990 __func__);
8991 return -EINVAL;
8992 }
8993 return 0;
8994}
8995
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308996void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008997{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308998 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308999 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009000 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309001 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009002
Yue Ma3ede6052013-08-29 00:33:26 -07009003 if (NULL == pHddCtx)
9004 {
9005 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9006 return;
9007 }
9008
9009 hHal = pHddCtx->hHal;
9010
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309011 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009012 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309013 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9014 return;
9015 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309016
9017 /* Check if INI is enabled or not, other wise just return
9018 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309019 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309020 {
9021 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9022 if (NULL == pMulticastAddrs)
9023 {
9024 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9025 return;
9026 }
9027
Jeff Johnson295189b2012-06-20 16:38:30 -07009028 if (set)
9029 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309030 /* Following pre-conditions should be satisfied before wei
9031 * configure the MC address list.
9032 */
9033 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9034 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9035 && pAdapter->mc_addr_list.mc_cnt
9036 && (eConnectionState_Associated ==
9037 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9038 {
9039 pMulticastAddrs->ulMulticastAddrCnt =
9040 pAdapter->mc_addr_list.mc_cnt;
9041 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9042 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009043 memcpy(pMulticastAddrs->multicastAddr[i],
9044 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309045 sizeof(pAdapter->mc_addr_list.addr[i]));
9046 hddLog(VOS_TRACE_LEVEL_INFO,
9047 "%s: %s multicast filter: addr ="
9048 MAC_ADDRESS_STR,
9049 __func__, set ? "setting" : "clearing",
9050 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9051 }
9052 /* Set multicast filter */
9053 sme_8023MulticastList(hHal, pAdapter->sessionId,
9054 pMulticastAddrs);
9055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309057 else
9058 {
9059 /* Need to clear only if it was previously configured
9060 */
9061 if (pAdapter->mc_addr_list.isFilterApplied)
9062 {
9063 pMulticastAddrs->ulMulticastAddrCnt = 0;
9064 sme_8023MulticastList(hHal, pAdapter->sessionId,
9065 pMulticastAddrs);
9066 }
9067
9068 }
9069 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009070 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309072 else
9073 {
9074 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309075 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309076 }
9077 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009078}
9079
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309080static int __iw_set_packet_filter_params(struct net_device *dev,
9081 struct iw_request_info *info,
9082 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309083{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309084 hdd_adapter_t *pAdapter;
9085 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009086 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309087 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309088 struct iw_point s_priv_data;
9089
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309090 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309091
9092 if (!capable(CAP_NET_ADMIN))
9093 {
9094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9095 FL("permission check failed"));
9096 return -EPERM;
9097 }
9098
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309099 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9100 if (NULL == pAdapter)
9101 {
9102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9103 "%s: Adapter is NULL",__func__);
9104 return -EINVAL;
9105 }
9106 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9107 ret = wlan_hdd_validate_context(pHddCtx);
9108 if (0 != ret)
9109 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309110 return ret;
9111 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309112 if (hdd_priv_get_data(&s_priv_data, wrqu))
9113 {
9114 return -EINVAL;
9115 }
9116
9117 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9118 {
9119 return -EINVAL;
9120 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009121
Arif Hussain0273cba2014-01-07 20:58:29 -08009122 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309123 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9124 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009125 if (NULL == pRequest)
9126 {
9127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9128 "mem_alloc_copy_from_user_helper fail");
9129 return -ENOMEM;
9130 }
9131
9132 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
9133 kfree(pRequest);
9134
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309135 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009136 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009137}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309138
9139static int iw_set_packet_filter_params(struct net_device *dev,
9140 struct iw_request_info *info,
9141 union iwreq_data *wrqu, char *extra)
9142{
9143 int ret;
9144
9145 vos_ssr_protect(__func__);
9146 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9147 vos_ssr_unprotect(__func__);
9148
9149 return ret;
9150}
Jeff Johnson295189b2012-06-20 16:38:30 -07009151#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309152static int __iw_get_statistics(struct net_device *dev,
9153 struct iw_request_info *info,
9154 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009155{
9156
9157 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9158 eHalStatus status = eHAL_STATUS_SUCCESS;
9159 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309160 hdd_adapter_t *pAdapter;
9161 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009162 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309163 int tlen = 0, ret = 0;
9164 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009165
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309166 tCsrGlobalClassAStatsInfo *aStats;
9167 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009168
9169 ENTER();
9170
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309171 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9172 if (NULL == pAdapter)
9173 {
9174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9175 "%s: Adapter is NULL",__func__);
9176 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309178 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9179 ret = wlan_hdd_validate_context(pHddCtx);
9180 if (0 != ret)
9181 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309182 return ret;
9183 }
9184 pStats = &(pAdapter->hdd_stats.summary_stat);
9185 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9186 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9188
9189 wrqu->txpower.value = 0;
9190 }
9191 else {
9192 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9193 SME_SUMMARY_STATS |
9194 SME_GLOBAL_CLASSA_STATS |
9195 SME_GLOBAL_CLASSB_STATS |
9196 SME_GLOBAL_CLASSC_STATS |
9197 SME_GLOBAL_CLASSD_STATS |
9198 SME_PER_STA_STATS,
9199 hdd_StatisticsCB, 0, FALSE,
9200 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9201
9202 if (eHAL_STATUS_SUCCESS != status)
9203 {
9204 hddLog(VOS_TRACE_LEVEL_ERROR,
9205 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009206 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009207 return -EINVAL;
9208 }
9209
9210 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309211 if (NULL == pWextState)
9212 {
9213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9214 "%s: pWextState is NULL",__func__);
9215 return -EINVAL;
9216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009217
9218 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9219 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9220 {
9221 hddLog(VOS_TRACE_LEVEL_ERROR,
9222 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009223 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009224 /*Remove the SME statistics list by passing NULL in callback argument*/
9225 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9226 SME_SUMMARY_STATS |
9227 SME_GLOBAL_CLASSA_STATS |
9228 SME_GLOBAL_CLASSB_STATS |
9229 SME_GLOBAL_CLASSC_STATS |
9230 SME_GLOBAL_CLASSD_STATS |
9231 SME_PER_STA_STATS,
9232 NULL, 0, FALSE,
9233 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9234
9235 return -EINVAL;
9236 }
9237 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9238 (tANI_U8) sizeof (pStats->retry_cnt),
9239 (char*) &(pStats->retry_cnt[0]),
9240 tlen);
9241
9242 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9243 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9244 (char*) &(pStats->multiple_retry_cnt[0]),
9245 tlen);
9246
9247 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9248 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9249 (char*) &(pStats->tx_frm_cnt[0]),
9250 tlen);
9251
9252 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9253 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9254 (char*) &(pStats->rx_frm_cnt),
9255 tlen);
9256
9257 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9258 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9259 (char*) &(pStats->frm_dup_cnt),
9260 tlen);
9261
9262 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9263 (tANI_U8) sizeof (pStats->fail_cnt),
9264 (char*) &(pStats->fail_cnt[0]),
9265 tlen);
9266
9267 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9268 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9269 (char*) &(pStats->rts_fail_cnt),
9270 tlen);
9271
9272 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9273 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9274 (char*) &(pStats->ack_fail_cnt),
9275 tlen);
9276
9277 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9278 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9279 (char*) &(pStats->rts_succ_cnt),
9280 tlen);
9281
9282 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9283 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9284 (char*) &(pStats->rx_discard_cnt),
9285 tlen);
9286
9287 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9288 (tANI_U8) sizeof (pStats->rx_error_cnt),
9289 (char*) &(pStats->rx_error_cnt),
9290 tlen);
9291
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009292 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009293 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009294 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009295 tlen);
9296
9297 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9298 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9299 (char*) &(dStats->rx_byte_cnt),
9300 tlen);
9301
9302 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9303 (tANI_U8) sizeof (dStats->rx_rate),
9304 (char*) &(dStats->rx_rate),
9305 tlen);
9306
9307 /* Transmit rate, in units of 500 kbit/sec */
9308 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9309 (tANI_U8) sizeof (aStats->tx_rate),
9310 (char*) &(aStats->tx_rate),
9311 tlen);
9312
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009313 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9314 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9315 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009316 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009317 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9318 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9319 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009320 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009321 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9322 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9323 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009324 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009325 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9326 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9327 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009328 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009329 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9330 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9331 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009332 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009333 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9334 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9335 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009336 tlen);
9337
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 wrqu->data.length = tlen;
9339
9340 }
9341
9342 EXIT();
9343
9344 return 0;
9345}
9346
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309347static int iw_get_statistics(struct net_device *dev,
9348 struct iw_request_info *info,
9349 union iwreq_data *wrqu, char *extra)
9350{
9351 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009352
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309353 vos_ssr_protect(__func__);
9354 ret = __iw_get_statistics(dev, info, wrqu, extra);
9355 vos_ssr_unprotect(__func__);
9356
9357 return ret;
9358}
Jeff Johnson295189b2012-06-20 16:38:30 -07009359#ifdef FEATURE_WLAN_SCAN_PNO
9360
9361/*Max Len for PNO notification*/
9362#define MAX_PNO_NOTIFY_LEN 100
9363void found_pref_network_cb (void *callbackContext,
9364 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9365{
9366 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9367 union iwreq_data wrqu;
9368 char buf[MAX_PNO_NOTIFY_LEN+1];
9369
9370 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9371 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9372
9373 // create the event
9374 memset(&wrqu, 0, sizeof(wrqu));
9375 memset(buf, 0, sizeof(buf));
9376
9377 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9378 pPrefNetworkFoundInd->ssId.ssId,
9379 (unsigned int)pPrefNetworkFoundInd->rssi);
9380
9381 wrqu.data.pointer = buf;
9382 wrqu.data.length = strlen(buf);
9383
9384 // send the event
9385
9386 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9387
9388}
9389
9390
9391/*string based input*/
9392VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9393 union iwreq_data *wrqu, char *extra, int nOffset)
9394{
9395 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309396 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009397 /* pnoRequest is a large struct, so we make it static to avoid stack
9398 overflow. This API is only invoked via ioctl, so it is
9399 serialized by the kernel rtnl_lock and hence does not need to be
9400 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309401 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 char *ptr;
9403 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309404 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9406
9407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9408 "PNO data len %d data %s",
9409 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009410 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009411
9412 if (wrqu->data.length <= nOffset )
9413 {
9414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9415 return VOS_STATUS_E_FAILURE;
9416 }
9417
9418 pnoRequest.enable = 0;
9419 pnoRequest.ucNetworksCount = 0;
9420 /*-----------------------------------------------------------------------
9421 Input is string based and expected to be like this:
9422
9423 <enabled> <netw_count>
9424 for each network:
9425 <ssid_len> <ssid> <authentication> <encryption>
9426 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9427 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9428
9429 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009430 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 -07009431
9432 this translates into:
9433 -----------------------------
9434 enable PNO
9435 look for 2 networks:
9436 test - with authentication type 0 and encryption type 0,
9437 that can be found on 3 channels: 1 6 and 11 ,
9438 SSID bcast type is unknown (directed probe will be sent if AP not found)
9439 and must meet -40dBm RSSI
9440
9441 test2 - with auth and enrytption type 4/4
9442 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9443 bcast type is non-bcast (directed probe will be sent)
9444 and must not meet any RSSI threshold
9445
Jeff Johnson8301aa12013-03-28 14:27:29 -07009446 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009448 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009449
Wilson Yang623f6592013-10-08 16:33:37 -07009450 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9451 {
9452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9453 "PNO enable input is not valid %s",ptr);
9454 return VOS_STATUS_E_FAILURE;
9455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009456
9457 if ( 0 == pnoRequest.enable )
9458 {
9459 /*Disable PNO*/
9460 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309461 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9462 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 pAdapter->sessionId,
9464 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309465 if (eHAL_STATUS_SUCCESS != status)
9466 {
9467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9468 "%s: failed to disable PNO", __func__);
9469 return VOS_STATUS_E_FAILURE;
9470 }
9471 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 return VOS_STATUS_SUCCESS;
9473 }
9474
c_hpothu37f21312014-04-09 21:49:54 +05309475 if (TRUE == pHddCtx->isPnoEnable)
9476 {
9477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9478 FL("already PNO is enabled"));
9479 return -EBUSY;
9480 }
9481 pHddCtx->isPnoEnable = TRUE;
9482
Jeff Johnson295189b2012-06-20 16:38:30 -07009483 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009484
9485 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9486 {
9487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9488 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309489 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009491
9492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9493 "PNO enable %d networks count %d offset %d",
9494 pnoRequest.enable,
9495 pnoRequest.ucNetworksCount,
9496 nOffset);
9497
9498 /* Parameters checking:
9499 ucNetworksCount has to be larger than 0*/
9500 if (( 0 == pnoRequest.ucNetworksCount ) ||
9501 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9502 {
9503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309504 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009505 }
9506
9507 ptr += nOffset;
9508
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309509 pnoRequest.aNetworks =
9510 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9511 if (pnoRequest.aNetworks == NULL)
9512 {
9513 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9514 FL("failed to allocate memory aNetworks %u"),
9515 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9516 goto error;
9517 }
9518 vos_mem_zero(pnoRequest.aNetworks,
9519 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9520
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9522 {
9523
9524 pnoRequest.aNetworks[i].ssId.length = 0;
9525
Wilson Yang623f6592013-10-08 16:33:37 -07009526 ucParams = sscanf(ptr,"%hhu %n",
9527 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9528
9529 if (1 != ucParams)
9530 {
9531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9532 "PNO ssid length input is not valid %s",ptr);
9533 return VOS_STATUS_E_FAILURE;
9534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009535
9536 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9537 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9538 {
9539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9540 "SSID Len %d is not correct for network %d",
9541 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309542 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 }
9544
9545 /*Advance to SSID*/
9546 ptr += nOffset;
9547
Jeff Johnson8301aa12013-03-28 14:27:29 -07009548 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009549 pnoRequest.aNetworks[i].ssId.length);
9550 ptr += pnoRequest.aNetworks[i].ssId.length;
9551
Jeff Johnson02797792013-10-26 19:17:13 -07009552 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009553 &(pnoRequest.aNetworks[i].authentication),
9554 &(pnoRequest.aNetworks[i].encryption),
9555 &(pnoRequest.aNetworks[i].ucChannelCount),
9556 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009557
Wilson Yang623f6592013-10-08 16:33:37 -07009558 if ( 3 != ucParams )
9559 {
9560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9561 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309562 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009563 }
9564
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009566 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009567 "auth %d encry %d channel count %d offset %d",
9568 pnoRequest.aNetworks[i].ssId.length,
9569 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9570 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9571 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9572 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9573 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9574 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9575 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9576 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9577 pnoRequest.aNetworks[i].authentication,
9578 pnoRequest.aNetworks[i].encryption,
9579 pnoRequest.aNetworks[i].ucChannelCount,
9580 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009581
Jeff Johnson295189b2012-06-20 16:38:30 -07009582 /*Advance to channel list*/
9583 ptr += nOffset;
9584
Wilson Yang623f6592013-10-08 16:33:37 -07009585 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009586 {
9587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9588 "Incorrect number of channels");
9589 return VOS_STATUS_E_FAILURE;
9590 }
9591
9592 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9593 {
9594 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9595 {
Wilson Yang623f6592013-10-08 16:33:37 -07009596 if (1 != sscanf(ptr,"%hhu %n",
9597 &(pnoRequest.aNetworks[i].aChannels[j]),
9598 &nOffset))
9599 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9600 "PNO network channel input is not valid %s",ptr);
9601 return VOS_STATUS_E_FAILURE;
9602 }
9603 /*Advance to next channel number*/
9604 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 }
9606 }
9607
Jeff Johnson02797792013-10-26 19:17:13 -07009608 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009609 &(pnoRequest.aNetworks[i].bcastNetwType),
9610 &nOffset))
9611 {
9612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9613 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309614 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009616
9617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9618 "PNO bcastNetwType %d offset %d",
9619 pnoRequest.aNetworks[i].bcastNetwType,
9620 nOffset );
9621
9622 /*Advance to rssi Threshold*/
9623 ptr += nOffset;
9624
Wilson Yang623f6592013-10-08 16:33:37 -07009625 if (1 != sscanf(ptr,"%hhu %n",
9626 &(pnoRequest.aNetworks[i].rssiThreshold),
9627 &nOffset))
9628 {
9629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9630 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309631 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009633
9634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9635 "PNO rssi %d offset %d",
9636 pnoRequest.aNetworks[i].rssiThreshold,
9637 nOffset );
9638 /*Advance to next network*/
9639 ptr += nOffset;
9640 }/*For ucNetworkCount*/
9641
9642 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009643 &(pnoRequest.scanTimers.ucScanTimersCount),
9644 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009645
9646 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009647 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 {
9649 ptr += nOffset;
9650
Jeff Johnson8301aa12013-03-28 14:27:29 -07009651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9652 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 pnoRequest.scanTimers.ucScanTimersCount,
9654 nOffset );
9655
9656 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9657 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309660 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009661 }
9662
9663 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9664 {
Jeff Johnson02797792013-10-26 19:17:13 -07009665 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009666 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9667 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9668 &nOffset);
9669
Wilson Yang623f6592013-10-08 16:33:37 -07009670 if (2 != ucParams)
9671 {
9672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9673 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309674 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009675 }
9676
Jeff Johnson8301aa12013-03-28 14:27:29 -07009677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9678 "PNO Timer value %d Timer repeat %d offset %d",
9679 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9681 nOffset );
9682
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 ptr += nOffset;
9684 }
9685
9686 }
9687 else
9688 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9690 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009691 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9692
9693 /*Scan timers defaults to 5 minutes*/
9694 pnoRequest.scanTimers.ucScanTimersCount = 1;
9695 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9696 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9697 }
9698
Wilson Yang623f6592013-10-08 16:33:37 -07009699 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009700
9701 pnoRequest.modePNO = ucMode;
9702 /*for LA we just expose suspend option*/
9703 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9704 {
9705 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9706 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309707 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9708 if (pnoRequest.p24GProbeTemplate == NULL){
9709 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9710 FL("failed to allocate memory p24GProbeTemplate %u"),
9711 SIR_PNO_MAX_PB_REQ_SIZE);
9712 goto error;
9713 }
9714
9715 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9716 if (pnoRequest.p5GProbeTemplate == NULL){
9717 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9718 FL("failed to allocate memory p5GProbeTemplate %u"),
9719 SIR_PNO_MAX_PB_REQ_SIZE);
9720 goto error;
9721 }
9722
9723 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9724 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009725
c_hpothu37f21312014-04-09 21:49:54 +05309726 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 pAdapter->sessionId,
9728 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309729 if (eHAL_STATUS_SUCCESS == status)
9730 {
9731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9732 "%s: PNO enabled", __func__);
9733 return VOS_STATUS_SUCCESS;
9734 }
9735error:
9736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9737 "%s: Failed to enable PNO", __func__);
9738 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309739 if (pnoRequest.aNetworks)
9740 vos_mem_free(pnoRequest.aNetworks);
9741 if (pnoRequest.p24GProbeTemplate)
9742 vos_mem_free(pnoRequest.p24GProbeTemplate);
9743 if (pnoRequest.p5GProbeTemplate)
9744 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309745 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009746}/*iw_set_pno*/
9747
9748VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9749 union iwreq_data *wrqu, char *extra, int nOffset)
9750{
9751 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9752 v_U8_t rssiThreshold = 0;
9753 v_U8_t nRead;
9754
Arif Hussain7adce1b2013-11-11 22:59:34 -08009755 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009756 &rssiThreshold);
9757
9758 if ( 1 != nRead )
9759 {
9760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9761 "Incorrect format");
9762 return VOS_STATUS_E_FAILURE;
9763 }
9764
9765 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9766 return VOS_STATUS_SUCCESS;
9767}
9768
9769
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309770static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009771 struct iw_request_info *info,
9772 union iwreq_data *wrqu, char *extra)
9773{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309774 hdd_adapter_t *pAdapter;
9775 hdd_context_t *pHddCtx;
9776 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309777 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309778
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309779 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309780 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9781 if (NULL == pAdapter)
9782 {
9783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9784 "%s: Adapter is NULL",__func__);
9785 return -EINVAL;
9786 }
9787
9788 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9789 ret = wlan_hdd_validate_context(pHddCtx);
9790 if (0 != ret)
9791 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309792 return ret;
9793 }
9794
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009795
9796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009798
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309799 status = iw_set_pno(dev,info,wrqu,extra,0);
9800
9801 EXIT();
9802 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009803}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309804
9805static int iw_set_pno_priv(struct net_device *dev,
9806 struct iw_request_info *info,
9807 union iwreq_data *wrqu, char *extra)
9808{
9809 int ret;
9810
9811 vos_ssr_protect(__func__);
9812 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9813 vos_ssr_unprotect(__func__);
9814
9815 return ret;
9816}
Jeff Johnson295189b2012-06-20 16:38:30 -07009817#endif /*FEATURE_WLAN_SCAN_PNO*/
9818
9819//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309820int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009821{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309822 hdd_adapter_t *pAdapter;
9823 tHalHandle hHal;
9824 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309825 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309826 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309827 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309829 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309830 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309831 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309832
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309833 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309834 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9835 if (NULL == pAdapter)
9836 {
9837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9838 "%s: Adapter is NULL",__func__);
9839 return -EINVAL;
9840 }
9841 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9842 retval = wlan_hdd_validate_context(pHddCtx);
9843 if (0 != retval)
9844 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309845 return retval;
9846 }
9847 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9848 if (NULL == hHal)
9849 {
9850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9851 "%s: Hal Context is NULL",__func__);
9852 return -EINVAL;
9853 }
9854 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009855
Atul Mittal54378cb2014-04-02 16:51:50 +05309856 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 {
9858 case WLAN_HDD_UI_BAND_AUTO:
9859 band = eCSR_BAND_ALL;
9860 break;
9861 case WLAN_HDD_UI_BAND_5_GHZ:
9862 band = eCSR_BAND_5G;
9863 break;
9864 case WLAN_HDD_UI_BAND_2_4_GHZ:
9865 band = eCSR_BAND_24;
9866 break;
9867 default:
9868 band = eCSR_BAND_MAX;
9869 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309870 connectedBand =
9871 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009872
Atul Mittal54378cb2014-04-02 16:51:50 +05309873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009874 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009875
9876 if (band == eCSR_BAND_MAX)
9877 {
9878 /* Received change band request with invalid band value */
9879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309880 "%s: Invalid band value %u", __func__, ui_band);
9881 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 }
9883
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309884 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309885 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309886 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009888 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009889 band, pHddCtx->cfg_ini->nBandCapability);
9890 return -EIO;
9891 }
9892
Sushant Kaushik1165f872015-03-30 20:25:27 +05309893 if (band == eCSR_BAND_ALL)
9894 {
9895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9896 "received. Setting band same as ini value %d"),
9897 pHddCtx->cfg_ini->nBandCapability);
9898 band = pHddCtx->cfg_ini->nBandCapability;
9899 }
9900
Jeff Johnson295189b2012-06-20 16:38:30 -07009901 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9902 {
9903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9904 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009905 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 return -EIO;
9907 }
9908
9909 if (currBand != band)
9910 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309911 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309912 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309913 /* Return failure if current country code is world regulatory domain*/
9914 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9915 pMac->scan.countryCodeCurrent[1] == '0') )
9916 {
9917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9918 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309919 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309920 return -EAGAIN;
9921 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309922 }
9923
Jeff Johnson295189b2012-06-20 16:38:30 -07009924 /* Change band request received.
9925 * Abort pending scan requests, flush the existing scan results,
9926 * and change the band capability
9927 */
9928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9929 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009930 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009931
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309932 /* We need to change the band and flush the scan results here itself
9933 * as we may get timeout for disconnection in which we will return
9934 * with out doing any of these
9935 */
9936 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9937 {
9938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9939 "%s: failed to set the band value to %u ",
9940 __func__, band);
9941 return -EINVAL;
9942 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309943 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9944 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309945 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309946 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9947 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309948 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309949 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9950 * information available in NV so to get the channel information from kernel
9951 * we need to send regulatory hint for the currunt country
9952 * And to set the same country again we need to set the dummy country
9953 * first and then the actual country.
9954 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309955#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9956 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9957#else
9958 regulatory_hint_user("00");
9959#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309960 wait_result = wait_for_completion_interruptible_timeout(
9961 &pHddCtx->linux_reg_req,
9962 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9963
9964 /* if the country information does not exist with the kernel,
9965 then the driver callback would not be called */
9966
9967 if (wait_result >= 0)
9968 {
9969 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9970 "runtime country code is found in kernel db");
9971 }
9972 else
9973 {
9974 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9975 "runtime country code is not found"
9976 " in kernel db");
9977 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309978
9979 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309980
9981 /*
9982 * Update 11dcountry and current country here as the hint
9983 * with 00 results in 11d and current country with 00
9984 */
9985 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9986 WNI_CFG_COUNTRY_CODE_LEN);
9987 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9988 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309989#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9990 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9991#else
9992 regulatory_hint_user(curr_country);
9993#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309994 wait_result = wait_for_completion_interruptible_timeout(
9995 &pHddCtx->linux_reg_req,
9996 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9997
9998 /* if the country information does not exist with the kernel,
9999 then the driver callback would not be called */
10000 if (wait_result >= 0)
10001 {
10002 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10003 "runtime country code is found in kernel db");
10004 }
10005 else
10006 {
10007 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10008 "runtime country code is not found"
10009 " in kernel db");
10010 }
10011
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010012 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010013 }
10014 else
10015 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010016#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010017 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10018 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010019#else
10020 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10021#endif
10022
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010023 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010024 pScanInfo = &pHddCtx->scan_info;
10025 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10026 {
10027 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10028 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10029 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010030 sme_FilterScanResults(hHal, pAdapter->sessionId);
10031
10032 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010033 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10034 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010036 eHalStatus status = eHAL_STATUS_SUCCESS;
10037 long lrc;
10038
10039 /* STA already connected on current band, So issue disconnect first,
10040 * then change the band*/
10041
10042 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010043 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010044 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010045
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10047
10048 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10049 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10050
Jeff Johnson43971f52012-07-17 12:26:56 -070010051 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010052 {
10053 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010054 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010055 __func__, (int)status );
10056 return -EINVAL;
10057 }
10058
10059 lrc = wait_for_completion_interruptible_timeout(
10060 &pAdapter->disconnect_comp_var,
10061 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10062
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010063 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010064
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010065 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010066 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010067
10068 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10069 }
10070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010072 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010073 if (TRUE == pHddCtx->isSetBandByNL)
10074 return 0;
10075 else
10076 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010077}
10078
Atul Mittal54378cb2014-04-02 16:51:50 +053010079int hdd_setBand_helper(struct net_device *dev, const char *command)
10080{
10081 u8 band;
10082
10083 /*convert the band value from ascii to integer*/
10084 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10085
10086 return hdd_setBand(dev, band);
10087
10088}
10089
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010090static int __iw_set_band_config(struct net_device *dev,
10091 struct iw_request_info *info,
10092 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010093{
Atul Mittal54378cb2014-04-02 16:51:50 +053010094 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010095
Arif Hussain0273cba2014-01-07 20:58:29 -080010096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010097
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010098 if (!capable(CAP_NET_ADMIN))
10099 {
10100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10101 FL("permission check failed"));
10102 return -EPERM;
10103 }
10104
Atul Mittal54378cb2014-04-02 16:51:50 +053010105 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010106}
10107
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010108static int iw_set_band_config(struct net_device *dev,
10109 struct iw_request_info *info,
10110 union iwreq_data *wrqu, char *extra)
10111{
10112 int ret;
10113
10114 vos_ssr_protect(__func__);
10115 ret = __iw_set_band_config(dev, info, wrqu, extra);
10116 vos_ssr_unprotect(__func__);
10117
10118 return ret;
10119}
10120
c_manjeecfd1efb2015-09-25 19:32:34 +053010121static int get_fwr_memdump(struct net_device *dev,
10122 struct iw_request_info *info,
10123 union iwreq_data *wrqu, char *extra)
10124{
10125 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10126 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10127 int ret;
10128 ENTER();
10129 // HddCtx sanity
10130 ret = wlan_hdd_validate_context(pHddCtx);
10131 if (0 != ret)
10132 {
10133 return ret;
10134 }
10135 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10136 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10137 {
10138 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10139 return -EINVAL;
10140 }
10141 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10142
10143 EXIT();
10144 return ret;
10145}
10146
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010147static int __iw_set_power_params_priv(struct net_device *dev,
10148 struct iw_request_info *info,
10149 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010150{
Arif Hussain0273cba2014-01-07 20:58:29 -080010151 int ret;
10152 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010153
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10155 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010156
10157 if (!capable(CAP_NET_ADMIN))
10158 {
10159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10160 FL("permission check failed"));
10161 return -EPERM;
10162 }
10163
Arif Hussain0273cba2014-01-07 20:58:29 -080010164 /* ODD number is used for set, copy data using copy_from_user */
10165 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10166 wrqu->data.length);
10167 if (NULL == ptr)
10168 {
10169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10170 "mem_alloc_copy_from_user_helper fail");
10171 return -ENOMEM;
10172 }
10173
10174 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10175 kfree(ptr);
10176 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010177}
10178
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010179static int iw_set_power_params_priv(struct net_device *dev,
10180 struct iw_request_info *info,
10181 union iwreq_data *wrqu, char *extra)
10182{
10183 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010184
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010185 vos_ssr_protect(__func__);
10186 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10187 vos_ssr_unprotect(__func__);
10188
10189 return ret;
10190}
Jeff Johnson295189b2012-06-20 16:38:30 -070010191
10192/*string based input*/
10193VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10194 union iwreq_data *wrqu, char *extra, int nOffset)
10195{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010196 hdd_adapter_t *pAdapter;
10197 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 tSirSetPowerParamsReq powerRequest;
10199 char *ptr;
10200 v_U8_t ucType;
10201 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010202 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010203
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010204 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010205 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10206 if (NULL == pAdapter)
10207 {
10208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10209 "%s: Adapter is NULL",__func__);
10210 return -EINVAL;
10211 }
10212
10213 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10214 ret = wlan_hdd_validate_context(pHddCtx);
10215 if (0 != ret)
10216 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010217 return ret;
10218 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10220 "Power Params data len %d data %s",
10221 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010222 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010223
10224 if (wrqu->data.length <= nOffset )
10225 {
10226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10227 return VOS_STATUS_E_FAILURE;
10228 }
10229
10230 uTotalSize = wrqu->data.length - nOffset;
10231
10232 /*-----------------------------------------------------------------------
10233 Input is string based and expected to be like this:
10234
10235 <param_type> <param_value> <param_type> <param_value> ...
10236
10237 e.g:
10238 1 2 2 3 3 0 4 1 5 1
10239
10240 e.g. setting just a few:
10241 1 2 4 1
10242
10243 parameter types:
10244 -----------------------------
10245 1 - Ignore DTIM
10246 2 - Listen Interval
10247 3 - Broadcast Multicas Filter
10248 4 - Beacon Early Termination
10249 5 - Beacon Early Termination Interval
10250 -----------------------------------------------------------------------*/
10251 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10252 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10253 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10254 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10255 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10256
Arif Hussain7adce1b2013-11-11 22:59:34 -080010257 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010258
10259 while ( uTotalSize )
10260 {
Wilson Yang6f971452013-10-08 15:00:00 -070010261 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10262 {
10263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10264 "Invalid input parameter type %s",ptr);
10265 return VOS_STATUS_E_FAILURE;
10266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010267
10268 uTotalSize -= nOffset;
10269
10270 if (!uTotalSize)
10271 {
10272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010273 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010274 ucType, nOffset);
10275 return VOS_STATUS_E_FAILURE;
10276 }
10277
10278 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010279
Jeff Johnson02797792013-10-26 19:17:13 -070010280 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010281 {
10282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10283 "Invalid input parameter value %s",ptr);
10284 return VOS_STATUS_E_FAILURE;
10285 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010286
10287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10288 "Power request parameter %d value %d offset %d",
10289 ucType, uValue, nOffset);
10290
10291 switch (ucType)
10292 {
10293 case eSIR_IGNORE_DTIM:
10294 powerRequest.uIgnoreDTIM = uValue;
10295 break;
10296 case eSIR_LISTEN_INTERVAL:
10297 powerRequest.uListenInterval = uValue;
10298 break;
10299 case eSIR_MCAST_BCAST_FILTER:
10300 powerRequest.uBcastMcastFilter = uValue;
10301 break;
10302 case eSIR_ENABLE_BET:
10303 powerRequest.uEnableBET = uValue;
10304 break;
10305 case eSIR_BET_INTERVAL:
10306 powerRequest.uBETInterval = uValue;
10307 break;
10308 default:
10309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010310 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010311 ucType, uValue, nOffset);
10312 return VOS_STATUS_E_FAILURE;
10313 }
10314
10315 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10317 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010318 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010319 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010320 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010321 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010322 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10323 {
10324 uTotalSize = 0;
10325 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010326
10327 }/*Go for as long as we have a valid string*/
10328
10329 /* put the device into full power*/
10330 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10331
10332 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010333 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010334
10335 /* put the device back to power save*/
10336 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10337
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010338 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010339 return VOS_STATUS_SUCCESS;
10340}/*iw_set_power_params*/
10341
Atul Mittalc0f739f2014-07-31 13:47:47 +053010342// tdlsoffchan
10343#ifdef FEATURE_WLAN_TDLS
10344
Atul Mittal87ec2422014-09-24 13:12:50 +053010345int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010346{
10347 if (offchannel < 0 || offchannel > 165)
10348 {
10349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10350 __func__, offchannel);
10351 return -1;
10352
10353 }
10354
10355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10356 __func__, tdlsOffCh, offchannel);
10357
10358 tdlsOffCh = offchannel;
10359 return 0;
10360}
10361
Atul Mittal87ec2422014-09-24 13:12:50 +053010362int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010363{
10364 if (offchanoffset == 0)
10365 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010366 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10368 __func__, tdlsOffChBwOffset);
10369
10370 return 0;
10371
10372 }
10373
10374 if ( offchanoffset == 40 )
10375 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010376 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10378 __func__, tdlsOffChBwOffset);
10379
10380 return 0;
10381
10382 }
10383 if (offchanoffset == -40)
10384 {
10385 tdlsOffChBwOffset = 3;
10386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10387 __func__, tdlsOffChBwOffset);
10388
10389 return 0;
10390
10391 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010392
10393 if ((offchanoffset == 80) &&
10394 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10395 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10396 {
10397 tdlsOffChBwOffset = 4;
10398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10399 "%s: change tdls secondary off channel offset to %u",
10400 __func__, tdlsOffChBwOffset);
10401
10402 return 0;
10403 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10405 __func__, offchanoffset);
10406 return -1;
10407}
10408
Atul Mittal87ec2422014-09-24 13:12:50 +053010409int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010410{
10411 hddTdlsPeer_t *connPeer = NULL;
10412 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10413 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010414 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010415 if (offchanmode < 0 || offchanmode > 4)
10416 {
10417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10418 "%s: Invalid tdls off channel mode %d",
10419 __func__, offchanmode);
10420 return -1;
10421 }
10422
10423 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10424 {
10425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10426 "%s: tdls off channel mode req in not associated state %d",
10427 __func__, offchanmode);
10428 return -1;
10429 }
10430
10431 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10432 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10433 {
10434 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010435 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010436 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010437 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010438 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10440 "%s: No TDLS Connected Peer", __func__);
10441 return -1;
10442 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010443 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010444 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010445 }
10446 else
10447 {
10448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10449 "%s: TDLS Connection not supported", __func__);
10450 return -1;
10451 }
10452
10453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10454 ("%s: TDLS Channel Switch in swmode=%d"),
10455 __func__, offchanmode);
10456
10457 switch (offchanmode)
10458 {
10459 case 1:/*Enable*/
10460 case 2:/*Disable*/
10461 {
10462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10463 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10464 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10465 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10466 {
10467
10468 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010469 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010470 tdlsOffCh, tdlsOffChBwOffset,
10471 offchanmode);
10472 }
10473 else
10474 {
10475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10476 "%s: TDLS Off Channel not supported", __func__);
10477 return -1;
10478 }
10479 break;
10480 }
10481 case 3:
10482 {
10483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10484 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10485 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10486
10487 break;
10488 }
10489 case 4:
10490 {
10491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10492 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10493 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10494 break;
10495 }
10496 default:
10497 {
10498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10499 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10500 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10501 break;
10502 }
10503
10504 }
10505
10506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10507 __func__, offchanmode);
10508 return 0;
10509}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010510#endif
10511
Jeff Johnson295189b2012-06-20 16:38:30 -070010512
10513// Define the Wireless Extensions to the Linux Network Device structure
10514// A number of these routines are NULL (meaning they are not implemented.)
10515
10516static const iw_handler we_handler[] =
10517{
10518 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10519 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10520 (iw_handler) NULL, /* SIOCSIWNWID */
10521 (iw_handler) NULL, /* SIOCGIWNWID */
10522 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10523 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10524 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10525 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10526 (iw_handler) NULL, /* SIOCSIWSENS */
10527 (iw_handler) NULL, /* SIOCGIWSENS */
10528 (iw_handler) NULL, /* SIOCSIWRANGE */
10529 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10530 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
10531 (iw_handler) NULL, /* SIOCGIWPRIV */
10532 (iw_handler) NULL, /* SIOCSIWSTATS */
10533 (iw_handler) NULL, /* SIOCGIWSTATS */
10534 iw_handler_set_spy, /* SIOCSIWSPY */
10535 iw_handler_get_spy, /* SIOCGIWSPY */
10536 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10537 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10538 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10539 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10540 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10541 (iw_handler) NULL, /* SIOCGIWAPLIST */
10542 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10543 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10544 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10545 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10546 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10547 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10548 (iw_handler) NULL, /* -- hole -- */
10549 (iw_handler) NULL, /* -- hole -- */
10550 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10551 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10552 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10553 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10554 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10555 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10556 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10557 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10558 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10559 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10560 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10561 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10562 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10563 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10564 (iw_handler) NULL, /* -- hole -- */
10565 (iw_handler) NULL, /* -- hole -- */
10566 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10567 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10568 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10569 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10570 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10571 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10572 (iw_handler) NULL, /* SIOCSIWPMKSA */
10573};
10574
10575static const iw_handler we_private[] = {
10576
10577 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10578 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10579 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10580 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10581 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10582 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010583 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010584 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10585 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10586 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010587#ifdef FEATURE_OEM_DATA_SUPPORT
10588 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10589 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10590#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010591
Jeff Johnson295189b2012-06-20 16:38:30 -070010592#ifdef WLAN_FEATURE_VOWIFI_11R
10593 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10594#endif
10595 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10596 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10597 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10598#ifdef WLAN_FEATURE_PACKET_FILTERING
10599 ,
10600 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10601#endif
10602#ifdef FEATURE_WLAN_SCAN_PNO
10603 ,
10604 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10605#endif
10606 ,
10607 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10608 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10609 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10610 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010611 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010612};
10613
10614/*Maximum command length can be only 15 */
10615static const struct iw_priv_args we_private_args[] = {
10616
Katya Nigamf0511f62015-05-05 16:40:57 +053010617 { WE_SET_MONITOR_STATE,
10618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10619 0, "monitor" },
10620
Jeff Johnson295189b2012-06-20 16:38:30 -070010621 /* handlers for main ioctl */
10622 { WLAN_PRIV_SET_INT_GET_NONE,
10623 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10624 0,
10625 "" },
10626
10627 /* handlers for sub-ioctl */
10628 { WE_SET_11D_STATE,
10629 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10630 0,
10631 "set11Dstate" },
10632
10633 { WE_WOWL,
10634 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10635 0,
10636 "wowl" },
10637
10638 { WE_SET_POWER,
10639 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10640 0,
10641 "setPower" },
10642
10643 { WE_SET_MAX_ASSOC,
10644 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10645 0,
10646 "setMaxAssoc" },
10647
10648 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10649 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10650 0,
10651 "setAutoChannel" },
10652
10653 { WE_SET_DATA_INACTIVITY_TO,
10654 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10655 0,
10656 "inactivityTO" },
10657
10658 { WE_SET_MAX_TX_POWER,
10659 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10660 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010661 "setMaxTxPower" },
10662
10663 { WE_SET_MAX_TX_POWER_2_4,
10664 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10665 0,
10666 "setTxMaxPower2G" },
10667
10668 { WE_SET_MAX_TX_POWER_5_0,
10669 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10670 0,
10671 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010672
10673 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10674 * as well to keep same syntax as in SAP. Now onwards, STA
10675 * will support both */
10676 { WE_SET_MAX_TX_POWER,
10677 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10678 0,
10679 "setTxMaxPower" },
10680
Jeff Johnson295189b2012-06-20 16:38:30 -070010681 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10682 * 1 = enable and 0 = disable */
10683 {
10684 WE_SET_HIGHER_DTIM_TRANSITION,
10685 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10686 0,
10687 "setHDtimTransn" },
10688
10689 { WE_SET_TM_LEVEL,
10690 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010691 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010692 "setTmLevel" },
10693
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010694 { WE_ENABLE_STRICT_FCC_REG,
10695 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10696 0,
10697 "setStrictFCCreg" },
10698
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010699 { WE_SET_DEBUG_LOG,
10700 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10701 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010702#ifdef FEATURE_WLAN_TDLS
10703 {
10704 WE_SET_TDLS_OFF_CHAN,
10705 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10706 0,
10707 "tdlsoffchan" },
10708 {
10709 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10710 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10711 0,
10712 "tdlsecchnoffst" },
10713 {
10714 WE_SET_TDLS_OFF_CHAN_MODE,
10715 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10716 0,
10717 "tdlsoffchnmode" },
10718#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010719
Peng Xu2446a892014-09-05 17:21:18 +053010720 { WE_SET_SCAN_BAND_PREFERENCE,
10721 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10722 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010723 {
10724 WE_GET_FRAME_LOG,
10725 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10726 0,
10727 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010728
Abhishek Singh01c73d12015-03-12 15:13:44 +053010729 { WE_SET_MIRACAST_VENDOR_CONFIG,
10730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10731 0, "setMiracstConf" },
10732
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010733#ifdef FEATURE_WLAN_TDLS
10734 {
10735 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10736 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10737 0,
10738 "tdls_2040bsscox" },
10739#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010740 { WE_SET_RTS_CTS_HTVHT,
10741 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10742 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010743 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10744 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10745 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053010746 { WE_SET_PROXIMITY_ENABLE,
10747 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10748 0, "setProximity" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 /* handlers for main ioctl */
10750 { WLAN_PRIV_SET_NONE_GET_INT,
10751 0,
10752 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10753 "" },
10754
10755 /* handlers for sub-ioctl */
10756 { WE_GET_11D_STATE,
10757 0,
10758 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10759 "get11Dstate" },
10760
10761 { WE_IBSS_STATUS,
10762 0,
10763 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10764 "getAdhocStatus" },
10765
10766 { WE_PMC_STATE,
10767 0,
10768 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10769 "pmcState" },
10770
10771 { WE_GET_WLAN_DBG,
10772 0,
10773 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10774 "getwlandbg" },
10775
Jeff Johnson295189b2012-06-20 16:38:30 -070010776 { WE_GET_MAX_ASSOC,
10777 0,
10778 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10779 "getMaxAssoc" },
10780
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 { WE_GET_WDI_DBG,
10782 0,
10783 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10784 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010785
10786 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10787 0,
10788 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10789 "getAutoChannel" },
10790
10791 { WE_GET_CONCURRENCY_MODE,
10792 0,
10793 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10794 "getconcurrency" },
10795
Peng Xu2446a892014-09-05 17:21:18 +053010796 { WE_GET_SCAN_BAND_PREFERENCE,
10797 0,
10798 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10799 "get_scan_pref"},
10800
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053010801 { WE_GET_ANTENA_DIVERSITY_SELECTION,
10802 0,
10803 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10804 "getCurAnt"},
10805
Jeff Johnson295189b2012-06-20 16:38:30 -070010806 /* handlers for main ioctl */
10807 { WLAN_PRIV_SET_CHAR_GET_NONE,
10808 IW_PRIV_TYPE_CHAR| 512,
10809 0,
10810 "" },
10811
10812 /* handlers for sub-ioctl */
10813 { WE_WOWL_ADD_PTRN,
10814 IW_PRIV_TYPE_CHAR| 512,
10815 0,
10816 "wowlAddPtrn" },
10817
10818 { WE_WOWL_DEL_PTRN,
10819 IW_PRIV_TYPE_CHAR| 512,
10820 0,
10821 "wowlDelPtrn" },
10822
10823#if defined WLAN_FEATURE_VOWIFI
10824 /* handlers for sub-ioctl */
10825 { WE_NEIGHBOR_REPORT_REQUEST,
10826 IW_PRIV_TYPE_CHAR | 512,
10827 0,
10828 "neighbor" },
10829#endif
10830 { WE_SET_AP_WPS_IE,
10831 IW_PRIV_TYPE_CHAR| 512,
10832 0,
10833 "set_ap_wps_ie" },
10834
10835 { WE_SET_CONFIG,
10836 IW_PRIV_TYPE_CHAR| 512,
10837 0,
10838 "setConfig" },
10839
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010840 { WE_SET_ENCRYPT_MSG,
10841 IW_PRIV_TYPE_CHAR| 512,
10842 0,
10843 "encryptMsg" },
10844
10845
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 /* handlers for main ioctl */
10847 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10848 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10849 0,
10850 "" },
10851
10852 /* handlers for sub-ioctl */
10853 { WE_SET_WLAN_DBG,
10854 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10855 0,
10856 "setwlandbg" },
10857
Jeff Johnson295189b2012-06-20 16:38:30 -070010858 { WE_SET_WDI_DBG,
10859 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10860 0,
10861 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010862
10863 { WE_SET_SAP_CHANNELS,
10864 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10865 0,
10866 "setsapchannels" },
10867
10868 /* handlers for main ioctl */
10869 { WLAN_PRIV_GET_CHAR_SET_NONE,
10870 0,
10871 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10872 "" },
10873
10874 /* handlers for sub-ioctl */
10875 { WE_WLAN_VERSION,
10876 0,
10877 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10878 "version" },
10879 { WE_GET_STATS,
10880 0,
10881 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10882 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010883 { WE_GET_STATES,
10884 0,
10885 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10886 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010887 { WE_GET_CFG,
10888 0,
10889 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10890 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010891#ifdef WLAN_FEATURE_11AC
10892 { WE_GET_RSSI,
10893 0,
10894 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10895 "getRSSI" },
10896#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010897#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010898 { WE_GET_ROAM_RSSI,
10899 0,
10900 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10901 "getRoamRSSI" },
10902#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010903 { WE_GET_WMM_STATUS,
10904 0,
10905 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10906 "getWmmStatus" },
10907 {
10908 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010909 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010910 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10911 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010912#ifdef FEATURE_WLAN_TDLS
10913 {
10914 WE_GET_TDLS_PEERS,
10915 0,
10916 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10917 "getTdlsPeers" },
10918#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010919#ifdef WLAN_FEATURE_11W
10920 {
10921 WE_GET_11W_INFO,
10922 0,
10923 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10924 "getPMFInfo" },
10925#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010926 { WE_GET_SNR,
10927 0,
10928 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10929 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053010930#ifdef FEATURE_OEM_DATA_SUPPORT
10931 {
10932 WE_GET_OEM_DATA_CAP,
10933 0,
10934 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10935 "getOemDataCap" },
10936#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070010937 /* handlers for main ioctl */
10938 { WLAN_PRIV_SET_NONE_GET_NONE,
10939 0,
10940 0,
10941 "" },
10942
10943 /* handlers for sub-ioctl */
10944 { WE_CLEAR_STATS,
10945 0,
10946 0,
10947 "clearStats" },
10948 { WE_INIT_AP,
10949 0,
10950 0,
10951 "initAP" },
10952 { WE_STOP_AP,
10953 0,
10954 0,
10955 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010956#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010957 { WE_ENABLE_AMP,
10958 0,
10959 0,
10960 "enableAMP" },
10961 { WE_DISABLE_AMP,
10962 0,
10963 0,
10964 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010965#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010966 { WE_ENABLE_DXE_STALL_DETECT,
10967 0,
10968 0,
10969 "dxeStallDetect" },
10970 { WE_DISPLAY_DXE_SNAP_SHOT,
10971 0,
10972 0,
10973 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010974 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10975 0,
10976 0,
10977 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010978 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010979 WE_SET_REASSOC_TRIGGER,
10980 0,
10981 0,
10982 "reassoc" },
10983 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010984 WE_STOP_OBSS_SCAN,
10985 0,
10986 0,
10987 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010988 {
10989 WE_DUMP_ROAM_TIMER_LOG,
10990 0,
10991 0,
10992 "dumpRoamDelay" },
10993 {
10994 WE_RESET_ROAM_TIMER_LOG,
10995 0,
10996 0,
10997 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010998 {
10999 WE_GET_FW_LOGS,
11000 0,
11001 0,
11002 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011003 {
11004 WE_GET_FW_MEMDUMP,
11005 0,
11006 0,
11007 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 /* handlers for main ioctl */
11009 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11010 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11011 0,
11012 "" },
11013
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011014
11015
Jeff Johnson295189b2012-06-20 16:38:30 -070011016 /* handlers for sub-ioctl */
11017 { WE_LOG_DUMP_CMD,
11018 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11019 0,
11020 "dump" },
11021
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011022 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011023 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11024 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11025 0,
11026 "setdumplog" },
11027
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011028 { WE_MTRACE_DUMP_CMD,
11029 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11030 0,
11031 "dumplog" },
11032
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011033 /* handlers for sub ioctl */
11034 {
11035 WE_MCC_CONFIG_CREDENTIAL,
11036 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11037 0,
11038 "setMccCrdnl" },
11039
11040 /* handlers for sub ioctl */
11041 {
11042 WE_MCC_CONFIG_PARAMS,
11043 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11044 0,
11045 "setMccConfig" },
11046
Chilam NG571c65a2013-01-19 12:27:36 +053011047#ifdef FEATURE_WLAN_TDLS
11048 /* handlers for sub ioctl */
11049 {
11050 WE_TDLS_CONFIG_PARAMS,
11051 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11052 0,
11053 "setTdlsConfig" },
11054#endif
11055
Katya Nigamf0511f62015-05-05 16:40:57 +053011056 {
11057 WE_CONFIGURE_MONITOR_MODE,
11058 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11059 0,
11060 "MonitorModeConf" },
11061
11062 {
11063 WE_SET_MONITOR_MODE_FILTER,
11064 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11065 0,
11066 "MonitorFilter" },
11067
Jeff Johnson295189b2012-06-20 16:38:30 -070011068 /* handlers for main ioctl */
11069 { WLAN_PRIV_ADD_TSPEC,
11070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11071 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11072 "addTspec" },
11073
11074 /* handlers for main ioctl */
11075 { WLAN_PRIV_DEL_TSPEC,
11076 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11077 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11078 "delTspec" },
11079
11080 /* handlers for main ioctl */
11081 { WLAN_PRIV_GET_TSPEC,
11082 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11083 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11084 "getTspec" },
11085
Jeff Johnsone7245742012-09-05 17:12:55 -070011086#ifdef FEATURE_OEM_DATA_SUPPORT
11087 /* handlers for main ioctl - OEM DATA */
11088 {
11089 WLAN_PRIV_SET_OEM_DATA_REQ,
11090 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11091 0,
11092 "set_oem_data_req" },
11093
11094 /* handlers for main ioctl - OEM DATA */
11095 {
11096 WLAN_PRIV_GET_OEM_DATA_RSP,
11097 0,
11098 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11099 "get_oem_data_rsp" },
11100#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011101
Jeff Johnson295189b2012-06-20 16:38:30 -070011102 /* handlers for main ioctl - host offload */
11103 {
11104 WLAN_PRIV_SET_HOST_OFFLOAD,
11105 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11106 0,
11107 "setHostOffload" },
11108
11109 {
11110 WLAN_GET_WLAN_STATISTICS,
11111 0,
11112 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11113 "getWlanStats" },
11114
11115 {
11116 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011117 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11118 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011119 0,
11120 "setKeepAlive" },
11121#ifdef WLAN_FEATURE_PACKET_FILTERING
11122 {
11123 WLAN_SET_PACKET_FILTER_PARAMS,
11124 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11125 0,
11126 "setPktFilter" },
11127#endif
11128#ifdef FEATURE_WLAN_SCAN_PNO
11129 {
11130 WLAN_SET_PNO,
11131 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11132 0,
11133 "setpno" },
11134#endif
11135 {
11136 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011137 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011138 0,
11139 "SETBAND" },
11140 /* handlers for dynamic MC BC ioctl */
11141 {
11142 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011143 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011144 0,
11145 "setMCBCFilter" },
11146 {
11147 WLAN_PRIV_CLEAR_MCBC_FILTER,
11148 0,
11149 0,
11150 "clearMCBCFilter" },
11151 {
11152 WLAN_SET_POWER_PARAMS,
11153 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11154 0,
11155 "setpowerparams" },
11156 {
11157 WLAN_GET_LINK_SPEED,
11158 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011159 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011160};
11161
11162
11163
11164const struct iw_handler_def we_handler_def = {
11165 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11166 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11167 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11168
11169 .standard = (iw_handler *)we_handler,
11170 .private = (iw_handler *)we_private,
11171 .private_args = we_private_args,
11172 .get_wireless_stats = get_wireless_stats,
11173};
11174
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011175int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11176{
11177 v_U32_t cmd = 288; //Command to RIVA
11178 hdd_context_t *pHddCtx = NULL;
11179 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11180 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11181 /*
11182 *configMccParam : specify the bit which needs to be modified
11183 *allowed to update based on wlan_qcom_cfg.ini
11184 * configuration
11185 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11186 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11187 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11188 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11189 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11190 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11191 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11192 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11193 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11194 * Bit 9 : Reserved
11195 */
11196 switch (arg1)
11197 {
11198 //Update MCC SCHEDULE_TIME_SLICE parameter
11199 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11200 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11201 {
11202 if((arg2 >= 5) && (arg2 <= 20))
11203 {
11204 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11205 }
11206 else
11207 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011208 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011209 return 0;
11210 }
11211 }
11212 break;
11213
11214 //Update MCC MAX_NULL_SEND_TIME parameter
11215 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11216 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11217 {
11218 if((arg2 >= 1) && (arg2 <= 10))
11219 {
11220 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11221 }
11222 else
11223 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011224 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011225 return 0;
11226 }
11227 }
11228 break;
11229
11230 //Update MCC TX_EARLY_STOP_TIME parameter
11231 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11232 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11233 {
11234 if((arg2 >= 1) && (arg2 <= 10))
11235 {
11236 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11237 }
11238 else
11239 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011240 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011241 return 0;
11242 }
11243 }
11244 break;
11245
11246 //Update MCC RX_DRAIN_TIME parameter
11247 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11248 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11249 {
11250 if((arg2 >= 1) && (arg2 <= 10))
11251 {
11252 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11253 }
11254 else
11255 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011256 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011257 return 0;
11258 }
11259 }
11260 break;
11261
11262 //Update MCC CHANNEL_SWITCH_TIME parameter
11263 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11264 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11265 {
11266 if((arg2 >= 1) && (arg2 <= 20))
11267 {
11268 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11269 }
11270 else
11271 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011272 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011273 return 0;
11274 }
11275 }
11276 break;
11277
11278 //Update MCC MIN_CHANNEL_TIME parameter
11279 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11280 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11281 {
11282 if((arg2 >= 5) && (arg2 <= 20))
11283 {
11284 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11285 }
11286 else
11287 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011288 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011289 return 0;
11290 }
11291 }
11292 break;
11293
11294 //Update MCC PARK_BEFORE_TBTT parameter
11295 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11296 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11297 {
11298 if((arg2 >= 1) && (arg2 <= 5))
11299 {
11300 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11301 }
11302 else
11303 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011304 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011305 return 0;
11306 }
11307 }
11308 break;
11309
11310 //Update MCC MIN_AFTER_DTIM parameter
11311 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11312 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11313 {
11314 if((arg2 >= 5) && (arg2 <= 15))
11315 {
11316 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11317 }
11318 else
11319 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011320 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011321 return 0;
11322 }
11323 }
11324 break;
11325
11326 //Update MCC TOO_CLOSE_MARGIN parameter
11327 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11328 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11329 {
11330 if((arg2 >= 1) && (arg2 <= 3))
11331 {
11332 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11333 }
11334 else
11335 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011336 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011337 return 0;
11338 }
11339 }
11340 break;
11341
11342 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011343 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011344 __FUNCTION__,arg1);
11345 break;
11346 }
11347 return 0;
11348}
11349
Jeff Johnson295189b2012-06-20 16:38:30 -070011350int hdd_set_wext(hdd_adapter_t *pAdapter)
11351{
11352 hdd_wext_state_t *pwextBuf;
11353 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011354 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011355
11356 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11357
11358 // Now configure the roaming profile links. To SSID and bssid.
11359 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11360 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11361
11362 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11363 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11364
11365 /*Set the numOfChannels to zero to scan all the channels*/
11366 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11367 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11368
11369 /* Default is no encryption */
11370 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11371 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11372
11373 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11374 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11375
11376 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11377
11378 /* Default is no authentication */
11379 pwextBuf->roamProfile.AuthType.numEntries = 1;
11380 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11381
11382 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11383 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11384
11385 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011386 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011387
11388 hdd_clearRoamProfileIe(pAdapter);
11389
11390 return VOS_STATUS_SUCCESS;
11391
11392 }
11393
11394int hdd_register_wext(struct net_device *dev)
11395 {
11396 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11397 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11398 VOS_STATUS status;
11399
11400 ENTER();
11401
11402 // Zero the memory. This zeros the profile structure.
11403 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11404
11405 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11406
11407
11408 status = hdd_set_wext(pAdapter);
11409
11410 if(!VOS_IS_STATUS_SUCCESS(status)) {
11411
Arif Hussain6d2a3322013-11-17 19:50:10 -080011412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011413 return eHAL_STATUS_FAILURE;
11414 }
11415
11416 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11417 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 return eHAL_STATUS_FAILURE;
11420 }
11421
11422 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11423 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011425 return eHAL_STATUS_FAILURE;
11426 }
11427
11428 // Register as a wireless device
11429 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11430
11431 EXIT();
11432 return 0;
11433}
11434
11435int hdd_UnregisterWext(struct net_device *dev)
11436{
c_hpothu2a13bc32015-01-21 12:48:54 +053011437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11438 if (dev != NULL)
11439 {
11440 rtnl_lock();
11441 dev->wireless_handlers = NULL;
11442 rtnl_unlock();
11443 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011444
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 return 0;
11446}
11447
11448