blob: 3462628e25deae329a53b13417c5a62be326edf4 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
c_hpothu002231a2015-02-05 14:58:51 +05302 * Copyright (c) 2011-2015 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
Jeff Johnson295189b2012-06-20 16:38:30 -0700175
176/* Private ioctls and their sub-ioctls */
177#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
178#define WE_GET_11D_STATE 1
179#define WE_IBSS_STATUS 2
180#define WE_PMC_STATE 3
181#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700182#define WE_GET_MAX_ASSOC 6
183#define WE_GET_WDI_DBG 7
184#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
185#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530186#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700187/* Private ioctls and their sub-ioctls */
188#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
189
190/* Private ioctls and their sub-ioctls */
191#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
192#define WE_WOWL_ADD_PTRN 1
193#define WE_WOWL_DEL_PTRN 2
194#if defined WLAN_FEATURE_VOWIFI
195#define WE_NEIGHBOR_REPORT_REQUEST 3
196#endif
197#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
198#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530199#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700200
201/* Private ioctls and their sub-ioctls */
202#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
203#define WE_SET_WLAN_DBG 1
204#define WE_SET_WDI_DBG 2
205#define WE_SET_SAP_CHANNELS 3
206
207/* Private ioctls and their sub-ioctls */
208#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
209#define WE_WLAN_VERSION 1
210#define WE_GET_STATS 2
211#define WE_GET_CFG 3
212#define WE_GET_WMM_STATUS 4
213#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700214#ifdef WLAN_FEATURE_11AC
215#define WE_GET_RSSI 6
216#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800217#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800218#ifdef FEATURE_WLAN_TDLS
219#define WE_GET_TDLS_PEERS 8
220#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700221#ifdef WLAN_FEATURE_11W
222#define WE_GET_11W_INFO 9
223#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530224#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530225#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700226
227/* Private ioctls and their sub-ioctls */
228#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
229#define WE_CLEAR_STATS 1
230#define WE_INIT_AP 2
231#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530232#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700233#define WE_ENABLE_AMP 4
234#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530235#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700236#define WE_ENABLE_DXE_STALL_DETECT 6
237#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700238#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530239#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530240#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530241#define WE_DUMP_ROAM_TIMER_LOG 12
242#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530243#define WE_GET_FW_LOGS 14
Mukul Sharma84f27252014-07-14 18:11:42 +0530244
Jeff Johnson295189b2012-06-20 16:38:30 -0700245/* Private ioctls and their sub-ioctls */
246#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
247#define WE_LOG_DUMP_CMD 1
248
Jeff Johnson295189b2012-06-20 16:38:30 -0700249#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800250//IOCTL to configure MCC params
251#define WE_MCC_CONFIG_CREDENTIAL 3
252#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700253
Chilam NG571c65a2013-01-19 12:27:36 +0530254#ifdef FEATURE_WLAN_TDLS
255#define WE_TDLS_CONFIG_PARAMS 5
256#endif
257
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700258#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530259#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530260#define WE_CONFIGURE_MONITOR_MODE 10
261#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700262
Chilam Ng01120412013-02-19 18:32:21 -0800263#ifdef FEATURE_WLAN_TDLS
264#undef MAX_VAR_ARGS
265#define MAX_VAR_ARGS 10
266#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700267#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800268#endif
269
Jeff Johnson295189b2012-06-20 16:38:30 -0700270/* Private ioctls (with no sub-ioctls) */
271/* note that they must be odd so that they have "get" semantics */
272#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
273#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
274#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
275
Girish Gowli464c9c82014-06-09 19:47:53 +0530276/* (SIOCIWFIRSTPRIV + 8) is currently unused */
277/* (SIOCIWFIRSTPRIV + 16) is currently unused */
278/* (SIOCIWFIRSTPRIV + 10) is currently unused */
279/* (SIOCIWFIRSTPRIV + 12) is currently unused */
280/* (SIOCIWFIRSTPRIV + 14) is currently unused */
281/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700282
Jeff Johnsone7245742012-09-05 17:12:55 -0700283#ifdef FEATURE_OEM_DATA_SUPPORT
284/* Private ioctls for setting the measurement configuration */
285#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
286#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
287#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
289#ifdef WLAN_FEATURE_VOWIFI_11R
290#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
291#endif
292
293/* Private ioctl for setting the host offload feature */
294#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
295
296/* Private ioctl to get the statistics */
297#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
298
299/* Private ioctl to set the Keep Alive Params */
300#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
301#ifdef WLAN_FEATURE_PACKET_FILTERING
302/* Private ioctl to set the Packet Filtering Params */
303#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
304#endif
305
306#ifdef FEATURE_WLAN_SCAN_PNO
307/* Private ioctl to get the statistics */
308#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
309#endif
310
311#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
312
313#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
314#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700315/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700316
Jeff Johnson295189b2012-06-20 16:38:30 -0700317#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
318#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
319
320#define WLAN_STATS_INVALID 0
321#define WLAN_STATS_RETRY_CNT 1
322#define WLAN_STATS_MUL_RETRY_CNT 2
323#define WLAN_STATS_TX_FRM_CNT 3
324#define WLAN_STATS_RX_FRM_CNT 4
325#define WLAN_STATS_FRM_DUP_CNT 5
326#define WLAN_STATS_FAIL_CNT 6
327#define WLAN_STATS_RTS_FAIL_CNT 7
328#define WLAN_STATS_ACK_FAIL_CNT 8
329#define WLAN_STATS_RTS_SUC_CNT 9
330#define WLAN_STATS_RX_DISCARD_CNT 10
331#define WLAN_STATS_RX_ERROR_CNT 11
332#define WLAN_STATS_TX_BYTE_CNT 12
333
334#define WLAN_STATS_RX_BYTE_CNT 13
335#define WLAN_STATS_RX_RATE 14
336#define WLAN_STATS_TX_RATE 15
337
Jeff Johnsone7245742012-09-05 17:12:55 -0700338#define WLAN_STATS_RX_UC_BYTE_CNT 16
339#define WLAN_STATS_RX_MC_BYTE_CNT 17
340#define WLAN_STATS_RX_BC_BYTE_CNT 18
341#define WLAN_STATS_TX_UC_BYTE_CNT 19
342#define WLAN_STATS_TX_MC_BYTE_CNT 20
343#define WLAN_STATS_TX_BC_BYTE_CNT 21
344
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800345#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
346 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
347 { \
348 *__p++ = __type; \
349 *__p++ = __size; \
350 memcpy(__p, __val, __size); \
351 __p += __size; \
352 __tlen += __size + 2; \
353 } \
354 else \
355 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800356 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800357 } \
358 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700359
360#define VERSION_VALUE_MAX_LEN 32
361
362#define TX_PER_TRACKING_DEFAULT_RATIO 5
363#define TX_PER_TRACKING_MAX_RATIO 10
364#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
365
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530366#define WLAN_ADAPTER 0
367#define P2P_ADAPTER 1
368
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530369/*
370 * When supplicant sends SETBAND ioctl it queries for channels from
371 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
372 * This is not required if the return type from ioctl is
373 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
374 * event as part of regulatory_hint.
375 */
376enum {
377 SEND_CHANNEL_CHANGE_EVENT = 0,
378 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
379};
380
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800381/*MCC Configuration parameters */
382enum {
383 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
384 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
385 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
386 MCC_RX_DRAIN_TIME_CFG_PARAM,
387 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
388 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
389 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
390 MCC_MIN_AFTER_DTIM_CFG_PARAM,
391 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
392};
393
394int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
395 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
396
Jeff Johnson295189b2012-06-20 16:38:30 -0700397#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800398int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700399 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700400#endif
401
Jeff Johnson295189b2012-06-20 16:38:30 -0700402/**---------------------------------------------------------------------------
403
Arif Hussain0273cba2014-01-07 20:58:29 -0800404 \brief mem_alloc_copy_from_user_helper -
405
406 Helper function to allocate buffer and copy user data.
407
408 \param - wrqu - Pointer to IOCTL Data.
409 len - size
410
411 \return - On Success pointer to buffer, On failure NULL
412
413 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530414void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800415{
416 u8 *ptr = NULL;
417
418 /* in order to protect the code, an extra byte is post appended to the buffer
419 * and the null termination is added. However, when allocating (len+1) byte
420 * of memory, we need to make sure that there is no uint overflow when doing
421 * addition. In theory check len < UINT_MAX protects the uint overflow. For
422 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
423 * guess, now, it is assumed that the private command buffer size is no
424 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
425 */
426 if (len > MAX_USER_COMMAND_SIZE)
427 {
428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
429 "Invalid length");
430 return NULL;
431 }
432
433 ptr = kmalloc(len + 1, GFP_KERNEL);
434 if (NULL == ptr)
435 {
436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
437 "unable to allocate memory");
438 return NULL;
439 }
440
441 if (copy_from_user(ptr, wrqu_data, len))
442 {
443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
444 "%s: failed to copy data to user buffer", __func__);
445 kfree(ptr);
446 return NULL;
447 }
448 ptr[len] = '\0';
449 return ptr;
450}
451
Girish Gowli488ef492014-06-12 18:44:33 +0530452// Function to handle and get compatible struct iw_point passed to ioctl.
453int hdd_priv_get_data(struct iw_point *p_priv_data,
454 union iwreq_data *wrqu)
455{
456 if ((NULL == p_priv_data) || (NULL == wrqu))
457 {
458 return -EINVAL;
459 }
460
461#ifdef CONFIG_COMPAT
462 if (is_compat_task())
463 {
464 struct compat_iw_point *p_compat_priv_data;
465
466 // Compat task: typecast to campat structure and copy the members.
467 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
468
469 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
470 p_priv_data->length = p_compat_priv_data->length;
471 p_priv_data->flags = p_compat_priv_data->flags;
472 }//if(is_compat_task())
473 else
474 {
475#endif //#ifdef CONFIG_COMPAT
476
477 // Non compat task: directly copy the structure.
478 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
479
480#ifdef CONFIG_COMPAT
481 }//else of - if(is_compat_task())
482#endif //#ifdef CONFIG_COMPAT
483
484 return 0;
485}
486
Arif Hussain0273cba2014-01-07 20:58:29 -0800487/**---------------------------------------------------------------------------
488
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 \brief hdd_wlan_get_version() -
490
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800491 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700492
493 \param - pAdapter Pointer to the adapter.
494 wrqu - Pointer to IOCTL REQUEST Data.
495 extra - Pointer to char
496
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800497 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
499 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800500void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
501 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700502{
503 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800504 tSirVersionString wcnss_SW_version;
505 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530506 tSirVersionString iris_name;
507 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800508 char *pSWversion;
509 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700511
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800512 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
513 sizeof(wcnss_SW_version));
514 if (VOS_IS_STATUS_SUCCESS(status))
515 {
516 pSWversion = wcnss_SW_version;
517 }
518 else
519 {
520 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 }
522
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800523 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
524 sizeof(wcnss_HW_version));
525 if (VOS_IS_STATUS_SUCCESS(status))
526 {
527 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700528 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800529 else
530 {
531 pHWversion = "Unknown";
532 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530534 status = wcnss_get_iris_name(iris_name);
535
536 if (!status) {
537 pIRISversion = iris_name;
538 } else {
539 pIRISversion = "Unknown";
540 }
541
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700542 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530543 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800544 QWLAN_VERSIONSTR,
545 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530546 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800547
548 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700549}
550
Jeff Johnson295189b2012-06-20 16:38:30 -0700551int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
552{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530553 tHalHandle hHal;
554 hdd_context_t *pHddCtx;
555 v_U32_t threshold = 0;
556 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700557
558 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530559 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530560 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
562 "%s: Adapter is NULL",__func__);
563 return -EINVAL;
564 }
565
566 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
567 ret = wlan_hdd_validate_context(pHddCtx);
568 if (0 != ret)
569 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530570 return ret;
571 }
572
573 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
574 if (NULL == hHal)
575 {
576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
577 "%s: Hal Context is NULL",__func__);
578 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 }
580
581 if ( eHAL_STATUS_SUCCESS !=
582 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
583 {
c_hpothub8245442013-11-20 23:41:09 +0530584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
585 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 return -EIO;
587 }
588 wrqu->rts.value = threshold;
589
590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800591 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700592
593 EXIT();
594
595 return 0;
596}
597
598int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
599{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530600 tHalHandle hHal;
601 hdd_context_t *pHddCtx;
602 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700603
604 ENTER();
605
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530606 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530607 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
609 "%s: Adapter is NULL",__func__);
610 return -EINVAL;
611 }
612
613 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
614 status = wlan_hdd_validate_context(pHddCtx);
615 if (0 != status)
616 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530617 return status;
618 }
619
620 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
621 if (NULL == hHal)
622 {
623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
624 "%s: Hal Context is NULL",__func__);
625 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 }
627
628 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
629 != eHAL_STATUS_SUCCESS )
630 {
c_hpothub8245442013-11-20 23:41:09 +0530631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
632 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 return -EIO;
634 }
635 wrqu->frag.value = threshold;
636
637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800638 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700639
640 EXIT();
641
642 return 0;
643}
644
645int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
646{
Jeff Johnsone7245742012-09-05 17:12:55 -0700647 int i;
648 if (channel > 0)
649 {
650 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
651 {
652 if (channel == freq_chan_map[i].chan)
653 {
654 *pfreq = freq_chan_map[i].freq;
655 return 1;
656 }
657 }
658 }
659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800660 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700661 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700662}
663
664static v_BOOL_t
665hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
666{
667 v_BOOL_t rsnType = VOS_FALSE;
668 // is the authType supported?
669 switch (authType)
670 {
671 case eCSR_AUTH_TYPE_NONE: //never used
672 rsnType = eANI_BOOLEAN_FALSE;
673 break;
674 // MAC layer authentication types
675 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
676 rsnType = eANI_BOOLEAN_FALSE;
677 break;
678 case eCSR_AUTH_TYPE_SHARED_KEY:
679 rsnType = eANI_BOOLEAN_FALSE;
680 break;
681 case eCSR_AUTH_TYPE_AUTOSWITCH:
682 rsnType = eANI_BOOLEAN_FALSE;
683 break;
684
685 // Upper layer authentication types
686 case eCSR_AUTH_TYPE_WPA:
687 rsnType = eANI_BOOLEAN_TRUE;
688 break;
689 case eCSR_AUTH_TYPE_WPA_PSK:
690 rsnType = eANI_BOOLEAN_TRUE;
691 break;
692 case eCSR_AUTH_TYPE_WPA_NONE:
693 rsnType = eANI_BOOLEAN_TRUE;
694 break;
695#ifdef WLAN_FEATURE_VOWIFI_11R
696 case eCSR_AUTH_TYPE_FT_RSN:
697#endif
698 case eCSR_AUTH_TYPE_RSN:
699 rsnType = eANI_BOOLEAN_TRUE;
700 break;
701#ifdef WLAN_FEATURE_VOWIFI_11R
702 case eCSR_AUTH_TYPE_FT_RSN_PSK:
703#endif
704 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700705#ifdef WLAN_FEATURE_11W
706 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530707 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700708#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700709 rsnType = eANI_BOOLEAN_TRUE;
710 break;
711 //case eCSR_AUTH_TYPE_FAILED:
712 case eCSR_AUTH_TYPE_UNKNOWN:
713 rsnType = eANI_BOOLEAN_FALSE;
714 break;
715 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800716 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
717 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 rsnType = eANI_BOOLEAN_FALSE;
719 break;
720 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800721 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700722 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 return rsnType;
724}
725
726static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
727{
728 struct statsContext *pStatsContext;
729 hdd_adapter_t *pAdapter;
730
731 if (ioctl_debug)
732 {
733 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700734 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 }
736
737 if (NULL == pContext)
738 {
739 hddLog(VOS_TRACE_LEVEL_ERROR,
740 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700741 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 return;
743 }
744
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 pStatsContext = pContext;
746 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800747
748 /* there is a race condition that exists between this callback
749 function and the caller since the caller could time out either
750 before or while this code is executing. we use a spinlock to
751 serialize these actions */
752 spin_lock(&hdd_context_lock);
753
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
755 {
756 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800757 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 hddLog(VOS_TRACE_LEVEL_WARN,
759 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700760 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 if (ioctl_debug)
762 {
763 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700764 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 }
766 return;
767 }
768
Jeff Johnson72a40512013-12-19 10:14:15 -0800769 /* context is valid so caller is still waiting */
770
771 /* paranoia: invalidate the magic */
772 pStatsContext->magic = 0;
773
774 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530776 if (pAdapter->rssi > 0)
777 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800778 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800780
781 /* serialization is complete */
782 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700783}
784
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530785static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
786{
787 struct statsContext *pStatsContext;
788 hdd_adapter_t *pAdapter;
789
790 if (ioctl_debug)
791 {
792 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
793 __func__, (int)snr, (int)staId, pContext);
794 }
795
796 if (NULL == pContext)
797 {
798 hddLog(VOS_TRACE_LEVEL_ERROR,
799 "%s: Bad param, pContext [%p]",
800 __func__, pContext);
801 return;
802 }
803
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530804 pStatsContext = pContext;
805 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800806
807 /* there is a race condition that exists between this callback
808 function and the caller since the caller could time out either
809 before or while this code is executing. we use a spinlock to
810 serialize these actions */
811 spin_lock(&hdd_context_lock);
812
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530813 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
814 {
815 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800816 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530817 hddLog(VOS_TRACE_LEVEL_WARN,
818 "%s: Invalid context, pAdapter [%p] magic [%08x]",
819 __func__, pAdapter, pStatsContext->magic);
820 if (ioctl_debug)
821 {
822 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
823 __func__, pAdapter, pStatsContext->magic);
824 }
825 return;
826 }
827
Jeff Johnson72a40512013-12-19 10:14:15 -0800828 /* context is valid so caller is still waiting */
829
830 /* paranoia: invalidate the magic */
831 pStatsContext->magic = 0;
832
833 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530834 pAdapter->snr = snr;
835
Jeff Johnson72a40512013-12-19 10:14:15 -0800836 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530837 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800838
839 /* serialization is complete */
840 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530841}
842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
844{
845 struct statsContext context;
846 hdd_context_t *pHddCtx;
847 hdd_station_ctx_t *pHddStaCtx;
848 eHalStatus hstatus;
849 long lrc;
850
851 if (NULL == pAdapter)
852 {
853 hddLog(VOS_TRACE_LEVEL_WARN,
854 "%s: Invalid context, pAdapter", __func__);
855 return VOS_STATUS_E_FAULT;
856 }
857 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
858 {
859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
860 /* return a cached value */
861 *rssi_value = pAdapter->rssi;
862 return VOS_STATUS_SUCCESS;
863 }
864
865 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
866 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
867
mukul sharma8aec69b2015-06-10 22:28:43 +0530868 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
869 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
871 __func__, pAdapter->rssi_on_disconnect);
872 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +0530873 return VOS_STATUS_SUCCESS;
874 }
875
876 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
877 {
878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
879 "%s: Roaming in progress, hence return last cached RSSI", __func__);
880 *rssi_value = pAdapter->rssi;
881 return VOS_STATUS_SUCCESS;
882 }
883
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 init_completion(&context.completion);
885 context.pAdapter = pAdapter;
886 context.magic = RSSI_CONTEXT_MAGIC;
887
888 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
889 pHddStaCtx->conn_info.staId[ 0 ],
890 pHddStaCtx->conn_info.bssId,
891 &context, pHddCtx->pvosContext);
892 if (eHAL_STATUS_SUCCESS != hstatus)
893 {
894 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700895 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 /* we'll returned a cached value below */
897 }
898 else
899 {
900 /* request was sent -- wait for the response */
901 lrc = wait_for_completion_interruptible_timeout(&context.completion,
902 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 if (lrc <= 0)
904 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800905 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700906 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 /* we'll now returned a cached value below */
908 }
909 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800910
911 /* either we never sent a request, we sent a request and received a
912 response or we sent a request and timed out. if we never sent a
913 request or if we sent a request and got a response, we want to
914 clear the magic out of paranoia. if we timed out there is a
915 race condition such that the callback function could be
916 executing at the same time we are. of primary concern is if the
917 callback function had already verified the "magic" but had not
918 yet set the completion variable when a timeout occurred. we
919 serialize these activities by invalidating the magic while
920 holding a shared spinlock which will cause us to block if the
921 callback is currently executing */
922 spin_lock(&hdd_context_lock);
923 context.magic = 0;
924 spin_unlock(&hdd_context_lock);
925
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 *rssi_value = pAdapter->rssi;
927
928 return VOS_STATUS_SUCCESS;
929}
Siddharth Bhal64246172015-02-27 01:04:37 +0530930/**---------------------------------------------------------------------------
931
932 \brief wlan_hdd_get_frame_logs() -
933
934 This function use to get Frames log.
935
936 \param - pAdapter Pointer to the adapter.
937 flag - Specify type of request. Clear and Send request are
938 supported.
939
940 \return - none
941
942 --------------------------------------------------------------------------*/
943VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
944{
Siddharth Bhal64246172015-02-27 01:04:37 +0530945 hdd_context_t *pHddCtx;
946 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +0530947
948 if (NULL == pAdapter)
949 {
950 hddLog(VOS_TRACE_LEVEL_WARN,
951 "%s: Invalid context, pAdapter", __func__);
952 return VOS_STATUS_E_FAULT;
953 }
954
955 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
956 if (!pHddCtx->mgmt_frame_logging)
957 {
958 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
959 return VOS_STATUS_E_AGAIN;
960 }
961
Siddharth Bhal4507c262015-04-29 20:20:42 +0530962 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
963 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
964 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +0530965 {
966 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
967 return VOS_STATUS_E_INVAL;
968 }
969
Siddharth Bhal4507c262015-04-29 20:20:42 +0530970 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
971 (!pHddCtx->cfg_ini->enableBMUHWtracing))
972 {
973 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
974 return VOS_STATUS_E_INVAL;
975 }
976
Abhishek Singh611295e2015-07-09 11:11:54 +0530977 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +0530978 if (eHAL_STATUS_SUCCESS != hstatus)
979 {
980 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +0530981 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +0530982 }
Siddharth Bhal64246172015-02-27 01:04:37 +0530983
984 return VOS_STATUS_SUCCESS;
985}
986
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530987
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530988VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
989{
990 struct statsContext context;
991 hdd_context_t *pHddCtx;
992 hdd_station_ctx_t *pHddStaCtx;
993 eHalStatus hstatus;
994 long lrc;
995 int valid;
996
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530997 ENTER();
998
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530999 if (NULL == pAdapter)
1000 {
1001 hddLog(VOS_TRACE_LEVEL_ERROR,
1002 "%s: Invalid context, pAdapter", __func__);
1003 return VOS_STATUS_E_FAULT;
1004 }
1005
1006 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1007
1008 valid = wlan_hdd_validate_context(pHddCtx);
1009 if (0 != valid)
1010 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301011 return VOS_STATUS_E_FAULT;
1012 }
1013
1014 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1015 if (NULL == pHddStaCtx)
1016 {
1017 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1018 return VOS_STATUS_E_FAULT;
1019 }
1020
1021 init_completion(&context.completion);
1022 context.pAdapter = pAdapter;
1023 context.magic = SNR_CONTEXT_MAGIC;
1024
1025 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1026 pHddStaCtx->conn_info.staId[ 0 ],
1027 pHddStaCtx->conn_info.bssId,
1028 &context);
1029 if (eHAL_STATUS_SUCCESS != hstatus)
1030 {
1031 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1032 __func__);
1033 /* we'll returned a cached value below */
1034 }
1035 else
1036 {
1037 /* request was sent -- wait for the response */
1038 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1039 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301040 if (lrc <= 0)
1041 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001042 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301043 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301044 /* we'll now returned a cached value below */
1045 }
1046 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001047
1048 /* either we never sent a request, we sent a request and received a
1049 response or we sent a request and timed out. if we never sent a
1050 request or if we sent a request and got a response, we want to
1051 clear the magic out of paranoia. if we timed out there is a
1052 race condition such that the callback function could be
1053 executing at the same time we are. of primary concern is if the
1054 callback function had already verified the "magic" but had not
1055 yet set the completion variable when a timeout occurred. we
1056 serialize these activities by invalidating the magic while
1057 holding a shared spinlock which will cause us to block if the
1058 callback is currently executing */
1059 spin_lock(&hdd_context_lock);
1060 context.magic = 0;
1061 spin_unlock(&hdd_context_lock);
1062
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301063 *snr = pAdapter->snr;
1064
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301065 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301066 return VOS_STATUS_SUCCESS;
1067}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301068
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001069#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001070
1071static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1072{
1073 struct statsContext *pStatsContext;
1074 hdd_adapter_t *pAdapter;
1075 if (ioctl_debug)
1076 {
1077 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1078 __func__, (int)rssi, (int)staId, pContext);
1079 }
1080
1081 if (NULL == pContext)
1082 {
1083 hddLog(VOS_TRACE_LEVEL_ERROR,
1084 "%s: Bad param, pContext [%p]",
1085 __func__, pContext);
1086 return;
1087 }
1088
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001089 pStatsContext = pContext;
1090 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001091
1092 /* there is a race condition that exists between this callback
1093 function and the caller since the caller could time out either
1094 before or while this code is executing. we use a spinlock to
1095 serialize these actions */
1096 spin_lock(&hdd_context_lock);
1097
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001098 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1099 {
1100 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001101 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001102 hddLog(VOS_TRACE_LEVEL_WARN,
1103 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1104 __func__, pAdapter, pStatsContext->magic);
1105 if (ioctl_debug)
1106 {
1107 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1108 __func__, pAdapter, pStatsContext->magic);
1109 }
1110 return;
1111 }
1112
Jeff Johnson72a40512013-12-19 10:14:15 -08001113 /* context is valid so caller is still waiting */
1114
1115 /* paranoia: invalidate the magic */
1116 pStatsContext->magic = 0;
1117
1118 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001119 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301120 if (pAdapter->rssi > 0)
1121 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001122 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001123 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001124
1125 /* serialization is complete */
1126 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001127}
1128
1129
1130
1131VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1132{
1133 struct statsContext context;
1134 hdd_context_t *pHddCtx = NULL;
1135 hdd_station_ctx_t *pHddStaCtx = NULL;
1136 eHalStatus hstatus;
1137 long lrc;
1138
1139 if (NULL == pAdapter)
1140 {
1141 hddLog(VOS_TRACE_LEVEL_WARN,
1142 "%s: Invalid context, pAdapter", __func__);
1143 return VOS_STATUS_E_FAULT;
1144 }
1145 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1146 {
1147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1148 /* return a cached value */
1149 *rssi_value = pAdapter->rssi;
1150 return VOS_STATUS_SUCCESS;
1151 }
1152
1153 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1154 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1155
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301156 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001157 {
1158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1159 /* return a cached value */
1160 *rssi_value = 0;
1161 return VOS_STATUS_SUCCESS;
1162 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301163
1164 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1165 {
1166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1167 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1168 *rssi_value = pAdapter->rssi;
1169 return VOS_STATUS_SUCCESS;
1170 }
1171
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001172 init_completion(&context.completion);
1173 context.pAdapter = pAdapter;
1174 context.magic = RSSI_CONTEXT_MAGIC;
1175
1176 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1177 pHddStaCtx->conn_info.staId[ 0 ],
1178 pHddStaCtx->conn_info.bssId,
1179 &context, pHddCtx->pvosContext);
1180 if (eHAL_STATUS_SUCCESS != hstatus)
1181 {
1182 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1183 __func__);
1184 /* we'll returned a cached value below */
1185 }
1186 else
1187 {
1188 /* request was sent -- wait for the response */
1189 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1190 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001191 if (lrc <= 0)
1192 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001193 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001194 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001195 /* we'll now returned a cached value below */
1196 }
1197 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001198
1199 /* either we never sent a request, we sent a request and received a
1200 response or we sent a request and timed out. if we never sent a
1201 request or if we sent a request and got a response, we want to
1202 clear the magic out of paranoia. if we timed out there is a
1203 race condition such that the callback function could be
1204 executing at the same time we are. of primary concern is if the
1205 callback function had already verified the "magic" but had not
1206 yet set the completion variable when a timeout occurred. we
1207 serialize these activities by invalidating the magic while
1208 holding a shared spinlock which will cause us to block if the
1209 callback is currently executing */
1210 spin_lock(&hdd_context_lock);
1211 context.magic = 0;
1212 spin_unlock(&hdd_context_lock);
1213
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001214 *rssi_value = pAdapter->rssi;
1215
1216 return VOS_STATUS_SUCCESS;
1217}
1218#endif
1219
1220
Jeff Johnson295189b2012-06-20 16:38:30 -07001221void hdd_StatisticsCB( void *pStats, void *pContext )
1222{
1223 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1224 hdd_stats_t *pStatsCache = NULL;
1225 hdd_wext_state_t *pWextState;
1226 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1227
1228 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1229 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1230 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1231 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1232 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1233 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1234
1235 if (pAdapter!= NULL)
1236 pStatsCache = &pAdapter->hdd_stats;
1237
1238
1239 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1240 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1241 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1242 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1243 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1244 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1245
1246 if (pStatsCache!=NULL)
1247 {
1248 // and copy the stats into the cache we keep in the adapter instance structure
1249 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1250 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1251 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1252 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1253 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1254 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1255 }
1256
1257 if(pAdapter)
1258 {
1259 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1260 if(pWextState)
1261 {
1262 vos_status = vos_event_set(&pWextState->vosevent);
1263 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1264 {
1265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001266 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 return;
1268 }
1269 }
1270 }
1271}
1272
1273void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1274{
1275 v_CONTEXT_t pVosContext;
1276 hdd_context_t *pHddCtx;
1277 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1278#if 0
1279 hdd_wext_state_t *pWextState;
1280 v_U32_t roamId;
1281#endif
1282
1283 ENTER();
1284
1285 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1286
1287 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1288 if (NULL == pHddCtx)
1289 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001290 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 return;
1292 }
1293#if 0
1294 pWextState = pAdapter->pWextState;
1295#endif
1296
1297 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1298 {
1299 //TODO Verify is this is really used. If yes need to fix it.
1300 hdd_reconnect_all_adapters( pHddCtx );
1301#if 0
1302 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1303 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1304 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1305
1306 if(VOS_STATUS_SUCCESS == vosStatus)
1307 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1308 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1309
1310 sme_RoamConnect(halHandle,
1311 pAdapter->sessionId, &(pWextState->roamProfile),
1312 &roamId);
1313#endif
1314 }
1315
1316 EXIT();
1317
1318}
1319
1320void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1321{
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1323
1324 /* clear WPA/RSN/WSC IE information in the profile */
1325 pWextState->roamProfile.nWPAReqIELength = 0;
1326 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1327 pWextState->roamProfile.nRSNReqIELength = 0;
1328 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1329
Chet Lanctot186b5732013-03-18 10:26:30 -07001330#ifdef FEATURE_WLAN_WAPI
1331 pWextState->roamProfile.nWAPIReqIELength = 0;
1332 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1333#endif
1334
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001336 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301338 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1340 pWextState->roamProfile.nAddIEAssocLength = 0;
1341
1342 pWextState->roamProfile.EncryptionType.numEntries = 1;
1343 pWextState->roamProfile.EncryptionType.encryptionType[0]
1344 = eCSR_ENCRYPT_TYPE_NONE;
1345
1346 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1347 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1348 = eCSR_ENCRYPT_TYPE_NONE;
1349
1350 pWextState->roamProfile.AuthType.numEntries = 1;
1351 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1352
Chet Lanctot186b5732013-03-18 10:26:30 -07001353#ifdef WLAN_FEATURE_11W
1354 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1355 pWextState->roamProfile.MFPRequired = 0;
1356 pWextState->roamProfile.MFPCapable = 0;
1357#endif
1358
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 pWextState->authKeyMgmt = 0;
1360
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301361 vos_mem_zero(&pWextState->roamProfile.Keys,
1362 sizeof(pWextState->roamProfile.Keys));
1363
Jeff Johnson295189b2012-06-20 16:38:30 -07001364#ifdef FEATURE_WLAN_WAPI
1365 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1366 pAdapter->wapi_info.nWapiMode = 0;
1367#endif
1368
1369 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1370
1371}
1372
1373void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1374{
1375 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001376
Nirav Shahf6bd2672015-03-11 12:53:15 +05301377 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001378 {
1379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301380 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001381 }
1382 else
1383 {
1384 complete(&pAdapter->ula_complete);
1385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001386}
1387
1388VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1389{
1390 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001392 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
1394 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1395 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001396 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001397
1398 /*To avoid race condition between the set key and the last EAPOL
1399 packet, notify TL to finish upper layer authentication incase if the
1400 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001401 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001402
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001403 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 {
1405 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1406 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1407 __LINE__, vos_status );
1408 return vos_status;
1409
1410 }
1411
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001412 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301414 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001415 {
1416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301417 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001418 /* we'll still fall through and return success since the
1419 * connection may still get established but is just taking
1420 * too long for us to wait */
1421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 }
1423 return VOS_STATUS_SUCCESS;
1424}
1425
1426v_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)
1427{
1428
1429 int left = ie_len;
1430 v_U8_t *ptr = ie;
1431 v_U8_t elem_id,elem_len;
1432 v_U8_t eid = 0xDD;
1433
1434 if ( NULL == ie || 0 == ie_len )
1435 return NULL;
1436
1437 while(left >= 2)
1438 {
1439 elem_id = ptr[0];
1440 elem_len = ptr[1];
1441 left -= 2;
1442 if(elem_len > left)
1443 {
1444 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001445 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 eid,elem_len,left);
1447 return NULL;
1448 }
1449 if (elem_id == eid)
1450 {
1451 if(memcmp( &ptr[2], oui, oui_size)==0)
1452 return ptr;
1453 }
1454
1455 left -= elem_len;
1456 ptr += (elem_len + 2);
1457 }
1458 return NULL;
1459}
1460
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301461static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 union iwreq_data *wrqu, char *extra)
1463{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301464 hdd_adapter_t *pAdapter;
1465 hdd_context_t *pHddCtx;
1466 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301467
1468 ENTER();
1469
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301470 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1471 if (NULL == pAdapter)
1472 {
1473 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1474 "%s: pAdapter is NULL\n", __func__);
1475 return -EINVAL;
1476 }
1477 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1478 ret = wlan_hdd_validate_context(pHddCtx);
1479 if (0 != ret)
1480 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301481 return ret;
1482 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301483
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301485
1486 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301487 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001488}
1489
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301490static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1491 union iwreq_data *wrqu, char *extra)
1492{
1493 int ret;
1494
1495 vos_ssr_protect(__func__);
1496 ret = __iw_set_commit(dev, info, wrqu, extra);
1497 vos_ssr_unprotect(__func__);
1498
1499 return ret;
1500}
1501
1502static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 struct iw_request_info *info,
1504 char *wrqu, char *extra)
1505{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301506 hdd_adapter_t *pAdapter;
1507 hdd_context_t *pHddCtx;
1508 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301509
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301511 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1512 if (NULL == pAdapter)
1513 {
1514 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1515 "%s: pAdapter is NULL\n", __func__);
1516 return -EINVAL;
1517 }
1518 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1519 ret = wlan_hdd_validate_context(pHddCtx);
1520 if (0 != ret)
1521 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301522 return ret;
1523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001524 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1525 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301526 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001527}
1528
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301529static int iw_get_name(struct net_device *dev,
1530 struct iw_request_info *info,
1531 char *wrqu, char *extra)
1532{
1533 int ret;
1534
1535 vos_ssr_protect(__func__);
1536 ret = __iw_get_name(dev, info, wrqu, extra);
1537 vos_ssr_unprotect(__func__);
1538
1539 return ret;
1540}
1541
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301542static int __iw_set_mode(struct net_device *dev,
1543 struct iw_request_info *info,
1544 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001545{
1546 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301547 hdd_adapter_t *pAdapter;
1548 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 tCsrRoamProfile *pRoamProfile;
1550 eCsrRoamBssType LastBSSType;
1551 eMib_dot11DesiredBssType connectedBssType;
1552 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301554 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001555
1556 ENTER();
1557
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301558 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 if (NULL == pAdapter)
1560 {
1561 hddLog(VOS_TRACE_LEVEL_WARN,
1562 "%s: Invalid context, pAdapter", __func__);
1563 return 0;
1564 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301565 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1566 status = wlan_hdd_validate_context(pHddCtx);
1567 if (0 != status)
1568 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301569 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 }
1571
1572 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1573 if (pWextState == NULL)
1574 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301575 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 return -EINVAL;
1577 }
1578
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 pRoamProfile = &pWextState->roamProfile;
1581 LastBSSType = pRoamProfile->BSSType;
1582
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301583 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001584
1585 switch (wrqu->mode)
1586 {
1587 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301588 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1590 // Set the phymode correctly for IBSS.
1591 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1592 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001593 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 break;
1596 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301597 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 break;
1601 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301602 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1604 break;
1605 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301606 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 return -EOPNOTSUPP;
1608 }
1609
1610 if ( LastBSSType != pRoamProfile->BSSType )
1611 {
1612 //the BSS mode changed
1613 // We need to issue disconnect if connected or in IBSS disconnect state
1614 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1615 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1616 {
1617 VOS_STATUS vosStatus;
1618 // need to issue a disconnect to CSR.
1619 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1620 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1621 pAdapter->sessionId,
1622 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1623 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301624 {
1625 long ret;
1626 ret = wait_for_completion_interruptible_timeout(
1627 &pAdapter->disconnect_comp_var,
1628 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1629 if (ret <= 0)
1630 hddLog(VOS_TRACE_LEVEL_ERROR,
1631 FL("failed wait on disconnect_comp_var %ld"), ret);
1632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 }
1634 }
1635
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 EXIT();
1637 return 0;
1638}
1639
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301640static int iw_set_mode(struct net_device *dev,
1641 struct iw_request_info *info,
1642 union iwreq_data *wrqu, char *extra)
1643{
1644 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001645
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301646 vos_ssr_protect(__func__);
1647 ret = __iw_set_mode(dev, info, wrqu, extra);
1648 vos_ssr_unprotect(__func__);
1649
1650 return ret;
1651}
1652
1653static int __iw_get_mode(struct net_device *dev,
1654 struct iw_request_info *info,
1655 union iwreq_data *wrqu,
1656 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001657{
1658
1659 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301660 hdd_adapter_t *pAdapter;
1661 hdd_context_t *pHddCtx;
1662 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001663
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301664 ENTER();
1665
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301666 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001667 if (NULL == pAdapter)
1668 {
1669 hddLog(VOS_TRACE_LEVEL_WARN,
1670 "%s: Invalid context, pAdapter", __func__);
1671 return 0;
1672 }
1673
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301674 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1675 ret = wlan_hdd_validate_context(pHddCtx);
1676 if (0 != ret)
1677 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301678 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1681 if (pWextState == NULL)
1682 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301683 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 return -EINVAL;
1685 }
1686
1687 switch (pWextState->roamProfile.BSSType)
1688 {
1689 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001690 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301691 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 break;
1693 case eCSR_BSS_TYPE_IBSS:
1694 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001695 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301696 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 break;
1698 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001699 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301700 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 break;
1702 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001703 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 break;
1705 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301706
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301707 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 return 0;
1709}
1710
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301711static int iw_get_mode(struct net_device *dev,
1712 struct iw_request_info *info,
1713 union iwreq_data *wrqu,
1714 char *extra)
1715{
1716 int ret;
1717
1718 vos_ssr_protect(__func__);
1719 ret = __iw_get_mode(dev, info, wrqu, extra);
1720 vos_ssr_unprotect(__func__);
1721
1722 return ret;
1723}
1724
1725static int __iw_set_freq(struct net_device *dev,
1726 struct iw_request_info *info,
1727 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001728{
1729 v_U32_t numChans = 0;
1730 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1731 v_U32_t indx = 0;
1732 v_U32_t status = 0;
1733
1734 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301735 hdd_adapter_t *pAdapter;
1736 hdd_context_t *pHddCtx;
1737 tHalHandle hHal;
1738 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301740
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 ENTER();
1742
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301743 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1744 if (NULL == pAdapter)
1745 {
1746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1747 "%s:Invalid Adapter",__func__);
1748 return -EINVAL;
1749 }
1750
1751 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1752 status = wlan_hdd_validate_context(pHddCtx);
1753 if (0 != status)
1754 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 return status;
1756 }
1757
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301758 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1759 if (NULL == hHal)
1760 {
1761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1762 "%s: Hal Context is NULL",__func__);
1763 return -EINVAL;
1764 }
1765
1766 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1767 if (NULL == pHddStaCtx)
1768 {
1769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1770 "%s:STA context is NULL",__func__);
1771 return -EINVAL;
1772 }
1773
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301775 if (NULL == pWextState)
1776 {
1777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1778 "%s: pWextState is NULL",__func__);
1779 return -EINVAL;
1780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001781
1782 pRoamProfile = &pWextState->roamProfile;
1783
Arif Hussain6d2a3322013-11-17 19:50:10 -08001784 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001785
1786 /* Link is up then return cant set channel*/
1787 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1788 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1789 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001790 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 return -EOPNOTSUPP;
1792 }
1793
1794 /* Settings by Frequency as input */
1795 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1796 (wrqu->freq.m <= (tANI_U32)5.825e8))
1797 {
1798 tANI_U32 freq = wrqu->freq.m / 100000;
1799
1800 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1801 indx++;
1802 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1803 {
1804 return -EINVAL;
1805 }
1806 wrqu->freq.e = 0;
1807 wrqu->freq.m = freq_chan_map[indx].chan;
1808
1809 }
1810
1811 if (wrqu->freq.e == 0)
1812 {
1813 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1814 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1815 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001816 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001817 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1819 return -EINVAL;
1820 }
1821
1822 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1823
1824 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1825 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1827 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 return -EIO;
1829 }
1830
1831 for (indx = 0; indx < numChans; indx++) {
1832 if (wrqu->freq.m == validChan[indx]){
1833 break;
1834 }
1835 }
1836 }
1837 else{
1838
1839 return -EINVAL;
1840 }
1841
1842 if(indx >= numChans)
1843 {
1844 return -EINVAL;
1845 }
1846
1847 /* Set the Operational Channel */
1848 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1849 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1850 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1851
Arif Hussain6d2a3322013-11-17 19:50:10 -08001852 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001853
1854 EXIT();
1855
1856 return status;
1857}
1858
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301859static int iw_set_freq(struct net_device *dev,
1860 struct iw_request_info *info,
1861 union iwreq_data *wrqu, char *extra)
1862{
1863 int ret;
1864
1865 vos_ssr_protect(__func__);
1866 ret = __iw_set_freq(dev, info, wrqu, extra);
1867 vos_ssr_unprotect(__func__);
1868
1869 return ret;
1870}
1871
1872static int __iw_get_freq(struct net_device *dev,
1873 struct iw_request_info *info,
1874 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001875{
Jeff Johnsone7245742012-09-05 17:12:55 -07001876 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301877 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 tHalHandle hHal;
1879 hdd_wext_state_t *pWextState;
1880 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301881 hdd_station_ctx_t *pHddStaCtx;
1882 hdd_context_t *pHddCtx;
1883 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001884
1885 ENTER();
1886
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301887 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1888 if (NULL == pAdapter)
1889 {
1890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1891 "%s: Adapter is NULL", __func__);
1892 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301894 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1895 ret = wlan_hdd_validate_context(pHddCtx);
1896 if (0 != ret)
1897 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301898 return ret;
1899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301901 if (NULL == hHal)
1902 {
1903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1904 "%s: Hal Context is NULL",__func__);
1905 return -EINVAL;
1906 }
1907 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1908 if (NULL == pHddStaCtx)
1909 {
1910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1911 "%s: HddStaCtx is NULL", __func__);
1912 return -EINVAL;
1913 }
1914 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1915 if (NULL == pWextState)
1916 {
1917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1918 "%s: pWextState is NULL",__func__);
1919 return -EINVAL;
1920 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 pRoamProfile = &pWextState->roamProfile;
1922
1923 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1924 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001925 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 {
c_hpothub8245442013-11-20 23:41:09 +05301927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1928 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 return -EIO;
1930 }
1931 else
1932 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001933 status = hdd_wlan_get_freq(channel, &freq);
1934 if( TRUE == status )
1935 {
1936 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1937 * iwlist & iwconfig command shows frequency into proper
1938 * format (2.412 GHz instead of 246.2 MHz)*/
1939 fwrq->m = freq;
1940 fwrq->e = MHZ;
1941 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 }
1943 }
1944 else
1945 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001946 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1947 * iwlist & iwconfig command shows frequency into proper
1948 * format (2.412 GHz instead of 246.2 MHz)*/
1949 fwrq->m = 0;
1950 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301952
1953 EXIT();
1954 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001955}
1956
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301957static int iw_get_freq(struct net_device *dev,
1958 struct iw_request_info *info,
1959 struct iw_freq *fwrq, char *extra)
1960{
1961 int ret;
1962
1963 vos_ssr_protect(__func__);
1964 ret = __iw_get_freq(dev, info, fwrq, extra);
1965 vos_ssr_unprotect(__func__);
1966
1967 return ret;
1968}
1969
1970static int __iw_get_tx_power(struct net_device *dev,
1971 struct iw_request_info *info,
1972 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001973{
1974
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301975 hdd_adapter_t *pAdapter;
1976 hdd_context_t *pHddCtx;
1977 hdd_station_ctx_t *pHddStaCtx;
1978 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001979
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301980 ENTER();
1981
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301982 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1983 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1986 "%s: Adapter is NULL",__func__);
1987 return -EINVAL;
1988 }
1989 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1990 ret = wlan_hdd_validate_context(pHddCtx);
1991 if (0 != ret)
1992 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301993 return ret;
1994 }
1995
1996 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1997 if (NULL == pHddStaCtx)
1998 {
1999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2000 "%s: STA Context is NULL",__func__);
2001 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 }
2003
2004 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2005 {
2006 wrqu->txpower.value = 0;
2007 return 0;
2008 }
2009 wlan_hdd_get_classAstats(pAdapter);
2010 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2011
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302012 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 return 0;
2014}
2015
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302016static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 struct iw_request_info *info,
2018 union iwreq_data *wrqu, char *extra)
2019{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302020 int ret;
2021
2022 vos_ssr_protect(__func__);
2023 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2024 vos_ssr_unprotect(__func__);
2025
2026 return ret;
2027}
2028
2029static int __iw_set_tx_power(struct net_device *dev,
2030 struct iw_request_info *info,
2031 union iwreq_data *wrqu, char *extra)
2032{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302033 hdd_adapter_t *pAdapter;
2034 tHalHandle hHal;
2035 hdd_context_t *pHddCtx;
2036 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002037
2038 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302039 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2040 if (NULL == pAdapter)
2041 {
2042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2043 "%s: Adapter is NULL",__func__);
2044 return -EINVAL;
2045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002046
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302047 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2048 ret = wlan_hdd_validate_context(pHddCtx);
2049 if (0 != ret)
2050 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302051 return ret;
2052 }
2053
2054 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2055 if (NULL == hHal)
2056 {
2057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2058 "%s: Hal Context is NULL",__func__);
2059 return -EINVAL;
2060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2062 {
c_hpothub8245442013-11-20 23:41:09 +05302063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2064 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 return -EIO;
2066 }
2067
2068 EXIT();
2069
2070 return 0;
2071}
2072
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302073static int iw_set_tx_power(struct net_device *dev,
2074 struct iw_request_info *info,
2075 union iwreq_data *wrqu, char *extra)
2076{
2077 int ret;
2078
2079 vos_ssr_protect(__func__);
2080 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2081 vos_ssr_unprotect(__func__);
2082
2083 return ret;
2084}
2085
2086static int __iw_get_bitrate(struct net_device *dev,
2087 struct iw_request_info *info,
2088 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002089{
2090 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2091 eHalStatus status = eHAL_STATUS_SUCCESS;
2092 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302093 hdd_adapter_t *pAdapter;
2094 hdd_context_t *pHddCtx;
2095 hdd_station_ctx_t *pHddStaCtx;
2096 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002097
2098 ENTER();
2099
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302100 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2101 if (NULL == pAdapter)
2102 {
2103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2104 "%s: Adapter is NULL",__func__);
2105 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 }
2107
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302108 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2109 ret = wlan_hdd_validate_context(pHddCtx);
2110 if (0 != ret)
2111 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302112 return ret;
2113 }
2114
2115 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2116 if (NULL == pHddStaCtx)
2117 {
2118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2119 "%s: STA Context is NULL",__func__);
2120 return -EINVAL;
2121 }
2122
2123 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 wrqu->bitrate.value = 0;
2125 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302126 else
2127 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2129 SME_SUMMARY_STATS |
2130 SME_GLOBAL_CLASSA_STATS |
2131 SME_GLOBAL_CLASSB_STATS |
2132 SME_GLOBAL_CLASSC_STATS |
2133 SME_GLOBAL_CLASSD_STATS |
2134 SME_PER_STA_STATS,
2135 hdd_StatisticsCB, 0, FALSE,
2136 pHddStaCtx->conn_info.staId[0], pAdapter );
2137
2138 if(eHAL_STATUS_SUCCESS != status)
2139 {
2140 hddLog(VOS_TRACE_LEVEL_ERROR,
2141 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002142 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002143 return status;
2144 }
2145
2146 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302147 if (NULL == pWextState)
2148 {
2149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2150 "%s: pWextState is NULL",__func__);
2151 return -EINVAL;
2152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002153
2154 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2155
2156 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2157 {
2158 hddLog(VOS_TRACE_LEVEL_ERROR,
2159 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002160 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 return VOS_STATUS_E_FAILURE;
2162 }
2163
2164 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2165 }
2166
2167 EXIT();
2168
2169 return vos_status;
2170}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302171
2172static int iw_get_bitrate(struct net_device *dev,
2173 struct iw_request_info *info,
2174 union iwreq_data *wrqu, char *extra)
2175{
2176 int ret;
2177
2178 vos_ssr_protect(__func__);
2179 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2180 vos_ssr_unprotect(__func__);
2181
2182 return ret;
2183}
2184
2185
Jeff Johnson295189b2012-06-20 16:38:30 -07002186/* ccm call back function */
2187
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302188static int __iw_set_bitrate(struct net_device *dev,
2189 struct iw_request_info *info,
2190 union iwreq_data *wrqu,
2191 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002192{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302193 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302195 hdd_station_ctx_t *pHddStaCtx;
2196 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2198 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2199 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2200 v_U32_t i, rate;
2201 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302202 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002203
2204 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302205 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2206 if (NULL == pAdapter)
2207 {
2208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2209 "%s: Adapter is NULL",__func__);
2210 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 }
2212
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302213 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2214 ret = wlan_hdd_validate_context(pHddCtx);
2215 if (0 != ret)
2216 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302217 return ret;
2218 }
2219
2220 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2221 if (NULL == pHddStaCtx)
2222 {
2223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2224 "%s: STA Context is NULL",__func__);
2225 return -EINVAL;
2226 }
2227
2228
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302230 if (NULL == pWextState)
2231 {
2232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2233 "%s: pWextState is NULL",__func__);
2234 return -EINVAL;
2235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002236
2237 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2238 {
2239 return -ENXIO ;
2240 }
2241
2242 rate = wrqu->bitrate.value;
2243
2244 if (rate == -1)
2245 {
2246 rate = WNI_CFG_FIXED_RATE_AUTO;
2247 valid_rate = TRUE;
2248 }
2249 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2250 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2251 {
2252 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2253 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2254 {
2255 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2256 WNI_CFG_SUPPORTED_RATES_11A,
2257 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2258 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2259 WNI_CFG_SUPPORTED_RATES_11B,
2260 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2261 {
2262 for (i = 0; i < (b_len + a_len); ++i)
2263 {
2264 /* supported rates returned is double the actual rate so we divide it by 2 */
2265 if ((supp_rates[i]&0x7F)/2 == rate)
2266 {
2267 valid_rate = TRUE;
2268 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2269 break;
2270 }
2271 }
2272 }
2273 }
2274 }
2275 if (valid_rate != TRUE)
2276 {
2277 return -EINVAL;
2278 }
2279 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2280 WNI_CFG_FIXED_RATE, rate,
2281 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2282 {
c_hpothub8245442013-11-20 23:41:09 +05302283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2284 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 return -EIO;
2286 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302287
2288 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 return 0;
2290}
2291
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302292static int iw_set_bitrate(struct net_device *dev,
2293 struct iw_request_info *info,
2294 union iwreq_data *wrqu,
2295 char *extra)
2296{
2297 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002298
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302299 vos_ssr_protect(__func__);
2300 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2301 vos_ssr_unprotect(__func__);
2302
2303 return ret;
2304}
2305
2306static int __iw_set_genie(struct net_device *dev,
2307 struct iw_request_info *info,
2308 union iwreq_data *wrqu,
2309 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002310{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302311 hdd_adapter_t *pAdapter;
2312 hdd_context_t *pHddCtx;
2313 hdd_wext_state_t *pWextState;
2314 u_int8_t *genie = NULL;
2315 u_int8_t *base_genie = NULL;
2316 v_U16_t remLen;
2317 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002318
2319 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002320
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302321 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2322 if (NULL == pAdapter)
2323 {
2324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2325 "%s: Adapter is NULL",__func__);
2326 return -EINVAL;
2327 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002328
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302329 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2330 ret = wlan_hdd_validate_context(pHddCtx);
2331 if (0 != ret)
2332 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302333 return ret;
2334 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002335
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302336 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2337 if (NULL == pWextState)
2338 {
2339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2340 "%s: pWextState is NULL",__func__);
2341 return -EINVAL;
2342 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002343
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302344 if (!wrqu->data.length) {
2345 hdd_clearRoamProfileIe(pAdapter);
2346 EXIT();
2347 return 0;
2348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002349
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302350 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2351 wrqu->data.length);
2352 if (NULL == base_genie)
2353 {
2354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2355 "mem_alloc_copy_from_user_helper fail");
2356 return -ENOMEM;
2357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002358
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302359 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002360
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302361 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002362
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302363 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2364
2365 /* clear any previous genIE before this call */
2366 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2367
2368 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 {
2370 v_U16_t eLen = 0;
2371 v_U8_t elementId;
2372 elementId = *genie++;
2373 eLen = *genie++;
2374 remLen -= 2;
2375
Arif Hussain6d2a3322013-11-17 19:50:10 -08002376 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 __func__, elementId, eLen);
2378
2379 switch ( elementId )
2380 {
2381 case IE_EID_VENDOR:
2382 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002383 {
2384 kfree(base_genie);
2385 return -EINVAL;
2386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002387
2388 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2389 {
2390 v_U16_t curGenIELen = pWextState->genIE.length;
2391 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2392 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2393
2394 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2395 {
2396 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002397 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002399 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 return -ENOMEM;
2401 }
2402 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2403 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2404 pWextState->genIE.length += eLen + 2;
2405 }
2406 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2407 {
2408 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2409 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2410 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2411 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2412 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2413 }
2414 else /* any vendorId except WPA IE should be accumulated to genIE */
2415 {
2416 v_U16_t curGenIELen = pWextState->genIE.length;
2417 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2418 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2419
2420 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2421 {
2422 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002423 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002425 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 return -ENOMEM;
2427 }
2428 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2429 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2430 pWextState->genIE.length += eLen + 2;
2431 }
2432 break;
2433 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002434 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2436 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2437 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2438 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2439 break;
2440
2441 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002442 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002443 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 return 0;
2445 }
2446 genie += eLen;
2447 remLen -= eLen;
2448 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302449
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002451 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 return 0;
2453}
2454
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302455static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 struct iw_request_info *info,
2457 union iwreq_data *wrqu,
2458 char *extra)
2459{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302460 int ret;
2461
2462 vos_ssr_protect(__func__);
2463 ret = __iw_set_genie(dev, info, wrqu, extra);
2464 vos_ssr_unprotect(__func__);
2465
2466 return ret;
2467}
2468
2469static int __iw_get_genie(struct net_device *dev,
2470 struct iw_request_info *info,
2471 union iwreq_data *wrqu,
2472 char *extra)
2473{
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302475 hdd_context_t *pHddCtx;
2476 hdd_adapter_t *pAdapter;
2477 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 eHalStatus status;
2479 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2480 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2481
2482 ENTER();
2483
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302484 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2485 if (NULL == pAdapter)
2486 {
2487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2488 "%s: Adapter is NULL",__func__);
2489 return -EINVAL;
2490 }
2491 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2492 status = wlan_hdd_validate_context(pHddCtx);
2493 if (0 != status)
2494 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302495 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 }
2497
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302499 if (NULL == pWextState)
2500 {
2501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2502 "%s: pWextState is NULL",__func__);
2503 return -EINVAL;
2504 }
2505
2506 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2507 if (NULL == pHddStaCtx)
2508 {
2509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2510 "%s: STA Context is NULL",__func__);
2511 return -EINVAL;
2512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002513
2514 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2515 {
2516 return -ENXIO;
2517 }
2518
2519 // Return something ONLY if we are associated with an RSN or WPA network
2520 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2521 pWextState->roamProfile.negotiatedAuthType))
2522 {
2523 return -ENXIO;
2524 }
2525
2526 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2527 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2528 pAdapter->sessionId,
2529 &length,
2530 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002531 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2532 if (wrqu->data.length < length)
2533 {
2534 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2535 return -EFAULT;
2536 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002537 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002538 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002539
Arif Hussain6d2a3322013-11-17 19:50:10 -08002540 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002541
2542 EXIT();
2543
2544 return 0;
2545}
2546
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302547static int iw_get_genie(struct net_device *dev,
2548 struct iw_request_info *info,
2549 union iwreq_data *wrqu,
2550 char *extra)
2551{
2552 int ret;
2553
2554 vos_ssr_protect(__func__);
2555 ret = __iw_get_genie(dev, info, wrqu, extra);
2556 vos_ssr_unprotect(__func__);
2557
2558 return ret;
2559}
2560
2561
2562static int __iw_get_encode(struct net_device *dev,
2563 struct iw_request_info *info,
2564 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002565{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302566 hdd_adapter_t *pAdapter;
2567 hdd_context_t *pHddCtx;
2568 hdd_wext_state_t *pWextState;
2569 tCsrRoamProfile *pRoamProfile;
2570 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002572
2573 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302574 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2575 if (NULL == pAdapter)
2576 {
2577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2578 "%s: Adapter is NULL",__func__);
2579 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 }
2581
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302582 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2583 ret = wlan_hdd_validate_context(pHddCtx);
2584 if (0 != ret)
2585 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302586 return ret;
2587 }
2588 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2589 if (NULL == pWextState)
2590 {
2591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2592 "%s: pWextState is NULL",__func__);
2593 return -EINVAL;
2594 }
2595
2596 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 keyId = pRoamProfile->Keys.defaultIndex;
2598
2599 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2600 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002601 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 return -EINVAL;
2603 }
2604
2605 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2606 {
2607 dwrq->flags |= IW_ENCODE_ENABLED;
2608 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2609 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2610
2611 dwrq->flags |= (keyId + 1);
2612
2613 }
2614 else
2615 {
2616 dwrq->flags |= IW_ENCODE_DISABLED;
2617 }
2618
2619 for(i=0; i < MAX_WEP_KEYS; i++)
2620 {
2621 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2622 {
2623 continue;
2624 }
2625 else
2626 {
2627 break;
2628 }
2629 }
2630
2631 if(MAX_WEP_KEYS == i)
2632 {
2633 dwrq->flags |= IW_ENCODE_NOKEY;
2634 }
2635
2636 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2637
2638 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2639 {
2640 dwrq->flags |= IW_ENCODE_OPEN;
2641 }
2642 else
2643 {
2644 dwrq->flags |= IW_ENCODE_RESTRICTED;
2645 }
2646 EXIT();
2647 return 0;
2648}
2649
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302650static int iw_get_encode(struct net_device *dev,
2651 struct iw_request_info *info,
2652 struct iw_point *dwrq, char *extra)
2653{
2654 int ret;
2655
2656 vos_ssr_protect(__func__);
2657 ret = __iw_get_encode(dev, info, dwrq, extra);
2658 vos_ssr_unprotect(__func__);
2659
2660 return ret;
2661}
2662
Jeff Johnson295189b2012-06-20 16:38:30 -07002663#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2664#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2665
2666
2667/*
2668 * This function sends a single 'key' to LIM at all time.
2669 */
2670
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302671static int __iw_get_rts_threshold(struct net_device *dev,
2672 struct iw_request_info *info,
2673 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002674{
2675 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2676 v_U32_t status = 0;
2677
2678 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2679
2680 return status;
2681}
2682
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302683static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 struct iw_request_info *info,
2685 union iwreq_data *wrqu, char *extra)
2686{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302687 int ret;
2688
2689 vos_ssr_protect(__func__);
2690 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2691 vos_ssr_unprotect(__func__);
2692
2693 return ret;
2694}
2695
2696static int __iw_set_rts_threshold(struct net_device *dev,
2697 struct iw_request_info *info,
2698 union iwreq_data *wrqu, char *extra)
2699{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302700 hdd_adapter_t *pAdapter;
2701 hdd_context_t *pHddCtx;
2702 tHalHandle hHal;
2703 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002704
2705 ENTER();
2706
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302707 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2708 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002709 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2711 "%s: Adapter is NULL",__func__);
2712 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002713 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302714
2715 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2716 ret = wlan_hdd_validate_context(pHddCtx);
2717 if (0 != ret)
2718 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302719 return ret;
2720 }
2721
2722 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2723 if (NULL == hHal)
2724 {
2725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2726 "%s: Hal Context is NULL",__func__);
2727 return -EINVAL;
2728 }
2729
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2731 {
2732 return -EINVAL;
2733 }
2734
2735 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2736 {
c_hpothub8245442013-11-20 23:41:09 +05302737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2738 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 return -EIO;
2740 }
2741
2742 EXIT();
2743
2744 return 0;
2745}
2746
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302747static int iw_set_rts_threshold(struct net_device *dev,
2748 struct iw_request_info *info,
2749 union iwreq_data *wrqu, char *extra)
2750{
2751 int ret;
2752
2753 vos_ssr_protect(__func__);
2754 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2755 vos_ssr_unprotect(__func__);
2756
2757 return ret;
2758}
2759
2760static int __iw_get_frag_threshold(struct net_device *dev,
2761 struct iw_request_info *info,
2762 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002763{
2764 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2765 v_U32_t status = 0;
2766
2767 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2768
2769 return status;
2770}
2771
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302772static int iw_get_frag_threshold(struct net_device *dev,
2773 struct iw_request_info *info,
2774 union iwreq_data *wrqu, char *extra)
2775{
2776 int ret;
2777
2778 vos_ssr_protect(__func__);
2779 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2780 vos_ssr_unprotect(__func__);
2781
2782 return ret;
2783}
2784
2785static int __iw_set_frag_threshold(struct net_device *dev,
2786 struct iw_request_info *info,
2787 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002788{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302789 hdd_adapter_t *pAdapter;
2790 hdd_context_t *pHddCtx;
2791 tHalHandle hHal;
2792 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002793
2794 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302795 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2796 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002797 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2799 "%s: Adapter is NULL",__func__);
2800 return -EINVAL;
2801 }
2802
2803 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2804 ret = wlan_hdd_validate_context(pHddCtx);
2805 if (0 != ret)
2806 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302807 return ret;
2808 }
2809
2810 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2811 if (NULL == hHal)
2812 {
2813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2814 "%s: Hal Context is NULL",__func__);
2815 return -EINVAL;
2816 }
2817
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2819 {
2820 return -EINVAL;
2821 }
2822
2823 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2824 {
c_hpothub8245442013-11-20 23:41:09 +05302825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2826 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 return -EIO;
2828 }
2829
2830 EXIT();
2831
2832 return 0;
2833}
2834
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302835static int iw_set_frag_threshold(struct net_device *dev,
2836 struct iw_request_info *info,
2837 union iwreq_data *wrqu, char *extra)
2838{
2839 int ret;
2840
2841 vos_ssr_protect(__func__);
2842 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2843 vos_ssr_unprotect(__func__);
2844
2845 return ret;
2846}
2847
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302848static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 struct iw_request_info *info,
2850 union iwreq_data *wrqu, char *extra)
2851{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302852 hdd_adapter_t *pAdapter;
2853 hdd_context_t *pHddCtx;
2854 int ret = 0;
2855
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302857 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2858 if (NULL == pAdapter)
2859 {
2860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2861 "%s: Adapter is NULL",__func__);
2862 return -EINVAL;
2863 }
2864 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2865 ret = wlan_hdd_validate_context(pHddCtx);
2866 if (0 != ret)
2867 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302868 return ret;
2869 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302870
2871 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 return -EOPNOTSUPP;
2873}
2874
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302875static int iw_get_power_mode(struct net_device *dev,
2876 struct iw_request_info *info,
2877 union iwreq_data *wrqu, char *extra)
2878{
2879 int ret;
2880
2881 vos_ssr_protect(__func__);
2882 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2883 vos_ssr_unprotect(__func__);
2884
2885 return ret;
2886}
2887static int __iw_set_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_set_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_set_power_mode(dev, info, wrqu, extra);
2922 vos_ssr_unprotect(__func__);
2923
2924 return ret;
2925}
2926
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302927static int __iw_get_range(struct net_device *dev,
2928 struct iw_request_info *info,
2929 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002930{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302931 hdd_adapter_t *pAdapter;
2932 tHalHandle hHal;
2933 hdd_context_t *pHddCtx;
2934 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 struct iw_range *range = (struct iw_range *) extra;
2936
2937 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2938
2939 v_U32_t num_channels = sizeof(channels);
2940 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2941 v_U32_t a_len;
2942 v_U32_t b_len;
2943 v_U32_t active_phy_mode = 0;
2944 v_U8_t index = 0, i;
2945
2946 ENTER();
2947
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302948 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2949 if (NULL == pAdapter)
2950 {
2951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2952 "%s: pAdapter is NULL", __func__);
2953 return -EINVAL;
2954 }
2955 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2956 ret = wlan_hdd_validate_context(pHddCtx);
2957 if (0 != ret)
2958 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302959 return ret;
2960 }
2961 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2962 if (NULL == hHal)
2963 {
2964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2965 "%s: pAdapter is NULL", __func__);
2966 return -EINVAL;
2967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 wrqu->data.length = sizeof(struct iw_range);
2969 memset(range, 0, sizeof(struct iw_range));
2970
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 /*Get the phy mode*/
2972 if (ccmCfgGetInt(hHal,
2973 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2974 {
2975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002976 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002977
2978 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2979 {
2980 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002981 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 if (ccmCfgGetStr(hHal,
2983 WNI_CFG_SUPPORTED_RATES_11A,
2984 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2985 {
2986 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2987 {
2988 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2989 }
2990 for (i = 0; i < a_len; i++)
2991 {
2992 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2993 }
2994 range->num_bitrates = a_len;
2995 }
2996 else
2997 {
2998 return -EIO;
2999 }
3000 }
3001 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3002 {
3003 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003004 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003005 if (ccmCfgGetStr(hHal,
3006 WNI_CFG_SUPPORTED_RATES_11B,
3007 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3008 {
3009 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3010 {
3011 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3012 }
3013 for (i = 0; i < b_len; i++)
3014 {
3015 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3016 }
3017 range->num_bitrates = b_len;
3018 }
3019 else
3020 {
3021 return -EIO;
3022 }
3023 }
3024 }
3025
3026 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3027 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3028 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3029
3030 range->encoding_size[0] = 5;
3031 range->encoding_size[1] = 13;
3032 range->num_encoding_sizes = 2;
3033 range->max_encoding_tokens = MAX_WEP_KEYS;
3034
3035 // we support through Wireless Extensions 22
3036 range->we_version_compiled = WIRELESS_EXT;
3037 range->we_version_source = 22;
3038
3039 /*Supported Channels and Frequencies*/
3040 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3041 {
c_hpothub8245442013-11-20 23:41:09 +05303042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3043 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 return -EIO;
3045 }
3046 if (num_channels > IW_MAX_FREQUENCIES)
3047 {
3048 num_channels = IW_MAX_FREQUENCIES;
3049 }
3050
3051 range->num_channels = num_channels;
3052 range->num_frequency = num_channels;
3053
3054 for (index=0; index < num_channels; index++)
3055 {
3056 v_U32_t frq_indx = 0;
3057
3058 range->freq[index].i = channels[index];
3059 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3060 {
3061 if(channels[index] == freq_chan_map[frq_indx].chan)
3062 {
3063 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3064 range->freq[index].e = 1;
3065 break;
3066 }
3067 frq_indx++;
3068 }
3069 }
3070
3071 /* Event capability (kernel + driver) */
3072 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3073 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3074 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3075 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3076
3077 /*Encryption capability*/
3078 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3079 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3080
3081 /* Txpower capability */
3082 range->txpower_capa = IW_TXPOW_MWATT;
3083
3084 /*Scanning capability*/
3085 #if WIRELESS_EXT >= 22
3086 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3087 #endif
3088
3089 EXIT();
3090 return 0;
3091}
3092
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303093static int iw_get_range(struct net_device *dev,
3094 struct iw_request_info *info,
3095 union iwreq_data *wrqu, char *extra)
3096{
3097 int ret;
3098
3099 vos_ssr_protect(__func__);
3100 ret = __iw_get_range(dev, info, wrqu, extra);
3101 vos_ssr_unprotect(__func__);
3102
3103 return ret;
3104}
3105
Jeff Johnson295189b2012-06-20 16:38:30 -07003106/* Callback function registered with PMC to know status of PMC request */
3107static void iw_power_callback_fn (void *pContext, eHalStatus status)
3108{
3109 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003110
3111 if (NULL == pContext)
3112 {
3113 hddLog(VOS_TRACE_LEVEL_ERROR,
3114 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003115 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 return;
3117 }
3118
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003120
Jeff Johnson72a40512013-12-19 10:14:15 -08003121 /* there is a race condition that exists between this callback
3122 function and the caller since the caller could time out either
3123 before or while this code is executing. we use a spinlock to
3124 serialize these actions */
3125 spin_lock(&hdd_context_lock);
3126
3127 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 {
3129 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003130 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003132 "%s: Invalid context, magic [%08x]",
3133 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003134
3135 if (ioctl_debug)
3136 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003137 pr_info("%s: Invalid context, magic [%08x]\n",
3138 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 }
3140 return;
3141 }
3142
Jeff Johnson72a40512013-12-19 10:14:15 -08003143 /* context is valid so caller is still waiting */
3144
3145 /* paranoia: invalidate the magic */
3146 pStatsContext->magic = 0;
3147
3148 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003150
3151 /* serialization is complete */
3152 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003153}
3154
3155/* Callback function for tx per hit */
3156void hdd_tx_per_hit_cb (void *pCallbackContext)
3157{
3158 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3159 unsigned char tx_fail[16];
3160 union iwreq_data wrqu;
3161
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303162 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003164 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 return;
3166 }
3167 memset(&wrqu, 0, sizeof(wrqu));
3168 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3169 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3170}
3171
3172void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3173{
3174 struct statsContext *pStatsContext;
3175 tCsrGlobalClassAStatsInfo *pClassAStats;
3176 hdd_adapter_t *pAdapter;
3177
3178 if (ioctl_debug)
3179 {
3180 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003181 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 }
3183
3184 if ((NULL == pStats) || (NULL == pContext))
3185 {
3186 hddLog(VOS_TRACE_LEVEL_ERROR,
3187 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003188 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 return;
3190 }
3191
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 pClassAStats = pStats;
3193 pStatsContext = pContext;
3194 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003195
3196 /* there is a race condition that exists between this callback
3197 function and the caller since the caller could time out either
3198 before or while this code is executing. we use a spinlock to
3199 serialize these actions */
3200 spin_lock(&hdd_context_lock);
3201
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3203 {
3204 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003205 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 hddLog(VOS_TRACE_LEVEL_WARN,
3207 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003208 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 if (ioctl_debug)
3210 {
3211 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003212 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 }
3214 return;
3215 }
3216
Jeff Johnson72a40512013-12-19 10:14:15 -08003217 /* context is valid so caller is still waiting */
3218
3219 /* paranoia: invalidate the magic */
3220 pStatsContext->magic = 0;
3221
3222 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3224
Jeff Johnson72a40512013-12-19 10:14:15 -08003225 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003227
3228 /* serialization is complete */
3229 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003230}
3231
3232VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3233{
3234 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3235 eHalStatus hstatus;
3236 long lrc;
3237 struct statsContext context;
3238
3239 if (NULL == pAdapter)
3240 {
3241 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3242 return VOS_STATUS_E_FAULT;
3243 }
3244 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3245 {
3246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3247 return VOS_STATUS_SUCCESS;
3248 }
3249
3250 /* we are connected
3251 prepare our callback context */
3252 init_completion(&context.completion);
3253 context.pAdapter = pAdapter;
3254 context.magic = STATS_CONTEXT_MAGIC;
3255 /* query only for Class A statistics (which include link speed) */
3256 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3257 eCSR_HDD,
3258 SME_GLOBAL_CLASSA_STATS,
3259 hdd_GetClassA_statisticsCB,
3260 0, // not periodic
3261 FALSE, //non-cached results
3262 pHddStaCtx->conn_info.staId[0],
3263 &context);
3264 if (eHAL_STATUS_SUCCESS != hstatus)
3265 {
3266 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003267 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003268 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 /* we'll returned a cached value below */
3270 }
3271 else
3272 {
3273 /* request was sent -- wait for the response */
3274 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3275 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 if (lrc <= 0)
3277 {
3278 hddLog(VOS_TRACE_LEVEL_ERROR,
3279 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003280 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 }
3282 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003283
3284 /* either we never sent a request, we sent a request and received a
3285 response or we sent a request and timed out. if we never sent a
3286 request or if we sent a request and got a response, we want to
3287 clear the magic out of paranoia. if we timed out there is a
3288 race condition such that the callback function could be
3289 executing at the same time we are. of primary concern is if the
3290 callback function had already verified the "magic" but had not
3291 yet set the completion variable when a timeout occurred. we
3292 serialize these activities by invalidating the magic while
3293 holding a shared spinlock which will cause us to block if the
3294 callback is currently executing */
3295 spin_lock(&hdd_context_lock);
3296 context.magic = 0;
3297 spin_unlock(&hdd_context_lock);
3298
3299 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 return VOS_STATUS_SUCCESS;
3301}
3302
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003303static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3304{
3305 struct statsContext *pStatsContext;
3306 tCsrSummaryStatsInfo *pSummaryStats;
3307 tCsrGlobalClassAStatsInfo *pClassAStats;
3308 hdd_adapter_t *pAdapter;
3309
3310 if (ioctl_debug)
3311 {
3312 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003313 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003314 }
3315
3316 if ((NULL == pStats) || (NULL == pContext))
3317 {
3318 hddLog(VOS_TRACE_LEVEL_ERROR,
3319 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003320 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003321 return;
3322 }
3323
Jeff Johnson72a40512013-12-19 10:14:15 -08003324 /* there is a race condition that exists between this callback
3325 function and the caller since the caller could time out either
3326 before or while this code is executing. we use a spinlock to
3327 serialize these actions */
3328 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003329
3330 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3331 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3332 pStatsContext = pContext;
3333 pAdapter = pStatsContext->pAdapter;
3334 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3335 {
3336 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003337 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003338 hddLog(VOS_TRACE_LEVEL_WARN,
3339 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003340 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003341 if (ioctl_debug)
3342 {
3343 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003344 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003345 }
3346 return;
3347 }
3348
Jeff Johnson72a40512013-12-19 10:14:15 -08003349 /* context is valid so caller is still waiting */
3350
3351 /* paranoia: invalidate the magic */
3352 pStatsContext->magic = 0;
3353
3354 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003355 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3356 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3357
Jeff Johnson72a40512013-12-19 10:14:15 -08003358 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003359 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003360
3361 /* serialization is complete */
3362 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003363}
3364
3365VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3366{
3367 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3368 eHalStatus hstatus;
3369 long lrc;
3370 struct statsContext context;
3371
3372 if (NULL == pAdapter)
3373 {
3374 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3375 return VOS_STATUS_SUCCESS;
3376 }
3377
3378 /* we are connected
3379 prepare our callback context */
3380 init_completion(&context.completion);
3381 context.pAdapter = pAdapter;
3382 context.magic = STATS_CONTEXT_MAGIC;
3383
3384 /* query only for Summary & Class A statistics */
3385 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3386 eCSR_HDD,
3387 SME_SUMMARY_STATS |
3388 SME_GLOBAL_CLASSA_STATS,
3389 hdd_get_station_statisticsCB,
3390 0, // not periodic
3391 FALSE, //non-cached results
3392 pHddStaCtx->conn_info.staId[0],
3393 &context);
3394 if (eHAL_STATUS_SUCCESS != hstatus)
3395 {
3396 hddLog(VOS_TRACE_LEVEL_ERROR,
3397 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003398 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003399 /* we'll return with cached values */
3400 }
3401 else
3402 {
3403 /* request was sent -- wait for the response */
3404 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3405 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003406
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003407 if (lrc <= 0)
3408 {
3409 hddLog(VOS_TRACE_LEVEL_ERROR,
3410 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003411 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003412 }
3413 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003414
3415 /* either we never sent a request, we sent a request and received a
3416 response or we sent a request and timed out. if we never sent a
3417 request or if we sent a request and got a response, we want to
3418 clear the magic out of paranoia. if we timed out there is a
3419 race condition such that the callback function could be
3420 executing at the same time we are. of primary concern is if the
3421 callback function had already verified the "magic" but had not
3422 yet set the completion variable when a timeout occurred. we
3423 serialize these activities by invalidating the magic while
3424 holding a shared spinlock which will cause us to block if the
3425 callback is currently executing */
3426 spin_lock(&hdd_context_lock);
3427 context.magic = 0;
3428 spin_unlock(&hdd_context_lock);
3429
3430 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003431 return VOS_STATUS_SUCCESS;
3432}
3433
3434
Jeff Johnson295189b2012-06-20 16:38:30 -07003435/*
3436 * Support for the LINKSPEED private command
3437 * Per the WiFi framework the response must be of the form
3438 * "LinkSpeed xx"
3439 */
3440static int iw_get_linkspeed(struct net_device *dev,
3441 struct iw_request_info *info,
3442 union iwreq_data *wrqu, char *extra)
3443{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303444 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303445 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303447 int len = sizeof(v_U32_t) + 1;
3448 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303449 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303450 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303451 int rc, valid = 0;
3452
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303453 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303454 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3455 if (NULL == pAdapter)
3456 {
3457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3458 "%s: Adapter is NULL",__func__);
3459 return -EINVAL;
3460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003461
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303462 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303463 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303464 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003465 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303466 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003467 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303468 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3469 if (NULL == pHddStaCtx)
3470 {
3471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3472 "%s: STA Context is NULL",__func__);
3473 return -EINVAL;
3474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3476 {
3477 /* we are not connected so we don't have a classAstats */
3478 link_speed = 0;
3479 }
3480 else
3481 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303482 status = wlan_hdd_get_classAstats(pAdapter);
3483
3484 if (!VOS_IS_STATUS_SUCCESS(status ))
3485 {
3486 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3487 return -EINVAL;
3488 }
3489
3490 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3491 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3492 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3493 &link_speed);
3494
3495 link_speed = link_speed / 10;
3496
3497 if (0 == link_speed)
3498 {
3499 /* The linkspeed returned by HAL is in units of 500kbps.
3500 * converting it to mbps.
3501 * This is required to support legacy firmware which does
3502 * not return link capacity.
3503 */
3504 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3505 }
3506
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 }
3508
3509 wrqu->data.length = len;
3510 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003511 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 if ((rc < 0) || (rc >= len))
3513 {
3514 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303515 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 return -EIO;
3517 }
3518
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303519 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003521 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003522}
3523
Arif Hussain695279c2014-03-24 14:06:07 -07003524/*
3525 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3526 *
3527 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303528static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003529 struct iw_request_info *info,
3530 union iwreq_data *wrqu, char *extra)
3531{
3532 int rc;
3533
3534 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3535
3536 if (rc < 0)
3537 return rc;
3538
3539 /* a value is being successfully returned */
3540 return 0;
3541}
Jeff Johnson295189b2012-06-20 16:38:30 -07003542
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303543static int iw_get_linkspeed_priv(struct net_device *dev,
3544 struct iw_request_info *info,
3545 union iwreq_data *wrqu, char *extra)
3546{
3547 int ret;
3548
3549 vos_ssr_protect(__func__);
3550 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3551 vos_ssr_unprotect(__func__);
3552
3553 return ret;
3554}
3555
Jeff Johnson295189b2012-06-20 16:38:30 -07003556/*
3557 * Support for the RSSI & RSSI-APPROX private commands
3558 * Per the WiFi framework the response must be of the form
3559 * "<ssid> rssi <xx>"
3560 * unless we are not associated, in which case the response is
3561 * "OK"
3562 */
3563static int iw_get_rssi(struct net_device *dev,
3564 struct iw_request_info *info,
3565 union iwreq_data *wrqu, char *extra)
3566{
3567 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003568 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 int len = wrqu->data.length;
3570 v_S7_t s7Rssi = 0;
3571 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3572 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3573 VOS_STATUS vosStatus;
3574 int rc;
3575
3576 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3577 (0 == ssidlen) || (ssidlen >= len))
3578 {
3579 /* we are not connected or our SSID is too long
3580 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003581 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 }
3583 else
3584 {
3585 /* we are connected with a valid SSID
3586 so we can write the SSID into the return buffer
3587 (note that it is not NUL-terminated) */
3588 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3589
3590 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3591
3592 if (VOS_STATUS_SUCCESS == vosStatus)
3593 {
3594 /* append the rssi to the ssid in the format required by
3595 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003596 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303597 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 }
3599 else
3600 {
3601 rc = -1;
3602 }
3603 }
3604
3605 /* verify that we wrote a valid response */
3606 if ((rc < 0) || (rc >= len))
3607 {
3608 // encoding or length error?
3609 hddLog(VOS_TRACE_LEVEL_ERROR,
3610 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003611 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 return -EIO;
3613 }
3614
3615 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003616 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003617}
3618
3619/*
3620 * Support for SoftAP channel range private command
3621 */
3622static int iw_softap_set_channel_range( struct net_device *dev,
3623 int startChannel,
3624 int endChannel,
3625 int band)
3626{
Jeff Johnson43971f52012-07-17 12:26:56 -07003627 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 int ret = 0;
3629 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3630 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003631 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3632
Jeff Johnson295189b2012-06-20 16:38:30 -07003633
3634 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3635 if (VOS_STATUS_SUCCESS != status)
3636 {
3637 ret = -EINVAL;
3638 }
Yathish9f22e662012-12-10 14:21:35 -08003639 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 return ret;
3641}
3642
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303643static uint8 chartohex(char c)
3644{
3645 uint8 val = 0;
3646 if (c >= '0' && c <= '9')
3647 val = c - '0';
3648 else if (c >= 'a' && c <= 'f')
3649 val = c - 'a' + 10;
3650 else if (c >= 'A' && c <= 'F')
3651 val = c - 'A' + 10;
3652 else
3653 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3654
3655 return val;
3656}
3657
3658uint8 getByte(char **buf)
3659{
3660 uint8 byte = 0;
3661 char *temp = *buf;
3662 byte = chartohex(*temp) * 16;
3663 temp++;
3664 byte += chartohex(*temp);
3665 temp++;
3666 *buf = temp;
3667 return byte;
3668}
3669
3670static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3671{
3672 tSir80211Header *macHeader;
3673 int i = 0, j = 0, length = 0;
3674 uint8 byte = 0;
3675 char *temp = pBuffer;
3676 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303677 char *pHeader;
3678 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303679
3680 macHeader = &pkt->macHeader;
3681
3682 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3683
3684 temp++;
3685
3686 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3687 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3688 pkt->encParams.keyParams.key[0].keyId);
3689
3690 for (i = 0; i< 16; i++) {
3691 pkt->encParams.keyParams.key[0].key[i]
3692 = getByte(&temp);
3693 }
3694
3695 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3696 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3697
3698 for (i = 0; i< 6; i++) {
3699 pkt->encParams.pn[i]
3700 = getByte(&temp);
3701 }
3702
3703 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3704 &pkt->encParams.pn[0], 6, 0);
3705
3706 for (i = 0, j= 5; i< 3; i++, j--) {
3707 byte = pkt->encParams.pn[i];
3708 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3709 pkt->encParams.pn[j] = byte;
3710 }
3711
3712 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303713 if (length > sizeof(tSir80211Header))
3714 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303715
Srinivas Dasari2382de62015-01-22 15:00:04 +05303716 pHeader = temp;
3717 vos_mem_zero(&header, sizeof(tSir80211Header));
3718 for (i = 0; i < length; i++) {
3719 *((uint8 *)&header + i) = getByte(&pHeader);
3720 }
3721
3722 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3723 (char *)&header, length, 0);
3724
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303725 byte = getByte(&temp);
3726
3727 macHeader->frameCtrl.protVer = byte & 0x3;
3728 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3729 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3730
3731 byte = getByte(&temp);
3732 macHeader->frameCtrl.toDS = (byte) & 0x1;
3733 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3734 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3735 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3736 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3737 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3738 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3739 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3740
3741 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3742 "macHeader->frameCtrl.type : %x "
3743 "macHeader->frameCtrl.subType : %x "
3744 "macHeader->frameCtrl.toDS : %x "
3745 "macHeader->frameCtrl.fromDS : %x "
3746 "macHeader->frameCtrl.moreFrag : %x "
3747 "macHeader->frameCtrl.retry : %x "
3748 "macHeader->frameCtrl.powerMgmt : %x "
3749 "macHeader->frameCtrl.MoreData : %x "
3750 "macHeader->frameCtrl.wep : %x "
3751 "macHeader->frameCtrl.order : %x "
3752 , macHeader->frameCtrl.protVer
3753 , macHeader->frameCtrl.type
3754 , macHeader->frameCtrl.subType
3755 , macHeader->frameCtrl.toDS
3756 , macHeader->frameCtrl.fromDS
3757 , macHeader->frameCtrl.moreFrag
3758 , macHeader->frameCtrl.retry
3759 , macHeader->frameCtrl.powerMgmt
3760 , macHeader->frameCtrl.moreData
3761 , macHeader->frameCtrl.wep
3762 , macHeader->frameCtrl.order);
3763
3764
3765 macHeader->usDurationId = getByte(&temp);
3766 macHeader->usDurationId += getByte(&temp) << 8;
3767
3768 macHeader->vA1[0] = getByte(&temp);
3769 macHeader->vA1[1] = getByte(&temp);
3770 macHeader->vA1[2] = getByte(&temp);
3771 macHeader->vA1[3] = getByte(&temp);
3772 macHeader->vA1[4] = getByte(&temp);
3773 macHeader->vA1[5] = getByte(&temp);
3774
3775 macHeader->vA2[0] = getByte(&temp);
3776 macHeader->vA2[1] = getByte(&temp);
3777 macHeader->vA2[2] = getByte(&temp);
3778 macHeader->vA2[3] = getByte(&temp);
3779 macHeader->vA2[4] = getByte(&temp);
3780 macHeader->vA2[5] = getByte(&temp);
3781
3782 macHeader->vA3[0] = getByte(&temp);
3783 macHeader->vA3[1] = getByte(&temp);
3784 macHeader->vA3[2] = getByte(&temp);
3785 macHeader->vA3[3] = getByte(&temp);
3786 macHeader->vA3[4] = getByte(&temp);
3787 macHeader->vA3[5] = getByte(&temp);
3788
3789 macHeader->sSeqCtrl = getByte(&temp);
3790 fragNum = macHeader->sSeqCtrl & 0xF;
3791 macHeader->sSeqCtrl >>= 4;
3792
3793 macHeader->sSeqCtrl += getByte(&temp) << 4;
3794
3795 macHeader->sSeqCtrl |= fragNum << 12;
3796
3797 if (length == 30 || length == 32) {
3798 macHeader->optvA4[0] = getByte(&temp);
3799 macHeader->optvA4[1] = getByte(&temp);
3800 macHeader->optvA4[2] = getByte(&temp);
3801 macHeader->optvA4[3] = getByte(&temp);
3802 macHeader->optvA4[4] = getByte(&temp);
3803 macHeader->optvA4[5] = getByte(&temp);
3804 }
3805
3806 if (length == 26 || length == 32) {
3807 macHeader->usQosCtrl = getByte(&temp);
3808 macHeader->usQosCtrl += getByte(&temp) << 8;
3809 }
3810
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303811 //parse payload
3812 length = getByte(&temp);
3813 length += getByte(&temp) << 8;
3814 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3815
3816 pkt->data.length = length;
3817
3818 for (i = 0; i< length; i++) {
3819 pkt->data.data[i] = getByte(&temp);
3820 }
3821
3822 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3823 &pkt->data.data[0], pkt->data.length, 0);
3824}
3825
3826/**---------------------------------------------------------------------------
3827
3828 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3829 encrypt message request
3830 This is an asynchronous callback function from SME when the encrypted data
3831 is received
3832
3833 \pEncInfoRsp -> Encrypted data info
3834
3835 \return - 0 for success non-zero for failure
3836 --------------------------------------------------------------------------*/
3837static void
3838hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3839{
3840 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3841
3842 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3843
3844 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3845 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3846 pEncryptedDataRsp->encryptedPayload.length);
3847 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3848 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3849 pEncryptedDataRsp->encryptedPayload.data,
3850 pEncryptedDataRsp->encryptedPayload.length, 0);
3851}
3852
Jeff Johnson295189b2012-06-20 16:38:30 -07003853VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3854{
3855 struct statsContext context;
3856 eHalStatus status;
3857 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303858 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003859
3860 if (NULL == pAdapter)
3861 {
3862 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3863 return VOS_STATUS_E_FAULT;
3864 }
3865
3866 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3867 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303868 if (pHddCtx->isLogpInProgress) {
3869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3870 "%s:LOGP in Progress. Ignore!!!", __func__);
3871 return VOS_STATUS_E_FAILURE;
3872 }
3873
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 init_completion(&context.completion);
3875
3876 context.pAdapter = pAdapter;
3877 context.magic = POWER_CONTEXT_MAGIC;
3878
3879 if (DRIVER_POWER_MODE_ACTIVE == mode)
3880 {
3881 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3882 "Full Power", __func__);
3883 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3884 iw_power_callback_fn, &context,
3885 eSME_FULL_PWR_NEEDED_BY_HDD);
3886 // Enter Full power command received from GUI this means we are disconnected
3887 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3888 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3889 if (eHAL_STATUS_PMC_PENDING == status)
3890 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003891 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 int lrc = wait_for_completion_interruptible_timeout(
3893 &context.completion,
3894 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003895
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 if (lrc <= 0)
3897 {
3898 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003899 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 }
3901 }
3902 }
3903 else if (DRIVER_POWER_MODE_AUTO == mode)
3904 {
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303905 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
3906 {
3907 hddLog(VOS_TRACE_LEVEL_ERROR,
3908 "%s:station is in still not Authenticated ignore the "
3909 "power save mode", __func__);
3910 return VOS_STATUS_E_AGAIN;
3911 }
3912
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3914 {
3915 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3916 __func__);
3917 // Enter BMPS command received from GUI this means DHCP is completed
3918 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3919 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3920 FALSE);
3921 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3922 iw_power_callback_fn, &context);
3923 if (eHAL_STATUS_PMC_PENDING == status)
3924 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003925 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 int lrc = wait_for_completion_interruptible_timeout(
3927 &context.completion,
3928 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 if (lrc <= 0)
3930 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003931 hddLog(VOS_TRACE_LEVEL_ERROR,
3932 "%s: SME %s while requesting BMPS",
3933 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 }
3935 }
3936 }
3937 else
3938 {
3939 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3940 "enabled in the cfg");
3941 }
3942 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003943
3944 /* either we never sent a request, we sent a request and received a
3945 response or we sent a request and timed out. if we never sent a
3946 request or if we sent a request and got a response, we want to
3947 clear the magic out of paranoia. if we timed out there is a
3948 race condition such that the callback function could be
3949 executing at the same time we are. of primary concern is if the
3950 callback function had already verified the "magic" but had not
3951 yet set the completion variable when a timeout occurred. we
3952 serialize these activities by invalidating the magic while
3953 holding a shared spinlock which will cause us to block if the
3954 callback is currently executing */
3955 spin_lock(&hdd_context_lock);
3956 context.magic = 0;
3957 spin_unlock(&hdd_context_lock);
3958
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 return VOS_STATUS_SUCCESS;
3960}
3961
3962VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3963 hdd_adapter_t *pAdapter)
3964{
3965 VOS_STATUS vos_Status;
3966
3967 if ((NULL == pAdapter) || (NULL == pHddCtx))
3968 {
3969 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3970 return VOS_STATUS_E_FAULT;
3971 }
3972
3973 /**Exit from Deep sleep or standby if we get the driver
3974 START cmd from android GUI
3975 */
3976 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3977 {
3978 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3979 "from Stand by",__func__);
3980 vos_Status = hdd_exit_standby(pHddCtx);
3981 }
3982 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3983 {
3984 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3985 "from deep sleep",__func__);
3986 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3987 }
3988 else
3989 {
3990 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3991 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3992 vos_Status = VOS_STATUS_SUCCESS;
3993 }
3994
3995 return vos_Status;
3996}
3997
3998VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3999{
4000 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4001
4002 if (NULL == pHddCtx)
4003 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304004 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 return VOS_STATUS_E_FAULT;
4006 }
4007
4008 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4009 {
4010 //Execute standby procedure.
4011 //Executing standby procedure will cause the STA to
4012 //disassociate first and then the chip will be put into standby.
4013 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4014 vos_Status = hdd_enter_standby(pHddCtx);
4015 }
4016 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4017 pHddCtx->cfg_ini->nEnableDriverStop)
4018 {
4019 //Execute deep sleep procedure
4020 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004021 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 //Deep sleep not supported
4023 vos_Status = hdd_enter_standby(pHddCtx);
4024 }
4025 else
4026 {
4027 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4028 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4029 vos_Status = VOS_STATUS_SUCCESS;
4030 }
4031
4032 return vos_Status;
4033}
4034
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004035
4036void* wlan_hdd_change_country_code_callback(void *pAdapter)
4037{
4038
4039 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004040 complete(&call_back_pAdapter->change_country_code);
4041
4042 return NULL;
4043}
4044
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304045static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 struct iw_request_info *info,
4047 union iwreq_data *wrqu, char *extra)
4048{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304049 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004050 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304052 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004053 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4054
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304055 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004056
4057 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304058
4059 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4060 if (NULL == pAdapter)
4061 {
4062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4063 "mem_alloc_copy_from_user_helper fail");
4064 return -EINVAL;
4065 }
4066 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4067 rc = wlan_hdd_validate_context(pHddCtx);
4068 if (0 != rc)
4069 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304070 return rc;
4071 }
4072
Arif Hussain24bfa702014-01-22 13:51:30 -08004073 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4074 wrqu->data.length);
4075 if (NULL == cmd)
4076 {
4077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4078 "mem_alloc_copy_from_user_helper fail");
4079 return -ENOMEM;
4080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004081
4082 if (ioctl_debug)
4083 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004084 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 }
4086
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004087 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4088 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004089
Arif Hussain24bfa702014-01-22 13:51:30 -08004090 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004092 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4094 "%s: Error in iw_set_scan!", __func__);
4095 rc = -EINVAL;
4096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 }
4098 else if( strcasecmp(cmd, "start") == 0 ) {
4099
Arif Hussain6d2a3322013-11-17 19:50:10 -08004100 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004102
Arif Hussain24bfa702014-01-22 13:51:30 -08004103 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4104 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 {
4106 union iwreq_data wrqu;
4107 char buf[10];
4108
4109 memset(&wrqu, 0, sizeof(wrqu));
4110 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4111 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4112 }
4113 else
4114 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004115 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4116 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 }
4118 goto done;
4119 }
4120 else if( strcasecmp(cmd, "stop") == 0 )
4121 {
4122 union iwreq_data wrqu;
4123 char buf[10];
4124
Arif Hussain6d2a3322013-11-17 19:50:10 -08004125 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004126
4127 wlan_hdd_enter_lowpower(pHddCtx);
4128 memset(&wrqu, 0, sizeof(wrqu));
4129 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4130 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 goto done;
4132 }
4133 else if (strcasecmp(cmd, "macaddr") == 0)
4134 {
4135 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4136 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4137 }
4138 else if (strcasecmp(cmd, "scan-active") == 0)
4139 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304140 hddLog(VOS_TRACE_LEVEL_ERROR,
4141 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004142 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 ret = snprintf(cmd, cmd_len, "OK");
4144 }
4145 else if (strcasecmp(cmd, "scan-passive") == 0)
4146 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304147 hddLog(VOS_TRACE_LEVEL_ERROR,
4148 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004149 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 ret = snprintf(cmd, cmd_len, "OK");
4151 }
4152 else if( strcasecmp(cmd, "scan-mode") == 0 )
4153 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004154 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 }
4156 else if( strcasecmp(cmd, "linkspeed") == 0 )
4157 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004158 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 }
4160 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4161 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004162 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004163 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004164
4165 country_code = cmd + 8;
4166
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004167 init_completion(&pAdapter->change_country_code);
4168
Arif Hussain24bfa702014-01-22 13:51:30 -08004169 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004170 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 country_code,
4172 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304173 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304174 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304175 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004176
4177 /* Wait for completion */
4178 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4179 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4180
4181 if (lrc <= 0)
4182 {
4183 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004184 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004185 }
4186
Arif Hussain24bfa702014-01-22 13:51:30 -08004187 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004189 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004190 "%s: SME Change Country code fail", __func__);
4191 kfree(cmd);
4192 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 }
4194 }
4195 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4196 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004197 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 }
4199 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4200 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004201 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004202
Wilson Yang1be3e652013-10-09 15:18:31 -07004203 if (9 < cmd_len)
4204 {
4205 ptr = (char*)(cmd + 9);
4206
4207 }else{
4208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4209 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004210 kfree(cmd);
4211 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004212 }
4213
4214 if (1 != sscanf(ptr,"%d",&mode))
4215 {
4216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4217 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004218 kfree(cmd);
4219 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004220 }
4221
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 wlan_hdd_enter_bmps(pAdapter, mode);
4223 /*TODO:Set the power mode*/
4224 }
4225 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4226 v_U32_t pmc_state;
4227 v_U16_t value;
4228
4229 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4230 if(pmc_state == BMPS) {
4231 value = DRIVER_POWER_MODE_AUTO;
4232 }
4233 else {
4234 value = DRIVER_POWER_MODE_ACTIVE;
4235 }
4236 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4237 }
4238 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004239 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 /*TODO: set the btcoexmode*/
4241 }
4242 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4243
Arif Hussain6d2a3322013-11-17 19:50:10 -08004244 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 /*TODO: Return the btcoex status*/
4246 }
4247 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4248
Arif Hussain6d2a3322013-11-17 19:50:10 -08004249 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004250
4251 /*TODO: Enable Rx data Filter*/
4252 }
4253 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4254
Arif Hussain6d2a3322013-11-17 19:50:10 -08004255 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004256
4257 /*TODO: Disable Rx data Filter*/
4258 }
4259 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4260
Arif Hussain6d2a3322013-11-17 19:50:10 -08004261 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 /*TODO: rxfilter-statistics*/
4263 }
4264 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4265
Arif Hussain6d2a3322013-11-17 19:50:10 -08004266 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 /*TODO: rxfilter-add*/
4268 }
4269 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4270
Arif Hussain6d2a3322013-11-17 19:50:10 -08004271 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 /*TODO: rxfilter-remove*/
4273 }
4274#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004275 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4276 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4277 /*TODO: support pnosetup*/
4278 }
4279 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4280 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4281 /*TODO: support pnoforce*/
4282 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4284
Arif Hussain6d2a3322013-11-17 19:50:10 -08004285 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004286 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4287 kfree(cmd);
4288 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 }
4290 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004291 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004292 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4293 kfree(cmd);
4294 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 }
4296#endif /*FEATURE_WLAN_SCAN_PNO*/
4297 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004298 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004299 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4300 kfree(cmd);
4301 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 }
4303 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4304 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004305 char *ptr;
4306
4307 if (18 < cmd_len)
4308 {
4309 ptr = (char*)(cmd + 18);
4310 }else{
4311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4312 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004313 kfree(cmd);
4314 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004315 }
4316
Jeff Johnson02797792013-10-26 19:17:13 -07004317 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004318 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4319 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4320 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4321 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4322 {
4323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4324 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004325 kfree(cmd);
4326 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004327 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004328
4329 // parameters checking
4330 // period has to be larger than 0
4331 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4332 {
4333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004334 kfree(cmd);
4335 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 }
4337
4338 // use default value 5 is the input is not reasonable. in unit of 10%
4339 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4340 {
4341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4342 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4343 }
4344
4345 // default is 5
4346 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4347 {
4348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4349 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4350 }
4351
Arif Hussain24bfa702014-01-22 13:51:30 -08004352 if (eHAL_STATUS_SUCCESS !=
4353 sme_SetTxPerTracking(pHddCtx->hHal,
4354 hdd_tx_per_hit_cb,
4355 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004357 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 }
4359 }
4360 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004361 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4362 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 }
4364done:
4365 /* many of the commands write information back into the command
4366 string using snprintf(). check the return value here in one
4367 place */
4368 if ((ret < 0) || (ret >= cmd_len))
4369 {
4370 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004371 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004373 else if (ret > 0)
4374 {
4375 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4376 {
4377 hddLog(VOS_TRACE_LEVEL_ERROR,
4378 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004379 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004380 return -EFAULT;
4381 }
4382 wrqu->data.length = ret;
4383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004384
4385 if (ioctl_debug)
4386 {
4387 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004388 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004390 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304391 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004392 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004393}
4394
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304395static int iw_set_priv(struct net_device *dev,
4396 struct iw_request_info *info,
4397 union iwreq_data *wrqu, char *extra)
4398{
4399 int ret;
4400 vos_ssr_protect(__func__);
4401 ret = __iw_set_priv(dev, info, wrqu, extra);
4402 vos_ssr_unprotect(__func__);
4403
4404 return ret;
4405}
4406
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304407static int __iw_set_nick(struct net_device *dev,
4408 struct iw_request_info *info,
4409 union iwreq_data *wrqu, char *extra)
4410{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304411 hdd_adapter_t *pAdapter;
4412 hdd_context_t *pHddCtx;
4413 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304414
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304415 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304416
4417 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4418 if (NULL == pAdapter)
4419 {
4420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4421 "%s: Adapter is NULL",__func__);
4422 return -EINVAL;
4423 }
4424
4425 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4426 ret = wlan_hdd_validate_context(pHddCtx);
4427 if (0 != ret)
4428 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304429 return ret;
4430 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304431 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304432 return 0;
4433}
4434
Jeff Johnson295189b2012-06-20 16:38:30 -07004435static int iw_set_nick(struct net_device *dev,
4436 struct iw_request_info *info,
4437 union iwreq_data *wrqu, char *extra)
4438{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304439 int ret;
4440
4441 vos_ssr_protect(__func__);
4442 ret = __iw_set_nick(dev, info, wrqu, extra);
4443 vos_ssr_unprotect(__func__);
4444
4445 return ret;
4446}
4447
4448static int __iw_get_nick(struct net_device *dev,
4449 struct iw_request_info *info,
4450 union iwreq_data *wrqu, char *extra)
4451{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304452 hdd_adapter_t *pAdapter;
4453 hdd_context_t *pHddCtx;
4454 int ret = 0;
4455
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304457
4458 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4459 if (NULL == pAdapter)
4460 {
4461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4462 "%s: Adapter is NULL",__func__);
4463 return -EINVAL;
4464 }
4465
4466 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4467 ret = wlan_hdd_validate_context(pHddCtx);
4468 if (0 != ret)
4469 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304470 return ret;
4471 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304472 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 return 0;
4474}
4475
4476static int iw_get_nick(struct net_device *dev,
4477 struct iw_request_info *info,
4478 union iwreq_data *wrqu, char *extra)
4479{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304480 int ret;
4481
4482 vos_ssr_protect(__func__);
4483 ret = __iw_get_nick(dev, info, wrqu, extra);
4484 vos_ssr_unprotect(__func__);
4485
4486 return ret;
4487}
4488
4489static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4490{
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304492 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004493}
4494
4495static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4496{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304497
4498 struct iw_statistics *stats;
4499
4500 vos_ssr_protect(__func__);
4501 stats = __get_wireless_stats(dev);
4502 vos_ssr_unprotect(__func__);
4503
4504 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004505}
4506
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304507static int __iw_set_encode(struct net_device *dev,
4508 struct iw_request_info *info,
4509 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004510
4511{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304512 hdd_adapter_t *pAdapter;
4513 hdd_station_ctx_t *pHddStaCtx;
4514 hdd_wext_state_t *pWextState;
4515 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 struct iw_point *encoderq = &(wrqu->encoding);
4517 v_U32_t keyId;
4518 v_U8_t key_length;
4519 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4520 v_BOOL_t fKeyPresent = 0;
4521 int i;
4522 eHalStatus status = eHAL_STATUS_SUCCESS;
4523
4524
4525 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304526 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4527 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4530 "%s: Adapter is NULL",__func__);
4531 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 }
4533
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304534 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4535 status = wlan_hdd_validate_context(pHddCtx);
4536 if (0 != status)
4537 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304538 return status;
4539 }
4540 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4541 if (NULL == pWextState)
4542 {
4543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4544 "%s: pWextState is NULL ",__func__);
4545 return -EINVAL;
4546 }
4547 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4548 if (NULL == pHddStaCtx)
4549 {
4550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4551 "%s: STA Context is NULL",__func__);
4552 return -EINVAL;
4553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004554
4555 keyId = encoderq->flags & IW_ENCODE_INDEX;
4556
4557 if(keyId)
4558 {
4559 if(keyId > MAX_WEP_KEYS)
4560 {
4561 return -EINVAL;
4562 }
4563
4564 fKeyPresent = 1;
4565 keyId--;
4566 }
4567 else
4568 {
4569 fKeyPresent = 0;
4570 }
4571
4572
4573 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4574 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 if(!fKeyPresent) {
4577
4578 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4579
4580 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4581 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4582 }
4583 }
4584 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4585 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4586 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4587 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4588
4589 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4590 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4591
4592 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4593 {
4594 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4595 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004596 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304597 {
4598 long ret;
4599 ret = wait_for_completion_interruptible_timeout(
4600 &pAdapter->disconnect_comp_var,
4601 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4602 if (ret <= 0)
4603 hddLog(VOS_TRACE_LEVEL_ERROR,
4604 FL("failed wait on disconnect_comp_var %ld"), ret);
4605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 }
4607
4608 return status;
4609
4610 }
4611
4612 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4613 {
4614 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4615
4616 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4617
4618 }
4619
4620
4621 if(wrqu->data.length > 0)
4622 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004623 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004624
4625 key_length = wrqu->data.length;
4626
4627 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4628
4629 if(5 == key_length)
4630 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004631 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004632
4633 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4634 {
4635 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4636 }
4637 else
4638 {
4639 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4640 }
4641 }
4642 else if(13 == key_length)
4643 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004644 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004645
4646 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4647 {
4648 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4649 }
4650 else
4651 {
4652 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4653 }
4654 }
4655 else
4656 {
4657 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004658 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 return -EINVAL;
4660 }
4661
4662 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4663 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4664 pWextState->roamProfile.EncryptionType.numEntries = 1;
4665 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4666 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4667 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4668
4669 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4670 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4671 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4672 {
4673
4674 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4675
4676 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4677 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4678
4679 return status;
4680 }
4681 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304682 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 return 0;
4684}
4685
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304686static int iw_set_encode(struct net_device *dev,
4687 struct iw_request_info *info,
4688 union iwreq_data *wrqu,char *extra)
4689{
4690 int ret;
4691
4692 vos_ssr_protect(__func__);
4693 ret = __iw_set_encode(dev, info, wrqu, extra);
4694 vos_ssr_unprotect(__func__);
4695
4696 return ret;
4697}
4698
4699static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 struct iw_request_info *info,
4701 struct iw_point *dwrq,
4702 char *extra)
4703{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304704 hdd_adapter_t *pAdapter;
4705 hdd_wext_state_t *pWextState;
4706 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 int keyId;
4708 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4709 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304710 int i, ret = 0;
4711 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004712
4713 ENTER();
4714
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304715 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4716 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004717 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4719 "%s: Adapter is NULL",__func__);
4720 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004721 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304722 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4723 ret = wlan_hdd_validate_context(pHddCtx);
4724 if (0 != ret)
4725 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304726 return ret;
4727 }
4728 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4729 if (NULL == pWextState)
4730 {
4731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4732 "%s: pWextState is NULL",__func__);
4733 return -EINVAL;
4734 }
4735 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004736
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 keyId = pRoamProfile->Keys.defaultIndex;
4738
4739 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4740 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004741 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 return -EINVAL;
4743 }
4744
4745 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4746 {
4747 dwrq->flags |= IW_ENCODE_ENABLED;
4748 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304749 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4750 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 }
4752 else
4753 {
4754 dwrq->flags |= IW_ENCODE_DISABLED;
4755 }
4756
4757 for(i=0; i < MAX_WEP_KEYS; i++)
4758 {
4759 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4760 {
4761 continue;
4762 }
4763 else
4764 {
4765 break;
4766 }
4767 }
4768
4769 if(MAX_WEP_KEYS == i)
4770 {
4771 dwrq->flags |= IW_ENCODE_NOKEY;
4772 }
4773 else
4774 {
4775 dwrq->flags |= IW_ENCODE_ENABLED;
4776 }
4777
4778 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4779
4780 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4781 {
4782 dwrq->flags |= IW_ENCODE_DISABLED;
4783 }
4784
4785 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4786
4787 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4788 {
4789 dwrq->flags |= IW_ENCODE_OPEN;
4790 }
4791 else
4792 {
4793 dwrq->flags |= IW_ENCODE_RESTRICTED;
4794 }
4795 EXIT();
4796 return 0;
4797
4798}
4799
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304800static int iw_get_encodeext(struct net_device *dev,
4801 struct iw_request_info *info,
4802 struct iw_point *dwrq,
4803 char *extra)
4804{
4805 int ret;
4806 vos_ssr_protect(__func__);
4807 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4808 vos_ssr_unprotect(__func__);
4809
4810 return ret;
4811}
4812
4813static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 struct iw_request_info *info,
4815 union iwreq_data *wrqu, char *extra)
4816{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304817 hdd_adapter_t *pAdapter;
4818 hdd_station_ctx_t *pHddStaCtx;
4819 hdd_wext_state_t *pWextState;
4820 hdd_context_t *pHddCtx;
4821 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004822
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304823 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 v_U32_t status = 0;
4825
4826 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4827
4828 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4829
4830 int key_index;
4831 struct iw_point *encoding = &wrqu->encoding;
4832 tCsrRoamSetKey setKey;
4833 v_U32_t roamId= 0xFF;
4834 VOS_STATUS vos_status;
4835
4836 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304837 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4838 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4841 "%s: Adapter is NULL",__func__);
4842 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304844 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4845 status = wlan_hdd_validate_context(pHddCtx);
4846 if (0 != status)
4847 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304848 return status;
4849 }
4850 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4851 if (NULL == pHddStaCtx)
4852 {
4853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4854 "%s: STA Context is NULL",__func__);
4855 return -EINVAL;
4856 }
4857 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4858 if (NULL == pWextState)
4859 {
4860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4861 "%s: pWextState is NULL",__func__);
4862 return -EINVAL;
4863 }
4864 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004865 key_index = encoding->flags & IW_ENCODE_INDEX;
4866
4867 if(key_index > 0) {
4868
4869 /*Convert from 1-based to 0-based keying*/
4870 key_index--;
4871 }
4872 if(!ext->key_len) {
4873
4874 /*Set the encrytion type to NONE*/
4875 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4876 return status;
4877 }
4878
4879 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4880 (IW_ENCODE_ALG_WEP == ext->alg))
4881 {
4882 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4883
Agarwal Ashish971c2882013-10-30 20:11:12 +05304884 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4885 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 return -EINVAL;
4887 }
4888 else {
4889 /*Static wep, update the roam profile with the keys */
4890 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4891 key_index < CSR_MAX_NUM_KEY) {
4892 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4893 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4894
4895 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4896 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4897
4898 }
4899 }
4900 return status;
4901 }
4902
4903 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4904
4905 setKey.keyId = key_index;
4906 setKey.keyLength = ext->key_len;
4907
4908 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4909 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4910 }
4911
4912 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4913 /*Key direction for group is RX only*/
4914 setKey.keyDirection = eSIR_RX_ONLY;
4915 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4916 }
4917 else {
4918
4919 setKey.keyDirection = eSIR_TX_RX;
4920 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4921 }
4922
4923 /*For supplicant pae role is zero*/
4924 setKey.paeRole = 0;
4925
4926 switch(ext->alg)
4927 {
4928 case IW_ENCODE_ALG_NONE:
4929 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4930 break;
4931
4932 case IW_ENCODE_ALG_WEP:
4933 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4934 break;
4935
4936 case IW_ENCODE_ALG_TKIP:
4937 {
4938 v_U8_t *pKey = &setKey.Key[0];
4939
4940 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4941
4942 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4943
4944 /*Supplicant sends the 32bytes key in this order
4945
4946 |--------------|----------|----------|
4947 | Tk1 |TX-MIC | RX Mic |
4948 |--------------|----------|----------|
4949 <---16bytes---><--8bytes--><--8bytes-->
4950
4951 */
4952 /*Sme expects the 32 bytes key to be in the below order
4953
4954 |--------------|----------|----------|
4955 | Tk1 |RX-MIC | TX Mic |
4956 |--------------|----------|----------|
4957 <---16bytes---><--8bytes--><--8bytes-->
4958 */
4959 /* Copy the Temporal Key 1 (TK1) */
4960 vos_mem_copy(pKey,ext->key,16);
4961
4962 /*Copy the rx mic first*/
4963 vos_mem_copy(&pKey[16],&ext->key[24],8);
4964
4965 /*Copy the tx mic */
4966 vos_mem_copy(&pKey[24],&ext->key[16],8);
4967
4968 }
4969 break;
4970
4971 case IW_ENCODE_ALG_CCMP:
4972 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4973 break;
4974
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004975#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004976#define IW_ENCODE_ALG_KRK 6
4977 case IW_ENCODE_ALG_KRK:
4978 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4979 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004980#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004981
4982 default:
4983 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4984 break;
4985 }
4986
4987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004988 ("%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 -07004989
4990#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304991 /* The supplicant may attempt to set the PTK once pre-authentication
4992 is done. Save the key in the UMAC and include it in the ADD
4993 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304995 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304997 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4998 "%s: Update PreAuth Key success", __func__);
4999 return 0;
5000 }
5001 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5002 {
5003 hddLog(VOS_TRACE_LEVEL_ERROR,
5004 "%s: Update PreAuth Key failed", __func__);
5005 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 }
5007#endif /* WLAN_FEATURE_VOWIFI_11R */
5008
5009 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5010
5011 vos_status = wlan_hdd_check_ula_done(pAdapter);
5012 if ( vos_status != VOS_STATUS_SUCCESS )
5013 {
5014 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5015 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5016 __LINE__, vos_status );
5017
5018 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5019 }
5020
5021 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5022
5023 if ( halStatus != eHAL_STATUS_SUCCESS )
5024 {
5025 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5026 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5027 __LINE__, halStatus );
5028
5029 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5030 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305031 EXIT();
5032 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005033}
5034
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305035static int iw_set_encodeext(struct net_device *dev,
5036 struct iw_request_info *info,
5037 union iwreq_data *wrqu, char *extra)
5038{
5039 int ret;
5040
5041 vos_ssr_protect(__func__);
5042 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5043 vos_ssr_unprotect(__func__);
5044
5045 return ret;
5046}
5047
5048static int __iw_set_retry(struct net_device *dev,
5049 struct iw_request_info *info,
5050 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005051{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305052 hdd_adapter_t *pAdapter;
5053 tHalHandle hHal;
5054 hdd_context_t *pHddCtx;
5055 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005056
5057 ENTER();
5058
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305059 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5060 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005061 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5063 "%s: Adapter is NULL",__func__);
5064 return -EINVAL;
5065 }
5066
5067 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5068 ret = wlan_hdd_validate_context(pHddCtx);
5069 if (0 != ret)
5070 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305071 return ret;
5072 }
5073
5074 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5075 if (NULL == hHal)
5076 {
5077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5078 "%s: Hal Context is NULL",__func__);
5079 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005080 }
5081
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5083 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5084
Arif Hussain6d2a3322013-11-17 19:50:10 -08005085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005086
5087 return -EINVAL;
5088 }
5089
5090 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5091
5092 if((wrqu->retry.flags & IW_RETRY_LONG))
5093 {
5094 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5095 {
c_hpothub8245442013-11-20 23:41:09 +05305096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5097 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 return -EIO;
5099 }
5100 }
5101 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5102 {
5103 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5104 {
c_hpothub8245442013-11-20 23:41:09 +05305105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5106 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 return -EIO;
5108 }
5109 }
5110 }
5111 else
5112 {
5113 return -EOPNOTSUPP;
5114 }
5115
Arif Hussain6d2a3322013-11-17 19:50:10 -08005116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005117
5118 EXIT();
5119
5120 return 0;
5121
5122}
5123
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305124static int iw_set_retry(struct net_device *dev,
5125 struct iw_request_info *info,
5126 union iwreq_data *wrqu, char *extra)
5127{
5128 int ret;
5129
5130 vos_ssr_protect(__func__);
5131 ret = __iw_set_retry(dev, info, wrqu, extra);
5132 vos_ssr_unprotect(__func__);
5133
5134 return ret;
5135}
5136
5137static int __iw_get_retry(struct net_device *dev,
5138 struct iw_request_info *info,
5139 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005140{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305141 hdd_adapter_t *pAdapter;
5142 hdd_context_t *pHddCtx;
5143 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005144 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305145 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005146
5147 ENTER();
5148
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305149 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5150 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005151 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5153 "%s: Adapter is NULL",__func__);
5154 return -EINVAL;
5155 }
5156
5157 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5158 ret = wlan_hdd_validate_context(pHddCtx);
5159 if (0 != ret)
5160 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305161 return ret;
5162 }
5163
5164 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5165 if (NULL == hHal)
5166 {
5167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5168 "%s: Hal Context is NULL",__func__);
5169 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005170 }
5171
Jeff Johnson295189b2012-06-20 16:38:30 -07005172 if((wrqu->retry.flags & IW_RETRY_LONG))
5173 {
5174 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5175
5176 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5177 {
c_hpothub8245442013-11-20 23:41:09 +05305178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5179 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 return -EIO;
5181 }
5182
5183 wrqu->retry.value = retry;
5184 }
5185 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5186 {
5187 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5188
5189 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5190 {
c_hpothub8245442013-11-20 23:41:09 +05305191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5192 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 return -EIO;
5194 }
5195
5196 wrqu->retry.value = retry;
5197 }
5198 else {
5199 return -EOPNOTSUPP;
5200 }
5201
Arif Hussain6d2a3322013-11-17 19:50:10 -08005202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005203
5204 EXIT();
5205
5206 return 0;
5207}
5208
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305209static int iw_get_retry(struct net_device *dev,
5210 struct iw_request_info *info,
5211 union iwreq_data *wrqu, char *extra)
5212{
5213 int ret;
5214
5215 vos_ssr_protect(__func__);
5216 ret = __iw_get_retry(dev, info, wrqu, extra);
5217 vos_ssr_unprotect(__func__);
5218
5219 return ret;
5220}
5221
5222static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 struct iw_request_info *info,
5224 union iwreq_data *wrqu,
5225 char *extra)
5226{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305227 hdd_adapter_t *pAdapter;
5228 hdd_context_t *pHddCtx;
5229 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005230 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5231 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305232 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005233
5234 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305235 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5236 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5239 "%s:Adapter is NULL",__func__);
5240 return -EINVAL;
5241 }
5242 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5243 ret = wlan_hdd_validate_context(pHddCtx);
5244 if (0 != ret)
5245 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305246 return ret;
5247 }
5248 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5249 if (NULL == pHddStaCtx)
5250 {
5251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5252 "%s:STA context is NULL",__func__);
5253 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005254 }
5255
5256 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5257 switch (mlme->cmd) {
5258 case IW_MLME_DISASSOC:
5259 case IW_MLME_DEAUTH:
5260
5261 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5262 {
5263 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5264
5265 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5266 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5267
5268 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5269 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5270
Jeff Johnson43971f52012-07-17 12:26:56 -07005271 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305272 {
5273 long ret;
5274 ret = wait_for_completion_interruptible_timeout(
5275 &pAdapter->disconnect_comp_var,
5276 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5277 if (ret <= 0)
5278 hddLog(VOS_TRACE_LEVEL_ERROR,
5279 FL("failed wait on disconnect_comp_var %ld"), ret);
5280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005282 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005283 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005284
5285 /* Resetting authKeyMgmt */
5286 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5287
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305288 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 netif_tx_disable(dev);
5290 netif_carrier_off(dev);
5291
5292 }
5293 else
5294 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005295 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 -07005296 }
5297 break;
5298 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005299 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 return -EINVAL;
5301 }//end of switch
5302
5303 EXIT();
5304
5305 return status;
5306
5307}
5308
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305309static int iw_set_mlme(struct net_device *dev,
5310 struct iw_request_info *info,
5311 union iwreq_data *wrqu,
5312 char *extra)
5313{
5314 int ret;
5315
5316 vos_ssr_protect(__func__);
5317 ret = __iw_set_mlme(dev, info, wrqu, extra);
5318 vos_ssr_unprotect(__func__);
5319
5320 return ret;
5321}
5322
Jeff Johnson295189b2012-06-20 16:38:30 -07005323/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305324static int __iw_setint_getnone(struct net_device *dev,
5325 struct iw_request_info *info,
5326 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005327{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305328 hdd_adapter_t *pAdapter;
5329 tHalHandle hHal;
5330 hdd_wext_state_t *pWextState;
5331 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305332 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 int *value = (int *)extra;
5334 int sub_cmd = value[0];
5335 int set_value = value[1];
5336 int ret = 0; /* success */
5337 int enable_pbm, enable_mp;
5338#ifdef CONFIG_HAS_EARLYSUSPEND
5339 v_U8_t nEnableSuspendOld;
5340#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005341
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305342 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305343 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5344 if (NULL == pAdapter)
5345 {
5346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5347 "%s: Adapter is NULL",__func__);
5348 return -EINVAL;
5349 }
5350 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5351 ret = wlan_hdd_validate_context(pHddCtx);
5352 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005353 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305354 return ret;
5355 }
Katya Nigameae74b62015-05-28 17:19:16 +05305356 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305357 {
Katya Nigameae74b62015-05-28 17:19:16 +05305358 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5359 if (NULL == hHal)
5360 {
5361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5362 "%s: Hal Context is NULL",__func__);
5363 return -EINVAL;
5364 }
5365 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5366 if (NULL == pWextState)
5367 {
5368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5369 "%s: pWextState is NULL",__func__);
5370 return -EINVAL;
5371 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005372
Katya Nigameae74b62015-05-28 17:19:16 +05305373 INIT_COMPLETION(pWextState->completion_var);
5374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 switch(sub_cmd)
5376 {
5377 case WE_SET_11D_STATE:
5378 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005379 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005380 memset(&smeConfig, 0x00, sizeof(smeConfig));
5381
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5383
5384 sme_GetConfigParam(hHal,&smeConfig);
5385 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5386
Arif Hussain6d2a3322013-11-17 19:50:10 -08005387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005388
5389 sme_UpdateConfig(hHal,&smeConfig);
5390 }
5391 else {
5392 return -EINVAL;
5393 }
5394 break;
5395 }
5396
5397 case WE_WOWL:
5398 {
5399 switch (set_value)
5400 {
5401 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305402 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 break;
5404 case 0x01:
5405 case 0x02:
5406 case 0x03:
5407 enable_mp = (set_value & 0x01) ? 1 : 0;
5408 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005409 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5411 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5412 break;
5413 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005414 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 ret = -EINVAL;
5416 break;
5417 }
5418
5419 break;
5420 }
5421 case WE_SET_POWER:
5422 {
5423 switch (set_value)
5424 {
5425 case 0: //Full Power
5426 {
5427 struct statsContext context;
5428 eHalStatus status;
5429
5430 init_completion(&context.completion);
5431
5432 context.pAdapter = pAdapter;
5433 context.magic = POWER_CONTEXT_MAGIC;
5434
5435 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5436 iw_power_callback_fn, &context,
5437 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005438 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 {
5440 int lrc = wait_for_completion_interruptible_timeout(
5441 &context.completion,
5442 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005443
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 if (lrc <= 0)
5445 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005446 hddLog(VOS_TRACE_LEVEL_ERROR,
5447 "%s: SME %s while requesting fullpower",
5448 __func__, (0 == lrc) ?
5449 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 }
5451 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005452 /* either we have a response or we timed out. if we timed
5453 out there is a race condition such that the callback
5454 function could be executing at the same time we are. of
5455 primary concern is if the callback function had already
5456 verified the "magic" but had not yet set the completion
5457 variable when a timeout occurred. we serialize these
5458 activities by invalidating the magic while holding a
5459 shared spinlock which will cause us to block if the
5460 callback is currently executing */
5461 spin_lock(&hdd_context_lock);
5462 context.magic = 0;
5463 spin_unlock(&hdd_context_lock);
5464
Arif Hussain6d2a3322013-11-17 19:50:10 -08005465 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 break;
5467 }
5468 case 1: //Enable BMPS
5469 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5470 break;
5471 case 2: //Disable BMPS
5472 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5473 break;
5474 case 3: //Request Bmps
5475 {
5476 struct statsContext context;
5477 eHalStatus status;
5478
5479 init_completion(&context.completion);
5480
5481 context.pAdapter = pAdapter;
5482 context.magic = POWER_CONTEXT_MAGIC;
5483
5484 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5485 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005486 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 {
5488 int lrc = wait_for_completion_interruptible_timeout(
5489 &context.completion,
5490 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 if (lrc <= 0)
5492 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005493 hddLog(VOS_TRACE_LEVEL_ERROR,
5494 "%s: SME %s while requesting BMPS",
5495 __func__, (0 == lrc) ? "timeout" :
5496 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 }
5498 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005499 /* either we have a response or we timed out. if we
5500 timed out there is a race condition such that the
5501 callback function could be executing at the same
5502 time we are. of primary concern is if the callback
5503 function had already verified the "magic" but had
5504 not yet set the completion variable when a timeout
5505 occurred. we serialize these activities by
5506 invalidating the magic while holding a shared
5507 spinlock which will cause us to block if the
5508 callback is currently executing */
5509 spin_lock(&hdd_context_lock);
5510 context.magic = 0;
5511 spin_unlock(&hdd_context_lock);
5512
Arif Hussain6d2a3322013-11-17 19:50:10 -08005513 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 break;
5515 }
5516 case 4: //Enable IMPS
5517 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5518 break;
5519 case 5: //Disable IMPS
5520 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5521 break;
5522 case 6: //Enable Standby
5523 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5524 break;
5525 case 7: //Disable Standby
5526 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5527 break;
5528 case 8: //Request Standby
5529#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005530#endif
5531 break;
5532 case 9: //Start Auto Bmps Timer
5533 sme_StartAutoBmpsTimer(hHal);
5534 break;
5535 case 10://Stop Auto BMPS Timer
5536 sme_StopAutoBmpsTimer(hHal);
5537 break;
5538#ifdef CONFIG_HAS_EARLYSUSPEND
5539 case 11://suspend to standby
5540#ifdef CONFIG_HAS_EARLYSUSPEND
5541 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5542 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5544#endif
5545 break;
5546 case 12://suspend to deep sleep
5547#ifdef CONFIG_HAS_EARLYSUSPEND
5548 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5549 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5551#endif
5552 break;
5553 case 13://resume from suspend
5554#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005555#endif
5556 break;
5557#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005559 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 ret = -EINVAL;
5561 break;
5562 }
5563 break;
5564 }
5565
5566 case WE_SET_MAX_ASSOC:
5567 {
5568 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5569 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5570 {
5571 ret = -EINVAL;
5572 }
5573 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5574 set_value, NULL, eANI_BOOLEAN_FALSE)
5575 != eHAL_STATUS_SUCCESS )
5576 {
c_hpothub8245442013-11-20 23:41:09 +05305577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5578 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 ret = -EIO;
5580 }
5581 break;
5582 }
5583
5584 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5585 {
5586 if( 0 == set_value )
5587 {
5588 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5589 }
5590 else if ( 1 == set_value )
5591 {
5592 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5593 }
5594 else
5595 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005596 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 ret = -EINVAL;
5598 }
5599 break;
5600 }
5601
5602 case WE_SET_DATA_INACTIVITY_TO:
5603 {
5604 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5605 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5606 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5607 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5608 set_value,
5609 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5610 {
5611 hddLog(LOGE,"Failure: Could not pass on "
5612 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005613 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 ret = -EINVAL;
5615 }
5616 break;
5617 }
5618 case WE_SET_MAX_TX_POWER:
5619 {
5620 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5621 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5622
5623 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5624 __func__, set_value);
5625 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5626 eHAL_STATUS_SUCCESS )
5627 {
5628 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5629 __func__);
5630 return -EIO;
5631 }
5632
5633 break;
5634 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005635 case WE_SET_MAX_TX_POWER_2_4:
5636 {
5637 hddLog(VOS_TRACE_LEVEL_INFO,
5638 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5639 __func__, set_value);
5640 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5641 eHAL_STATUS_SUCCESS)
5642 {
5643 hddLog(VOS_TRACE_LEVEL_ERROR,
5644 "%s: Setting maximum tx power failed for 2.4 GHz band",
5645 __func__);
5646 return -EIO;
5647 }
5648
5649 break;
5650 }
5651 case WE_SET_MAX_TX_POWER_5_0:
5652 {
5653 hddLog(VOS_TRACE_LEVEL_INFO,
5654 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5655 __func__, set_value);
5656 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5657 eHAL_STATUS_SUCCESS)
5658 {
5659 hddLog(VOS_TRACE_LEVEL_ERROR,
5660 "%s: Setting maximum tx power failed for 5.0 GHz band",
5661 __func__);
5662 return -EIO;
5663 }
5664
5665 break;
5666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 case WE_SET_HIGHER_DTIM_TRANSITION:
5668 {
5669 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5670 (set_value == eANI_BOOLEAN_TRUE)))
5671 {
5672 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5673 ret = -EINVAL;
5674 }
5675 else
5676 {
5677 if(pAdapter->higherDtimTransition != set_value)
5678 {
5679 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005680 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 }
5682 }
5683
5684 break;
5685 }
5686
5687 case WE_SET_TM_LEVEL:
5688 {
5689 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005690 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5692
5693 break;
5694 }
5695
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305696 case WE_ENABLE_STRICT_FCC_REG:
5697 {
5698 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5699 struct wiphy *wiphy = NULL;
5700 long lrc;
5701 int status;
5702
5703 wiphy = hddCtxt->wiphy;
5704 if(wiphy == NULL)
5705 {
5706 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5707 break;
5708 }
5709 init_completion(&hddCtxt->wiphy_channel_update_event);
5710
5711 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5712
5713 status = regulatory_hint(wiphy, "00");
5714 if(status < 0)
5715 {
5716 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5717 break;
5718 }
5719
5720 /* Wait for completion */
5721 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5722 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5723 if (lrc <= 0)
5724 {
5725 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5726 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5727 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5728 }
5729 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5730
5731 break;
5732 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005733 case WE_SET_DEBUG_LOG:
5734 {
5735 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5736 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5737 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5738 break;
5739 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305740#ifdef FEATURE_WLAN_TDLS
5741 case WE_SET_TDLS_OFF_CHAN:
5742 {
5743 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5745 __func__, set_value);
5746 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5747 break;
5748 }
5749 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5750 {
5751 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5753 __func__, set_value);
5754 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5755 break;
5756 }
5757 case WE_SET_TDLS_OFF_CHAN_MODE:
5758 {
5759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5760 __func__, set_value);
5761 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5762 break;
5763 }
5764#endif
Peng Xu2446a892014-09-05 17:21:18 +05305765 case WE_SET_SCAN_BAND_PREFERENCE:
5766 {
5767 tSmeConfigParams smeConfig;
5768 memset(&smeConfig, 0x00, sizeof(smeConfig));
5769 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5770 ret = -EINVAL;
5771 break;
5772 }
5773 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5774
5775 if (eCSR_BAND_ALL == set_value ||
5776 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5777 sme_GetConfigParam(hHal, &smeConfig);
5778 smeConfig.csrConfig.scanBandPreference = set_value;
5779
5780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5781 "set band scan preference = %d\n",
5782 smeConfig.csrConfig.scanBandPreference);
5783
5784 sme_UpdateConfig(hHal, &smeConfig);
5785 }
5786 else {
5787 ret = -EINVAL;
5788 }
5789 break;
5790 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305791 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5792 * connection happens so that the params can take effect during
5793 * association. Also this should not be used in STA+p2p concurrency
5794 * as the param will also effect the STA mode.
5795 */
5796 case WE_SET_MIRACAST_VENDOR_CONFIG:
5797 {
5798 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305799
Abhishek Singh01c73d12015-03-12 15:13:44 +05305800 hddLog(LOG1, FL(
5801 "Set Miracast vendor tuning %d"), set_value);
5802
5803 if (1 == set_value || 0 == set_value)
5804 {
5805 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5806 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5807 {
5808 hddLog( LOGE, FL("set vendor miracast config failed"));
5809 ret = -EIO;
5810 }
5811 }
5812 else
5813 {
5814 hddLog(LOGE,
5815 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5816 ret = -EINVAL;
5817 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305818 break;
5819 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305820
5821 case WE_GET_FRAME_LOG:
5822 {
5823 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5824 != VOS_STATUS_SUCCESS)
5825 {
5826 ret = -EINVAL;
5827 }
5828 break;
5829 }
5830
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305831 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5832 {
5833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5834 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5835 if (set_value == 0 || set_value == 1)
5836 {
5837 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5838 set_value);
5839 }
5840 else
5841 ret = -EINVAL;
5842
5843 break;
5844 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05305845 /* Bit mask value to enable RTS/CTS for different modes
5846 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
5847 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
5848 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
5849 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
5850 * for 5 GHz, VHT80 - 0x1000
5851 */
5852 case WE_SET_RTS_CTS_HTVHT:
5853 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305854
Abhishek Singh41988ba2015-05-25 19:42:29 +05305855 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
5856
5857 if (eHAL_STATUS_SUCCESS !=
5858 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
5859 {
5860 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
5861 ret = -EINVAL;
5862 }
5863 break;
5864 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305865 case WE_SET_MONITOR_STATE:
5866 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305867 v_U32_t magic = 0;
5868 struct completion cmpVar;
5869 long waitRet = 0;
5870 tVOS_CON_MODE mode = hdd_get_conparam();
5871
5872 if( VOS_MONITOR_MODE != mode)
5873 {
5874 hddLog(LOGE, "invalid mode %d", mode);
5875 ret = -EIO;
5876 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305877
5878 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
5879 if( pMonCtx == NULL )
5880 {
5881 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305882 ret = -EIO;
5883 }
5884 if (pMonCtx->state == set_value)
5885 {
5886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5887 FL("already in same mode curr_mode:%d req_mode: %d"),
5888 pMonCtx->state, set_value);
5889 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305890 }
5891 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305892 magic = MON_MODE_MSG_MAGIC;
5893 init_completion(&cmpVar);
5894 if (VOS_STATUS_SUCCESS !=
5895 wlan_hdd_mon_postMsg(&magic, &cmpVar,
5896 pMonCtx, hdd_monPostMsgCb)) {
5897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5898 FL("failed to post MON MODE REQ"));
5899 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
5900 MON_MODE_STOP : MON_MODE_START;
5901 magic = 0;
5902 ret = -EIO;
5903 break;
5904 }
5905 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
5906 magic = 0;
5907 if (waitRet <= 0 ){
5908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5909 FL("failed to wait on monitor mode completion %ld"),
5910 waitRet);
5911 }
5912 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305913 }
5914
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 default:
5916 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005917 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 sub_cmd, set_value);
5919 break;
5920 }
5921 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305922 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 return ret;
5924}
5925
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305926static int iw_setint_getnone(struct net_device *dev,
5927 struct iw_request_info *info,
5928 union iwreq_data *wrqu, char *extra)
5929{
5930 int ret;
5931
5932 vos_ssr_protect(__func__);
5933 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5934 vos_ssr_unprotect(__func__);
5935
5936 return 0;
5937}
Jeff Johnson295189b2012-06-20 16:38:30 -07005938/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305939static int __iw_setchar_getnone(struct net_device *dev,
5940 struct iw_request_info *info,
5941 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005942{
5943 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305944 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005946 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305947 hdd_adapter_t *pAdapter;
5948 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005949#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305950 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005951#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305952 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305953 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005954
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305955 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305956 pAdapter = (netdev_priv(dev));
5957 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005958 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5960 "%s: Adapter is NULL",__func__);
5961 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005962 }
5963
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305964 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5965 ret = wlan_hdd_validate_context(pHddCtx);
5966 if (0 != ret)
5967 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305968 return ret;
5969 }
5970#ifdef WLAN_FEATURE_VOWIFI
5971 pConfig = pHddCtx->cfg_ini;
5972#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305973 /* helper function to get iwreq_data with compat handling. */
5974 if (hdd_priv_get_data(&s_priv_data, wrqu))
5975 {
5976 return -EINVAL;
5977 }
5978
5979 /* make sure all params are correctly passed to function */
5980 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5981 {
5982 return -EINVAL;
5983 }
5984
5985 sub_cmd = s_priv_data.flags;
5986
Arif Hussain0273cba2014-01-07 20:58:29 -08005987 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305988 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5989 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005990 if (NULL == pBuffer)
5991 {
5992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5993 "mem_alloc_copy_from_user_helper fail");
5994 return -ENOMEM;
5995 }
5996
5997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305998 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6000 "%s: Received data %s", __func__, pBuffer);
6001
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 switch(sub_cmd)
6003 {
6004 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006006 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 break;
6008 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006010 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 break;
6012#if defined WLAN_FEATURE_VOWIFI
6013 case WE_NEIGHBOR_REPORT_REQUEST:
6014 {
6015 tRrmNeighborReq neighborReq;
6016 tRrmNeighborRspCallbackInfo callbackInfo;
6017
6018 if (pConfig->fRrmEnable)
6019 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306021 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 if( !neighborReq.no_ssid )
6023 {
Girish Gowli552fc072014-06-14 18:26:16 +05306024 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006025 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 }
6027
6028 callbackInfo.neighborRspCallback = NULL;
6029 callbackInfo.neighborRspCallbackContext = NULL;
6030 callbackInfo.timeout = 5000; //5 seconds
6031 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6032 }
6033 else
6034 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006035 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 ret = -EINVAL;
6037 }
6038 }
6039 break;
6040#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 case WE_SET_AP_WPS_IE:
6042 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306043 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006046 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 if (VOS_STATUS_SUCCESS != vstatus)
6048 {
6049 ret = -EINVAL;
6050 }
6051 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306052 case WE_SET_ENCRYPT_MSG:
6053 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6054 if (NULL == pkt)
6055 {
6056 hddLog(VOS_TRACE_LEVEL_ERROR,
6057 "%s: vos_mem_alloc failed", __func__);
6058 return -ENOMEM;
6059 }
6060
6061 memset(pkt, 0, sizeof(tSirpkt80211));
6062
6063 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6064 hddLog(VOS_TRACE_LEVEL_ERROR,
6065 FL("Firmware is not DISA capable"));
6066 ret = -EINVAL;
6067 vos_mem_free(pkt);
6068 break;
6069 }
6070
6071 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6072
6073 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6074 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6075 if (eHAL_STATUS_SUCCESS != ret) {
6076 hddLog(VOS_TRACE_LEVEL_ERROR,
6077 FL("SENDEncryptMSG: fail to post WDA cmd"));
6078 ret = -EINVAL;
6079 }
6080 vos_mem_free(pkt);
6081
6082 break;
6083
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 default:
6085 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006086 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 ret = -EINVAL;
6088 break;
6089 }
6090 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006091 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306092
6093 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 return ret;
6095}
6096
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306097static int iw_setchar_getnone(struct net_device *dev,
6098 struct iw_request_info *info,
6099 union iwreq_data *wrqu, char *extra)
6100{
6101 int ret;
6102
6103 vos_ssr_protect(__func__);
6104 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6105 vos_ssr_unprotect(__func__);
6106
6107 return ret;
6108}
6109
Jeff Johnson295189b2012-06-20 16:38:30 -07006110/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306111static int __iw_setnone_getint(struct net_device *dev,
6112 struct iw_request_info *info,
6113 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006114{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306115 hdd_adapter_t *pAdapter;
6116 tHalHandle hHal;
6117 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 int *value = (int *)extra;
6119 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05306120 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006121
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306122 ENTER();
6123
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306124 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6125 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006126 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6128 "%s: Adapter is NULL",__func__);
6129 return -EINVAL;
6130 }
6131 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6132 ret = wlan_hdd_validate_context(pHddCtx);
6133 if (0 != ret)
6134 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306135 return ret;
6136 }
6137 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6138 if (NULL == hHal)
6139 {
6140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6141 "%s: Hal Context is NULL",__func__);
6142 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006144
6145 switch (value[0])
6146 {
6147 case WE_GET_11D_STATE:
6148 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006149 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306151
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6153
Arif Hussain6d2a3322013-11-17 19:50:10 -08006154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006155
6156 break;
6157 }
6158
6159 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 break;
6162
6163 case WE_PMC_STATE:
6164 {
6165 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 break;
6168 }
6169 case WE_GET_WLAN_DBG:
6170 {
6171 vos_trace_display();
6172 *value = 0;
6173 break;
6174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 case WE_GET_MAX_ASSOC:
6176 {
6177 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6178 {
c_hpothub8245442013-11-20 23:41:09 +05306179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6180 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 ret = -EIO;
6182 }
Girish Gowli385be612014-09-18 11:17:20 +05306183#ifdef WLAN_SOFTAP_VSTA_FEATURE
6184 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6185 {
6186 if (*value > VSTA_NUM_ASSOC_STA)
6187 {
6188 *value = VSTA_NUM_ASSOC_STA;
6189 }
6190 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6191 (*value > (VSTA_NUM_ASSOC_STA -
6192 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6193 {
6194 *value = (VSTA_NUM_ASSOC_STA -
6195 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6196 }
6197 }
6198 else
6199#endif
6200 {
6201 if (*value > NUM_ASSOC_STA)
6202 {
6203 *value = NUM_ASSOC_STA;
6204 }
6205 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6206 (*value > (NUM_ASSOC_STA -
6207 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6208 {
6209 *value = (NUM_ASSOC_STA -
6210 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6211 }
6212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 break;
6214 }
6215
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 case WE_GET_WDI_DBG:
6217 {
6218 wpalTraceDisplay();
6219 *value = 0;
6220 break;
6221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006222
6223 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6224 {
6225 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6226 break;
6227 }
6228 case WE_GET_CONCURRENCY_MODE:
6229 {
6230 *value = hdd_get_concurrency_mode ( );
6231
Arif Hussain6d2a3322013-11-17 19:50:10 -08006232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 break;
6234 }
6235
Peng Xu2446a892014-09-05 17:21:18 +05306236 case WE_GET_SCAN_BAND_PREFERENCE:
6237 {
6238 sme_GetConfigParam(hHal, &smeConfig);
6239 *value = smeConfig.csrConfig.scanBandPreference;
6240
6241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6242 "scanBandPreference = %d\n", *value);
6243 break;
6244 }
6245
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 default:
6247 {
6248 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6249 break;
6250 }
6251 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306252 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 return ret;
6254}
6255
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306256static int iw_setnone_getint(struct net_device *dev,
6257 struct iw_request_info *info,
6258 union iwreq_data *wrqu, char *extra)
6259{
6260 int ret;
6261
6262 vos_ssr_protect(__func__);
6263 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6264 vos_ssr_unprotect(__func__);
6265
6266 return ret;
6267
6268}
Jeff Johnson295189b2012-06-20 16:38:30 -07006269/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306270int __iw_set_three_ints_getnone(struct net_device *dev,
6271 struct iw_request_info *info,
6272 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006273{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306274 hdd_adapter_t *pAdapter;
6275 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 int *value = (int *)extra;
6277 int sub_cmd = value[0];
6278 int ret = 0;
6279
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306280 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306281 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6282 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006283 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6285 "%s: Adapter is NULL",__func__);
6286 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006287 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306288 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6289 ret = wlan_hdd_validate_context(pHddCtx);
6290 if (0 != ret)
6291 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306292 return ret;
6293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 switch(sub_cmd)
6295 {
6296 case WE_SET_WLAN_DBG:
6297 {
6298 vos_trace_setValue( value[1], value[2], value[3]);
6299 break;
6300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 case WE_SET_WDI_DBG:
6302 {
6303 wpalTraceSetLevel( value[1], value[2], value[3]);
6304 break;
6305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 case WE_SET_SAP_CHANNELS:
6307 {
6308 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6309 break;
6310 }
6311
6312 default:
6313 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006314 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 break;
6316 }
6317 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306318 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 return ret;
6320}
6321
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306322int iw_set_three_ints_getnone(struct net_device *dev,
6323 struct iw_request_info *info,
6324 union iwreq_data *wrqu, char *extra)
6325{
6326 int ret;
6327
6328 vos_ssr_protect(__func__);
6329 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6330 vos_ssr_unprotect(__func__);
6331
6332 return ret;
6333}
6334
6335static int __iw_get_char_setnone(struct net_device *dev,
6336 struct iw_request_info *info,
6337 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006338{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306339 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306341 hdd_context_t *pHddCtx;
6342 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006343#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006344 hdd_wext_state_t *pWextState;
6345#endif
6346
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306347 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306348 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006349 if (pAdapter == NULL)
6350 {
6351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6352 "%s: pAdapter is NULL!", __func__);
6353 return -EINVAL;
6354 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306355 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6356 ret = wlan_hdd_validate_context(pHddCtx);
6357 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006358 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306359 return ret;
6360 }
6361#ifdef WLAN_FEATURE_11W
6362 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6363 if (NULL == pWextState)
6364 {
6365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6366 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006367 return -EINVAL;
6368 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306369#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006370
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 switch(sub_cmd)
6372 {
6373 case WE_WLAN_VERSION:
6374 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006375 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 break;
6377 }
6378
6379 case WE_GET_STATS:
6380 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306381 tHalHandle hHal = NULL;
6382 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6384 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6385 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6386
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306387
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 snprintf(extra, WE_MAX_STR_LEN,
6389 "\nTransmit"
6390 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6391 "\n dropped BK %u, BE %u, VI %u, VO %u"
6392 "\n classified BK %u, BE %u, VI %u, VO %u"
6393 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6394 "\n queued BK %u, BE %u, VI %u, VO %u"
6395 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006396 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 "\n fetched BK %u, BE %u, VI %u, VO %u"
6398 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6399 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006400 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 "\n flushed BK %u, BE %u, VI %u, VO %u"
6402 "\n\nReceive"
6403 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6404 "\n\nResetsStats"
6405 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6406 "\n",
6407 pStats->txXmitCalled,
6408 pStats->txXmitDropped,
6409 pStats->txXmitBackPressured,
6410 pStats->txXmitQueued,
6411
6412 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6413 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6414 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6415 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6416
6417 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6418 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6419 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6420 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6421
6422 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6423 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6424 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6425 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6426
6427 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6428 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6429 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6430 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6431
6432 pStats->txFetched,
6433 pStats->txFetchEmpty,
6434 pStats->txFetchLowResources,
6435 pStats->txFetchDequeueError,
6436
6437 pStats->txFetchDequeued,
6438 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006439 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 pStats->txCompleted,
6441 pStats->txFlushed,
6442
6443 pStats->txFetchedAC[WLANTL_AC_BK],
6444 pStats->txFetchedAC[WLANTL_AC_BE],
6445 pStats->txFetchedAC[WLANTL_AC_VI],
6446 pStats->txFetchedAC[WLANTL_AC_VO],
6447
6448 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6449 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6450 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6451 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6452
6453 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6454 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6455 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6456 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6457
Ravi Joshi41914632013-10-21 23:02:21 -07006458 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6459 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6460 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6461 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6462
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 pStats->txFlushedAC[WLANTL_AC_BK],
6464 pStats->txFlushedAC[WLANTL_AC_BE],
6465 pStats->txFlushedAC[WLANTL_AC_VI],
6466 pStats->txFlushedAC[WLANTL_AC_VO],
6467
6468 pStats->rxChains,
6469 pStats->rxPackets,
6470 pStats->rxDropped,
6471 pStats->rxDelivered,
6472 pStats->rxRefused,
6473
6474 pResetStats->totalLogpResets,
6475 pResetStats->totalCMD53Failures,
6476 pResetStats->totalMutexReadFailures,
6477 pResetStats->totalMIFErrorFailures,
6478 pResetStats->totalFWHearbeatFailures,
6479 pResetStats->totalUnknownExceptions
6480 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306481 wrqu->data.length = strlen(extra);
6482
6483 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6484
6485 if (hHal)
6486 pMac = PMAC_STRUCT( hHal );
6487
6488 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6489 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6490 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306491 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6492 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6493 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6494 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306495 "\n",
6496 pMac->pmm.BmpscntSleep,
6497 pMac->pmm.BmpscntAwake,
6498 pMac->pmm.BmpsSleeReqFailCnt,
6499 pMac->pmm.BmpsWakeupReqFailCnt,
6500 pMac->pmm.ImpsCntSleep,
6501 pMac->pmm.ImpsCntAwake,
6502 pMac->pmm.ImpsSleepErrCnt,
6503 pMac->pmm.ImpsWakeupErrCnt,
6504 pMac->pmm.ImpsLastErr
6505 );
6506 }
6507
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 wrqu->data.length = strlen(extra)+1;
6509 break;
6510 }
6511
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306512/* The case prints the current state of the HDD, SME, CSR, PE, TL
6513 *it can be extended for WDI Global State as well.
6514 *And currently it only checks P2P_CLIENT adapter.
6515 *P2P_DEVICE and P2P_GO have not been added as of now.
6516*/
6517 case WE_GET_STATES:
6518 {
6519 int buf = 0, len = 0;
6520 int adapter_num = 0;
6521 int count = 0, check = 1;
6522
6523 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006524 tHalHandle hHal = NULL;
6525 tpAniSirGlobal pMac = NULL;
6526 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306527
6528 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6529 hdd_adapter_t *useAdapter = NULL;
6530
6531 /* Print wlan0 or p2p0 states based on the adapter_num
6532 *by using the correct adapter
6533 */
6534 while ( adapter_num < 2 )
6535 {
6536 if ( WLAN_ADAPTER == adapter_num )
6537 {
6538 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006539 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306540 "\n\n wlan0 States:-");
6541 len += buf;
6542 }
6543 else if ( P2P_ADAPTER == adapter_num )
6544 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006545 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306546 "\n\n p2p0 States:-");
6547 len += buf;
6548
6549 if( !pHddCtx )
6550 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006551 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306552 "\n pHddCtx is NULL");
6553 len += buf;
6554 break;
6555 }
6556
6557 /*Printing p2p0 states only in the case when the device is
6558 configured as a p2p_client*/
6559 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6560 if ( !useAdapter )
6561 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006562 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306563 "\n Device not configured as P2P_CLIENT.");
6564 len += buf;
6565 break;
6566 }
6567 }
6568
6569 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006570 if (!hHal) {
6571 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6572 "\n pMac is NULL");
6573 len += buf;
6574 break;
6575 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306576 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006577 if (!pMac) {
6578 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6579 "\n pMac is NULL");
6580 len += buf;
6581 break;
6582 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306583 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6584 if( !pHddStaCtx )
6585 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006586 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306587 "\n pHddStaCtx is NULL");
6588 len += buf;
6589 break;
6590 }
6591
6592 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6593
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006594 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306595 "\n HDD Conn State - %s "
6596 "\n \n SME State:"
6597 "\n Neighbour Roam State - %s"
6598 "\n CSR State - %s"
6599 "\n CSR Substate - %s"
6600 "\n \n TL STA %d State: %s",
6601 macTraceGetHDDWlanConnState(
6602 pHddStaCtx->conn_info.connState),
6603 macTraceGetNeighbourRoamState(
6604 pMac->roam.neighborRoamInfo.neighborRoamState),
6605 macTraceGetcsrRoamState(
6606 pMac->roam.curState[useAdapter->sessionId]),
6607 macTraceGetcsrRoamSubState(
6608 pMac->roam.curSubState[useAdapter->sessionId]),
6609 pHddStaCtx->conn_info.staId[0],
6610 macTraceGetTLState(tlState)
6611 );
6612 len += buf;
6613 adapter_num++;
6614 }
6615
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006616 if (pMac) {
6617 /* Printing Lim State starting with global lim states */
6618 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6619 "\n \n LIM STATES:-"
6620 "\n Global Sme State - %s "\
6621 "\n Global mlm State - %s "\
6622 "\n",
6623 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6624 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6625 );
6626 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306627
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006628 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05306629 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306630 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006631 if ( pMac->lim.gpSession[count].valid )
6632 {
6633 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6634 "\n Lim Valid Session %d:-"
6635 "\n PE Sme State - %s "
6636 "\n PE Mlm State - %s "
6637 "\n",
6638 check,
6639 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6640 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6641 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306642
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006643 len += buf;
6644 check++;
6645 }
6646 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306647 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306648 }
6649
6650 wrqu->data.length = strlen(extra)+1;
6651 break;
6652 }
6653
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 case WE_GET_CFG:
6655 {
6656 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6657 wrqu->data.length = strlen(extra)+1;
6658 break;
6659 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006660#ifdef WLAN_FEATURE_11AC
6661 case WE_GET_RSSI:
6662 {
6663 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05306664 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07006665 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6666 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6667 wrqu->data.length = strlen(extra)+1;
6668 break;
6669 }
6670#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306671
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006672#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006673 case WE_GET_ROAM_RSSI:
6674 {
6675 v_S7_t s7Rssi = 0;
6676 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6677 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6678 wrqu->data.length = strlen(extra)+1;
6679 break;
6680 }
6681#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 case WE_GET_WMM_STATUS:
6683 {
6684 snprintf(extra, WE_MAX_STR_LEN,
6685 "\nDir: 0=up, 1=down, 3=both\n"
6686 "|------------------------|\n"
6687 "|AC | ACM |Admitted| Dir |\n"
6688 "|------------------------|\n"
6689 "|VO | %d | %3s | %d |\n"
6690 "|VI | %d | %3s | %d |\n"
6691 "|BE | %d | %3s | %d |\n"
6692 "|BK | %d | %3s | %d |\n"
6693 "|------------------------|\n",
6694 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6695 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6696 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6697 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6698 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6699 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6700 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6701 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6702 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6703 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6704 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6705 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6706
Jeff Johnsone7245742012-09-05 17:12:55 -07006707
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 wrqu->data.length = strlen(extra)+1;
6709 break;
6710 }
6711 case WE_GET_CHANNEL_LIST:
6712 {
6713 VOS_STATUS status;
6714 v_U8_t i, len;
6715 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306716 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6717 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6718 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 tChannelListInfo channel_list;
6720
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006721 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006723 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006725 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 return -EINVAL;
6727 }
6728 buf = extra;
6729
6730 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006731 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6732 * needed = 5 * number of channels. Check ifsufficient
6733 * buffer is available and then proceed to fill the buffer.
6734 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6736 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006737 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006738 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006739 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 return -EINVAL;
6741 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006742 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6743 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306744 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6745 {
6746 //Printing Country code in getChannelList
6747 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6748 {
6749 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6750 "%c ", pBuf[i]);
6751 }
6752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 for(i = 0 ; i < channel_list.num_channels; i++)
6754 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006755 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 }
6758 wrqu->data.length = strlen(extra)+1;
6759
6760 break;
6761 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006762#ifdef FEATURE_WLAN_TDLS
6763 case WE_GET_TDLS_PEERS:
6764 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006765 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006766 break;
6767 }
6768#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006769#ifdef WLAN_FEATURE_11W
6770 case WE_GET_11W_INFO:
6771 {
6772 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6773
6774 snprintf(extra, WE_MAX_STR_LEN,
6775 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6776 "\n Number of Unprotected Disassocs %d"
6777 "\n Number of Unprotected Deauths %d",
6778 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6779 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6780 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6781 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6782 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6783
6784 wrqu->data.length = strlen(extra)+1;
6785 break;
6786 }
6787#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306788 case WE_GET_SNR:
6789 {
6790 v_S7_t s7snr = 0;
6791 int status = 0;
6792 hdd_context_t *pHddCtx;
6793 hdd_station_ctx_t *pHddStaCtx;
6794
6795 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6796 status = wlan_hdd_validate_context(pHddCtx);
6797 if (0 != status)
6798 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306799 return status;
6800 }
6801
6802 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6803
6804 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6805 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6806 {
6807 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6808 " ConnectionState-%d", __func__,
6809 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6810 pHddStaCtx->conn_info.connState);
6811 return -ENONET;
6812 }
6813
6814 /*update the stats in TL*/
6815 wlan_hdd_get_station_stats(pAdapter);
6816 wlan_hdd_get_snr(pAdapter, &s7snr);
6817 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6818 wrqu->data.length = strlen(extra) + 1;
6819 break;
6820 }
6821
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306822 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006823 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006824 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 break;
6826 }
6827 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306828 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 return 0;
6830}
6831
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306832static int iw_get_char_setnone(struct net_device *dev,
6833 struct iw_request_info *info,
6834 union iwreq_data *wrqu, char *extra)
6835{
6836 int ret;
6837
6838 vos_ssr_protect(__func__);
6839 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6840 vos_ssr_unprotect(__func__);
6841
6842 return ret;
6843}
6844
Jeff Johnson295189b2012-06-20 16:38:30 -07006845/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306846static int __iw_setnone_getnone(struct net_device *dev,
6847 struct iw_request_info *info,
6848 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006849{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306850 hdd_adapter_t *pAdapter;
6851 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306852 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006853 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306854 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006855
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306856 ENTER();
6857
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306858 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6859 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006860 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6862 "%s: Adapter is NULL",__func__);
6863 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006864 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306865 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6866 ret = wlan_hdd_validate_context(pHddCtx);
6867 if (0 != ret)
6868 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306869 return ret;
6870 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306871 /* helper function to get iwreq_data with compat handling. */
6872 if (hdd_priv_get_data(&s_priv_data, wrqu))
6873 {
6874 return -EINVAL;
6875 }
6876
6877 sub_cmd = s_priv_data.flags;
6878
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 switch (sub_cmd)
6880 {
6881 case WE_CLEAR_STATS:
6882 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006884 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6885 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6886 break;
6887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 case WE_INIT_AP:
6889 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306890 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6891
6892 /* As Soft AP mode might been changed to STA already with
6893 * killing of Hostapd, need to find the adpater by name
6894 * rather than mode */
6895 hdd_adapter_t* pAdapter_to_stop =
6896 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6897 if( pAdapter_to_stop )
6898 {
6899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6900 "Adapter with name softap.0 already "
6901 "exist, ignoring the request.\nRemove the "
6902 "adapter and try again\n");
6903 break;
6904 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 pr_info("Init AP trigger\n");
6906 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6907 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6908 break;
6909 }
6910 case WE_STOP_AP:
6911 {
6912 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6913 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6914 * this is a dead code and need to find the adpater by name rather than mode */
6915 hdd_adapter_t* pAdapter_to_stop =
6916 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6917 if( pAdapter_to_stop )
6918 {
6919 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6920
6921 pr_info("Stopping AP mode\n");
6922
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306923 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6924 {
6925 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6926 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6927 }
6928
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306930 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306931 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006932 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6933
6934 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6935 pAdapter_to_stop->macAddressCurrent.bytes);
6936 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6937 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306938
6939 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6940 {
6941 /* put the device back into BMPS */
6942 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006944 }
6945 else
6946 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006947 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 }
6949
6950 break;
6951 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006952#ifdef WLAN_BTAMP_FEATURE
6953 case WE_ENABLE_AMP:
6954 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006956 WLANBAP_RegisterWithHCI(pAdapter);
6957 break;
6958 }
6959 case WE_DISABLE_AMP:
6960 {
6961 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6962 VOS_STATUS status;
6963
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006965
6966 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6967 status = WLANBAP_StopAmp();
6968 if(VOS_STATUS_SUCCESS != status )
6969 {
6970 pHddCtx->isAmpAllowed = VOS_TRUE;
6971 hddLog(VOS_TRACE_LEVEL_FATAL,
6972 "%s: Failed to stop AMP", __func__);
6973 }
6974 else
6975 {
6976 //a state m/c implementation in PAL is TBD to avoid this delay
6977 msleep(500);
6978 pHddCtx->isAmpAllowed = VOS_FALSE;
6979 WLANBAP_DeregisterFromHCI();
6980 }
6981
6982 break;
6983 }
6984#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006985 case WE_ENABLE_DXE_STALL_DETECT:
6986 {
schang6295e542013-03-12 15:31:23 -07006987 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6988 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006989 break;
6990 }
6991 case WE_DISPLAY_DXE_SNAP_SHOT:
6992 {
schang6295e542013-03-12 15:31:23 -07006993 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6994 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006995 break;
6996 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306997 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6998 {
6999 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7000 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307001 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307002 break;
7003 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307004
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307005 case WE_SET_REASSOC_TRIGGER:
7006 {
7007 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7008 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7009 v_U32_t roamId = 0;
7010 tCsrRoamModifyProfileFields modProfileFields;
7011 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7012 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
7013 return 0;
7014 }
7015
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307016 case WE_STOP_OBSS_SCAN:
7017 {
7018 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7019 2.OBSS scan is stopped by Firmware during the disassociation
7020 3.OBSS stop comamnd is added for debugging purpose*/
7021 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7022 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007023
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307024 if (pAdapter == NULL)
7025 {
7026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7027 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307028 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307029 }
7030 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7031 if (pMac == NULL)
7032 {
7033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7034 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307035 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307036 }
7037 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7038 }
7039 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307040 case WE_DUMP_ROAM_TIMER_LOG:
7041 {
7042 vos_dump_roam_time_log_service();
7043 break;
7044 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307045
Mukul Sharma84f27252014-07-14 18:11:42 +05307046 case WE_RESET_ROAM_TIMER_LOG:
7047 {
7048 vos_reset_roam_timer_log();
7049 break;
7050 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307051 case WE_GET_FW_LOGS:
7052 {
7053 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7054 WLAN_LOG_INDICATOR_IOCTL,
7055 WLAN_LOG_REASON_CODE_UNUSED,
7056 TRUE);
7057 break;
7058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007059 default:
7060 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007061 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 break;
7063 }
7064 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307065 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007066 return ret;
7067}
7068
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307069static int iw_setnone_getnone(struct net_device *dev,
7070 struct iw_request_info *info,
7071 union iwreq_data *wrqu, char *extra)
7072{
7073 int ret;
7074
7075 vos_ssr_protect(__func__);
7076 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7077 vos_ssr_unprotect(__func__);
7078
7079 return ret;
7080}
7081
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307082void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7083{
7084 /*
7085 * Function to display HDD WMM information
7086 * for Tx Queues.
7087 * Prints globala as well as per client depending
7088 * whether the clients are registered or not.
7089 */
7090 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307091 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7092 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307093 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7094 hdd_ibss_peer_info_t *pPeerInfo;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307095
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307096 for ( i=0; i< NUM_TX_QUEUES; i++)
7097 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307098 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307099
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007100 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307101 i, pAdapter->wmm_tx_queue[i].count,
7102 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307103 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307104 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307105 if(pSapCtx == NULL){
7106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7107 FL("psapCtx is NULL"));
7108 return;
7109 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307110
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307111 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307112 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7113 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307114 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307115 {
7116 hddLog(LOGE, "******STAIndex: %d*********", i);
7117 for ( j=0; j< NUM_TX_QUEUES; j++)
7118 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307119 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7120 {
7121 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7122 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d"
7123 "PrevAdress:%p, NextAddress:%p",
7124 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
7125 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
7126 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
7127 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7128 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307129 }
7130 }
7131 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307132 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307133
Katya Nigam1fd24402015-02-16 14:52:19 +05307134 if(pHddStaCtx == NULL){
7135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7136 FL("pHddStaCtx is NULL"));
7137 return;
7138 }
7139
7140 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7141 if(pPeerInfo == NULL){
7142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7143 FL("ppeerinfo is NULL"));
7144 return;
7145 }
7146
7147 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7148 {
7149 if(pPeerInfo->ibssStaInfo[i].isUsed)
7150 {
7151 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7152 for ( j=0; j< NUM_TX_QUEUES; j++)
7153 {
7154 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7155 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7156 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7157 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7158 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7159 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7160 }
7161 }
7162 }
7163
7164
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307165}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307166static int __iw_set_var_ints_getnone(struct net_device *dev,
7167 struct iw_request_info *info,
7168 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007169{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307170 hdd_adapter_t *pAdapter;
7171 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307172 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307173 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007174 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307175 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307176 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007177 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307178 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007179 int cmd = 0;
7180 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307181 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007182
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307183 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307184 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307185 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7187 "%s: NULL extra buffer pointer", __func__);
7188 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307189 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307190 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7191 if (NULL == pAdapter)
7192 {
7193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7194 "%s: Adapter is NULL",__func__);
7195 return -EINVAL;
7196 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307197 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307198 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7199 ret = wlan_hdd_validate_context(pHddCtx);
7200 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007201 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307202 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007203 }
Katya Nigameae74b62015-05-28 17:19:16 +05307204 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307205 {
Katya Nigameae74b62015-05-28 17:19:16 +05307206 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7207 if (NULL == hHal)
7208 {
7209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7210 "%s: Hal Context is NULL",__func__);
7211 return -EINVAL;
7212 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307213 }
7214 sub_cmd = wrqu->data.flags;
7215
7216 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7217
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007218
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007219 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7220 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7221 {
7222 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7223 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7224 {
7225 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7226 staId = pStaCtx->conn_info.staId[0];
7227 }
7228 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7229 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7230 {
7231 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7232 staId = pAPCtx->uBCStaId;
7233 }
7234 else
7235 {
7236 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7237 return 0;
7238 }
7239 }
7240
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 switch (sub_cmd)
7242 {
7243 case WE_LOG_DUMP_CMD:
7244 {
7245 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007246 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 apps_args[3], apps_args[4]);
7248
7249 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7250 apps_args[3], apps_args[4]);
7251
7252 }
7253 break;
7254
Jeff Johnson295189b2012-06-20 16:38:30 -07007255 case WE_P2P_NOA_CMD:
7256 {
7257 p2p_app_setP2pPs_t p2pNoA;
7258
7259 p2pNoA.opp_ps = apps_args[0];
7260 p2pNoA.ctWindow = apps_args[1];
7261 p2pNoA.duration = apps_args[2];
7262 p2pNoA.interval = apps_args[3];
7263 p2pNoA.count = apps_args[4];
7264 p2pNoA.single_noa_duration = apps_args[5];
7265 p2pNoA.psSelection = apps_args[6];
7266
7267 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7268 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007269 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7271
7272 hdd_setP2pPs(dev, &p2pNoA);
7273
7274 }
7275 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007276
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307277 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7278 {
7279 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7280 __func__, apps_args[0], apps_args[1]);
7281 vosTraceEnable(apps_args[0], apps_args[1]);
7282 }
7283 break;
7284
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007285 case WE_MTRACE_DUMP_CMD:
7286 {
7287 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7288 "bitmask_of_module %d ",
7289 __func__, apps_args[0], apps_args[1], apps_args[2],
7290 apps_args[3]);
7291 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7292 apps_args[2], apps_args[3]);
7293
7294 }
7295 break;
7296
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007297 case WE_MCC_CONFIG_CREDENTIAL :
7298 {
7299 cmd = 287; //Command should be updated if there is any change
7300 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007301 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007302 {
7303 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7304 }
7305 else
7306 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007307 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007308 return 0;
7309 }
7310 }
7311 break;
7312
7313 case WE_MCC_CONFIG_PARAMS :
7314 {
7315 cmd = 288; //command Should be updated if there is any change
7316 // in the Riva dump command
7317 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7318 }
7319 break;
7320
Chilam NG571c65a2013-01-19 12:27:36 +05307321#ifdef FEATURE_WLAN_TDLS
7322 case WE_TDLS_CONFIG_PARAMS :
7323 {
7324 tdls_config_params_t tdlsParams;
7325
Chilam Ng01120412013-02-19 18:32:21 -08007326 tdlsParams.tdls = apps_args[0];
7327 tdlsParams.tx_period_t = apps_args[1];
7328 tdlsParams.tx_packet_n = apps_args[2];
7329 tdlsParams.discovery_period_t = apps_args[3];
7330 tdlsParams.discovery_tries_n = apps_args[4];
7331 tdlsParams.idle_timeout_t = apps_args[5];
7332 tdlsParams.idle_packet_n = apps_args[6];
7333 tdlsParams.rssi_hysteresis = apps_args[7];
7334 tdlsParams.rssi_trigger_threshold = apps_args[8];
7335 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307336
Chilam Ng01120412013-02-19 18:32:21 -08007337 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307338 }
7339 break;
7340#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307341 case WE_CONFIGURE_MONITOR_MODE:
7342 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307343 v_U32_t magic = 0;
7344 struct completion cmpVar;
7345 long waitRet = 0;
7346
Katya Nigamf0511f62015-05-05 16:40:57 +05307347 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7348 if( pMonCtx == NULL )
7349 {
7350 hddLog(LOGE, "Monitor Context NULL");
7351 break;
7352 }
7353 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7354 __func__, apps_args[0], apps_args[1], apps_args[2],
7355 apps_args[3], apps_args[4]);
7356 /* Input Validation part of FW */
7357 pMonCtx->ChannelNo = apps_args[0];
7358 pMonCtx->ChannelBW = apps_args[1];
7359 pMonCtx->crcCheckEnabled = apps_args[2];
7360 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7361 pMonCtx->is80211to803ConReq = apps_args[4];
7362 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7363 if( pMonCtx->is80211to803ConReq )
7364 pAdapter->dev->type = ARPHRD_ETHER;
7365 else
7366 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7367 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7368 {
7369 hddLog(LOGE, "%s: Filtering data packets as management and control"
7370 " cannot be converted to 802.3 ",__func__);
7371 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7372 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307373 if (MON_MODE_START == pMonCtx->state) {
7374 magic = MON_MODE_MSG_MAGIC;
7375 init_completion(&cmpVar);
7376 if (VOS_STATUS_SUCCESS !=
7377 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7378 pMonCtx, hdd_monPostMsgCb)) {
7379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7380 FL("failed to post MON MODE REQ"));
7381 magic = 0;
7382 ret = -EIO;
7383 break;
7384 }
7385 waitRet = wait_for_completion_timeout(&cmpVar,
7386 MON_MODE_MSG_TIMEOUT);
7387 magic = 0;
7388 if (waitRet <= 0 ) {
7389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7390 FL("failed to wait on monitor mode completion %ld"),
7391 waitRet);
7392 }
7393 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307394 }
7395 break;
7396
7397 case WE_SET_MONITOR_MODE_FILTER:
7398 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307399 v_U32_t magic = 0;
7400 struct completion cmpVar;
7401 long waitRet = 0;
7402
Katya Nigamf0511f62015-05-05 16:40:57 +05307403 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7404 if( pMonCtx == NULL )
7405 {
7406 hddLog(LOGE, "Monitor Context NULL");
7407 break;
7408 }
7409 /* Input Validation Part of FW */
7410 pMonCtx->numOfMacFilters=1;
7411 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7412 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7413 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7414 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7415 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7416 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7417 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7418 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7419 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7420 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7421 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7422 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307423 if (MON_MODE_START == pMonCtx->state) {
7424 magic = MON_MODE_MSG_MAGIC;
7425 init_completion(&cmpVar);
7426 if (VOS_STATUS_SUCCESS !=
7427 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7428 pMonCtx, hdd_monPostMsgCb)) {
7429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7430 FL("failed to post MON MODE REQ"));
7431 magic = 0;
7432 ret = -EIO;
7433 break;
7434 }
7435 waitRet = wait_for_completion_timeout(&cmpVar,
7436 MON_MODE_MSG_TIMEOUT);
7437 magic = 0;
7438 if (waitRet <= 0 ) {
7439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7440 FL("failed to wait on monitor mode completion %ld"),
7441 waitRet);
7442 }
7443 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307444 }
7445 break;
7446
Jeff Johnson295189b2012-06-20 16:38:30 -07007447 default:
7448 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007449 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7450 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007451 }
7452 break;
7453 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307454 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007455 return 0;
7456}
7457
Girish Gowlifb9758e2014-11-19 15:19:17 +05307458static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7459 struct iw_request_info *info,
7460 union iwreq_data *wrqu, char *extra)
7461{
7462 int ret;
7463 union iwreq_data u_priv_wrqu;
7464 int apps_args[MAX_VAR_ARGS] = {0};
7465 int num_args;
7466
7467 /* helper function to get iwreq_data with compat handling. */
7468 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7469 {
7470 return -EINVAL;
7471 }
7472
7473 if (NULL == u_priv_wrqu.data.pointer)
7474 {
7475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7476 "%s: NULL data pointer", __func__);
7477 return -EINVAL;
7478 }
7479
7480 num_args = u_priv_wrqu.data.length;
7481 if (num_args > MAX_VAR_ARGS)
7482 {
7483 num_args = MAX_VAR_ARGS;
7484 }
7485
7486 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7487 (sizeof(int)) * num_args))
7488 {
7489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7490 "%s: failed to copy data from user buffer", __func__);
7491 return -EFAULT;
7492 }
7493
7494 vos_ssr_protect(__func__);
7495 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7496 (char *)&apps_args);
7497 vos_ssr_unprotect(__func__);
7498
7499 return ret;
7500}
7501
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307502int iw_set_var_ints_getnone(struct net_device *dev,
7503 struct iw_request_info *info,
7504 union iwreq_data *wrqu, char *extra)
7505{
7506 int ret;
7507 vos_ssr_protect(__func__);
7508 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7509 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007510
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307511 return ret;
7512}
7513
7514static int __iw_add_tspec(struct net_device *dev,
7515 struct iw_request_info *info,
7516 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007517{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307518 hdd_adapter_t *pAdapter;
7519 hdd_station_ctx_t *pHddStaCtx;
7520 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7522 int params[HDD_WLAN_WMM_PARAM_COUNT];
7523 sme_QosWmmTspecInfo tSpec;
7524 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307525 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307526 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007527
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307528 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307529 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7530 if (NULL == pAdapter)
7531 {
7532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7533 "%s: Adapter is NULL",__func__);
7534 return -EINVAL;
7535 }
7536 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7537 ret = wlan_hdd_validate_context(pHddCtx);
7538 if (0 != ret)
7539 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307540 return ret;
7541 }
7542 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7543 if (NULL == pHddStaCtx)
7544 {
7545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7546 "%s: STA Context is NULL",__func__);
7547 return -EINVAL;
7548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 // make sure the application is sufficiently priviledged
7550 // note that the kernel will do this for "set" ioctls, but since
7551 // this ioctl wants to return status to user space it must be
7552 // defined as a "get" ioctl
7553 if (!capable(CAP_NET_ADMIN))
7554 {
7555 return -EPERM;
7556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 // we must be associated in order to add a tspec
7558 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7559 {
7560 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7561 return 0;
7562 }
7563
7564 // since we are defined to be a "get" ioctl, and since the number
7565 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307566 // will pass down in the iwreq_data, we must copy the "set" params.
7567 // We must handle the compat for iwreq_data in 32U/64K environment.
7568
7569 // helper fucntion to get iwreq_data with compat handling.
7570 if (hdd_priv_get_data(&s_priv_data, wrqu))
7571 {
7572 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7573 return 0;
7574 }
7575
7576 // make sure all params are correctly passed to function
7577 if ((NULL == s_priv_data.pointer) ||
7578 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7579 {
7580 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7581 return 0;
7582 }
7583
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307585 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 {
7587 // hmmm, can't get them
7588 return -EIO;
7589 }
7590
7591 // clear the tspec
7592 memset(&tSpec, 0, sizeof(tSpec));
7593
7594 // validate the handle
7595 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7596 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7597 {
7598 // that one is reserved
7599 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7600 return 0;
7601 }
7602
7603 // validate the TID
7604 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7605 {
7606 // out of range
7607 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7608 return 0;
7609 }
7610 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7611
7612 // validate the direction
7613 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7614 {
7615 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7616 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7617 break;
7618
7619 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7620 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7621 break;
7622
7623 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7624 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7625 break;
7626
7627 default:
7628 // unknown
7629 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7630 return 0;
7631 }
7632
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307633 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7634
Jeff Johnson295189b2012-06-20 16:38:30 -07007635 // validate the user priority
7636 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7637 {
7638 // out of range
7639 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7640 return 0;
7641 }
7642 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307643 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7644 {
7645 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7646 return 0;
7647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007648
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7650 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7651 tSpec.ts_info.psb, tSpec.ts_info.up);
7652
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7654 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7655 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7656 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7657 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7658 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7659 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7660 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7661 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7662 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7663 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7664 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7665
7666 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7667
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307668 // Save the expected UAPSD settings by application, this will be needed
7669 // when re-negotiating UAPSD settings during BT Coex cases.
7670 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7671
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 // validate the ts info ack policy
7673 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7674 {
7675 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7676 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7677 break;
7678
7679 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7680 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7681 break;
7682
7683 default:
7684 // unknown
7685 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7686 return 0;
7687 }
7688
7689 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307690
7691 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 return 0;
7693}
7694
7695
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307696static int iw_add_tspec(struct net_device *dev,
7697 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 union iwreq_data *wrqu, char *extra)
7699{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307700 int ret;
7701
7702 vos_ssr_protect(__func__);
7703 ret = __iw_add_tspec(dev, info, wrqu, extra);
7704 vos_ssr_unprotect(__func__);
7705
7706 return ret;
7707}
7708
7709static int __iw_del_tspec(struct net_device *dev,
7710 struct iw_request_info *info,
7711 union iwreq_data *wrqu, char *extra)
7712{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307713 hdd_adapter_t *pAdapter;
7714 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007715 int *params = (int *)extra;
7716 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7717 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307718 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007719
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307720 ENTER();
7721
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307722 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7723 if (NULL == pAdapter)
7724 {
7725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7726 "%s: Adapter is NULL",__func__);
7727 return -EINVAL;
7728 }
7729
7730 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7731 ret = wlan_hdd_validate_context(pHddCtx);
7732 if (0 != ret)
7733 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307734 return ret;
7735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007736 // make sure the application is sufficiently priviledged
7737 // note that the kernel will do this for "set" ioctls, but since
7738 // this ioctl wants to return status to user space it must be
7739 // defined as a "get" ioctl
7740 if (!capable(CAP_NET_ADMIN))
7741 {
7742 return -EPERM;
7743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007744 // although we are defined to be a "get" ioctl, the params we require
7745 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7746 // is no need to copy the params from user space
7747
7748 // validate the handle
7749 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7750 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7751 {
7752 // that one is reserved
7753 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7754 return 0;
7755 }
7756
7757 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307758
7759 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007760 return 0;
7761}
7762
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307763static int iw_del_tspec(struct net_device *dev,
7764 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007765 union iwreq_data *wrqu, char *extra)
7766{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307767 int ret;
7768
7769 vos_ssr_protect(__func__);
7770 ret = __iw_del_tspec(dev, info, wrqu, extra);
7771 vos_ssr_unprotect(__func__);
7772
7773 return ret;
7774}
7775
7776
7777static int __iw_get_tspec(struct net_device *dev,
7778 struct iw_request_info *info,
7779 union iwreq_data *wrqu, char *extra)
7780{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307781 hdd_adapter_t *pAdapter;
7782 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 int *params = (int *)extra;
7784 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7785 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307786 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007787
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307788 ENTER();
7789
Jeff Johnson295189b2012-06-20 16:38:30 -07007790 // although we are defined to be a "get" ioctl, the params we require
7791 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7792 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307793 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7794 if (NULL == pAdapter)
7795 {
7796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7797 "%s: Adapter is NULL",__func__);
7798 return -EINVAL;
7799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007800
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7802 ret = wlan_hdd_validate_context(pHddCtx);
7803 if (0 != ret)
7804 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307805 return ret;
7806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007807 // validate the handle
7808 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7809 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7810 {
7811 // that one is reserved
7812 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7813 return 0;
7814 }
7815
7816 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307817 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 return 0;
7819}
7820
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307821static int iw_get_tspec(struct net_device *dev,
7822 struct iw_request_info *info,
7823 union iwreq_data *wrqu, char *extra)
7824{
7825 int ret;
7826
7827 vos_ssr_protect(__func__);
7828 ret = __iw_get_tspec(dev, info, wrqu, extra);
7829 vos_ssr_unprotect(__func__);
7830
7831 return ret;
7832}
7833
Jeff Johnson295189b2012-06-20 16:38:30 -07007834#ifdef WLAN_FEATURE_VOWIFI_11R
7835//
7836//
7837// Each time the supplicant has the auth_request or reassoc request
7838// IEs ready. This is pushed to the driver. The driver will inturn use
7839// it to send out the auth req and reassoc req for 11r FT Assoc.
7840//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307841static int __iw_set_fties(struct net_device *dev,
7842 struct iw_request_info *info,
7843 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007844{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307845 hdd_adapter_t *pAdapter;
7846 hdd_station_ctx_t *pHddStaCtx;
7847 hdd_context_t *pHddCtx;
7848 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 //v_CONTEXT_t pVosContext;
7850
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307851 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307852 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7853 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007854 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7856 "%s: Adapter is NULL",__func__);
7857 return -EINVAL;
7858 }
7859 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7860 ret = wlan_hdd_validate_context(pHddCtx);
7861 if (0 != ret)
7862 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307863 return ret;
7864 }
7865 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7866 if (NULL == pHddStaCtx)
7867 {
7868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7869 "%s: STA Context is NULL",__func__);
7870 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 if (!wrqu->data.length)
7873 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007874 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 return -EINVAL;
7876 }
7877 if (wrqu->data.pointer == NULL)
7878 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007879 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007880 return -EINVAL;
7881 }
7882
7883 // Added for debug on reception of Re-assoc Req.
7884 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7885 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007886 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007888 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007889 }
7890
7891#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007892 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007893#endif
7894
7895 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007896 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007897 wrqu->data.length);
7898
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307899 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 return 0;
7901}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307902
7903static int iw_set_fties(struct net_device *dev,
7904 struct iw_request_info *info,
7905 union iwreq_data *wrqu, char *extra)
7906{
7907 int ret;
7908
7909 vos_ssr_protect(__func__);
7910 ret = __iw_set_fties(dev, info, wrqu, extra);
7911 vos_ssr_unprotect(__func__);
7912
7913 return ret;
7914}
Jeff Johnson295189b2012-06-20 16:38:30 -07007915#endif
7916
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307917static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007918 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007919 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007920{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307921 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007922 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307923 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007924 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307925 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007926 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7927 int idx;
7928 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007929
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307930 ENTER();
7931
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307932 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7933 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007934 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7936 "%s: Adapter is NULL",__func__);
7937 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007938 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307939 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7940 ret_val = wlan_hdd_validate_context(pHddCtx);
7941 if (0 != ret_val)
7942 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307943 return ret_val;
7944 }
7945 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7946 if (NULL == hHal)
7947 {
7948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7949 "%s: Hal Context is NULL",__func__);
7950 return -EINVAL;
7951 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307952 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7953 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307954#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007955
Amar Singhalf3a6e762013-02-19 15:06:50 -08007956 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7957 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007958 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007959 hddLog(VOS_TRACE_LEVEL_ERROR,
7960 "%s: vos_mem_alloc failed", __func__);
7961 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007962 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007963
7964 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7965
7966 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7967 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7968
7969 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7970 mc_addr_list_ptr->ulMulticastAddrCnt);
7971
7972 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007973 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007974 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7975 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7976
7977 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7978 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007979 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007980
Amar Singhalf3a6e762013-02-19 15:06:50 -08007981 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7982 vos_mem_free(mc_addr_list_ptr);
7983 if (eHAL_STATUS_SUCCESS != ret_val)
7984 {
7985 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7986 __func__);
7987 return -EINVAL;
7988 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307989#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307990 }
7991 else
7992 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007993
Amar Singhalf3a6e762013-02-19 15:06:50 -08007994 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7995 "%s: Set MC BC Filter Config request: %d suspend %d",
7996 __func__, pRequest->mcastBcastFilterSetting,
7997 pHddCtx->hdd_wlan_suspended);
7998
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307999 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008000
8001 if (pHddCtx->hdd_wlan_suspended)
8002 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008003 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8004 if (NULL == wlanRxpFilterParam)
8005 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308006 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008007 "%s: vos_mem_alloc failed", __func__);
8008 return -EINVAL;
8009 }
8010
Amar Singhalf3a6e762013-02-19 15:06:50 -08008011 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8012 pRequest->mcastBcastFilterSetting;
8013 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8014
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308015 hdd_conf_hostoffload(pAdapter, TRUE);
8016 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8017 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008018
8019 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8020 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308021 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008022 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8023 wlanRxpFilterParam->setMcstBcstFilter);
8024
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308025 if (eHAL_STATUS_SUCCESS !=
8026 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8027 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008028 {
8029 hddLog(VOS_TRACE_LEVEL_ERROR,
8030 "%s: Failure to execute set HW MC/BC Filter request",
8031 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008032 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008033 return -EINVAL;
8034 }
8035
c_hpothud3ce76d2014-10-28 10:34:13 +05308036 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8037 {
8038 pHddCtx->sus_res_mcastbcast_filter =
8039 pRequest->mcastBcastFilterSetting;
8040 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008041 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008043
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308044 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008045 return 0;
8046}
8047
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308048static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8049 struct iw_request_info *info,
8050 union iwreq_data *wrqu, char *extra)
8051{
8052 int ret;
8053
8054 vos_ssr_protect(__func__);
8055 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8056 vos_ssr_unprotect(__func__);
8057
8058 return ret;
8059}
8060
8061static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8062 struct iw_request_info *info,
8063 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008064{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308065 hdd_adapter_t *pAdapter;
8066 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308067 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308068 int ret = 0;
8069
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308070 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008071
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308072 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8073 if (NULL == pAdapter)
8074 {
8075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8076 "%s: Adapter is NULL",__func__);
8077 return -EINVAL;
8078 }
8079
8080 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8081 ret = wlan_hdd_validate_context(pHddCtx);
8082 if (0 != ret)
8083 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308084 return ret;
8085 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308086 //Reset the filter to INI value as we have to clear the dynamic filter
8087 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008088
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308089 //Configure FW with new setting
8090 if (pHddCtx->hdd_wlan_suspended)
8091 {
8092 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8093 if (NULL == wlanRxpFilterParam)
8094 {
8095 hddLog(VOS_TRACE_LEVEL_ERROR,
8096 "%s: vos_mem_alloc failed", __func__);
8097 return -EINVAL;
8098 }
8099
8100 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8101 pHddCtx->configuredMcastBcastFilter;
8102 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8103
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308104 hdd_conf_hostoffload(pAdapter, TRUE);
8105 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8106 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308107
8108 if (eHAL_STATUS_SUCCESS !=
8109 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8110 wlanRxpFilterParam))
8111 {
8112 hddLog(VOS_TRACE_LEVEL_ERROR,
8113 "%s: Failure to execute set HW MC/BC Filter request",
8114 __func__);
8115 vos_mem_free(wlanRxpFilterParam);
8116 return -EINVAL;
8117 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308118
8119 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8120 {
8121 pHddCtx->sus_res_mcastbcast_filter =
8122 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8123 }
8124
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308125 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308126 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 return 0;
8128}
8129
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308130
8131static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8132 struct iw_request_info *info,
8133 union iwreq_data *wrqu, char *extra)
8134{
8135 int ret;
8136
8137 vos_ssr_protect(__func__);
8138 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8139 vos_ssr_unprotect(__func__);
8140
8141 return ret;
8142}
8143
8144static int __iw_set_host_offload(struct net_device *dev,
8145 struct iw_request_info *info,
8146 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008147{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308148 hdd_adapter_t *pAdapter;
8149 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008150 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308152 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008153
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308154 ENTER();
8155
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308156 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8157 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008158 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8160 "%s: Adapter is NULL",__func__);
8161 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008162 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308163 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8164 ret = wlan_hdd_validate_context(pHddCtx);
8165 if (0 != ret)
8166 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308167 return ret;
8168 }
8169
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 /* Debug display of request components. */
8171 switch (pRequest->offloadType)
8172 {
8173 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008174 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 switch (pRequest->enableOrDisable)
8176 {
8177 case WLAN_OFFLOAD_DISABLE:
8178 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8179 break;
8180 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8181 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8182 case WLAN_OFFLOAD_ENABLE:
8183 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8184 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8185 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8186 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8187 }
8188 break;
8189
8190 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008191 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008192 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008193 switch (pRequest->enableOrDisable)
8194 {
8195 case WLAN_OFFLOAD_DISABLE:
8196 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8197 break;
8198 case WLAN_OFFLOAD_ENABLE:
8199 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8200 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8201 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8202 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8203 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8204 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8205 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8206 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8207 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8208 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8209 }
8210 }
8211
8212 /* Execute offload request. The reason that we can copy the request information
8213 from the ioctl structure to the SME structure is that they are laid out
8214 exactly the same. Otherwise, each piece of information would have to be
8215 copied individually. */
8216 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008217 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8218 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008220 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 __func__);
8222 return -EINVAL;
8223 }
8224
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308225 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 return 0;
8227}
8228
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308229static int iw_set_host_offload(struct net_device *dev,
8230 struct iw_request_info *info,
8231 union iwreq_data *wrqu, char *extra)
8232{
8233 int ret;
8234
8235 vos_ssr_protect(__func__);
8236 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8237 vos_ssr_unprotect(__func__);
8238
8239 return ret;
8240}
8241
8242static int __iw_set_keepalive_params(struct net_device *dev,
8243 struct iw_request_info *info,
8244 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008245{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308246 hdd_adapter_t *pAdapter;
8247 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008248 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308250 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008251
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308252 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308253 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8254 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008255 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8257 "%s: Adapter is NULL",__func__);
8258 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308260 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8261 ret = wlan_hdd_validate_context(pHddCtx);
8262 if (0 != ret)
8263 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308264 return ret;
8265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008266 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008267 hddLog(VOS_TRACE_LEVEL_INFO,
8268 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8269 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008270
8271 switch (pRequest->packetType)
8272 {
8273 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008274 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 break;
8276
8277 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8278
Arif Hussain6d2a3322013-11-17 19:50:10 -08008279 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008280 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008281
8282 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8283 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8284 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8285
8286 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8287 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8288 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8289
8290 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8291 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8292 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8293 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8294 break;
8295
8296 }
8297
8298 /* Execute keep alive request. The reason that we can copy the request information
8299 from the ioctl structure to the SME structure is that they are laid out
8300 exactly the same. Otherwise, each piece of information would have to be
8301 copied individually. */
8302 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8303
Arif Hussain6d2a3322013-11-17 19:50:10 -08008304 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008305
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008306 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008307 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008309 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 __func__);
8311 return -EINVAL;
8312 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308313 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 return 0;
8315}
8316
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308317static int iw_set_keepalive_params(struct net_device *dev,
8318 struct iw_request_info *info,
8319 union iwreq_data *wrqu, char *extra)
8320{
8321 int ret;
8322 vos_ssr_protect(__func__);
8323 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8324 vos_ssr_unprotect(__func__);
8325
8326 return ret;
8327}
8328
Jeff Johnson295189b2012-06-20 16:38:30 -07008329#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008330int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008331 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008332{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008333 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8334 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008335 int i=0;
8336
8337 if (pHddCtx->cfg_ini->disablePacketFilter)
8338 {
8339 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008340 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 return 0;
8342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008343 /* Debug display of request components. */
8344 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008345 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008346
8347 switch (pRequest->filterAction)
8348 {
8349 case HDD_RCV_FILTER_SET:
8350 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008351 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008352
8353 packetFilterSetReq.filterId = pRequest->filterId;
8354 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8355 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008356 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 __func__, pRequest->numParams);
8358 return -EINVAL;
8359 }
8360 packetFilterSetReq.numFieldParams = pRequest->numParams;
8361 packetFilterSetReq.coalesceTime = 0;
8362 packetFilterSetReq.filterType = 1;
8363 for (i=0; i < pRequest->numParams; i++)
8364 {
8365 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8366 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8367 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8368 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8369 packetFilterSetReq.paramsData[i].reserved = 0;
8370
Arif Hussain6d2a3322013-11-17 19:50:10 -08008371 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8373 packetFilterSetReq.filterType);
8374
Arif Hussain6d2a3322013-11-17 19:50:10 -08008375 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008376 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8377
8378 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8379 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8380 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8381 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8382
Arif Hussain6d2a3322013-11-17 19:50:10 -08008383 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008384 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8385 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8386 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8387
Arif Hussain6d2a3322013-11-17 19:50:10 -08008388 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008389 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8390 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8391 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8392 }
8393
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008394 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008395 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008396 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 __func__);
8398 return -EINVAL;
8399 }
8400
8401 break;
8402
8403 case HDD_RCV_FILTER_CLEAR:
8404
Arif Hussain6d2a3322013-11-17 19:50:10 -08008405 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008406 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008407 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008408 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008410 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 __func__);
8412 return -EINVAL;
8413 }
8414 break;
8415
8416 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008417 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008418 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 return -EINVAL;
8420 }
8421 return 0;
8422}
8423
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308424int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8425 tANI_U8 sessionId)
8426{
8427 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8428 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8429
8430 if (NULL == pHddCtx)
8431 {
8432 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8433 return -EINVAL;
8434 }
8435
8436 if (pHddCtx->isLogpInProgress)
8437 {
8438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8439 "%s:LOGP in Progress. Ignore!!!", __func__);
8440 return -EBUSY;
8441 }
8442
8443 if (pHddCtx->cfg_ini->disablePacketFilter)
8444 {
8445 hddLog(VOS_TRACE_LEVEL_ERROR,
8446 "%s: Packet Filtering Disabled. Returning ",
8447 __func__ );
8448 return -EINVAL;
8449 }
8450
8451 switch (filterType)
8452 {
8453 /* For setting IPV6 MC and UC Filter we need to configure
8454 * 2 filters, one for MC and one for UC.
8455 * The Filter ID shouldn't be swapped, which results in making
8456 * UC Filter ineffective.
8457 * We have Hardcode all the values
8458 *
8459 * Reason for a seperate UC filter is because, driver need to
8460 * specify the FW that the specific filter is for unicast
8461 * otherwise FW will not pass the unicast frames by default
8462 * through the filter. This is required to avoid any performance
8463 * hits when no unicast filter is set and only MC/BC are set.
8464 * The way driver informs host is by using the MAC protocol
8465 * layer, CMP flag set to MAX, CMP Data set to 1.
8466 */
8467
8468 case HDD_FILTER_IPV6_MC_UC:
8469 /* Setting IPV6 MC Filter below
8470 */
8471 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8472 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8473 packetFilterSetReq.numFieldParams = 2;
8474 packetFilterSetReq.paramsData[0].protocolLayer =
8475 HDD_FILTER_PROTO_TYPE_MAC;
8476 packetFilterSetReq.paramsData[0].cmpFlag =
8477 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8478 packetFilterSetReq.paramsData[0].dataOffset =
8479 WLAN_HDD_80211_FRM_DA_OFFSET;
8480 packetFilterSetReq.paramsData[0].dataLength = 1;
8481 packetFilterSetReq.paramsData[0].compareData[0] =
8482 HDD_IPV6_MC_CMP_DATA;
8483
8484 packetFilterSetReq.paramsData[1].protocolLayer =
8485 HDD_FILTER_PROTO_TYPE_ARP;
8486 packetFilterSetReq.paramsData[1].cmpFlag =
8487 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8488 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8489 packetFilterSetReq.paramsData[1].dataLength = 2;
8490 packetFilterSetReq.paramsData[1].compareData[0] =
8491 HDD_IPV6_CMP_DATA_0;
8492 packetFilterSetReq.paramsData[1].compareData[1] =
8493 HDD_IPV6_CMP_DATA_1;
8494
8495
8496 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8497 &packetFilterSetReq, sessionId))
8498 {
8499 hddLog(VOS_TRACE_LEVEL_ERROR,
8500 "%s: Failure to execute Set IPv6 Mulicast Filter",
8501 __func__);
8502 return -EINVAL;
8503 }
8504
8505 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8506
8507 /*
8508 * Setting IPV6 UC Filter below
8509 */
8510 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8511 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8512 packetFilterSetReq.numFieldParams = 2;
8513 packetFilterSetReq.paramsData[0].protocolLayer =
8514 HDD_FILTER_PROTO_TYPE_MAC;
8515 packetFilterSetReq.paramsData[0].cmpFlag =
8516 HDD_FILTER_CMP_TYPE_MAX;
8517 packetFilterSetReq.paramsData[0].dataOffset = 0;
8518 packetFilterSetReq.paramsData[0].dataLength = 1;
8519 packetFilterSetReq.paramsData[0].compareData[0] =
8520 HDD_IPV6_UC_CMP_DATA;
8521
8522 packetFilterSetReq.paramsData[1].protocolLayer =
8523 HDD_FILTER_PROTO_TYPE_ARP;
8524 packetFilterSetReq.paramsData[1].cmpFlag =
8525 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8526 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8527 packetFilterSetReq.paramsData[1].dataLength = 2;
8528 packetFilterSetReq.paramsData[1].compareData[0] =
8529 HDD_IPV6_CMP_DATA_0;
8530 packetFilterSetReq.paramsData[1].compareData[1] =
8531 HDD_IPV6_CMP_DATA_1;
8532
8533 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8534 &packetFilterSetReq, sessionId))
8535 {
8536 hddLog(VOS_TRACE_LEVEL_ERROR,
8537 "%s: Failure to execute Set IPv6 Unicast Filter",
8538 __func__);
8539 return -EINVAL;
8540 }
8541
8542 break;
8543
8544 case HDD_FILTER_IPV6_MC:
8545 /*
8546 * IPV6 UC Filter might be already set,
8547 * clear the UC Filter. As the Filter
8548 * IDs are static, we can directly clear it.
8549 */
8550 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8551 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8552 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8553 &packetFilterClrReq, sessionId))
8554 {
8555 hddLog(VOS_TRACE_LEVEL_ERROR,
8556 "%s: Failure to execute Clear IPv6 Unicast Filter",
8557 __func__);
8558 return -EINVAL;
8559 }
8560
8561 /*
8562 * Setting IPV6 MC Filter below
8563 */
8564 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8565 packetFilterSetReq.numFieldParams = 2;
8566 packetFilterSetReq.paramsData[0].protocolLayer =
8567 HDD_FILTER_PROTO_TYPE_MAC;
8568 packetFilterSetReq.paramsData[0].cmpFlag =
8569 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8570 packetFilterSetReq.paramsData[0].dataOffset =
8571 WLAN_HDD_80211_FRM_DA_OFFSET;
8572 packetFilterSetReq.paramsData[0].dataLength = 1;
8573 packetFilterSetReq.paramsData[0].compareData[0] =
8574 HDD_IPV6_MC_CMP_DATA;
8575
8576 packetFilterSetReq.paramsData[1].protocolLayer =
8577 HDD_FILTER_PROTO_TYPE_ARP;
8578 packetFilterSetReq.paramsData[1].cmpFlag =
8579 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8580 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8581 packetFilterSetReq.paramsData[1].dataLength = 2;
8582 packetFilterSetReq.paramsData[1].compareData[0] =
8583 HDD_IPV6_CMP_DATA_0;
8584 packetFilterSetReq.paramsData[1].compareData[1] =
8585 HDD_IPV6_CMP_DATA_1;
8586
8587
8588 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8589 &packetFilterSetReq, sessionId))
8590 {
8591 hddLog(VOS_TRACE_LEVEL_ERROR,
8592 "%s: Failure to execute Set IPv6 Multicast Filter",
8593 __func__);
8594 return -EINVAL;
8595 }
8596 break;
8597
8598 default :
8599 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8600 "%s: Packet Filter Request: Invalid",
8601 __func__);
8602 return -EINVAL;
8603 }
8604 return 0;
8605}
8606
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308607void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008608{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308609 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308610 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008611 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308612 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008613
Yue Ma3ede6052013-08-29 00:33:26 -07008614 if (NULL == pHddCtx)
8615 {
8616 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8617 return;
8618 }
8619
8620 hHal = pHddCtx->hHal;
8621
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308622 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308624 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8625 return;
8626 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308627
8628 /* Check if INI is enabled or not, other wise just return
8629 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308630 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308631 {
8632 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8633 if (NULL == pMulticastAddrs)
8634 {
8635 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8636 return;
8637 }
8638
Jeff Johnson295189b2012-06-20 16:38:30 -07008639 if (set)
8640 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308641 /* Following pre-conditions should be satisfied before wei
8642 * configure the MC address list.
8643 */
8644 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8645 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8646 && pAdapter->mc_addr_list.mc_cnt
8647 && (eConnectionState_Associated ==
8648 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8649 {
8650 pMulticastAddrs->ulMulticastAddrCnt =
8651 pAdapter->mc_addr_list.mc_cnt;
8652 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8653 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008654 memcpy(pMulticastAddrs->multicastAddr[i],
8655 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308656 sizeof(pAdapter->mc_addr_list.addr[i]));
8657 hddLog(VOS_TRACE_LEVEL_INFO,
8658 "%s: %s multicast filter: addr ="
8659 MAC_ADDRESS_STR,
8660 __func__, set ? "setting" : "clearing",
8661 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8662 }
8663 /* Set multicast filter */
8664 sme_8023MulticastList(hHal, pAdapter->sessionId,
8665 pMulticastAddrs);
8666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008667 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308668 else
8669 {
8670 /* Need to clear only if it was previously configured
8671 */
8672 if (pAdapter->mc_addr_list.isFilterApplied)
8673 {
8674 pMulticastAddrs->ulMulticastAddrCnt = 0;
8675 sme_8023MulticastList(hHal, pAdapter->sessionId,
8676 pMulticastAddrs);
8677 }
8678
8679 }
8680 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008681 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308683 else
8684 {
8685 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308686 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308687 }
8688 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008689}
8690
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308691static int __iw_set_packet_filter_params(struct net_device *dev,
8692 struct iw_request_info *info,
8693 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308694{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308695 hdd_adapter_t *pAdapter;
8696 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008697 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308698 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308699 struct iw_point s_priv_data;
8700
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308701 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308702 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8703 if (NULL == pAdapter)
8704 {
8705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8706 "%s: Adapter is NULL",__func__);
8707 return -EINVAL;
8708 }
8709 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8710 ret = wlan_hdd_validate_context(pHddCtx);
8711 if (0 != ret)
8712 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308713 return ret;
8714 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308715 if (hdd_priv_get_data(&s_priv_data, wrqu))
8716 {
8717 return -EINVAL;
8718 }
8719
8720 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8721 {
8722 return -EINVAL;
8723 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008724
Arif Hussain0273cba2014-01-07 20:58:29 -08008725 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308726 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8727 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008728 if (NULL == pRequest)
8729 {
8730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8731 "mem_alloc_copy_from_user_helper fail");
8732 return -ENOMEM;
8733 }
8734
8735 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8736 kfree(pRequest);
8737
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308738 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008739 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008740}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308741
8742static int iw_set_packet_filter_params(struct net_device *dev,
8743 struct iw_request_info *info,
8744 union iwreq_data *wrqu, char *extra)
8745{
8746 int ret;
8747
8748 vos_ssr_protect(__func__);
8749 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8750 vos_ssr_unprotect(__func__);
8751
8752 return ret;
8753}
Jeff Johnson295189b2012-06-20 16:38:30 -07008754#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308755static int __iw_get_statistics(struct net_device *dev,
8756 struct iw_request_info *info,
8757 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008758{
8759
8760 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8761 eHalStatus status = eHAL_STATUS_SUCCESS;
8762 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308763 hdd_adapter_t *pAdapter;
8764 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308766 int tlen = 0, ret = 0;
8767 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008768
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308769 tCsrGlobalClassAStatsInfo *aStats;
8770 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008771
8772 ENTER();
8773
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308774 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8775 if (NULL == pAdapter)
8776 {
8777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8778 "%s: Adapter is NULL",__func__);
8779 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308781 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8782 ret = wlan_hdd_validate_context(pHddCtx);
8783 if (0 != ret)
8784 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308785 return ret;
8786 }
8787 pStats = &(pAdapter->hdd_stats.summary_stat);
8788 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8789 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8791
8792 wrqu->txpower.value = 0;
8793 }
8794 else {
8795 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8796 SME_SUMMARY_STATS |
8797 SME_GLOBAL_CLASSA_STATS |
8798 SME_GLOBAL_CLASSB_STATS |
8799 SME_GLOBAL_CLASSC_STATS |
8800 SME_GLOBAL_CLASSD_STATS |
8801 SME_PER_STA_STATS,
8802 hdd_StatisticsCB, 0, FALSE,
8803 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8804
8805 if (eHAL_STATUS_SUCCESS != status)
8806 {
8807 hddLog(VOS_TRACE_LEVEL_ERROR,
8808 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008809 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 return -EINVAL;
8811 }
8812
8813 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308814 if (NULL == pWextState)
8815 {
8816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8817 "%s: pWextState is NULL",__func__);
8818 return -EINVAL;
8819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008820
8821 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8822 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8823 {
8824 hddLog(VOS_TRACE_LEVEL_ERROR,
8825 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008826 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 /*Remove the SME statistics list by passing NULL in callback argument*/
8828 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8829 SME_SUMMARY_STATS |
8830 SME_GLOBAL_CLASSA_STATS |
8831 SME_GLOBAL_CLASSB_STATS |
8832 SME_GLOBAL_CLASSC_STATS |
8833 SME_GLOBAL_CLASSD_STATS |
8834 SME_PER_STA_STATS,
8835 NULL, 0, FALSE,
8836 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8837
8838 return -EINVAL;
8839 }
8840 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8841 (tANI_U8) sizeof (pStats->retry_cnt),
8842 (char*) &(pStats->retry_cnt[0]),
8843 tlen);
8844
8845 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8846 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8847 (char*) &(pStats->multiple_retry_cnt[0]),
8848 tlen);
8849
8850 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8851 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8852 (char*) &(pStats->tx_frm_cnt[0]),
8853 tlen);
8854
8855 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8856 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8857 (char*) &(pStats->rx_frm_cnt),
8858 tlen);
8859
8860 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8861 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8862 (char*) &(pStats->frm_dup_cnt),
8863 tlen);
8864
8865 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8866 (tANI_U8) sizeof (pStats->fail_cnt),
8867 (char*) &(pStats->fail_cnt[0]),
8868 tlen);
8869
8870 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8871 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8872 (char*) &(pStats->rts_fail_cnt),
8873 tlen);
8874
8875 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8876 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8877 (char*) &(pStats->ack_fail_cnt),
8878 tlen);
8879
8880 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8881 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8882 (char*) &(pStats->rts_succ_cnt),
8883 tlen);
8884
8885 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8886 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8887 (char*) &(pStats->rx_discard_cnt),
8888 tlen);
8889
8890 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8891 (tANI_U8) sizeof (pStats->rx_error_cnt),
8892 (char*) &(pStats->rx_error_cnt),
8893 tlen);
8894
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008895 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008896 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008897 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008898 tlen);
8899
8900 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8901 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8902 (char*) &(dStats->rx_byte_cnt),
8903 tlen);
8904
8905 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8906 (tANI_U8) sizeof (dStats->rx_rate),
8907 (char*) &(dStats->rx_rate),
8908 tlen);
8909
8910 /* Transmit rate, in units of 500 kbit/sec */
8911 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8912 (tANI_U8) sizeof (aStats->tx_rate),
8913 (char*) &(aStats->tx_rate),
8914 tlen);
8915
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008916 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8917 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8918 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008919 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008920 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8921 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8922 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008923 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008924 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8925 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8926 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008927 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008928 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8929 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8930 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008931 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008932 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8933 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8934 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008935 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008936 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8937 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8938 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008939 tlen);
8940
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 wrqu->data.length = tlen;
8942
8943 }
8944
8945 EXIT();
8946
8947 return 0;
8948}
8949
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308950static int iw_get_statistics(struct net_device *dev,
8951 struct iw_request_info *info,
8952 union iwreq_data *wrqu, char *extra)
8953{
8954 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008955
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308956 vos_ssr_protect(__func__);
8957 ret = __iw_get_statistics(dev, info, wrqu, extra);
8958 vos_ssr_unprotect(__func__);
8959
8960 return ret;
8961}
Jeff Johnson295189b2012-06-20 16:38:30 -07008962#ifdef FEATURE_WLAN_SCAN_PNO
8963
8964/*Max Len for PNO notification*/
8965#define MAX_PNO_NOTIFY_LEN 100
8966void found_pref_network_cb (void *callbackContext,
8967 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8968{
8969 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8970 union iwreq_data wrqu;
8971 char buf[MAX_PNO_NOTIFY_LEN+1];
8972
8973 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8974 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8975
8976 // create the event
8977 memset(&wrqu, 0, sizeof(wrqu));
8978 memset(buf, 0, sizeof(buf));
8979
8980 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8981 pPrefNetworkFoundInd->ssId.ssId,
8982 (unsigned int)pPrefNetworkFoundInd->rssi);
8983
8984 wrqu.data.pointer = buf;
8985 wrqu.data.length = strlen(buf);
8986
8987 // send the event
8988
8989 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8990
8991}
8992
8993
8994/*string based input*/
8995VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8996 union iwreq_data *wrqu, char *extra, int nOffset)
8997{
8998 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308999 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009000 /* pnoRequest is a large struct, so we make it static to avoid stack
9001 overflow. This API is only invoked via ioctl, so it is
9002 serialized by the kernel rtnl_lock and hence does not need to be
9003 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309004 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 char *ptr;
9006 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309007 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9009
9010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9011 "PNO data len %d data %s",
9012 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009013 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009014
9015 if (wrqu->data.length <= nOffset )
9016 {
9017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9018 return VOS_STATUS_E_FAILURE;
9019 }
9020
9021 pnoRequest.enable = 0;
9022 pnoRequest.ucNetworksCount = 0;
9023 /*-----------------------------------------------------------------------
9024 Input is string based and expected to be like this:
9025
9026 <enabled> <netw_count>
9027 for each network:
9028 <ssid_len> <ssid> <authentication> <encryption>
9029 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9030 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9031
9032 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009033 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 -07009034
9035 this translates into:
9036 -----------------------------
9037 enable PNO
9038 look for 2 networks:
9039 test - with authentication type 0 and encryption type 0,
9040 that can be found on 3 channels: 1 6 and 11 ,
9041 SSID bcast type is unknown (directed probe will be sent if AP not found)
9042 and must meet -40dBm RSSI
9043
9044 test2 - with auth and enrytption type 4/4
9045 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9046 bcast type is non-bcast (directed probe will be sent)
9047 and must not meet any RSSI threshold
9048
Jeff Johnson8301aa12013-03-28 14:27:29 -07009049 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009051 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009052
Wilson Yang623f6592013-10-08 16:33:37 -07009053 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9054 {
9055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9056 "PNO enable input is not valid %s",ptr);
9057 return VOS_STATUS_E_FAILURE;
9058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009059
9060 if ( 0 == pnoRequest.enable )
9061 {
9062 /*Disable PNO*/
9063 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309064 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9065 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009066 pAdapter->sessionId,
9067 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309068 if (eHAL_STATUS_SUCCESS != status)
9069 {
9070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9071 "%s: failed to disable PNO", __func__);
9072 return VOS_STATUS_E_FAILURE;
9073 }
9074 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009075 return VOS_STATUS_SUCCESS;
9076 }
9077
c_hpothu37f21312014-04-09 21:49:54 +05309078 if (TRUE == pHddCtx->isPnoEnable)
9079 {
9080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9081 FL("already PNO is enabled"));
9082 return -EBUSY;
9083 }
9084 pHddCtx->isPnoEnable = TRUE;
9085
Jeff Johnson295189b2012-06-20 16:38:30 -07009086 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009087
9088 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9089 {
9090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9091 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309092 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009094
9095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9096 "PNO enable %d networks count %d offset %d",
9097 pnoRequest.enable,
9098 pnoRequest.ucNetworksCount,
9099 nOffset);
9100
9101 /* Parameters checking:
9102 ucNetworksCount has to be larger than 0*/
9103 if (( 0 == pnoRequest.ucNetworksCount ) ||
9104 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9105 {
9106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309107 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009108 }
9109
9110 ptr += nOffset;
9111
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309112 pnoRequest.aNetworks =
9113 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9114 if (pnoRequest.aNetworks == NULL)
9115 {
9116 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9117 FL("failed to allocate memory aNetworks %u"),
9118 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9119 goto error;
9120 }
9121 vos_mem_zero(pnoRequest.aNetworks,
9122 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9123
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9125 {
9126
9127 pnoRequest.aNetworks[i].ssId.length = 0;
9128
Wilson Yang623f6592013-10-08 16:33:37 -07009129 ucParams = sscanf(ptr,"%hhu %n",
9130 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9131
9132 if (1 != ucParams)
9133 {
9134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9135 "PNO ssid length input is not valid %s",ptr);
9136 return VOS_STATUS_E_FAILURE;
9137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009138
9139 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9140 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9141 {
9142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9143 "SSID Len %d is not correct for network %d",
9144 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309145 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 }
9147
9148 /*Advance to SSID*/
9149 ptr += nOffset;
9150
Jeff Johnson8301aa12013-03-28 14:27:29 -07009151 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009152 pnoRequest.aNetworks[i].ssId.length);
9153 ptr += pnoRequest.aNetworks[i].ssId.length;
9154
Jeff Johnson02797792013-10-26 19:17:13 -07009155 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009156 &(pnoRequest.aNetworks[i].authentication),
9157 &(pnoRequest.aNetworks[i].encryption),
9158 &(pnoRequest.aNetworks[i].ucChannelCount),
9159 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009160
Wilson Yang623f6592013-10-08 16:33:37 -07009161 if ( 3 != ucParams )
9162 {
9163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9164 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309165 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009166 }
9167
Jeff Johnson295189b2012-06-20 16:38:30 -07009168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009169 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009170 "auth %d encry %d channel count %d offset %d",
9171 pnoRequest.aNetworks[i].ssId.length,
9172 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9173 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9174 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9175 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9176 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9177 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9178 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9179 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9180 pnoRequest.aNetworks[i].authentication,
9181 pnoRequest.aNetworks[i].encryption,
9182 pnoRequest.aNetworks[i].ucChannelCount,
9183 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009184
Jeff Johnson295189b2012-06-20 16:38:30 -07009185 /*Advance to channel list*/
9186 ptr += nOffset;
9187
Wilson Yang623f6592013-10-08 16:33:37 -07009188 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 {
9190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9191 "Incorrect number of channels");
9192 return VOS_STATUS_E_FAILURE;
9193 }
9194
9195 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9196 {
9197 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9198 {
Wilson Yang623f6592013-10-08 16:33:37 -07009199 if (1 != sscanf(ptr,"%hhu %n",
9200 &(pnoRequest.aNetworks[i].aChannels[j]),
9201 &nOffset))
9202 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9203 "PNO network channel input is not valid %s",ptr);
9204 return VOS_STATUS_E_FAILURE;
9205 }
9206 /*Advance to next channel number*/
9207 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009208 }
9209 }
9210
Jeff Johnson02797792013-10-26 19:17:13 -07009211 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009212 &(pnoRequest.aNetworks[i].bcastNetwType),
9213 &nOffset))
9214 {
9215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9216 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309217 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009219
9220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9221 "PNO bcastNetwType %d offset %d",
9222 pnoRequest.aNetworks[i].bcastNetwType,
9223 nOffset );
9224
9225 /*Advance to rssi Threshold*/
9226 ptr += nOffset;
9227
Wilson Yang623f6592013-10-08 16:33:37 -07009228 if (1 != sscanf(ptr,"%hhu %n",
9229 &(pnoRequest.aNetworks[i].rssiThreshold),
9230 &nOffset))
9231 {
9232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9233 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309234 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009236
9237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9238 "PNO rssi %d offset %d",
9239 pnoRequest.aNetworks[i].rssiThreshold,
9240 nOffset );
9241 /*Advance to next network*/
9242 ptr += nOffset;
9243 }/*For ucNetworkCount*/
9244
9245 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009246 &(pnoRequest.scanTimers.ucScanTimersCount),
9247 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009248
9249 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009250 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 {
9252 ptr += nOffset;
9253
Jeff Johnson8301aa12013-03-28 14:27:29 -07009254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9255 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009256 pnoRequest.scanTimers.ucScanTimersCount,
9257 nOffset );
9258
9259 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9260 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309263 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 }
9265
9266 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9267 {
Jeff Johnson02797792013-10-26 19:17:13 -07009268 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9270 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9271 &nOffset);
9272
Wilson Yang623f6592013-10-08 16:33:37 -07009273 if (2 != ucParams)
9274 {
9275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9276 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309277 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009278 }
9279
Jeff Johnson8301aa12013-03-28 14:27:29 -07009280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9281 "PNO Timer value %d Timer repeat %d offset %d",
9282 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009283 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9284 nOffset );
9285
Jeff Johnson295189b2012-06-20 16:38:30 -07009286 ptr += nOffset;
9287 }
9288
9289 }
9290 else
9291 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9293 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009294 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9295
9296 /*Scan timers defaults to 5 minutes*/
9297 pnoRequest.scanTimers.ucScanTimersCount = 1;
9298 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9299 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9300 }
9301
Wilson Yang623f6592013-10-08 16:33:37 -07009302 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009303
9304 pnoRequest.modePNO = ucMode;
9305 /*for LA we just expose suspend option*/
9306 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9307 {
9308 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9309 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309310 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9311 if (pnoRequest.p24GProbeTemplate == NULL){
9312 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9313 FL("failed to allocate memory p24GProbeTemplate %u"),
9314 SIR_PNO_MAX_PB_REQ_SIZE);
9315 goto error;
9316 }
9317
9318 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9319 if (pnoRequest.p5GProbeTemplate == NULL){
9320 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9321 FL("failed to allocate memory p5GProbeTemplate %u"),
9322 SIR_PNO_MAX_PB_REQ_SIZE);
9323 goto error;
9324 }
9325
9326 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9327 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009328
c_hpothu37f21312014-04-09 21:49:54 +05309329 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009330 pAdapter->sessionId,
9331 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309332 if (eHAL_STATUS_SUCCESS == status)
9333 {
9334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9335 "%s: PNO enabled", __func__);
9336 return VOS_STATUS_SUCCESS;
9337 }
9338error:
9339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9340 "%s: Failed to enable PNO", __func__);
9341 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309342 if (pnoRequest.aNetworks)
9343 vos_mem_free(pnoRequest.aNetworks);
9344 if (pnoRequest.p24GProbeTemplate)
9345 vos_mem_free(pnoRequest.p24GProbeTemplate);
9346 if (pnoRequest.p5GProbeTemplate)
9347 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309348 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009349}/*iw_set_pno*/
9350
9351VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9352 union iwreq_data *wrqu, char *extra, int nOffset)
9353{
9354 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9355 v_U8_t rssiThreshold = 0;
9356 v_U8_t nRead;
9357
Arif Hussain7adce1b2013-11-11 22:59:34 -08009358 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009359 &rssiThreshold);
9360
9361 if ( 1 != nRead )
9362 {
9363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9364 "Incorrect format");
9365 return VOS_STATUS_E_FAILURE;
9366 }
9367
9368 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9369 return VOS_STATUS_SUCCESS;
9370}
9371
9372
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309373static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009374 struct iw_request_info *info,
9375 union iwreq_data *wrqu, char *extra)
9376{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309377 hdd_adapter_t *pAdapter;
9378 hdd_context_t *pHddCtx;
9379 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309380 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309381
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309382 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309383 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9384 if (NULL == pAdapter)
9385 {
9386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9387 "%s: Adapter is NULL",__func__);
9388 return -EINVAL;
9389 }
9390
9391 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9392 ret = wlan_hdd_validate_context(pHddCtx);
9393 if (0 != ret)
9394 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309395 return ret;
9396 }
9397
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009398
9399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009401
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309402 status = iw_set_pno(dev,info,wrqu,extra,0);
9403
9404 EXIT();
9405 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009406}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309407
9408static int iw_set_pno_priv(struct net_device *dev,
9409 struct iw_request_info *info,
9410 union iwreq_data *wrqu, char *extra)
9411{
9412 int ret;
9413
9414 vos_ssr_protect(__func__);
9415 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9416 vos_ssr_unprotect(__func__);
9417
9418 return ret;
9419}
Jeff Johnson295189b2012-06-20 16:38:30 -07009420#endif /*FEATURE_WLAN_SCAN_PNO*/
9421
9422//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309423int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009424{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309425 hdd_adapter_t *pAdapter;
9426 tHalHandle hHal;
9427 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309428 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309429 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309430 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309432 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309433 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309434 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309435
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309436 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309437 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9438 if (NULL == pAdapter)
9439 {
9440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9441 "%s: Adapter is NULL",__func__);
9442 return -EINVAL;
9443 }
9444 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9445 retval = wlan_hdd_validate_context(pHddCtx);
9446 if (0 != retval)
9447 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309448 return retval;
9449 }
9450 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9451 if (NULL == hHal)
9452 {
9453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9454 "%s: Hal Context is NULL",__func__);
9455 return -EINVAL;
9456 }
9457 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009458
Atul Mittal54378cb2014-04-02 16:51:50 +05309459 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 {
9461 case WLAN_HDD_UI_BAND_AUTO:
9462 band = eCSR_BAND_ALL;
9463 break;
9464 case WLAN_HDD_UI_BAND_5_GHZ:
9465 band = eCSR_BAND_5G;
9466 break;
9467 case WLAN_HDD_UI_BAND_2_4_GHZ:
9468 band = eCSR_BAND_24;
9469 break;
9470 default:
9471 band = eCSR_BAND_MAX;
9472 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309473 connectedBand =
9474 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009475
Atul Mittal54378cb2014-04-02 16:51:50 +05309476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009477 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009478
9479 if (band == eCSR_BAND_MAX)
9480 {
9481 /* Received change band request with invalid band value */
9482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309483 "%s: Invalid band value %u", __func__, ui_band);
9484 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 }
9486
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309487 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309488 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309489 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009491 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009492 band, pHddCtx->cfg_ini->nBandCapability);
9493 return -EIO;
9494 }
9495
Sushant Kaushik1165f872015-03-30 20:25:27 +05309496 if (band == eCSR_BAND_ALL)
9497 {
9498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9499 "received. Setting band same as ini value %d"),
9500 pHddCtx->cfg_ini->nBandCapability);
9501 band = pHddCtx->cfg_ini->nBandCapability;
9502 }
9503
Jeff Johnson295189b2012-06-20 16:38:30 -07009504 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9505 {
9506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9507 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009508 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009509 return -EIO;
9510 }
9511
9512 if (currBand != band)
9513 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309514 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309515 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309516 /* Return failure if current country code is world regulatory domain*/
9517 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9518 pMac->scan.countryCodeCurrent[1] == '0') )
9519 {
9520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9521 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309522 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309523 return -EAGAIN;
9524 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309525 }
9526
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 /* Change band request received.
9528 * Abort pending scan requests, flush the existing scan results,
9529 * and change the band capability
9530 */
9531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9532 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009533 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009534
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309535 /* We need to change the band and flush the scan results here itself
9536 * as we may get timeout for disconnection in which we will return
9537 * with out doing any of these
9538 */
9539 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9540 {
9541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9542 "%s: failed to set the band value to %u ",
9543 __func__, band);
9544 return -EINVAL;
9545 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309546 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9547 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309548 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309549 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9550 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309551 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309552 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9553 * information available in NV so to get the channel information from kernel
9554 * we need to send regulatory hint for the currunt country
9555 * And to set the same country again we need to set the dummy country
9556 * first and then the actual country.
9557 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309558#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9559 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9560#else
9561 regulatory_hint_user("00");
9562#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309563 wait_result = wait_for_completion_interruptible_timeout(
9564 &pHddCtx->linux_reg_req,
9565 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9566
9567 /* if the country information does not exist with the kernel,
9568 then the driver callback would not be called */
9569
9570 if (wait_result >= 0)
9571 {
9572 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9573 "runtime country code is found in kernel db");
9574 }
9575 else
9576 {
9577 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9578 "runtime country code is not found"
9579 " in kernel db");
9580 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309581
9582 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309583
9584 /*
9585 * Update 11dcountry and current country here as the hint
9586 * with 00 results in 11d and current country with 00
9587 */
9588 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9589 WNI_CFG_COUNTRY_CODE_LEN);
9590 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9591 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309592#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9593 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9594#else
9595 regulatory_hint_user(curr_country);
9596#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309597 wait_result = wait_for_completion_interruptible_timeout(
9598 &pHddCtx->linux_reg_req,
9599 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9600
9601 /* if the country information does not exist with the kernel,
9602 then the driver callback would not be called */
9603 if (wait_result >= 0)
9604 {
9605 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9606 "runtime country code is found in kernel db");
9607 }
9608 else
9609 {
9610 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9611 "runtime country code is not found"
9612 " in kernel db");
9613 }
9614
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309615 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309616 }
9617 else
9618 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309619#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309620 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9621 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309622#else
9623 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9624#endif
9625
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309626 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309627 pScanInfo = &pHddCtx->scan_info;
9628 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9629 {
9630 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9631 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9632 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309633 sme_FilterScanResults(hHal, pAdapter->sessionId);
9634
9635 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309636 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9637 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009638 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 eHalStatus status = eHAL_STATUS_SUCCESS;
9640 long lrc;
9641
9642 /* STA already connected on current band, So issue disconnect first,
9643 * then change the band*/
9644
9645 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309646 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309647 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009648
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9650
9651 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9652 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9653
Jeff Johnson43971f52012-07-17 12:26:56 -07009654 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009655 {
9656 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009657 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 __func__, (int)status );
9659 return -EINVAL;
9660 }
9661
9662 lrc = wait_for_completion_interruptible_timeout(
9663 &pAdapter->disconnect_comp_var,
9664 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9665
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309666 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009667
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009668 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009669 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009670
9671 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9672 }
9673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009674 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309675 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309676 if (TRUE == pHddCtx->isSetBandByNL)
9677 return 0;
9678 else
9679 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07009680}
9681
Atul Mittal54378cb2014-04-02 16:51:50 +05309682int hdd_setBand_helper(struct net_device *dev, const char *command)
9683{
9684 u8 band;
9685
9686 /*convert the band value from ascii to integer*/
9687 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9688
9689 return hdd_setBand(dev, band);
9690
9691}
9692
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309693static int __iw_set_band_config(struct net_device *dev,
9694 struct iw_request_info *info,
9695 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009696{
Atul Mittal54378cb2014-04-02 16:51:50 +05309697 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009698
Arif Hussain0273cba2014-01-07 20:58:29 -08009699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009700
Atul Mittal54378cb2014-04-02 16:51:50 +05309701 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009702}
9703
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309704static int iw_set_band_config(struct net_device *dev,
9705 struct iw_request_info *info,
9706 union iwreq_data *wrqu, char *extra)
9707{
9708 int ret;
9709
9710 vos_ssr_protect(__func__);
9711 ret = __iw_set_band_config(dev, info, wrqu, extra);
9712 vos_ssr_unprotect(__func__);
9713
9714 return ret;
9715}
9716
9717static int __iw_set_power_params_priv(struct net_device *dev,
9718 struct iw_request_info *info,
9719 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009720{
Arif Hussain0273cba2014-01-07 20:58:29 -08009721 int ret;
9722 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9724 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009725 /* ODD number is used for set, copy data using copy_from_user */
9726 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9727 wrqu->data.length);
9728 if (NULL == ptr)
9729 {
9730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9731 "mem_alloc_copy_from_user_helper fail");
9732 return -ENOMEM;
9733 }
9734
9735 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9736 kfree(ptr);
9737 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009738}
9739
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309740static int iw_set_power_params_priv(struct net_device *dev,
9741 struct iw_request_info *info,
9742 union iwreq_data *wrqu, char *extra)
9743{
9744 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009745
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309746 vos_ssr_protect(__func__);
9747 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9748 vos_ssr_unprotect(__func__);
9749
9750 return ret;
9751}
Jeff Johnson295189b2012-06-20 16:38:30 -07009752
9753/*string based input*/
9754VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9755 union iwreq_data *wrqu, char *extra, int nOffset)
9756{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309757 hdd_adapter_t *pAdapter;
9758 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009759 tSirSetPowerParamsReq powerRequest;
9760 char *ptr;
9761 v_U8_t ucType;
9762 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309763 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009764
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309765 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309766 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9767 if (NULL == pAdapter)
9768 {
9769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9770 "%s: Adapter is NULL",__func__);
9771 return -EINVAL;
9772 }
9773
9774 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9775 ret = wlan_hdd_validate_context(pHddCtx);
9776 if (0 != ret)
9777 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309778 return ret;
9779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9781 "Power Params data len %d data %s",
9782 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009783 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009784
9785 if (wrqu->data.length <= nOffset )
9786 {
9787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9788 return VOS_STATUS_E_FAILURE;
9789 }
9790
9791 uTotalSize = wrqu->data.length - nOffset;
9792
9793 /*-----------------------------------------------------------------------
9794 Input is string based and expected to be like this:
9795
9796 <param_type> <param_value> <param_type> <param_value> ...
9797
9798 e.g:
9799 1 2 2 3 3 0 4 1 5 1
9800
9801 e.g. setting just a few:
9802 1 2 4 1
9803
9804 parameter types:
9805 -----------------------------
9806 1 - Ignore DTIM
9807 2 - Listen Interval
9808 3 - Broadcast Multicas Filter
9809 4 - Beacon Early Termination
9810 5 - Beacon Early Termination Interval
9811 -----------------------------------------------------------------------*/
9812 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9813 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9814 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9815 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9816 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9817
Arif Hussain7adce1b2013-11-11 22:59:34 -08009818 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009819
9820 while ( uTotalSize )
9821 {
Wilson Yang6f971452013-10-08 15:00:00 -07009822 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9823 {
9824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9825 "Invalid input parameter type %s",ptr);
9826 return VOS_STATUS_E_FAILURE;
9827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009828
9829 uTotalSize -= nOffset;
9830
9831 if (!uTotalSize)
9832 {
9833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009834 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009835 ucType, nOffset);
9836 return VOS_STATUS_E_FAILURE;
9837 }
9838
9839 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009840
Jeff Johnson02797792013-10-26 19:17:13 -07009841 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009842 {
9843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9844 "Invalid input parameter value %s",ptr);
9845 return VOS_STATUS_E_FAILURE;
9846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009847
9848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9849 "Power request parameter %d value %d offset %d",
9850 ucType, uValue, nOffset);
9851
9852 switch (ucType)
9853 {
9854 case eSIR_IGNORE_DTIM:
9855 powerRequest.uIgnoreDTIM = uValue;
9856 break;
9857 case eSIR_LISTEN_INTERVAL:
9858 powerRequest.uListenInterval = uValue;
9859 break;
9860 case eSIR_MCAST_BCAST_FILTER:
9861 powerRequest.uBcastMcastFilter = uValue;
9862 break;
9863 case eSIR_ENABLE_BET:
9864 powerRequest.uEnableBET = uValue;
9865 break;
9866 case eSIR_BET_INTERVAL:
9867 powerRequest.uBETInterval = uValue;
9868 break;
9869 default:
9870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009871 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009872 ucType, uValue, nOffset);
9873 return VOS_STATUS_E_FAILURE;
9874 }
9875
9876 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9878 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009879 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009880 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009881 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009882 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009883 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9884 {
9885 uTotalSize = 0;
9886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009887
9888 }/*Go for as long as we have a valid string*/
9889
9890 /* put the device into full power*/
9891 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9892
9893 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009894 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009895
9896 /* put the device back to power save*/
9897 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9898
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309899 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009900 return VOS_STATUS_SUCCESS;
9901}/*iw_set_power_params*/
9902
Atul Mittalc0f739f2014-07-31 13:47:47 +05309903// tdlsoffchan
9904#ifdef FEATURE_WLAN_TDLS
9905
Atul Mittal87ec2422014-09-24 13:12:50 +05309906int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309907{
9908 if (offchannel < 0 || offchannel > 165)
9909 {
9910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9911 __func__, offchannel);
9912 return -1;
9913
9914 }
9915
9916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9917 __func__, tdlsOffCh, offchannel);
9918
9919 tdlsOffCh = offchannel;
9920 return 0;
9921}
9922
Atul Mittal87ec2422014-09-24 13:12:50 +05309923int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309924{
9925 if (offchanoffset == 0)
9926 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309927 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9929 __func__, tdlsOffChBwOffset);
9930
9931 return 0;
9932
9933 }
9934
9935 if ( offchanoffset == 40 )
9936 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309937 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9939 __func__, tdlsOffChBwOffset);
9940
9941 return 0;
9942
9943 }
9944 if (offchanoffset == -40)
9945 {
9946 tdlsOffChBwOffset = 3;
9947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9948 __func__, tdlsOffChBwOffset);
9949
9950 return 0;
9951
9952 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +05309953
9954 if ((offchanoffset == 80) &&
9955 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
9956 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
9957 {
9958 tdlsOffChBwOffset = 4;
9959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9960 "%s: change tdls secondary off channel offset to %u",
9961 __func__, tdlsOffChBwOffset);
9962
9963 return 0;
9964 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05309965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9966 __func__, offchanoffset);
9967 return -1;
9968}
9969
Atul Mittal87ec2422014-09-24 13:12:50 +05309970int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309971{
9972 hddTdlsPeer_t *connPeer = NULL;
9973 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9974 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9975
9976 if (offchanmode < 0 || offchanmode > 4)
9977 {
9978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9979 "%s: Invalid tdls off channel mode %d",
9980 __func__, offchanmode);
9981 return -1;
9982 }
9983
9984 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9985 {
9986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9987 "%s: tdls off channel mode req in not associated state %d",
9988 __func__, offchanmode);
9989 return -1;
9990 }
9991
9992 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9993 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9994 {
9995 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309996 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309997 if (NULL == connPeer) {
9998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9999 "%s: No TDLS Connected Peer", __func__);
10000 return -1;
10001 }
10002 }
10003 else
10004 {
10005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10006 "%s: TDLS Connection not supported", __func__);
10007 return -1;
10008 }
10009
10010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10011 ("%s: TDLS Channel Switch in swmode=%d"),
10012 __func__, offchanmode);
10013
10014 switch (offchanmode)
10015 {
10016 case 1:/*Enable*/
10017 case 2:/*Disable*/
10018 {
10019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10020 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10021 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10022 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10023 {
10024
10025 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
10026 pAdapter->sessionId, connPeer->peerMac,
10027 tdlsOffCh, tdlsOffChBwOffset,
10028 offchanmode);
10029 }
10030 else
10031 {
10032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10033 "%s: TDLS Off Channel not supported", __func__);
10034 return -1;
10035 }
10036 break;
10037 }
10038 case 3:
10039 {
10040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10041 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10042 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10043
10044 break;
10045 }
10046 case 4:
10047 {
10048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10049 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10050 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10051 break;
10052 }
10053 default:
10054 {
10055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10056 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10057 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10058 break;
10059 }
10060
10061 }
10062
10063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10064 __func__, offchanmode);
10065 return 0;
10066}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010067#endif
10068
Jeff Johnson295189b2012-06-20 16:38:30 -070010069
10070// Define the Wireless Extensions to the Linux Network Device structure
10071// A number of these routines are NULL (meaning they are not implemented.)
10072
10073static const iw_handler we_handler[] =
10074{
10075 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10076 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10077 (iw_handler) NULL, /* SIOCSIWNWID */
10078 (iw_handler) NULL, /* SIOCGIWNWID */
10079 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10080 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10081 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10082 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10083 (iw_handler) NULL, /* SIOCSIWSENS */
10084 (iw_handler) NULL, /* SIOCGIWSENS */
10085 (iw_handler) NULL, /* SIOCSIWRANGE */
10086 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10087 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
10088 (iw_handler) NULL, /* SIOCGIWPRIV */
10089 (iw_handler) NULL, /* SIOCSIWSTATS */
10090 (iw_handler) NULL, /* SIOCGIWSTATS */
10091 iw_handler_set_spy, /* SIOCSIWSPY */
10092 iw_handler_get_spy, /* SIOCGIWSPY */
10093 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10094 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10095 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10096 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10097 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10098 (iw_handler) NULL, /* SIOCGIWAPLIST */
10099 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10100 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10101 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10102 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10103 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10104 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10105 (iw_handler) NULL, /* -- hole -- */
10106 (iw_handler) NULL, /* -- hole -- */
10107 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10108 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10109 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10110 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10111 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10112 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10113 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10114 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10115 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10116 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10117 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10118 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10119 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10120 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10121 (iw_handler) NULL, /* -- hole -- */
10122 (iw_handler) NULL, /* -- hole -- */
10123 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10124 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10125 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10126 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10127 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10128 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10129 (iw_handler) NULL, /* SIOCSIWPMKSA */
10130};
10131
10132static const iw_handler we_private[] = {
10133
10134 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10135 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10136 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10137 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10138 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10139 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010140 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010141 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10142 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10143 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010144#ifdef FEATURE_OEM_DATA_SUPPORT
10145 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10146 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10147#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010148
Jeff Johnson295189b2012-06-20 16:38:30 -070010149#ifdef WLAN_FEATURE_VOWIFI_11R
10150 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10151#endif
10152 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10153 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10154 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10155#ifdef WLAN_FEATURE_PACKET_FILTERING
10156 ,
10157 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10158#endif
10159#ifdef FEATURE_WLAN_SCAN_PNO
10160 ,
10161 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10162#endif
10163 ,
10164 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10165 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10166 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10167 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010168 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010169};
10170
10171/*Maximum command length can be only 15 */
10172static const struct iw_priv_args we_private_args[] = {
10173
Katya Nigamf0511f62015-05-05 16:40:57 +053010174 { WE_SET_MONITOR_STATE,
10175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10176 0, "monitor" },
10177
Jeff Johnson295189b2012-06-20 16:38:30 -070010178 /* handlers for main ioctl */
10179 { WLAN_PRIV_SET_INT_GET_NONE,
10180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10181 0,
10182 "" },
10183
10184 /* handlers for sub-ioctl */
10185 { WE_SET_11D_STATE,
10186 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10187 0,
10188 "set11Dstate" },
10189
10190 { WE_WOWL,
10191 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10192 0,
10193 "wowl" },
10194
10195 { WE_SET_POWER,
10196 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10197 0,
10198 "setPower" },
10199
10200 { WE_SET_MAX_ASSOC,
10201 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10202 0,
10203 "setMaxAssoc" },
10204
10205 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10206 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10207 0,
10208 "setAutoChannel" },
10209
10210 { WE_SET_DATA_INACTIVITY_TO,
10211 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10212 0,
10213 "inactivityTO" },
10214
10215 { WE_SET_MAX_TX_POWER,
10216 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10217 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010218 "setMaxTxPower" },
10219
10220 { WE_SET_MAX_TX_POWER_2_4,
10221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10222 0,
10223 "setTxMaxPower2G" },
10224
10225 { WE_SET_MAX_TX_POWER_5_0,
10226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10227 0,
10228 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010229
10230 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10231 * as well to keep same syntax as in SAP. Now onwards, STA
10232 * will support both */
10233 { WE_SET_MAX_TX_POWER,
10234 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10235 0,
10236 "setTxMaxPower" },
10237
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10239 * 1 = enable and 0 = disable */
10240 {
10241 WE_SET_HIGHER_DTIM_TRANSITION,
10242 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10243 0,
10244 "setHDtimTransn" },
10245
10246 { WE_SET_TM_LEVEL,
10247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010248 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010249 "setTmLevel" },
10250
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010251 { WE_ENABLE_STRICT_FCC_REG,
10252 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10253 0,
10254 "setStrictFCCreg" },
10255
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010256 { WE_SET_DEBUG_LOG,
10257 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10258 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010259#ifdef FEATURE_WLAN_TDLS
10260 {
10261 WE_SET_TDLS_OFF_CHAN,
10262 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10263 0,
10264 "tdlsoffchan" },
10265 {
10266 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10268 0,
10269 "tdlsecchnoffst" },
10270 {
10271 WE_SET_TDLS_OFF_CHAN_MODE,
10272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10273 0,
10274 "tdlsoffchnmode" },
10275#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010276
Peng Xu2446a892014-09-05 17:21:18 +053010277 { WE_SET_SCAN_BAND_PREFERENCE,
10278 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10279 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010280 {
10281 WE_GET_FRAME_LOG,
10282 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10283 0,
10284 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010285
Abhishek Singh01c73d12015-03-12 15:13:44 +053010286 { WE_SET_MIRACAST_VENDOR_CONFIG,
10287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10288 0, "setMiracstConf" },
10289
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010290#ifdef FEATURE_WLAN_TDLS
10291 {
10292 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10293 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10294 0,
10295 "tdls_2040bsscox" },
10296#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010297 { WE_SET_RTS_CTS_HTVHT,
10298 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10299 0, "setRtsCtsHtVht" },
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010300
Jeff Johnson295189b2012-06-20 16:38:30 -070010301 /* handlers for main ioctl */
10302 { WLAN_PRIV_SET_NONE_GET_INT,
10303 0,
10304 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10305 "" },
10306
10307 /* handlers for sub-ioctl */
10308 { WE_GET_11D_STATE,
10309 0,
10310 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10311 "get11Dstate" },
10312
10313 { WE_IBSS_STATUS,
10314 0,
10315 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10316 "getAdhocStatus" },
10317
10318 { WE_PMC_STATE,
10319 0,
10320 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10321 "pmcState" },
10322
10323 { WE_GET_WLAN_DBG,
10324 0,
10325 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10326 "getwlandbg" },
10327
Jeff Johnson295189b2012-06-20 16:38:30 -070010328 { WE_GET_MAX_ASSOC,
10329 0,
10330 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10331 "getMaxAssoc" },
10332
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 { WE_GET_WDI_DBG,
10334 0,
10335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10336 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010337
10338 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10339 0,
10340 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10341 "getAutoChannel" },
10342
10343 { WE_GET_CONCURRENCY_MODE,
10344 0,
10345 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10346 "getconcurrency" },
10347
Peng Xu2446a892014-09-05 17:21:18 +053010348 { WE_GET_SCAN_BAND_PREFERENCE,
10349 0,
10350 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10351 "get_scan_pref"},
10352
Jeff Johnson295189b2012-06-20 16:38:30 -070010353 /* handlers for main ioctl */
10354 { WLAN_PRIV_SET_CHAR_GET_NONE,
10355 IW_PRIV_TYPE_CHAR| 512,
10356 0,
10357 "" },
10358
10359 /* handlers for sub-ioctl */
10360 { WE_WOWL_ADD_PTRN,
10361 IW_PRIV_TYPE_CHAR| 512,
10362 0,
10363 "wowlAddPtrn" },
10364
10365 { WE_WOWL_DEL_PTRN,
10366 IW_PRIV_TYPE_CHAR| 512,
10367 0,
10368 "wowlDelPtrn" },
10369
10370#if defined WLAN_FEATURE_VOWIFI
10371 /* handlers for sub-ioctl */
10372 { WE_NEIGHBOR_REPORT_REQUEST,
10373 IW_PRIV_TYPE_CHAR | 512,
10374 0,
10375 "neighbor" },
10376#endif
10377 { WE_SET_AP_WPS_IE,
10378 IW_PRIV_TYPE_CHAR| 512,
10379 0,
10380 "set_ap_wps_ie" },
10381
10382 { WE_SET_CONFIG,
10383 IW_PRIV_TYPE_CHAR| 512,
10384 0,
10385 "setConfig" },
10386
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010387 { WE_SET_ENCRYPT_MSG,
10388 IW_PRIV_TYPE_CHAR| 512,
10389 0,
10390 "encryptMsg" },
10391
10392
Jeff Johnson295189b2012-06-20 16:38:30 -070010393 /* handlers for main ioctl */
10394 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10395 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10396 0,
10397 "" },
10398
10399 /* handlers for sub-ioctl */
10400 { WE_SET_WLAN_DBG,
10401 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10402 0,
10403 "setwlandbg" },
10404
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 { WE_SET_WDI_DBG,
10406 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10407 0,
10408 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010409
10410 { WE_SET_SAP_CHANNELS,
10411 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10412 0,
10413 "setsapchannels" },
10414
10415 /* handlers for main ioctl */
10416 { WLAN_PRIV_GET_CHAR_SET_NONE,
10417 0,
10418 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10419 "" },
10420
10421 /* handlers for sub-ioctl */
10422 { WE_WLAN_VERSION,
10423 0,
10424 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10425 "version" },
10426 { WE_GET_STATS,
10427 0,
10428 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10429 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010430 { WE_GET_STATES,
10431 0,
10432 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10433 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010434 { WE_GET_CFG,
10435 0,
10436 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10437 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010438#ifdef WLAN_FEATURE_11AC
10439 { WE_GET_RSSI,
10440 0,
10441 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10442 "getRSSI" },
10443#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010444#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010445 { WE_GET_ROAM_RSSI,
10446 0,
10447 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10448 "getRoamRSSI" },
10449#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010450 { WE_GET_WMM_STATUS,
10451 0,
10452 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10453 "getWmmStatus" },
10454 {
10455 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010456 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10458 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010459#ifdef FEATURE_WLAN_TDLS
10460 {
10461 WE_GET_TDLS_PEERS,
10462 0,
10463 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10464 "getTdlsPeers" },
10465#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010466#ifdef WLAN_FEATURE_11W
10467 {
10468 WE_GET_11W_INFO,
10469 0,
10470 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10471 "getPMFInfo" },
10472#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010473 { WE_GET_SNR,
10474 0,
10475 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10476 "getSNR" },
10477
Jeff Johnson295189b2012-06-20 16:38:30 -070010478 /* handlers for main ioctl */
10479 { WLAN_PRIV_SET_NONE_GET_NONE,
10480 0,
10481 0,
10482 "" },
10483
10484 /* handlers for sub-ioctl */
10485 { WE_CLEAR_STATS,
10486 0,
10487 0,
10488 "clearStats" },
10489 { WE_INIT_AP,
10490 0,
10491 0,
10492 "initAP" },
10493 { WE_STOP_AP,
10494 0,
10495 0,
10496 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010497#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010498 { WE_ENABLE_AMP,
10499 0,
10500 0,
10501 "enableAMP" },
10502 { WE_DISABLE_AMP,
10503 0,
10504 0,
10505 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010506#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010507 { WE_ENABLE_DXE_STALL_DETECT,
10508 0,
10509 0,
10510 "dxeStallDetect" },
10511 { WE_DISPLAY_DXE_SNAP_SHOT,
10512 0,
10513 0,
10514 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010515 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10516 0,
10517 0,
10518 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010519 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010520 WE_SET_REASSOC_TRIGGER,
10521 0,
10522 0,
10523 "reassoc" },
10524 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010525 WE_STOP_OBSS_SCAN,
10526 0,
10527 0,
10528 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010529 {
10530 WE_DUMP_ROAM_TIMER_LOG,
10531 0,
10532 0,
10533 "dumpRoamDelay" },
10534 {
10535 WE_RESET_ROAM_TIMER_LOG,
10536 0,
10537 0,
10538 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010539 {
10540 WE_GET_FW_LOGS,
10541 0,
10542 0,
10543 "getFwLogs" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010544 /* handlers for main ioctl */
10545 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10546 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10547 0,
10548 "" },
10549
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010550
10551
Jeff Johnson295189b2012-06-20 16:38:30 -070010552 /* handlers for sub-ioctl */
10553 { WE_LOG_DUMP_CMD,
10554 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10555 0,
10556 "dump" },
10557
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010558 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010559 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10560 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10561 0,
10562 "setdumplog" },
10563
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010564 { WE_MTRACE_DUMP_CMD,
10565 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10566 0,
10567 "dumplog" },
10568
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010569 /* handlers for sub ioctl */
10570 {
10571 WE_MCC_CONFIG_CREDENTIAL,
10572 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10573 0,
10574 "setMccCrdnl" },
10575
10576 /* handlers for sub ioctl */
10577 {
10578 WE_MCC_CONFIG_PARAMS,
10579 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10580 0,
10581 "setMccConfig" },
10582
Chilam NG571c65a2013-01-19 12:27:36 +053010583#ifdef FEATURE_WLAN_TDLS
10584 /* handlers for sub ioctl */
10585 {
10586 WE_TDLS_CONFIG_PARAMS,
10587 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10588 0,
10589 "setTdlsConfig" },
10590#endif
10591
Katya Nigamf0511f62015-05-05 16:40:57 +053010592 {
10593 WE_CONFIGURE_MONITOR_MODE,
10594 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10595 0,
10596 "MonitorModeConf" },
10597
10598 {
10599 WE_SET_MONITOR_MODE_FILTER,
10600 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10601 0,
10602 "MonitorFilter" },
10603
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 /* handlers for main ioctl */
10605 { WLAN_PRIV_ADD_TSPEC,
10606 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10607 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10608 "addTspec" },
10609
10610 /* handlers for main ioctl */
10611 { WLAN_PRIV_DEL_TSPEC,
10612 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10613 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10614 "delTspec" },
10615
10616 /* handlers for main ioctl */
10617 { WLAN_PRIV_GET_TSPEC,
10618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10619 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10620 "getTspec" },
10621
Jeff Johnsone7245742012-09-05 17:12:55 -070010622#ifdef FEATURE_OEM_DATA_SUPPORT
10623 /* handlers for main ioctl - OEM DATA */
10624 {
10625 WLAN_PRIV_SET_OEM_DATA_REQ,
10626 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10627 0,
10628 "set_oem_data_req" },
10629
10630 /* handlers for main ioctl - OEM DATA */
10631 {
10632 WLAN_PRIV_GET_OEM_DATA_RSP,
10633 0,
10634 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10635 "get_oem_data_rsp" },
10636#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010637
Jeff Johnson295189b2012-06-20 16:38:30 -070010638 /* handlers for main ioctl - host offload */
10639 {
10640 WLAN_PRIV_SET_HOST_OFFLOAD,
10641 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10642 0,
10643 "setHostOffload" },
10644
10645 {
10646 WLAN_GET_WLAN_STATISTICS,
10647 0,
10648 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10649 "getWlanStats" },
10650
10651 {
10652 WLAN_SET_KEEPALIVE_PARAMS,
10653 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10654 0,
10655 "setKeepAlive" },
10656#ifdef WLAN_FEATURE_PACKET_FILTERING
10657 {
10658 WLAN_SET_PACKET_FILTER_PARAMS,
10659 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10660 0,
10661 "setPktFilter" },
10662#endif
10663#ifdef FEATURE_WLAN_SCAN_PNO
10664 {
10665 WLAN_SET_PNO,
10666 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10667 0,
10668 "setpno" },
10669#endif
10670 {
10671 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010672 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010673 0,
10674 "SETBAND" },
10675 /* handlers for dynamic MC BC ioctl */
10676 {
10677 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010678 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010679 0,
10680 "setMCBCFilter" },
10681 {
10682 WLAN_PRIV_CLEAR_MCBC_FILTER,
10683 0,
10684 0,
10685 "clearMCBCFilter" },
10686 {
10687 WLAN_SET_POWER_PARAMS,
10688 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10689 0,
10690 "setpowerparams" },
10691 {
10692 WLAN_GET_LINK_SPEED,
10693 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010694 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010695};
10696
10697
10698
10699const struct iw_handler_def we_handler_def = {
10700 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10701 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10702 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10703
10704 .standard = (iw_handler *)we_handler,
10705 .private = (iw_handler *)we_private,
10706 .private_args = we_private_args,
10707 .get_wireless_stats = get_wireless_stats,
10708};
10709
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010710int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10711{
10712 v_U32_t cmd = 288; //Command to RIVA
10713 hdd_context_t *pHddCtx = NULL;
10714 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10715 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10716 /*
10717 *configMccParam : specify the bit which needs to be modified
10718 *allowed to update based on wlan_qcom_cfg.ini
10719 * configuration
10720 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10721 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10722 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10723 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10724 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10725 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10726 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10727 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10728 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10729 * Bit 9 : Reserved
10730 */
10731 switch (arg1)
10732 {
10733 //Update MCC SCHEDULE_TIME_SLICE parameter
10734 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10735 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10736 {
10737 if((arg2 >= 5) && (arg2 <= 20))
10738 {
10739 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10740 }
10741 else
10742 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010743 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010744 return 0;
10745 }
10746 }
10747 break;
10748
10749 //Update MCC MAX_NULL_SEND_TIME parameter
10750 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10751 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10752 {
10753 if((arg2 >= 1) && (arg2 <= 10))
10754 {
10755 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10756 }
10757 else
10758 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010759 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010760 return 0;
10761 }
10762 }
10763 break;
10764
10765 //Update MCC TX_EARLY_STOP_TIME parameter
10766 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10767 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10768 {
10769 if((arg2 >= 1) && (arg2 <= 10))
10770 {
10771 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10772 }
10773 else
10774 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010775 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010776 return 0;
10777 }
10778 }
10779 break;
10780
10781 //Update MCC RX_DRAIN_TIME parameter
10782 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10783 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10784 {
10785 if((arg2 >= 1) && (arg2 <= 10))
10786 {
10787 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10788 }
10789 else
10790 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010791 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010792 return 0;
10793 }
10794 }
10795 break;
10796
10797 //Update MCC CHANNEL_SWITCH_TIME parameter
10798 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10799 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10800 {
10801 if((arg2 >= 1) && (arg2 <= 20))
10802 {
10803 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10804 }
10805 else
10806 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010807 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010808 return 0;
10809 }
10810 }
10811 break;
10812
10813 //Update MCC MIN_CHANNEL_TIME parameter
10814 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10815 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10816 {
10817 if((arg2 >= 5) && (arg2 <= 20))
10818 {
10819 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10820 }
10821 else
10822 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010823 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010824 return 0;
10825 }
10826 }
10827 break;
10828
10829 //Update MCC PARK_BEFORE_TBTT parameter
10830 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10831 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10832 {
10833 if((arg2 >= 1) && (arg2 <= 5))
10834 {
10835 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10836 }
10837 else
10838 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010839 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010840 return 0;
10841 }
10842 }
10843 break;
10844
10845 //Update MCC MIN_AFTER_DTIM parameter
10846 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10847 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10848 {
10849 if((arg2 >= 5) && (arg2 <= 15))
10850 {
10851 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10852 }
10853 else
10854 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010855 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010856 return 0;
10857 }
10858 }
10859 break;
10860
10861 //Update MCC TOO_CLOSE_MARGIN parameter
10862 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10863 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10864 {
10865 if((arg2 >= 1) && (arg2 <= 3))
10866 {
10867 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10868 }
10869 else
10870 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010871 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010872 return 0;
10873 }
10874 }
10875 break;
10876
10877 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010878 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010879 __FUNCTION__,arg1);
10880 break;
10881 }
10882 return 0;
10883}
10884
Jeff Johnson295189b2012-06-20 16:38:30 -070010885int hdd_set_wext(hdd_adapter_t *pAdapter)
10886{
10887 hdd_wext_state_t *pwextBuf;
10888 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010889 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010890
10891 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10892
10893 // Now configure the roaming profile links. To SSID and bssid.
10894 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10895 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10896
10897 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10898 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10899
10900 /*Set the numOfChannels to zero to scan all the channels*/
10901 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10902 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10903
10904 /* Default is no encryption */
10905 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10906 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10907
10908 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10909 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10910
10911 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10912
10913 /* Default is no authentication */
10914 pwextBuf->roamProfile.AuthType.numEntries = 1;
10915 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10916
10917 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10918 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10919
10920 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010921 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010922
10923 hdd_clearRoamProfileIe(pAdapter);
10924
10925 return VOS_STATUS_SUCCESS;
10926
10927 }
10928
10929int hdd_register_wext(struct net_device *dev)
10930 {
10931 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10932 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10933 VOS_STATUS status;
10934
10935 ENTER();
10936
10937 // Zero the memory. This zeros the profile structure.
10938 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10939
10940 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10941
10942
10943 status = hdd_set_wext(pAdapter);
10944
10945 if(!VOS_IS_STATUS_SUCCESS(status)) {
10946
Arif Hussain6d2a3322013-11-17 19:50:10 -080010947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010948 return eHAL_STATUS_FAILURE;
10949 }
10950
10951 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10952 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010954 return eHAL_STATUS_FAILURE;
10955 }
10956
10957 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10958 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010960 return eHAL_STATUS_FAILURE;
10961 }
10962
10963 // Register as a wireless device
10964 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10965
10966 EXIT();
10967 return 0;
10968}
10969
10970int hdd_UnregisterWext(struct net_device *dev)
10971{
c_hpothu2a13bc32015-01-21 12:48:54 +053010972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10973 if (dev != NULL)
10974 {
10975 rtnl_lock();
10976 dev->wireless_handlers = NULL;
10977 rtnl_unlock();
10978 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010979
Jeff Johnson295189b2012-06-20 16:38:30 -070010980 return 0;
10981}
10982
10983