blob: bfbec3c090b4714dc10de87a19fde9a1faeb21e8 [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
Sushant Kaushik33200572015-08-05 16:46:20 +0530175#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Jeff Johnson295189b2012-06-20 16:38:30 -0700176
177/* Private ioctls and their sub-ioctls */
178#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
179#define WE_GET_11D_STATE 1
180#define WE_IBSS_STATUS 2
181#define WE_PMC_STATE 3
182#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700183#define WE_GET_MAX_ASSOC 6
184#define WE_GET_WDI_DBG 7
185#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
186#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530187#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700188/* Private ioctls and their sub-ioctls */
189#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
190
191/* Private ioctls and their sub-ioctls */
192#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
193#define WE_WOWL_ADD_PTRN 1
194#define WE_WOWL_DEL_PTRN 2
195#if defined WLAN_FEATURE_VOWIFI
196#define WE_NEIGHBOR_REPORT_REQUEST 3
197#endif
198#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
199#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530200#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
202/* Private ioctls and their sub-ioctls */
203#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
204#define WE_SET_WLAN_DBG 1
205#define WE_SET_WDI_DBG 2
206#define WE_SET_SAP_CHANNELS 3
207
208/* Private ioctls and their sub-ioctls */
209#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
210#define WE_WLAN_VERSION 1
211#define WE_GET_STATS 2
212#define WE_GET_CFG 3
213#define WE_GET_WMM_STATUS 4
214#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700215#ifdef WLAN_FEATURE_11AC
216#define WE_GET_RSSI 6
217#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800218#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800219#ifdef FEATURE_WLAN_TDLS
220#define WE_GET_TDLS_PEERS 8
221#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700222#ifdef WLAN_FEATURE_11W
223#define WE_GET_11W_INFO 9
224#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530225#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530226#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700227
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530228#ifdef FEATURE_OEM_DATA_SUPPORT
229#define WE_GET_OEM_DATA_CAP 13
230#endif
231
Jeff Johnson295189b2012-06-20 16:38:30 -0700232/* Private ioctls and their sub-ioctls */
233#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
234#define WE_CLEAR_STATS 1
235#define WE_INIT_AP 2
236#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530237#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700238#define WE_ENABLE_AMP 4
239#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530240#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700241#define WE_ENABLE_DXE_STALL_DETECT 6
242#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700243#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530244#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530245#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530246#define WE_DUMP_ROAM_TIMER_LOG 12
247#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530248#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530249#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530250
Jeff Johnson295189b2012-06-20 16:38:30 -0700251/* Private ioctls and their sub-ioctls */
252#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
253#define WE_LOG_DUMP_CMD 1
254
Jeff Johnson295189b2012-06-20 16:38:30 -0700255#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800256//IOCTL to configure MCC params
257#define WE_MCC_CONFIG_CREDENTIAL 3
258#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700259
Chilam NG571c65a2013-01-19 12:27:36 +0530260#ifdef FEATURE_WLAN_TDLS
261#define WE_TDLS_CONFIG_PARAMS 5
262#endif
263
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700264#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530265#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530266#define WE_CONFIGURE_MONITOR_MODE 10
267#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700268
Chilam Ng01120412013-02-19 18:32:21 -0800269#ifdef FEATURE_WLAN_TDLS
270#undef MAX_VAR_ARGS
271#define MAX_VAR_ARGS 10
272#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700273#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800274#endif
275
Jeff Johnson295189b2012-06-20 16:38:30 -0700276/* Private ioctls (with no sub-ioctls) */
277/* note that they must be odd so that they have "get" semantics */
278#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
279#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
280#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
281
Girish Gowli464c9c82014-06-09 19:47:53 +0530282/* (SIOCIWFIRSTPRIV + 8) is currently unused */
283/* (SIOCIWFIRSTPRIV + 16) is currently unused */
284/* (SIOCIWFIRSTPRIV + 10) is currently unused */
285/* (SIOCIWFIRSTPRIV + 12) is currently unused */
286/* (SIOCIWFIRSTPRIV + 14) is currently unused */
287/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
Jeff Johnsone7245742012-09-05 17:12:55 -0700289#ifdef FEATURE_OEM_DATA_SUPPORT
290/* Private ioctls for setting the measurement configuration */
291#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
292#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
293#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700294
295#ifdef WLAN_FEATURE_VOWIFI_11R
296#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
297#endif
298
299/* Private ioctl for setting the host offload feature */
300#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
301
302/* Private ioctl to get the statistics */
303#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
304
305/* Private ioctl to set the Keep Alive Params */
306#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
307#ifdef WLAN_FEATURE_PACKET_FILTERING
308/* Private ioctl to set the Packet Filtering Params */
309#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
310#endif
311
312#ifdef FEATURE_WLAN_SCAN_PNO
313/* Private ioctl to get the statistics */
314#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
315#endif
316
317#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
318
319#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
320#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700321/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700322
Jeff Johnson295189b2012-06-20 16:38:30 -0700323#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
324#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
325
326#define WLAN_STATS_INVALID 0
327#define WLAN_STATS_RETRY_CNT 1
328#define WLAN_STATS_MUL_RETRY_CNT 2
329#define WLAN_STATS_TX_FRM_CNT 3
330#define WLAN_STATS_RX_FRM_CNT 4
331#define WLAN_STATS_FRM_DUP_CNT 5
332#define WLAN_STATS_FAIL_CNT 6
333#define WLAN_STATS_RTS_FAIL_CNT 7
334#define WLAN_STATS_ACK_FAIL_CNT 8
335#define WLAN_STATS_RTS_SUC_CNT 9
336#define WLAN_STATS_RX_DISCARD_CNT 10
337#define WLAN_STATS_RX_ERROR_CNT 11
338#define WLAN_STATS_TX_BYTE_CNT 12
339
340#define WLAN_STATS_RX_BYTE_CNT 13
341#define WLAN_STATS_RX_RATE 14
342#define WLAN_STATS_TX_RATE 15
343
Jeff Johnsone7245742012-09-05 17:12:55 -0700344#define WLAN_STATS_RX_UC_BYTE_CNT 16
345#define WLAN_STATS_RX_MC_BYTE_CNT 17
346#define WLAN_STATS_RX_BC_BYTE_CNT 18
347#define WLAN_STATS_TX_UC_BYTE_CNT 19
348#define WLAN_STATS_TX_MC_BYTE_CNT 20
349#define WLAN_STATS_TX_BC_BYTE_CNT 21
350
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800351#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
352 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
353 { \
354 *__p++ = __type; \
355 *__p++ = __size; \
356 memcpy(__p, __val, __size); \
357 __p += __size; \
358 __tlen += __size + 2; \
359 } \
360 else \
361 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800362 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800363 } \
364 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700365
366#define VERSION_VALUE_MAX_LEN 32
367
368#define TX_PER_TRACKING_DEFAULT_RATIO 5
369#define TX_PER_TRACKING_MAX_RATIO 10
370#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
371
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530372#define WLAN_ADAPTER 0
373#define P2P_ADAPTER 1
374
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530375/*
376 * When supplicant sends SETBAND ioctl it queries for channels from
377 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
378 * This is not required if the return type from ioctl is
379 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
380 * event as part of regulatory_hint.
381 */
382enum {
383 SEND_CHANNEL_CHANGE_EVENT = 0,
384 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
385};
386
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800387/*MCC Configuration parameters */
388enum {
389 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
390 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
391 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
392 MCC_RX_DRAIN_TIME_CFG_PARAM,
393 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
394 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
395 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
396 MCC_MIN_AFTER_DTIM_CFG_PARAM,
397 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
398};
399
400int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
401 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
402
Jeff Johnson295189b2012-06-20 16:38:30 -0700403#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800404int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700405 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700406#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530407static int get_fwr_memdump(struct net_device *,
408 struct iw_request_info *,
409 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700410/**---------------------------------------------------------------------------
411
Arif Hussain0273cba2014-01-07 20:58:29 -0800412 \brief mem_alloc_copy_from_user_helper -
413
414 Helper function to allocate buffer and copy user data.
415
416 \param - wrqu - Pointer to IOCTL Data.
417 len - size
418
419 \return - On Success pointer to buffer, On failure NULL
420
421 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530422void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800423{
424 u8 *ptr = NULL;
425
426 /* in order to protect the code, an extra byte is post appended to the buffer
427 * and the null termination is added. However, when allocating (len+1) byte
428 * of memory, we need to make sure that there is no uint overflow when doing
429 * addition. In theory check len < UINT_MAX protects the uint overflow. For
430 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
431 * guess, now, it is assumed that the private command buffer size is no
432 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
433 */
434 if (len > MAX_USER_COMMAND_SIZE)
435 {
436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
437 "Invalid length");
438 return NULL;
439 }
440
441 ptr = kmalloc(len + 1, GFP_KERNEL);
442 if (NULL == ptr)
443 {
444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
445 "unable to allocate memory");
446 return NULL;
447 }
448
449 if (copy_from_user(ptr, wrqu_data, len))
450 {
451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
452 "%s: failed to copy data to user buffer", __func__);
453 kfree(ptr);
454 return NULL;
455 }
456 ptr[len] = '\0';
457 return ptr;
458}
459
Girish Gowli488ef492014-06-12 18:44:33 +0530460// Function to handle and get compatible struct iw_point passed to ioctl.
461int hdd_priv_get_data(struct iw_point *p_priv_data,
462 union iwreq_data *wrqu)
463{
464 if ((NULL == p_priv_data) || (NULL == wrqu))
465 {
466 return -EINVAL;
467 }
468
469#ifdef CONFIG_COMPAT
470 if (is_compat_task())
471 {
472 struct compat_iw_point *p_compat_priv_data;
473
474 // Compat task: typecast to campat structure and copy the members.
475 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
476
477 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
478 p_priv_data->length = p_compat_priv_data->length;
479 p_priv_data->flags = p_compat_priv_data->flags;
480 }//if(is_compat_task())
481 else
482 {
483#endif //#ifdef CONFIG_COMPAT
484
485 // Non compat task: directly copy the structure.
486 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
487
488#ifdef CONFIG_COMPAT
489 }//else of - if(is_compat_task())
490#endif //#ifdef CONFIG_COMPAT
491
492 return 0;
493}
494
Arif Hussain0273cba2014-01-07 20:58:29 -0800495/**---------------------------------------------------------------------------
496
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 \brief hdd_wlan_get_version() -
498
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800499 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700500
501 \param - pAdapter Pointer to the adapter.
502 wrqu - Pointer to IOCTL REQUEST Data.
503 extra - Pointer to char
504
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800505 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700506
507 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800508void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
509 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700510{
511 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800512 tSirVersionString wcnss_SW_version;
513 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530514 tSirVersionString iris_name;
515 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800516 char *pSWversion;
517 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700519
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800520 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
521 sizeof(wcnss_SW_version));
522 if (VOS_IS_STATUS_SUCCESS(status))
523 {
524 pSWversion = wcnss_SW_version;
525 }
526 else
527 {
528 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 }
530
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800531 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
532 sizeof(wcnss_HW_version));
533 if (VOS_IS_STATUS_SUCCESS(status))
534 {
535 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700536 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800537 else
538 {
539 pHWversion = "Unknown";
540 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700541
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530542 status = wcnss_get_iris_name(iris_name);
543
544 if (!status) {
545 pIRISversion = iris_name;
546 } else {
547 pIRISversion = "Unknown";
548 }
549
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700550 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530551 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800552 QWLAN_VERSIONSTR,
553 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530554 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800555
556 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700557}
558
Jeff Johnson295189b2012-06-20 16:38:30 -0700559int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
560{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530561 tHalHandle hHal;
562 hdd_context_t *pHddCtx;
563 v_U32_t threshold = 0;
564 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700565
566 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530567 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530568 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
570 "%s: Adapter is NULL",__func__);
571 return -EINVAL;
572 }
573
574 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
575 ret = wlan_hdd_validate_context(pHddCtx);
576 if (0 != ret)
577 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530578 return ret;
579 }
580
581 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
582 if (NULL == hHal)
583 {
584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
585 "%s: Hal Context is NULL",__func__);
586 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 }
588
589 if ( eHAL_STATUS_SUCCESS !=
590 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
591 {
c_hpothub8245442013-11-20 23:41:09 +0530592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
593 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 return -EIO;
595 }
596 wrqu->rts.value = threshold;
597
598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800599 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700600
601 EXIT();
602
603 return 0;
604}
605
606int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
607{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530608 tHalHandle hHal;
609 hdd_context_t *pHddCtx;
610 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700611
612 ENTER();
613
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530614 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530615 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: Adapter is NULL",__func__);
618 return -EINVAL;
619 }
620
621 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
622 status = wlan_hdd_validate_context(pHddCtx);
623 if (0 != status)
624 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530625 return status;
626 }
627
628 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
629 if (NULL == hHal)
630 {
631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
632 "%s: Hal Context is NULL",__func__);
633 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 }
635
636 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
637 != eHAL_STATUS_SUCCESS )
638 {
c_hpothub8245442013-11-20 23:41:09 +0530639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
640 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 return -EIO;
642 }
643 wrqu->frag.value = threshold;
644
645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800646 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700647
648 EXIT();
649
650 return 0;
651}
652
653int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
654{
Jeff Johnsone7245742012-09-05 17:12:55 -0700655 int i;
656 if (channel > 0)
657 {
658 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
659 {
660 if (channel == freq_chan_map[i].chan)
661 {
662 *pfreq = freq_chan_map[i].freq;
663 return 1;
664 }
665 }
666 }
667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800668 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700669 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700670}
671
672static v_BOOL_t
673hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
674{
675 v_BOOL_t rsnType = VOS_FALSE;
676 // is the authType supported?
677 switch (authType)
678 {
679 case eCSR_AUTH_TYPE_NONE: //never used
680 rsnType = eANI_BOOLEAN_FALSE;
681 break;
682 // MAC layer authentication types
683 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
684 rsnType = eANI_BOOLEAN_FALSE;
685 break;
686 case eCSR_AUTH_TYPE_SHARED_KEY:
687 rsnType = eANI_BOOLEAN_FALSE;
688 break;
689 case eCSR_AUTH_TYPE_AUTOSWITCH:
690 rsnType = eANI_BOOLEAN_FALSE;
691 break;
692
693 // Upper layer authentication types
694 case eCSR_AUTH_TYPE_WPA:
695 rsnType = eANI_BOOLEAN_TRUE;
696 break;
697 case eCSR_AUTH_TYPE_WPA_PSK:
698 rsnType = eANI_BOOLEAN_TRUE;
699 break;
700 case eCSR_AUTH_TYPE_WPA_NONE:
701 rsnType = eANI_BOOLEAN_TRUE;
702 break;
703#ifdef WLAN_FEATURE_VOWIFI_11R
704 case eCSR_AUTH_TYPE_FT_RSN:
705#endif
706 case eCSR_AUTH_TYPE_RSN:
707 rsnType = eANI_BOOLEAN_TRUE;
708 break;
709#ifdef WLAN_FEATURE_VOWIFI_11R
710 case eCSR_AUTH_TYPE_FT_RSN_PSK:
711#endif
712 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700713#ifdef WLAN_FEATURE_11W
714 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530715 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700716#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 rsnType = eANI_BOOLEAN_TRUE;
718 break;
719 //case eCSR_AUTH_TYPE_FAILED:
720 case eCSR_AUTH_TYPE_UNKNOWN:
721 rsnType = eANI_BOOLEAN_FALSE;
722 break;
723 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800724 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
725 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 rsnType = eANI_BOOLEAN_FALSE;
727 break;
728 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800729 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700730 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 return rsnType;
732}
733
734static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
735{
736 struct statsContext *pStatsContext;
737 hdd_adapter_t *pAdapter;
738
739 if (ioctl_debug)
740 {
741 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700742 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 }
744
745 if (NULL == pContext)
746 {
747 hddLog(VOS_TRACE_LEVEL_ERROR,
748 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700749 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 return;
751 }
752
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 pStatsContext = pContext;
754 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800755
756 /* there is a race condition that exists between this callback
757 function and the caller since the caller could time out either
758 before or while this code is executing. we use a spinlock to
759 serialize these actions */
760 spin_lock(&hdd_context_lock);
761
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
763 {
764 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800765 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700766 hddLog(VOS_TRACE_LEVEL_WARN,
767 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700768 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 if (ioctl_debug)
770 {
771 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700772 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 }
774 return;
775 }
776
Jeff Johnson72a40512013-12-19 10:14:15 -0800777 /* context is valid so caller is still waiting */
778
779 /* paranoia: invalidate the magic */
780 pStatsContext->magic = 0;
781
Sachin Ahujaa082b672015-10-05 19:51:31 +0530782 /* copy over the rssi.FW will return RSSI as -100
783 * if there are no samples to calculate the average
784 * RSSI
785 */
786 if (rssi != -100)
787 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530788 if (pAdapter->rssi > 0)
789 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800790 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800792
793 /* serialization is complete */
794 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700795}
796
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530797static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
798{
799 struct statsContext *pStatsContext;
800 hdd_adapter_t *pAdapter;
801
802 if (ioctl_debug)
803 {
804 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
805 __func__, (int)snr, (int)staId, pContext);
806 }
807
808 if (NULL == pContext)
809 {
810 hddLog(VOS_TRACE_LEVEL_ERROR,
811 "%s: Bad param, pContext [%p]",
812 __func__, pContext);
813 return;
814 }
815
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530816 pStatsContext = pContext;
817 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800818
819 /* there is a race condition that exists between this callback
820 function and the caller since the caller could time out either
821 before or while this code is executing. we use a spinlock to
822 serialize these actions */
823 spin_lock(&hdd_context_lock);
824
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530825 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
826 {
827 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800828 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530829 hddLog(VOS_TRACE_LEVEL_WARN,
830 "%s: Invalid context, pAdapter [%p] magic [%08x]",
831 __func__, pAdapter, pStatsContext->magic);
832 if (ioctl_debug)
833 {
834 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
835 __func__, pAdapter, pStatsContext->magic);
836 }
837 return;
838 }
839
Jeff Johnson72a40512013-12-19 10:14:15 -0800840 /* context is valid so caller is still waiting */
841
842 /* paranoia: invalidate the magic */
843 pStatsContext->magic = 0;
844
845 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530846 pAdapter->snr = snr;
847
Jeff Johnson72a40512013-12-19 10:14:15 -0800848 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530849 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800850
851 /* serialization is complete */
852 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530853}
854
Jeff Johnson295189b2012-06-20 16:38:30 -0700855VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
856{
857 struct statsContext context;
858 hdd_context_t *pHddCtx;
859 hdd_station_ctx_t *pHddStaCtx;
860 eHalStatus hstatus;
861 long lrc;
862
863 if (NULL == pAdapter)
864 {
865 hddLog(VOS_TRACE_LEVEL_WARN,
866 "%s: Invalid context, pAdapter", __func__);
867 return VOS_STATUS_E_FAULT;
868 }
869 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
870 {
871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
872 /* return a cached value */
873 *rssi_value = pAdapter->rssi;
874 return VOS_STATUS_SUCCESS;
875 }
876
877 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
878 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
879
mukul sharma8aec69b2015-06-10 22:28:43 +0530880 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
881 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
883 __func__, pAdapter->rssi_on_disconnect);
884 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +0530885 return VOS_STATUS_SUCCESS;
886 }
887
888 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
889 {
890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
891 "%s: Roaming in progress, hence return last cached RSSI", __func__);
892 *rssi_value = pAdapter->rssi;
893 return VOS_STATUS_SUCCESS;
894 }
895
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 init_completion(&context.completion);
897 context.pAdapter = pAdapter;
898 context.magic = RSSI_CONTEXT_MAGIC;
899
900 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
901 pHddStaCtx->conn_info.staId[ 0 ],
902 pHddStaCtx->conn_info.bssId,
903 &context, pHddCtx->pvosContext);
904 if (eHAL_STATUS_SUCCESS != hstatus)
905 {
906 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700907 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 /* we'll returned a cached value below */
909 }
910 else
911 {
912 /* request was sent -- wait for the response */
913 lrc = wait_for_completion_interruptible_timeout(&context.completion,
914 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 if (lrc <= 0)
916 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800917 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700918 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 /* we'll now returned a cached value below */
920 }
921 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800922
923 /* either we never sent a request, we sent a request and received a
924 response or we sent a request and timed out. if we never sent a
925 request or if we sent a request and got a response, we want to
926 clear the magic out of paranoia. if we timed out there is a
927 race condition such that the callback function could be
928 executing at the same time we are. of primary concern is if the
929 callback function had already verified the "magic" but had not
930 yet set the completion variable when a timeout occurred. we
931 serialize these activities by invalidating the magic while
932 holding a shared spinlock which will cause us to block if the
933 callback is currently executing */
934 spin_lock(&hdd_context_lock);
935 context.magic = 0;
936 spin_unlock(&hdd_context_lock);
937
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 *rssi_value = pAdapter->rssi;
939
940 return VOS_STATUS_SUCCESS;
941}
Siddharth Bhal64246172015-02-27 01:04:37 +0530942/**---------------------------------------------------------------------------
943
944 \brief wlan_hdd_get_frame_logs() -
945
946 This function use to get Frames log.
947
948 \param - pAdapter Pointer to the adapter.
949 flag - Specify type of request. Clear and Send request are
950 supported.
951
952 \return - none
953
954 --------------------------------------------------------------------------*/
955VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
956{
Siddharth Bhal64246172015-02-27 01:04:37 +0530957 hdd_context_t *pHddCtx;
958 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +0530959
960 if (NULL == pAdapter)
961 {
962 hddLog(VOS_TRACE_LEVEL_WARN,
963 "%s: Invalid context, pAdapter", __func__);
964 return VOS_STATUS_E_FAULT;
965 }
966
967 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
968 if (!pHddCtx->mgmt_frame_logging)
969 {
970 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
971 return VOS_STATUS_E_AGAIN;
972 }
973
Siddharth Bhal4507c262015-04-29 20:20:42 +0530974 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
975 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
976 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +0530977 {
978 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
979 return VOS_STATUS_E_INVAL;
980 }
981
Siddharth Bhal4507c262015-04-29 20:20:42 +0530982 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
983 (!pHddCtx->cfg_ini->enableBMUHWtracing))
984 {
985 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
986 return VOS_STATUS_E_INVAL;
987 }
988
Abhishek Singh611295e2015-07-09 11:11:54 +0530989 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +0530990 if (eHAL_STATUS_SUCCESS != hstatus)
991 {
992 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +0530993 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +0530994 }
Siddharth Bhal64246172015-02-27 01:04:37 +0530995
996 return VOS_STATUS_SUCCESS;
997}
998
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530999
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301000VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1001{
1002 struct statsContext context;
1003 hdd_context_t *pHddCtx;
1004 hdd_station_ctx_t *pHddStaCtx;
1005 eHalStatus hstatus;
1006 long lrc;
1007 int valid;
1008
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301009 ENTER();
1010
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301011 if (NULL == pAdapter)
1012 {
1013 hddLog(VOS_TRACE_LEVEL_ERROR,
1014 "%s: Invalid context, pAdapter", __func__);
1015 return VOS_STATUS_E_FAULT;
1016 }
1017
1018 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1019
1020 valid = wlan_hdd_validate_context(pHddCtx);
1021 if (0 != valid)
1022 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301023 return VOS_STATUS_E_FAULT;
1024 }
1025
1026 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1027 if (NULL == pHddStaCtx)
1028 {
1029 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1030 return VOS_STATUS_E_FAULT;
1031 }
1032
1033 init_completion(&context.completion);
1034 context.pAdapter = pAdapter;
1035 context.magic = SNR_CONTEXT_MAGIC;
1036
1037 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1038 pHddStaCtx->conn_info.staId[ 0 ],
1039 pHddStaCtx->conn_info.bssId,
1040 &context);
1041 if (eHAL_STATUS_SUCCESS != hstatus)
1042 {
1043 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1044 __func__);
1045 /* we'll returned a cached value below */
1046 }
1047 else
1048 {
1049 /* request was sent -- wait for the response */
1050 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1051 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301052 if (lrc <= 0)
1053 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001054 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301055 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301056 /* we'll now returned a cached value below */
1057 }
1058 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001059
1060 /* either we never sent a request, we sent a request and received a
1061 response or we sent a request and timed out. if we never sent a
1062 request or if we sent a request and got a response, we want to
1063 clear the magic out of paranoia. if we timed out there is a
1064 race condition such that the callback function could be
1065 executing at the same time we are. of primary concern is if the
1066 callback function had already verified the "magic" but had not
1067 yet set the completion variable when a timeout occurred. we
1068 serialize these activities by invalidating the magic while
1069 holding a shared spinlock which will cause us to block if the
1070 callback is currently executing */
1071 spin_lock(&hdd_context_lock);
1072 context.magic = 0;
1073 spin_unlock(&hdd_context_lock);
1074
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301075 *snr = pAdapter->snr;
1076
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301077 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301078 return VOS_STATUS_SUCCESS;
1079}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301080
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001081#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001082
1083static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1084{
1085 struct statsContext *pStatsContext;
1086 hdd_adapter_t *pAdapter;
1087 if (ioctl_debug)
1088 {
1089 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1090 __func__, (int)rssi, (int)staId, pContext);
1091 }
1092
1093 if (NULL == pContext)
1094 {
1095 hddLog(VOS_TRACE_LEVEL_ERROR,
1096 "%s: Bad param, pContext [%p]",
1097 __func__, pContext);
1098 return;
1099 }
1100
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001101 pStatsContext = pContext;
1102 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001103
1104 /* there is a race condition that exists between this callback
1105 function and the caller since the caller could time out either
1106 before or while this code is executing. we use a spinlock to
1107 serialize these actions */
1108 spin_lock(&hdd_context_lock);
1109
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001110 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1111 {
1112 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001113 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001114 hddLog(VOS_TRACE_LEVEL_WARN,
1115 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1116 __func__, pAdapter, pStatsContext->magic);
1117 if (ioctl_debug)
1118 {
1119 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1120 __func__, pAdapter, pStatsContext->magic);
1121 }
1122 return;
1123 }
1124
Jeff Johnson72a40512013-12-19 10:14:15 -08001125 /* context is valid so caller is still waiting */
1126
1127 /* paranoia: invalidate the magic */
1128 pStatsContext->magic = 0;
1129
Sachin Ahujaa082b672015-10-05 19:51:31 +05301130 /* copy over the rssi.FW will return RSSI as -100
1131 * if there are no samples to calculate the average
1132 * RSSI
1133 */
1134 if (rssi != -100)
1135 pAdapter->rssi = rssi;
1136
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301137 if (pAdapter->rssi > 0)
1138 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001139 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001140 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001141
1142 /* serialization is complete */
1143 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001144}
1145
1146
1147
1148VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1149{
1150 struct statsContext context;
1151 hdd_context_t *pHddCtx = NULL;
1152 hdd_station_ctx_t *pHddStaCtx = NULL;
1153 eHalStatus hstatus;
1154 long lrc;
1155
1156 if (NULL == pAdapter)
1157 {
1158 hddLog(VOS_TRACE_LEVEL_WARN,
1159 "%s: Invalid context, pAdapter", __func__);
1160 return VOS_STATUS_E_FAULT;
1161 }
1162 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1163 {
1164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1165 /* return a cached value */
1166 *rssi_value = pAdapter->rssi;
1167 return VOS_STATUS_SUCCESS;
1168 }
1169
1170 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1171 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1172
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301173 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001174 {
1175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1176 /* return a cached value */
1177 *rssi_value = 0;
1178 return VOS_STATUS_SUCCESS;
1179 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301180
1181 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1182 {
1183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1184 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1185 *rssi_value = pAdapter->rssi;
1186 return VOS_STATUS_SUCCESS;
1187 }
1188
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001189 init_completion(&context.completion);
1190 context.pAdapter = pAdapter;
1191 context.magic = RSSI_CONTEXT_MAGIC;
1192
1193 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1194 pHddStaCtx->conn_info.staId[ 0 ],
1195 pHddStaCtx->conn_info.bssId,
1196 &context, pHddCtx->pvosContext);
1197 if (eHAL_STATUS_SUCCESS != hstatus)
1198 {
1199 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1200 __func__);
1201 /* we'll returned a cached value below */
1202 }
1203 else
1204 {
1205 /* request was sent -- wait for the response */
1206 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1207 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001208 if (lrc <= 0)
1209 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001210 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001211 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001212 /* we'll now returned a cached value below */
1213 }
1214 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001215
1216 /* either we never sent a request, we sent a request and received a
1217 response or we sent a request and timed out. if we never sent a
1218 request or if we sent a request and got a response, we want to
1219 clear the magic out of paranoia. if we timed out there is a
1220 race condition such that the callback function could be
1221 executing at the same time we are. of primary concern is if the
1222 callback function had already verified the "magic" but had not
1223 yet set the completion variable when a timeout occurred. we
1224 serialize these activities by invalidating the magic while
1225 holding a shared spinlock which will cause us to block if the
1226 callback is currently executing */
1227 spin_lock(&hdd_context_lock);
1228 context.magic = 0;
1229 spin_unlock(&hdd_context_lock);
1230
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001231 *rssi_value = pAdapter->rssi;
1232
1233 return VOS_STATUS_SUCCESS;
1234}
1235#endif
1236
1237
Jeff Johnson295189b2012-06-20 16:38:30 -07001238void hdd_StatisticsCB( void *pStats, void *pContext )
1239{
1240 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1241 hdd_stats_t *pStatsCache = NULL;
1242 hdd_wext_state_t *pWextState;
1243 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1244
1245 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1246 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1247 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1248 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1249 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1250 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1251
1252 if (pAdapter!= NULL)
1253 pStatsCache = &pAdapter->hdd_stats;
1254
1255
1256 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1257 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1258 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1259 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1260 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1261 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1262
1263 if (pStatsCache!=NULL)
1264 {
1265 // and copy the stats into the cache we keep in the adapter instance structure
1266 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1267 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1268 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1269 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1270 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1271 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1272 }
1273
1274 if(pAdapter)
1275 {
1276 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1277 if(pWextState)
1278 {
1279 vos_status = vos_event_set(&pWextState->vosevent);
1280 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1281 {
1282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001283 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 return;
1285 }
1286 }
1287 }
1288}
1289
1290void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1291{
1292 v_CONTEXT_t pVosContext;
1293 hdd_context_t *pHddCtx;
1294 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1295#if 0
1296 hdd_wext_state_t *pWextState;
1297 v_U32_t roamId;
1298#endif
1299
1300 ENTER();
1301
1302 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1303
1304 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1305 if (NULL == pHddCtx)
1306 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001307 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 return;
1309 }
1310#if 0
1311 pWextState = pAdapter->pWextState;
1312#endif
1313
1314 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1315 {
1316 //TODO Verify is this is really used. If yes need to fix it.
1317 hdd_reconnect_all_adapters( pHddCtx );
1318#if 0
1319 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1320 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1321 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1322
1323 if(VOS_STATUS_SUCCESS == vosStatus)
1324 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1325 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1326
1327 sme_RoamConnect(halHandle,
1328 pAdapter->sessionId, &(pWextState->roamProfile),
1329 &roamId);
1330#endif
1331 }
1332
1333 EXIT();
1334
1335}
1336
1337void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1338{
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1340
1341 /* clear WPA/RSN/WSC IE information in the profile */
1342 pWextState->roamProfile.nWPAReqIELength = 0;
1343 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1344 pWextState->roamProfile.nRSNReqIELength = 0;
1345 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1346
Chet Lanctot186b5732013-03-18 10:26:30 -07001347#ifdef FEATURE_WLAN_WAPI
1348 pWextState->roamProfile.nWAPIReqIELength = 0;
1349 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1350#endif
1351
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001353 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301355 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1357 pWextState->roamProfile.nAddIEAssocLength = 0;
1358
1359 pWextState->roamProfile.EncryptionType.numEntries = 1;
1360 pWextState->roamProfile.EncryptionType.encryptionType[0]
1361 = eCSR_ENCRYPT_TYPE_NONE;
1362
1363 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1364 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1365 = eCSR_ENCRYPT_TYPE_NONE;
1366
1367 pWextState->roamProfile.AuthType.numEntries = 1;
1368 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1369
Chet Lanctot186b5732013-03-18 10:26:30 -07001370#ifdef WLAN_FEATURE_11W
1371 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1372 pWextState->roamProfile.MFPRequired = 0;
1373 pWextState->roamProfile.MFPCapable = 0;
1374#endif
1375
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 pWextState->authKeyMgmt = 0;
1377
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301378 vos_mem_zero(&pWextState->roamProfile.Keys,
1379 sizeof(pWextState->roamProfile.Keys));
1380
Jeff Johnson295189b2012-06-20 16:38:30 -07001381#ifdef FEATURE_WLAN_WAPI
1382 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1383 pAdapter->wapi_info.nWapiMode = 0;
1384#endif
1385
1386 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1387
1388}
1389
1390void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1391{
1392 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
Nirav Shahf6bd2672015-03-11 12:53:15 +05301394 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001395 {
1396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301397 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001398 }
1399 else
1400 {
1401 complete(&pAdapter->ula_complete);
1402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001403}
1404
1405VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1406{
1407 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001409 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001410
1411 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1412 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001413 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001414
1415 /*To avoid race condition between the set key and the last EAPOL
1416 packet, notify TL to finish upper layer authentication incase if the
1417 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001418 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001419
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001420 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 {
1422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1423 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1424 __LINE__, vos_status );
1425 return vos_status;
1426
1427 }
1428
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001429 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301431 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001432 {
1433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301434 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001435 /* we'll still fall through and return success since the
1436 * connection may still get established but is just taking
1437 * too long for us to wait */
1438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 }
1440 return VOS_STATUS_SUCCESS;
1441}
1442
1443v_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)
1444{
1445
1446 int left = ie_len;
1447 v_U8_t *ptr = ie;
1448 v_U8_t elem_id,elem_len;
1449 v_U8_t eid = 0xDD;
1450
1451 if ( NULL == ie || 0 == ie_len )
1452 return NULL;
1453
1454 while(left >= 2)
1455 {
1456 elem_id = ptr[0];
1457 elem_len = ptr[1];
1458 left -= 2;
1459 if(elem_len > left)
1460 {
1461 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001462 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 eid,elem_len,left);
1464 return NULL;
1465 }
1466 if (elem_id == eid)
1467 {
1468 if(memcmp( &ptr[2], oui, oui_size)==0)
1469 return ptr;
1470 }
1471
1472 left -= elem_len;
1473 ptr += (elem_len + 2);
1474 }
1475 return NULL;
1476}
1477
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301478static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 union iwreq_data *wrqu, char *extra)
1480{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301481 hdd_adapter_t *pAdapter;
1482 hdd_context_t *pHddCtx;
1483 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301484
1485 ENTER();
1486
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301487 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1488 if (NULL == pAdapter)
1489 {
1490 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1491 "%s: pAdapter is NULL\n", __func__);
1492 return -EINVAL;
1493 }
1494 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1495 ret = wlan_hdd_validate_context(pHddCtx);
1496 if (0 != ret)
1497 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301498 return ret;
1499 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301500
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301502
1503 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301504 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001505}
1506
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301507static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1508 union iwreq_data *wrqu, char *extra)
1509{
1510 int ret;
1511
1512 vos_ssr_protect(__func__);
1513 ret = __iw_set_commit(dev, info, wrqu, extra);
1514 vos_ssr_unprotect(__func__);
1515
1516 return ret;
1517}
1518
1519static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 struct iw_request_info *info,
1521 char *wrqu, char *extra)
1522{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301523 hdd_adapter_t *pAdapter;
1524 hdd_context_t *pHddCtx;
1525 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301526
Jeff Johnson295189b2012-06-20 16:38:30 -07001527 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301528 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1529 if (NULL == pAdapter)
1530 {
1531 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1532 "%s: pAdapter is NULL\n", __func__);
1533 return -EINVAL;
1534 }
1535 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1536 ret = wlan_hdd_validate_context(pHddCtx);
1537 if (0 != ret)
1538 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301539 return ret;
1540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1542 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301543 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001544}
1545
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301546static int iw_get_name(struct net_device *dev,
1547 struct iw_request_info *info,
1548 char *wrqu, char *extra)
1549{
1550 int ret;
1551
1552 vos_ssr_protect(__func__);
1553 ret = __iw_get_name(dev, info, wrqu, extra);
1554 vos_ssr_unprotect(__func__);
1555
1556 return ret;
1557}
1558
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301559static int __iw_set_mode(struct net_device *dev,
1560 struct iw_request_info *info,
1561 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001562{
1563 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301564 hdd_adapter_t *pAdapter;
1565 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 tCsrRoamProfile *pRoamProfile;
1567 eCsrRoamBssType LastBSSType;
1568 eMib_dot11DesiredBssType connectedBssType;
1569 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301571 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001572
1573 ENTER();
1574
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301575 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 if (NULL == pAdapter)
1577 {
1578 hddLog(VOS_TRACE_LEVEL_WARN,
1579 "%s: Invalid context, pAdapter", __func__);
1580 return 0;
1581 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301582 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1583 status = wlan_hdd_validate_context(pHddCtx);
1584 if (0 != status)
1585 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301586 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 }
1588
1589 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1590 if (pWextState == NULL)
1591 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301592 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 return -EINVAL;
1594 }
1595
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 pRoamProfile = &pWextState->roamProfile;
1598 LastBSSType = pRoamProfile->BSSType;
1599
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301600 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001601
1602 switch (wrqu->mode)
1603 {
1604 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301605 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1607 // Set the phymode correctly for IBSS.
1608 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1609 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001610 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 break;
1613 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301614 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 break;
1618 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301619 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1621 break;
1622 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301623 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 return -EOPNOTSUPP;
1625 }
1626
1627 if ( LastBSSType != pRoamProfile->BSSType )
1628 {
1629 //the BSS mode changed
1630 // We need to issue disconnect if connected or in IBSS disconnect state
1631 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1632 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1633 {
1634 VOS_STATUS vosStatus;
1635 // need to issue a disconnect to CSR.
1636 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1637 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1638 pAdapter->sessionId,
1639 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1640 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301641 {
1642 long ret;
1643 ret = wait_for_completion_interruptible_timeout(
1644 &pAdapter->disconnect_comp_var,
1645 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1646 if (ret <= 0)
1647 hddLog(VOS_TRACE_LEVEL_ERROR,
1648 FL("failed wait on disconnect_comp_var %ld"), ret);
1649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 }
1651 }
1652
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 EXIT();
1654 return 0;
1655}
1656
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301657static int iw_set_mode(struct net_device *dev,
1658 struct iw_request_info *info,
1659 union iwreq_data *wrqu, char *extra)
1660{
1661 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001662
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301663 vos_ssr_protect(__func__);
1664 ret = __iw_set_mode(dev, info, wrqu, extra);
1665 vos_ssr_unprotect(__func__);
1666
1667 return ret;
1668}
1669
1670static int __iw_get_mode(struct net_device *dev,
1671 struct iw_request_info *info,
1672 union iwreq_data *wrqu,
1673 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001674{
1675
1676 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301677 hdd_adapter_t *pAdapter;
1678 hdd_context_t *pHddCtx;
1679 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001680
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301681 ENTER();
1682
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301683 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 if (NULL == pAdapter)
1685 {
1686 hddLog(VOS_TRACE_LEVEL_WARN,
1687 "%s: Invalid context, pAdapter", __func__);
1688 return 0;
1689 }
1690
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301691 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1692 ret = wlan_hdd_validate_context(pHddCtx);
1693 if (0 != ret)
1694 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301695 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1698 if (pWextState == NULL)
1699 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301700 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 return -EINVAL;
1702 }
1703
1704 switch (pWextState->roamProfile.BSSType)
1705 {
1706 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001707 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301708 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 break;
1710 case eCSR_BSS_TYPE_IBSS:
1711 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001712 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301713 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 break;
1715 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001716 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301717 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 break;
1719 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001720 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 break;
1722 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301723
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301724 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 return 0;
1726}
1727
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301728static int iw_get_mode(struct net_device *dev,
1729 struct iw_request_info *info,
1730 union iwreq_data *wrqu,
1731 char *extra)
1732{
1733 int ret;
1734
1735 vos_ssr_protect(__func__);
1736 ret = __iw_get_mode(dev, info, wrqu, extra);
1737 vos_ssr_unprotect(__func__);
1738
1739 return ret;
1740}
1741
1742static int __iw_set_freq(struct net_device *dev,
1743 struct iw_request_info *info,
1744 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001745{
1746 v_U32_t numChans = 0;
1747 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1748 v_U32_t indx = 0;
1749 v_U32_t status = 0;
1750
1751 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301752 hdd_adapter_t *pAdapter;
1753 hdd_context_t *pHddCtx;
1754 tHalHandle hHal;
1755 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301757
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 ENTER();
1759
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301760 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1761 if (NULL == pAdapter)
1762 {
1763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1764 "%s:Invalid Adapter",__func__);
1765 return -EINVAL;
1766 }
1767
1768 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1769 status = wlan_hdd_validate_context(pHddCtx);
1770 if (0 != status)
1771 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 return status;
1773 }
1774
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301775 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1776 if (NULL == hHal)
1777 {
1778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1779 "%s: Hal Context is NULL",__func__);
1780 return -EINVAL;
1781 }
1782
1783 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1784 if (NULL == pHddStaCtx)
1785 {
1786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1787 "%s:STA context is NULL",__func__);
1788 return -EINVAL;
1789 }
1790
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301792 if (NULL == pWextState)
1793 {
1794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1795 "%s: pWextState is NULL",__func__);
1796 return -EINVAL;
1797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001798
1799 pRoamProfile = &pWextState->roamProfile;
1800
Arif Hussain6d2a3322013-11-17 19:50:10 -08001801 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001802
1803 /* Link is up then return cant set channel*/
1804 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1805 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1806 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001807 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 return -EOPNOTSUPP;
1809 }
1810
1811 /* Settings by Frequency as input */
1812 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1813 (wrqu->freq.m <= (tANI_U32)5.825e8))
1814 {
1815 tANI_U32 freq = wrqu->freq.m / 100000;
1816
1817 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1818 indx++;
1819 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1820 {
1821 return -EINVAL;
1822 }
1823 wrqu->freq.e = 0;
1824 wrqu->freq.m = freq_chan_map[indx].chan;
1825
1826 }
1827
1828 if (wrqu->freq.e == 0)
1829 {
1830 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1831 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1832 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001833 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001834 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1836 return -EINVAL;
1837 }
1838
1839 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1840
1841 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1842 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1844 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 return -EIO;
1846 }
1847
1848 for (indx = 0; indx < numChans; indx++) {
1849 if (wrqu->freq.m == validChan[indx]){
1850 break;
1851 }
1852 }
1853 }
1854 else{
1855
1856 return -EINVAL;
1857 }
1858
1859 if(indx >= numChans)
1860 {
1861 return -EINVAL;
1862 }
1863
1864 /* Set the Operational Channel */
1865 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1866 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1867 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1868
Arif Hussain6d2a3322013-11-17 19:50:10 -08001869 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001870
1871 EXIT();
1872
1873 return status;
1874}
1875
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301876static int iw_set_freq(struct net_device *dev,
1877 struct iw_request_info *info,
1878 union iwreq_data *wrqu, char *extra)
1879{
1880 int ret;
1881
1882 vos_ssr_protect(__func__);
1883 ret = __iw_set_freq(dev, info, wrqu, extra);
1884 vos_ssr_unprotect(__func__);
1885
1886 return ret;
1887}
1888
1889static int __iw_get_freq(struct net_device *dev,
1890 struct iw_request_info *info,
1891 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001892{
Jeff Johnsone7245742012-09-05 17:12:55 -07001893 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301894 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 tHalHandle hHal;
1896 hdd_wext_state_t *pWextState;
1897 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301898 hdd_station_ctx_t *pHddStaCtx;
1899 hdd_context_t *pHddCtx;
1900 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001901
1902 ENTER();
1903
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301904 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1905 if (NULL == pAdapter)
1906 {
1907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1908 "%s: Adapter is NULL", __func__);
1909 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301911 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1912 ret = wlan_hdd_validate_context(pHddCtx);
1913 if (0 != ret)
1914 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301915 return ret;
1916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301918 if (NULL == hHal)
1919 {
1920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1921 "%s: Hal Context is NULL",__func__);
1922 return -EINVAL;
1923 }
1924 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1925 if (NULL == pHddStaCtx)
1926 {
1927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1928 "%s: HddStaCtx is NULL", __func__);
1929 return -EINVAL;
1930 }
1931 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1932 if (NULL == pWextState)
1933 {
1934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1935 "%s: pWextState is NULL",__func__);
1936 return -EINVAL;
1937 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 pRoamProfile = &pWextState->roamProfile;
1939
1940 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1941 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001942 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 {
c_hpothub8245442013-11-20 23:41:09 +05301944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1945 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 return -EIO;
1947 }
1948 else
1949 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001950 status = hdd_wlan_get_freq(channel, &freq);
1951 if( TRUE == status )
1952 {
1953 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1954 * iwlist & iwconfig command shows frequency into proper
1955 * format (2.412 GHz instead of 246.2 MHz)*/
1956 fwrq->m = freq;
1957 fwrq->e = MHZ;
1958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 }
1960 }
1961 else
1962 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001963 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1964 * iwlist & iwconfig command shows frequency into proper
1965 * format (2.412 GHz instead of 246.2 MHz)*/
1966 fwrq->m = 0;
1967 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301969
1970 EXIT();
1971 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001972}
1973
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301974static int iw_get_freq(struct net_device *dev,
1975 struct iw_request_info *info,
1976 struct iw_freq *fwrq, char *extra)
1977{
1978 int ret;
1979
1980 vos_ssr_protect(__func__);
1981 ret = __iw_get_freq(dev, info, fwrq, extra);
1982 vos_ssr_unprotect(__func__);
1983
1984 return ret;
1985}
1986
1987static int __iw_get_tx_power(struct net_device *dev,
1988 struct iw_request_info *info,
1989 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001990{
1991
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301992 hdd_adapter_t *pAdapter;
1993 hdd_context_t *pHddCtx;
1994 hdd_station_ctx_t *pHddStaCtx;
1995 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001996
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301997 ENTER();
1998
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301999 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2000 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2003 "%s: Adapter is NULL",__func__);
2004 return -EINVAL;
2005 }
2006 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2007 ret = wlan_hdd_validate_context(pHddCtx);
2008 if (0 != ret)
2009 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302010 return ret;
2011 }
2012
2013 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2014 if (NULL == pHddStaCtx)
2015 {
2016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2017 "%s: STA Context is NULL",__func__);
2018 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 }
2020
2021 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2022 {
2023 wrqu->txpower.value = 0;
2024 return 0;
2025 }
2026 wlan_hdd_get_classAstats(pAdapter);
2027 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2028
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302029 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 return 0;
2031}
2032
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302033static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 struct iw_request_info *info,
2035 union iwreq_data *wrqu, char *extra)
2036{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302037 int ret;
2038
2039 vos_ssr_protect(__func__);
2040 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2041 vos_ssr_unprotect(__func__);
2042
2043 return ret;
2044}
2045
2046static int __iw_set_tx_power(struct net_device *dev,
2047 struct iw_request_info *info,
2048 union iwreq_data *wrqu, char *extra)
2049{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302050 hdd_adapter_t *pAdapter;
2051 tHalHandle hHal;
2052 hdd_context_t *pHddCtx;
2053 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002054
2055 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302056 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2057 if (NULL == pAdapter)
2058 {
2059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2060 "%s: Adapter is NULL",__func__);
2061 return -EINVAL;
2062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302064 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2065 ret = wlan_hdd_validate_context(pHddCtx);
2066 if (0 != ret)
2067 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302068 return ret;
2069 }
2070
2071 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2072 if (NULL == hHal)
2073 {
2074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2075 "%s: Hal Context is NULL",__func__);
2076 return -EINVAL;
2077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2079 {
c_hpothub8245442013-11-20 23:41:09 +05302080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2081 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 return -EIO;
2083 }
2084
2085 EXIT();
2086
2087 return 0;
2088}
2089
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302090static int iw_set_tx_power(struct net_device *dev,
2091 struct iw_request_info *info,
2092 union iwreq_data *wrqu, char *extra)
2093{
2094 int ret;
2095
2096 vos_ssr_protect(__func__);
2097 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2098 vos_ssr_unprotect(__func__);
2099
2100 return ret;
2101}
2102
2103static int __iw_get_bitrate(struct net_device *dev,
2104 struct iw_request_info *info,
2105 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002106{
2107 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2108 eHalStatus status = eHAL_STATUS_SUCCESS;
2109 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302110 hdd_adapter_t *pAdapter;
2111 hdd_context_t *pHddCtx;
2112 hdd_station_ctx_t *pHddStaCtx;
2113 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002114
2115 ENTER();
2116
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302117 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2118 if (NULL == pAdapter)
2119 {
2120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2121 "%s: Adapter is NULL",__func__);
2122 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 }
2124
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302125 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2126 ret = wlan_hdd_validate_context(pHddCtx);
2127 if (0 != ret)
2128 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302129 return ret;
2130 }
2131
2132 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2133 if (NULL == pHddStaCtx)
2134 {
2135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2136 "%s: STA Context is NULL",__func__);
2137 return -EINVAL;
2138 }
2139
2140 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 wrqu->bitrate.value = 0;
2142 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302143 else
2144 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2146 SME_SUMMARY_STATS |
2147 SME_GLOBAL_CLASSA_STATS |
2148 SME_GLOBAL_CLASSB_STATS |
2149 SME_GLOBAL_CLASSC_STATS |
2150 SME_GLOBAL_CLASSD_STATS |
2151 SME_PER_STA_STATS,
2152 hdd_StatisticsCB, 0, FALSE,
2153 pHddStaCtx->conn_info.staId[0], pAdapter );
2154
2155 if(eHAL_STATUS_SUCCESS != status)
2156 {
2157 hddLog(VOS_TRACE_LEVEL_ERROR,
2158 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002159 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 return status;
2161 }
2162
2163 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302164 if (NULL == pWextState)
2165 {
2166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2167 "%s: pWextState is NULL",__func__);
2168 return -EINVAL;
2169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002170
2171 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2172
2173 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2174 {
2175 hddLog(VOS_TRACE_LEVEL_ERROR,
2176 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002177 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 return VOS_STATUS_E_FAILURE;
2179 }
2180
2181 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2182 }
2183
2184 EXIT();
2185
2186 return vos_status;
2187}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302188
2189static int iw_get_bitrate(struct net_device *dev,
2190 struct iw_request_info *info,
2191 union iwreq_data *wrqu, char *extra)
2192{
2193 int ret;
2194
2195 vos_ssr_protect(__func__);
2196 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2197 vos_ssr_unprotect(__func__);
2198
2199 return ret;
2200}
2201
2202
Jeff Johnson295189b2012-06-20 16:38:30 -07002203/* ccm call back function */
2204
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302205static int __iw_set_bitrate(struct net_device *dev,
2206 struct iw_request_info *info,
2207 union iwreq_data *wrqu,
2208 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002209{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302210 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302212 hdd_station_ctx_t *pHddStaCtx;
2213 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2215 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2216 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2217 v_U32_t i, rate;
2218 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302219 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002220
2221 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302222 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2223 if (NULL == pAdapter)
2224 {
2225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2226 "%s: Adapter is NULL",__func__);
2227 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 }
2229
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302230 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2231 ret = wlan_hdd_validate_context(pHddCtx);
2232 if (0 != ret)
2233 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302234 return ret;
2235 }
2236
2237 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2238 if (NULL == pHddStaCtx)
2239 {
2240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2241 "%s: STA Context is NULL",__func__);
2242 return -EINVAL;
2243 }
2244
2245
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302247 if (NULL == pWextState)
2248 {
2249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2250 "%s: pWextState is NULL",__func__);
2251 return -EINVAL;
2252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002253
2254 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2255 {
2256 return -ENXIO ;
2257 }
2258
2259 rate = wrqu->bitrate.value;
2260
2261 if (rate == -1)
2262 {
2263 rate = WNI_CFG_FIXED_RATE_AUTO;
2264 valid_rate = TRUE;
2265 }
2266 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2267 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2268 {
2269 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2270 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2271 {
2272 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2273 WNI_CFG_SUPPORTED_RATES_11A,
2274 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2275 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2276 WNI_CFG_SUPPORTED_RATES_11B,
2277 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2278 {
2279 for (i = 0; i < (b_len + a_len); ++i)
2280 {
2281 /* supported rates returned is double the actual rate so we divide it by 2 */
2282 if ((supp_rates[i]&0x7F)/2 == rate)
2283 {
2284 valid_rate = TRUE;
2285 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2286 break;
2287 }
2288 }
2289 }
2290 }
2291 }
2292 if (valid_rate != TRUE)
2293 {
2294 return -EINVAL;
2295 }
2296 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2297 WNI_CFG_FIXED_RATE, rate,
2298 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2299 {
c_hpothub8245442013-11-20 23:41:09 +05302300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2301 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 return -EIO;
2303 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302304
2305 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 return 0;
2307}
2308
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302309static int iw_set_bitrate(struct net_device *dev,
2310 struct iw_request_info *info,
2311 union iwreq_data *wrqu,
2312 char *extra)
2313{
2314 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002315
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302316 vos_ssr_protect(__func__);
2317 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2318 vos_ssr_unprotect(__func__);
2319
2320 return ret;
2321}
2322
2323static int __iw_set_genie(struct net_device *dev,
2324 struct iw_request_info *info,
2325 union iwreq_data *wrqu,
2326 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002327{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302328 hdd_adapter_t *pAdapter;
2329 hdd_context_t *pHddCtx;
2330 hdd_wext_state_t *pWextState;
2331 u_int8_t *genie = NULL;
2332 u_int8_t *base_genie = NULL;
2333 v_U16_t remLen;
2334 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002335
2336 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002337
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302338 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2339 if (NULL == pAdapter)
2340 {
2341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2342 "%s: Adapter is NULL",__func__);
2343 return -EINVAL;
2344 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002345
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302346 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2347 ret = wlan_hdd_validate_context(pHddCtx);
2348 if (0 != ret)
2349 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302350 return ret;
2351 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002352
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302353 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2354 if (NULL == pWextState)
2355 {
2356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2357 "%s: pWextState is NULL",__func__);
2358 return -EINVAL;
2359 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002360
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302361 if (!wrqu->data.length) {
2362 hdd_clearRoamProfileIe(pAdapter);
2363 EXIT();
2364 return 0;
2365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002366
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302367 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2368 wrqu->data.length);
2369 if (NULL == base_genie)
2370 {
2371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2372 "mem_alloc_copy_from_user_helper fail");
2373 return -ENOMEM;
2374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002375
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302376 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002377
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302378 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002379
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302380 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2381
2382 /* clear any previous genIE before this call */
2383 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2384
2385 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 {
2387 v_U16_t eLen = 0;
2388 v_U8_t elementId;
2389 elementId = *genie++;
2390 eLen = *genie++;
2391 remLen -= 2;
2392
Arif Hussain6d2a3322013-11-17 19:50:10 -08002393 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 __func__, elementId, eLen);
2395
2396 switch ( elementId )
2397 {
2398 case IE_EID_VENDOR:
2399 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002400 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302401 ret = -EINVAL;
2402 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002404
2405 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2406 {
2407 v_U16_t curGenIELen = pWextState->genIE.length;
2408 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2409 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2410
2411 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2412 {
2413 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002414 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302416 ret = -EINVAL;
2417 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002418 }
2419 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2420 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2421 pWextState->genIE.length += eLen + 2;
2422 }
2423 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2424 {
2425 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302426 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2427 {
2428 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2429 "Need bigger buffer space");
2430 ret = -EINVAL;
2431 VOS_ASSERT(0);
2432 goto exit;
2433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2435 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2436 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2437 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2438 }
2439 else /* any vendorId except WPA IE should be accumulated to genIE */
2440 {
2441 v_U16_t curGenIELen = pWextState->genIE.length;
2442 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2443 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2444
2445 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2446 {
2447 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002448 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302450 ret = -ENOMEM;
2451 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 }
2453 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2454 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2455 pWextState->genIE.length += eLen + 2;
2456 }
2457 break;
2458 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002459 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302460 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2461 {
2462 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2463 "Need bigger buffer space");
2464 ret = -EINVAL;
2465 VOS_ASSERT(0);
2466 goto exit;
2467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2469 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2470 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2471 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2472 break;
2473
2474 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002475 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302476 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 }
2478 genie += eLen;
2479 remLen -= eLen;
2480 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302481
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302482exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002484 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302485 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002486}
2487
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302488static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 struct iw_request_info *info,
2490 union iwreq_data *wrqu,
2491 char *extra)
2492{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302493 int ret;
2494
2495 vos_ssr_protect(__func__);
2496 ret = __iw_set_genie(dev, info, wrqu, extra);
2497 vos_ssr_unprotect(__func__);
2498
2499 return ret;
2500}
2501
2502static int __iw_get_genie(struct net_device *dev,
2503 struct iw_request_info *info,
2504 union iwreq_data *wrqu,
2505 char *extra)
2506{
Jeff Johnson295189b2012-06-20 16:38:30 -07002507 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302508 hdd_context_t *pHddCtx;
2509 hdd_adapter_t *pAdapter;
2510 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 eHalStatus status;
2512 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2513 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2514
2515 ENTER();
2516
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302517 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2518 if (NULL == pAdapter)
2519 {
2520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2521 "%s: Adapter is NULL",__func__);
2522 return -EINVAL;
2523 }
2524 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2525 status = wlan_hdd_validate_context(pHddCtx);
2526 if (0 != status)
2527 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302528 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 }
2530
Jeff Johnson295189b2012-06-20 16:38:30 -07002531 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302532 if (NULL == pWextState)
2533 {
2534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2535 "%s: pWextState is NULL",__func__);
2536 return -EINVAL;
2537 }
2538
2539 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2540 if (NULL == pHddStaCtx)
2541 {
2542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2543 "%s: STA Context is NULL",__func__);
2544 return -EINVAL;
2545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002546
2547 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2548 {
2549 return -ENXIO;
2550 }
2551
2552 // Return something ONLY if we are associated with an RSN or WPA network
2553 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2554 pWextState->roamProfile.negotiatedAuthType))
2555 {
2556 return -ENXIO;
2557 }
2558
2559 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2560 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2561 pAdapter->sessionId,
2562 &length,
2563 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002564 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2565 if (wrqu->data.length < length)
2566 {
2567 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2568 return -EFAULT;
2569 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002570 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002571 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002572
Arif Hussain6d2a3322013-11-17 19:50:10 -08002573 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002574
2575 EXIT();
2576
2577 return 0;
2578}
2579
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302580static int iw_get_genie(struct net_device *dev,
2581 struct iw_request_info *info,
2582 union iwreq_data *wrqu,
2583 char *extra)
2584{
2585 int ret;
2586
2587 vos_ssr_protect(__func__);
2588 ret = __iw_get_genie(dev, info, wrqu, extra);
2589 vos_ssr_unprotect(__func__);
2590
2591 return ret;
2592}
2593
2594
2595static int __iw_get_encode(struct net_device *dev,
2596 struct iw_request_info *info,
2597 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002598{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302599 hdd_adapter_t *pAdapter;
2600 hdd_context_t *pHddCtx;
2601 hdd_wext_state_t *pWextState;
2602 tCsrRoamProfile *pRoamProfile;
2603 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002605
2606 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302607 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2608 if (NULL == pAdapter)
2609 {
2610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2611 "%s: Adapter is NULL",__func__);
2612 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 }
2614
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302615 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2616 ret = wlan_hdd_validate_context(pHddCtx);
2617 if (0 != ret)
2618 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302619 return ret;
2620 }
2621 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2622 if (NULL == pWextState)
2623 {
2624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2625 "%s: pWextState is NULL",__func__);
2626 return -EINVAL;
2627 }
2628
2629 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 keyId = pRoamProfile->Keys.defaultIndex;
2631
2632 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2633 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002634 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 return -EINVAL;
2636 }
2637
2638 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2639 {
2640 dwrq->flags |= IW_ENCODE_ENABLED;
2641 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2642 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2643
2644 dwrq->flags |= (keyId + 1);
2645
2646 }
2647 else
2648 {
2649 dwrq->flags |= IW_ENCODE_DISABLED;
2650 }
2651
2652 for(i=0; i < MAX_WEP_KEYS; i++)
2653 {
2654 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2655 {
2656 continue;
2657 }
2658 else
2659 {
2660 break;
2661 }
2662 }
2663
2664 if(MAX_WEP_KEYS == i)
2665 {
2666 dwrq->flags |= IW_ENCODE_NOKEY;
2667 }
2668
2669 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2670
2671 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2672 {
2673 dwrq->flags |= IW_ENCODE_OPEN;
2674 }
2675 else
2676 {
2677 dwrq->flags |= IW_ENCODE_RESTRICTED;
2678 }
2679 EXIT();
2680 return 0;
2681}
2682
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302683static int iw_get_encode(struct net_device *dev,
2684 struct iw_request_info *info,
2685 struct iw_point *dwrq, char *extra)
2686{
2687 int ret;
2688
2689 vos_ssr_protect(__func__);
2690 ret = __iw_get_encode(dev, info, dwrq, extra);
2691 vos_ssr_unprotect(__func__);
2692
2693 return ret;
2694}
2695
Jeff Johnson295189b2012-06-20 16:38:30 -07002696#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2697#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2698
2699
2700/*
2701 * This function sends a single 'key' to LIM at all time.
2702 */
2703
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302704static int __iw_get_rts_threshold(struct net_device *dev,
2705 struct iw_request_info *info,
2706 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002707{
2708 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2709 v_U32_t status = 0;
2710
2711 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2712
2713 return status;
2714}
2715
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302716static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 struct iw_request_info *info,
2718 union iwreq_data *wrqu, char *extra)
2719{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302720 int ret;
2721
2722 vos_ssr_protect(__func__);
2723 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2724 vos_ssr_unprotect(__func__);
2725
2726 return ret;
2727}
2728
2729static int __iw_set_rts_threshold(struct net_device *dev,
2730 struct iw_request_info *info,
2731 union iwreq_data *wrqu, char *extra)
2732{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302733 hdd_adapter_t *pAdapter;
2734 hdd_context_t *pHddCtx;
2735 tHalHandle hHal;
2736 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002737
2738 ENTER();
2739
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302740 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2741 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002742 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2744 "%s: Adapter is NULL",__func__);
2745 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002746 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302747
2748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2749 ret = wlan_hdd_validate_context(pHddCtx);
2750 if (0 != ret)
2751 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302752 return ret;
2753 }
2754
2755 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2756 if (NULL == hHal)
2757 {
2758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2759 "%s: Hal Context is NULL",__func__);
2760 return -EINVAL;
2761 }
2762
Jeff Johnson295189b2012-06-20 16:38:30 -07002763 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2764 {
2765 return -EINVAL;
2766 }
2767
2768 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2769 {
c_hpothub8245442013-11-20 23:41:09 +05302770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2771 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 return -EIO;
2773 }
2774
2775 EXIT();
2776
2777 return 0;
2778}
2779
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302780static int iw_set_rts_threshold(struct net_device *dev,
2781 struct iw_request_info *info,
2782 union iwreq_data *wrqu, char *extra)
2783{
2784 int ret;
2785
2786 vos_ssr_protect(__func__);
2787 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2788 vos_ssr_unprotect(__func__);
2789
2790 return ret;
2791}
2792
2793static int __iw_get_frag_threshold(struct net_device *dev,
2794 struct iw_request_info *info,
2795 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002796{
2797 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2798 v_U32_t status = 0;
2799
2800 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2801
2802 return status;
2803}
2804
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302805static int iw_get_frag_threshold(struct net_device *dev,
2806 struct iw_request_info *info,
2807 union iwreq_data *wrqu, char *extra)
2808{
2809 int ret;
2810
2811 vos_ssr_protect(__func__);
2812 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2813 vos_ssr_unprotect(__func__);
2814
2815 return ret;
2816}
2817
2818static int __iw_set_frag_threshold(struct net_device *dev,
2819 struct iw_request_info *info,
2820 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002821{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302822 hdd_adapter_t *pAdapter;
2823 hdd_context_t *pHddCtx;
2824 tHalHandle hHal;
2825 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002826
2827 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302828 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2829 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002830 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2832 "%s: Adapter is NULL",__func__);
2833 return -EINVAL;
2834 }
2835
2836 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2837 ret = wlan_hdd_validate_context(pHddCtx);
2838 if (0 != ret)
2839 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302840 return ret;
2841 }
2842
2843 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2844 if (NULL == hHal)
2845 {
2846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2847 "%s: Hal Context is NULL",__func__);
2848 return -EINVAL;
2849 }
2850
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2852 {
2853 return -EINVAL;
2854 }
2855
2856 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2857 {
c_hpothub8245442013-11-20 23:41:09 +05302858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2859 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 return -EIO;
2861 }
2862
2863 EXIT();
2864
2865 return 0;
2866}
2867
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302868static int iw_set_frag_threshold(struct net_device *dev,
2869 struct iw_request_info *info,
2870 union iwreq_data *wrqu, char *extra)
2871{
2872 int ret;
2873
2874 vos_ssr_protect(__func__);
2875 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2876 vos_ssr_unprotect(__func__);
2877
2878 return ret;
2879}
2880
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302881static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 struct iw_request_info *info,
2883 union iwreq_data *wrqu, char *extra)
2884{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302885 hdd_adapter_t *pAdapter;
2886 hdd_context_t *pHddCtx;
2887 int ret = 0;
2888
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302890 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2891 if (NULL == pAdapter)
2892 {
2893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2894 "%s: Adapter is NULL",__func__);
2895 return -EINVAL;
2896 }
2897 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2898 ret = wlan_hdd_validate_context(pHddCtx);
2899 if (0 != ret)
2900 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302901 return ret;
2902 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302903
2904 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 return -EOPNOTSUPP;
2906}
2907
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302908static int iw_get_power_mode(struct net_device *dev,
2909 struct iw_request_info *info,
2910 union iwreq_data *wrqu, char *extra)
2911{
2912 int ret;
2913
2914 vos_ssr_protect(__func__);
2915 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2916 vos_ssr_unprotect(__func__);
2917
2918 return ret;
2919}
2920static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 struct iw_request_info *info,
2922 union iwreq_data *wrqu, char *extra)
2923{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302924 hdd_adapter_t *pAdapter;
2925 hdd_context_t *pHddCtx;
2926 int ret = 0;
2927
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302929 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2930 if (NULL == pAdapter)
2931 {
2932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2933 "%s: Adapter is NULL",__func__);
2934 return -EINVAL;
2935 }
2936 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2937 ret = wlan_hdd_validate_context(pHddCtx);
2938 if (0 != ret)
2939 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302940 return ret;
2941 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302942
2943 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 return -EOPNOTSUPP;
2945}
2946
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302947static int iw_set_power_mode(struct net_device *dev,
2948 struct iw_request_info *info,
2949 union iwreq_data *wrqu, char *extra)
2950{
2951 int ret;
2952
2953 vos_ssr_protect(__func__);
2954 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2955 vos_ssr_unprotect(__func__);
2956
2957 return ret;
2958}
2959
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302960static int __iw_get_range(struct net_device *dev,
2961 struct iw_request_info *info,
2962 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002963{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302964 hdd_adapter_t *pAdapter;
2965 tHalHandle hHal;
2966 hdd_context_t *pHddCtx;
2967 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 struct iw_range *range = (struct iw_range *) extra;
2969
2970 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2971
2972 v_U32_t num_channels = sizeof(channels);
2973 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2974 v_U32_t a_len;
2975 v_U32_t b_len;
2976 v_U32_t active_phy_mode = 0;
2977 v_U8_t index = 0, i;
2978
2979 ENTER();
2980
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302981 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2982 if (NULL == pAdapter)
2983 {
2984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2985 "%s: pAdapter is NULL", __func__);
2986 return -EINVAL;
2987 }
2988 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2989 ret = wlan_hdd_validate_context(pHddCtx);
2990 if (0 != ret)
2991 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302992 return ret;
2993 }
2994 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2995 if (NULL == hHal)
2996 {
2997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2998 "%s: pAdapter is NULL", __func__);
2999 return -EINVAL;
3000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 wrqu->data.length = sizeof(struct iw_range);
3002 memset(range, 0, sizeof(struct iw_range));
3003
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 /*Get the phy mode*/
3005 if (ccmCfgGetInt(hHal,
3006 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3007 {
3008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003009 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003010
3011 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3012 {
3013 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003014 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 if (ccmCfgGetStr(hHal,
3016 WNI_CFG_SUPPORTED_RATES_11A,
3017 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3018 {
3019 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3020 {
3021 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3022 }
3023 for (i = 0; i < a_len; i++)
3024 {
3025 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3026 }
3027 range->num_bitrates = a_len;
3028 }
3029 else
3030 {
3031 return -EIO;
3032 }
3033 }
3034 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3035 {
3036 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003037 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 if (ccmCfgGetStr(hHal,
3039 WNI_CFG_SUPPORTED_RATES_11B,
3040 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3041 {
3042 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3043 {
3044 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3045 }
3046 for (i = 0; i < b_len; i++)
3047 {
3048 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3049 }
3050 range->num_bitrates = b_len;
3051 }
3052 else
3053 {
3054 return -EIO;
3055 }
3056 }
3057 }
3058
3059 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3060 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3061 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3062
3063 range->encoding_size[0] = 5;
3064 range->encoding_size[1] = 13;
3065 range->num_encoding_sizes = 2;
3066 range->max_encoding_tokens = MAX_WEP_KEYS;
3067
3068 // we support through Wireless Extensions 22
3069 range->we_version_compiled = WIRELESS_EXT;
3070 range->we_version_source = 22;
3071
3072 /*Supported Channels and Frequencies*/
3073 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3074 {
c_hpothub8245442013-11-20 23:41:09 +05303075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3076 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 return -EIO;
3078 }
3079 if (num_channels > IW_MAX_FREQUENCIES)
3080 {
3081 num_channels = IW_MAX_FREQUENCIES;
3082 }
3083
3084 range->num_channels = num_channels;
3085 range->num_frequency = num_channels;
3086
3087 for (index=0; index < num_channels; index++)
3088 {
3089 v_U32_t frq_indx = 0;
3090
3091 range->freq[index].i = channels[index];
3092 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3093 {
3094 if(channels[index] == freq_chan_map[frq_indx].chan)
3095 {
3096 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3097 range->freq[index].e = 1;
3098 break;
3099 }
3100 frq_indx++;
3101 }
3102 }
3103
3104 /* Event capability (kernel + driver) */
3105 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3106 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3107 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3108 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3109
3110 /*Encryption capability*/
3111 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3112 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3113
3114 /* Txpower capability */
3115 range->txpower_capa = IW_TXPOW_MWATT;
3116
3117 /*Scanning capability*/
3118 #if WIRELESS_EXT >= 22
3119 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3120 #endif
3121
3122 EXIT();
3123 return 0;
3124}
3125
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303126static int iw_get_range(struct net_device *dev,
3127 struct iw_request_info *info,
3128 union iwreq_data *wrqu, char *extra)
3129{
3130 int ret;
3131
3132 vos_ssr_protect(__func__);
3133 ret = __iw_get_range(dev, info, wrqu, extra);
3134 vos_ssr_unprotect(__func__);
3135
3136 return ret;
3137}
3138
Jeff Johnson295189b2012-06-20 16:38:30 -07003139/* Callback function registered with PMC to know status of PMC request */
3140static void iw_power_callback_fn (void *pContext, eHalStatus status)
3141{
3142 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003143
3144 if (NULL == pContext)
3145 {
3146 hddLog(VOS_TRACE_LEVEL_ERROR,
3147 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003148 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 return;
3150 }
3151
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003153
Jeff Johnson72a40512013-12-19 10:14:15 -08003154 /* there is a race condition that exists between this callback
3155 function and the caller since the caller could time out either
3156 before or while this code is executing. we use a spinlock to
3157 serialize these actions */
3158 spin_lock(&hdd_context_lock);
3159
3160 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 {
3162 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003163 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003165 "%s: Invalid context, magic [%08x]",
3166 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003167
3168 if (ioctl_debug)
3169 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003170 pr_info("%s: Invalid context, magic [%08x]\n",
3171 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003172 }
3173 return;
3174 }
3175
Jeff Johnson72a40512013-12-19 10:14:15 -08003176 /* context is valid so caller is still waiting */
3177
3178 /* paranoia: invalidate the magic */
3179 pStatsContext->magic = 0;
3180
3181 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003183
3184 /* serialization is complete */
3185 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003186}
3187
3188/* Callback function for tx per hit */
3189void hdd_tx_per_hit_cb (void *pCallbackContext)
3190{
3191 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3192 unsigned char tx_fail[16];
3193 union iwreq_data wrqu;
3194
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303195 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003197 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 return;
3199 }
3200 memset(&wrqu, 0, sizeof(wrqu));
3201 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3202 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3203}
3204
3205void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3206{
3207 struct statsContext *pStatsContext;
3208 tCsrGlobalClassAStatsInfo *pClassAStats;
3209 hdd_adapter_t *pAdapter;
3210
3211 if (ioctl_debug)
3212 {
3213 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003214 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 }
3216
3217 if ((NULL == pStats) || (NULL == pContext))
3218 {
3219 hddLog(VOS_TRACE_LEVEL_ERROR,
3220 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003221 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 return;
3223 }
3224
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 pClassAStats = pStats;
3226 pStatsContext = pContext;
3227 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003228
3229 /* there is a race condition that exists between this callback
3230 function and the caller since the caller could time out either
3231 before or while this code is executing. we use a spinlock to
3232 serialize these actions */
3233 spin_lock(&hdd_context_lock);
3234
Jeff Johnson295189b2012-06-20 16:38:30 -07003235 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3236 {
3237 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003238 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 hddLog(VOS_TRACE_LEVEL_WARN,
3240 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003241 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 if (ioctl_debug)
3243 {
3244 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003245 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 }
3247 return;
3248 }
3249
Jeff Johnson72a40512013-12-19 10:14:15 -08003250 /* context is valid so caller is still waiting */
3251
3252 /* paranoia: invalidate the magic */
3253 pStatsContext->magic = 0;
3254
3255 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3257
Jeff Johnson72a40512013-12-19 10:14:15 -08003258 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003260
3261 /* serialization is complete */
3262 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003263}
3264
3265VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3266{
3267 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3268 eHalStatus hstatus;
3269 long lrc;
3270 struct statsContext context;
3271
3272 if (NULL == pAdapter)
3273 {
3274 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3275 return VOS_STATUS_E_FAULT;
3276 }
3277 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3278 {
3279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3280 return VOS_STATUS_SUCCESS;
3281 }
3282
3283 /* we are connected
3284 prepare our callback context */
3285 init_completion(&context.completion);
3286 context.pAdapter = pAdapter;
3287 context.magic = STATS_CONTEXT_MAGIC;
3288 /* query only for Class A statistics (which include link speed) */
3289 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3290 eCSR_HDD,
3291 SME_GLOBAL_CLASSA_STATS,
3292 hdd_GetClassA_statisticsCB,
3293 0, // not periodic
3294 FALSE, //non-cached results
3295 pHddStaCtx->conn_info.staId[0],
3296 &context);
3297 if (eHAL_STATUS_SUCCESS != hstatus)
3298 {
3299 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003300 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003301 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 /* we'll returned a cached value below */
3303 }
3304 else
3305 {
3306 /* request was sent -- wait for the response */
3307 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3308 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 if (lrc <= 0)
3310 {
3311 hddLog(VOS_TRACE_LEVEL_ERROR,
3312 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003313 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 }
3315 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003316
3317 /* either we never sent a request, we sent a request and received a
3318 response or we sent a request and timed out. if we never sent a
3319 request or if we sent a request and got a response, we want to
3320 clear the magic out of paranoia. if we timed out there is a
3321 race condition such that the callback function could be
3322 executing at the same time we are. of primary concern is if the
3323 callback function had already verified the "magic" but had not
3324 yet set the completion variable when a timeout occurred. we
3325 serialize these activities by invalidating the magic while
3326 holding a shared spinlock which will cause us to block if the
3327 callback is currently executing */
3328 spin_lock(&hdd_context_lock);
3329 context.magic = 0;
3330 spin_unlock(&hdd_context_lock);
3331
3332 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 return VOS_STATUS_SUCCESS;
3334}
3335
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003336static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3337{
3338 struct statsContext *pStatsContext;
3339 tCsrSummaryStatsInfo *pSummaryStats;
3340 tCsrGlobalClassAStatsInfo *pClassAStats;
3341 hdd_adapter_t *pAdapter;
3342
3343 if (ioctl_debug)
3344 {
3345 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003346 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003347 }
3348
3349 if ((NULL == pStats) || (NULL == pContext))
3350 {
3351 hddLog(VOS_TRACE_LEVEL_ERROR,
3352 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003353 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003354 return;
3355 }
3356
Jeff Johnson72a40512013-12-19 10:14:15 -08003357 /* there is a race condition that exists between this callback
3358 function and the caller since the caller could time out either
3359 before or while this code is executing. we use a spinlock to
3360 serialize these actions */
3361 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003362
3363 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3364 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3365 pStatsContext = pContext;
3366 pAdapter = pStatsContext->pAdapter;
3367 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3368 {
3369 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003370 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003371 hddLog(VOS_TRACE_LEVEL_WARN,
3372 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003373 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003374 if (ioctl_debug)
3375 {
3376 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003377 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003378 }
3379 return;
3380 }
3381
Jeff Johnson72a40512013-12-19 10:14:15 -08003382 /* context is valid so caller is still waiting */
3383
3384 /* paranoia: invalidate the magic */
3385 pStatsContext->magic = 0;
3386
3387 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003388 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3389 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3390
Jeff Johnson72a40512013-12-19 10:14:15 -08003391 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003392 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003393
3394 /* serialization is complete */
3395 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003396}
3397
3398VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3399{
3400 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3401 eHalStatus hstatus;
3402 long lrc;
3403 struct statsContext context;
3404
3405 if (NULL == pAdapter)
3406 {
3407 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3408 return VOS_STATUS_SUCCESS;
3409 }
3410
3411 /* we are connected
3412 prepare our callback context */
3413 init_completion(&context.completion);
3414 context.pAdapter = pAdapter;
3415 context.magic = STATS_CONTEXT_MAGIC;
3416
3417 /* query only for Summary & Class A statistics */
3418 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3419 eCSR_HDD,
3420 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303421 SME_GLOBAL_CLASSA_STATS |
3422 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003423 hdd_get_station_statisticsCB,
3424 0, // not periodic
3425 FALSE, //non-cached results
3426 pHddStaCtx->conn_info.staId[0],
3427 &context);
3428 if (eHAL_STATUS_SUCCESS != hstatus)
3429 {
3430 hddLog(VOS_TRACE_LEVEL_ERROR,
3431 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003432 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003433 /* we'll return with cached values */
3434 }
3435 else
3436 {
3437 /* request was sent -- wait for the response */
3438 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3439 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003440
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003441 if (lrc <= 0)
3442 {
3443 hddLog(VOS_TRACE_LEVEL_ERROR,
3444 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003445 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003446 }
3447 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003448
3449 /* either we never sent a request, we sent a request and received a
3450 response or we sent a request and timed out. if we never sent a
3451 request or if we sent a request and got a response, we want to
3452 clear the magic out of paranoia. if we timed out there is a
3453 race condition such that the callback function could be
3454 executing at the same time we are. of primary concern is if the
3455 callback function had already verified the "magic" but had not
3456 yet set the completion variable when a timeout occurred. we
3457 serialize these activities by invalidating the magic while
3458 holding a shared spinlock which will cause us to block if the
3459 callback is currently executing */
3460 spin_lock(&hdd_context_lock);
3461 context.magic = 0;
3462 spin_unlock(&hdd_context_lock);
3463
3464 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003465 return VOS_STATUS_SUCCESS;
3466}
3467
3468
Jeff Johnson295189b2012-06-20 16:38:30 -07003469/*
3470 * Support for the LINKSPEED private command
3471 * Per the WiFi framework the response must be of the form
3472 * "LinkSpeed xx"
3473 */
3474static int iw_get_linkspeed(struct net_device *dev,
3475 struct iw_request_info *info,
3476 union iwreq_data *wrqu, char *extra)
3477{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303478 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303479 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303481 int len = sizeof(v_U32_t) + 1;
3482 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303483 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303484 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303485 int rc, valid = 0;
3486
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303487 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303488 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3489 if (NULL == pAdapter)
3490 {
3491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3492 "%s: Adapter is NULL",__func__);
3493 return -EINVAL;
3494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003495
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303496 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303497 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303498 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003499 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303500 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003501 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303502 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3503 if (NULL == pHddStaCtx)
3504 {
3505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3506 "%s: STA Context is NULL",__func__);
3507 return -EINVAL;
3508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3510 {
3511 /* we are not connected so we don't have a classAstats */
3512 link_speed = 0;
3513 }
3514 else
3515 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303516 status = wlan_hdd_get_classAstats(pAdapter);
3517
3518 if (!VOS_IS_STATUS_SUCCESS(status ))
3519 {
3520 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3521 return -EINVAL;
3522 }
3523
3524 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3525 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3526 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3527 &link_speed);
3528
3529 link_speed = link_speed / 10;
3530
3531 if (0 == link_speed)
3532 {
3533 /* The linkspeed returned by HAL is in units of 500kbps.
3534 * converting it to mbps.
3535 * This is required to support legacy firmware which does
3536 * not return link capacity.
3537 */
3538 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3539 }
3540
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 }
3542
3543 wrqu->data.length = len;
3544 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003545 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 if ((rc < 0) || (rc >= len))
3547 {
3548 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303549 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 return -EIO;
3551 }
3552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303553 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003555 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003556}
3557
Arif Hussain695279c2014-03-24 14:06:07 -07003558/*
3559 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3560 *
3561 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303562static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003563 struct iw_request_info *info,
3564 union iwreq_data *wrqu, char *extra)
3565{
3566 int rc;
3567
3568 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3569
3570 if (rc < 0)
3571 return rc;
3572
3573 /* a value is being successfully returned */
3574 return 0;
3575}
Jeff Johnson295189b2012-06-20 16:38:30 -07003576
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303577static int iw_get_linkspeed_priv(struct net_device *dev,
3578 struct iw_request_info *info,
3579 union iwreq_data *wrqu, char *extra)
3580{
3581 int ret;
3582
3583 vos_ssr_protect(__func__);
3584 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3585 vos_ssr_unprotect(__func__);
3586
3587 return ret;
3588}
3589
Jeff Johnson295189b2012-06-20 16:38:30 -07003590/*
3591 * Support for the RSSI & RSSI-APPROX private commands
3592 * Per the WiFi framework the response must be of the form
3593 * "<ssid> rssi <xx>"
3594 * unless we are not associated, in which case the response is
3595 * "OK"
3596 */
3597static int iw_get_rssi(struct net_device *dev,
3598 struct iw_request_info *info,
3599 union iwreq_data *wrqu, char *extra)
3600{
3601 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003602 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 int len = wrqu->data.length;
3604 v_S7_t s7Rssi = 0;
3605 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3606 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3607 VOS_STATUS vosStatus;
3608 int rc;
3609
3610 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3611 (0 == ssidlen) || (ssidlen >= len))
3612 {
3613 /* we are not connected or our SSID is too long
3614 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003615 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 }
3617 else
3618 {
3619 /* we are connected with a valid SSID
3620 so we can write the SSID into the return buffer
3621 (note that it is not NUL-terminated) */
3622 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3623
3624 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3625
3626 if (VOS_STATUS_SUCCESS == vosStatus)
3627 {
3628 /* append the rssi to the ssid in the format required by
3629 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003630 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303631 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 }
3633 else
3634 {
3635 rc = -1;
3636 }
3637 }
3638
3639 /* verify that we wrote a valid response */
3640 if ((rc < 0) || (rc >= len))
3641 {
3642 // encoding or length error?
3643 hddLog(VOS_TRACE_LEVEL_ERROR,
3644 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003645 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 return -EIO;
3647 }
3648
3649 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003650 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003651}
3652
3653/*
3654 * Support for SoftAP channel range private command
3655 */
3656static int iw_softap_set_channel_range( struct net_device *dev,
3657 int startChannel,
3658 int endChannel,
3659 int band)
3660{
Jeff Johnson43971f52012-07-17 12:26:56 -07003661 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 int ret = 0;
3663 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3664 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003665 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3666
Jeff Johnson295189b2012-06-20 16:38:30 -07003667
3668 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3669 if (VOS_STATUS_SUCCESS != status)
3670 {
3671 ret = -EINVAL;
3672 }
Yathish9f22e662012-12-10 14:21:35 -08003673 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 return ret;
3675}
3676
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303677static uint8 chartohex(char c)
3678{
3679 uint8 val = 0;
3680 if (c >= '0' && c <= '9')
3681 val = c - '0';
3682 else if (c >= 'a' && c <= 'f')
3683 val = c - 'a' + 10;
3684 else if (c >= 'A' && c <= 'F')
3685 val = c - 'A' + 10;
3686 else
3687 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3688
3689 return val;
3690}
3691
3692uint8 getByte(char **buf)
3693{
3694 uint8 byte = 0;
3695 char *temp = *buf;
3696 byte = chartohex(*temp) * 16;
3697 temp++;
3698 byte += chartohex(*temp);
3699 temp++;
3700 *buf = temp;
3701 return byte;
3702}
3703
3704static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3705{
3706 tSir80211Header *macHeader;
3707 int i = 0, j = 0, length = 0;
3708 uint8 byte = 0;
3709 char *temp = pBuffer;
3710 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303711 char *pHeader;
3712 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303713
3714 macHeader = &pkt->macHeader;
3715
3716 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3717
3718 temp++;
3719
3720 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3721 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3722 pkt->encParams.keyParams.key[0].keyId);
3723
3724 for (i = 0; i< 16; i++) {
3725 pkt->encParams.keyParams.key[0].key[i]
3726 = getByte(&temp);
3727 }
3728
3729 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3730 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3731
3732 for (i = 0; i< 6; i++) {
3733 pkt->encParams.pn[i]
3734 = getByte(&temp);
3735 }
3736
3737 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3738 &pkt->encParams.pn[0], 6, 0);
3739
3740 for (i = 0, j= 5; i< 3; i++, j--) {
3741 byte = pkt->encParams.pn[i];
3742 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3743 pkt->encParams.pn[j] = byte;
3744 }
3745
3746 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303747 if (length > sizeof(tSir80211Header))
3748 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303749
Srinivas Dasari2382de62015-01-22 15:00:04 +05303750 pHeader = temp;
3751 vos_mem_zero(&header, sizeof(tSir80211Header));
3752 for (i = 0; i < length; i++) {
3753 *((uint8 *)&header + i) = getByte(&pHeader);
3754 }
3755
3756 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3757 (char *)&header, length, 0);
3758
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303759 byte = getByte(&temp);
3760
3761 macHeader->frameCtrl.protVer = byte & 0x3;
3762 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3763 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3764
3765 byte = getByte(&temp);
3766 macHeader->frameCtrl.toDS = (byte) & 0x1;
3767 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3768 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3769 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3770 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3771 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3772 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3773 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3774
3775 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3776 "macHeader->frameCtrl.type : %x "
3777 "macHeader->frameCtrl.subType : %x "
3778 "macHeader->frameCtrl.toDS : %x "
3779 "macHeader->frameCtrl.fromDS : %x "
3780 "macHeader->frameCtrl.moreFrag : %x "
3781 "macHeader->frameCtrl.retry : %x "
3782 "macHeader->frameCtrl.powerMgmt : %x "
3783 "macHeader->frameCtrl.MoreData : %x "
3784 "macHeader->frameCtrl.wep : %x "
3785 "macHeader->frameCtrl.order : %x "
3786 , macHeader->frameCtrl.protVer
3787 , macHeader->frameCtrl.type
3788 , macHeader->frameCtrl.subType
3789 , macHeader->frameCtrl.toDS
3790 , macHeader->frameCtrl.fromDS
3791 , macHeader->frameCtrl.moreFrag
3792 , macHeader->frameCtrl.retry
3793 , macHeader->frameCtrl.powerMgmt
3794 , macHeader->frameCtrl.moreData
3795 , macHeader->frameCtrl.wep
3796 , macHeader->frameCtrl.order);
3797
3798
3799 macHeader->usDurationId = getByte(&temp);
3800 macHeader->usDurationId += getByte(&temp) << 8;
3801
3802 macHeader->vA1[0] = getByte(&temp);
3803 macHeader->vA1[1] = getByte(&temp);
3804 macHeader->vA1[2] = getByte(&temp);
3805 macHeader->vA1[3] = getByte(&temp);
3806 macHeader->vA1[4] = getByte(&temp);
3807 macHeader->vA1[5] = getByte(&temp);
3808
3809 macHeader->vA2[0] = getByte(&temp);
3810 macHeader->vA2[1] = getByte(&temp);
3811 macHeader->vA2[2] = getByte(&temp);
3812 macHeader->vA2[3] = getByte(&temp);
3813 macHeader->vA2[4] = getByte(&temp);
3814 macHeader->vA2[5] = getByte(&temp);
3815
3816 macHeader->vA3[0] = getByte(&temp);
3817 macHeader->vA3[1] = getByte(&temp);
3818 macHeader->vA3[2] = getByte(&temp);
3819 macHeader->vA3[3] = getByte(&temp);
3820 macHeader->vA3[4] = getByte(&temp);
3821 macHeader->vA3[5] = getByte(&temp);
3822
3823 macHeader->sSeqCtrl = getByte(&temp);
3824 fragNum = macHeader->sSeqCtrl & 0xF;
3825 macHeader->sSeqCtrl >>= 4;
3826
3827 macHeader->sSeqCtrl += getByte(&temp) << 4;
3828
3829 macHeader->sSeqCtrl |= fragNum << 12;
3830
3831 if (length == 30 || length == 32) {
3832 macHeader->optvA4[0] = getByte(&temp);
3833 macHeader->optvA4[1] = getByte(&temp);
3834 macHeader->optvA4[2] = getByte(&temp);
3835 macHeader->optvA4[3] = getByte(&temp);
3836 macHeader->optvA4[4] = getByte(&temp);
3837 macHeader->optvA4[5] = getByte(&temp);
3838 }
3839
3840 if (length == 26 || length == 32) {
3841 macHeader->usQosCtrl = getByte(&temp);
3842 macHeader->usQosCtrl += getByte(&temp) << 8;
3843 }
3844
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303845 //parse payload
3846 length = getByte(&temp);
3847 length += getByte(&temp) << 8;
3848 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3849
3850 pkt->data.length = length;
3851
3852 for (i = 0; i< length; i++) {
3853 pkt->data.data[i] = getByte(&temp);
3854 }
3855
3856 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3857 &pkt->data.data[0], pkt->data.length, 0);
3858}
3859
3860/**---------------------------------------------------------------------------
3861
3862 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3863 encrypt message request
3864 This is an asynchronous callback function from SME when the encrypted data
3865 is received
3866
3867 \pEncInfoRsp -> Encrypted data info
3868
3869 \return - 0 for success non-zero for failure
3870 --------------------------------------------------------------------------*/
3871static void
3872hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3873{
3874 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3875
3876 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3877
3878 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3879 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3880 pEncryptedDataRsp->encryptedPayload.length);
3881 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3882 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3883 pEncryptedDataRsp->encryptedPayload.data,
3884 pEncryptedDataRsp->encryptedPayload.length, 0);
3885}
3886
Jeff Johnson295189b2012-06-20 16:38:30 -07003887VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3888{
3889 struct statsContext context;
3890 eHalStatus status;
3891 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303892 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003893
3894 if (NULL == pAdapter)
3895 {
3896 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3897 return VOS_STATUS_E_FAULT;
3898 }
3899
3900 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3901 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303902 if (pHddCtx->isLogpInProgress) {
3903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3904 "%s:LOGP in Progress. Ignore!!!", __func__);
3905 return VOS_STATUS_E_FAILURE;
3906 }
3907
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 init_completion(&context.completion);
3909
3910 context.pAdapter = pAdapter;
3911 context.magic = POWER_CONTEXT_MAGIC;
3912
3913 if (DRIVER_POWER_MODE_ACTIVE == mode)
3914 {
3915 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3916 "Full Power", __func__);
3917 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3918 iw_power_callback_fn, &context,
3919 eSME_FULL_PWR_NEEDED_BY_HDD);
3920 // Enter Full power command received from GUI this means we are disconnected
3921 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3922 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
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 Johnson72a40512013-12-19 10:14:15 -08003929
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 if (lrc <= 0)
3931 {
3932 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003933 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 }
3935 }
3936 }
3937 else if (DRIVER_POWER_MODE_AUTO == mode)
3938 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303939 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
3940 * was already in BMPS state and thus either STA or P2P-CLI is in
3941 * associated state and authenticated, so even if STA connState is
3942 * not associated it can be assumed that P2P-CLI is associated and
3943 * authenticated. Thus driver can enter BMPS. And even if we try to enter
3944 * BMPS with no adaptor in associated state, pmcRequestBmps will check
3945 * if all condition are satisfied for entering BMPS.
3946 */
3947 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
3948 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303949 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303950 hddLog(LOGE,
3951 FL("Station is associated but, still not Authenticated ignore "
3952 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303953 return VOS_STATUS_E_AGAIN;
3954 }
3955
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3957 {
3958 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3959 __func__);
3960 // Enter BMPS command received from GUI this means DHCP is completed
3961 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3962 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3963 FALSE);
3964 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3965 iw_power_callback_fn, &context);
3966 if (eHAL_STATUS_PMC_PENDING == status)
3967 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003968 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 int lrc = wait_for_completion_interruptible_timeout(
3970 &context.completion,
3971 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 if (lrc <= 0)
3973 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003974 hddLog(VOS_TRACE_LEVEL_ERROR,
3975 "%s: SME %s while requesting BMPS",
3976 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 }
3978 }
3979 }
3980 else
3981 {
3982 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3983 "enabled in the cfg");
3984 }
3985 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003986
3987 /* either we never sent a request, we sent a request and received a
3988 response or we sent a request and timed out. if we never sent a
3989 request or if we sent a request and got a response, we want to
3990 clear the magic out of paranoia. if we timed out there is a
3991 race condition such that the callback function could be
3992 executing at the same time we are. of primary concern is if the
3993 callback function had already verified the "magic" but had not
3994 yet set the completion variable when a timeout occurred. we
3995 serialize these activities by invalidating the magic while
3996 holding a shared spinlock which will cause us to block if the
3997 callback is currently executing */
3998 spin_lock(&hdd_context_lock);
3999 context.magic = 0;
4000 spin_unlock(&hdd_context_lock);
4001
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 return VOS_STATUS_SUCCESS;
4003}
4004
4005VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4006 hdd_adapter_t *pAdapter)
4007{
4008 VOS_STATUS vos_Status;
4009
4010 if ((NULL == pAdapter) || (NULL == pHddCtx))
4011 {
4012 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4013 return VOS_STATUS_E_FAULT;
4014 }
4015
4016 /**Exit from Deep sleep or standby if we get the driver
4017 START cmd from android GUI
4018 */
4019 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4020 {
4021 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4022 "from Stand by",__func__);
4023 vos_Status = hdd_exit_standby(pHddCtx);
4024 }
4025 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4026 {
4027 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4028 "from deep sleep",__func__);
4029 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4030 }
4031 else
4032 {
4033 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4034 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4035 vos_Status = VOS_STATUS_SUCCESS;
4036 }
4037
4038 return vos_Status;
4039}
4040
4041VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4042{
4043 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4044
4045 if (NULL == pHddCtx)
4046 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304047 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 return VOS_STATUS_E_FAULT;
4049 }
4050
4051 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4052 {
4053 //Execute standby procedure.
4054 //Executing standby procedure will cause the STA to
4055 //disassociate first and then the chip will be put into standby.
4056 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4057 vos_Status = hdd_enter_standby(pHddCtx);
4058 }
4059 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4060 pHddCtx->cfg_ini->nEnableDriverStop)
4061 {
4062 //Execute deep sleep procedure
4063 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004064 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 //Deep sleep not supported
4066 vos_Status = hdd_enter_standby(pHddCtx);
4067 }
4068 else
4069 {
4070 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4071 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4072 vos_Status = VOS_STATUS_SUCCESS;
4073 }
4074
4075 return vos_Status;
4076}
4077
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004078
4079void* wlan_hdd_change_country_code_callback(void *pAdapter)
4080{
4081
4082 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004083 complete(&call_back_pAdapter->change_country_code);
4084
4085 return NULL;
4086}
4087
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304088static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 struct iw_request_info *info,
4090 union iwreq_data *wrqu, char *extra)
4091{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304092 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004093 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304095 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004096 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4097
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304098 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004099
4100 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304101
4102 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4103 if (NULL == pAdapter)
4104 {
4105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4106 "mem_alloc_copy_from_user_helper fail");
4107 return -EINVAL;
4108 }
4109 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4110 rc = wlan_hdd_validate_context(pHddCtx);
4111 if (0 != rc)
4112 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304113 return rc;
4114 }
4115
Arif Hussain24bfa702014-01-22 13:51:30 -08004116 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4117 wrqu->data.length);
4118 if (NULL == cmd)
4119 {
4120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4121 "mem_alloc_copy_from_user_helper fail");
4122 return -ENOMEM;
4123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004124
4125 if (ioctl_debug)
4126 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004127 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 }
4129
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004130 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4131 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004132
Arif Hussain24bfa702014-01-22 13:51:30 -08004133 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004135 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4137 "%s: Error in iw_set_scan!", __func__);
4138 rc = -EINVAL;
4139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 }
4141 else if( strcasecmp(cmd, "start") == 0 ) {
4142
Arif Hussain6d2a3322013-11-17 19:50:10 -08004143 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004145
Arif Hussain24bfa702014-01-22 13:51:30 -08004146 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4147 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 {
4149 union iwreq_data wrqu;
4150 char buf[10];
4151
4152 memset(&wrqu, 0, sizeof(wrqu));
4153 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4154 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4155 }
4156 else
4157 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004158 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4159 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 }
4161 goto done;
4162 }
4163 else if( strcasecmp(cmd, "stop") == 0 )
4164 {
4165 union iwreq_data wrqu;
4166 char buf[10];
4167
Arif Hussain6d2a3322013-11-17 19:50:10 -08004168 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004169
4170 wlan_hdd_enter_lowpower(pHddCtx);
4171 memset(&wrqu, 0, sizeof(wrqu));
4172 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4173 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 goto done;
4175 }
4176 else if (strcasecmp(cmd, "macaddr") == 0)
4177 {
4178 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4179 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4180 }
4181 else if (strcasecmp(cmd, "scan-active") == 0)
4182 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304183 hddLog(VOS_TRACE_LEVEL_ERROR,
4184 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004185 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 ret = snprintf(cmd, cmd_len, "OK");
4187 }
4188 else if (strcasecmp(cmd, "scan-passive") == 0)
4189 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304190 hddLog(VOS_TRACE_LEVEL_ERROR,
4191 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004192 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 ret = snprintf(cmd, cmd_len, "OK");
4194 }
4195 else if( strcasecmp(cmd, "scan-mode") == 0 )
4196 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004197 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 }
4199 else if( strcasecmp(cmd, "linkspeed") == 0 )
4200 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004201 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 }
4203 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4204 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004205 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004206 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004207
4208 country_code = cmd + 8;
4209
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004210 init_completion(&pAdapter->change_country_code);
4211
Arif Hussain24bfa702014-01-22 13:51:30 -08004212 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004213 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 country_code,
4215 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304216 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304217 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304218 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004219
4220 /* Wait for completion */
4221 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4222 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4223
4224 if (lrc <= 0)
4225 {
4226 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004227 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004228 }
4229
Arif Hussain24bfa702014-01-22 13:51:30 -08004230 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004232 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004233 "%s: SME Change Country code fail", __func__);
4234 kfree(cmd);
4235 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 }
4237 }
4238 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4239 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004240 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 }
4242 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4243 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004244 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004245
Wilson Yang1be3e652013-10-09 15:18:31 -07004246 if (9 < cmd_len)
4247 {
4248 ptr = (char*)(cmd + 9);
4249
4250 }else{
4251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4252 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004253 kfree(cmd);
4254 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004255 }
4256
4257 if (1 != sscanf(ptr,"%d",&mode))
4258 {
4259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4260 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004261 kfree(cmd);
4262 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004263 }
4264
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 wlan_hdd_enter_bmps(pAdapter, mode);
4266 /*TODO:Set the power mode*/
4267 }
4268 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4269 v_U32_t pmc_state;
4270 v_U16_t value;
4271
4272 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4273 if(pmc_state == BMPS) {
4274 value = DRIVER_POWER_MODE_AUTO;
4275 }
4276 else {
4277 value = DRIVER_POWER_MODE_ACTIVE;
4278 }
4279 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4280 }
4281 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004282 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 /*TODO: set the btcoexmode*/
4284 }
4285 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4286
Arif Hussain6d2a3322013-11-17 19:50:10 -08004287 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 /*TODO: Return the btcoex status*/
4289 }
4290 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4291
Arif Hussain6d2a3322013-11-17 19:50:10 -08004292 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004293
4294 /*TODO: Enable Rx data Filter*/
4295 }
4296 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4297
Arif Hussain6d2a3322013-11-17 19:50:10 -08004298 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004299
4300 /*TODO: Disable Rx data Filter*/
4301 }
4302 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4303
Arif Hussain6d2a3322013-11-17 19:50:10 -08004304 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 /*TODO: rxfilter-statistics*/
4306 }
4307 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4308
Arif Hussain6d2a3322013-11-17 19:50:10 -08004309 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 /*TODO: rxfilter-add*/
4311 }
4312 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4313
Arif Hussain6d2a3322013-11-17 19:50:10 -08004314 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 /*TODO: rxfilter-remove*/
4316 }
4317#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004318 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4319 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4320 /*TODO: support pnosetup*/
4321 }
4322 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4323 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4324 /*TODO: support pnoforce*/
4325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4327
Arif Hussain6d2a3322013-11-17 19:50:10 -08004328 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004329 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4330 kfree(cmd);
4331 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 }
4333 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004334 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004335 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4336 kfree(cmd);
4337 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 }
4339#endif /*FEATURE_WLAN_SCAN_PNO*/
4340 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004341 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004342 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4343 kfree(cmd);
4344 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 }
4346 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4347 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004348 char *ptr;
4349
4350 if (18 < cmd_len)
4351 {
4352 ptr = (char*)(cmd + 18);
4353 }else{
4354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4355 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004356 kfree(cmd);
4357 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004358 }
4359
Jeff Johnson02797792013-10-26 19:17:13 -07004360 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004361 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4362 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4363 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4364 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4365 {
4366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4367 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004368 kfree(cmd);
4369 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004371
4372 // parameters checking
4373 // period has to be larger than 0
4374 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4375 {
4376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004377 kfree(cmd);
4378 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 }
4380
4381 // use default value 5 is the input is not reasonable. in unit of 10%
4382 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4383 {
4384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4385 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4386 }
4387
4388 // default is 5
4389 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4390 {
4391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4392 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4393 }
4394
Arif Hussain24bfa702014-01-22 13:51:30 -08004395 if (eHAL_STATUS_SUCCESS !=
4396 sme_SetTxPerTracking(pHddCtx->hHal,
4397 hdd_tx_per_hit_cb,
4398 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004400 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004401 }
4402 }
4403 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004404 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4405 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 }
4407done:
4408 /* many of the commands write information back into the command
4409 string using snprintf(). check the return value here in one
4410 place */
4411 if ((ret < 0) || (ret >= cmd_len))
4412 {
4413 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004414 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004416 else if (ret > 0)
4417 {
4418 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4419 {
4420 hddLog(VOS_TRACE_LEVEL_ERROR,
4421 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004422 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004423 return -EFAULT;
4424 }
4425 wrqu->data.length = ret;
4426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004427
4428 if (ioctl_debug)
4429 {
4430 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004431 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004433 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304434 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004435 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004436}
4437
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304438static int iw_set_priv(struct net_device *dev,
4439 struct iw_request_info *info,
4440 union iwreq_data *wrqu, char *extra)
4441{
4442 int ret;
4443 vos_ssr_protect(__func__);
4444 ret = __iw_set_priv(dev, info, wrqu, extra);
4445 vos_ssr_unprotect(__func__);
4446
4447 return ret;
4448}
4449
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304450static int __iw_set_nick(struct net_device *dev,
4451 struct iw_request_info *info,
4452 union iwreq_data *wrqu, char *extra)
4453{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304454 hdd_adapter_t *pAdapter;
4455 hdd_context_t *pHddCtx;
4456 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304457
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304458 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304459
4460 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4461 if (NULL == pAdapter)
4462 {
4463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4464 "%s: Adapter is NULL",__func__);
4465 return -EINVAL;
4466 }
4467
4468 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4469 ret = wlan_hdd_validate_context(pHddCtx);
4470 if (0 != ret)
4471 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304472 return ret;
4473 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304474 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304475 return 0;
4476}
4477
Jeff Johnson295189b2012-06-20 16:38:30 -07004478static int iw_set_nick(struct net_device *dev,
4479 struct iw_request_info *info,
4480 union iwreq_data *wrqu, char *extra)
4481{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304482 int ret;
4483
4484 vos_ssr_protect(__func__);
4485 ret = __iw_set_nick(dev, info, wrqu, extra);
4486 vos_ssr_unprotect(__func__);
4487
4488 return ret;
4489}
4490
4491static int __iw_get_nick(struct net_device *dev,
4492 struct iw_request_info *info,
4493 union iwreq_data *wrqu, char *extra)
4494{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304495 hdd_adapter_t *pAdapter;
4496 hdd_context_t *pHddCtx;
4497 int ret = 0;
4498
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304500
4501 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4502 if (NULL == pAdapter)
4503 {
4504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4505 "%s: Adapter is NULL",__func__);
4506 return -EINVAL;
4507 }
4508
4509 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4510 ret = wlan_hdd_validate_context(pHddCtx);
4511 if (0 != ret)
4512 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304513 return ret;
4514 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304515 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 return 0;
4517}
4518
4519static int iw_get_nick(struct net_device *dev,
4520 struct iw_request_info *info,
4521 union iwreq_data *wrqu, char *extra)
4522{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304523 int ret;
4524
4525 vos_ssr_protect(__func__);
4526 ret = __iw_get_nick(dev, info, wrqu, extra);
4527 vos_ssr_unprotect(__func__);
4528
4529 return ret;
4530}
4531
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304532/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304533static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4534{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304535 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4536 hdd_context_t *pHddCtx;
4537 hdd_station_ctx_t *pHddStaCtx;
4538 v_S7_t snr = 0, rssi = 0;
4539 eHalStatus status = eHAL_STATUS_SUCCESS;
4540
4541 ENTER();
4542
4543 if (NULL == pAdapter)
4544 {
4545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4546 "%s: Adapter is NULL",__func__);
4547 return NULL;
4548 }
4549
4550 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4551 status = wlan_hdd_validate_context(pHddCtx);
4552 if (0 != status)
4553 {
4554 return NULL;
4555 }
4556
4557 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4558 if (NULL == pHddStaCtx)
4559 {
4560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4561 "%s: STA Context is NULL",__func__);
4562 return NULL;
4563 }
4564
4565 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4566 {
4567 wlan_hdd_get_station_stats(pAdapter);
4568 wlan_hdd_get_snr(pAdapter, &snr);
4569 wlan_hdd_get_rssi(pAdapter, &rssi);
4570
4571 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4572 pAdapter->iwStats.status = 0;
4573 pAdapter->iwStats.qual.qual = snr;
4574 pAdapter->iwStats.qual.level = rssi;
4575 pAdapter->iwStats.qual.noise = rssi - snr;
4576 pAdapter->iwStats.discard.code = 0;
4577 pAdapter->iwStats.discard.retries= 0;
4578 pAdapter->iwStats.miss.beacon = 0;
4579 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4580 }
4581 else
4582 {
4583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4584 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4585 return NULL;
4586 }
4587
4588 EXIT();
4589 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004590}
4591
4592static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4593{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304594
4595 struct iw_statistics *stats;
4596
4597 vos_ssr_protect(__func__);
4598 stats = __get_wireless_stats(dev);
4599 vos_ssr_unprotect(__func__);
4600
4601 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004602}
4603
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304604static int __iw_set_encode(struct net_device *dev,
4605 struct iw_request_info *info,
4606 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004607
4608{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304609 hdd_adapter_t *pAdapter;
4610 hdd_station_ctx_t *pHddStaCtx;
4611 hdd_wext_state_t *pWextState;
4612 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 struct iw_point *encoderq = &(wrqu->encoding);
4614 v_U32_t keyId;
4615 v_U8_t key_length;
4616 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4617 v_BOOL_t fKeyPresent = 0;
4618 int i;
4619 eHalStatus status = eHAL_STATUS_SUCCESS;
4620
4621
4622 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304623 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4624 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4627 "%s: Adapter is NULL",__func__);
4628 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 }
4630
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304631 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4632 status = wlan_hdd_validate_context(pHddCtx);
4633 if (0 != status)
4634 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304635 return status;
4636 }
4637 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4638 if (NULL == pWextState)
4639 {
4640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4641 "%s: pWextState is NULL ",__func__);
4642 return -EINVAL;
4643 }
4644 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4645 if (NULL == pHddStaCtx)
4646 {
4647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4648 "%s: STA Context is NULL",__func__);
4649 return -EINVAL;
4650 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004651
4652 keyId = encoderq->flags & IW_ENCODE_INDEX;
4653
4654 if(keyId)
4655 {
4656 if(keyId > MAX_WEP_KEYS)
4657 {
4658 return -EINVAL;
4659 }
4660
4661 fKeyPresent = 1;
4662 keyId--;
4663 }
4664 else
4665 {
4666 fKeyPresent = 0;
4667 }
4668
4669
4670 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4671 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 if(!fKeyPresent) {
4674
4675 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4676
4677 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4678 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4679 }
4680 }
4681 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4682 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4683 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4684 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4685
4686 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4687 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4688
4689 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4690 {
4691 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4692 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004693 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304694 {
4695 long ret;
4696 ret = wait_for_completion_interruptible_timeout(
4697 &pAdapter->disconnect_comp_var,
4698 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4699 if (ret <= 0)
4700 hddLog(VOS_TRACE_LEVEL_ERROR,
4701 FL("failed wait on disconnect_comp_var %ld"), ret);
4702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 }
4704
4705 return status;
4706
4707 }
4708
4709 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4710 {
4711 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4712
4713 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4714
4715 }
4716
4717
4718 if(wrqu->data.length > 0)
4719 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004720 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004721
4722 key_length = wrqu->data.length;
4723
4724 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4725
4726 if(5 == key_length)
4727 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004728 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004729
4730 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4731 {
4732 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4733 }
4734 else
4735 {
4736 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4737 }
4738 }
4739 else if(13 == key_length)
4740 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004741 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004742
4743 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4744 {
4745 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4746 }
4747 else
4748 {
4749 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4750 }
4751 }
4752 else
4753 {
4754 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004755 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 return -EINVAL;
4757 }
4758
4759 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4760 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4761 pWextState->roamProfile.EncryptionType.numEntries = 1;
4762 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4763 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4764 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4765
4766 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4767 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4768 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4769 {
4770
4771 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4772
4773 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4774 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4775
4776 return status;
4777 }
4778 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304779 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 return 0;
4781}
4782
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304783static int iw_set_encode(struct net_device *dev,
4784 struct iw_request_info *info,
4785 union iwreq_data *wrqu,char *extra)
4786{
4787 int ret;
4788
4789 vos_ssr_protect(__func__);
4790 ret = __iw_set_encode(dev, info, wrqu, extra);
4791 vos_ssr_unprotect(__func__);
4792
4793 return ret;
4794}
4795
4796static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004797 struct iw_request_info *info,
4798 struct iw_point *dwrq,
4799 char *extra)
4800{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304801 hdd_adapter_t *pAdapter;
4802 hdd_wext_state_t *pWextState;
4803 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 int keyId;
4805 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4806 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304807 int i, ret = 0;
4808 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004809
4810 ENTER();
4811
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304812 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4813 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004814 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4816 "%s: Adapter is NULL",__func__);
4817 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004818 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304819 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4820 ret = wlan_hdd_validate_context(pHddCtx);
4821 if (0 != ret)
4822 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304823 return ret;
4824 }
4825 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4826 if (NULL == pWextState)
4827 {
4828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4829 "%s: pWextState is NULL",__func__);
4830 return -EINVAL;
4831 }
4832 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004833
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 keyId = pRoamProfile->Keys.defaultIndex;
4835
4836 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4837 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004838 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 return -EINVAL;
4840 }
4841
4842 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4843 {
4844 dwrq->flags |= IW_ENCODE_ENABLED;
4845 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304846 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4847 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 }
4849 else
4850 {
4851 dwrq->flags |= IW_ENCODE_DISABLED;
4852 }
4853
4854 for(i=0; i < MAX_WEP_KEYS; i++)
4855 {
4856 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4857 {
4858 continue;
4859 }
4860 else
4861 {
4862 break;
4863 }
4864 }
4865
4866 if(MAX_WEP_KEYS == i)
4867 {
4868 dwrq->flags |= IW_ENCODE_NOKEY;
4869 }
4870 else
4871 {
4872 dwrq->flags |= IW_ENCODE_ENABLED;
4873 }
4874
4875 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4876
4877 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4878 {
4879 dwrq->flags |= IW_ENCODE_DISABLED;
4880 }
4881
4882 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4883
4884 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4885 {
4886 dwrq->flags |= IW_ENCODE_OPEN;
4887 }
4888 else
4889 {
4890 dwrq->flags |= IW_ENCODE_RESTRICTED;
4891 }
4892 EXIT();
4893 return 0;
4894
4895}
4896
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304897static int iw_get_encodeext(struct net_device *dev,
4898 struct iw_request_info *info,
4899 struct iw_point *dwrq,
4900 char *extra)
4901{
4902 int ret;
4903 vos_ssr_protect(__func__);
4904 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4905 vos_ssr_unprotect(__func__);
4906
4907 return ret;
4908}
4909
4910static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 struct iw_request_info *info,
4912 union iwreq_data *wrqu, char *extra)
4913{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304914 hdd_adapter_t *pAdapter;
4915 hdd_station_ctx_t *pHddStaCtx;
4916 hdd_wext_state_t *pWextState;
4917 hdd_context_t *pHddCtx;
4918 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004919
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304920 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 v_U32_t status = 0;
4922
4923 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4924
4925 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4926
4927 int key_index;
4928 struct iw_point *encoding = &wrqu->encoding;
4929 tCsrRoamSetKey setKey;
4930 v_U32_t roamId= 0xFF;
4931 VOS_STATUS vos_status;
4932
4933 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304934 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4935 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4938 "%s: Adapter is NULL",__func__);
4939 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4942 status = wlan_hdd_validate_context(pHddCtx);
4943 if (0 != status)
4944 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304945 return status;
4946 }
4947 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4948 if (NULL == pHddStaCtx)
4949 {
4950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4951 "%s: STA Context is NULL",__func__);
4952 return -EINVAL;
4953 }
4954 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4955 if (NULL == pWextState)
4956 {
4957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4958 "%s: pWextState is NULL",__func__);
4959 return -EINVAL;
4960 }
4961 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 key_index = encoding->flags & IW_ENCODE_INDEX;
4963
4964 if(key_index > 0) {
4965
4966 /*Convert from 1-based to 0-based keying*/
4967 key_index--;
4968 }
4969 if(!ext->key_len) {
4970
4971 /*Set the encrytion type to NONE*/
4972 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4973 return status;
4974 }
4975
4976 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4977 (IW_ENCODE_ALG_WEP == ext->alg))
4978 {
4979 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4980
Agarwal Ashish971c2882013-10-30 20:11:12 +05304981 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4982 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 return -EINVAL;
4984 }
4985 else {
4986 /*Static wep, update the roam profile with the keys */
4987 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4988 key_index < CSR_MAX_NUM_KEY) {
4989 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4990 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4991
4992 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4993 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4994
4995 }
4996 }
4997 return status;
4998 }
4999
5000 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5001
5002 setKey.keyId = key_index;
5003 setKey.keyLength = ext->key_len;
5004
5005 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5006 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5007 }
5008
5009 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5010 /*Key direction for group is RX only*/
5011 setKey.keyDirection = eSIR_RX_ONLY;
5012 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5013 }
5014 else {
5015
5016 setKey.keyDirection = eSIR_TX_RX;
5017 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5018 }
5019
5020 /*For supplicant pae role is zero*/
5021 setKey.paeRole = 0;
5022
5023 switch(ext->alg)
5024 {
5025 case IW_ENCODE_ALG_NONE:
5026 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5027 break;
5028
5029 case IW_ENCODE_ALG_WEP:
5030 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5031 break;
5032
5033 case IW_ENCODE_ALG_TKIP:
5034 {
5035 v_U8_t *pKey = &setKey.Key[0];
5036
5037 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5038
5039 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5040
5041 /*Supplicant sends the 32bytes key in this order
5042
5043 |--------------|----------|----------|
5044 | Tk1 |TX-MIC | RX Mic |
5045 |--------------|----------|----------|
5046 <---16bytes---><--8bytes--><--8bytes-->
5047
5048 */
5049 /*Sme expects the 32 bytes key to be in the below order
5050
5051 |--------------|----------|----------|
5052 | Tk1 |RX-MIC | TX Mic |
5053 |--------------|----------|----------|
5054 <---16bytes---><--8bytes--><--8bytes-->
5055 */
5056 /* Copy the Temporal Key 1 (TK1) */
5057 vos_mem_copy(pKey,ext->key,16);
5058
5059 /*Copy the rx mic first*/
5060 vos_mem_copy(&pKey[16],&ext->key[24],8);
5061
5062 /*Copy the tx mic */
5063 vos_mem_copy(&pKey[24],&ext->key[16],8);
5064
5065 }
5066 break;
5067
5068 case IW_ENCODE_ALG_CCMP:
5069 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5070 break;
5071
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005072#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005073#define IW_ENCODE_ALG_KRK 6
5074 case IW_ENCODE_ALG_KRK:
5075 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5076 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005077#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005078
5079 default:
5080 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5081 break;
5082 }
5083
5084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005085 ("%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 -07005086
5087#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305088 /* The supplicant may attempt to set the PTK once pre-authentication
5089 is done. Save the key in the UMAC and include it in the ADD
5090 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305092 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305094 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5095 "%s: Update PreAuth Key success", __func__);
5096 return 0;
5097 }
5098 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5099 {
5100 hddLog(VOS_TRACE_LEVEL_ERROR,
5101 "%s: Update PreAuth Key failed", __func__);
5102 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 }
5104#endif /* WLAN_FEATURE_VOWIFI_11R */
5105
5106 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5107
5108 vos_status = wlan_hdd_check_ula_done(pAdapter);
5109 if ( vos_status != VOS_STATUS_SUCCESS )
5110 {
5111 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5112 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5113 __LINE__, vos_status );
5114
5115 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5116 }
5117
5118 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5119
5120 if ( halStatus != eHAL_STATUS_SUCCESS )
5121 {
5122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5123 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5124 __LINE__, halStatus );
5125
5126 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5127 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305128 EXIT();
5129 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005130}
5131
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305132static int iw_set_encodeext(struct net_device *dev,
5133 struct iw_request_info *info,
5134 union iwreq_data *wrqu, char *extra)
5135{
5136 int ret;
5137
5138 vos_ssr_protect(__func__);
5139 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5140 vos_ssr_unprotect(__func__);
5141
5142 return ret;
5143}
5144
5145static int __iw_set_retry(struct net_device *dev,
5146 struct iw_request_info *info,
5147 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005148{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305149 hdd_adapter_t *pAdapter;
5150 tHalHandle hHal;
5151 hdd_context_t *pHddCtx;
5152 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005153
5154 ENTER();
5155
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305156 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5157 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005158 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5160 "%s: Adapter is NULL",__func__);
5161 return -EINVAL;
5162 }
5163
5164 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5165 ret = wlan_hdd_validate_context(pHddCtx);
5166 if (0 != ret)
5167 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305168 return ret;
5169 }
5170
5171 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5172 if (NULL == hHal)
5173 {
5174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5175 "%s: Hal Context is NULL",__func__);
5176 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005177 }
5178
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5180 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5181
Arif Hussain6d2a3322013-11-17 19:50:10 -08005182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005183
5184 return -EINVAL;
5185 }
5186
5187 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5188
5189 if((wrqu->retry.flags & IW_RETRY_LONG))
5190 {
5191 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5192 {
c_hpothub8245442013-11-20 23:41:09 +05305193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5194 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 return -EIO;
5196 }
5197 }
5198 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5199 {
5200 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5201 {
c_hpothub8245442013-11-20 23:41:09 +05305202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5203 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 return -EIO;
5205 }
5206 }
5207 }
5208 else
5209 {
5210 return -EOPNOTSUPP;
5211 }
5212
Arif Hussain6d2a3322013-11-17 19:50:10 -08005213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005214
5215 EXIT();
5216
5217 return 0;
5218
5219}
5220
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305221static int iw_set_retry(struct net_device *dev,
5222 struct iw_request_info *info,
5223 union iwreq_data *wrqu, char *extra)
5224{
5225 int ret;
5226
5227 vos_ssr_protect(__func__);
5228 ret = __iw_set_retry(dev, info, wrqu, extra);
5229 vos_ssr_unprotect(__func__);
5230
5231 return ret;
5232}
5233
5234static int __iw_get_retry(struct net_device *dev,
5235 struct iw_request_info *info,
5236 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005237{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305238 hdd_adapter_t *pAdapter;
5239 hdd_context_t *pHddCtx;
5240 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305242 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005243
5244 ENTER();
5245
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305246 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5247 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005248 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5250 "%s: Adapter is NULL",__func__);
5251 return -EINVAL;
5252 }
5253
5254 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5255 ret = wlan_hdd_validate_context(pHddCtx);
5256 if (0 != ret)
5257 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305258 return ret;
5259 }
5260
5261 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5262 if (NULL == hHal)
5263 {
5264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5265 "%s: Hal Context is NULL",__func__);
5266 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005267 }
5268
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 if((wrqu->retry.flags & IW_RETRY_LONG))
5270 {
5271 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5272
5273 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5274 {
c_hpothub8245442013-11-20 23:41:09 +05305275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5276 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 return -EIO;
5278 }
5279
5280 wrqu->retry.value = retry;
5281 }
5282 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5283 {
5284 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5285
5286 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5287 {
c_hpothub8245442013-11-20 23:41:09 +05305288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5289 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 return -EIO;
5291 }
5292
5293 wrqu->retry.value = retry;
5294 }
5295 else {
5296 return -EOPNOTSUPP;
5297 }
5298
Arif Hussain6d2a3322013-11-17 19:50:10 -08005299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005300
5301 EXIT();
5302
5303 return 0;
5304}
5305
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305306static int iw_get_retry(struct net_device *dev,
5307 struct iw_request_info *info,
5308 union iwreq_data *wrqu, char *extra)
5309{
5310 int ret;
5311
5312 vos_ssr_protect(__func__);
5313 ret = __iw_get_retry(dev, info, wrqu, extra);
5314 vos_ssr_unprotect(__func__);
5315
5316 return ret;
5317}
5318
5319static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 struct iw_request_info *info,
5321 union iwreq_data *wrqu,
5322 char *extra)
5323{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305324 hdd_adapter_t *pAdapter;
5325 hdd_context_t *pHddCtx;
5326 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5328 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305329 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005330
5331 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305332 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5333 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5336 "%s:Adapter is NULL",__func__);
5337 return -EINVAL;
5338 }
5339 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5340 ret = wlan_hdd_validate_context(pHddCtx);
5341 if (0 != ret)
5342 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305343 return ret;
5344 }
5345 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5346 if (NULL == pHddStaCtx)
5347 {
5348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5349 "%s:STA context is NULL",__func__);
5350 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 }
5352
5353 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5354 switch (mlme->cmd) {
5355 case IW_MLME_DISASSOC:
5356 case IW_MLME_DEAUTH:
5357
5358 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5359 {
5360 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5361
5362 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5363 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5364
5365 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5366 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5367
Jeff Johnson43971f52012-07-17 12:26:56 -07005368 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305369 {
5370 long ret;
5371 ret = wait_for_completion_interruptible_timeout(
5372 &pAdapter->disconnect_comp_var,
5373 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5374 if (ret <= 0)
5375 hddLog(VOS_TRACE_LEVEL_ERROR,
5376 FL("failed wait on disconnect_comp_var %ld"), ret);
5377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005379 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005380 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005381
5382 /* Resetting authKeyMgmt */
5383 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5384
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305385 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 netif_tx_disable(dev);
5387 netif_carrier_off(dev);
5388
5389 }
5390 else
5391 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005392 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 -07005393 }
5394 break;
5395 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005396 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 return -EINVAL;
5398 }//end of switch
5399
5400 EXIT();
5401
5402 return status;
5403
5404}
5405
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305406static int iw_set_mlme(struct net_device *dev,
5407 struct iw_request_info *info,
5408 union iwreq_data *wrqu,
5409 char *extra)
5410{
5411 int ret;
5412
5413 vos_ssr_protect(__func__);
5414 ret = __iw_set_mlme(dev, info, wrqu, extra);
5415 vos_ssr_unprotect(__func__);
5416
5417 return ret;
5418}
5419
Jeff Johnson295189b2012-06-20 16:38:30 -07005420/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305421static int __iw_setint_getnone(struct net_device *dev,
5422 struct iw_request_info *info,
5423 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005424{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305425 hdd_adapter_t *pAdapter;
5426 tHalHandle hHal;
5427 hdd_wext_state_t *pWextState;
5428 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305429 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 int *value = (int *)extra;
5431 int sub_cmd = value[0];
5432 int set_value = value[1];
5433 int ret = 0; /* success */
5434 int enable_pbm, enable_mp;
5435#ifdef CONFIG_HAS_EARLYSUSPEND
5436 v_U8_t nEnableSuspendOld;
5437#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005438
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305439 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305440 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5441 if (NULL == pAdapter)
5442 {
5443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5444 "%s: Adapter is NULL",__func__);
5445 return -EINVAL;
5446 }
5447 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5448 ret = wlan_hdd_validate_context(pHddCtx);
5449 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005450 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305451 return ret;
5452 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305453
5454 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5455 if (NULL == hHal)
5456 {
5457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5458 "%s: Hal Context is NULL",__func__);
5459 return -EINVAL;
5460 }
5461
Katya Nigameae74b62015-05-28 17:19:16 +05305462 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305463 {
Katya Nigameae74b62015-05-28 17:19:16 +05305464 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5465 if (NULL == pWextState)
5466 {
5467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5468 "%s: pWextState is NULL",__func__);
5469 return -EINVAL;
5470 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005471
Katya Nigameae74b62015-05-28 17:19:16 +05305472 INIT_COMPLETION(pWextState->completion_var);
5473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005474 switch(sub_cmd)
5475 {
5476 case WE_SET_11D_STATE:
5477 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005478 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005479 memset(&smeConfig, 0x00, sizeof(smeConfig));
5480
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5482
5483 sme_GetConfigParam(hHal,&smeConfig);
5484 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5485
Arif Hussain6d2a3322013-11-17 19:50:10 -08005486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005487
5488 sme_UpdateConfig(hHal,&smeConfig);
5489 }
5490 else {
5491 return -EINVAL;
5492 }
5493 break;
5494 }
5495
5496 case WE_WOWL:
5497 {
5498 switch (set_value)
5499 {
5500 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305501 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 break;
5503 case 0x01:
5504 case 0x02:
5505 case 0x03:
5506 enable_mp = (set_value & 0x01) ? 1 : 0;
5507 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005508 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5510 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5511 break;
5512 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005513 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 ret = -EINVAL;
5515 break;
5516 }
5517
5518 break;
5519 }
5520 case WE_SET_POWER:
5521 {
5522 switch (set_value)
5523 {
5524 case 0: //Full Power
5525 {
5526 struct statsContext context;
5527 eHalStatus status;
5528
5529 init_completion(&context.completion);
5530
5531 context.pAdapter = pAdapter;
5532 context.magic = POWER_CONTEXT_MAGIC;
5533
5534 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5535 iw_power_callback_fn, &context,
5536 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005537 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 {
5539 int lrc = wait_for_completion_interruptible_timeout(
5540 &context.completion,
5541 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005542
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 if (lrc <= 0)
5544 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005545 hddLog(VOS_TRACE_LEVEL_ERROR,
5546 "%s: SME %s while requesting fullpower",
5547 __func__, (0 == lrc) ?
5548 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 }
5550 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005551 /* either we have a response or we timed out. if we timed
5552 out there is a race condition such that the callback
5553 function could be executing at the same time we are. of
5554 primary concern is if the callback function had already
5555 verified the "magic" but had not yet set the completion
5556 variable when a timeout occurred. we serialize these
5557 activities by invalidating the magic while holding a
5558 shared spinlock which will cause us to block if the
5559 callback is currently executing */
5560 spin_lock(&hdd_context_lock);
5561 context.magic = 0;
5562 spin_unlock(&hdd_context_lock);
5563
Arif Hussain6d2a3322013-11-17 19:50:10 -08005564 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005565 break;
5566 }
5567 case 1: //Enable BMPS
5568 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5569 break;
5570 case 2: //Disable BMPS
5571 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5572 break;
5573 case 3: //Request Bmps
5574 {
5575 struct statsContext context;
5576 eHalStatus status;
5577
5578 init_completion(&context.completion);
5579
5580 context.pAdapter = pAdapter;
5581 context.magic = POWER_CONTEXT_MAGIC;
5582
5583 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5584 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005585 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005586 {
5587 int lrc = wait_for_completion_interruptible_timeout(
5588 &context.completion,
5589 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 if (lrc <= 0)
5591 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005592 hddLog(VOS_TRACE_LEVEL_ERROR,
5593 "%s: SME %s while requesting BMPS",
5594 __func__, (0 == lrc) ? "timeout" :
5595 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005596 }
5597 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005598 /* either we have a response or we timed out. if we
5599 timed out there is a race condition such that the
5600 callback function could be executing at the same
5601 time we are. of primary concern is if the callback
5602 function had already verified the "magic" but had
5603 not yet set the completion variable when a timeout
5604 occurred. we serialize these activities by
5605 invalidating the magic while holding a shared
5606 spinlock which will cause us to block if the
5607 callback is currently executing */
5608 spin_lock(&hdd_context_lock);
5609 context.magic = 0;
5610 spin_unlock(&hdd_context_lock);
5611
Arif Hussain6d2a3322013-11-17 19:50:10 -08005612 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 break;
5614 }
5615 case 4: //Enable IMPS
5616 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5617 break;
5618 case 5: //Disable IMPS
5619 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5620 break;
5621 case 6: //Enable Standby
5622 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5623 break;
5624 case 7: //Disable Standby
5625 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5626 break;
5627 case 8: //Request Standby
5628#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005629#endif
5630 break;
5631 case 9: //Start Auto Bmps Timer
5632 sme_StartAutoBmpsTimer(hHal);
5633 break;
5634 case 10://Stop Auto BMPS Timer
5635 sme_StopAutoBmpsTimer(hHal);
5636 break;
5637#ifdef CONFIG_HAS_EARLYSUSPEND
5638 case 11://suspend to standby
5639#ifdef CONFIG_HAS_EARLYSUSPEND
5640 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5641 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5643#endif
5644 break;
5645 case 12://suspend to deep sleep
5646#ifdef CONFIG_HAS_EARLYSUSPEND
5647 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5648 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5650#endif
5651 break;
5652 case 13://resume from suspend
5653#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005654#endif
5655 break;
5656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005658 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 ret = -EINVAL;
5660 break;
5661 }
5662 break;
5663 }
5664
5665 case WE_SET_MAX_ASSOC:
5666 {
5667 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5668 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5669 {
5670 ret = -EINVAL;
5671 }
5672 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5673 set_value, NULL, eANI_BOOLEAN_FALSE)
5674 != eHAL_STATUS_SUCCESS )
5675 {
c_hpothub8245442013-11-20 23:41:09 +05305676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5677 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 ret = -EIO;
5679 }
5680 break;
5681 }
5682
5683 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5684 {
5685 if( 0 == set_value )
5686 {
5687 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5688 }
5689 else if ( 1 == set_value )
5690 {
5691 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5692 }
5693 else
5694 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005695 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 ret = -EINVAL;
5697 }
5698 break;
5699 }
5700
5701 case WE_SET_DATA_INACTIVITY_TO:
5702 {
5703 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5704 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5705 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5706 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5707 set_value,
5708 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5709 {
5710 hddLog(LOGE,"Failure: Could not pass on "
5711 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005712 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 ret = -EINVAL;
5714 }
5715 break;
5716 }
5717 case WE_SET_MAX_TX_POWER:
5718 {
5719 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5720 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5721
5722 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5723 __func__, set_value);
5724 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5725 eHAL_STATUS_SUCCESS )
5726 {
5727 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5728 __func__);
5729 return -EIO;
5730 }
5731
5732 break;
5733 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005734 case WE_SET_MAX_TX_POWER_2_4:
5735 {
5736 hddLog(VOS_TRACE_LEVEL_INFO,
5737 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5738 __func__, set_value);
5739 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5740 eHAL_STATUS_SUCCESS)
5741 {
5742 hddLog(VOS_TRACE_LEVEL_ERROR,
5743 "%s: Setting maximum tx power failed for 2.4 GHz band",
5744 __func__);
5745 return -EIO;
5746 }
5747
5748 break;
5749 }
5750 case WE_SET_MAX_TX_POWER_5_0:
5751 {
5752 hddLog(VOS_TRACE_LEVEL_INFO,
5753 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5754 __func__, set_value);
5755 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5756 eHAL_STATUS_SUCCESS)
5757 {
5758 hddLog(VOS_TRACE_LEVEL_ERROR,
5759 "%s: Setting maximum tx power failed for 5.0 GHz band",
5760 __func__);
5761 return -EIO;
5762 }
5763
5764 break;
5765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 case WE_SET_HIGHER_DTIM_TRANSITION:
5767 {
5768 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5769 (set_value == eANI_BOOLEAN_TRUE)))
5770 {
5771 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5772 ret = -EINVAL;
5773 }
5774 else
5775 {
5776 if(pAdapter->higherDtimTransition != set_value)
5777 {
5778 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005779 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 }
5781 }
5782
5783 break;
5784 }
5785
5786 case WE_SET_TM_LEVEL:
5787 {
5788 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005789 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5791
5792 break;
5793 }
5794
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305795 case WE_ENABLE_STRICT_FCC_REG:
5796 {
5797 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5798 struct wiphy *wiphy = NULL;
5799 long lrc;
5800 int status;
5801
5802 wiphy = hddCtxt->wiphy;
5803 if(wiphy == NULL)
5804 {
5805 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5806 break;
5807 }
5808 init_completion(&hddCtxt->wiphy_channel_update_event);
5809
5810 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5811
5812 status = regulatory_hint(wiphy, "00");
5813 if(status < 0)
5814 {
5815 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5816 break;
5817 }
5818
5819 /* Wait for completion */
5820 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5821 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5822 if (lrc <= 0)
5823 {
5824 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5825 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5826 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5827 }
5828 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5829
5830 break;
5831 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005832 case WE_SET_DEBUG_LOG:
5833 {
5834 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5835 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5836 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5837 break;
5838 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305839#ifdef FEATURE_WLAN_TDLS
5840 case WE_SET_TDLS_OFF_CHAN:
5841 {
5842 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5844 __func__, set_value);
5845 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5846 break;
5847 }
5848 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5849 {
5850 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5852 __func__, set_value);
5853 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5854 break;
5855 }
5856 case WE_SET_TDLS_OFF_CHAN_MODE:
5857 {
5858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5859 __func__, set_value);
5860 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5861 break;
5862 }
5863#endif
Peng Xu2446a892014-09-05 17:21:18 +05305864 case WE_SET_SCAN_BAND_PREFERENCE:
5865 {
5866 tSmeConfigParams smeConfig;
5867 memset(&smeConfig, 0x00, sizeof(smeConfig));
5868 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5869 ret = -EINVAL;
5870 break;
5871 }
5872 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5873
5874 if (eCSR_BAND_ALL == set_value ||
5875 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5876 sme_GetConfigParam(hHal, &smeConfig);
5877 smeConfig.csrConfig.scanBandPreference = set_value;
5878
5879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5880 "set band scan preference = %d\n",
5881 smeConfig.csrConfig.scanBandPreference);
5882
5883 sme_UpdateConfig(hHal, &smeConfig);
5884 }
5885 else {
5886 ret = -EINVAL;
5887 }
5888 break;
5889 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305890 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5891 * connection happens so that the params can take effect during
5892 * association. Also this should not be used in STA+p2p concurrency
5893 * as the param will also effect the STA mode.
5894 */
5895 case WE_SET_MIRACAST_VENDOR_CONFIG:
5896 {
5897 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305898
Abhishek Singh01c73d12015-03-12 15:13:44 +05305899 hddLog(LOG1, FL(
5900 "Set Miracast vendor tuning %d"), set_value);
5901
5902 if (1 == set_value || 0 == set_value)
5903 {
5904 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5905 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5906 {
5907 hddLog( LOGE, FL("set vendor miracast config failed"));
5908 ret = -EIO;
5909 }
5910 }
5911 else
5912 {
5913 hddLog(LOGE,
5914 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5915 ret = -EINVAL;
5916 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305917 break;
5918 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305919
5920 case WE_GET_FRAME_LOG:
5921 {
5922 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5923 != VOS_STATUS_SUCCESS)
5924 {
5925 ret = -EINVAL;
5926 }
5927 break;
5928 }
5929
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305930 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5931 {
5932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5933 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5934 if (set_value == 0 || set_value == 1)
5935 {
5936 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5937 set_value);
5938 }
5939 else
5940 ret = -EINVAL;
5941
5942 break;
5943 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05305944 /* Bit mask value to enable RTS/CTS for different modes
5945 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
5946 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
5947 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
5948 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
5949 * for 5 GHz, VHT80 - 0x1000
5950 */
5951 case WE_SET_RTS_CTS_HTVHT:
5952 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305953
Abhishek Singh41988ba2015-05-25 19:42:29 +05305954 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
5955
5956 if (eHAL_STATUS_SUCCESS !=
5957 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
5958 {
5959 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
5960 ret = -EINVAL;
5961 }
5962 break;
5963 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305964 case WE_SET_MONITOR_STATE:
5965 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305966 v_U32_t magic = 0;
5967 struct completion cmpVar;
5968 long waitRet = 0;
5969 tVOS_CON_MODE mode = hdd_get_conparam();
5970
5971 if( VOS_MONITOR_MODE != mode)
5972 {
5973 hddLog(LOGE, "invalid mode %d", mode);
5974 ret = -EIO;
5975 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305976
5977 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
5978 if( pMonCtx == NULL )
5979 {
5980 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305981 ret = -EIO;
5982 }
5983 if (pMonCtx->state == set_value)
5984 {
5985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5986 FL("already in same mode curr_mode:%d req_mode: %d"),
5987 pMonCtx->state, set_value);
5988 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305989 }
5990 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305991 magic = MON_MODE_MSG_MAGIC;
5992 init_completion(&cmpVar);
5993 if (VOS_STATUS_SUCCESS !=
5994 wlan_hdd_mon_postMsg(&magic, &cmpVar,
5995 pMonCtx, hdd_monPostMsgCb)) {
5996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5997 FL("failed to post MON MODE REQ"));
5998 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
5999 MON_MODE_STOP : MON_MODE_START;
6000 magic = 0;
6001 ret = -EIO;
6002 break;
6003 }
6004 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6005 magic = 0;
6006 if (waitRet <= 0 ){
6007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6008 FL("failed to wait on monitor mode completion %ld"),
6009 waitRet);
6010 }
6011 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306012 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306013 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6014 {
6015 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6016 tAniWifiStartLog start_log;
6017 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6018 !vos_isPktStatsEnabled())
6019 {
6020 hddLog(LOGE, FL("per pkt stats not enabled"));
6021 return -EINVAL;
6022 }
6023 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6024
6025 if (1 == set_value || 0 == set_value)
6026 {
6027 start_log.ringId = RING_ID_PER_PACKET_STATS;
6028 start_log.flag = 0;
6029 if (set_value)
6030 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6031 else
6032 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6033
6034 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6035 }
6036 else
6037 {
6038 hddLog(LOGE,
6039 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6040 set_value);
6041 ret = -EINVAL;
6042 }
6043 break;
6044 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306045
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 default:
6047 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006048 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 sub_cmd, set_value);
6050 break;
6051 }
6052 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306053 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 return ret;
6055}
6056
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306057static int iw_setint_getnone(struct net_device *dev,
6058 struct iw_request_info *info,
6059 union iwreq_data *wrqu, char *extra)
6060{
6061 int ret;
6062
6063 vos_ssr_protect(__func__);
6064 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6065 vos_ssr_unprotect(__func__);
6066
6067 return 0;
6068}
Jeff Johnson295189b2012-06-20 16:38:30 -07006069/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306070static int __iw_setchar_getnone(struct net_device *dev,
6071 struct iw_request_info *info,
6072 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006073{
6074 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306075 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006077 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306078 hdd_adapter_t *pAdapter;
6079 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006080#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306081 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006082#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306083 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306084 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006085
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306086 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306087
6088 if (!capable(CAP_NET_ADMIN))
6089 {
6090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6091 FL("permission check failed"));
6092 return -EPERM;
6093 }
6094
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306095 pAdapter = (netdev_priv(dev));
6096 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006097 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6099 "%s: Adapter is NULL",__func__);
6100 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006101 }
6102
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306103 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6104 ret = wlan_hdd_validate_context(pHddCtx);
6105 if (0 != ret)
6106 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306107 return ret;
6108 }
6109#ifdef WLAN_FEATURE_VOWIFI
6110 pConfig = pHddCtx->cfg_ini;
6111#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306112 /* helper function to get iwreq_data with compat handling. */
6113 if (hdd_priv_get_data(&s_priv_data, wrqu))
6114 {
6115 return -EINVAL;
6116 }
6117
6118 /* make sure all params are correctly passed to function */
6119 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6120 {
6121 return -EINVAL;
6122 }
6123
6124 sub_cmd = s_priv_data.flags;
6125
Arif Hussain0273cba2014-01-07 20:58:29 -08006126 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306127 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6128 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006129 if (NULL == pBuffer)
6130 {
6131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6132 "mem_alloc_copy_from_user_helper fail");
6133 return -ENOMEM;
6134 }
6135
6136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306137 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6139 "%s: Received data %s", __func__, pBuffer);
6140
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 switch(sub_cmd)
6142 {
6143 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006145 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 break;
6147 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006149 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 break;
6151#if defined WLAN_FEATURE_VOWIFI
6152 case WE_NEIGHBOR_REPORT_REQUEST:
6153 {
6154 tRrmNeighborReq neighborReq;
6155 tRrmNeighborRspCallbackInfo callbackInfo;
6156
6157 if (pConfig->fRrmEnable)
6158 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306160 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 if( !neighborReq.no_ssid )
6162 {
Girish Gowli552fc072014-06-14 18:26:16 +05306163 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006164 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 }
6166
6167 callbackInfo.neighborRspCallback = NULL;
6168 callbackInfo.neighborRspCallbackContext = NULL;
6169 callbackInfo.timeout = 5000; //5 seconds
6170 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6171 }
6172 else
6173 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006174 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 ret = -EINVAL;
6176 }
6177 }
6178 break;
6179#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 case WE_SET_AP_WPS_IE:
6181 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306182 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006184 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006185 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 if (VOS_STATUS_SUCCESS != vstatus)
6187 {
6188 ret = -EINVAL;
6189 }
6190 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306191 case WE_SET_ENCRYPT_MSG:
6192 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6193 if (NULL == pkt)
6194 {
6195 hddLog(VOS_TRACE_LEVEL_ERROR,
6196 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306197 ret = -ENOMEM;
6198 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306199 }
6200
6201 memset(pkt, 0, sizeof(tSirpkt80211));
6202
6203 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6204 hddLog(VOS_TRACE_LEVEL_ERROR,
6205 FL("Firmware is not DISA capable"));
6206 ret = -EINVAL;
6207 vos_mem_free(pkt);
6208 break;
6209 }
6210
6211 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6212
6213 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6214 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6215 if (eHAL_STATUS_SUCCESS != ret) {
6216 hddLog(VOS_TRACE_LEVEL_ERROR,
6217 FL("SENDEncryptMSG: fail to post WDA cmd"));
6218 ret = -EINVAL;
6219 }
6220 vos_mem_free(pkt);
6221
6222 break;
6223
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 default:
6225 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006226 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 ret = -EINVAL;
6228 break;
6229 }
6230 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006231 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306232
6233 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 return ret;
6235}
6236
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306237static int iw_setchar_getnone(struct net_device *dev,
6238 struct iw_request_info *info,
6239 union iwreq_data *wrqu, char *extra)
6240{
6241 int ret;
6242
6243 vos_ssr_protect(__func__);
6244 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6245 vos_ssr_unprotect(__func__);
6246
6247 return ret;
6248}
6249
Jeff Johnson295189b2012-06-20 16:38:30 -07006250/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306251static int __iw_setnone_getint(struct net_device *dev,
6252 struct iw_request_info *info,
6253 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006254{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306255 hdd_adapter_t *pAdapter;
6256 tHalHandle hHal;
6257 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 int *value = (int *)extra;
6259 int ret = 0; /* success */
6260
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306261 ENTER();
6262
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306263 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6264 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006265 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6267 "%s: Adapter is NULL",__func__);
6268 return -EINVAL;
6269 }
6270 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6271 ret = wlan_hdd_validate_context(pHddCtx);
6272 if (0 != ret)
6273 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306274 return ret;
6275 }
6276 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6277 if (NULL == hHal)
6278 {
6279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6280 "%s: Hal Context is NULL",__func__);
6281 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006282 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006283
6284 switch (value[0])
6285 {
6286 case WE_GET_11D_STATE:
6287 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006288 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306290
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6292
Arif Hussain6d2a3322013-11-17 19:50:10 -08006293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006294
6295 break;
6296 }
6297
6298 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 break;
6301
6302 case WE_PMC_STATE:
6303 {
6304 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 break;
6307 }
6308 case WE_GET_WLAN_DBG:
6309 {
6310 vos_trace_display();
6311 *value = 0;
6312 break;
6313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 case WE_GET_MAX_ASSOC:
6315 {
6316 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6317 {
c_hpothub8245442013-11-20 23:41:09 +05306318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6319 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006320 ret = -EIO;
6321 }
Girish Gowli385be612014-09-18 11:17:20 +05306322#ifdef WLAN_SOFTAP_VSTA_FEATURE
6323 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6324 {
6325 if (*value > VSTA_NUM_ASSOC_STA)
6326 {
6327 *value = VSTA_NUM_ASSOC_STA;
6328 }
6329 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6330 (*value > (VSTA_NUM_ASSOC_STA -
6331 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6332 {
6333 *value = (VSTA_NUM_ASSOC_STA -
6334 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6335 }
6336 }
6337 else
6338#endif
6339 {
6340 if (*value > NUM_ASSOC_STA)
6341 {
6342 *value = NUM_ASSOC_STA;
6343 }
6344 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6345 (*value > (NUM_ASSOC_STA -
6346 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6347 {
6348 *value = (NUM_ASSOC_STA -
6349 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6350 }
6351 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 break;
6353 }
6354
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 case WE_GET_WDI_DBG:
6356 {
6357 wpalTraceDisplay();
6358 *value = 0;
6359 break;
6360 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006361
6362 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6363 {
6364 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6365 break;
6366 }
6367 case WE_GET_CONCURRENCY_MODE:
6368 {
6369 *value = hdd_get_concurrency_mode ( );
6370
Arif Hussain6d2a3322013-11-17 19:50:10 -08006371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 break;
6373 }
6374
Peng Xu2446a892014-09-05 17:21:18 +05306375 case WE_GET_SCAN_BAND_PREFERENCE:
6376 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306377 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306378 sme_GetConfigParam(hHal, &smeConfig);
6379 *value = smeConfig.csrConfig.scanBandPreference;
6380
6381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6382 "scanBandPreference = %d\n", *value);
6383 break;
6384 }
6385
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 default:
6387 {
6388 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6389 break;
6390 }
6391 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306392 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 return ret;
6394}
6395
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306396static int iw_setnone_getint(struct net_device *dev,
6397 struct iw_request_info *info,
6398 union iwreq_data *wrqu, char *extra)
6399{
6400 int ret;
6401
6402 vos_ssr_protect(__func__);
6403 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6404 vos_ssr_unprotect(__func__);
6405
6406 return ret;
6407
6408}
Jeff Johnson295189b2012-06-20 16:38:30 -07006409/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306410int __iw_set_three_ints_getnone(struct net_device *dev,
6411 struct iw_request_info *info,
6412 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006413{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306414 hdd_adapter_t *pAdapter;
6415 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 int *value = (int *)extra;
6417 int sub_cmd = value[0];
6418 int ret = 0;
6419
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306420 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306421
6422 if (!capable(CAP_NET_ADMIN))
6423 {
6424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6425 FL("permission check failed"));
6426 return -EPERM;
6427 }
6428
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306429 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6430 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006431 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6433 "%s: Adapter is NULL",__func__);
6434 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006435 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306436 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6437 ret = wlan_hdd_validate_context(pHddCtx);
6438 if (0 != ret)
6439 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306440 return ret;
6441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006442 switch(sub_cmd)
6443 {
6444 case WE_SET_WLAN_DBG:
6445 {
6446 vos_trace_setValue( value[1], value[2], value[3]);
6447 break;
6448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006449 case WE_SET_WDI_DBG:
6450 {
6451 wpalTraceSetLevel( value[1], value[2], value[3]);
6452 break;
6453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 case WE_SET_SAP_CHANNELS:
6455 {
6456 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6457 break;
6458 }
6459
6460 default:
6461 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006462 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 break;
6464 }
6465 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306466 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 return ret;
6468}
6469
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306470int iw_set_three_ints_getnone(struct net_device *dev,
6471 struct iw_request_info *info,
6472 union iwreq_data *wrqu, char *extra)
6473{
6474 int ret;
6475
6476 vos_ssr_protect(__func__);
6477 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6478 vos_ssr_unprotect(__func__);
6479
6480 return ret;
6481}
6482
6483static int __iw_get_char_setnone(struct net_device *dev,
6484 struct iw_request_info *info,
6485 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006486{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306487 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306489 hdd_context_t *pHddCtx;
6490 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006491#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006492 hdd_wext_state_t *pWextState;
6493#endif
6494
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306495 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306496 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006497 if (pAdapter == NULL)
6498 {
6499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6500 "%s: pAdapter is NULL!", __func__);
6501 return -EINVAL;
6502 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306503 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6504 ret = wlan_hdd_validate_context(pHddCtx);
6505 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006506 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306507 return ret;
6508 }
6509#ifdef WLAN_FEATURE_11W
6510 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6511 if (NULL == pWextState)
6512 {
6513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6514 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006515 return -EINVAL;
6516 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306517#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006518
Jeff Johnson295189b2012-06-20 16:38:30 -07006519 switch(sub_cmd)
6520 {
6521 case WE_WLAN_VERSION:
6522 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006523 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 break;
6525 }
6526
6527 case WE_GET_STATS:
6528 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306529 tHalHandle hHal = NULL;
6530 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006531 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6532 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6533 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6534
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306535
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 snprintf(extra, WE_MAX_STR_LEN,
6537 "\nTransmit"
6538 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6539 "\n dropped BK %u, BE %u, VI %u, VO %u"
6540 "\n classified BK %u, BE %u, VI %u, VO %u"
6541 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6542 "\n queued BK %u, BE %u, VI %u, VO %u"
6543 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006544 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 "\n fetched BK %u, BE %u, VI %u, VO %u"
6546 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6547 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006548 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 "\n flushed BK %u, BE %u, VI %u, VO %u"
6550 "\n\nReceive"
6551 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6552 "\n\nResetsStats"
6553 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6554 "\n",
6555 pStats->txXmitCalled,
6556 pStats->txXmitDropped,
6557 pStats->txXmitBackPressured,
6558 pStats->txXmitQueued,
6559
6560 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6561 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6562 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6563 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6564
6565 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6566 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6567 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6568 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6569
6570 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6571 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6572 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6573 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6574
6575 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6576 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6577 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6578 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6579
6580 pStats->txFetched,
6581 pStats->txFetchEmpty,
6582 pStats->txFetchLowResources,
6583 pStats->txFetchDequeueError,
6584
6585 pStats->txFetchDequeued,
6586 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006587 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 pStats->txCompleted,
6589 pStats->txFlushed,
6590
6591 pStats->txFetchedAC[WLANTL_AC_BK],
6592 pStats->txFetchedAC[WLANTL_AC_BE],
6593 pStats->txFetchedAC[WLANTL_AC_VI],
6594 pStats->txFetchedAC[WLANTL_AC_VO],
6595
6596 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6597 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6598 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6599 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6600
6601 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6602 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6603 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6604 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6605
Ravi Joshi41914632013-10-21 23:02:21 -07006606 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6607 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6608 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6609 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6610
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 pStats->txFlushedAC[WLANTL_AC_BK],
6612 pStats->txFlushedAC[WLANTL_AC_BE],
6613 pStats->txFlushedAC[WLANTL_AC_VI],
6614 pStats->txFlushedAC[WLANTL_AC_VO],
6615
6616 pStats->rxChains,
6617 pStats->rxPackets,
6618 pStats->rxDropped,
6619 pStats->rxDelivered,
6620 pStats->rxRefused,
6621
6622 pResetStats->totalLogpResets,
6623 pResetStats->totalCMD53Failures,
6624 pResetStats->totalMutexReadFailures,
6625 pResetStats->totalMIFErrorFailures,
6626 pResetStats->totalFWHearbeatFailures,
6627 pResetStats->totalUnknownExceptions
6628 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306629 wrqu->data.length = strlen(extra);
6630
6631 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6632
6633 if (hHal)
6634 pMac = PMAC_STRUCT( hHal );
6635
6636 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6637 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6638 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306639 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6640 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6641 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6642 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306643 "\n",
6644 pMac->pmm.BmpscntSleep,
6645 pMac->pmm.BmpscntAwake,
6646 pMac->pmm.BmpsSleeReqFailCnt,
6647 pMac->pmm.BmpsWakeupReqFailCnt,
6648 pMac->pmm.ImpsCntSleep,
6649 pMac->pmm.ImpsCntAwake,
6650 pMac->pmm.ImpsSleepErrCnt,
6651 pMac->pmm.ImpsWakeupErrCnt,
6652 pMac->pmm.ImpsLastErr
6653 );
6654 }
6655
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 wrqu->data.length = strlen(extra)+1;
6657 break;
6658 }
6659
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306660/* The case prints the current state of the HDD, SME, CSR, PE, TL
6661 *it can be extended for WDI Global State as well.
6662 *And currently it only checks P2P_CLIENT adapter.
6663 *P2P_DEVICE and P2P_GO have not been added as of now.
6664*/
6665 case WE_GET_STATES:
6666 {
6667 int buf = 0, len = 0;
6668 int adapter_num = 0;
6669 int count = 0, check = 1;
6670
6671 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006672 tHalHandle hHal = NULL;
6673 tpAniSirGlobal pMac = NULL;
6674 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306675
6676 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6677 hdd_adapter_t *useAdapter = NULL;
6678
6679 /* Print wlan0 or p2p0 states based on the adapter_num
6680 *by using the correct adapter
6681 */
6682 while ( adapter_num < 2 )
6683 {
6684 if ( WLAN_ADAPTER == adapter_num )
6685 {
6686 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006687 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306688 "\n\n wlan0 States:-");
6689 len += buf;
6690 }
6691 else if ( P2P_ADAPTER == adapter_num )
6692 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006693 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306694 "\n\n p2p0 States:-");
6695 len += buf;
6696
6697 if( !pHddCtx )
6698 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006699 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306700 "\n pHddCtx is NULL");
6701 len += buf;
6702 break;
6703 }
6704
6705 /*Printing p2p0 states only in the case when the device is
6706 configured as a p2p_client*/
6707 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6708 if ( !useAdapter )
6709 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006710 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306711 "\n Device not configured as P2P_CLIENT.");
6712 len += buf;
6713 break;
6714 }
6715 }
6716
6717 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006718 if (!hHal) {
6719 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6720 "\n pMac is NULL");
6721 len += buf;
6722 break;
6723 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306724 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006725 if (!pMac) {
6726 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6727 "\n pMac is NULL");
6728 len += buf;
6729 break;
6730 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306731 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6732 if( !pHddStaCtx )
6733 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006734 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306735 "\n pHddStaCtx is NULL");
6736 len += buf;
6737 break;
6738 }
6739
6740 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6741
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006742 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306743 "\n HDD Conn State - %s "
6744 "\n \n SME State:"
6745 "\n Neighbour Roam State - %s"
6746 "\n CSR State - %s"
6747 "\n CSR Substate - %s"
6748 "\n \n TL STA %d State: %s",
6749 macTraceGetHDDWlanConnState(
6750 pHddStaCtx->conn_info.connState),
6751 macTraceGetNeighbourRoamState(
6752 pMac->roam.neighborRoamInfo.neighborRoamState),
6753 macTraceGetcsrRoamState(
6754 pMac->roam.curState[useAdapter->sessionId]),
6755 macTraceGetcsrRoamSubState(
6756 pMac->roam.curSubState[useAdapter->sessionId]),
6757 pHddStaCtx->conn_info.staId[0],
6758 macTraceGetTLState(tlState)
6759 );
6760 len += buf;
6761 adapter_num++;
6762 }
6763
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006764 if (pMac) {
6765 /* Printing Lim State starting with global lim states */
6766 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6767 "\n \n LIM STATES:-"
6768 "\n Global Sme State - %s "\
6769 "\n Global mlm State - %s "\
6770 "\n",
6771 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6772 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6773 );
6774 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306775
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006776 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05306777 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306778 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006779 if ( pMac->lim.gpSession[count].valid )
6780 {
6781 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6782 "\n Lim Valid Session %d:-"
6783 "\n PE Sme State - %s "
6784 "\n PE Mlm State - %s "
6785 "\n",
6786 check,
6787 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6788 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6789 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306790
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006791 len += buf;
6792 check++;
6793 }
6794 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306795 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306796 }
6797
6798 wrqu->data.length = strlen(extra)+1;
6799 break;
6800 }
6801
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 case WE_GET_CFG:
6803 {
6804 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6805 wrqu->data.length = strlen(extra)+1;
6806 break;
6807 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006808#ifdef WLAN_FEATURE_11AC
6809 case WE_GET_RSSI:
6810 {
6811 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05306812 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07006813 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6814 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6815 wrqu->data.length = strlen(extra)+1;
6816 break;
6817 }
6818#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306819
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006820#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006821 case WE_GET_ROAM_RSSI:
6822 {
6823 v_S7_t s7Rssi = 0;
6824 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6825 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6826 wrqu->data.length = strlen(extra)+1;
6827 break;
6828 }
6829#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006830 case WE_GET_WMM_STATUS:
6831 {
6832 snprintf(extra, WE_MAX_STR_LEN,
6833 "\nDir: 0=up, 1=down, 3=both\n"
6834 "|------------------------|\n"
6835 "|AC | ACM |Admitted| Dir |\n"
6836 "|------------------------|\n"
6837 "|VO | %d | %3s | %d |\n"
6838 "|VI | %d | %3s | %d |\n"
6839 "|BE | %d | %3s | %d |\n"
6840 "|BK | %d | %3s | %d |\n"
6841 "|------------------------|\n",
6842 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6843 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6844 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6845 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6846 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6847 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6848 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6849 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6850 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6851 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6852 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6853 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6854
Jeff Johnsone7245742012-09-05 17:12:55 -07006855
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 wrqu->data.length = strlen(extra)+1;
6857 break;
6858 }
6859 case WE_GET_CHANNEL_LIST:
6860 {
6861 VOS_STATUS status;
6862 v_U8_t i, len;
6863 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306864 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6865 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6866 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006867 tChannelListInfo channel_list;
6868
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006869 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006871 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006873 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006874 return -EINVAL;
6875 }
6876 buf = extra;
6877
6878 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006879 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6880 * needed = 5 * number of channels. Check ifsufficient
6881 * buffer is available and then proceed to fill the buffer.
6882 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6884 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006885 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006886 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006887 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 return -EINVAL;
6889 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006890 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6891 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306892 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6893 {
6894 //Printing Country code in getChannelList
6895 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6896 {
6897 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6898 "%c ", pBuf[i]);
6899 }
6900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 for(i = 0 ; i < channel_list.num_channels; i++)
6902 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006903 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 }
6906 wrqu->data.length = strlen(extra)+1;
6907
6908 break;
6909 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006910#ifdef FEATURE_WLAN_TDLS
6911 case WE_GET_TDLS_PEERS:
6912 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006913 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006914 break;
6915 }
6916#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006917#ifdef WLAN_FEATURE_11W
6918 case WE_GET_11W_INFO:
6919 {
6920 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6921
6922 snprintf(extra, WE_MAX_STR_LEN,
6923 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6924 "\n Number of Unprotected Disassocs %d"
6925 "\n Number of Unprotected Deauths %d",
6926 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6927 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6928 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6929 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6930 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6931
6932 wrqu->data.length = strlen(extra)+1;
6933 break;
6934 }
6935#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306936 case WE_GET_SNR:
6937 {
6938 v_S7_t s7snr = 0;
6939 int status = 0;
6940 hdd_context_t *pHddCtx;
6941 hdd_station_ctx_t *pHddStaCtx;
6942
6943 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6944 status = wlan_hdd_validate_context(pHddCtx);
6945 if (0 != status)
6946 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306947 return status;
6948 }
6949
6950 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6951
6952 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6953 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6954 {
6955 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6956 " ConnectionState-%d", __func__,
6957 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6958 pHddStaCtx->conn_info.connState);
6959 return -ENONET;
6960 }
6961
6962 /*update the stats in TL*/
6963 wlan_hdd_get_station_stats(pAdapter);
6964 wlan_hdd_get_snr(pAdapter, &s7snr);
6965 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6966 wrqu->data.length = strlen(extra) + 1;
6967 break;
6968 }
6969
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05306970#ifdef FEATURE_OEM_DATA_SUPPORT
6971 case WE_GET_OEM_DATA_CAP:
6972 {
6973 return iw_get_oem_data_cap(dev, info, wrqu, extra);
6974 }
6975#endif /* FEATURE_OEM_DATA_SUPPORT */
6976
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306977 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006978 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006979 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 break;
6981 }
6982 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306983 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 return 0;
6985}
6986
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306987static int iw_get_char_setnone(struct net_device *dev,
6988 struct iw_request_info *info,
6989 union iwreq_data *wrqu, char *extra)
6990{
6991 int ret;
6992
6993 vos_ssr_protect(__func__);
6994 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6995 vos_ssr_unprotect(__func__);
6996
6997 return ret;
6998}
6999
Jeff Johnson295189b2012-06-20 16:38:30 -07007000/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307001static int __iw_setnone_getnone(struct net_device *dev,
7002 struct iw_request_info *info,
7003 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007004{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307005 hdd_adapter_t *pAdapter;
7006 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307007 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007008 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307009 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007010
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307011 ENTER();
7012
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307013 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7014 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007015 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7017 "%s: Adapter is NULL",__func__);
7018 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007019 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307020 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7021 ret = wlan_hdd_validate_context(pHddCtx);
7022 if (0 != ret)
7023 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307024 return ret;
7025 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307026 /* helper function to get iwreq_data with compat handling. */
7027 if (hdd_priv_get_data(&s_priv_data, wrqu))
7028 {
7029 return -EINVAL;
7030 }
7031
7032 sub_cmd = s_priv_data.flags;
7033
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 switch (sub_cmd)
7035 {
7036 case WE_CLEAR_STATS:
7037 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7040 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7041 break;
7042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007043 case WE_INIT_AP:
7044 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307045 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7046
7047 /* As Soft AP mode might been changed to STA already with
7048 * killing of Hostapd, need to find the adpater by name
7049 * rather than mode */
7050 hdd_adapter_t* pAdapter_to_stop =
7051 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7052 if( pAdapter_to_stop )
7053 {
7054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7055 "Adapter with name softap.0 already "
7056 "exist, ignoring the request.\nRemove the "
7057 "adapter and try again\n");
7058 break;
7059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 pr_info("Init AP trigger\n");
7061 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7062 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7063 break;
7064 }
7065 case WE_STOP_AP:
7066 {
7067 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7068 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7069 * this is a dead code and need to find the adpater by name rather than mode */
7070 hdd_adapter_t* pAdapter_to_stop =
7071 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7072 if( pAdapter_to_stop )
7073 {
7074 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7075
7076 pr_info("Stopping AP mode\n");
7077
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307078 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7079 {
7080 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7081 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7082 }
7083
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307085 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307086 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7088
7089 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7090 pAdapter_to_stop->macAddressCurrent.bytes);
7091 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7092 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307093
7094 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7095 {
7096 /* put the device back into BMPS */
7097 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007099 }
7100 else
7101 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007102 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 }
7104
7105 break;
7106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007107#ifdef WLAN_BTAMP_FEATURE
7108 case WE_ENABLE_AMP:
7109 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007111 WLANBAP_RegisterWithHCI(pAdapter);
7112 break;
7113 }
7114 case WE_DISABLE_AMP:
7115 {
7116 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7117 VOS_STATUS status;
7118
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007120
7121 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7122 status = WLANBAP_StopAmp();
7123 if(VOS_STATUS_SUCCESS != status )
7124 {
7125 pHddCtx->isAmpAllowed = VOS_TRUE;
7126 hddLog(VOS_TRACE_LEVEL_FATAL,
7127 "%s: Failed to stop AMP", __func__);
7128 }
7129 else
7130 {
7131 //a state m/c implementation in PAL is TBD to avoid this delay
7132 msleep(500);
7133 pHddCtx->isAmpAllowed = VOS_FALSE;
7134 WLANBAP_DeregisterFromHCI();
7135 }
7136
7137 break;
7138 }
7139#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007140 case WE_ENABLE_DXE_STALL_DETECT:
7141 {
schang6295e542013-03-12 15:31:23 -07007142 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7143 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007144 break;
7145 }
7146 case WE_DISPLAY_DXE_SNAP_SHOT:
7147 {
schang6295e542013-03-12 15:31:23 -07007148 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7149 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007150 break;
7151 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307152 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7153 {
7154 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7155 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307156 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307157 break;
7158 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307159
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307160 case WE_SET_REASSOC_TRIGGER:
7161 {
7162 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7163 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7164 v_U32_t roamId = 0;
7165 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307166 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7167 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307168 return 0;
7169 }
7170
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307171 case WE_STOP_OBSS_SCAN:
7172 {
7173 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7174 2.OBSS scan is stopped by Firmware during the disassociation
7175 3.OBSS stop comamnd is added for debugging purpose*/
7176 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7177 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007178
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307179 if (pAdapter == NULL)
7180 {
7181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7182 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307183 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307184 }
7185 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7186 if (pMac == NULL)
7187 {
7188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7189 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307190 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307191 }
7192 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7193 }
7194 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307195 case WE_DUMP_ROAM_TIMER_LOG:
7196 {
7197 vos_dump_roam_time_log_service();
7198 break;
7199 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307200
Mukul Sharma84f27252014-07-14 18:11:42 +05307201 case WE_RESET_ROAM_TIMER_LOG:
7202 {
7203 vos_reset_roam_timer_log();
7204 break;
7205 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307206 case WE_GET_FW_LOGS:
7207 {
7208 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7209 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307210 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307211 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307212 break;
7213 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307214 case WE_GET_FW_MEMDUMP:
7215 {
7216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7217 "FW_MEM_DUMP requested ");
7218 get_fwr_memdump(dev,info,wrqu,extra);
7219 break;
7220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 default:
7222 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007223 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007224 break;
7225 }
7226 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307227 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 return ret;
7229}
7230
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307231static int iw_setnone_getnone(struct net_device *dev,
7232 struct iw_request_info *info,
7233 union iwreq_data *wrqu, char *extra)
7234{
7235 int ret;
7236
7237 vos_ssr_protect(__func__);
7238 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7239 vos_ssr_unprotect(__func__);
7240
7241 return ret;
7242}
7243
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307244void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7245{
7246 /*
7247 * Function to display HDD WMM information
7248 * for Tx Queues.
7249 * Prints globala as well as per client depending
7250 * whether the clients are registered or not.
7251 */
7252 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307253 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7254 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307255 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7256 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307257 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307258
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307259 for ( i=0; i< NUM_TX_QUEUES; i++)
7260 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307261 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307262 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307263 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307264 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307265
7266 for ( i=0; i< NUM_TX_QUEUES; i++) {
7267 if (tx_queue_count[i]) {
7268 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7269 i, tx_queue_count[i]);
7270 }
7271 }
7272
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307273 if(pSapCtx == NULL){
7274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7275 FL("psapCtx is NULL"));
7276 return;
7277 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307278
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307279 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307280 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7281 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307282 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307283 {
7284 hddLog(LOGE, "******STAIndex: %d*********", i);
7285 for ( j=0; j< NUM_TX_QUEUES; j++)
7286 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307287 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7288 {
7289 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307290 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7291 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307292 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7293 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307294 }
7295 }
7296 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307297 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307298
Katya Nigam1fd24402015-02-16 14:52:19 +05307299 if(pHddStaCtx == NULL){
7300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7301 FL("pHddStaCtx is NULL"));
7302 return;
7303 }
7304
7305 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7306 if(pPeerInfo == NULL){
7307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7308 FL("ppeerinfo is NULL"));
7309 return;
7310 }
7311
7312 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7313 {
7314 if(pPeerInfo->ibssStaInfo[i].isUsed)
7315 {
7316 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7317 for ( j=0; j< NUM_TX_QUEUES; j++)
7318 {
7319 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7320 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7321 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7322 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7323 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7324 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7325 }
7326 }
7327 }
7328
7329
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307330}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307331static int __iw_set_var_ints_getnone(struct net_device *dev,
7332 struct iw_request_info *info,
7333 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007334{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307335 hdd_adapter_t *pAdapter;
7336 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307337 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307338 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007339 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307340 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307341 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007342 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307343 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007344 int cmd = 0;
7345 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307346 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007347
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307348 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307349 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307350 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7352 "%s: NULL extra buffer pointer", __func__);
7353 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307354 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307355 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7356 if (NULL == pAdapter)
7357 {
7358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7359 "%s: Adapter is NULL",__func__);
7360 return -EINVAL;
7361 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307362 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307363 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7364 ret = wlan_hdd_validate_context(pHddCtx);
7365 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007366 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307367 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007368 }
Katya Nigameae74b62015-05-28 17:19:16 +05307369 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307370 {
Katya Nigameae74b62015-05-28 17:19:16 +05307371 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7372 if (NULL == hHal)
7373 {
7374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7375 "%s: Hal Context is NULL",__func__);
7376 return -EINVAL;
7377 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307378 }
7379 sub_cmd = wrqu->data.flags;
7380
7381 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7382
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007383
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007384 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7385 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7386 {
7387 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7388 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7389 {
7390 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7391 staId = pStaCtx->conn_info.staId[0];
7392 }
7393 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7394 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7395 {
7396 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7397 staId = pAPCtx->uBCStaId;
7398 }
7399 else
7400 {
7401 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7402 return 0;
7403 }
7404 }
7405
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 switch (sub_cmd)
7407 {
7408 case WE_LOG_DUMP_CMD:
7409 {
7410 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007411 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 apps_args[3], apps_args[4]);
7413
7414 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7415 apps_args[3], apps_args[4]);
7416
7417 }
7418 break;
7419
Jeff Johnson295189b2012-06-20 16:38:30 -07007420 case WE_P2P_NOA_CMD:
7421 {
7422 p2p_app_setP2pPs_t p2pNoA;
7423
7424 p2pNoA.opp_ps = apps_args[0];
7425 p2pNoA.ctWindow = apps_args[1];
7426 p2pNoA.duration = apps_args[2];
7427 p2pNoA.interval = apps_args[3];
7428 p2pNoA.count = apps_args[4];
7429 p2pNoA.single_noa_duration = apps_args[5];
7430 p2pNoA.psSelection = apps_args[6];
7431
7432 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7433 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007434 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7436
7437 hdd_setP2pPs(dev, &p2pNoA);
7438
7439 }
7440 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007441
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307442 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7443 {
7444 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7445 __func__, apps_args[0], apps_args[1]);
7446 vosTraceEnable(apps_args[0], apps_args[1]);
7447 }
7448 break;
7449
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007450 case WE_MTRACE_DUMP_CMD:
7451 {
7452 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7453 "bitmask_of_module %d ",
7454 __func__, apps_args[0], apps_args[1], apps_args[2],
7455 apps_args[3]);
7456 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7457 apps_args[2], apps_args[3]);
7458
7459 }
7460 break;
7461
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007462 case WE_MCC_CONFIG_CREDENTIAL :
7463 {
7464 cmd = 287; //Command should be updated if there is any change
7465 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007466 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007467 {
7468 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7469 }
7470 else
7471 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007472 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007473 return 0;
7474 }
7475 }
7476 break;
7477
7478 case WE_MCC_CONFIG_PARAMS :
7479 {
7480 cmd = 288; //command Should be updated if there is any change
7481 // in the Riva dump command
7482 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7483 }
7484 break;
7485
Chilam NG571c65a2013-01-19 12:27:36 +05307486#ifdef FEATURE_WLAN_TDLS
7487 case WE_TDLS_CONFIG_PARAMS :
7488 {
7489 tdls_config_params_t tdlsParams;
7490
Chilam Ng01120412013-02-19 18:32:21 -08007491 tdlsParams.tdls = apps_args[0];
7492 tdlsParams.tx_period_t = apps_args[1];
7493 tdlsParams.tx_packet_n = apps_args[2];
7494 tdlsParams.discovery_period_t = apps_args[3];
7495 tdlsParams.discovery_tries_n = apps_args[4];
7496 tdlsParams.idle_timeout_t = apps_args[5];
7497 tdlsParams.idle_packet_n = apps_args[6];
7498 tdlsParams.rssi_hysteresis = apps_args[7];
7499 tdlsParams.rssi_trigger_threshold = apps_args[8];
7500 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307501
Chilam Ng01120412013-02-19 18:32:21 -08007502 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307503 }
7504 break;
7505#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307506 case WE_CONFIGURE_MONITOR_MODE:
7507 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307508 v_U32_t magic = 0;
7509 struct completion cmpVar;
7510 long waitRet = 0;
7511
Katya Nigamf0511f62015-05-05 16:40:57 +05307512 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7513 if( pMonCtx == NULL )
7514 {
7515 hddLog(LOGE, "Monitor Context NULL");
7516 break;
7517 }
7518 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7519 __func__, apps_args[0], apps_args[1], apps_args[2],
7520 apps_args[3], apps_args[4]);
7521 /* Input Validation part of FW */
7522 pMonCtx->ChannelNo = apps_args[0];
7523 pMonCtx->ChannelBW = apps_args[1];
7524 pMonCtx->crcCheckEnabled = apps_args[2];
7525 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7526 pMonCtx->is80211to803ConReq = apps_args[4];
7527 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7528 if( pMonCtx->is80211to803ConReq )
7529 pAdapter->dev->type = ARPHRD_ETHER;
7530 else
7531 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7532 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7533 {
7534 hddLog(LOGE, "%s: Filtering data packets as management and control"
7535 " cannot be converted to 802.3 ",__func__);
7536 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7537 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307538 if (MON_MODE_START == pMonCtx->state) {
7539 magic = MON_MODE_MSG_MAGIC;
7540 init_completion(&cmpVar);
7541 if (VOS_STATUS_SUCCESS !=
7542 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7543 pMonCtx, hdd_monPostMsgCb)) {
7544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7545 FL("failed to post MON MODE REQ"));
7546 magic = 0;
7547 ret = -EIO;
7548 break;
7549 }
7550 waitRet = wait_for_completion_timeout(&cmpVar,
7551 MON_MODE_MSG_TIMEOUT);
7552 magic = 0;
7553 if (waitRet <= 0 ) {
7554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7555 FL("failed to wait on monitor mode completion %ld"),
7556 waitRet);
7557 }
7558 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307559 }
7560 break;
7561
7562 case WE_SET_MONITOR_MODE_FILTER:
7563 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307564 v_U32_t magic = 0;
7565 struct completion cmpVar;
7566 long waitRet = 0;
7567
Katya Nigamf0511f62015-05-05 16:40:57 +05307568 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7569 if( pMonCtx == NULL )
7570 {
7571 hddLog(LOGE, "Monitor Context NULL");
7572 break;
7573 }
7574 /* Input Validation Part of FW */
7575 pMonCtx->numOfMacFilters=1;
7576 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7577 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7578 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7579 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7580 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7581 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7582 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7583 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7584 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7585 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7586 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7587 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307588 if (MON_MODE_START == pMonCtx->state) {
7589 magic = MON_MODE_MSG_MAGIC;
7590 init_completion(&cmpVar);
7591 if (VOS_STATUS_SUCCESS !=
7592 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7593 pMonCtx, hdd_monPostMsgCb)) {
7594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7595 FL("failed to post MON MODE REQ"));
7596 magic = 0;
7597 ret = -EIO;
7598 break;
7599 }
7600 waitRet = wait_for_completion_timeout(&cmpVar,
7601 MON_MODE_MSG_TIMEOUT);
7602 magic = 0;
7603 if (waitRet <= 0 ) {
7604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7605 FL("failed to wait on monitor mode completion %ld"),
7606 waitRet);
7607 }
7608 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307609 }
7610 break;
7611
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 default:
7613 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007614 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7615 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 }
7617 break;
7618 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307619 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007620 return 0;
7621}
7622
Girish Gowlifb9758e2014-11-19 15:19:17 +05307623static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7624 struct iw_request_info *info,
7625 union iwreq_data *wrqu, char *extra)
7626{
7627 int ret;
7628 union iwreq_data u_priv_wrqu;
7629 int apps_args[MAX_VAR_ARGS] = {0};
7630 int num_args;
7631
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05307632 if (!capable(CAP_NET_ADMIN))
7633 {
7634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7635 FL("permission check failed"));
7636 return -EPERM;
7637 }
7638
Girish Gowlifb9758e2014-11-19 15:19:17 +05307639 /* helper function to get iwreq_data with compat handling. */
7640 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7641 {
7642 return -EINVAL;
7643 }
7644
7645 if (NULL == u_priv_wrqu.data.pointer)
7646 {
7647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7648 "%s: NULL data pointer", __func__);
7649 return -EINVAL;
7650 }
7651
7652 num_args = u_priv_wrqu.data.length;
7653 if (num_args > MAX_VAR_ARGS)
7654 {
7655 num_args = MAX_VAR_ARGS;
7656 }
7657
7658 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7659 (sizeof(int)) * num_args))
7660 {
7661 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7662 "%s: failed to copy data from user buffer", __func__);
7663 return -EFAULT;
7664 }
7665
7666 vos_ssr_protect(__func__);
7667 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7668 (char *)&apps_args);
7669 vos_ssr_unprotect(__func__);
7670
7671 return ret;
7672}
7673
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307674int iw_set_var_ints_getnone(struct net_device *dev,
7675 struct iw_request_info *info,
7676 union iwreq_data *wrqu, char *extra)
7677{
7678 int ret;
7679 vos_ssr_protect(__func__);
7680 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7681 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007682
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307683 return ret;
7684}
7685
7686static int __iw_add_tspec(struct net_device *dev,
7687 struct iw_request_info *info,
7688 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007689{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307690 hdd_adapter_t *pAdapter;
7691 hdd_station_ctx_t *pHddStaCtx;
7692 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7694 int params[HDD_WLAN_WMM_PARAM_COUNT];
7695 sme_QosWmmTspecInfo tSpec;
7696 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307697 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307698 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007699
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307700 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307701 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7702 if (NULL == pAdapter)
7703 {
7704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7705 "%s: Adapter is NULL",__func__);
7706 return -EINVAL;
7707 }
7708 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7709 ret = wlan_hdd_validate_context(pHddCtx);
7710 if (0 != ret)
7711 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307712 return ret;
7713 }
7714 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7715 if (NULL == pHddStaCtx)
7716 {
7717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7718 "%s: STA Context is NULL",__func__);
7719 return -EINVAL;
7720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 // make sure the application is sufficiently priviledged
7722 // note that the kernel will do this for "set" ioctls, but since
7723 // this ioctl wants to return status to user space it must be
7724 // defined as a "get" ioctl
7725 if (!capable(CAP_NET_ADMIN))
7726 {
7727 return -EPERM;
7728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007729 // we must be associated in order to add a tspec
7730 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7731 {
7732 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7733 return 0;
7734 }
7735
7736 // since we are defined to be a "get" ioctl, and since the number
7737 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307738 // will pass down in the iwreq_data, we must copy the "set" params.
7739 // We must handle the compat for iwreq_data in 32U/64K environment.
7740
7741 // helper fucntion to get iwreq_data with compat handling.
7742 if (hdd_priv_get_data(&s_priv_data, wrqu))
7743 {
7744 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7745 return 0;
7746 }
7747
7748 // make sure all params are correctly passed to function
7749 if ((NULL == s_priv_data.pointer) ||
7750 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7751 {
7752 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7753 return 0;
7754 }
7755
Jeff Johnson295189b2012-06-20 16:38:30 -07007756 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307757 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007758 {
7759 // hmmm, can't get them
7760 return -EIO;
7761 }
7762
7763 // clear the tspec
7764 memset(&tSpec, 0, sizeof(tSpec));
7765
7766 // validate the handle
7767 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7768 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7769 {
7770 // that one is reserved
7771 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7772 return 0;
7773 }
7774
7775 // validate the TID
7776 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7777 {
7778 // out of range
7779 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7780 return 0;
7781 }
7782 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7783
7784 // validate the direction
7785 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7786 {
7787 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7788 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7789 break;
7790
7791 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7792 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7793 break;
7794
7795 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7796 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7797 break;
7798
7799 default:
7800 // unknown
7801 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7802 return 0;
7803 }
7804
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307805 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7806
Jeff Johnson295189b2012-06-20 16:38:30 -07007807 // validate the user priority
7808 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7809 {
7810 // out of range
7811 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7812 return 0;
7813 }
7814 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307815 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7816 {
7817 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7818 return 0;
7819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007820
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7822 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7823 tSpec.ts_info.psb, tSpec.ts_info.up);
7824
Jeff Johnson295189b2012-06-20 16:38:30 -07007825 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7826 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7827 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7828 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7829 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7830 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7831 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7832 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7833 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7834 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7835 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7836 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7837
7838 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7839
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307840 // Save the expected UAPSD settings by application, this will be needed
7841 // when re-negotiating UAPSD settings during BT Coex cases.
7842 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7843
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 // validate the ts info ack policy
7845 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7846 {
7847 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7848 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7849 break;
7850
7851 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7852 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7853 break;
7854
7855 default:
7856 // unknown
7857 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7858 return 0;
7859 }
7860
7861 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307862
7863 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 return 0;
7865}
7866
7867
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307868static int iw_add_tspec(struct net_device *dev,
7869 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 union iwreq_data *wrqu, char *extra)
7871{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307872 int ret;
7873
7874 vos_ssr_protect(__func__);
7875 ret = __iw_add_tspec(dev, info, wrqu, extra);
7876 vos_ssr_unprotect(__func__);
7877
7878 return ret;
7879}
7880
7881static int __iw_del_tspec(struct net_device *dev,
7882 struct iw_request_info *info,
7883 union iwreq_data *wrqu, char *extra)
7884{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307885 hdd_adapter_t *pAdapter;
7886 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 int *params = (int *)extra;
7888 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7889 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307890 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007891
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307892 ENTER();
7893
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307894 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7895 if (NULL == pAdapter)
7896 {
7897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7898 "%s: Adapter is NULL",__func__);
7899 return -EINVAL;
7900 }
7901
7902 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7903 ret = wlan_hdd_validate_context(pHddCtx);
7904 if (0 != ret)
7905 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307906 return ret;
7907 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 // make sure the application is sufficiently priviledged
7909 // note that the kernel will do this for "set" ioctls, but since
7910 // this ioctl wants to return status to user space it must be
7911 // defined as a "get" ioctl
7912 if (!capable(CAP_NET_ADMIN))
7913 {
7914 return -EPERM;
7915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 // although we are defined to be a "get" ioctl, the params we require
7917 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7918 // is no need to copy the params from user space
7919
7920 // validate the handle
7921 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7922 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7923 {
7924 // that one is reserved
7925 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7926 return 0;
7927 }
7928
7929 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307930
7931 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 return 0;
7933}
7934
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307935static int iw_del_tspec(struct net_device *dev,
7936 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007937 union iwreq_data *wrqu, char *extra)
7938{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307939 int ret;
7940
7941 vos_ssr_protect(__func__);
7942 ret = __iw_del_tspec(dev, info, wrqu, extra);
7943 vos_ssr_unprotect(__func__);
7944
7945 return ret;
7946}
7947
7948
7949static int __iw_get_tspec(struct net_device *dev,
7950 struct iw_request_info *info,
7951 union iwreq_data *wrqu, char *extra)
7952{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307953 hdd_adapter_t *pAdapter;
7954 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 int *params = (int *)extra;
7956 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7957 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307958 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007959
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307960 ENTER();
7961
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 // although we are defined to be a "get" ioctl, the params we require
7963 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7964 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307965 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7966 if (NULL == pAdapter)
7967 {
7968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7969 "%s: Adapter is NULL",__func__);
7970 return -EINVAL;
7971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007972
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307973 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7974 ret = wlan_hdd_validate_context(pHddCtx);
7975 if (0 != ret)
7976 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307977 return ret;
7978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007979 // validate the handle
7980 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7981 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7982 {
7983 // that one is reserved
7984 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7985 return 0;
7986 }
7987
7988 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307989 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 return 0;
7991}
7992
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307993static int iw_get_tspec(struct net_device *dev,
7994 struct iw_request_info *info,
7995 union iwreq_data *wrqu, char *extra)
7996{
7997 int ret;
7998
7999 vos_ssr_protect(__func__);
8000 ret = __iw_get_tspec(dev, info, wrqu, extra);
8001 vos_ssr_unprotect(__func__);
8002
8003 return ret;
8004}
8005
Jeff Johnson295189b2012-06-20 16:38:30 -07008006#ifdef WLAN_FEATURE_VOWIFI_11R
8007//
8008//
8009// Each time the supplicant has the auth_request or reassoc request
8010// IEs ready. This is pushed to the driver. The driver will inturn use
8011// it to send out the auth req and reassoc req for 11r FT Assoc.
8012//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308013static int __iw_set_fties(struct net_device *dev,
8014 struct iw_request_info *info,
8015 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008016{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308017 hdd_adapter_t *pAdapter;
8018 hdd_station_ctx_t *pHddStaCtx;
8019 hdd_context_t *pHddCtx;
8020 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008021 //v_CONTEXT_t pVosContext;
8022
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308023 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308024 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8025 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008026 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8028 "%s: Adapter is NULL",__func__);
8029 return -EINVAL;
8030 }
8031 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8032 ret = wlan_hdd_validate_context(pHddCtx);
8033 if (0 != ret)
8034 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308035 return ret;
8036 }
8037 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8038 if (NULL == pHddStaCtx)
8039 {
8040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8041 "%s: STA Context is NULL",__func__);
8042 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 if (!wrqu->data.length)
8045 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008046 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 return -EINVAL;
8048 }
8049 if (wrqu->data.pointer == NULL)
8050 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008051 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008052 return -EINVAL;
8053 }
8054
8055 // Added for debug on reception of Re-assoc Req.
8056 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8057 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008058 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008059 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008060 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 }
8062
8063#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008064 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008065#endif
8066
8067 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008068 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 wrqu->data.length);
8070
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308071 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 return 0;
8073}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308074
8075static int iw_set_fties(struct net_device *dev,
8076 struct iw_request_info *info,
8077 union iwreq_data *wrqu, char *extra)
8078{
8079 int ret;
8080
8081 vos_ssr_protect(__func__);
8082 ret = __iw_set_fties(dev, info, wrqu, extra);
8083 vos_ssr_unprotect(__func__);
8084
8085 return ret;
8086}
Jeff Johnson295189b2012-06-20 16:38:30 -07008087#endif
8088
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308089static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008090 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008091 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008092{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308093 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008094 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308095 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008096 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308097 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008098 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8099 int idx;
8100 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008101
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308102 ENTER();
8103
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308104 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8105 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008106 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8108 "%s: Adapter is NULL",__func__);
8109 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008110 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308111 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8112 ret_val = wlan_hdd_validate_context(pHddCtx);
8113 if (0 != ret_val)
8114 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308115 return ret_val;
8116 }
8117 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8118 if (NULL == hHal)
8119 {
8120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8121 "%s: Hal Context is NULL",__func__);
8122 return -EINVAL;
8123 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308124 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8125 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308126#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008127
Amar Singhalf3a6e762013-02-19 15:06:50 -08008128 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8129 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008130 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008131 hddLog(VOS_TRACE_LEVEL_ERROR,
8132 "%s: vos_mem_alloc failed", __func__);
8133 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008134 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008135
8136 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8137
8138 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8139 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8140
8141 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8142 mc_addr_list_ptr->ulMulticastAddrCnt);
8143
8144 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008145 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008146 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8147 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8148
8149 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8150 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008151 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008152
Amar Singhalf3a6e762013-02-19 15:06:50 -08008153 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8154 vos_mem_free(mc_addr_list_ptr);
8155 if (eHAL_STATUS_SUCCESS != ret_val)
8156 {
8157 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8158 __func__);
8159 return -EINVAL;
8160 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308161#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308162 }
8163 else
8164 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008165
Amar Singhalf3a6e762013-02-19 15:06:50 -08008166 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8167 "%s: Set MC BC Filter Config request: %d suspend %d",
8168 __func__, pRequest->mcastBcastFilterSetting,
8169 pHddCtx->hdd_wlan_suspended);
8170
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308171 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008172
8173 if (pHddCtx->hdd_wlan_suspended)
8174 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008175 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8176 if (NULL == wlanRxpFilterParam)
8177 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308178 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008179 "%s: vos_mem_alloc failed", __func__);
8180 return -EINVAL;
8181 }
8182
Amar Singhalf3a6e762013-02-19 15:06:50 -08008183 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8184 pRequest->mcastBcastFilterSetting;
8185 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8186
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308187 hdd_conf_hostoffload(pAdapter, TRUE);
8188 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8189 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008190
8191 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8192 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308193 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008194 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8195 wlanRxpFilterParam->setMcstBcstFilter);
8196
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308197 if (eHAL_STATUS_SUCCESS !=
8198 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8199 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008200 {
8201 hddLog(VOS_TRACE_LEVEL_ERROR,
8202 "%s: Failure to execute set HW MC/BC Filter request",
8203 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008204 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008205 return -EINVAL;
8206 }
8207
c_hpothud3ce76d2014-10-28 10:34:13 +05308208 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8209 {
8210 pHddCtx->sus_res_mcastbcast_filter =
8211 pRequest->mcastBcastFilterSetting;
8212 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008213 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008215
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308216 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 return 0;
8218}
8219
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308220static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8221 struct iw_request_info *info,
8222 union iwreq_data *wrqu, char *extra)
8223{
8224 int ret;
8225
8226 vos_ssr_protect(__func__);
8227 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8228 vos_ssr_unprotect(__func__);
8229
8230 return ret;
8231}
8232
8233static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8234 struct iw_request_info *info,
8235 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008236{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308237 hdd_adapter_t *pAdapter;
8238 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308239 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308240 int ret = 0;
8241
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308242 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008243
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308244 if (!capable(CAP_NET_ADMIN))
8245 {
8246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8247 FL("permission check failed"));
8248 return -EPERM;
8249 }
8250
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308251 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8252 if (NULL == pAdapter)
8253 {
8254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8255 "%s: Adapter is NULL",__func__);
8256 return -EINVAL;
8257 }
8258
8259 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8260 ret = wlan_hdd_validate_context(pHddCtx);
8261 if (0 != ret)
8262 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308263 return ret;
8264 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308265 //Reset the filter to INI value as we have to clear the dynamic filter
8266 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008267
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308268 //Configure FW with new setting
8269 if (pHddCtx->hdd_wlan_suspended)
8270 {
8271 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8272 if (NULL == wlanRxpFilterParam)
8273 {
8274 hddLog(VOS_TRACE_LEVEL_ERROR,
8275 "%s: vos_mem_alloc failed", __func__);
8276 return -EINVAL;
8277 }
8278
8279 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8280 pHddCtx->configuredMcastBcastFilter;
8281 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8282
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308283 hdd_conf_hostoffload(pAdapter, TRUE);
8284 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8285 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308286
8287 if (eHAL_STATUS_SUCCESS !=
8288 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8289 wlanRxpFilterParam))
8290 {
8291 hddLog(VOS_TRACE_LEVEL_ERROR,
8292 "%s: Failure to execute set HW MC/BC Filter request",
8293 __func__);
8294 vos_mem_free(wlanRxpFilterParam);
8295 return -EINVAL;
8296 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308297
8298 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8299 {
8300 pHddCtx->sus_res_mcastbcast_filter =
8301 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8302 }
8303
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308304 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308305 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 return 0;
8307}
8308
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308309
8310static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8311 struct iw_request_info *info,
8312 union iwreq_data *wrqu, char *extra)
8313{
8314 int ret;
8315
8316 vos_ssr_protect(__func__);
8317 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8318 vos_ssr_unprotect(__func__);
8319
8320 return ret;
8321}
8322
8323static int __iw_set_host_offload(struct net_device *dev,
8324 struct iw_request_info *info,
8325 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008326{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308327 hdd_adapter_t *pAdapter;
8328 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008329 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308331 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008332
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308333 ENTER();
8334
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308335 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8336 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008337 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8339 "%s: Adapter is NULL",__func__);
8340 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008341 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308342 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8343 ret = wlan_hdd_validate_context(pHddCtx);
8344 if (0 != ret)
8345 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308346 return ret;
8347 }
8348
Jeff Johnson295189b2012-06-20 16:38:30 -07008349 /* Debug display of request components. */
8350 switch (pRequest->offloadType)
8351 {
8352 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008353 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 switch (pRequest->enableOrDisable)
8355 {
8356 case WLAN_OFFLOAD_DISABLE:
8357 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8358 break;
8359 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8360 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8361 case WLAN_OFFLOAD_ENABLE:
8362 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8363 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8364 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8365 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8366 }
8367 break;
8368
8369 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008370 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008371 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 switch (pRequest->enableOrDisable)
8373 {
8374 case WLAN_OFFLOAD_DISABLE:
8375 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8376 break;
8377 case WLAN_OFFLOAD_ENABLE:
8378 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8379 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8380 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8381 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8382 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8383 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8384 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8385 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8386 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8387 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8388 }
8389 }
8390
8391 /* Execute offload request. The reason that we can copy the request information
8392 from the ioctl structure to the SME structure is that they are laid out
8393 exactly the same. Otherwise, each piece of information would have to be
8394 copied individually. */
8395 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008396 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8397 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008399 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 __func__);
8401 return -EINVAL;
8402 }
8403
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308404 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 return 0;
8406}
8407
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308408static int iw_set_host_offload(struct net_device *dev,
8409 struct iw_request_info *info,
8410 union iwreq_data *wrqu, char *extra)
8411{
8412 int ret;
8413
8414 vos_ssr_protect(__func__);
8415 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8416 vos_ssr_unprotect(__func__);
8417
8418 return ret;
8419}
8420
8421static int __iw_set_keepalive_params(struct net_device *dev,
8422 struct iw_request_info *info,
8423 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008424{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308425 hdd_adapter_t *pAdapter;
8426 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008427 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008428 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308429 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008430
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308431 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308432 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8433 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8436 "%s: Adapter is NULL",__func__);
8437 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308439 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8440 ret = wlan_hdd_validate_context(pHddCtx);
8441 if (0 != ret)
8442 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308443 return ret;
8444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008446 hddLog(VOS_TRACE_LEVEL_INFO,
8447 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8448 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008449
8450 switch (pRequest->packetType)
8451 {
8452 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008453 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 break;
8455
8456 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8457
Arif Hussain6d2a3322013-11-17 19:50:10 -08008458 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008459 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008460
8461 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8462 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8463 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8464
8465 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8466 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8467 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8468
8469 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8470 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8471 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8472 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8473 break;
8474
8475 }
8476
8477 /* Execute keep alive request. The reason that we can copy the request information
8478 from the ioctl structure to the SME structure is that they are laid out
8479 exactly the same. Otherwise, each piece of information would have to be
8480 copied individually. */
8481 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8482
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308483 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8484 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008485
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008486 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008487 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008489 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008490 __func__);
8491 return -EINVAL;
8492 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308493 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008494 return 0;
8495}
8496
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308497static int iw_set_keepalive_params(struct net_device *dev,
8498 struct iw_request_info *info,
8499 union iwreq_data *wrqu, char *extra)
8500{
8501 int ret;
8502 vos_ssr_protect(__func__);
8503 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8504 vos_ssr_unprotect(__func__);
8505
8506 return ret;
8507}
8508
Jeff Johnson295189b2012-06-20 16:38:30 -07008509#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008510int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008511 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008512{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008513 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8514 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008515 int i=0;
8516
8517 if (pHddCtx->cfg_ini->disablePacketFilter)
8518 {
8519 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008520 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 return 0;
8522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 /* Debug display of request components. */
8524 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008525 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008526
8527 switch (pRequest->filterAction)
8528 {
8529 case HDD_RCV_FILTER_SET:
8530 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008531 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008532
8533 packetFilterSetReq.filterId = pRequest->filterId;
8534 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8535 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008536 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 __func__, pRequest->numParams);
8538 return -EINVAL;
8539 }
8540 packetFilterSetReq.numFieldParams = pRequest->numParams;
8541 packetFilterSetReq.coalesceTime = 0;
8542 packetFilterSetReq.filterType = 1;
8543 for (i=0; i < pRequest->numParams; i++)
8544 {
8545 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8546 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8547 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8548 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8549 packetFilterSetReq.paramsData[i].reserved = 0;
8550
Arif Hussain6d2a3322013-11-17 19:50:10 -08008551 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008552 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8553 packetFilterSetReq.filterType);
8554
Arif Hussain6d2a3322013-11-17 19:50:10 -08008555 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05308557 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
8558 (pRequest->paramsData[i].dataLength))
8559 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008560
8561 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8562 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8563 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8564 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8565
Arif Hussain6d2a3322013-11-17 19:50:10 -08008566 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008567 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8568 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8569 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8570
Arif Hussain6d2a3322013-11-17 19:50:10 -08008571 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008572 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8573 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8574 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8575 }
8576
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008577 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008578 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008579 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008580 __func__);
8581 return -EINVAL;
8582 }
8583
8584 break;
8585
8586 case HDD_RCV_FILTER_CLEAR:
8587
Arif Hussain6d2a3322013-11-17 19:50:10 -08008588 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008589 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008590 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008591 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008592 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008593 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 __func__);
8595 return -EINVAL;
8596 }
8597 break;
8598
8599 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008600 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008601 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008602 return -EINVAL;
8603 }
8604 return 0;
8605}
8606
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308607int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8608 tANI_U8 sessionId)
8609{
8610 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8611 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8612
8613 if (NULL == pHddCtx)
8614 {
8615 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8616 return -EINVAL;
8617 }
8618
8619 if (pHddCtx->isLogpInProgress)
8620 {
8621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8622 "%s:LOGP in Progress. Ignore!!!", __func__);
8623 return -EBUSY;
8624 }
8625
8626 if (pHddCtx->cfg_ini->disablePacketFilter)
8627 {
8628 hddLog(VOS_TRACE_LEVEL_ERROR,
8629 "%s: Packet Filtering Disabled. Returning ",
8630 __func__ );
8631 return -EINVAL;
8632 }
8633
8634 switch (filterType)
8635 {
8636 /* For setting IPV6 MC and UC Filter we need to configure
8637 * 2 filters, one for MC and one for UC.
8638 * The Filter ID shouldn't be swapped, which results in making
8639 * UC Filter ineffective.
8640 * We have Hardcode all the values
8641 *
8642 * Reason for a seperate UC filter is because, driver need to
8643 * specify the FW that the specific filter is for unicast
8644 * otherwise FW will not pass the unicast frames by default
8645 * through the filter. This is required to avoid any performance
8646 * hits when no unicast filter is set and only MC/BC are set.
8647 * The way driver informs host is by using the MAC protocol
8648 * layer, CMP flag set to MAX, CMP Data set to 1.
8649 */
8650
8651 case HDD_FILTER_IPV6_MC_UC:
8652 /* Setting IPV6 MC Filter below
8653 */
8654 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8655 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8656 packetFilterSetReq.numFieldParams = 2;
8657 packetFilterSetReq.paramsData[0].protocolLayer =
8658 HDD_FILTER_PROTO_TYPE_MAC;
8659 packetFilterSetReq.paramsData[0].cmpFlag =
8660 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8661 packetFilterSetReq.paramsData[0].dataOffset =
8662 WLAN_HDD_80211_FRM_DA_OFFSET;
8663 packetFilterSetReq.paramsData[0].dataLength = 1;
8664 packetFilterSetReq.paramsData[0].compareData[0] =
8665 HDD_IPV6_MC_CMP_DATA;
8666
8667 packetFilterSetReq.paramsData[1].protocolLayer =
8668 HDD_FILTER_PROTO_TYPE_ARP;
8669 packetFilterSetReq.paramsData[1].cmpFlag =
8670 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8671 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8672 packetFilterSetReq.paramsData[1].dataLength = 2;
8673 packetFilterSetReq.paramsData[1].compareData[0] =
8674 HDD_IPV6_CMP_DATA_0;
8675 packetFilterSetReq.paramsData[1].compareData[1] =
8676 HDD_IPV6_CMP_DATA_1;
8677
8678
8679 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8680 &packetFilterSetReq, sessionId))
8681 {
8682 hddLog(VOS_TRACE_LEVEL_ERROR,
8683 "%s: Failure to execute Set IPv6 Mulicast Filter",
8684 __func__);
8685 return -EINVAL;
8686 }
8687
8688 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8689
8690 /*
8691 * Setting IPV6 UC Filter below
8692 */
8693 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8694 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8695 packetFilterSetReq.numFieldParams = 2;
8696 packetFilterSetReq.paramsData[0].protocolLayer =
8697 HDD_FILTER_PROTO_TYPE_MAC;
8698 packetFilterSetReq.paramsData[0].cmpFlag =
8699 HDD_FILTER_CMP_TYPE_MAX;
8700 packetFilterSetReq.paramsData[0].dataOffset = 0;
8701 packetFilterSetReq.paramsData[0].dataLength = 1;
8702 packetFilterSetReq.paramsData[0].compareData[0] =
8703 HDD_IPV6_UC_CMP_DATA;
8704
8705 packetFilterSetReq.paramsData[1].protocolLayer =
8706 HDD_FILTER_PROTO_TYPE_ARP;
8707 packetFilterSetReq.paramsData[1].cmpFlag =
8708 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8709 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8710 packetFilterSetReq.paramsData[1].dataLength = 2;
8711 packetFilterSetReq.paramsData[1].compareData[0] =
8712 HDD_IPV6_CMP_DATA_0;
8713 packetFilterSetReq.paramsData[1].compareData[1] =
8714 HDD_IPV6_CMP_DATA_1;
8715
8716 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8717 &packetFilterSetReq, sessionId))
8718 {
8719 hddLog(VOS_TRACE_LEVEL_ERROR,
8720 "%s: Failure to execute Set IPv6 Unicast Filter",
8721 __func__);
8722 return -EINVAL;
8723 }
8724
8725 break;
8726
8727 case HDD_FILTER_IPV6_MC:
8728 /*
8729 * IPV6 UC Filter might be already set,
8730 * clear the UC Filter. As the Filter
8731 * IDs are static, we can directly clear it.
8732 */
8733 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8734 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8735 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8736 &packetFilterClrReq, sessionId))
8737 {
8738 hddLog(VOS_TRACE_LEVEL_ERROR,
8739 "%s: Failure to execute Clear IPv6 Unicast Filter",
8740 __func__);
8741 return -EINVAL;
8742 }
8743
8744 /*
8745 * Setting IPV6 MC Filter below
8746 */
8747 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8748 packetFilterSetReq.numFieldParams = 2;
8749 packetFilterSetReq.paramsData[0].protocolLayer =
8750 HDD_FILTER_PROTO_TYPE_MAC;
8751 packetFilterSetReq.paramsData[0].cmpFlag =
8752 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8753 packetFilterSetReq.paramsData[0].dataOffset =
8754 WLAN_HDD_80211_FRM_DA_OFFSET;
8755 packetFilterSetReq.paramsData[0].dataLength = 1;
8756 packetFilterSetReq.paramsData[0].compareData[0] =
8757 HDD_IPV6_MC_CMP_DATA;
8758
8759 packetFilterSetReq.paramsData[1].protocolLayer =
8760 HDD_FILTER_PROTO_TYPE_ARP;
8761 packetFilterSetReq.paramsData[1].cmpFlag =
8762 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8763 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8764 packetFilterSetReq.paramsData[1].dataLength = 2;
8765 packetFilterSetReq.paramsData[1].compareData[0] =
8766 HDD_IPV6_CMP_DATA_0;
8767 packetFilterSetReq.paramsData[1].compareData[1] =
8768 HDD_IPV6_CMP_DATA_1;
8769
8770
8771 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8772 &packetFilterSetReq, sessionId))
8773 {
8774 hddLog(VOS_TRACE_LEVEL_ERROR,
8775 "%s: Failure to execute Set IPv6 Multicast Filter",
8776 __func__);
8777 return -EINVAL;
8778 }
8779 break;
8780
8781 default :
8782 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8783 "%s: Packet Filter Request: Invalid",
8784 __func__);
8785 return -EINVAL;
8786 }
8787 return 0;
8788}
8789
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308790void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008791{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308792 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308793 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008794 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308795 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008796
Yue Ma3ede6052013-08-29 00:33:26 -07008797 if (NULL == pHddCtx)
8798 {
8799 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8800 return;
8801 }
8802
8803 hHal = pHddCtx->hHal;
8804
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308805 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308807 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8808 return;
8809 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308810
8811 /* Check if INI is enabled or not, other wise just return
8812 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308813 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308814 {
8815 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8816 if (NULL == pMulticastAddrs)
8817 {
8818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8819 return;
8820 }
8821
Jeff Johnson295189b2012-06-20 16:38:30 -07008822 if (set)
8823 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308824 /* Following pre-conditions should be satisfied before wei
8825 * configure the MC address list.
8826 */
8827 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8828 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8829 && pAdapter->mc_addr_list.mc_cnt
8830 && (eConnectionState_Associated ==
8831 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8832 {
8833 pMulticastAddrs->ulMulticastAddrCnt =
8834 pAdapter->mc_addr_list.mc_cnt;
8835 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8836 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008837 memcpy(pMulticastAddrs->multicastAddr[i],
8838 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308839 sizeof(pAdapter->mc_addr_list.addr[i]));
8840 hddLog(VOS_TRACE_LEVEL_INFO,
8841 "%s: %s multicast filter: addr ="
8842 MAC_ADDRESS_STR,
8843 __func__, set ? "setting" : "clearing",
8844 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8845 }
8846 /* Set multicast filter */
8847 sme_8023MulticastList(hHal, pAdapter->sessionId,
8848 pMulticastAddrs);
8849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008850 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308851 else
8852 {
8853 /* Need to clear only if it was previously configured
8854 */
8855 if (pAdapter->mc_addr_list.isFilterApplied)
8856 {
8857 pMulticastAddrs->ulMulticastAddrCnt = 0;
8858 sme_8023MulticastList(hHal, pAdapter->sessionId,
8859 pMulticastAddrs);
8860 }
8861
8862 }
8863 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008864 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008865 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308866 else
8867 {
8868 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308869 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308870 }
8871 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008872}
8873
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308874static int __iw_set_packet_filter_params(struct net_device *dev,
8875 struct iw_request_info *info,
8876 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308877{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308878 hdd_adapter_t *pAdapter;
8879 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008880 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308881 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308882 struct iw_point s_priv_data;
8883
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308884 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05308885
8886 if (!capable(CAP_NET_ADMIN))
8887 {
8888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8889 FL("permission check failed"));
8890 return -EPERM;
8891 }
8892
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308893 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8894 if (NULL == pAdapter)
8895 {
8896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8897 "%s: Adapter is NULL",__func__);
8898 return -EINVAL;
8899 }
8900 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8901 ret = wlan_hdd_validate_context(pHddCtx);
8902 if (0 != ret)
8903 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308904 return ret;
8905 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308906 if (hdd_priv_get_data(&s_priv_data, wrqu))
8907 {
8908 return -EINVAL;
8909 }
8910
8911 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8912 {
8913 return -EINVAL;
8914 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008915
Arif Hussain0273cba2014-01-07 20:58:29 -08008916 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308917 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8918 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008919 if (NULL == pRequest)
8920 {
8921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8922 "mem_alloc_copy_from_user_helper fail");
8923 return -ENOMEM;
8924 }
8925
8926 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8927 kfree(pRequest);
8928
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308929 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008930 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008931}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308932
8933static int iw_set_packet_filter_params(struct net_device *dev,
8934 struct iw_request_info *info,
8935 union iwreq_data *wrqu, char *extra)
8936{
8937 int ret;
8938
8939 vos_ssr_protect(__func__);
8940 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8941 vos_ssr_unprotect(__func__);
8942
8943 return ret;
8944}
Jeff Johnson295189b2012-06-20 16:38:30 -07008945#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308946static int __iw_get_statistics(struct net_device *dev,
8947 struct iw_request_info *info,
8948 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008949{
8950
8951 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8952 eHalStatus status = eHAL_STATUS_SUCCESS;
8953 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308954 hdd_adapter_t *pAdapter;
8955 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008956 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308957 int tlen = 0, ret = 0;
8958 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008959
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308960 tCsrGlobalClassAStatsInfo *aStats;
8961 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008962
8963 ENTER();
8964
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308965 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8966 if (NULL == pAdapter)
8967 {
8968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8969 "%s: Adapter is NULL",__func__);
8970 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008971 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308972 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8973 ret = wlan_hdd_validate_context(pHddCtx);
8974 if (0 != ret)
8975 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308976 return ret;
8977 }
8978 pStats = &(pAdapter->hdd_stats.summary_stat);
8979 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8980 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008981 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8982
8983 wrqu->txpower.value = 0;
8984 }
8985 else {
8986 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8987 SME_SUMMARY_STATS |
8988 SME_GLOBAL_CLASSA_STATS |
8989 SME_GLOBAL_CLASSB_STATS |
8990 SME_GLOBAL_CLASSC_STATS |
8991 SME_GLOBAL_CLASSD_STATS |
8992 SME_PER_STA_STATS,
8993 hdd_StatisticsCB, 0, FALSE,
8994 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8995
8996 if (eHAL_STATUS_SUCCESS != status)
8997 {
8998 hddLog(VOS_TRACE_LEVEL_ERROR,
8999 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009000 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009001 return -EINVAL;
9002 }
9003
9004 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309005 if (NULL == pWextState)
9006 {
9007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9008 "%s: pWextState is NULL",__func__);
9009 return -EINVAL;
9010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009011
9012 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9013 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9014 {
9015 hddLog(VOS_TRACE_LEVEL_ERROR,
9016 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009017 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009018 /*Remove the SME statistics list by passing NULL in callback argument*/
9019 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9020 SME_SUMMARY_STATS |
9021 SME_GLOBAL_CLASSA_STATS |
9022 SME_GLOBAL_CLASSB_STATS |
9023 SME_GLOBAL_CLASSC_STATS |
9024 SME_GLOBAL_CLASSD_STATS |
9025 SME_PER_STA_STATS,
9026 NULL, 0, FALSE,
9027 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9028
9029 return -EINVAL;
9030 }
9031 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9032 (tANI_U8) sizeof (pStats->retry_cnt),
9033 (char*) &(pStats->retry_cnt[0]),
9034 tlen);
9035
9036 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9037 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9038 (char*) &(pStats->multiple_retry_cnt[0]),
9039 tlen);
9040
9041 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9042 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9043 (char*) &(pStats->tx_frm_cnt[0]),
9044 tlen);
9045
9046 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9047 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9048 (char*) &(pStats->rx_frm_cnt),
9049 tlen);
9050
9051 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9052 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9053 (char*) &(pStats->frm_dup_cnt),
9054 tlen);
9055
9056 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9057 (tANI_U8) sizeof (pStats->fail_cnt),
9058 (char*) &(pStats->fail_cnt[0]),
9059 tlen);
9060
9061 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9062 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9063 (char*) &(pStats->rts_fail_cnt),
9064 tlen);
9065
9066 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9067 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9068 (char*) &(pStats->ack_fail_cnt),
9069 tlen);
9070
9071 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9072 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9073 (char*) &(pStats->rts_succ_cnt),
9074 tlen);
9075
9076 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9077 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9078 (char*) &(pStats->rx_discard_cnt),
9079 tlen);
9080
9081 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9082 (tANI_U8) sizeof (pStats->rx_error_cnt),
9083 (char*) &(pStats->rx_error_cnt),
9084 tlen);
9085
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009086 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009087 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009088 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009089 tlen);
9090
9091 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9092 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9093 (char*) &(dStats->rx_byte_cnt),
9094 tlen);
9095
9096 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9097 (tANI_U8) sizeof (dStats->rx_rate),
9098 (char*) &(dStats->rx_rate),
9099 tlen);
9100
9101 /* Transmit rate, in units of 500 kbit/sec */
9102 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9103 (tANI_U8) sizeof (aStats->tx_rate),
9104 (char*) &(aStats->tx_rate),
9105 tlen);
9106
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009107 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9108 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9109 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009110 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009111 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9112 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9113 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009114 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009115 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9116 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9117 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009118 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009119 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9120 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9121 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009122 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009123 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9124 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9125 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009126 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009127 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9128 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9129 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009130 tlen);
9131
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 wrqu->data.length = tlen;
9133
9134 }
9135
9136 EXIT();
9137
9138 return 0;
9139}
9140
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309141static int iw_get_statistics(struct net_device *dev,
9142 struct iw_request_info *info,
9143 union iwreq_data *wrqu, char *extra)
9144{
9145 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009146
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309147 vos_ssr_protect(__func__);
9148 ret = __iw_get_statistics(dev, info, wrqu, extra);
9149 vos_ssr_unprotect(__func__);
9150
9151 return ret;
9152}
Jeff Johnson295189b2012-06-20 16:38:30 -07009153#ifdef FEATURE_WLAN_SCAN_PNO
9154
9155/*Max Len for PNO notification*/
9156#define MAX_PNO_NOTIFY_LEN 100
9157void found_pref_network_cb (void *callbackContext,
9158 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9159{
9160 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9161 union iwreq_data wrqu;
9162 char buf[MAX_PNO_NOTIFY_LEN+1];
9163
9164 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9165 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9166
9167 // create the event
9168 memset(&wrqu, 0, sizeof(wrqu));
9169 memset(buf, 0, sizeof(buf));
9170
9171 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9172 pPrefNetworkFoundInd->ssId.ssId,
9173 (unsigned int)pPrefNetworkFoundInd->rssi);
9174
9175 wrqu.data.pointer = buf;
9176 wrqu.data.length = strlen(buf);
9177
9178 // send the event
9179
9180 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9181
9182}
9183
9184
9185/*string based input*/
9186VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9187 union iwreq_data *wrqu, char *extra, int nOffset)
9188{
9189 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309190 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009191 /* pnoRequest is a large struct, so we make it static to avoid stack
9192 overflow. This API is only invoked via ioctl, so it is
9193 serialized by the kernel rtnl_lock and hence does not need to be
9194 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309195 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009196 char *ptr;
9197 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309198 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009199 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9200
9201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9202 "PNO data len %d data %s",
9203 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009204 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009205
9206 if (wrqu->data.length <= nOffset )
9207 {
9208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9209 return VOS_STATUS_E_FAILURE;
9210 }
9211
9212 pnoRequest.enable = 0;
9213 pnoRequest.ucNetworksCount = 0;
9214 /*-----------------------------------------------------------------------
9215 Input is string based and expected to be like this:
9216
9217 <enabled> <netw_count>
9218 for each network:
9219 <ssid_len> <ssid> <authentication> <encryption>
9220 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9221 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9222
9223 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009224 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 -07009225
9226 this translates into:
9227 -----------------------------
9228 enable PNO
9229 look for 2 networks:
9230 test - with authentication type 0 and encryption type 0,
9231 that can be found on 3 channels: 1 6 and 11 ,
9232 SSID bcast type is unknown (directed probe will be sent if AP not found)
9233 and must meet -40dBm RSSI
9234
9235 test2 - with auth and enrytption type 4/4
9236 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9237 bcast type is non-bcast (directed probe will be sent)
9238 and must not meet any RSSI threshold
9239
Jeff Johnson8301aa12013-03-28 14:27:29 -07009240 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009241 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009242 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009243
Wilson Yang623f6592013-10-08 16:33:37 -07009244 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9245 {
9246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9247 "PNO enable input is not valid %s",ptr);
9248 return VOS_STATUS_E_FAILURE;
9249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009250
9251 if ( 0 == pnoRequest.enable )
9252 {
9253 /*Disable PNO*/
9254 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309255 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9256 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 pAdapter->sessionId,
9258 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309259 if (eHAL_STATUS_SUCCESS != status)
9260 {
9261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9262 "%s: failed to disable PNO", __func__);
9263 return VOS_STATUS_E_FAILURE;
9264 }
9265 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 return VOS_STATUS_SUCCESS;
9267 }
9268
c_hpothu37f21312014-04-09 21:49:54 +05309269 if (TRUE == pHddCtx->isPnoEnable)
9270 {
9271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9272 FL("already PNO is enabled"));
9273 return -EBUSY;
9274 }
9275 pHddCtx->isPnoEnable = TRUE;
9276
Jeff Johnson295189b2012-06-20 16:38:30 -07009277 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009278
9279 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9280 {
9281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9282 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309283 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009285
9286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9287 "PNO enable %d networks count %d offset %d",
9288 pnoRequest.enable,
9289 pnoRequest.ucNetworksCount,
9290 nOffset);
9291
9292 /* Parameters checking:
9293 ucNetworksCount has to be larger than 0*/
9294 if (( 0 == pnoRequest.ucNetworksCount ) ||
9295 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9296 {
9297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309298 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009299 }
9300
9301 ptr += nOffset;
9302
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309303 pnoRequest.aNetworks =
9304 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9305 if (pnoRequest.aNetworks == NULL)
9306 {
9307 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9308 FL("failed to allocate memory aNetworks %u"),
9309 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9310 goto error;
9311 }
9312 vos_mem_zero(pnoRequest.aNetworks,
9313 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9314
Jeff Johnson295189b2012-06-20 16:38:30 -07009315 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9316 {
9317
9318 pnoRequest.aNetworks[i].ssId.length = 0;
9319
Wilson Yang623f6592013-10-08 16:33:37 -07009320 ucParams = sscanf(ptr,"%hhu %n",
9321 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9322
9323 if (1 != ucParams)
9324 {
9325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9326 "PNO ssid length input is not valid %s",ptr);
9327 return VOS_STATUS_E_FAILURE;
9328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009329
9330 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9331 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9332 {
9333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9334 "SSID Len %d is not correct for network %d",
9335 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309336 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 }
9338
9339 /*Advance to SSID*/
9340 ptr += nOffset;
9341
Jeff Johnson8301aa12013-03-28 14:27:29 -07009342 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009343 pnoRequest.aNetworks[i].ssId.length);
9344 ptr += pnoRequest.aNetworks[i].ssId.length;
9345
Jeff Johnson02797792013-10-26 19:17:13 -07009346 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009347 &(pnoRequest.aNetworks[i].authentication),
9348 &(pnoRequest.aNetworks[i].encryption),
9349 &(pnoRequest.aNetworks[i].ucChannelCount),
9350 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009351
Wilson Yang623f6592013-10-08 16:33:37 -07009352 if ( 3 != ucParams )
9353 {
9354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9355 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309356 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009357 }
9358
Jeff Johnson295189b2012-06-20 16:38:30 -07009359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009360 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009361 "auth %d encry %d channel count %d offset %d",
9362 pnoRequest.aNetworks[i].ssId.length,
9363 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9364 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9365 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9366 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9367 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9368 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9369 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9370 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9371 pnoRequest.aNetworks[i].authentication,
9372 pnoRequest.aNetworks[i].encryption,
9373 pnoRequest.aNetworks[i].ucChannelCount,
9374 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009375
Jeff Johnson295189b2012-06-20 16:38:30 -07009376 /*Advance to channel list*/
9377 ptr += nOffset;
9378
Wilson Yang623f6592013-10-08 16:33:37 -07009379 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009380 {
9381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9382 "Incorrect number of channels");
9383 return VOS_STATUS_E_FAILURE;
9384 }
9385
9386 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9387 {
9388 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9389 {
Wilson Yang623f6592013-10-08 16:33:37 -07009390 if (1 != sscanf(ptr,"%hhu %n",
9391 &(pnoRequest.aNetworks[i].aChannels[j]),
9392 &nOffset))
9393 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9394 "PNO network channel input is not valid %s",ptr);
9395 return VOS_STATUS_E_FAILURE;
9396 }
9397 /*Advance to next channel number*/
9398 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 }
9400 }
9401
Jeff Johnson02797792013-10-26 19:17:13 -07009402 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009403 &(pnoRequest.aNetworks[i].bcastNetwType),
9404 &nOffset))
9405 {
9406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9407 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309408 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009410
9411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9412 "PNO bcastNetwType %d offset %d",
9413 pnoRequest.aNetworks[i].bcastNetwType,
9414 nOffset );
9415
9416 /*Advance to rssi Threshold*/
9417 ptr += nOffset;
9418
Wilson Yang623f6592013-10-08 16:33:37 -07009419 if (1 != sscanf(ptr,"%hhu %n",
9420 &(pnoRequest.aNetworks[i].rssiThreshold),
9421 &nOffset))
9422 {
9423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9424 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309425 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009427
9428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9429 "PNO rssi %d offset %d",
9430 pnoRequest.aNetworks[i].rssiThreshold,
9431 nOffset );
9432 /*Advance to next network*/
9433 ptr += nOffset;
9434 }/*For ucNetworkCount*/
9435
9436 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009437 &(pnoRequest.scanTimers.ucScanTimersCount),
9438 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009439
9440 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009441 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009442 {
9443 ptr += nOffset;
9444
Jeff Johnson8301aa12013-03-28 14:27:29 -07009445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9446 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 pnoRequest.scanTimers.ucScanTimersCount,
9448 nOffset );
9449
9450 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9451 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009453 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309454 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009455 }
9456
9457 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9458 {
Jeff Johnson02797792013-10-26 19:17:13 -07009459 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9461 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9462 &nOffset);
9463
Wilson Yang623f6592013-10-08 16:33:37 -07009464 if (2 != ucParams)
9465 {
9466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9467 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309468 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009469 }
9470
Jeff Johnson8301aa12013-03-28 14:27:29 -07009471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9472 "PNO Timer value %d Timer repeat %d offset %d",
9473 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9475 nOffset );
9476
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 ptr += nOffset;
9478 }
9479
9480 }
9481 else
9482 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9484 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9486
9487 /*Scan timers defaults to 5 minutes*/
9488 pnoRequest.scanTimers.ucScanTimersCount = 1;
9489 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9490 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9491 }
9492
Wilson Yang623f6592013-10-08 16:33:37 -07009493 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009494
9495 pnoRequest.modePNO = ucMode;
9496 /*for LA we just expose suspend option*/
9497 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9498 {
9499 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9500 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309501 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9502 if (pnoRequest.p24GProbeTemplate == NULL){
9503 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9504 FL("failed to allocate memory p24GProbeTemplate %u"),
9505 SIR_PNO_MAX_PB_REQ_SIZE);
9506 goto error;
9507 }
9508
9509 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9510 if (pnoRequest.p5GProbeTemplate == NULL){
9511 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9512 FL("failed to allocate memory p5GProbeTemplate %u"),
9513 SIR_PNO_MAX_PB_REQ_SIZE);
9514 goto error;
9515 }
9516
9517 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9518 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009519
c_hpothu37f21312014-04-09 21:49:54 +05309520 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 pAdapter->sessionId,
9522 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309523 if (eHAL_STATUS_SUCCESS == status)
9524 {
9525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9526 "%s: PNO enabled", __func__);
9527 return VOS_STATUS_SUCCESS;
9528 }
9529error:
9530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9531 "%s: Failed to enable PNO", __func__);
9532 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309533 if (pnoRequest.aNetworks)
9534 vos_mem_free(pnoRequest.aNetworks);
9535 if (pnoRequest.p24GProbeTemplate)
9536 vos_mem_free(pnoRequest.p24GProbeTemplate);
9537 if (pnoRequest.p5GProbeTemplate)
9538 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309539 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009540}/*iw_set_pno*/
9541
9542VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9543 union iwreq_data *wrqu, char *extra, int nOffset)
9544{
9545 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9546 v_U8_t rssiThreshold = 0;
9547 v_U8_t nRead;
9548
Arif Hussain7adce1b2013-11-11 22:59:34 -08009549 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 &rssiThreshold);
9551
9552 if ( 1 != nRead )
9553 {
9554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9555 "Incorrect format");
9556 return VOS_STATUS_E_FAILURE;
9557 }
9558
9559 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9560 return VOS_STATUS_SUCCESS;
9561}
9562
9563
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309564static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 struct iw_request_info *info,
9566 union iwreq_data *wrqu, char *extra)
9567{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309568 hdd_adapter_t *pAdapter;
9569 hdd_context_t *pHddCtx;
9570 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309571 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309572
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309573 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309574 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9575 if (NULL == pAdapter)
9576 {
9577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9578 "%s: Adapter is NULL",__func__);
9579 return -EINVAL;
9580 }
9581
9582 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9583 ret = wlan_hdd_validate_context(pHddCtx);
9584 if (0 != ret)
9585 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309586 return ret;
9587 }
9588
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009589
9590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009592
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309593 status = iw_set_pno(dev,info,wrqu,extra,0);
9594
9595 EXIT();
9596 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009597}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309598
9599static int iw_set_pno_priv(struct net_device *dev,
9600 struct iw_request_info *info,
9601 union iwreq_data *wrqu, char *extra)
9602{
9603 int ret;
9604
9605 vos_ssr_protect(__func__);
9606 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9607 vos_ssr_unprotect(__func__);
9608
9609 return ret;
9610}
Jeff Johnson295189b2012-06-20 16:38:30 -07009611#endif /*FEATURE_WLAN_SCAN_PNO*/
9612
9613//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309614int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009615{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309616 hdd_adapter_t *pAdapter;
9617 tHalHandle hHal;
9618 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309619 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309620 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309621 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309623 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309624 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309625 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309626
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309627 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309628 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9629 if (NULL == pAdapter)
9630 {
9631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9632 "%s: Adapter is NULL",__func__);
9633 return -EINVAL;
9634 }
9635 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9636 retval = wlan_hdd_validate_context(pHddCtx);
9637 if (0 != retval)
9638 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309639 return retval;
9640 }
9641 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9642 if (NULL == hHal)
9643 {
9644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9645 "%s: Hal Context is NULL",__func__);
9646 return -EINVAL;
9647 }
9648 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009649
Atul Mittal54378cb2014-04-02 16:51:50 +05309650 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 {
9652 case WLAN_HDD_UI_BAND_AUTO:
9653 band = eCSR_BAND_ALL;
9654 break;
9655 case WLAN_HDD_UI_BAND_5_GHZ:
9656 band = eCSR_BAND_5G;
9657 break;
9658 case WLAN_HDD_UI_BAND_2_4_GHZ:
9659 band = eCSR_BAND_24;
9660 break;
9661 default:
9662 band = eCSR_BAND_MAX;
9663 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309664 connectedBand =
9665 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009666
Atul Mittal54378cb2014-04-02 16:51:50 +05309667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009668 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009669
9670 if (band == eCSR_BAND_MAX)
9671 {
9672 /* Received change band request with invalid band value */
9673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309674 "%s: Invalid band value %u", __func__, ui_band);
9675 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 }
9677
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309678 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309679 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309680 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009682 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009683 band, pHddCtx->cfg_ini->nBandCapability);
9684 return -EIO;
9685 }
9686
Sushant Kaushik1165f872015-03-30 20:25:27 +05309687 if (band == eCSR_BAND_ALL)
9688 {
9689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9690 "received. Setting band same as ini value %d"),
9691 pHddCtx->cfg_ini->nBandCapability);
9692 band = pHddCtx->cfg_ini->nBandCapability;
9693 }
9694
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9696 {
9697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9698 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009699 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 return -EIO;
9701 }
9702
9703 if (currBand != band)
9704 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309705 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309706 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309707 /* Return failure if current country code is world regulatory domain*/
9708 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9709 pMac->scan.countryCodeCurrent[1] == '0') )
9710 {
9711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9712 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309713 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309714 return -EAGAIN;
9715 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309716 }
9717
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 /* Change band request received.
9719 * Abort pending scan requests, flush the existing scan results,
9720 * and change the band capability
9721 */
9722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9723 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009724 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009725
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309726 /* We need to change the band and flush the scan results here itself
9727 * as we may get timeout for disconnection in which we will return
9728 * with out doing any of these
9729 */
9730 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9731 {
9732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9733 "%s: failed to set the band value to %u ",
9734 __func__, band);
9735 return -EINVAL;
9736 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309737 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9738 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309739 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309740 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9741 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309742 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309743 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9744 * information available in NV so to get the channel information from kernel
9745 * we need to send regulatory hint for the currunt country
9746 * And to set the same country again we need to set the dummy country
9747 * first and then the actual country.
9748 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309749#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9750 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9751#else
9752 regulatory_hint_user("00");
9753#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309754 wait_result = wait_for_completion_interruptible_timeout(
9755 &pHddCtx->linux_reg_req,
9756 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9757
9758 /* if the country information does not exist with the kernel,
9759 then the driver callback would not be called */
9760
9761 if (wait_result >= 0)
9762 {
9763 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9764 "runtime country code is found in kernel db");
9765 }
9766 else
9767 {
9768 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9769 "runtime country code is not found"
9770 " in kernel db");
9771 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309772
9773 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309774
9775 /*
9776 * Update 11dcountry and current country here as the hint
9777 * with 00 results in 11d and current country with 00
9778 */
9779 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9780 WNI_CFG_COUNTRY_CODE_LEN);
9781 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9782 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309783#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9784 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9785#else
9786 regulatory_hint_user(curr_country);
9787#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309788 wait_result = wait_for_completion_interruptible_timeout(
9789 &pHddCtx->linux_reg_req,
9790 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9791
9792 /* if the country information does not exist with the kernel,
9793 then the driver callback would not be called */
9794 if (wait_result >= 0)
9795 {
9796 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9797 "runtime country code is found in kernel db");
9798 }
9799 else
9800 {
9801 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9802 "runtime country code is not found"
9803 " in kernel db");
9804 }
9805
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309806 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309807 }
9808 else
9809 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309810#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309811 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9812 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309813#else
9814 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9815#endif
9816
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309817 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309818 pScanInfo = &pHddCtx->scan_info;
9819 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9820 {
9821 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9822 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9823 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309824 sme_FilterScanResults(hHal, pAdapter->sessionId);
9825
9826 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309827 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9828 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009830 eHalStatus status = eHAL_STATUS_SUCCESS;
9831 long lrc;
9832
9833 /* STA already connected on current band, So issue disconnect first,
9834 * then change the band*/
9835
9836 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309837 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309838 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009839
Jeff Johnson295189b2012-06-20 16:38:30 -07009840 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9841
9842 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9843 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9844
Jeff Johnson43971f52012-07-17 12:26:56 -07009845 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009846 {
9847 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009848 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009849 __func__, (int)status );
9850 return -EINVAL;
9851 }
9852
9853 lrc = wait_for_completion_interruptible_timeout(
9854 &pAdapter->disconnect_comp_var,
9855 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9856
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309857 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009858
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009859 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009860 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009861
9862 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9863 }
9864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309866 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309867 if (TRUE == pHddCtx->isSetBandByNL)
9868 return 0;
9869 else
9870 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07009871}
9872
Atul Mittal54378cb2014-04-02 16:51:50 +05309873int hdd_setBand_helper(struct net_device *dev, const char *command)
9874{
9875 u8 band;
9876
9877 /*convert the band value from ascii to integer*/
9878 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9879
9880 return hdd_setBand(dev, band);
9881
9882}
9883
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309884static int __iw_set_band_config(struct net_device *dev,
9885 struct iw_request_info *info,
9886 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009887{
Atul Mittal54378cb2014-04-02 16:51:50 +05309888 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009889
Arif Hussain0273cba2014-01-07 20:58:29 -08009890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009891
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +05309892 if (!capable(CAP_NET_ADMIN))
9893 {
9894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9895 FL("permission check failed"));
9896 return -EPERM;
9897 }
9898
Atul Mittal54378cb2014-04-02 16:51:50 +05309899 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009900}
9901
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309902static int iw_set_band_config(struct net_device *dev,
9903 struct iw_request_info *info,
9904 union iwreq_data *wrqu, char *extra)
9905{
9906 int ret;
9907
9908 vos_ssr_protect(__func__);
9909 ret = __iw_set_band_config(dev, info, wrqu, extra);
9910 vos_ssr_unprotect(__func__);
9911
9912 return ret;
9913}
9914
c_manjeecfd1efb2015-09-25 19:32:34 +05309915static int get_fwr_memdump(struct net_device *dev,
9916 struct iw_request_info *info,
9917 union iwreq_data *wrqu, char *extra)
9918{
9919 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9920 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9921 int ret;
9922 ENTER();
9923 // HddCtx sanity
9924 ret = wlan_hdd_validate_context(pHddCtx);
9925 if (0 != ret)
9926 {
9927 return ret;
9928 }
9929 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
9930 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
9931 {
9932 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
9933 return -EINVAL;
9934 }
9935 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
9936
9937 EXIT();
9938 return ret;
9939}
9940
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309941static int __iw_set_power_params_priv(struct net_device *dev,
9942 struct iw_request_info *info,
9943 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009944{
Arif Hussain0273cba2014-01-07 20:58:29 -08009945 int ret;
9946 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +05309947
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9949 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +05309950
9951 if (!capable(CAP_NET_ADMIN))
9952 {
9953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9954 FL("permission check failed"));
9955 return -EPERM;
9956 }
9957
Arif Hussain0273cba2014-01-07 20:58:29 -08009958 /* ODD number is used for set, copy data using copy_from_user */
9959 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9960 wrqu->data.length);
9961 if (NULL == ptr)
9962 {
9963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9964 "mem_alloc_copy_from_user_helper fail");
9965 return -ENOMEM;
9966 }
9967
9968 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9969 kfree(ptr);
9970 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009971}
9972
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309973static int iw_set_power_params_priv(struct net_device *dev,
9974 struct iw_request_info *info,
9975 union iwreq_data *wrqu, char *extra)
9976{
9977 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009978
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309979 vos_ssr_protect(__func__);
9980 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9981 vos_ssr_unprotect(__func__);
9982
9983 return ret;
9984}
Jeff Johnson295189b2012-06-20 16:38:30 -07009985
9986/*string based input*/
9987VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9988 union iwreq_data *wrqu, char *extra, int nOffset)
9989{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309990 hdd_adapter_t *pAdapter;
9991 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 tSirSetPowerParamsReq powerRequest;
9993 char *ptr;
9994 v_U8_t ucType;
9995 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309996 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009997
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309998 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309999 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10000 if (NULL == pAdapter)
10001 {
10002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10003 "%s: Adapter is NULL",__func__);
10004 return -EINVAL;
10005 }
10006
10007 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10008 ret = wlan_hdd_validate_context(pHddCtx);
10009 if (0 != ret)
10010 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010011 return ret;
10012 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10014 "Power Params data len %d data %s",
10015 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010016 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010017
10018 if (wrqu->data.length <= nOffset )
10019 {
10020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10021 return VOS_STATUS_E_FAILURE;
10022 }
10023
10024 uTotalSize = wrqu->data.length - nOffset;
10025
10026 /*-----------------------------------------------------------------------
10027 Input is string based and expected to be like this:
10028
10029 <param_type> <param_value> <param_type> <param_value> ...
10030
10031 e.g:
10032 1 2 2 3 3 0 4 1 5 1
10033
10034 e.g. setting just a few:
10035 1 2 4 1
10036
10037 parameter types:
10038 -----------------------------
10039 1 - Ignore DTIM
10040 2 - Listen Interval
10041 3 - Broadcast Multicas Filter
10042 4 - Beacon Early Termination
10043 5 - Beacon Early Termination Interval
10044 -----------------------------------------------------------------------*/
10045 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10046 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10047 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10048 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10049 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10050
Arif Hussain7adce1b2013-11-11 22:59:34 -080010051 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010052
10053 while ( uTotalSize )
10054 {
Wilson Yang6f971452013-10-08 15:00:00 -070010055 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10056 {
10057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10058 "Invalid input parameter type %s",ptr);
10059 return VOS_STATUS_E_FAILURE;
10060 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010061
10062 uTotalSize -= nOffset;
10063
10064 if (!uTotalSize)
10065 {
10066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010067 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 ucType, nOffset);
10069 return VOS_STATUS_E_FAILURE;
10070 }
10071
10072 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010073
Jeff Johnson02797792013-10-26 19:17:13 -070010074 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010075 {
10076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10077 "Invalid input parameter value %s",ptr);
10078 return VOS_STATUS_E_FAILURE;
10079 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010080
10081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10082 "Power request parameter %d value %d offset %d",
10083 ucType, uValue, nOffset);
10084
10085 switch (ucType)
10086 {
10087 case eSIR_IGNORE_DTIM:
10088 powerRequest.uIgnoreDTIM = uValue;
10089 break;
10090 case eSIR_LISTEN_INTERVAL:
10091 powerRequest.uListenInterval = uValue;
10092 break;
10093 case eSIR_MCAST_BCAST_FILTER:
10094 powerRequest.uBcastMcastFilter = uValue;
10095 break;
10096 case eSIR_ENABLE_BET:
10097 powerRequest.uEnableBET = uValue;
10098 break;
10099 case eSIR_BET_INTERVAL:
10100 powerRequest.uBETInterval = uValue;
10101 break;
10102 default:
10103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010104 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010105 ucType, uValue, nOffset);
10106 return VOS_STATUS_E_FAILURE;
10107 }
10108
10109 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10111 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010112 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010113 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010114 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010115 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010116 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10117 {
10118 uTotalSize = 0;
10119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010120
10121 }/*Go for as long as we have a valid string*/
10122
10123 /* put the device into full power*/
10124 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10125
10126 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010127 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010128
10129 /* put the device back to power save*/
10130 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10131
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010132 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 return VOS_STATUS_SUCCESS;
10134}/*iw_set_power_params*/
10135
Atul Mittalc0f739f2014-07-31 13:47:47 +053010136// tdlsoffchan
10137#ifdef FEATURE_WLAN_TDLS
10138
Atul Mittal87ec2422014-09-24 13:12:50 +053010139int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010140{
10141 if (offchannel < 0 || offchannel > 165)
10142 {
10143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10144 __func__, offchannel);
10145 return -1;
10146
10147 }
10148
10149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10150 __func__, tdlsOffCh, offchannel);
10151
10152 tdlsOffCh = offchannel;
10153 return 0;
10154}
10155
Atul Mittal87ec2422014-09-24 13:12:50 +053010156int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010157{
10158 if (offchanoffset == 0)
10159 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010160 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10162 __func__, tdlsOffChBwOffset);
10163
10164 return 0;
10165
10166 }
10167
10168 if ( offchanoffset == 40 )
10169 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010170 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10172 __func__, tdlsOffChBwOffset);
10173
10174 return 0;
10175
10176 }
10177 if (offchanoffset == -40)
10178 {
10179 tdlsOffChBwOffset = 3;
10180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10181 __func__, tdlsOffChBwOffset);
10182
10183 return 0;
10184
10185 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010186
10187 if ((offchanoffset == 80) &&
10188 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10189 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10190 {
10191 tdlsOffChBwOffset = 4;
10192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10193 "%s: change tdls secondary off channel offset to %u",
10194 __func__, tdlsOffChBwOffset);
10195
10196 return 0;
10197 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10199 __func__, offchanoffset);
10200 return -1;
10201}
10202
Atul Mittal87ec2422014-09-24 13:12:50 +053010203int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010204{
10205 hddTdlsPeer_t *connPeer = NULL;
10206 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10207 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010208 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010209 if (offchanmode < 0 || offchanmode > 4)
10210 {
10211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10212 "%s: Invalid tdls off channel mode %d",
10213 __func__, offchanmode);
10214 return -1;
10215 }
10216
10217 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10218 {
10219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10220 "%s: tdls off channel mode req in not associated state %d",
10221 __func__, offchanmode);
10222 return -1;
10223 }
10224
10225 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10226 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10227 {
10228 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010229 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010230 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010231 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010232 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10234 "%s: No TDLS Connected Peer", __func__);
10235 return -1;
10236 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010237 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010238 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010239 }
10240 else
10241 {
10242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10243 "%s: TDLS Connection not supported", __func__);
10244 return -1;
10245 }
10246
10247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10248 ("%s: TDLS Channel Switch in swmode=%d"),
10249 __func__, offchanmode);
10250
10251 switch (offchanmode)
10252 {
10253 case 1:/*Enable*/
10254 case 2:/*Disable*/
10255 {
10256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10257 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10258 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10259 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10260 {
10261
10262 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010263 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010264 tdlsOffCh, tdlsOffChBwOffset,
10265 offchanmode);
10266 }
10267 else
10268 {
10269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10270 "%s: TDLS Off Channel not supported", __func__);
10271 return -1;
10272 }
10273 break;
10274 }
10275 case 3:
10276 {
10277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10278 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10279 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10280
10281 break;
10282 }
10283 case 4:
10284 {
10285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10286 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10287 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10288 break;
10289 }
10290 default:
10291 {
10292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10293 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10294 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10295 break;
10296 }
10297
10298 }
10299
10300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10301 __func__, offchanmode);
10302 return 0;
10303}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010304#endif
10305
Jeff Johnson295189b2012-06-20 16:38:30 -070010306
10307// Define the Wireless Extensions to the Linux Network Device structure
10308// A number of these routines are NULL (meaning they are not implemented.)
10309
10310static const iw_handler we_handler[] =
10311{
10312 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10313 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10314 (iw_handler) NULL, /* SIOCSIWNWID */
10315 (iw_handler) NULL, /* SIOCGIWNWID */
10316 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10317 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10318 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10319 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10320 (iw_handler) NULL, /* SIOCSIWSENS */
10321 (iw_handler) NULL, /* SIOCGIWSENS */
10322 (iw_handler) NULL, /* SIOCSIWRANGE */
10323 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10324 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
10325 (iw_handler) NULL, /* SIOCGIWPRIV */
10326 (iw_handler) NULL, /* SIOCSIWSTATS */
10327 (iw_handler) NULL, /* SIOCGIWSTATS */
10328 iw_handler_set_spy, /* SIOCSIWSPY */
10329 iw_handler_get_spy, /* SIOCGIWSPY */
10330 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10331 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10332 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10333 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10334 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10335 (iw_handler) NULL, /* SIOCGIWAPLIST */
10336 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10337 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10338 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10339 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10340 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10341 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10342 (iw_handler) NULL, /* -- hole -- */
10343 (iw_handler) NULL, /* -- hole -- */
10344 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10345 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10346 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10347 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10348 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10349 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10350 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10351 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10352 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10353 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10354 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10355 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10356 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10357 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10358 (iw_handler) NULL, /* -- hole -- */
10359 (iw_handler) NULL, /* -- hole -- */
10360 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10361 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10362 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10363 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10364 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10365 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10366 (iw_handler) NULL, /* SIOCSIWPMKSA */
10367};
10368
10369static const iw_handler we_private[] = {
10370
10371 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10372 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10373 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10374 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10375 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10376 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010377 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010378 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10379 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10380 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010381#ifdef FEATURE_OEM_DATA_SUPPORT
10382 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10383 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10384#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010385
Jeff Johnson295189b2012-06-20 16:38:30 -070010386#ifdef WLAN_FEATURE_VOWIFI_11R
10387 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10388#endif
10389 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10390 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10391 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10392#ifdef WLAN_FEATURE_PACKET_FILTERING
10393 ,
10394 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10395#endif
10396#ifdef FEATURE_WLAN_SCAN_PNO
10397 ,
10398 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10399#endif
10400 ,
10401 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10402 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10403 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10404 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010405 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010406};
10407
10408/*Maximum command length can be only 15 */
10409static const struct iw_priv_args we_private_args[] = {
10410
Katya Nigamf0511f62015-05-05 16:40:57 +053010411 { WE_SET_MONITOR_STATE,
10412 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10413 0, "monitor" },
10414
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 /* handlers for main ioctl */
10416 { WLAN_PRIV_SET_INT_GET_NONE,
10417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10418 0,
10419 "" },
10420
10421 /* handlers for sub-ioctl */
10422 { WE_SET_11D_STATE,
10423 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10424 0,
10425 "set11Dstate" },
10426
10427 { WE_WOWL,
10428 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10429 0,
10430 "wowl" },
10431
10432 { WE_SET_POWER,
10433 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10434 0,
10435 "setPower" },
10436
10437 { WE_SET_MAX_ASSOC,
10438 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10439 0,
10440 "setMaxAssoc" },
10441
10442 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10443 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10444 0,
10445 "setAutoChannel" },
10446
10447 { WE_SET_DATA_INACTIVITY_TO,
10448 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10449 0,
10450 "inactivityTO" },
10451
10452 { WE_SET_MAX_TX_POWER,
10453 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10454 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010455 "setMaxTxPower" },
10456
10457 { WE_SET_MAX_TX_POWER_2_4,
10458 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10459 0,
10460 "setTxMaxPower2G" },
10461
10462 { WE_SET_MAX_TX_POWER_5_0,
10463 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10464 0,
10465 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010466
10467 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10468 * as well to keep same syntax as in SAP. Now onwards, STA
10469 * will support both */
10470 { WE_SET_MAX_TX_POWER,
10471 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10472 0,
10473 "setTxMaxPower" },
10474
Jeff Johnson295189b2012-06-20 16:38:30 -070010475 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10476 * 1 = enable and 0 = disable */
10477 {
10478 WE_SET_HIGHER_DTIM_TRANSITION,
10479 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10480 0,
10481 "setHDtimTransn" },
10482
10483 { WE_SET_TM_LEVEL,
10484 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010485 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010486 "setTmLevel" },
10487
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010488 { WE_ENABLE_STRICT_FCC_REG,
10489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10490 0,
10491 "setStrictFCCreg" },
10492
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010493 { WE_SET_DEBUG_LOG,
10494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10495 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010496#ifdef FEATURE_WLAN_TDLS
10497 {
10498 WE_SET_TDLS_OFF_CHAN,
10499 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10500 0,
10501 "tdlsoffchan" },
10502 {
10503 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10504 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10505 0,
10506 "tdlsecchnoffst" },
10507 {
10508 WE_SET_TDLS_OFF_CHAN_MODE,
10509 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10510 0,
10511 "tdlsoffchnmode" },
10512#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010513
Peng Xu2446a892014-09-05 17:21:18 +053010514 { WE_SET_SCAN_BAND_PREFERENCE,
10515 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10516 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010517 {
10518 WE_GET_FRAME_LOG,
10519 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10520 0,
10521 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010522
Abhishek Singh01c73d12015-03-12 15:13:44 +053010523 { WE_SET_MIRACAST_VENDOR_CONFIG,
10524 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10525 0, "setMiracstConf" },
10526
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010527#ifdef FEATURE_WLAN_TDLS
10528 {
10529 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10530 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10531 0,
10532 "tdls_2040bsscox" },
10533#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010534 { WE_SET_RTS_CTS_HTVHT,
10535 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10536 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010537 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10538 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10539 0, "setPktStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 /* handlers for main ioctl */
10541 { WLAN_PRIV_SET_NONE_GET_INT,
10542 0,
10543 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10544 "" },
10545
10546 /* handlers for sub-ioctl */
10547 { WE_GET_11D_STATE,
10548 0,
10549 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10550 "get11Dstate" },
10551
10552 { WE_IBSS_STATUS,
10553 0,
10554 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10555 "getAdhocStatus" },
10556
10557 { WE_PMC_STATE,
10558 0,
10559 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10560 "pmcState" },
10561
10562 { WE_GET_WLAN_DBG,
10563 0,
10564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10565 "getwlandbg" },
10566
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 { WE_GET_MAX_ASSOC,
10568 0,
10569 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10570 "getMaxAssoc" },
10571
Jeff Johnson295189b2012-06-20 16:38:30 -070010572 { WE_GET_WDI_DBG,
10573 0,
10574 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10575 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010576
10577 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10578 0,
10579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10580 "getAutoChannel" },
10581
10582 { WE_GET_CONCURRENCY_MODE,
10583 0,
10584 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10585 "getconcurrency" },
10586
Peng Xu2446a892014-09-05 17:21:18 +053010587 { WE_GET_SCAN_BAND_PREFERENCE,
10588 0,
10589 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10590 "get_scan_pref"},
10591
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 /* handlers for main ioctl */
10593 { WLAN_PRIV_SET_CHAR_GET_NONE,
10594 IW_PRIV_TYPE_CHAR| 512,
10595 0,
10596 "" },
10597
10598 /* handlers for sub-ioctl */
10599 { WE_WOWL_ADD_PTRN,
10600 IW_PRIV_TYPE_CHAR| 512,
10601 0,
10602 "wowlAddPtrn" },
10603
10604 { WE_WOWL_DEL_PTRN,
10605 IW_PRIV_TYPE_CHAR| 512,
10606 0,
10607 "wowlDelPtrn" },
10608
10609#if defined WLAN_FEATURE_VOWIFI
10610 /* handlers for sub-ioctl */
10611 { WE_NEIGHBOR_REPORT_REQUEST,
10612 IW_PRIV_TYPE_CHAR | 512,
10613 0,
10614 "neighbor" },
10615#endif
10616 { WE_SET_AP_WPS_IE,
10617 IW_PRIV_TYPE_CHAR| 512,
10618 0,
10619 "set_ap_wps_ie" },
10620
10621 { WE_SET_CONFIG,
10622 IW_PRIV_TYPE_CHAR| 512,
10623 0,
10624 "setConfig" },
10625
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010626 { WE_SET_ENCRYPT_MSG,
10627 IW_PRIV_TYPE_CHAR| 512,
10628 0,
10629 "encryptMsg" },
10630
10631
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 /* handlers for main ioctl */
10633 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10634 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10635 0,
10636 "" },
10637
10638 /* handlers for sub-ioctl */
10639 { WE_SET_WLAN_DBG,
10640 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10641 0,
10642 "setwlandbg" },
10643
Jeff Johnson295189b2012-06-20 16:38:30 -070010644 { WE_SET_WDI_DBG,
10645 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10646 0,
10647 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010648
10649 { WE_SET_SAP_CHANNELS,
10650 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10651 0,
10652 "setsapchannels" },
10653
10654 /* handlers for main ioctl */
10655 { WLAN_PRIV_GET_CHAR_SET_NONE,
10656 0,
10657 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10658 "" },
10659
10660 /* handlers for sub-ioctl */
10661 { WE_WLAN_VERSION,
10662 0,
10663 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10664 "version" },
10665 { WE_GET_STATS,
10666 0,
10667 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10668 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010669 { WE_GET_STATES,
10670 0,
10671 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10672 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010673 { WE_GET_CFG,
10674 0,
10675 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10676 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010677#ifdef WLAN_FEATURE_11AC
10678 { WE_GET_RSSI,
10679 0,
10680 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10681 "getRSSI" },
10682#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010683#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010684 { WE_GET_ROAM_RSSI,
10685 0,
10686 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10687 "getRoamRSSI" },
10688#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 { WE_GET_WMM_STATUS,
10690 0,
10691 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10692 "getWmmStatus" },
10693 {
10694 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010695 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010696 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10697 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010698#ifdef FEATURE_WLAN_TDLS
10699 {
10700 WE_GET_TDLS_PEERS,
10701 0,
10702 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10703 "getTdlsPeers" },
10704#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010705#ifdef WLAN_FEATURE_11W
10706 {
10707 WE_GET_11W_INFO,
10708 0,
10709 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10710 "getPMFInfo" },
10711#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010712 { WE_GET_SNR,
10713 0,
10714 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10715 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053010716#ifdef FEATURE_OEM_DATA_SUPPORT
10717 {
10718 WE_GET_OEM_DATA_CAP,
10719 0,
10720 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10721 "getOemDataCap" },
10722#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070010723 /* handlers for main ioctl */
10724 { WLAN_PRIV_SET_NONE_GET_NONE,
10725 0,
10726 0,
10727 "" },
10728
10729 /* handlers for sub-ioctl */
10730 { WE_CLEAR_STATS,
10731 0,
10732 0,
10733 "clearStats" },
10734 { WE_INIT_AP,
10735 0,
10736 0,
10737 "initAP" },
10738 { WE_STOP_AP,
10739 0,
10740 0,
10741 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010742#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010743 { WE_ENABLE_AMP,
10744 0,
10745 0,
10746 "enableAMP" },
10747 { WE_DISABLE_AMP,
10748 0,
10749 0,
10750 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010751#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010752 { WE_ENABLE_DXE_STALL_DETECT,
10753 0,
10754 0,
10755 "dxeStallDetect" },
10756 { WE_DISPLAY_DXE_SNAP_SHOT,
10757 0,
10758 0,
10759 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010760 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10761 0,
10762 0,
10763 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010764 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010765 WE_SET_REASSOC_TRIGGER,
10766 0,
10767 0,
10768 "reassoc" },
10769 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010770 WE_STOP_OBSS_SCAN,
10771 0,
10772 0,
10773 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010774 {
10775 WE_DUMP_ROAM_TIMER_LOG,
10776 0,
10777 0,
10778 "dumpRoamDelay" },
10779 {
10780 WE_RESET_ROAM_TIMER_LOG,
10781 0,
10782 0,
10783 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010784 {
10785 WE_GET_FW_LOGS,
10786 0,
10787 0,
10788 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053010789 {
10790 WE_GET_FW_MEMDUMP,
10791 0,
10792 0,
10793 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010794 /* handlers for main ioctl */
10795 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10796 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10797 0,
10798 "" },
10799
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010800
10801
Jeff Johnson295189b2012-06-20 16:38:30 -070010802 /* handlers for sub-ioctl */
10803 { WE_LOG_DUMP_CMD,
10804 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10805 0,
10806 "dump" },
10807
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010808 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010809 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10810 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10811 0,
10812 "setdumplog" },
10813
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010814 { WE_MTRACE_DUMP_CMD,
10815 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10816 0,
10817 "dumplog" },
10818
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010819 /* handlers for sub ioctl */
10820 {
10821 WE_MCC_CONFIG_CREDENTIAL,
10822 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10823 0,
10824 "setMccCrdnl" },
10825
10826 /* handlers for sub ioctl */
10827 {
10828 WE_MCC_CONFIG_PARAMS,
10829 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10830 0,
10831 "setMccConfig" },
10832
Chilam NG571c65a2013-01-19 12:27:36 +053010833#ifdef FEATURE_WLAN_TDLS
10834 /* handlers for sub ioctl */
10835 {
10836 WE_TDLS_CONFIG_PARAMS,
10837 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10838 0,
10839 "setTdlsConfig" },
10840#endif
10841
Katya Nigamf0511f62015-05-05 16:40:57 +053010842 {
10843 WE_CONFIGURE_MONITOR_MODE,
10844 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10845 0,
10846 "MonitorModeConf" },
10847
10848 {
10849 WE_SET_MONITOR_MODE_FILTER,
10850 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10851 0,
10852 "MonitorFilter" },
10853
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 /* handlers for main ioctl */
10855 { WLAN_PRIV_ADD_TSPEC,
10856 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10857 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10858 "addTspec" },
10859
10860 /* handlers for main ioctl */
10861 { WLAN_PRIV_DEL_TSPEC,
10862 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10863 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10864 "delTspec" },
10865
10866 /* handlers for main ioctl */
10867 { WLAN_PRIV_GET_TSPEC,
10868 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10869 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10870 "getTspec" },
10871
Jeff Johnsone7245742012-09-05 17:12:55 -070010872#ifdef FEATURE_OEM_DATA_SUPPORT
10873 /* handlers for main ioctl - OEM DATA */
10874 {
10875 WLAN_PRIV_SET_OEM_DATA_REQ,
10876 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10877 0,
10878 "set_oem_data_req" },
10879
10880 /* handlers for main ioctl - OEM DATA */
10881 {
10882 WLAN_PRIV_GET_OEM_DATA_RSP,
10883 0,
10884 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10885 "get_oem_data_rsp" },
10886#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010887
Jeff Johnson295189b2012-06-20 16:38:30 -070010888 /* handlers for main ioctl - host offload */
10889 {
10890 WLAN_PRIV_SET_HOST_OFFLOAD,
10891 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10892 0,
10893 "setHostOffload" },
10894
10895 {
10896 WLAN_GET_WLAN_STATISTICS,
10897 0,
10898 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10899 "getWlanStats" },
10900
10901 {
10902 WLAN_SET_KEEPALIVE_PARAMS,
10903 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10904 0,
10905 "setKeepAlive" },
10906#ifdef WLAN_FEATURE_PACKET_FILTERING
10907 {
10908 WLAN_SET_PACKET_FILTER_PARAMS,
10909 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10910 0,
10911 "setPktFilter" },
10912#endif
10913#ifdef FEATURE_WLAN_SCAN_PNO
10914 {
10915 WLAN_SET_PNO,
10916 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10917 0,
10918 "setpno" },
10919#endif
10920 {
10921 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010922 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010923 0,
10924 "SETBAND" },
10925 /* handlers for dynamic MC BC ioctl */
10926 {
10927 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010928 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010929 0,
10930 "setMCBCFilter" },
10931 {
10932 WLAN_PRIV_CLEAR_MCBC_FILTER,
10933 0,
10934 0,
10935 "clearMCBCFilter" },
10936 {
10937 WLAN_SET_POWER_PARAMS,
10938 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10939 0,
10940 "setpowerparams" },
10941 {
10942 WLAN_GET_LINK_SPEED,
10943 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010944 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010945};
10946
10947
10948
10949const struct iw_handler_def we_handler_def = {
10950 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10951 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10952 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10953
10954 .standard = (iw_handler *)we_handler,
10955 .private = (iw_handler *)we_private,
10956 .private_args = we_private_args,
10957 .get_wireless_stats = get_wireless_stats,
10958};
10959
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010960int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10961{
10962 v_U32_t cmd = 288; //Command to RIVA
10963 hdd_context_t *pHddCtx = NULL;
10964 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10965 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10966 /*
10967 *configMccParam : specify the bit which needs to be modified
10968 *allowed to update based on wlan_qcom_cfg.ini
10969 * configuration
10970 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10971 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10972 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10973 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10974 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10975 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10976 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10977 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10978 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10979 * Bit 9 : Reserved
10980 */
10981 switch (arg1)
10982 {
10983 //Update MCC SCHEDULE_TIME_SLICE parameter
10984 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10985 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10986 {
10987 if((arg2 >= 5) && (arg2 <= 20))
10988 {
10989 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10990 }
10991 else
10992 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010993 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010994 return 0;
10995 }
10996 }
10997 break;
10998
10999 //Update MCC MAX_NULL_SEND_TIME parameter
11000 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11001 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11002 {
11003 if((arg2 >= 1) && (arg2 <= 10))
11004 {
11005 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11006 }
11007 else
11008 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011009 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011010 return 0;
11011 }
11012 }
11013 break;
11014
11015 //Update MCC TX_EARLY_STOP_TIME parameter
11016 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11017 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11018 {
11019 if((arg2 >= 1) && (arg2 <= 10))
11020 {
11021 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11022 }
11023 else
11024 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011025 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011026 return 0;
11027 }
11028 }
11029 break;
11030
11031 //Update MCC RX_DRAIN_TIME parameter
11032 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11033 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11034 {
11035 if((arg2 >= 1) && (arg2 <= 10))
11036 {
11037 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11038 }
11039 else
11040 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011041 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011042 return 0;
11043 }
11044 }
11045 break;
11046
11047 //Update MCC CHANNEL_SWITCH_TIME parameter
11048 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11049 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11050 {
11051 if((arg2 >= 1) && (arg2 <= 20))
11052 {
11053 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11054 }
11055 else
11056 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011057 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011058 return 0;
11059 }
11060 }
11061 break;
11062
11063 //Update MCC MIN_CHANNEL_TIME parameter
11064 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11065 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11066 {
11067 if((arg2 >= 5) && (arg2 <= 20))
11068 {
11069 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11070 }
11071 else
11072 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011073 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011074 return 0;
11075 }
11076 }
11077 break;
11078
11079 //Update MCC PARK_BEFORE_TBTT parameter
11080 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11081 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11082 {
11083 if((arg2 >= 1) && (arg2 <= 5))
11084 {
11085 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11086 }
11087 else
11088 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011089 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011090 return 0;
11091 }
11092 }
11093 break;
11094
11095 //Update MCC MIN_AFTER_DTIM parameter
11096 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11097 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11098 {
11099 if((arg2 >= 5) && (arg2 <= 15))
11100 {
11101 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11102 }
11103 else
11104 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011105 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011106 return 0;
11107 }
11108 }
11109 break;
11110
11111 //Update MCC TOO_CLOSE_MARGIN parameter
11112 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11113 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11114 {
11115 if((arg2 >= 1) && (arg2 <= 3))
11116 {
11117 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11118 }
11119 else
11120 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011121 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011122 return 0;
11123 }
11124 }
11125 break;
11126
11127 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011128 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011129 __FUNCTION__,arg1);
11130 break;
11131 }
11132 return 0;
11133}
11134
Jeff Johnson295189b2012-06-20 16:38:30 -070011135int hdd_set_wext(hdd_adapter_t *pAdapter)
11136{
11137 hdd_wext_state_t *pwextBuf;
11138 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011139 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011140
11141 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11142
11143 // Now configure the roaming profile links. To SSID and bssid.
11144 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11145 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11146
11147 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11148 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11149
11150 /*Set the numOfChannels to zero to scan all the channels*/
11151 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11152 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11153
11154 /* Default is no encryption */
11155 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11156 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11157
11158 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11159 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11160
11161 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11162
11163 /* Default is no authentication */
11164 pwextBuf->roamProfile.AuthType.numEntries = 1;
11165 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11166
11167 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11168 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11169
11170 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011171 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011172
11173 hdd_clearRoamProfileIe(pAdapter);
11174
11175 return VOS_STATUS_SUCCESS;
11176
11177 }
11178
11179int hdd_register_wext(struct net_device *dev)
11180 {
11181 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11182 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11183 VOS_STATUS status;
11184
11185 ENTER();
11186
11187 // Zero the memory. This zeros the profile structure.
11188 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11189
11190 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11191
11192
11193 status = hdd_set_wext(pAdapter);
11194
11195 if(!VOS_IS_STATUS_SUCCESS(status)) {
11196
Arif Hussain6d2a3322013-11-17 19:50:10 -080011197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011198 return eHAL_STATUS_FAILURE;
11199 }
11200
11201 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11202 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011204 return eHAL_STATUS_FAILURE;
11205 }
11206
11207 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11208 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011210 return eHAL_STATUS_FAILURE;
11211 }
11212
11213 // Register as a wireless device
11214 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11215
11216 EXIT();
11217 return 0;
11218}
11219
11220int hdd_UnregisterWext(struct net_device *dev)
11221{
c_hpothu2a13bc32015-01-21 12:48:54 +053011222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11223 if (dev != NULL)
11224 {
11225 rtnl_lock();
11226 dev->wireless_handlers = NULL;
11227 rtnl_unlock();
11228 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011229
Jeff Johnson295189b2012-06-20 16:38:30 -070011230 return 0;
11231}
11232
11233