blob: 9cd41e6cf570fd2db17759b95ec4e9f8736c1ce1 [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
228/* Private ioctls and their sub-ioctls */
229#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
230#define WE_CLEAR_STATS 1
231#define WE_INIT_AP 2
232#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530233#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700234#define WE_ENABLE_AMP 4
235#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530236#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700237#define WE_ENABLE_DXE_STALL_DETECT 6
238#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700239#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530240#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530241#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530242#define WE_DUMP_ROAM_TIMER_LOG 12
243#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530244#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530245#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530246
Jeff Johnson295189b2012-06-20 16:38:30 -0700247/* Private ioctls and their sub-ioctls */
248#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
249#define WE_LOG_DUMP_CMD 1
250
Jeff Johnson295189b2012-06-20 16:38:30 -0700251#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800252//IOCTL to configure MCC params
253#define WE_MCC_CONFIG_CREDENTIAL 3
254#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700255
Chilam NG571c65a2013-01-19 12:27:36 +0530256#ifdef FEATURE_WLAN_TDLS
257#define WE_TDLS_CONFIG_PARAMS 5
258#endif
259
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700260#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530261#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530262#define WE_CONFIGURE_MONITOR_MODE 10
263#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700264
Chilam Ng01120412013-02-19 18:32:21 -0800265#ifdef FEATURE_WLAN_TDLS
266#undef MAX_VAR_ARGS
267#define MAX_VAR_ARGS 10
268#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700269#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800270#endif
271
Jeff Johnson295189b2012-06-20 16:38:30 -0700272/* Private ioctls (with no sub-ioctls) */
273/* note that they must be odd so that they have "get" semantics */
274#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
275#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
276#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
277
Girish Gowli464c9c82014-06-09 19:47:53 +0530278/* (SIOCIWFIRSTPRIV + 8) is currently unused */
279/* (SIOCIWFIRSTPRIV + 16) is currently unused */
280/* (SIOCIWFIRSTPRIV + 10) is currently unused */
281/* (SIOCIWFIRSTPRIV + 12) is currently unused */
282/* (SIOCIWFIRSTPRIV + 14) is currently unused */
283/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
Jeff Johnsone7245742012-09-05 17:12:55 -0700285#ifdef FEATURE_OEM_DATA_SUPPORT
286/* Private ioctls for setting the measurement configuration */
287#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
288#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700290
291#ifdef WLAN_FEATURE_VOWIFI_11R
292#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
293#endif
294
295/* Private ioctl for setting the host offload feature */
296#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
297
298/* Private ioctl to get the statistics */
299#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
300
301/* Private ioctl to set the Keep Alive Params */
302#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
303#ifdef WLAN_FEATURE_PACKET_FILTERING
304/* Private ioctl to set the Packet Filtering Params */
305#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
306#endif
307
308#ifdef FEATURE_WLAN_SCAN_PNO
309/* Private ioctl to get the statistics */
310#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
311#endif
312
313#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
314
315#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
316#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700317/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700318
Jeff Johnson295189b2012-06-20 16:38:30 -0700319#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
320#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
321
322#define WLAN_STATS_INVALID 0
323#define WLAN_STATS_RETRY_CNT 1
324#define WLAN_STATS_MUL_RETRY_CNT 2
325#define WLAN_STATS_TX_FRM_CNT 3
326#define WLAN_STATS_RX_FRM_CNT 4
327#define WLAN_STATS_FRM_DUP_CNT 5
328#define WLAN_STATS_FAIL_CNT 6
329#define WLAN_STATS_RTS_FAIL_CNT 7
330#define WLAN_STATS_ACK_FAIL_CNT 8
331#define WLAN_STATS_RTS_SUC_CNT 9
332#define WLAN_STATS_RX_DISCARD_CNT 10
333#define WLAN_STATS_RX_ERROR_CNT 11
334#define WLAN_STATS_TX_BYTE_CNT 12
335
336#define WLAN_STATS_RX_BYTE_CNT 13
337#define WLAN_STATS_RX_RATE 14
338#define WLAN_STATS_TX_RATE 15
339
Jeff Johnsone7245742012-09-05 17:12:55 -0700340#define WLAN_STATS_RX_UC_BYTE_CNT 16
341#define WLAN_STATS_RX_MC_BYTE_CNT 17
342#define WLAN_STATS_RX_BC_BYTE_CNT 18
343#define WLAN_STATS_TX_UC_BYTE_CNT 19
344#define WLAN_STATS_TX_MC_BYTE_CNT 20
345#define WLAN_STATS_TX_BC_BYTE_CNT 21
346
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800347#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
348 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
349 { \
350 *__p++ = __type; \
351 *__p++ = __size; \
352 memcpy(__p, __val, __size); \
353 __p += __size; \
354 __tlen += __size + 2; \
355 } \
356 else \
357 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800358 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800359 } \
360 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700361
362#define VERSION_VALUE_MAX_LEN 32
363
364#define TX_PER_TRACKING_DEFAULT_RATIO 5
365#define TX_PER_TRACKING_MAX_RATIO 10
366#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
367
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530368#define WLAN_ADAPTER 0
369#define P2P_ADAPTER 1
370
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530371/*
372 * When supplicant sends SETBAND ioctl it queries for channels from
373 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
374 * This is not required if the return type from ioctl is
375 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
376 * event as part of regulatory_hint.
377 */
378enum {
379 SEND_CHANNEL_CHANGE_EVENT = 0,
380 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
381};
382
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800383/*MCC Configuration parameters */
384enum {
385 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
386 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
387 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
388 MCC_RX_DRAIN_TIME_CFG_PARAM,
389 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
390 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
391 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
392 MCC_MIN_AFTER_DTIM_CFG_PARAM,
393 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
394};
395
396int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
397 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
398
Jeff Johnson295189b2012-06-20 16:38:30 -0700399#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800400int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700401 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700402#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530403static int get_fwr_memdump(struct net_device *,
404 struct iw_request_info *,
405 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700406/**---------------------------------------------------------------------------
407
Arif Hussain0273cba2014-01-07 20:58:29 -0800408 \brief mem_alloc_copy_from_user_helper -
409
410 Helper function to allocate buffer and copy user data.
411
412 \param - wrqu - Pointer to IOCTL Data.
413 len - size
414
415 \return - On Success pointer to buffer, On failure NULL
416
417 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530418void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800419{
420 u8 *ptr = NULL;
421
422 /* in order to protect the code, an extra byte is post appended to the buffer
423 * and the null termination is added. However, when allocating (len+1) byte
424 * of memory, we need to make sure that there is no uint overflow when doing
425 * addition. In theory check len < UINT_MAX protects the uint overflow. For
426 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
427 * guess, now, it is assumed that the private command buffer size is no
428 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
429 */
430 if (len > MAX_USER_COMMAND_SIZE)
431 {
432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
433 "Invalid length");
434 return NULL;
435 }
436
437 ptr = kmalloc(len + 1, GFP_KERNEL);
438 if (NULL == ptr)
439 {
440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
441 "unable to allocate memory");
442 return NULL;
443 }
444
445 if (copy_from_user(ptr, wrqu_data, len))
446 {
447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
448 "%s: failed to copy data to user buffer", __func__);
449 kfree(ptr);
450 return NULL;
451 }
452 ptr[len] = '\0';
453 return ptr;
454}
455
Girish Gowli488ef492014-06-12 18:44:33 +0530456// Function to handle and get compatible struct iw_point passed to ioctl.
457int hdd_priv_get_data(struct iw_point *p_priv_data,
458 union iwreq_data *wrqu)
459{
460 if ((NULL == p_priv_data) || (NULL == wrqu))
461 {
462 return -EINVAL;
463 }
464
465#ifdef CONFIG_COMPAT
466 if (is_compat_task())
467 {
468 struct compat_iw_point *p_compat_priv_data;
469
470 // Compat task: typecast to campat structure and copy the members.
471 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
472
473 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
474 p_priv_data->length = p_compat_priv_data->length;
475 p_priv_data->flags = p_compat_priv_data->flags;
476 }//if(is_compat_task())
477 else
478 {
479#endif //#ifdef CONFIG_COMPAT
480
481 // Non compat task: directly copy the structure.
482 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
483
484#ifdef CONFIG_COMPAT
485 }//else of - if(is_compat_task())
486#endif //#ifdef CONFIG_COMPAT
487
488 return 0;
489}
490
Arif Hussain0273cba2014-01-07 20:58:29 -0800491/**---------------------------------------------------------------------------
492
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 \brief hdd_wlan_get_version() -
494
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800495 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700496
497 \param - pAdapter Pointer to the adapter.
498 wrqu - Pointer to IOCTL REQUEST Data.
499 extra - Pointer to char
500
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800501 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700502
503 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800504void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
505 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700506{
507 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800508 tSirVersionString wcnss_SW_version;
509 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530510 tSirVersionString iris_name;
511 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800512 char *pSWversion;
513 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800516 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
517 sizeof(wcnss_SW_version));
518 if (VOS_IS_STATUS_SUCCESS(status))
519 {
520 pSWversion = wcnss_SW_version;
521 }
522 else
523 {
524 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 }
526
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800527 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
528 sizeof(wcnss_HW_version));
529 if (VOS_IS_STATUS_SUCCESS(status))
530 {
531 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800533 else
534 {
535 pHWversion = "Unknown";
536 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700537
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530538 status = wcnss_get_iris_name(iris_name);
539
540 if (!status) {
541 pIRISversion = iris_name;
542 } else {
543 pIRISversion = "Unknown";
544 }
545
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700546 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530547 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800548 QWLAN_VERSIONSTR,
549 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530550 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800551
552 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700553}
554
Jeff Johnson295189b2012-06-20 16:38:30 -0700555int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
556{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530557 tHalHandle hHal;
558 hdd_context_t *pHddCtx;
559 v_U32_t threshold = 0;
560 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700561
562 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530563 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530564 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
566 "%s: Adapter is NULL",__func__);
567 return -EINVAL;
568 }
569
570 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
571 ret = wlan_hdd_validate_context(pHddCtx);
572 if (0 != ret)
573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530574 return ret;
575 }
576
577 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
578 if (NULL == hHal)
579 {
580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
581 "%s: Hal Context is NULL",__func__);
582 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 }
584
585 if ( eHAL_STATUS_SUCCESS !=
586 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
587 {
c_hpothub8245442013-11-20 23:41:09 +0530588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
589 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700590 return -EIO;
591 }
592 wrqu->rts.value = threshold;
593
594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800595 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700596
597 EXIT();
598
599 return 0;
600}
601
602int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
603{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530604 tHalHandle hHal;
605 hdd_context_t *pHddCtx;
606 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700607
608 ENTER();
609
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530610 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530611 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
613 "%s: Adapter is NULL",__func__);
614 return -EINVAL;
615 }
616
617 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
618 status = wlan_hdd_validate_context(pHddCtx);
619 if (0 != status)
620 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530621 return status;
622 }
623
624 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
625 if (NULL == hHal)
626 {
627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
628 "%s: Hal Context is NULL",__func__);
629 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 }
631
632 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
633 != eHAL_STATUS_SUCCESS )
634 {
c_hpothub8245442013-11-20 23:41:09 +0530635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
636 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 return -EIO;
638 }
639 wrqu->frag.value = threshold;
640
641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800642 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700643
644 EXIT();
645
646 return 0;
647}
648
649int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
650{
Jeff Johnsone7245742012-09-05 17:12:55 -0700651 int i;
652 if (channel > 0)
653 {
654 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
655 {
656 if (channel == freq_chan_map[i].chan)
657 {
658 *pfreq = freq_chan_map[i].freq;
659 return 1;
660 }
661 }
662 }
663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800664 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700665 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700666}
667
668static v_BOOL_t
669hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
670{
671 v_BOOL_t rsnType = VOS_FALSE;
672 // is the authType supported?
673 switch (authType)
674 {
675 case eCSR_AUTH_TYPE_NONE: //never used
676 rsnType = eANI_BOOLEAN_FALSE;
677 break;
678 // MAC layer authentication types
679 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
680 rsnType = eANI_BOOLEAN_FALSE;
681 break;
682 case eCSR_AUTH_TYPE_SHARED_KEY:
683 rsnType = eANI_BOOLEAN_FALSE;
684 break;
685 case eCSR_AUTH_TYPE_AUTOSWITCH:
686 rsnType = eANI_BOOLEAN_FALSE;
687 break;
688
689 // Upper layer authentication types
690 case eCSR_AUTH_TYPE_WPA:
691 rsnType = eANI_BOOLEAN_TRUE;
692 break;
693 case eCSR_AUTH_TYPE_WPA_PSK:
694 rsnType = eANI_BOOLEAN_TRUE;
695 break;
696 case eCSR_AUTH_TYPE_WPA_NONE:
697 rsnType = eANI_BOOLEAN_TRUE;
698 break;
699#ifdef WLAN_FEATURE_VOWIFI_11R
700 case eCSR_AUTH_TYPE_FT_RSN:
701#endif
702 case eCSR_AUTH_TYPE_RSN:
703 rsnType = eANI_BOOLEAN_TRUE;
704 break;
705#ifdef WLAN_FEATURE_VOWIFI_11R
706 case eCSR_AUTH_TYPE_FT_RSN_PSK:
707#endif
708 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700709#ifdef WLAN_FEATURE_11W
710 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530711 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700712#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 rsnType = eANI_BOOLEAN_TRUE;
714 break;
715 //case eCSR_AUTH_TYPE_FAILED:
716 case eCSR_AUTH_TYPE_UNKNOWN:
717 rsnType = eANI_BOOLEAN_FALSE;
718 break;
719 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800720 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
721 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 rsnType = eANI_BOOLEAN_FALSE;
723 break;
724 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800725 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700726 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 return rsnType;
728}
729
730static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
731{
732 struct statsContext *pStatsContext;
733 hdd_adapter_t *pAdapter;
734
735 if (ioctl_debug)
736 {
737 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700738 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 }
740
741 if (NULL == pContext)
742 {
743 hddLog(VOS_TRACE_LEVEL_ERROR,
744 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700745 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 return;
747 }
748
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 pStatsContext = pContext;
750 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800751
752 /* there is a race condition that exists between this callback
753 function and the caller since the caller could time out either
754 before or while this code is executing. we use a spinlock to
755 serialize these actions */
756 spin_lock(&hdd_context_lock);
757
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
759 {
760 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800761 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 hddLog(VOS_TRACE_LEVEL_WARN,
763 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700764 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 if (ioctl_debug)
766 {
767 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700768 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 }
770 return;
771 }
772
Jeff Johnson72a40512013-12-19 10:14:15 -0800773 /* context is valid so caller is still waiting */
774
775 /* paranoia: invalidate the magic */
776 pStatsContext->magic = 0;
777
778 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530780 if (pAdapter->rssi > 0)
781 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800782 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800784
785 /* serialization is complete */
786 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700787}
788
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530789static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
790{
791 struct statsContext *pStatsContext;
792 hdd_adapter_t *pAdapter;
793
794 if (ioctl_debug)
795 {
796 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
797 __func__, (int)snr, (int)staId, pContext);
798 }
799
800 if (NULL == pContext)
801 {
802 hddLog(VOS_TRACE_LEVEL_ERROR,
803 "%s: Bad param, pContext [%p]",
804 __func__, pContext);
805 return;
806 }
807
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530808 pStatsContext = pContext;
809 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800810
811 /* there is a race condition that exists between this callback
812 function and the caller since the caller could time out either
813 before or while this code is executing. we use a spinlock to
814 serialize these actions */
815 spin_lock(&hdd_context_lock);
816
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530817 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
818 {
819 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800820 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530821 hddLog(VOS_TRACE_LEVEL_WARN,
822 "%s: Invalid context, pAdapter [%p] magic [%08x]",
823 __func__, pAdapter, pStatsContext->magic);
824 if (ioctl_debug)
825 {
826 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
827 __func__, pAdapter, pStatsContext->magic);
828 }
829 return;
830 }
831
Jeff Johnson72a40512013-12-19 10:14:15 -0800832 /* context is valid so caller is still waiting */
833
834 /* paranoia: invalidate the magic */
835 pStatsContext->magic = 0;
836
837 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530838 pAdapter->snr = snr;
839
Jeff Johnson72a40512013-12-19 10:14:15 -0800840 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530841 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800842
843 /* serialization is complete */
844 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530845}
846
Jeff Johnson295189b2012-06-20 16:38:30 -0700847VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
848{
849 struct statsContext context;
850 hdd_context_t *pHddCtx;
851 hdd_station_ctx_t *pHddStaCtx;
852 eHalStatus hstatus;
853 long lrc;
854
855 if (NULL == pAdapter)
856 {
857 hddLog(VOS_TRACE_LEVEL_WARN,
858 "%s: Invalid context, pAdapter", __func__);
859 return VOS_STATUS_E_FAULT;
860 }
861 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
862 {
863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
864 /* return a cached value */
865 *rssi_value = pAdapter->rssi;
866 return VOS_STATUS_SUCCESS;
867 }
868
869 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
870 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
871
mukul sharma8aec69b2015-06-10 22:28:43 +0530872 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
873 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
875 __func__, pAdapter->rssi_on_disconnect);
876 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +0530877 return VOS_STATUS_SUCCESS;
878 }
879
880 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
881 {
882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
883 "%s: Roaming in progress, hence return last cached RSSI", __func__);
884 *rssi_value = pAdapter->rssi;
885 return VOS_STATUS_SUCCESS;
886 }
887
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 init_completion(&context.completion);
889 context.pAdapter = pAdapter;
890 context.magic = RSSI_CONTEXT_MAGIC;
891
892 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
893 pHddStaCtx->conn_info.staId[ 0 ],
894 pHddStaCtx->conn_info.bssId,
895 &context, pHddCtx->pvosContext);
896 if (eHAL_STATUS_SUCCESS != hstatus)
897 {
898 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700899 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 /* we'll returned a cached value below */
901 }
902 else
903 {
904 /* request was sent -- wait for the response */
905 lrc = wait_for_completion_interruptible_timeout(&context.completion,
906 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 if (lrc <= 0)
908 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800909 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700910 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 /* we'll now returned a cached value below */
912 }
913 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800914
915 /* either we never sent a request, we sent a request and received a
916 response or we sent a request and timed out. if we never sent a
917 request or if we sent a request and got a response, we want to
918 clear the magic out of paranoia. if we timed out there is a
919 race condition such that the callback function could be
920 executing at the same time we are. of primary concern is if the
921 callback function had already verified the "magic" but had not
922 yet set the completion variable when a timeout occurred. we
923 serialize these activities by invalidating the magic while
924 holding a shared spinlock which will cause us to block if the
925 callback is currently executing */
926 spin_lock(&hdd_context_lock);
927 context.magic = 0;
928 spin_unlock(&hdd_context_lock);
929
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 *rssi_value = pAdapter->rssi;
931
932 return VOS_STATUS_SUCCESS;
933}
Siddharth Bhal64246172015-02-27 01:04:37 +0530934/**---------------------------------------------------------------------------
935
936 \brief wlan_hdd_get_frame_logs() -
937
938 This function use to get Frames log.
939
940 \param - pAdapter Pointer to the adapter.
941 flag - Specify type of request. Clear and Send request are
942 supported.
943
944 \return - none
945
946 --------------------------------------------------------------------------*/
947VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
948{
Siddharth Bhal64246172015-02-27 01:04:37 +0530949 hdd_context_t *pHddCtx;
950 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +0530951
952 if (NULL == pAdapter)
953 {
954 hddLog(VOS_TRACE_LEVEL_WARN,
955 "%s: Invalid context, pAdapter", __func__);
956 return VOS_STATUS_E_FAULT;
957 }
958
959 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
960 if (!pHddCtx->mgmt_frame_logging)
961 {
962 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
963 return VOS_STATUS_E_AGAIN;
964 }
965
Siddharth Bhal4507c262015-04-29 20:20:42 +0530966 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
967 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
968 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +0530969 {
970 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
971 return VOS_STATUS_E_INVAL;
972 }
973
Siddharth Bhal4507c262015-04-29 20:20:42 +0530974 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
975 (!pHddCtx->cfg_ini->enableBMUHWtracing))
976 {
977 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
978 return VOS_STATUS_E_INVAL;
979 }
980
Abhishek Singh611295e2015-07-09 11:11:54 +0530981 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +0530982 if (eHAL_STATUS_SUCCESS != hstatus)
983 {
984 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +0530985 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +0530986 }
Siddharth Bhal64246172015-02-27 01:04:37 +0530987
988 return VOS_STATUS_SUCCESS;
989}
990
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530991
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530992VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
993{
994 struct statsContext context;
995 hdd_context_t *pHddCtx;
996 hdd_station_ctx_t *pHddStaCtx;
997 eHalStatus hstatus;
998 long lrc;
999 int valid;
1000
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301001 ENTER();
1002
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301003 if (NULL == pAdapter)
1004 {
1005 hddLog(VOS_TRACE_LEVEL_ERROR,
1006 "%s: Invalid context, pAdapter", __func__);
1007 return VOS_STATUS_E_FAULT;
1008 }
1009
1010 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1011
1012 valid = wlan_hdd_validate_context(pHddCtx);
1013 if (0 != valid)
1014 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301015 return VOS_STATUS_E_FAULT;
1016 }
1017
1018 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1019 if (NULL == pHddStaCtx)
1020 {
1021 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1022 return VOS_STATUS_E_FAULT;
1023 }
1024
1025 init_completion(&context.completion);
1026 context.pAdapter = pAdapter;
1027 context.magic = SNR_CONTEXT_MAGIC;
1028
1029 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1030 pHddStaCtx->conn_info.staId[ 0 ],
1031 pHddStaCtx->conn_info.bssId,
1032 &context);
1033 if (eHAL_STATUS_SUCCESS != hstatus)
1034 {
1035 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1036 __func__);
1037 /* we'll returned a cached value below */
1038 }
1039 else
1040 {
1041 /* request was sent -- wait for the response */
1042 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1043 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301044 if (lrc <= 0)
1045 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001046 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301047 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301048 /* we'll now returned a cached value below */
1049 }
1050 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001051
1052 /* either we never sent a request, we sent a request and received a
1053 response or we sent a request and timed out. if we never sent a
1054 request or if we sent a request and got a response, we want to
1055 clear the magic out of paranoia. if we timed out there is a
1056 race condition such that the callback function could be
1057 executing at the same time we are. of primary concern is if the
1058 callback function had already verified the "magic" but had not
1059 yet set the completion variable when a timeout occurred. we
1060 serialize these activities by invalidating the magic while
1061 holding a shared spinlock which will cause us to block if the
1062 callback is currently executing */
1063 spin_lock(&hdd_context_lock);
1064 context.magic = 0;
1065 spin_unlock(&hdd_context_lock);
1066
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301067 *snr = pAdapter->snr;
1068
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301069 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301070 return VOS_STATUS_SUCCESS;
1071}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301072
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001073#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001074
1075static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1076{
1077 struct statsContext *pStatsContext;
1078 hdd_adapter_t *pAdapter;
1079 if (ioctl_debug)
1080 {
1081 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1082 __func__, (int)rssi, (int)staId, pContext);
1083 }
1084
1085 if (NULL == pContext)
1086 {
1087 hddLog(VOS_TRACE_LEVEL_ERROR,
1088 "%s: Bad param, pContext [%p]",
1089 __func__, pContext);
1090 return;
1091 }
1092
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001093 pStatsContext = pContext;
1094 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001095
1096 /* there is a race condition that exists between this callback
1097 function and the caller since the caller could time out either
1098 before or while this code is executing. we use a spinlock to
1099 serialize these actions */
1100 spin_lock(&hdd_context_lock);
1101
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001102 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1103 {
1104 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001105 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001106 hddLog(VOS_TRACE_LEVEL_WARN,
1107 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1108 __func__, pAdapter, pStatsContext->magic);
1109 if (ioctl_debug)
1110 {
1111 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1112 __func__, pAdapter, pStatsContext->magic);
1113 }
1114 return;
1115 }
1116
Jeff Johnson72a40512013-12-19 10:14:15 -08001117 /* context is valid so caller is still waiting */
1118
1119 /* paranoia: invalidate the magic */
1120 pStatsContext->magic = 0;
1121
1122 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001123 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301124 if (pAdapter->rssi > 0)
1125 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001126 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001127 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001128
1129 /* serialization is complete */
1130 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001131}
1132
1133
1134
1135VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1136{
1137 struct statsContext context;
1138 hdd_context_t *pHddCtx = NULL;
1139 hdd_station_ctx_t *pHddStaCtx = NULL;
1140 eHalStatus hstatus;
1141 long lrc;
1142
1143 if (NULL == pAdapter)
1144 {
1145 hddLog(VOS_TRACE_LEVEL_WARN,
1146 "%s: Invalid context, pAdapter", __func__);
1147 return VOS_STATUS_E_FAULT;
1148 }
1149 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1150 {
1151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1152 /* return a cached value */
1153 *rssi_value = pAdapter->rssi;
1154 return VOS_STATUS_SUCCESS;
1155 }
1156
1157 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1158 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1159
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301160 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001161 {
1162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1163 /* return a cached value */
1164 *rssi_value = 0;
1165 return VOS_STATUS_SUCCESS;
1166 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301167
1168 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1169 {
1170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1171 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1172 *rssi_value = pAdapter->rssi;
1173 return VOS_STATUS_SUCCESS;
1174 }
1175
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001176 init_completion(&context.completion);
1177 context.pAdapter = pAdapter;
1178 context.magic = RSSI_CONTEXT_MAGIC;
1179
1180 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1181 pHddStaCtx->conn_info.staId[ 0 ],
1182 pHddStaCtx->conn_info.bssId,
1183 &context, pHddCtx->pvosContext);
1184 if (eHAL_STATUS_SUCCESS != hstatus)
1185 {
1186 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1187 __func__);
1188 /* we'll returned a cached value below */
1189 }
1190 else
1191 {
1192 /* request was sent -- wait for the response */
1193 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1194 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001195 if (lrc <= 0)
1196 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001197 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001198 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001199 /* we'll now returned a cached value below */
1200 }
1201 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001202
1203 /* either we never sent a request, we sent a request and received a
1204 response or we sent a request and timed out. if we never sent a
1205 request or if we sent a request and got a response, we want to
1206 clear the magic out of paranoia. if we timed out there is a
1207 race condition such that the callback function could be
1208 executing at the same time we are. of primary concern is if the
1209 callback function had already verified the "magic" but had not
1210 yet set the completion variable when a timeout occurred. we
1211 serialize these activities by invalidating the magic while
1212 holding a shared spinlock which will cause us to block if the
1213 callback is currently executing */
1214 spin_lock(&hdd_context_lock);
1215 context.magic = 0;
1216 spin_unlock(&hdd_context_lock);
1217
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001218 *rssi_value = pAdapter->rssi;
1219
1220 return VOS_STATUS_SUCCESS;
1221}
1222#endif
1223
1224
Jeff Johnson295189b2012-06-20 16:38:30 -07001225void hdd_StatisticsCB( void *pStats, void *pContext )
1226{
1227 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1228 hdd_stats_t *pStatsCache = NULL;
1229 hdd_wext_state_t *pWextState;
1230 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1231
1232 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1233 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1234 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1235 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1236 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1237 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1238
1239 if (pAdapter!= NULL)
1240 pStatsCache = &pAdapter->hdd_stats;
1241
1242
1243 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1244 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1245 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1246 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1247 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1248 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1249
1250 if (pStatsCache!=NULL)
1251 {
1252 // and copy the stats into the cache we keep in the adapter instance structure
1253 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1254 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1255 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1256 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1257 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1258 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1259 }
1260
1261 if(pAdapter)
1262 {
1263 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1264 if(pWextState)
1265 {
1266 vos_status = vos_event_set(&pWextState->vosevent);
1267 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1268 {
1269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001270 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001271 return;
1272 }
1273 }
1274 }
1275}
1276
1277void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1278{
1279 v_CONTEXT_t pVosContext;
1280 hdd_context_t *pHddCtx;
1281 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1282#if 0
1283 hdd_wext_state_t *pWextState;
1284 v_U32_t roamId;
1285#endif
1286
1287 ENTER();
1288
1289 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1290
1291 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1292 if (NULL == pHddCtx)
1293 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001294 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 return;
1296 }
1297#if 0
1298 pWextState = pAdapter->pWextState;
1299#endif
1300
1301 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1302 {
1303 //TODO Verify is this is really used. If yes need to fix it.
1304 hdd_reconnect_all_adapters( pHddCtx );
1305#if 0
1306 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1307 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1308 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1309
1310 if(VOS_STATUS_SUCCESS == vosStatus)
1311 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1312 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1313
1314 sme_RoamConnect(halHandle,
1315 pAdapter->sessionId, &(pWextState->roamProfile),
1316 &roamId);
1317#endif
1318 }
1319
1320 EXIT();
1321
1322}
1323
1324void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1325{
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1327
1328 /* clear WPA/RSN/WSC IE information in the profile */
1329 pWextState->roamProfile.nWPAReqIELength = 0;
1330 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1331 pWextState->roamProfile.nRSNReqIELength = 0;
1332 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1333
Chet Lanctot186b5732013-03-18 10:26:30 -07001334#ifdef FEATURE_WLAN_WAPI
1335 pWextState->roamProfile.nWAPIReqIELength = 0;
1336 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1337#endif
1338
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001340 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301342 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1344 pWextState->roamProfile.nAddIEAssocLength = 0;
1345
1346 pWextState->roamProfile.EncryptionType.numEntries = 1;
1347 pWextState->roamProfile.EncryptionType.encryptionType[0]
1348 = eCSR_ENCRYPT_TYPE_NONE;
1349
1350 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1351 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1352 = eCSR_ENCRYPT_TYPE_NONE;
1353
1354 pWextState->roamProfile.AuthType.numEntries = 1;
1355 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1356
Chet Lanctot186b5732013-03-18 10:26:30 -07001357#ifdef WLAN_FEATURE_11W
1358 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1359 pWextState->roamProfile.MFPRequired = 0;
1360 pWextState->roamProfile.MFPCapable = 0;
1361#endif
1362
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 pWextState->authKeyMgmt = 0;
1364
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301365 vos_mem_zero(&pWextState->roamProfile.Keys,
1366 sizeof(pWextState->roamProfile.Keys));
1367
Jeff Johnson295189b2012-06-20 16:38:30 -07001368#ifdef FEATURE_WLAN_WAPI
1369 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1370 pAdapter->wapi_info.nWapiMode = 0;
1371#endif
1372
1373 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1374
1375}
1376
1377void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1378{
1379 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001380
Nirav Shahf6bd2672015-03-11 12:53:15 +05301381 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001382 {
1383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301384 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001385 }
1386 else
1387 {
1388 complete(&pAdapter->ula_complete);
1389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001390}
1391
1392VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1393{
1394 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001396 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001397
1398 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1399 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001400 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001401
1402 /*To avoid race condition between the set key and the last EAPOL
1403 packet, notify TL to finish upper layer authentication incase if the
1404 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001405 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001406
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001407 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 {
1409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1410 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1411 __LINE__, vos_status );
1412 return vos_status;
1413
1414 }
1415
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001416 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301418 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001419 {
1420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301421 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001422 /* we'll still fall through and return success since the
1423 * connection may still get established but is just taking
1424 * too long for us to wait */
1425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 }
1427 return VOS_STATUS_SUCCESS;
1428}
1429
1430v_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)
1431{
1432
1433 int left = ie_len;
1434 v_U8_t *ptr = ie;
1435 v_U8_t elem_id,elem_len;
1436 v_U8_t eid = 0xDD;
1437
1438 if ( NULL == ie || 0 == ie_len )
1439 return NULL;
1440
1441 while(left >= 2)
1442 {
1443 elem_id = ptr[0];
1444 elem_len = ptr[1];
1445 left -= 2;
1446 if(elem_len > left)
1447 {
1448 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001449 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 eid,elem_len,left);
1451 return NULL;
1452 }
1453 if (elem_id == eid)
1454 {
1455 if(memcmp( &ptr[2], oui, oui_size)==0)
1456 return ptr;
1457 }
1458
1459 left -= elem_len;
1460 ptr += (elem_len + 2);
1461 }
1462 return NULL;
1463}
1464
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301465static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 union iwreq_data *wrqu, char *extra)
1467{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301468 hdd_adapter_t *pAdapter;
1469 hdd_context_t *pHddCtx;
1470 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301471
1472 ENTER();
1473
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301474 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1475 if (NULL == pAdapter)
1476 {
1477 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1478 "%s: pAdapter is NULL\n", __func__);
1479 return -EINVAL;
1480 }
1481 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1482 ret = wlan_hdd_validate_context(pHddCtx);
1483 if (0 != ret)
1484 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301485 return ret;
1486 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301487
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301489
1490 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301491 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001492}
1493
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301494static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1495 union iwreq_data *wrqu, char *extra)
1496{
1497 int ret;
1498
1499 vos_ssr_protect(__func__);
1500 ret = __iw_set_commit(dev, info, wrqu, extra);
1501 vos_ssr_unprotect(__func__);
1502
1503 return ret;
1504}
1505
1506static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 struct iw_request_info *info,
1508 char *wrqu, char *extra)
1509{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301510 hdd_adapter_t *pAdapter;
1511 hdd_context_t *pHddCtx;
1512 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301513
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301515 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1516 if (NULL == pAdapter)
1517 {
1518 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1519 "%s: pAdapter is NULL\n", __func__);
1520 return -EINVAL;
1521 }
1522 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1523 ret = wlan_hdd_validate_context(pHddCtx);
1524 if (0 != ret)
1525 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301526 return ret;
1527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1529 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301530 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001531}
1532
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301533static int iw_get_name(struct net_device *dev,
1534 struct iw_request_info *info,
1535 char *wrqu, char *extra)
1536{
1537 int ret;
1538
1539 vos_ssr_protect(__func__);
1540 ret = __iw_get_name(dev, info, wrqu, extra);
1541 vos_ssr_unprotect(__func__);
1542
1543 return ret;
1544}
1545
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301546static int __iw_set_mode(struct net_device *dev,
1547 struct iw_request_info *info,
1548 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001549{
1550 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301551 hdd_adapter_t *pAdapter;
1552 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 tCsrRoamProfile *pRoamProfile;
1554 eCsrRoamBssType LastBSSType;
1555 eMib_dot11DesiredBssType connectedBssType;
1556 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301558 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001559
1560 ENTER();
1561
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301562 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 if (NULL == pAdapter)
1564 {
1565 hddLog(VOS_TRACE_LEVEL_WARN,
1566 "%s: Invalid context, pAdapter", __func__);
1567 return 0;
1568 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301569 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1570 status = wlan_hdd_validate_context(pHddCtx);
1571 if (0 != status)
1572 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301573 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 }
1575
1576 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1577 if (pWextState == NULL)
1578 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301579 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 return -EINVAL;
1581 }
1582
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 pRoamProfile = &pWextState->roamProfile;
1585 LastBSSType = pRoamProfile->BSSType;
1586
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301587 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001588
1589 switch (wrqu->mode)
1590 {
1591 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301592 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1594 // Set the phymode correctly for IBSS.
1595 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1596 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001597 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 break;
1600 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301601 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 break;
1605 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301606 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1608 break;
1609 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301610 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 return -EOPNOTSUPP;
1612 }
1613
1614 if ( LastBSSType != pRoamProfile->BSSType )
1615 {
1616 //the BSS mode changed
1617 // We need to issue disconnect if connected or in IBSS disconnect state
1618 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1619 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1620 {
1621 VOS_STATUS vosStatus;
1622 // need to issue a disconnect to CSR.
1623 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1624 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1625 pAdapter->sessionId,
1626 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1627 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301628 {
1629 long ret;
1630 ret = wait_for_completion_interruptible_timeout(
1631 &pAdapter->disconnect_comp_var,
1632 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1633 if (ret <= 0)
1634 hddLog(VOS_TRACE_LEVEL_ERROR,
1635 FL("failed wait on disconnect_comp_var %ld"), ret);
1636 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 }
1638 }
1639
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 EXIT();
1641 return 0;
1642}
1643
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301644static int iw_set_mode(struct net_device *dev,
1645 struct iw_request_info *info,
1646 union iwreq_data *wrqu, char *extra)
1647{
1648 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001649
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301650 vos_ssr_protect(__func__);
1651 ret = __iw_set_mode(dev, info, wrqu, extra);
1652 vos_ssr_unprotect(__func__);
1653
1654 return ret;
1655}
1656
1657static int __iw_get_mode(struct net_device *dev,
1658 struct iw_request_info *info,
1659 union iwreq_data *wrqu,
1660 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001661{
1662
1663 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301664 hdd_adapter_t *pAdapter;
1665 hdd_context_t *pHddCtx;
1666 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001667
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301668 ENTER();
1669
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301670 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 if (NULL == pAdapter)
1672 {
1673 hddLog(VOS_TRACE_LEVEL_WARN,
1674 "%s: Invalid context, pAdapter", __func__);
1675 return 0;
1676 }
1677
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301678 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1679 ret = wlan_hdd_validate_context(pHddCtx);
1680 if (0 != ret)
1681 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301682 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1685 if (pWextState == NULL)
1686 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301687 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 return -EINVAL;
1689 }
1690
1691 switch (pWextState->roamProfile.BSSType)
1692 {
1693 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001694 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301695 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 break;
1697 case eCSR_BSS_TYPE_IBSS:
1698 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001699 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301700 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 break;
1702 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001703 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301704 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 break;
1706 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001707 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 break;
1709 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301710
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301711 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 return 0;
1713}
1714
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301715static int iw_get_mode(struct net_device *dev,
1716 struct iw_request_info *info,
1717 union iwreq_data *wrqu,
1718 char *extra)
1719{
1720 int ret;
1721
1722 vos_ssr_protect(__func__);
1723 ret = __iw_get_mode(dev, info, wrqu, extra);
1724 vos_ssr_unprotect(__func__);
1725
1726 return ret;
1727}
1728
1729static int __iw_set_freq(struct net_device *dev,
1730 struct iw_request_info *info,
1731 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001732{
1733 v_U32_t numChans = 0;
1734 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1735 v_U32_t indx = 0;
1736 v_U32_t status = 0;
1737
1738 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301739 hdd_adapter_t *pAdapter;
1740 hdd_context_t *pHddCtx;
1741 tHalHandle hHal;
1742 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301744
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 ENTER();
1746
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301747 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1748 if (NULL == pAdapter)
1749 {
1750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1751 "%s:Invalid Adapter",__func__);
1752 return -EINVAL;
1753 }
1754
1755 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1756 status = wlan_hdd_validate_context(pHddCtx);
1757 if (0 != status)
1758 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001759 return status;
1760 }
1761
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301762 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1763 if (NULL == hHal)
1764 {
1765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1766 "%s: Hal Context is NULL",__func__);
1767 return -EINVAL;
1768 }
1769
1770 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1771 if (NULL == pHddStaCtx)
1772 {
1773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1774 "%s:STA context is NULL",__func__);
1775 return -EINVAL;
1776 }
1777
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301779 if (NULL == pWextState)
1780 {
1781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1782 "%s: pWextState is NULL",__func__);
1783 return -EINVAL;
1784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001785
1786 pRoamProfile = &pWextState->roamProfile;
1787
Arif Hussain6d2a3322013-11-17 19:50:10 -08001788 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001789
1790 /* Link is up then return cant set channel*/
1791 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1792 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1793 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001794 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 return -EOPNOTSUPP;
1796 }
1797
1798 /* Settings by Frequency as input */
1799 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1800 (wrqu->freq.m <= (tANI_U32)5.825e8))
1801 {
1802 tANI_U32 freq = wrqu->freq.m / 100000;
1803
1804 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1805 indx++;
1806 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1807 {
1808 return -EINVAL;
1809 }
1810 wrqu->freq.e = 0;
1811 wrqu->freq.m = freq_chan_map[indx].chan;
1812
1813 }
1814
1815 if (wrqu->freq.e == 0)
1816 {
1817 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1818 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1819 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001820 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001821 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001822 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1823 return -EINVAL;
1824 }
1825
1826 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1827
1828 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1829 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1831 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 return -EIO;
1833 }
1834
1835 for (indx = 0; indx < numChans; indx++) {
1836 if (wrqu->freq.m == validChan[indx]){
1837 break;
1838 }
1839 }
1840 }
1841 else{
1842
1843 return -EINVAL;
1844 }
1845
1846 if(indx >= numChans)
1847 {
1848 return -EINVAL;
1849 }
1850
1851 /* Set the Operational Channel */
1852 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1853 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1854 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1855
Arif Hussain6d2a3322013-11-17 19:50:10 -08001856 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001857
1858 EXIT();
1859
1860 return status;
1861}
1862
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301863static int iw_set_freq(struct net_device *dev,
1864 struct iw_request_info *info,
1865 union iwreq_data *wrqu, char *extra)
1866{
1867 int ret;
1868
1869 vos_ssr_protect(__func__);
1870 ret = __iw_set_freq(dev, info, wrqu, extra);
1871 vos_ssr_unprotect(__func__);
1872
1873 return ret;
1874}
1875
1876static int __iw_get_freq(struct net_device *dev,
1877 struct iw_request_info *info,
1878 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001879{
Jeff Johnsone7245742012-09-05 17:12:55 -07001880 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301881 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 tHalHandle hHal;
1883 hdd_wext_state_t *pWextState;
1884 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301885 hdd_station_ctx_t *pHddStaCtx;
1886 hdd_context_t *pHddCtx;
1887 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001888
1889 ENTER();
1890
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301891 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1892 if (NULL == pAdapter)
1893 {
1894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1895 "%s: Adapter is NULL", __func__);
1896 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001897 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301898 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1899 ret = wlan_hdd_validate_context(pHddCtx);
1900 if (0 != ret)
1901 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301902 return ret;
1903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301905 if (NULL == hHal)
1906 {
1907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1908 "%s: Hal Context is NULL",__func__);
1909 return -EINVAL;
1910 }
1911 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1912 if (NULL == pHddStaCtx)
1913 {
1914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1915 "%s: HddStaCtx is NULL", __func__);
1916 return -EINVAL;
1917 }
1918 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1919 if (NULL == pWextState)
1920 {
1921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1922 "%s: pWextState is NULL",__func__);
1923 return -EINVAL;
1924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 pRoamProfile = &pWextState->roamProfile;
1926
1927 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1928 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001929 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 {
c_hpothub8245442013-11-20 23:41:09 +05301931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1932 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 return -EIO;
1934 }
1935 else
1936 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001937 status = hdd_wlan_get_freq(channel, &freq);
1938 if( TRUE == status )
1939 {
1940 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1941 * iwlist & iwconfig command shows frequency into proper
1942 * format (2.412 GHz instead of 246.2 MHz)*/
1943 fwrq->m = freq;
1944 fwrq->e = MHZ;
1945 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 }
1947 }
1948 else
1949 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001950 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1951 * iwlist & iwconfig command shows frequency into proper
1952 * format (2.412 GHz instead of 246.2 MHz)*/
1953 fwrq->m = 0;
1954 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301956
1957 EXIT();
1958 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001959}
1960
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301961static int iw_get_freq(struct net_device *dev,
1962 struct iw_request_info *info,
1963 struct iw_freq *fwrq, char *extra)
1964{
1965 int ret;
1966
1967 vos_ssr_protect(__func__);
1968 ret = __iw_get_freq(dev, info, fwrq, extra);
1969 vos_ssr_unprotect(__func__);
1970
1971 return ret;
1972}
1973
1974static int __iw_get_tx_power(struct net_device *dev,
1975 struct iw_request_info *info,
1976 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001977{
1978
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301979 hdd_adapter_t *pAdapter;
1980 hdd_context_t *pHddCtx;
1981 hdd_station_ctx_t *pHddStaCtx;
1982 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001983
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301984 ENTER();
1985
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301986 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1987 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001988 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1990 "%s: Adapter is NULL",__func__);
1991 return -EINVAL;
1992 }
1993 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1994 ret = wlan_hdd_validate_context(pHddCtx);
1995 if (0 != ret)
1996 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301997 return ret;
1998 }
1999
2000 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2001 if (NULL == pHddStaCtx)
2002 {
2003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2004 "%s: STA Context is NULL",__func__);
2005 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002006 }
2007
2008 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2009 {
2010 wrqu->txpower.value = 0;
2011 return 0;
2012 }
2013 wlan_hdd_get_classAstats(pAdapter);
2014 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2015
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302016 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 return 0;
2018}
2019
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302020static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 struct iw_request_info *info,
2022 union iwreq_data *wrqu, char *extra)
2023{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302024 int ret;
2025
2026 vos_ssr_protect(__func__);
2027 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2028 vos_ssr_unprotect(__func__);
2029
2030 return ret;
2031}
2032
2033static int __iw_set_tx_power(struct net_device *dev,
2034 struct iw_request_info *info,
2035 union iwreq_data *wrqu, char *extra)
2036{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302037 hdd_adapter_t *pAdapter;
2038 tHalHandle hHal;
2039 hdd_context_t *pHddCtx;
2040 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002041
2042 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302043 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2044 if (NULL == pAdapter)
2045 {
2046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2047 "%s: Adapter is NULL",__func__);
2048 return -EINVAL;
2049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002050
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302051 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2052 ret = wlan_hdd_validate_context(pHddCtx);
2053 if (0 != ret)
2054 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302055 return ret;
2056 }
2057
2058 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2059 if (NULL == hHal)
2060 {
2061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2062 "%s: Hal Context is NULL",__func__);
2063 return -EINVAL;
2064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2066 {
c_hpothub8245442013-11-20 23:41:09 +05302067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2068 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 return -EIO;
2070 }
2071
2072 EXIT();
2073
2074 return 0;
2075}
2076
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302077static int iw_set_tx_power(struct net_device *dev,
2078 struct iw_request_info *info,
2079 union iwreq_data *wrqu, char *extra)
2080{
2081 int ret;
2082
2083 vos_ssr_protect(__func__);
2084 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2085 vos_ssr_unprotect(__func__);
2086
2087 return ret;
2088}
2089
2090static int __iw_get_bitrate(struct net_device *dev,
2091 struct iw_request_info *info,
2092 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002093{
2094 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2095 eHalStatus status = eHAL_STATUS_SUCCESS;
2096 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302097 hdd_adapter_t *pAdapter;
2098 hdd_context_t *pHddCtx;
2099 hdd_station_ctx_t *pHddStaCtx;
2100 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002101
2102 ENTER();
2103
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302104 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2105 if (NULL == pAdapter)
2106 {
2107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2108 "%s: Adapter is NULL",__func__);
2109 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 }
2111
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302112 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2113 ret = wlan_hdd_validate_context(pHddCtx);
2114 if (0 != ret)
2115 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302116 return ret;
2117 }
2118
2119 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2120 if (NULL == pHddStaCtx)
2121 {
2122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2123 "%s: STA Context is NULL",__func__);
2124 return -EINVAL;
2125 }
2126
2127 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 wrqu->bitrate.value = 0;
2129 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302130 else
2131 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2133 SME_SUMMARY_STATS |
2134 SME_GLOBAL_CLASSA_STATS |
2135 SME_GLOBAL_CLASSB_STATS |
2136 SME_GLOBAL_CLASSC_STATS |
2137 SME_GLOBAL_CLASSD_STATS |
2138 SME_PER_STA_STATS,
2139 hdd_StatisticsCB, 0, FALSE,
2140 pHddStaCtx->conn_info.staId[0], pAdapter );
2141
2142 if(eHAL_STATUS_SUCCESS != status)
2143 {
2144 hddLog(VOS_TRACE_LEVEL_ERROR,
2145 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002146 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 return status;
2148 }
2149
2150 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302151 if (NULL == pWextState)
2152 {
2153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2154 "%s: pWextState is NULL",__func__);
2155 return -EINVAL;
2156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002157
2158 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2159
2160 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2161 {
2162 hddLog(VOS_TRACE_LEVEL_ERROR,
2163 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002164 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 return VOS_STATUS_E_FAILURE;
2166 }
2167
2168 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2169 }
2170
2171 EXIT();
2172
2173 return vos_status;
2174}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302175
2176static int iw_get_bitrate(struct net_device *dev,
2177 struct iw_request_info *info,
2178 union iwreq_data *wrqu, char *extra)
2179{
2180 int ret;
2181
2182 vos_ssr_protect(__func__);
2183 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2184 vos_ssr_unprotect(__func__);
2185
2186 return ret;
2187}
2188
2189
Jeff Johnson295189b2012-06-20 16:38:30 -07002190/* ccm call back function */
2191
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302192static int __iw_set_bitrate(struct net_device *dev,
2193 struct iw_request_info *info,
2194 union iwreq_data *wrqu,
2195 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002196{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302197 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302199 hdd_station_ctx_t *pHddStaCtx;
2200 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2202 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2203 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2204 v_U32_t i, rate;
2205 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302206 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207
2208 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302209 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2210 if (NULL == pAdapter)
2211 {
2212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2213 "%s: Adapter is NULL",__func__);
2214 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 }
2216
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302217 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2218 ret = wlan_hdd_validate_context(pHddCtx);
2219 if (0 != ret)
2220 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302221 return ret;
2222 }
2223
2224 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2225 if (NULL == pHddStaCtx)
2226 {
2227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2228 "%s: STA Context is NULL",__func__);
2229 return -EINVAL;
2230 }
2231
2232
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302234 if (NULL == pWextState)
2235 {
2236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2237 "%s: pWextState is NULL",__func__);
2238 return -EINVAL;
2239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002240
2241 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2242 {
2243 return -ENXIO ;
2244 }
2245
2246 rate = wrqu->bitrate.value;
2247
2248 if (rate == -1)
2249 {
2250 rate = WNI_CFG_FIXED_RATE_AUTO;
2251 valid_rate = TRUE;
2252 }
2253 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2254 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2255 {
2256 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2257 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2258 {
2259 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2260 WNI_CFG_SUPPORTED_RATES_11A,
2261 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2262 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2263 WNI_CFG_SUPPORTED_RATES_11B,
2264 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2265 {
2266 for (i = 0; i < (b_len + a_len); ++i)
2267 {
2268 /* supported rates returned is double the actual rate so we divide it by 2 */
2269 if ((supp_rates[i]&0x7F)/2 == rate)
2270 {
2271 valid_rate = TRUE;
2272 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2273 break;
2274 }
2275 }
2276 }
2277 }
2278 }
2279 if (valid_rate != TRUE)
2280 {
2281 return -EINVAL;
2282 }
2283 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2284 WNI_CFG_FIXED_RATE, rate,
2285 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2286 {
c_hpothub8245442013-11-20 23:41:09 +05302287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2288 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 return -EIO;
2290 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302291
2292 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 return 0;
2294}
2295
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302296static int iw_set_bitrate(struct net_device *dev,
2297 struct iw_request_info *info,
2298 union iwreq_data *wrqu,
2299 char *extra)
2300{
2301 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002302
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302303 vos_ssr_protect(__func__);
2304 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2305 vos_ssr_unprotect(__func__);
2306
2307 return ret;
2308}
2309
2310static int __iw_set_genie(struct net_device *dev,
2311 struct iw_request_info *info,
2312 union iwreq_data *wrqu,
2313 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002314{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302315 hdd_adapter_t *pAdapter;
2316 hdd_context_t *pHddCtx;
2317 hdd_wext_state_t *pWextState;
2318 u_int8_t *genie = NULL;
2319 u_int8_t *base_genie = NULL;
2320 v_U16_t remLen;
2321 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002322
2323 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002324
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302325 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2326 if (NULL == pAdapter)
2327 {
2328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2329 "%s: Adapter is NULL",__func__);
2330 return -EINVAL;
2331 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002332
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302333 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2334 ret = wlan_hdd_validate_context(pHddCtx);
2335 if (0 != ret)
2336 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302337 return ret;
2338 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002339
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302340 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2341 if (NULL == pWextState)
2342 {
2343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2344 "%s: pWextState is NULL",__func__);
2345 return -EINVAL;
2346 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002347
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302348 if (!wrqu->data.length) {
2349 hdd_clearRoamProfileIe(pAdapter);
2350 EXIT();
2351 return 0;
2352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002353
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302354 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2355 wrqu->data.length);
2356 if (NULL == base_genie)
2357 {
2358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2359 "mem_alloc_copy_from_user_helper fail");
2360 return -ENOMEM;
2361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002362
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302363 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002364
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302365 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002366
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302367 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2368
2369 /* clear any previous genIE before this call */
2370 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2371
2372 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 {
2374 v_U16_t eLen = 0;
2375 v_U8_t elementId;
2376 elementId = *genie++;
2377 eLen = *genie++;
2378 remLen -= 2;
2379
Arif Hussain6d2a3322013-11-17 19:50:10 -08002380 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 __func__, elementId, eLen);
2382
2383 switch ( elementId )
2384 {
2385 case IE_EID_VENDOR:
2386 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002387 {
2388 kfree(base_genie);
2389 return -EINVAL;
2390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002391
2392 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2393 {
2394 v_U16_t curGenIELen = pWextState->genIE.length;
2395 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2396 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2397
2398 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2399 {
2400 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002401 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002403 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 return -ENOMEM;
2405 }
2406 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2407 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2408 pWextState->genIE.length += eLen + 2;
2409 }
2410 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2411 {
2412 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2413 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2414 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2415 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2416 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2417 }
2418 else /* any vendorId except WPA IE should be accumulated to genIE */
2419 {
2420 v_U16_t curGenIELen = pWextState->genIE.length;
2421 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2422 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2423
2424 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2425 {
2426 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002427 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002429 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 return -ENOMEM;
2431 }
2432 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2433 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2434 pWextState->genIE.length += eLen + 2;
2435 }
2436 break;
2437 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002438 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2440 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2441 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2442 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2443 break;
2444
2445 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002446 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002447 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 return 0;
2449 }
2450 genie += eLen;
2451 remLen -= eLen;
2452 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302453
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002455 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 return 0;
2457}
2458
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302459static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 struct iw_request_info *info,
2461 union iwreq_data *wrqu,
2462 char *extra)
2463{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302464 int ret;
2465
2466 vos_ssr_protect(__func__);
2467 ret = __iw_set_genie(dev, info, wrqu, extra);
2468 vos_ssr_unprotect(__func__);
2469
2470 return ret;
2471}
2472
2473static int __iw_get_genie(struct net_device *dev,
2474 struct iw_request_info *info,
2475 union iwreq_data *wrqu,
2476 char *extra)
2477{
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302479 hdd_context_t *pHddCtx;
2480 hdd_adapter_t *pAdapter;
2481 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 eHalStatus status;
2483 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2484 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2485
2486 ENTER();
2487
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302488 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2489 if (NULL == pAdapter)
2490 {
2491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2492 "%s: Adapter is NULL",__func__);
2493 return -EINVAL;
2494 }
2495 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2496 status = wlan_hdd_validate_context(pHddCtx);
2497 if (0 != status)
2498 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302499 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 }
2501
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302503 if (NULL == pWextState)
2504 {
2505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2506 "%s: pWextState is NULL",__func__);
2507 return -EINVAL;
2508 }
2509
2510 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2511 if (NULL == pHddStaCtx)
2512 {
2513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2514 "%s: STA Context is NULL",__func__);
2515 return -EINVAL;
2516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002517
2518 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2519 {
2520 return -ENXIO;
2521 }
2522
2523 // Return something ONLY if we are associated with an RSN or WPA network
2524 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2525 pWextState->roamProfile.negotiatedAuthType))
2526 {
2527 return -ENXIO;
2528 }
2529
2530 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2531 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2532 pAdapter->sessionId,
2533 &length,
2534 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002535 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2536 if (wrqu->data.length < length)
2537 {
2538 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2539 return -EFAULT;
2540 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002541 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002542 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002543
Arif Hussain6d2a3322013-11-17 19:50:10 -08002544 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002545
2546 EXIT();
2547
2548 return 0;
2549}
2550
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302551static int iw_get_genie(struct net_device *dev,
2552 struct iw_request_info *info,
2553 union iwreq_data *wrqu,
2554 char *extra)
2555{
2556 int ret;
2557
2558 vos_ssr_protect(__func__);
2559 ret = __iw_get_genie(dev, info, wrqu, extra);
2560 vos_ssr_unprotect(__func__);
2561
2562 return ret;
2563}
2564
2565
2566static int __iw_get_encode(struct net_device *dev,
2567 struct iw_request_info *info,
2568 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002569{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302570 hdd_adapter_t *pAdapter;
2571 hdd_context_t *pHddCtx;
2572 hdd_wext_state_t *pWextState;
2573 tCsrRoamProfile *pRoamProfile;
2574 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002576
2577 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302578 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2579 if (NULL == pAdapter)
2580 {
2581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2582 "%s: Adapter is NULL",__func__);
2583 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 }
2585
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302586 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2587 ret = wlan_hdd_validate_context(pHddCtx);
2588 if (0 != ret)
2589 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302590 return ret;
2591 }
2592 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2593 if (NULL == pWextState)
2594 {
2595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2596 "%s: pWextState is NULL",__func__);
2597 return -EINVAL;
2598 }
2599
2600 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 keyId = pRoamProfile->Keys.defaultIndex;
2602
2603 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2604 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002605 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 return -EINVAL;
2607 }
2608
2609 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2610 {
2611 dwrq->flags |= IW_ENCODE_ENABLED;
2612 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2613 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2614
2615 dwrq->flags |= (keyId + 1);
2616
2617 }
2618 else
2619 {
2620 dwrq->flags |= IW_ENCODE_DISABLED;
2621 }
2622
2623 for(i=0; i < MAX_WEP_KEYS; i++)
2624 {
2625 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2626 {
2627 continue;
2628 }
2629 else
2630 {
2631 break;
2632 }
2633 }
2634
2635 if(MAX_WEP_KEYS == i)
2636 {
2637 dwrq->flags |= IW_ENCODE_NOKEY;
2638 }
2639
2640 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2641
2642 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2643 {
2644 dwrq->flags |= IW_ENCODE_OPEN;
2645 }
2646 else
2647 {
2648 dwrq->flags |= IW_ENCODE_RESTRICTED;
2649 }
2650 EXIT();
2651 return 0;
2652}
2653
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302654static int iw_get_encode(struct net_device *dev,
2655 struct iw_request_info *info,
2656 struct iw_point *dwrq, char *extra)
2657{
2658 int ret;
2659
2660 vos_ssr_protect(__func__);
2661 ret = __iw_get_encode(dev, info, dwrq, extra);
2662 vos_ssr_unprotect(__func__);
2663
2664 return ret;
2665}
2666
Jeff Johnson295189b2012-06-20 16:38:30 -07002667#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2668#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2669
2670
2671/*
2672 * This function sends a single 'key' to LIM at all time.
2673 */
2674
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302675static int __iw_get_rts_threshold(struct net_device *dev,
2676 struct iw_request_info *info,
2677 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002678{
2679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2680 v_U32_t status = 0;
2681
2682 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2683
2684 return status;
2685}
2686
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302687static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 struct iw_request_info *info,
2689 union iwreq_data *wrqu, char *extra)
2690{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302691 int ret;
2692
2693 vos_ssr_protect(__func__);
2694 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2695 vos_ssr_unprotect(__func__);
2696
2697 return ret;
2698}
2699
2700static int __iw_set_rts_threshold(struct net_device *dev,
2701 struct iw_request_info *info,
2702 union iwreq_data *wrqu, char *extra)
2703{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302704 hdd_adapter_t *pAdapter;
2705 hdd_context_t *pHddCtx;
2706 tHalHandle hHal;
2707 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002708
2709 ENTER();
2710
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302711 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2712 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002713 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2715 "%s: Adapter is NULL",__func__);
2716 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002717 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302718
2719 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2720 ret = wlan_hdd_validate_context(pHddCtx);
2721 if (0 != ret)
2722 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302723 return ret;
2724 }
2725
2726 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2727 if (NULL == hHal)
2728 {
2729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2730 "%s: Hal Context is NULL",__func__);
2731 return -EINVAL;
2732 }
2733
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2735 {
2736 return -EINVAL;
2737 }
2738
2739 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2740 {
c_hpothub8245442013-11-20 23:41:09 +05302741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2742 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 return -EIO;
2744 }
2745
2746 EXIT();
2747
2748 return 0;
2749}
2750
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302751static int iw_set_rts_threshold(struct net_device *dev,
2752 struct iw_request_info *info,
2753 union iwreq_data *wrqu, char *extra)
2754{
2755 int ret;
2756
2757 vos_ssr_protect(__func__);
2758 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2759 vos_ssr_unprotect(__func__);
2760
2761 return ret;
2762}
2763
2764static int __iw_get_frag_threshold(struct net_device *dev,
2765 struct iw_request_info *info,
2766 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002767{
2768 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2769 v_U32_t status = 0;
2770
2771 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2772
2773 return status;
2774}
2775
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302776static int iw_get_frag_threshold(struct net_device *dev,
2777 struct iw_request_info *info,
2778 union iwreq_data *wrqu, char *extra)
2779{
2780 int ret;
2781
2782 vos_ssr_protect(__func__);
2783 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2784 vos_ssr_unprotect(__func__);
2785
2786 return ret;
2787}
2788
2789static int __iw_set_frag_threshold(struct net_device *dev,
2790 struct iw_request_info *info,
2791 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002792{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302793 hdd_adapter_t *pAdapter;
2794 hdd_context_t *pHddCtx;
2795 tHalHandle hHal;
2796 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002797
2798 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302799 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2800 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002801 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2803 "%s: Adapter is NULL",__func__);
2804 return -EINVAL;
2805 }
2806
2807 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2808 ret = wlan_hdd_validate_context(pHddCtx);
2809 if (0 != ret)
2810 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302811 return ret;
2812 }
2813
2814 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2815 if (NULL == hHal)
2816 {
2817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2818 "%s: Hal Context is NULL",__func__);
2819 return -EINVAL;
2820 }
2821
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2823 {
2824 return -EINVAL;
2825 }
2826
2827 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2828 {
c_hpothub8245442013-11-20 23:41:09 +05302829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2830 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 return -EIO;
2832 }
2833
2834 EXIT();
2835
2836 return 0;
2837}
2838
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302839static int iw_set_frag_threshold(struct net_device *dev,
2840 struct iw_request_info *info,
2841 union iwreq_data *wrqu, char *extra)
2842{
2843 int ret;
2844
2845 vos_ssr_protect(__func__);
2846 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2847 vos_ssr_unprotect(__func__);
2848
2849 return ret;
2850}
2851
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302852static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 struct iw_request_info *info,
2854 union iwreq_data *wrqu, char *extra)
2855{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302856 hdd_adapter_t *pAdapter;
2857 hdd_context_t *pHddCtx;
2858 int ret = 0;
2859
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302861 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2862 if (NULL == pAdapter)
2863 {
2864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2865 "%s: Adapter is NULL",__func__);
2866 return -EINVAL;
2867 }
2868 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2869 ret = wlan_hdd_validate_context(pHddCtx);
2870 if (0 != ret)
2871 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302872 return ret;
2873 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302874
2875 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 return -EOPNOTSUPP;
2877}
2878
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302879static int iw_get_power_mode(struct net_device *dev,
2880 struct iw_request_info *info,
2881 union iwreq_data *wrqu, char *extra)
2882{
2883 int ret;
2884
2885 vos_ssr_protect(__func__);
2886 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2887 vos_ssr_unprotect(__func__);
2888
2889 return ret;
2890}
2891static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 struct iw_request_info *info,
2893 union iwreq_data *wrqu, char *extra)
2894{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302895 hdd_adapter_t *pAdapter;
2896 hdd_context_t *pHddCtx;
2897 int ret = 0;
2898
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302900 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2901 if (NULL == pAdapter)
2902 {
2903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2904 "%s: Adapter is NULL",__func__);
2905 return -EINVAL;
2906 }
2907 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2908 ret = wlan_hdd_validate_context(pHddCtx);
2909 if (0 != ret)
2910 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302911 return ret;
2912 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302913
2914 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 return -EOPNOTSUPP;
2916}
2917
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302918static int iw_set_power_mode(struct net_device *dev,
2919 struct iw_request_info *info,
2920 union iwreq_data *wrqu, char *extra)
2921{
2922 int ret;
2923
2924 vos_ssr_protect(__func__);
2925 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2926 vos_ssr_unprotect(__func__);
2927
2928 return ret;
2929}
2930
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302931static int __iw_get_range(struct net_device *dev,
2932 struct iw_request_info *info,
2933 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002934{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302935 hdd_adapter_t *pAdapter;
2936 tHalHandle hHal;
2937 hdd_context_t *pHddCtx;
2938 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 struct iw_range *range = (struct iw_range *) extra;
2940
2941 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2942
2943 v_U32_t num_channels = sizeof(channels);
2944 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2945 v_U32_t a_len;
2946 v_U32_t b_len;
2947 v_U32_t active_phy_mode = 0;
2948 v_U8_t index = 0, i;
2949
2950 ENTER();
2951
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302952 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2953 if (NULL == pAdapter)
2954 {
2955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2956 "%s: pAdapter is NULL", __func__);
2957 return -EINVAL;
2958 }
2959 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2960 ret = wlan_hdd_validate_context(pHddCtx);
2961 if (0 != ret)
2962 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302963 return ret;
2964 }
2965 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2966 if (NULL == hHal)
2967 {
2968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2969 "%s: pAdapter is NULL", __func__);
2970 return -EINVAL;
2971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 wrqu->data.length = sizeof(struct iw_range);
2973 memset(range, 0, sizeof(struct iw_range));
2974
Jeff Johnson295189b2012-06-20 16:38:30 -07002975 /*Get the phy mode*/
2976 if (ccmCfgGetInt(hHal,
2977 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2978 {
2979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002980 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002981
2982 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2983 {
2984 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002985 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 if (ccmCfgGetStr(hHal,
2987 WNI_CFG_SUPPORTED_RATES_11A,
2988 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2989 {
2990 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2991 {
2992 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2993 }
2994 for (i = 0; i < a_len; i++)
2995 {
2996 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2997 }
2998 range->num_bitrates = a_len;
2999 }
3000 else
3001 {
3002 return -EIO;
3003 }
3004 }
3005 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3006 {
3007 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003008 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 if (ccmCfgGetStr(hHal,
3010 WNI_CFG_SUPPORTED_RATES_11B,
3011 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3012 {
3013 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3014 {
3015 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3016 }
3017 for (i = 0; i < b_len; i++)
3018 {
3019 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3020 }
3021 range->num_bitrates = b_len;
3022 }
3023 else
3024 {
3025 return -EIO;
3026 }
3027 }
3028 }
3029
3030 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3031 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3032 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3033
3034 range->encoding_size[0] = 5;
3035 range->encoding_size[1] = 13;
3036 range->num_encoding_sizes = 2;
3037 range->max_encoding_tokens = MAX_WEP_KEYS;
3038
3039 // we support through Wireless Extensions 22
3040 range->we_version_compiled = WIRELESS_EXT;
3041 range->we_version_source = 22;
3042
3043 /*Supported Channels and Frequencies*/
3044 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3045 {
c_hpothub8245442013-11-20 23:41:09 +05303046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3047 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 return -EIO;
3049 }
3050 if (num_channels > IW_MAX_FREQUENCIES)
3051 {
3052 num_channels = IW_MAX_FREQUENCIES;
3053 }
3054
3055 range->num_channels = num_channels;
3056 range->num_frequency = num_channels;
3057
3058 for (index=0; index < num_channels; index++)
3059 {
3060 v_U32_t frq_indx = 0;
3061
3062 range->freq[index].i = channels[index];
3063 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3064 {
3065 if(channels[index] == freq_chan_map[frq_indx].chan)
3066 {
3067 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3068 range->freq[index].e = 1;
3069 break;
3070 }
3071 frq_indx++;
3072 }
3073 }
3074
3075 /* Event capability (kernel + driver) */
3076 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3077 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3078 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3079 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3080
3081 /*Encryption capability*/
3082 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3083 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3084
3085 /* Txpower capability */
3086 range->txpower_capa = IW_TXPOW_MWATT;
3087
3088 /*Scanning capability*/
3089 #if WIRELESS_EXT >= 22
3090 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3091 #endif
3092
3093 EXIT();
3094 return 0;
3095}
3096
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303097static int iw_get_range(struct net_device *dev,
3098 struct iw_request_info *info,
3099 union iwreq_data *wrqu, char *extra)
3100{
3101 int ret;
3102
3103 vos_ssr_protect(__func__);
3104 ret = __iw_get_range(dev, info, wrqu, extra);
3105 vos_ssr_unprotect(__func__);
3106
3107 return ret;
3108}
3109
Jeff Johnson295189b2012-06-20 16:38:30 -07003110/* Callback function registered with PMC to know status of PMC request */
3111static void iw_power_callback_fn (void *pContext, eHalStatus status)
3112{
3113 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003114
3115 if (NULL == pContext)
3116 {
3117 hddLog(VOS_TRACE_LEVEL_ERROR,
3118 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003119 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 return;
3121 }
3122
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003124
Jeff Johnson72a40512013-12-19 10:14:15 -08003125 /* there is a race condition that exists between this callback
3126 function and the caller since the caller could time out either
3127 before or while this code is executing. we use a spinlock to
3128 serialize these actions */
3129 spin_lock(&hdd_context_lock);
3130
3131 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 {
3133 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003134 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003136 "%s: Invalid context, magic [%08x]",
3137 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003138
3139 if (ioctl_debug)
3140 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003141 pr_info("%s: Invalid context, magic [%08x]\n",
3142 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 }
3144 return;
3145 }
3146
Jeff Johnson72a40512013-12-19 10:14:15 -08003147 /* context is valid so caller is still waiting */
3148
3149 /* paranoia: invalidate the magic */
3150 pStatsContext->magic = 0;
3151
3152 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003154
3155 /* serialization is complete */
3156 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003157}
3158
3159/* Callback function for tx per hit */
3160void hdd_tx_per_hit_cb (void *pCallbackContext)
3161{
3162 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3163 unsigned char tx_fail[16];
3164 union iwreq_data wrqu;
3165
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303166 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003168 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 return;
3170 }
3171 memset(&wrqu, 0, sizeof(wrqu));
3172 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3173 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3174}
3175
3176void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3177{
3178 struct statsContext *pStatsContext;
3179 tCsrGlobalClassAStatsInfo *pClassAStats;
3180 hdd_adapter_t *pAdapter;
3181
3182 if (ioctl_debug)
3183 {
3184 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003185 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 }
3187
3188 if ((NULL == pStats) || (NULL == pContext))
3189 {
3190 hddLog(VOS_TRACE_LEVEL_ERROR,
3191 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003192 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 return;
3194 }
3195
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 pClassAStats = pStats;
3197 pStatsContext = pContext;
3198 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003199
3200 /* there is a race condition that exists between this callback
3201 function and the caller since the caller could time out either
3202 before or while this code is executing. we use a spinlock to
3203 serialize these actions */
3204 spin_lock(&hdd_context_lock);
3205
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3207 {
3208 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003209 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 hddLog(VOS_TRACE_LEVEL_WARN,
3211 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003212 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 if (ioctl_debug)
3214 {
3215 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003216 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 }
3218 return;
3219 }
3220
Jeff Johnson72a40512013-12-19 10:14:15 -08003221 /* context is valid so caller is still waiting */
3222
3223 /* paranoia: invalidate the magic */
3224 pStatsContext->magic = 0;
3225
3226 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3228
Jeff Johnson72a40512013-12-19 10:14:15 -08003229 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003231
3232 /* serialization is complete */
3233 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003234}
3235
3236VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3237{
3238 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3239 eHalStatus hstatus;
3240 long lrc;
3241 struct statsContext context;
3242
3243 if (NULL == pAdapter)
3244 {
3245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3246 return VOS_STATUS_E_FAULT;
3247 }
3248 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3249 {
3250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3251 return VOS_STATUS_SUCCESS;
3252 }
3253
3254 /* we are connected
3255 prepare our callback context */
3256 init_completion(&context.completion);
3257 context.pAdapter = pAdapter;
3258 context.magic = STATS_CONTEXT_MAGIC;
3259 /* query only for Class A statistics (which include link speed) */
3260 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3261 eCSR_HDD,
3262 SME_GLOBAL_CLASSA_STATS,
3263 hdd_GetClassA_statisticsCB,
3264 0, // not periodic
3265 FALSE, //non-cached results
3266 pHddStaCtx->conn_info.staId[0],
3267 &context);
3268 if (eHAL_STATUS_SUCCESS != hstatus)
3269 {
3270 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003271 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003272 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 /* we'll returned a cached value below */
3274 }
3275 else
3276 {
3277 /* request was sent -- wait for the response */
3278 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3279 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 if (lrc <= 0)
3281 {
3282 hddLog(VOS_TRACE_LEVEL_ERROR,
3283 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003284 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 }
3286 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003287
3288 /* either we never sent a request, we sent a request and received a
3289 response or we sent a request and timed out. if we never sent a
3290 request or if we sent a request and got a response, we want to
3291 clear the magic out of paranoia. if we timed out there is a
3292 race condition such that the callback function could be
3293 executing at the same time we are. of primary concern is if the
3294 callback function had already verified the "magic" but had not
3295 yet set the completion variable when a timeout occurred. we
3296 serialize these activities by invalidating the magic while
3297 holding a shared spinlock which will cause us to block if the
3298 callback is currently executing */
3299 spin_lock(&hdd_context_lock);
3300 context.magic = 0;
3301 spin_unlock(&hdd_context_lock);
3302
3303 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 return VOS_STATUS_SUCCESS;
3305}
3306
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003307static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3308{
3309 struct statsContext *pStatsContext;
3310 tCsrSummaryStatsInfo *pSummaryStats;
3311 tCsrGlobalClassAStatsInfo *pClassAStats;
3312 hdd_adapter_t *pAdapter;
3313
3314 if (ioctl_debug)
3315 {
3316 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003317 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003318 }
3319
3320 if ((NULL == pStats) || (NULL == pContext))
3321 {
3322 hddLog(VOS_TRACE_LEVEL_ERROR,
3323 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003324 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003325 return;
3326 }
3327
Jeff Johnson72a40512013-12-19 10:14:15 -08003328 /* there is a race condition that exists between this callback
3329 function and the caller since the caller could time out either
3330 before or while this code is executing. we use a spinlock to
3331 serialize these actions */
3332 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003333
3334 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3335 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3336 pStatsContext = pContext;
3337 pAdapter = pStatsContext->pAdapter;
3338 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3339 {
3340 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003341 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003342 hddLog(VOS_TRACE_LEVEL_WARN,
3343 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003344 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003345 if (ioctl_debug)
3346 {
3347 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003348 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003349 }
3350 return;
3351 }
3352
Jeff Johnson72a40512013-12-19 10:14:15 -08003353 /* context is valid so caller is still waiting */
3354
3355 /* paranoia: invalidate the magic */
3356 pStatsContext->magic = 0;
3357
3358 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003359 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3360 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3361
Jeff Johnson72a40512013-12-19 10:14:15 -08003362 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003363 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003364
3365 /* serialization is complete */
3366 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003367}
3368
3369VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3370{
3371 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3372 eHalStatus hstatus;
3373 long lrc;
3374 struct statsContext context;
3375
3376 if (NULL == pAdapter)
3377 {
3378 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3379 return VOS_STATUS_SUCCESS;
3380 }
3381
3382 /* we are connected
3383 prepare our callback context */
3384 init_completion(&context.completion);
3385 context.pAdapter = pAdapter;
3386 context.magic = STATS_CONTEXT_MAGIC;
3387
3388 /* query only for Summary & Class A statistics */
3389 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3390 eCSR_HDD,
3391 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303392 SME_GLOBAL_CLASSA_STATS |
3393 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003394 hdd_get_station_statisticsCB,
3395 0, // not periodic
3396 FALSE, //non-cached results
3397 pHddStaCtx->conn_info.staId[0],
3398 &context);
3399 if (eHAL_STATUS_SUCCESS != hstatus)
3400 {
3401 hddLog(VOS_TRACE_LEVEL_ERROR,
3402 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003403 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003404 /* we'll return with cached values */
3405 }
3406 else
3407 {
3408 /* request was sent -- wait for the response */
3409 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3410 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003411
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003412 if (lrc <= 0)
3413 {
3414 hddLog(VOS_TRACE_LEVEL_ERROR,
3415 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003416 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003417 }
3418 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003419
3420 /* either we never sent a request, we sent a request and received a
3421 response or we sent a request and timed out. if we never sent a
3422 request or if we sent a request and got a response, we want to
3423 clear the magic out of paranoia. if we timed out there is a
3424 race condition such that the callback function could be
3425 executing at the same time we are. of primary concern is if the
3426 callback function had already verified the "magic" but had not
3427 yet set the completion variable when a timeout occurred. we
3428 serialize these activities by invalidating the magic while
3429 holding a shared spinlock which will cause us to block if the
3430 callback is currently executing */
3431 spin_lock(&hdd_context_lock);
3432 context.magic = 0;
3433 spin_unlock(&hdd_context_lock);
3434
3435 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003436 return VOS_STATUS_SUCCESS;
3437}
3438
3439
Jeff Johnson295189b2012-06-20 16:38:30 -07003440/*
3441 * Support for the LINKSPEED private command
3442 * Per the WiFi framework the response must be of the form
3443 * "LinkSpeed xx"
3444 */
3445static int iw_get_linkspeed(struct net_device *dev,
3446 struct iw_request_info *info,
3447 union iwreq_data *wrqu, char *extra)
3448{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303449 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303450 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303452 int len = sizeof(v_U32_t) + 1;
3453 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303454 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303455 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303456 int rc, valid = 0;
3457
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303458 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303459 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3460 if (NULL == pAdapter)
3461 {
3462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3463 "%s: Adapter is NULL",__func__);
3464 return -EINVAL;
3465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003466
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303467 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303468 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303469 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003470 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303471 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003472 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303473 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3474 if (NULL == pHddStaCtx)
3475 {
3476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3477 "%s: STA Context is NULL",__func__);
3478 return -EINVAL;
3479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3481 {
3482 /* we are not connected so we don't have a classAstats */
3483 link_speed = 0;
3484 }
3485 else
3486 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303487 status = wlan_hdd_get_classAstats(pAdapter);
3488
3489 if (!VOS_IS_STATUS_SUCCESS(status ))
3490 {
3491 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3492 return -EINVAL;
3493 }
3494
3495 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3496 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3497 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3498 &link_speed);
3499
3500 link_speed = link_speed / 10;
3501
3502 if (0 == link_speed)
3503 {
3504 /* The linkspeed returned by HAL is in units of 500kbps.
3505 * converting it to mbps.
3506 * This is required to support legacy firmware which does
3507 * not return link capacity.
3508 */
3509 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3510 }
3511
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 }
3513
3514 wrqu->data.length = len;
3515 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003516 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 if ((rc < 0) || (rc >= len))
3518 {
3519 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303520 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 return -EIO;
3522 }
3523
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303524 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003526 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003527}
3528
Arif Hussain695279c2014-03-24 14:06:07 -07003529/*
3530 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3531 *
3532 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303533static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003534 struct iw_request_info *info,
3535 union iwreq_data *wrqu, char *extra)
3536{
3537 int rc;
3538
3539 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3540
3541 if (rc < 0)
3542 return rc;
3543
3544 /* a value is being successfully returned */
3545 return 0;
3546}
Jeff Johnson295189b2012-06-20 16:38:30 -07003547
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303548static int iw_get_linkspeed_priv(struct net_device *dev,
3549 struct iw_request_info *info,
3550 union iwreq_data *wrqu, char *extra)
3551{
3552 int ret;
3553
3554 vos_ssr_protect(__func__);
3555 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3556 vos_ssr_unprotect(__func__);
3557
3558 return ret;
3559}
3560
Jeff Johnson295189b2012-06-20 16:38:30 -07003561/*
3562 * Support for the RSSI & RSSI-APPROX private commands
3563 * Per the WiFi framework the response must be of the form
3564 * "<ssid> rssi <xx>"
3565 * unless we are not associated, in which case the response is
3566 * "OK"
3567 */
3568static int iw_get_rssi(struct net_device *dev,
3569 struct iw_request_info *info,
3570 union iwreq_data *wrqu, char *extra)
3571{
3572 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003573 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 int len = wrqu->data.length;
3575 v_S7_t s7Rssi = 0;
3576 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3577 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3578 VOS_STATUS vosStatus;
3579 int rc;
3580
3581 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3582 (0 == ssidlen) || (ssidlen >= len))
3583 {
3584 /* we are not connected or our SSID is too long
3585 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003586 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 }
3588 else
3589 {
3590 /* we are connected with a valid SSID
3591 so we can write the SSID into the return buffer
3592 (note that it is not NUL-terminated) */
3593 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3594
3595 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3596
3597 if (VOS_STATUS_SUCCESS == vosStatus)
3598 {
3599 /* append the rssi to the ssid in the format required by
3600 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003601 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303602 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 }
3604 else
3605 {
3606 rc = -1;
3607 }
3608 }
3609
3610 /* verify that we wrote a valid response */
3611 if ((rc < 0) || (rc >= len))
3612 {
3613 // encoding or length error?
3614 hddLog(VOS_TRACE_LEVEL_ERROR,
3615 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003616 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 return -EIO;
3618 }
3619
3620 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003621 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003622}
3623
3624/*
3625 * Support for SoftAP channel range private command
3626 */
3627static int iw_softap_set_channel_range( struct net_device *dev,
3628 int startChannel,
3629 int endChannel,
3630 int band)
3631{
Jeff Johnson43971f52012-07-17 12:26:56 -07003632 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 int ret = 0;
3634 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3635 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003636 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3637
Jeff Johnson295189b2012-06-20 16:38:30 -07003638
3639 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3640 if (VOS_STATUS_SUCCESS != status)
3641 {
3642 ret = -EINVAL;
3643 }
Yathish9f22e662012-12-10 14:21:35 -08003644 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 return ret;
3646}
3647
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303648static uint8 chartohex(char c)
3649{
3650 uint8 val = 0;
3651 if (c >= '0' && c <= '9')
3652 val = c - '0';
3653 else if (c >= 'a' && c <= 'f')
3654 val = c - 'a' + 10;
3655 else if (c >= 'A' && c <= 'F')
3656 val = c - 'A' + 10;
3657 else
3658 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3659
3660 return val;
3661}
3662
3663uint8 getByte(char **buf)
3664{
3665 uint8 byte = 0;
3666 char *temp = *buf;
3667 byte = chartohex(*temp) * 16;
3668 temp++;
3669 byte += chartohex(*temp);
3670 temp++;
3671 *buf = temp;
3672 return byte;
3673}
3674
3675static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3676{
3677 tSir80211Header *macHeader;
3678 int i = 0, j = 0, length = 0;
3679 uint8 byte = 0;
3680 char *temp = pBuffer;
3681 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303682 char *pHeader;
3683 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303684
3685 macHeader = &pkt->macHeader;
3686
3687 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3688
3689 temp++;
3690
3691 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3692 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3693 pkt->encParams.keyParams.key[0].keyId);
3694
3695 for (i = 0; i< 16; i++) {
3696 pkt->encParams.keyParams.key[0].key[i]
3697 = getByte(&temp);
3698 }
3699
3700 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3701 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3702
3703 for (i = 0; i< 6; i++) {
3704 pkt->encParams.pn[i]
3705 = getByte(&temp);
3706 }
3707
3708 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3709 &pkt->encParams.pn[0], 6, 0);
3710
3711 for (i = 0, j= 5; i< 3; i++, j--) {
3712 byte = pkt->encParams.pn[i];
3713 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3714 pkt->encParams.pn[j] = byte;
3715 }
3716
3717 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303718 if (length > sizeof(tSir80211Header))
3719 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303720
Srinivas Dasari2382de62015-01-22 15:00:04 +05303721 pHeader = temp;
3722 vos_mem_zero(&header, sizeof(tSir80211Header));
3723 for (i = 0; i < length; i++) {
3724 *((uint8 *)&header + i) = getByte(&pHeader);
3725 }
3726
3727 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3728 (char *)&header, length, 0);
3729
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303730 byte = getByte(&temp);
3731
3732 macHeader->frameCtrl.protVer = byte & 0x3;
3733 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3734 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3735
3736 byte = getByte(&temp);
3737 macHeader->frameCtrl.toDS = (byte) & 0x1;
3738 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3739 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3740 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3741 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3742 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3743 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3744 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3745
3746 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3747 "macHeader->frameCtrl.type : %x "
3748 "macHeader->frameCtrl.subType : %x "
3749 "macHeader->frameCtrl.toDS : %x "
3750 "macHeader->frameCtrl.fromDS : %x "
3751 "macHeader->frameCtrl.moreFrag : %x "
3752 "macHeader->frameCtrl.retry : %x "
3753 "macHeader->frameCtrl.powerMgmt : %x "
3754 "macHeader->frameCtrl.MoreData : %x "
3755 "macHeader->frameCtrl.wep : %x "
3756 "macHeader->frameCtrl.order : %x "
3757 , macHeader->frameCtrl.protVer
3758 , macHeader->frameCtrl.type
3759 , macHeader->frameCtrl.subType
3760 , macHeader->frameCtrl.toDS
3761 , macHeader->frameCtrl.fromDS
3762 , macHeader->frameCtrl.moreFrag
3763 , macHeader->frameCtrl.retry
3764 , macHeader->frameCtrl.powerMgmt
3765 , macHeader->frameCtrl.moreData
3766 , macHeader->frameCtrl.wep
3767 , macHeader->frameCtrl.order);
3768
3769
3770 macHeader->usDurationId = getByte(&temp);
3771 macHeader->usDurationId += getByte(&temp) << 8;
3772
3773 macHeader->vA1[0] = getByte(&temp);
3774 macHeader->vA1[1] = getByte(&temp);
3775 macHeader->vA1[2] = getByte(&temp);
3776 macHeader->vA1[3] = getByte(&temp);
3777 macHeader->vA1[4] = getByte(&temp);
3778 macHeader->vA1[5] = getByte(&temp);
3779
3780 macHeader->vA2[0] = getByte(&temp);
3781 macHeader->vA2[1] = getByte(&temp);
3782 macHeader->vA2[2] = getByte(&temp);
3783 macHeader->vA2[3] = getByte(&temp);
3784 macHeader->vA2[4] = getByte(&temp);
3785 macHeader->vA2[5] = getByte(&temp);
3786
3787 macHeader->vA3[0] = getByte(&temp);
3788 macHeader->vA3[1] = getByte(&temp);
3789 macHeader->vA3[2] = getByte(&temp);
3790 macHeader->vA3[3] = getByte(&temp);
3791 macHeader->vA3[4] = getByte(&temp);
3792 macHeader->vA3[5] = getByte(&temp);
3793
3794 macHeader->sSeqCtrl = getByte(&temp);
3795 fragNum = macHeader->sSeqCtrl & 0xF;
3796 macHeader->sSeqCtrl >>= 4;
3797
3798 macHeader->sSeqCtrl += getByte(&temp) << 4;
3799
3800 macHeader->sSeqCtrl |= fragNum << 12;
3801
3802 if (length == 30 || length == 32) {
3803 macHeader->optvA4[0] = getByte(&temp);
3804 macHeader->optvA4[1] = getByte(&temp);
3805 macHeader->optvA4[2] = getByte(&temp);
3806 macHeader->optvA4[3] = getByte(&temp);
3807 macHeader->optvA4[4] = getByte(&temp);
3808 macHeader->optvA4[5] = getByte(&temp);
3809 }
3810
3811 if (length == 26 || length == 32) {
3812 macHeader->usQosCtrl = getByte(&temp);
3813 macHeader->usQosCtrl += getByte(&temp) << 8;
3814 }
3815
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303816 //parse payload
3817 length = getByte(&temp);
3818 length += getByte(&temp) << 8;
3819 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3820
3821 pkt->data.length = length;
3822
3823 for (i = 0; i< length; i++) {
3824 pkt->data.data[i] = getByte(&temp);
3825 }
3826
3827 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3828 &pkt->data.data[0], pkt->data.length, 0);
3829}
3830
3831/**---------------------------------------------------------------------------
3832
3833 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3834 encrypt message request
3835 This is an asynchronous callback function from SME when the encrypted data
3836 is received
3837
3838 \pEncInfoRsp -> Encrypted data info
3839
3840 \return - 0 for success non-zero for failure
3841 --------------------------------------------------------------------------*/
3842static void
3843hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3844{
3845 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3846
3847 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3848
3849 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3850 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3851 pEncryptedDataRsp->encryptedPayload.length);
3852 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3853 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3854 pEncryptedDataRsp->encryptedPayload.data,
3855 pEncryptedDataRsp->encryptedPayload.length, 0);
3856}
3857
Jeff Johnson295189b2012-06-20 16:38:30 -07003858VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3859{
3860 struct statsContext context;
3861 eHalStatus status;
3862 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303863 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003864
3865 if (NULL == pAdapter)
3866 {
3867 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3868 return VOS_STATUS_E_FAULT;
3869 }
3870
3871 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3872 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303873 if (pHddCtx->isLogpInProgress) {
3874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3875 "%s:LOGP in Progress. Ignore!!!", __func__);
3876 return VOS_STATUS_E_FAILURE;
3877 }
3878
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 init_completion(&context.completion);
3880
3881 context.pAdapter = pAdapter;
3882 context.magic = POWER_CONTEXT_MAGIC;
3883
3884 if (DRIVER_POWER_MODE_ACTIVE == mode)
3885 {
3886 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3887 "Full Power", __func__);
3888 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3889 iw_power_callback_fn, &context,
3890 eSME_FULL_PWR_NEEDED_BY_HDD);
3891 // Enter Full power command received from GUI this means we are disconnected
3892 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3893 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3894 if (eHAL_STATUS_PMC_PENDING == status)
3895 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003896 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 int lrc = wait_for_completion_interruptible_timeout(
3898 &context.completion,
3899 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003900
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 if (lrc <= 0)
3902 {
3903 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003904 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 }
3906 }
3907 }
3908 else if (DRIVER_POWER_MODE_AUTO == mode)
3909 {
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303910 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
3911 {
3912 hddLog(VOS_TRACE_LEVEL_ERROR,
3913 "%s:station is in still not Authenticated ignore the "
3914 "power save mode", __func__);
3915 return VOS_STATUS_E_AGAIN;
3916 }
3917
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3919 {
3920 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3921 __func__);
3922 // Enter BMPS command received from GUI this means DHCP is completed
3923 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3924 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3925 FALSE);
3926 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3927 iw_power_callback_fn, &context);
3928 if (eHAL_STATUS_PMC_PENDING == status)
3929 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003930 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003931 int lrc = wait_for_completion_interruptible_timeout(
3932 &context.completion,
3933 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 if (lrc <= 0)
3935 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003936 hddLog(VOS_TRACE_LEVEL_ERROR,
3937 "%s: SME %s while requesting BMPS",
3938 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 }
3940 }
3941 }
3942 else
3943 {
3944 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3945 "enabled in the cfg");
3946 }
3947 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003948
3949 /* either we never sent a request, we sent a request and received a
3950 response or we sent a request and timed out. if we never sent a
3951 request or if we sent a request and got a response, we want to
3952 clear the magic out of paranoia. if we timed out there is a
3953 race condition such that the callback function could be
3954 executing at the same time we are. of primary concern is if the
3955 callback function had already verified the "magic" but had not
3956 yet set the completion variable when a timeout occurred. we
3957 serialize these activities by invalidating the magic while
3958 holding a shared spinlock which will cause us to block if the
3959 callback is currently executing */
3960 spin_lock(&hdd_context_lock);
3961 context.magic = 0;
3962 spin_unlock(&hdd_context_lock);
3963
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 return VOS_STATUS_SUCCESS;
3965}
3966
3967VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3968 hdd_adapter_t *pAdapter)
3969{
3970 VOS_STATUS vos_Status;
3971
3972 if ((NULL == pAdapter) || (NULL == pHddCtx))
3973 {
3974 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3975 return VOS_STATUS_E_FAULT;
3976 }
3977
3978 /**Exit from Deep sleep or standby if we get the driver
3979 START cmd from android GUI
3980 */
3981 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3982 {
3983 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3984 "from Stand by",__func__);
3985 vos_Status = hdd_exit_standby(pHddCtx);
3986 }
3987 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3988 {
3989 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3990 "from deep sleep",__func__);
3991 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3992 }
3993 else
3994 {
3995 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3996 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3997 vos_Status = VOS_STATUS_SUCCESS;
3998 }
3999
4000 return vos_Status;
4001}
4002
4003VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4004{
4005 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4006
4007 if (NULL == pHddCtx)
4008 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304009 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 return VOS_STATUS_E_FAULT;
4011 }
4012
4013 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4014 {
4015 //Execute standby procedure.
4016 //Executing standby procedure will cause the STA to
4017 //disassociate first and then the chip will be put into standby.
4018 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4019 vos_Status = hdd_enter_standby(pHddCtx);
4020 }
4021 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4022 pHddCtx->cfg_ini->nEnableDriverStop)
4023 {
4024 //Execute deep sleep procedure
4025 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004026 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 //Deep sleep not supported
4028 vos_Status = hdd_enter_standby(pHddCtx);
4029 }
4030 else
4031 {
4032 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4033 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4034 vos_Status = VOS_STATUS_SUCCESS;
4035 }
4036
4037 return vos_Status;
4038}
4039
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004040
4041void* wlan_hdd_change_country_code_callback(void *pAdapter)
4042{
4043
4044 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004045 complete(&call_back_pAdapter->change_country_code);
4046
4047 return NULL;
4048}
4049
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304050static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 struct iw_request_info *info,
4052 union iwreq_data *wrqu, char *extra)
4053{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304054 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004055 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304057 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004058 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4059
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304060 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004061
4062 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304063
4064 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4065 if (NULL == pAdapter)
4066 {
4067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4068 "mem_alloc_copy_from_user_helper fail");
4069 return -EINVAL;
4070 }
4071 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4072 rc = wlan_hdd_validate_context(pHddCtx);
4073 if (0 != rc)
4074 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304075 return rc;
4076 }
4077
Arif Hussain24bfa702014-01-22 13:51:30 -08004078 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4079 wrqu->data.length);
4080 if (NULL == cmd)
4081 {
4082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4083 "mem_alloc_copy_from_user_helper fail");
4084 return -ENOMEM;
4085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004086
4087 if (ioctl_debug)
4088 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004089 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 }
4091
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004092 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4093 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004094
Arif Hussain24bfa702014-01-22 13:51:30 -08004095 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004097 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4099 "%s: Error in iw_set_scan!", __func__);
4100 rc = -EINVAL;
4101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 }
4103 else if( strcasecmp(cmd, "start") == 0 ) {
4104
Arif Hussain6d2a3322013-11-17 19:50:10 -08004105 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004107
Arif Hussain24bfa702014-01-22 13:51:30 -08004108 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4109 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 {
4111 union iwreq_data wrqu;
4112 char buf[10];
4113
4114 memset(&wrqu, 0, sizeof(wrqu));
4115 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4116 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4117 }
4118 else
4119 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004120 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4121 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 }
4123 goto done;
4124 }
4125 else if( strcasecmp(cmd, "stop") == 0 )
4126 {
4127 union iwreq_data wrqu;
4128 char buf[10];
4129
Arif Hussain6d2a3322013-11-17 19:50:10 -08004130 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004131
4132 wlan_hdd_enter_lowpower(pHddCtx);
4133 memset(&wrqu, 0, sizeof(wrqu));
4134 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4135 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 goto done;
4137 }
4138 else if (strcasecmp(cmd, "macaddr") == 0)
4139 {
4140 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4141 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4142 }
4143 else if (strcasecmp(cmd, "scan-active") == 0)
4144 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304145 hddLog(VOS_TRACE_LEVEL_ERROR,
4146 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004147 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 ret = snprintf(cmd, cmd_len, "OK");
4149 }
4150 else if (strcasecmp(cmd, "scan-passive") == 0)
4151 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304152 hddLog(VOS_TRACE_LEVEL_ERROR,
4153 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004154 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 ret = snprintf(cmd, cmd_len, "OK");
4156 }
4157 else if( strcasecmp(cmd, "scan-mode") == 0 )
4158 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004159 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 }
4161 else if( strcasecmp(cmd, "linkspeed") == 0 )
4162 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004163 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 }
4165 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4166 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004167 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004168 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004169
4170 country_code = cmd + 8;
4171
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004172 init_completion(&pAdapter->change_country_code);
4173
Arif Hussain24bfa702014-01-22 13:51:30 -08004174 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004175 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 country_code,
4177 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304178 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304179 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304180 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004181
4182 /* Wait for completion */
4183 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4184 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4185
4186 if (lrc <= 0)
4187 {
4188 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004189 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004190 }
4191
Arif Hussain24bfa702014-01-22 13:51:30 -08004192 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004194 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004195 "%s: SME Change Country code fail", __func__);
4196 kfree(cmd);
4197 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 }
4199 }
4200 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4201 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004202 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 }
4204 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4205 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004206 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004207
Wilson Yang1be3e652013-10-09 15:18:31 -07004208 if (9 < cmd_len)
4209 {
4210 ptr = (char*)(cmd + 9);
4211
4212 }else{
4213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4214 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004215 kfree(cmd);
4216 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004217 }
4218
4219 if (1 != sscanf(ptr,"%d",&mode))
4220 {
4221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4222 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004223 kfree(cmd);
4224 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004225 }
4226
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 wlan_hdd_enter_bmps(pAdapter, mode);
4228 /*TODO:Set the power mode*/
4229 }
4230 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4231 v_U32_t pmc_state;
4232 v_U16_t value;
4233
4234 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4235 if(pmc_state == BMPS) {
4236 value = DRIVER_POWER_MODE_AUTO;
4237 }
4238 else {
4239 value = DRIVER_POWER_MODE_ACTIVE;
4240 }
4241 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4242 }
4243 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004244 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 /*TODO: set the btcoexmode*/
4246 }
4247 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4248
Arif Hussain6d2a3322013-11-17 19:50:10 -08004249 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 /*TODO: Return the btcoex status*/
4251 }
4252 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4253
Arif Hussain6d2a3322013-11-17 19:50:10 -08004254 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004255
4256 /*TODO: Enable Rx data Filter*/
4257 }
4258 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4259
Arif Hussain6d2a3322013-11-17 19:50:10 -08004260 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004261
4262 /*TODO: Disable Rx data Filter*/
4263 }
4264 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4265
Arif Hussain6d2a3322013-11-17 19:50:10 -08004266 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 /*TODO: rxfilter-statistics*/
4268 }
4269 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4270
Arif Hussain6d2a3322013-11-17 19:50:10 -08004271 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 /*TODO: rxfilter-add*/
4273 }
4274 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4275
Arif Hussain6d2a3322013-11-17 19:50:10 -08004276 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 /*TODO: rxfilter-remove*/
4278 }
4279#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004280 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4281 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4282 /*TODO: support pnosetup*/
4283 }
4284 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4285 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4286 /*TODO: support pnoforce*/
4287 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4289
Arif Hussain6d2a3322013-11-17 19:50:10 -08004290 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004291 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4292 kfree(cmd);
4293 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 }
4295 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004296 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004297 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4298 kfree(cmd);
4299 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 }
4301#endif /*FEATURE_WLAN_SCAN_PNO*/
4302 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004303 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004304 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4305 kfree(cmd);
4306 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 }
4308 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4309 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004310 char *ptr;
4311
4312 if (18 < cmd_len)
4313 {
4314 ptr = (char*)(cmd + 18);
4315 }else{
4316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4317 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004318 kfree(cmd);
4319 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004320 }
4321
Jeff Johnson02797792013-10-26 19:17:13 -07004322 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004323 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4324 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4325 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4326 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4327 {
4328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4329 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004330 kfree(cmd);
4331 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004333
4334 // parameters checking
4335 // period has to be larger than 0
4336 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4337 {
4338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004339 kfree(cmd);
4340 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 }
4342
4343 // use default value 5 is the input is not reasonable. in unit of 10%
4344 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4345 {
4346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4347 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4348 }
4349
4350 // default is 5
4351 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4352 {
4353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4354 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4355 }
4356
Arif Hussain24bfa702014-01-22 13:51:30 -08004357 if (eHAL_STATUS_SUCCESS !=
4358 sme_SetTxPerTracking(pHddCtx->hHal,
4359 hdd_tx_per_hit_cb,
4360 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004362 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 }
4364 }
4365 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004366 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4367 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 }
4369done:
4370 /* many of the commands write information back into the command
4371 string using snprintf(). check the return value here in one
4372 place */
4373 if ((ret < 0) || (ret >= cmd_len))
4374 {
4375 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004376 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004378 else if (ret > 0)
4379 {
4380 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4381 {
4382 hddLog(VOS_TRACE_LEVEL_ERROR,
4383 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004384 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004385 return -EFAULT;
4386 }
4387 wrqu->data.length = ret;
4388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004389
4390 if (ioctl_debug)
4391 {
4392 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004393 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004395 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304396 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004397 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004398}
4399
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304400static int iw_set_priv(struct net_device *dev,
4401 struct iw_request_info *info,
4402 union iwreq_data *wrqu, char *extra)
4403{
4404 int ret;
4405 vos_ssr_protect(__func__);
4406 ret = __iw_set_priv(dev, info, wrqu, extra);
4407 vos_ssr_unprotect(__func__);
4408
4409 return ret;
4410}
4411
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304412static int __iw_set_nick(struct net_device *dev,
4413 struct iw_request_info *info,
4414 union iwreq_data *wrqu, char *extra)
4415{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304416 hdd_adapter_t *pAdapter;
4417 hdd_context_t *pHddCtx;
4418 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304419
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304420 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304421
4422 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4423 if (NULL == pAdapter)
4424 {
4425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4426 "%s: Adapter is NULL",__func__);
4427 return -EINVAL;
4428 }
4429
4430 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4431 ret = wlan_hdd_validate_context(pHddCtx);
4432 if (0 != ret)
4433 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304434 return ret;
4435 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304436 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304437 return 0;
4438}
4439
Jeff Johnson295189b2012-06-20 16:38:30 -07004440static int iw_set_nick(struct net_device *dev,
4441 struct iw_request_info *info,
4442 union iwreq_data *wrqu, char *extra)
4443{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304444 int ret;
4445
4446 vos_ssr_protect(__func__);
4447 ret = __iw_set_nick(dev, info, wrqu, extra);
4448 vos_ssr_unprotect(__func__);
4449
4450 return ret;
4451}
4452
4453static int __iw_get_nick(struct net_device *dev,
4454 struct iw_request_info *info,
4455 union iwreq_data *wrqu, char *extra)
4456{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304457 hdd_adapter_t *pAdapter;
4458 hdd_context_t *pHddCtx;
4459 int ret = 0;
4460
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304462
4463 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4464 if (NULL == pAdapter)
4465 {
4466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4467 "%s: Adapter is NULL",__func__);
4468 return -EINVAL;
4469 }
4470
4471 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4472 ret = wlan_hdd_validate_context(pHddCtx);
4473 if (0 != ret)
4474 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304475 return ret;
4476 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304477 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 return 0;
4479}
4480
4481static int iw_get_nick(struct net_device *dev,
4482 struct iw_request_info *info,
4483 union iwreq_data *wrqu, char *extra)
4484{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304485 int ret;
4486
4487 vos_ssr_protect(__func__);
4488 ret = __iw_get_nick(dev, info, wrqu, extra);
4489 vos_ssr_unprotect(__func__);
4490
4491 return ret;
4492}
4493
4494static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4495{
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304497 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004498}
4499
4500static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4501{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304502
4503 struct iw_statistics *stats;
4504
4505 vos_ssr_protect(__func__);
4506 stats = __get_wireless_stats(dev);
4507 vos_ssr_unprotect(__func__);
4508
4509 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004510}
4511
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304512static int __iw_set_encode(struct net_device *dev,
4513 struct iw_request_info *info,
4514 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004515
4516{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304517 hdd_adapter_t *pAdapter;
4518 hdd_station_ctx_t *pHddStaCtx;
4519 hdd_wext_state_t *pWextState;
4520 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 struct iw_point *encoderq = &(wrqu->encoding);
4522 v_U32_t keyId;
4523 v_U8_t key_length;
4524 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4525 v_BOOL_t fKeyPresent = 0;
4526 int i;
4527 eHalStatus status = eHAL_STATUS_SUCCESS;
4528
4529
4530 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304531 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4532 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4535 "%s: Adapter is NULL",__func__);
4536 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 }
4538
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304539 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4540 status = wlan_hdd_validate_context(pHddCtx);
4541 if (0 != status)
4542 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304543 return status;
4544 }
4545 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4546 if (NULL == pWextState)
4547 {
4548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4549 "%s: pWextState is NULL ",__func__);
4550 return -EINVAL;
4551 }
4552 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4553 if (NULL == pHddStaCtx)
4554 {
4555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4556 "%s: STA Context is NULL",__func__);
4557 return -EINVAL;
4558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004559
4560 keyId = encoderq->flags & IW_ENCODE_INDEX;
4561
4562 if(keyId)
4563 {
4564 if(keyId > MAX_WEP_KEYS)
4565 {
4566 return -EINVAL;
4567 }
4568
4569 fKeyPresent = 1;
4570 keyId--;
4571 }
4572 else
4573 {
4574 fKeyPresent = 0;
4575 }
4576
4577
4578 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4579 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 if(!fKeyPresent) {
4582
4583 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4584
4585 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4586 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4587 }
4588 }
4589 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4590 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4591 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4592 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4593
4594 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4595 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4596
4597 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4598 {
4599 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4600 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004601 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304602 {
4603 long ret;
4604 ret = wait_for_completion_interruptible_timeout(
4605 &pAdapter->disconnect_comp_var,
4606 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4607 if (ret <= 0)
4608 hddLog(VOS_TRACE_LEVEL_ERROR,
4609 FL("failed wait on disconnect_comp_var %ld"), ret);
4610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 }
4612
4613 return status;
4614
4615 }
4616
4617 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4618 {
4619 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4620
4621 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4622
4623 }
4624
4625
4626 if(wrqu->data.length > 0)
4627 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004628 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004629
4630 key_length = wrqu->data.length;
4631
4632 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4633
4634 if(5 == key_length)
4635 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004636 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004637
4638 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4639 {
4640 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4641 }
4642 else
4643 {
4644 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4645 }
4646 }
4647 else if(13 == key_length)
4648 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004649 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004650
4651 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4652 {
4653 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4654 }
4655 else
4656 {
4657 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4658 }
4659 }
4660 else
4661 {
4662 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004663 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 return -EINVAL;
4665 }
4666
4667 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4668 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4669 pWextState->roamProfile.EncryptionType.numEntries = 1;
4670 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4671 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4672 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4673
4674 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4675 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4676 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4677 {
4678
4679 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4680
4681 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4682 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4683
4684 return status;
4685 }
4686 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304687 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 return 0;
4689}
4690
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304691static int iw_set_encode(struct net_device *dev,
4692 struct iw_request_info *info,
4693 union iwreq_data *wrqu,char *extra)
4694{
4695 int ret;
4696
4697 vos_ssr_protect(__func__);
4698 ret = __iw_set_encode(dev, info, wrqu, extra);
4699 vos_ssr_unprotect(__func__);
4700
4701 return ret;
4702}
4703
4704static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 struct iw_request_info *info,
4706 struct iw_point *dwrq,
4707 char *extra)
4708{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304709 hdd_adapter_t *pAdapter;
4710 hdd_wext_state_t *pWextState;
4711 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 int keyId;
4713 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4714 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304715 int i, ret = 0;
4716 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004717
4718 ENTER();
4719
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304720 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4721 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004722 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4724 "%s: Adapter is NULL",__func__);
4725 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004726 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304727 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4728 ret = wlan_hdd_validate_context(pHddCtx);
4729 if (0 != ret)
4730 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304731 return ret;
4732 }
4733 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4734 if (NULL == pWextState)
4735 {
4736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4737 "%s: pWextState is NULL",__func__);
4738 return -EINVAL;
4739 }
4740 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004741
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 keyId = pRoamProfile->Keys.defaultIndex;
4743
4744 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4745 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004746 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 return -EINVAL;
4748 }
4749
4750 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4751 {
4752 dwrq->flags |= IW_ENCODE_ENABLED;
4753 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304754 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4755 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 }
4757 else
4758 {
4759 dwrq->flags |= IW_ENCODE_DISABLED;
4760 }
4761
4762 for(i=0; i < MAX_WEP_KEYS; i++)
4763 {
4764 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4765 {
4766 continue;
4767 }
4768 else
4769 {
4770 break;
4771 }
4772 }
4773
4774 if(MAX_WEP_KEYS == i)
4775 {
4776 dwrq->flags |= IW_ENCODE_NOKEY;
4777 }
4778 else
4779 {
4780 dwrq->flags |= IW_ENCODE_ENABLED;
4781 }
4782
4783 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4784
4785 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4786 {
4787 dwrq->flags |= IW_ENCODE_DISABLED;
4788 }
4789
4790 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4791
4792 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4793 {
4794 dwrq->flags |= IW_ENCODE_OPEN;
4795 }
4796 else
4797 {
4798 dwrq->flags |= IW_ENCODE_RESTRICTED;
4799 }
4800 EXIT();
4801 return 0;
4802
4803}
4804
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304805static int iw_get_encodeext(struct net_device *dev,
4806 struct iw_request_info *info,
4807 struct iw_point *dwrq,
4808 char *extra)
4809{
4810 int ret;
4811 vos_ssr_protect(__func__);
4812 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4813 vos_ssr_unprotect(__func__);
4814
4815 return ret;
4816}
4817
4818static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 struct iw_request_info *info,
4820 union iwreq_data *wrqu, char *extra)
4821{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304822 hdd_adapter_t *pAdapter;
4823 hdd_station_ctx_t *pHddStaCtx;
4824 hdd_wext_state_t *pWextState;
4825 hdd_context_t *pHddCtx;
4826 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004827
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304828 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 v_U32_t status = 0;
4830
4831 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4832
4833 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4834
4835 int key_index;
4836 struct iw_point *encoding = &wrqu->encoding;
4837 tCsrRoamSetKey setKey;
4838 v_U32_t roamId= 0xFF;
4839 VOS_STATUS vos_status;
4840
4841 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304842 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4843 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4846 "%s: Adapter is NULL",__func__);
4847 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304849 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4850 status = wlan_hdd_validate_context(pHddCtx);
4851 if (0 != status)
4852 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304853 return status;
4854 }
4855 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4856 if (NULL == pHddStaCtx)
4857 {
4858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4859 "%s: STA Context is NULL",__func__);
4860 return -EINVAL;
4861 }
4862 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4863 if (NULL == pWextState)
4864 {
4865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4866 "%s: pWextState is NULL",__func__);
4867 return -EINVAL;
4868 }
4869 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004870 key_index = encoding->flags & IW_ENCODE_INDEX;
4871
4872 if(key_index > 0) {
4873
4874 /*Convert from 1-based to 0-based keying*/
4875 key_index--;
4876 }
4877 if(!ext->key_len) {
4878
4879 /*Set the encrytion type to NONE*/
4880 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4881 return status;
4882 }
4883
4884 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4885 (IW_ENCODE_ALG_WEP == ext->alg))
4886 {
4887 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4888
Agarwal Ashish971c2882013-10-30 20:11:12 +05304889 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4890 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 return -EINVAL;
4892 }
4893 else {
4894 /*Static wep, update the roam profile with the keys */
4895 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4896 key_index < CSR_MAX_NUM_KEY) {
4897 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4898 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4899
4900 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4901 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4902
4903 }
4904 }
4905 return status;
4906 }
4907
4908 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4909
4910 setKey.keyId = key_index;
4911 setKey.keyLength = ext->key_len;
4912
4913 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4914 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4915 }
4916
4917 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4918 /*Key direction for group is RX only*/
4919 setKey.keyDirection = eSIR_RX_ONLY;
4920 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4921 }
4922 else {
4923
4924 setKey.keyDirection = eSIR_TX_RX;
4925 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4926 }
4927
4928 /*For supplicant pae role is zero*/
4929 setKey.paeRole = 0;
4930
4931 switch(ext->alg)
4932 {
4933 case IW_ENCODE_ALG_NONE:
4934 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4935 break;
4936
4937 case IW_ENCODE_ALG_WEP:
4938 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4939 break;
4940
4941 case IW_ENCODE_ALG_TKIP:
4942 {
4943 v_U8_t *pKey = &setKey.Key[0];
4944
4945 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4946
4947 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4948
4949 /*Supplicant sends the 32bytes key in this order
4950
4951 |--------------|----------|----------|
4952 | Tk1 |TX-MIC | RX Mic |
4953 |--------------|----------|----------|
4954 <---16bytes---><--8bytes--><--8bytes-->
4955
4956 */
4957 /*Sme expects the 32 bytes key to be in the below order
4958
4959 |--------------|----------|----------|
4960 | Tk1 |RX-MIC | TX Mic |
4961 |--------------|----------|----------|
4962 <---16bytes---><--8bytes--><--8bytes-->
4963 */
4964 /* Copy the Temporal Key 1 (TK1) */
4965 vos_mem_copy(pKey,ext->key,16);
4966
4967 /*Copy the rx mic first*/
4968 vos_mem_copy(&pKey[16],&ext->key[24],8);
4969
4970 /*Copy the tx mic */
4971 vos_mem_copy(&pKey[24],&ext->key[16],8);
4972
4973 }
4974 break;
4975
4976 case IW_ENCODE_ALG_CCMP:
4977 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4978 break;
4979
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004980#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004981#define IW_ENCODE_ALG_KRK 6
4982 case IW_ENCODE_ALG_KRK:
4983 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4984 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004985#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004986
4987 default:
4988 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4989 break;
4990 }
4991
4992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004993 ("%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 -07004994
4995#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304996 /* The supplicant may attempt to set the PTK once pre-authentication
4997 is done. Save the key in the UMAC and include it in the ADD
4998 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305000 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305002 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5003 "%s: Update PreAuth Key success", __func__);
5004 return 0;
5005 }
5006 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5007 {
5008 hddLog(VOS_TRACE_LEVEL_ERROR,
5009 "%s: Update PreAuth Key failed", __func__);
5010 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 }
5012#endif /* WLAN_FEATURE_VOWIFI_11R */
5013
5014 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5015
5016 vos_status = wlan_hdd_check_ula_done(pAdapter);
5017 if ( vos_status != VOS_STATUS_SUCCESS )
5018 {
5019 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5020 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5021 __LINE__, vos_status );
5022
5023 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5024 }
5025
5026 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5027
5028 if ( halStatus != eHAL_STATUS_SUCCESS )
5029 {
5030 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5031 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5032 __LINE__, halStatus );
5033
5034 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5035 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305036 EXIT();
5037 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005038}
5039
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305040static int iw_set_encodeext(struct net_device *dev,
5041 struct iw_request_info *info,
5042 union iwreq_data *wrqu, char *extra)
5043{
5044 int ret;
5045
5046 vos_ssr_protect(__func__);
5047 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5048 vos_ssr_unprotect(__func__);
5049
5050 return ret;
5051}
5052
5053static int __iw_set_retry(struct net_device *dev,
5054 struct iw_request_info *info,
5055 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005056{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305057 hdd_adapter_t *pAdapter;
5058 tHalHandle hHal;
5059 hdd_context_t *pHddCtx;
5060 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005061
5062 ENTER();
5063
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305064 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5065 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005066 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5068 "%s: Adapter is NULL",__func__);
5069 return -EINVAL;
5070 }
5071
5072 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5073 ret = wlan_hdd_validate_context(pHddCtx);
5074 if (0 != ret)
5075 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305076 return ret;
5077 }
5078
5079 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5080 if (NULL == hHal)
5081 {
5082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5083 "%s: Hal Context is NULL",__func__);
5084 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005085 }
5086
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5088 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5089
Arif Hussain6d2a3322013-11-17 19:50:10 -08005090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005091
5092 return -EINVAL;
5093 }
5094
5095 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5096
5097 if((wrqu->retry.flags & IW_RETRY_LONG))
5098 {
5099 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5100 {
c_hpothub8245442013-11-20 23:41:09 +05305101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5102 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 return -EIO;
5104 }
5105 }
5106 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5107 {
5108 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5109 {
c_hpothub8245442013-11-20 23:41:09 +05305110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5111 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 return -EIO;
5113 }
5114 }
5115 }
5116 else
5117 {
5118 return -EOPNOTSUPP;
5119 }
5120
Arif Hussain6d2a3322013-11-17 19:50:10 -08005121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005122
5123 EXIT();
5124
5125 return 0;
5126
5127}
5128
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305129static int iw_set_retry(struct net_device *dev,
5130 struct iw_request_info *info,
5131 union iwreq_data *wrqu, char *extra)
5132{
5133 int ret;
5134
5135 vos_ssr_protect(__func__);
5136 ret = __iw_set_retry(dev, info, wrqu, extra);
5137 vos_ssr_unprotect(__func__);
5138
5139 return ret;
5140}
5141
5142static int __iw_get_retry(struct net_device *dev,
5143 struct iw_request_info *info,
5144 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005145{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305146 hdd_adapter_t *pAdapter;
5147 hdd_context_t *pHddCtx;
5148 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005149 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305150 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005151
5152 ENTER();
5153
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305154 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5155 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005156 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5158 "%s: Adapter is NULL",__func__);
5159 return -EINVAL;
5160 }
5161
5162 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5163 ret = wlan_hdd_validate_context(pHddCtx);
5164 if (0 != ret)
5165 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305166 return ret;
5167 }
5168
5169 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5170 if (NULL == hHal)
5171 {
5172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5173 "%s: Hal Context is NULL",__func__);
5174 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005175 }
5176
Jeff Johnson295189b2012-06-20 16:38:30 -07005177 if((wrqu->retry.flags & IW_RETRY_LONG))
5178 {
5179 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5180
5181 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5182 {
c_hpothub8245442013-11-20 23:41:09 +05305183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5184 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 return -EIO;
5186 }
5187
5188 wrqu->retry.value = retry;
5189 }
5190 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5191 {
5192 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5193
5194 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5195 {
c_hpothub8245442013-11-20 23:41:09 +05305196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5197 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 return -EIO;
5199 }
5200
5201 wrqu->retry.value = retry;
5202 }
5203 else {
5204 return -EOPNOTSUPP;
5205 }
5206
Arif Hussain6d2a3322013-11-17 19:50:10 -08005207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005208
5209 EXIT();
5210
5211 return 0;
5212}
5213
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305214static int iw_get_retry(struct net_device *dev,
5215 struct iw_request_info *info,
5216 union iwreq_data *wrqu, char *extra)
5217{
5218 int ret;
5219
5220 vos_ssr_protect(__func__);
5221 ret = __iw_get_retry(dev, info, wrqu, extra);
5222 vos_ssr_unprotect(__func__);
5223
5224 return ret;
5225}
5226
5227static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 struct iw_request_info *info,
5229 union iwreq_data *wrqu,
5230 char *extra)
5231{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305232 hdd_adapter_t *pAdapter;
5233 hdd_context_t *pHddCtx;
5234 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5236 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305237 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005238
5239 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305240 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5241 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005242 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5244 "%s:Adapter is NULL",__func__);
5245 return -EINVAL;
5246 }
5247 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5248 ret = wlan_hdd_validate_context(pHddCtx);
5249 if (0 != ret)
5250 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305251 return ret;
5252 }
5253 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5254 if (NULL == pHddStaCtx)
5255 {
5256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5257 "%s:STA context is NULL",__func__);
5258 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 }
5260
5261 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5262 switch (mlme->cmd) {
5263 case IW_MLME_DISASSOC:
5264 case IW_MLME_DEAUTH:
5265
5266 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5267 {
5268 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5269
5270 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5271 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5272
5273 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5274 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5275
Jeff Johnson43971f52012-07-17 12:26:56 -07005276 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305277 {
5278 long ret;
5279 ret = wait_for_completion_interruptible_timeout(
5280 &pAdapter->disconnect_comp_var,
5281 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5282 if (ret <= 0)
5283 hddLog(VOS_TRACE_LEVEL_ERROR,
5284 FL("failed wait on disconnect_comp_var %ld"), ret);
5285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005287 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005288 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005289
5290 /* Resetting authKeyMgmt */
5291 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5292
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305293 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 netif_tx_disable(dev);
5295 netif_carrier_off(dev);
5296
5297 }
5298 else
5299 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005300 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 -07005301 }
5302 break;
5303 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005304 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 return -EINVAL;
5306 }//end of switch
5307
5308 EXIT();
5309
5310 return status;
5311
5312}
5313
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305314static int iw_set_mlme(struct net_device *dev,
5315 struct iw_request_info *info,
5316 union iwreq_data *wrqu,
5317 char *extra)
5318{
5319 int ret;
5320
5321 vos_ssr_protect(__func__);
5322 ret = __iw_set_mlme(dev, info, wrqu, extra);
5323 vos_ssr_unprotect(__func__);
5324
5325 return ret;
5326}
5327
Jeff Johnson295189b2012-06-20 16:38:30 -07005328/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305329static int __iw_setint_getnone(struct net_device *dev,
5330 struct iw_request_info *info,
5331 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005332{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305333 hdd_adapter_t *pAdapter;
5334 tHalHandle hHal;
5335 hdd_wext_state_t *pWextState;
5336 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305337 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 int *value = (int *)extra;
5339 int sub_cmd = value[0];
5340 int set_value = value[1];
5341 int ret = 0; /* success */
5342 int enable_pbm, enable_mp;
5343#ifdef CONFIG_HAS_EARLYSUSPEND
5344 v_U8_t nEnableSuspendOld;
5345#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005346
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305347 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305348 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5349 if (NULL == pAdapter)
5350 {
5351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5352 "%s: Adapter is NULL",__func__);
5353 return -EINVAL;
5354 }
5355 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5356 ret = wlan_hdd_validate_context(pHddCtx);
5357 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005358 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305359 return ret;
5360 }
Katya Nigameae74b62015-05-28 17:19:16 +05305361 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305362 {
Katya Nigameae74b62015-05-28 17:19:16 +05305363 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5364 if (NULL == hHal)
5365 {
5366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5367 "%s: Hal Context is NULL",__func__);
5368 return -EINVAL;
5369 }
5370 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5371 if (NULL == pWextState)
5372 {
5373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5374 "%s: pWextState is NULL",__func__);
5375 return -EINVAL;
5376 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005377
Katya Nigameae74b62015-05-28 17:19:16 +05305378 INIT_COMPLETION(pWextState->completion_var);
5379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 switch(sub_cmd)
5381 {
5382 case WE_SET_11D_STATE:
5383 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005384 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005385 memset(&smeConfig, 0x00, sizeof(smeConfig));
5386
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5388
5389 sme_GetConfigParam(hHal,&smeConfig);
5390 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5391
Arif Hussain6d2a3322013-11-17 19:50:10 -08005392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005393
5394 sme_UpdateConfig(hHal,&smeConfig);
5395 }
5396 else {
5397 return -EINVAL;
5398 }
5399 break;
5400 }
5401
5402 case WE_WOWL:
5403 {
5404 switch (set_value)
5405 {
5406 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305407 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 break;
5409 case 0x01:
5410 case 0x02:
5411 case 0x03:
5412 enable_mp = (set_value & 0x01) ? 1 : 0;
5413 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005414 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5416 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5417 break;
5418 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005419 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 ret = -EINVAL;
5421 break;
5422 }
5423
5424 break;
5425 }
5426 case WE_SET_POWER:
5427 {
5428 switch (set_value)
5429 {
5430 case 0: //Full Power
5431 {
5432 struct statsContext context;
5433 eHalStatus status;
5434
5435 init_completion(&context.completion);
5436
5437 context.pAdapter = pAdapter;
5438 context.magic = POWER_CONTEXT_MAGIC;
5439
5440 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5441 iw_power_callback_fn, &context,
5442 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005443 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 {
5445 int lrc = wait_for_completion_interruptible_timeout(
5446 &context.completion,
5447 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005448
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 if (lrc <= 0)
5450 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005451 hddLog(VOS_TRACE_LEVEL_ERROR,
5452 "%s: SME %s while requesting fullpower",
5453 __func__, (0 == lrc) ?
5454 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 }
5456 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005457 /* either we have a response or we timed out. if we timed
5458 out there is a race condition such that the callback
5459 function could be executing at the same time we are. of
5460 primary concern is if the callback function had already
5461 verified the "magic" but had not yet set the completion
5462 variable when a timeout occurred. we serialize these
5463 activities by invalidating the magic while holding a
5464 shared spinlock which will cause us to block if the
5465 callback is currently executing */
5466 spin_lock(&hdd_context_lock);
5467 context.magic = 0;
5468 spin_unlock(&hdd_context_lock);
5469
Arif Hussain6d2a3322013-11-17 19:50:10 -08005470 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 break;
5472 }
5473 case 1: //Enable BMPS
5474 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5475 break;
5476 case 2: //Disable BMPS
5477 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5478 break;
5479 case 3: //Request Bmps
5480 {
5481 struct statsContext context;
5482 eHalStatus status;
5483
5484 init_completion(&context.completion);
5485
5486 context.pAdapter = pAdapter;
5487 context.magic = POWER_CONTEXT_MAGIC;
5488
5489 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5490 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005491 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 {
5493 int lrc = wait_for_completion_interruptible_timeout(
5494 &context.completion,
5495 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 if (lrc <= 0)
5497 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005498 hddLog(VOS_TRACE_LEVEL_ERROR,
5499 "%s: SME %s while requesting BMPS",
5500 __func__, (0 == lrc) ? "timeout" :
5501 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 }
5503 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005504 /* either we have a response or we timed out. if we
5505 timed out there is a race condition such that the
5506 callback function could be executing at the same
5507 time we are. of primary concern is if the callback
5508 function had already verified the "magic" but had
5509 not yet set the completion variable when a timeout
5510 occurred. we serialize these activities by
5511 invalidating the magic while holding a shared
5512 spinlock which will cause us to block if the
5513 callback is currently executing */
5514 spin_lock(&hdd_context_lock);
5515 context.magic = 0;
5516 spin_unlock(&hdd_context_lock);
5517
Arif Hussain6d2a3322013-11-17 19:50:10 -08005518 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 break;
5520 }
5521 case 4: //Enable IMPS
5522 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5523 break;
5524 case 5: //Disable IMPS
5525 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5526 break;
5527 case 6: //Enable Standby
5528 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5529 break;
5530 case 7: //Disable Standby
5531 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5532 break;
5533 case 8: //Request Standby
5534#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005535#endif
5536 break;
5537 case 9: //Start Auto Bmps Timer
5538 sme_StartAutoBmpsTimer(hHal);
5539 break;
5540 case 10://Stop Auto BMPS Timer
5541 sme_StopAutoBmpsTimer(hHal);
5542 break;
5543#ifdef CONFIG_HAS_EARLYSUSPEND
5544 case 11://suspend to standby
5545#ifdef CONFIG_HAS_EARLYSUSPEND
5546 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5547 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5549#endif
5550 break;
5551 case 12://suspend to deep sleep
5552#ifdef CONFIG_HAS_EARLYSUSPEND
5553 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5554 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5556#endif
5557 break;
5558 case 13://resume from suspend
5559#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005560#endif
5561 break;
5562#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005564 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005565 ret = -EINVAL;
5566 break;
5567 }
5568 break;
5569 }
5570
5571 case WE_SET_MAX_ASSOC:
5572 {
5573 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5574 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5575 {
5576 ret = -EINVAL;
5577 }
5578 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5579 set_value, NULL, eANI_BOOLEAN_FALSE)
5580 != eHAL_STATUS_SUCCESS )
5581 {
c_hpothub8245442013-11-20 23:41:09 +05305582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5583 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 ret = -EIO;
5585 }
5586 break;
5587 }
5588
5589 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5590 {
5591 if( 0 == set_value )
5592 {
5593 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5594 }
5595 else if ( 1 == set_value )
5596 {
5597 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5598 }
5599 else
5600 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005601 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 ret = -EINVAL;
5603 }
5604 break;
5605 }
5606
5607 case WE_SET_DATA_INACTIVITY_TO:
5608 {
5609 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5610 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5611 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5612 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5613 set_value,
5614 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5615 {
5616 hddLog(LOGE,"Failure: Could not pass on "
5617 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005618 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 ret = -EINVAL;
5620 }
5621 break;
5622 }
5623 case WE_SET_MAX_TX_POWER:
5624 {
5625 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5626 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5627
5628 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5629 __func__, set_value);
5630 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5631 eHAL_STATUS_SUCCESS )
5632 {
5633 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5634 __func__);
5635 return -EIO;
5636 }
5637
5638 break;
5639 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005640 case WE_SET_MAX_TX_POWER_2_4:
5641 {
5642 hddLog(VOS_TRACE_LEVEL_INFO,
5643 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5644 __func__, set_value);
5645 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5646 eHAL_STATUS_SUCCESS)
5647 {
5648 hddLog(VOS_TRACE_LEVEL_ERROR,
5649 "%s: Setting maximum tx power failed for 2.4 GHz band",
5650 __func__);
5651 return -EIO;
5652 }
5653
5654 break;
5655 }
5656 case WE_SET_MAX_TX_POWER_5_0:
5657 {
5658 hddLog(VOS_TRACE_LEVEL_INFO,
5659 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5660 __func__, set_value);
5661 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5662 eHAL_STATUS_SUCCESS)
5663 {
5664 hddLog(VOS_TRACE_LEVEL_ERROR,
5665 "%s: Setting maximum tx power failed for 5.0 GHz band",
5666 __func__);
5667 return -EIO;
5668 }
5669
5670 break;
5671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 case WE_SET_HIGHER_DTIM_TRANSITION:
5673 {
5674 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5675 (set_value == eANI_BOOLEAN_TRUE)))
5676 {
5677 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5678 ret = -EINVAL;
5679 }
5680 else
5681 {
5682 if(pAdapter->higherDtimTransition != set_value)
5683 {
5684 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005685 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 }
5687 }
5688
5689 break;
5690 }
5691
5692 case WE_SET_TM_LEVEL:
5693 {
5694 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005695 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5697
5698 break;
5699 }
5700
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305701 case WE_ENABLE_STRICT_FCC_REG:
5702 {
5703 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5704 struct wiphy *wiphy = NULL;
5705 long lrc;
5706 int status;
5707
5708 wiphy = hddCtxt->wiphy;
5709 if(wiphy == NULL)
5710 {
5711 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5712 break;
5713 }
5714 init_completion(&hddCtxt->wiphy_channel_update_event);
5715
5716 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5717
5718 status = regulatory_hint(wiphy, "00");
5719 if(status < 0)
5720 {
5721 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5722 break;
5723 }
5724
5725 /* Wait for completion */
5726 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5727 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5728 if (lrc <= 0)
5729 {
5730 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5731 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5732 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5733 }
5734 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5735
5736 break;
5737 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005738 case WE_SET_DEBUG_LOG:
5739 {
5740 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5741 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5742 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5743 break;
5744 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305745#ifdef FEATURE_WLAN_TDLS
5746 case WE_SET_TDLS_OFF_CHAN:
5747 {
5748 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5750 __func__, set_value);
5751 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5752 break;
5753 }
5754 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5755 {
5756 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5758 __func__, set_value);
5759 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5760 break;
5761 }
5762 case WE_SET_TDLS_OFF_CHAN_MODE:
5763 {
5764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5765 __func__, set_value);
5766 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5767 break;
5768 }
5769#endif
Peng Xu2446a892014-09-05 17:21:18 +05305770 case WE_SET_SCAN_BAND_PREFERENCE:
5771 {
5772 tSmeConfigParams smeConfig;
5773 memset(&smeConfig, 0x00, sizeof(smeConfig));
5774 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5775 ret = -EINVAL;
5776 break;
5777 }
5778 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5779
5780 if (eCSR_BAND_ALL == set_value ||
5781 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5782 sme_GetConfigParam(hHal, &smeConfig);
5783 smeConfig.csrConfig.scanBandPreference = set_value;
5784
5785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5786 "set band scan preference = %d\n",
5787 smeConfig.csrConfig.scanBandPreference);
5788
5789 sme_UpdateConfig(hHal, &smeConfig);
5790 }
5791 else {
5792 ret = -EINVAL;
5793 }
5794 break;
5795 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305796 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5797 * connection happens so that the params can take effect during
5798 * association. Also this should not be used in STA+p2p concurrency
5799 * as the param will also effect the STA mode.
5800 */
5801 case WE_SET_MIRACAST_VENDOR_CONFIG:
5802 {
5803 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305804
Abhishek Singh01c73d12015-03-12 15:13:44 +05305805 hddLog(LOG1, FL(
5806 "Set Miracast vendor tuning %d"), set_value);
5807
5808 if (1 == set_value || 0 == set_value)
5809 {
5810 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5811 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5812 {
5813 hddLog( LOGE, FL("set vendor miracast config failed"));
5814 ret = -EIO;
5815 }
5816 }
5817 else
5818 {
5819 hddLog(LOGE,
5820 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5821 ret = -EINVAL;
5822 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305823 break;
5824 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305825
5826 case WE_GET_FRAME_LOG:
5827 {
5828 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5829 != VOS_STATUS_SUCCESS)
5830 {
5831 ret = -EINVAL;
5832 }
5833 break;
5834 }
5835
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305836 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5837 {
5838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5839 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5840 if (set_value == 0 || set_value == 1)
5841 {
5842 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5843 set_value);
5844 }
5845 else
5846 ret = -EINVAL;
5847
5848 break;
5849 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05305850 /* Bit mask value to enable RTS/CTS for different modes
5851 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
5852 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
5853 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
5854 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
5855 * for 5 GHz, VHT80 - 0x1000
5856 */
5857 case WE_SET_RTS_CTS_HTVHT:
5858 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305859
Abhishek Singh41988ba2015-05-25 19:42:29 +05305860 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
5861
5862 if (eHAL_STATUS_SUCCESS !=
5863 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
5864 {
5865 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
5866 ret = -EINVAL;
5867 }
5868 break;
5869 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305870 case WE_SET_MONITOR_STATE:
5871 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305872 v_U32_t magic = 0;
5873 struct completion cmpVar;
5874 long waitRet = 0;
5875 tVOS_CON_MODE mode = hdd_get_conparam();
5876
5877 if( VOS_MONITOR_MODE != mode)
5878 {
5879 hddLog(LOGE, "invalid mode %d", mode);
5880 ret = -EIO;
5881 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305882
5883 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
5884 if( pMonCtx == NULL )
5885 {
5886 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305887 ret = -EIO;
5888 }
5889 if (pMonCtx->state == set_value)
5890 {
5891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5892 FL("already in same mode curr_mode:%d req_mode: %d"),
5893 pMonCtx->state, set_value);
5894 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305895 }
5896 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305897 magic = MON_MODE_MSG_MAGIC;
5898 init_completion(&cmpVar);
5899 if (VOS_STATUS_SUCCESS !=
5900 wlan_hdd_mon_postMsg(&magic, &cmpVar,
5901 pMonCtx, hdd_monPostMsgCb)) {
5902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5903 FL("failed to post MON MODE REQ"));
5904 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
5905 MON_MODE_STOP : MON_MODE_START;
5906 magic = 0;
5907 ret = -EIO;
5908 break;
5909 }
5910 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
5911 magic = 0;
5912 if (waitRet <= 0 ){
5913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5914 FL("failed to wait on monitor mode completion %ld"),
5915 waitRet);
5916 }
5917 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305918 }
Sushant Kaushik33200572015-08-05 16:46:20 +05305919 case WE_SET_PKT_STATS_ENABLE_DISABLE:
5920 {
5921 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5922 tAniWifiStartLog start_log;
5923 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
5924 !vos_isPktStatsEnabled())
5925 {
5926 hddLog(LOGE, FL("per pkt stats not enabled"));
5927 return -EINVAL;
5928 }
5929 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
5930
5931 if (1 == set_value || 0 == set_value)
5932 {
5933 start_log.ringId = RING_ID_PER_PACKET_STATS;
5934 start_log.flag = 0;
5935 if (set_value)
5936 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
5937 else
5938 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
5939
5940 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
5941 }
5942 else
5943 {
5944 hddLog(LOGE,
5945 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
5946 set_value);
5947 ret = -EINVAL;
5948 }
5949 break;
5950 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305951
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 default:
5953 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005954 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 sub_cmd, set_value);
5956 break;
5957 }
5958 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305959 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 return ret;
5961}
5962
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305963static int iw_setint_getnone(struct net_device *dev,
5964 struct iw_request_info *info,
5965 union iwreq_data *wrqu, char *extra)
5966{
5967 int ret;
5968
5969 vos_ssr_protect(__func__);
5970 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5971 vos_ssr_unprotect(__func__);
5972
5973 return 0;
5974}
Jeff Johnson295189b2012-06-20 16:38:30 -07005975/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305976static int __iw_setchar_getnone(struct net_device *dev,
5977 struct iw_request_info *info,
5978 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005979{
5980 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305981 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005983 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305984 hdd_adapter_t *pAdapter;
5985 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005986#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305987 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005988#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305989 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305990 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005991
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305992 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305993 pAdapter = (netdev_priv(dev));
5994 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005995 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5997 "%s: Adapter is NULL",__func__);
5998 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005999 }
6000
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306001 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6002 ret = wlan_hdd_validate_context(pHddCtx);
6003 if (0 != ret)
6004 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306005 return ret;
6006 }
6007#ifdef WLAN_FEATURE_VOWIFI
6008 pConfig = pHddCtx->cfg_ini;
6009#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306010 /* helper function to get iwreq_data with compat handling. */
6011 if (hdd_priv_get_data(&s_priv_data, wrqu))
6012 {
6013 return -EINVAL;
6014 }
6015
6016 /* make sure all params are correctly passed to function */
6017 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6018 {
6019 return -EINVAL;
6020 }
6021
6022 sub_cmd = s_priv_data.flags;
6023
Arif Hussain0273cba2014-01-07 20:58:29 -08006024 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306025 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6026 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006027 if (NULL == pBuffer)
6028 {
6029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6030 "mem_alloc_copy_from_user_helper fail");
6031 return -ENOMEM;
6032 }
6033
6034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306035 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6037 "%s: Received data %s", __func__, pBuffer);
6038
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 switch(sub_cmd)
6040 {
6041 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006043 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 break;
6045 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006047 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 break;
6049#if defined WLAN_FEATURE_VOWIFI
6050 case WE_NEIGHBOR_REPORT_REQUEST:
6051 {
6052 tRrmNeighborReq neighborReq;
6053 tRrmNeighborRspCallbackInfo callbackInfo;
6054
6055 if (pConfig->fRrmEnable)
6056 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306058 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 if( !neighborReq.no_ssid )
6060 {
Girish Gowli552fc072014-06-14 18:26:16 +05306061 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006062 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006063 }
6064
6065 callbackInfo.neighborRspCallback = NULL;
6066 callbackInfo.neighborRspCallbackContext = NULL;
6067 callbackInfo.timeout = 5000; //5 seconds
6068 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6069 }
6070 else
6071 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006072 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 ret = -EINVAL;
6074 }
6075 }
6076 break;
6077#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 case WE_SET_AP_WPS_IE:
6079 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306080 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006081 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006083 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 if (VOS_STATUS_SUCCESS != vstatus)
6085 {
6086 ret = -EINVAL;
6087 }
6088 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306089 case WE_SET_ENCRYPT_MSG:
6090 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6091 if (NULL == pkt)
6092 {
6093 hddLog(VOS_TRACE_LEVEL_ERROR,
6094 "%s: vos_mem_alloc failed", __func__);
6095 return -ENOMEM;
6096 }
6097
6098 memset(pkt, 0, sizeof(tSirpkt80211));
6099
6100 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6101 hddLog(VOS_TRACE_LEVEL_ERROR,
6102 FL("Firmware is not DISA capable"));
6103 ret = -EINVAL;
6104 vos_mem_free(pkt);
6105 break;
6106 }
6107
6108 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6109
6110 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6111 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6112 if (eHAL_STATUS_SUCCESS != ret) {
6113 hddLog(VOS_TRACE_LEVEL_ERROR,
6114 FL("SENDEncryptMSG: fail to post WDA cmd"));
6115 ret = -EINVAL;
6116 }
6117 vos_mem_free(pkt);
6118
6119 break;
6120
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 default:
6122 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006123 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 ret = -EINVAL;
6125 break;
6126 }
6127 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006128 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306129
6130 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 return ret;
6132}
6133
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306134static int iw_setchar_getnone(struct net_device *dev,
6135 struct iw_request_info *info,
6136 union iwreq_data *wrqu, char *extra)
6137{
6138 int ret;
6139
6140 vos_ssr_protect(__func__);
6141 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6142 vos_ssr_unprotect(__func__);
6143
6144 return ret;
6145}
6146
Jeff Johnson295189b2012-06-20 16:38:30 -07006147/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306148static int __iw_setnone_getint(struct net_device *dev,
6149 struct iw_request_info *info,
6150 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006151{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306152 hdd_adapter_t *pAdapter;
6153 tHalHandle hHal;
6154 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 int *value = (int *)extra;
6156 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05306157 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006158
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306159 ENTER();
6160
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306161 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6162 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006163 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6165 "%s: Adapter is NULL",__func__);
6166 return -EINVAL;
6167 }
6168 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6169 ret = wlan_hdd_validate_context(pHddCtx);
6170 if (0 != ret)
6171 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306172 return ret;
6173 }
6174 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6175 if (NULL == hHal)
6176 {
6177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6178 "%s: Hal Context is NULL",__func__);
6179 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006180 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006181
6182 switch (value[0])
6183 {
6184 case WE_GET_11D_STATE:
6185 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006186 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306188
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6190
Arif Hussain6d2a3322013-11-17 19:50:10 -08006191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006192
6193 break;
6194 }
6195
6196 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 break;
6199
6200 case WE_PMC_STATE:
6201 {
6202 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 break;
6205 }
6206 case WE_GET_WLAN_DBG:
6207 {
6208 vos_trace_display();
6209 *value = 0;
6210 break;
6211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 case WE_GET_MAX_ASSOC:
6213 {
6214 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6215 {
c_hpothub8245442013-11-20 23:41:09 +05306216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6217 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 ret = -EIO;
6219 }
Girish Gowli385be612014-09-18 11:17:20 +05306220#ifdef WLAN_SOFTAP_VSTA_FEATURE
6221 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6222 {
6223 if (*value > VSTA_NUM_ASSOC_STA)
6224 {
6225 *value = VSTA_NUM_ASSOC_STA;
6226 }
6227 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6228 (*value > (VSTA_NUM_ASSOC_STA -
6229 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6230 {
6231 *value = (VSTA_NUM_ASSOC_STA -
6232 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6233 }
6234 }
6235 else
6236#endif
6237 {
6238 if (*value > NUM_ASSOC_STA)
6239 {
6240 *value = NUM_ASSOC_STA;
6241 }
6242 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6243 (*value > (NUM_ASSOC_STA -
6244 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6245 {
6246 *value = (NUM_ASSOC_STA -
6247 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6248 }
6249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 break;
6251 }
6252
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 case WE_GET_WDI_DBG:
6254 {
6255 wpalTraceDisplay();
6256 *value = 0;
6257 break;
6258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006259
6260 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6261 {
6262 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6263 break;
6264 }
6265 case WE_GET_CONCURRENCY_MODE:
6266 {
6267 *value = hdd_get_concurrency_mode ( );
6268
Arif Hussain6d2a3322013-11-17 19:50:10 -08006269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 break;
6271 }
6272
Peng Xu2446a892014-09-05 17:21:18 +05306273 case WE_GET_SCAN_BAND_PREFERENCE:
6274 {
6275 sme_GetConfigParam(hHal, &smeConfig);
6276 *value = smeConfig.csrConfig.scanBandPreference;
6277
6278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6279 "scanBandPreference = %d\n", *value);
6280 break;
6281 }
6282
Jeff Johnson295189b2012-06-20 16:38:30 -07006283 default:
6284 {
6285 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6286 break;
6287 }
6288 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306289 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 return ret;
6291}
6292
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306293static int iw_setnone_getint(struct net_device *dev,
6294 struct iw_request_info *info,
6295 union iwreq_data *wrqu, char *extra)
6296{
6297 int ret;
6298
6299 vos_ssr_protect(__func__);
6300 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6301 vos_ssr_unprotect(__func__);
6302
6303 return ret;
6304
6305}
Jeff Johnson295189b2012-06-20 16:38:30 -07006306/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306307int __iw_set_three_ints_getnone(struct net_device *dev,
6308 struct iw_request_info *info,
6309 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006310{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306311 hdd_adapter_t *pAdapter;
6312 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 int *value = (int *)extra;
6314 int sub_cmd = value[0];
6315 int ret = 0;
6316
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306317 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306318 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6319 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006320 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6322 "%s: Adapter is NULL",__func__);
6323 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006324 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306325 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6326 ret = wlan_hdd_validate_context(pHddCtx);
6327 if (0 != ret)
6328 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306329 return ret;
6330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 switch(sub_cmd)
6332 {
6333 case WE_SET_WLAN_DBG:
6334 {
6335 vos_trace_setValue( value[1], value[2], value[3]);
6336 break;
6337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 case WE_SET_WDI_DBG:
6339 {
6340 wpalTraceSetLevel( value[1], value[2], value[3]);
6341 break;
6342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 case WE_SET_SAP_CHANNELS:
6344 {
6345 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6346 break;
6347 }
6348
6349 default:
6350 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006351 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 break;
6353 }
6354 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306355 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 return ret;
6357}
6358
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306359int iw_set_three_ints_getnone(struct net_device *dev,
6360 struct iw_request_info *info,
6361 union iwreq_data *wrqu, char *extra)
6362{
6363 int ret;
6364
6365 vos_ssr_protect(__func__);
6366 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6367 vos_ssr_unprotect(__func__);
6368
6369 return ret;
6370}
6371
6372static int __iw_get_char_setnone(struct net_device *dev,
6373 struct iw_request_info *info,
6374 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006375{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306376 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306378 hdd_context_t *pHddCtx;
6379 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006380#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006381 hdd_wext_state_t *pWextState;
6382#endif
6383
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306384 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306385 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006386 if (pAdapter == NULL)
6387 {
6388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6389 "%s: pAdapter is NULL!", __func__);
6390 return -EINVAL;
6391 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306392 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6393 ret = wlan_hdd_validate_context(pHddCtx);
6394 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006395 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306396 return ret;
6397 }
6398#ifdef WLAN_FEATURE_11W
6399 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6400 if (NULL == pWextState)
6401 {
6402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6403 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006404 return -EINVAL;
6405 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306406#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006407
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 switch(sub_cmd)
6409 {
6410 case WE_WLAN_VERSION:
6411 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006412 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 break;
6414 }
6415
6416 case WE_GET_STATS:
6417 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306418 tHalHandle hHal = NULL;
6419 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6421 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6422 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6423
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306424
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 snprintf(extra, WE_MAX_STR_LEN,
6426 "\nTransmit"
6427 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6428 "\n dropped BK %u, BE %u, VI %u, VO %u"
6429 "\n classified BK %u, BE %u, VI %u, VO %u"
6430 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6431 "\n queued BK %u, BE %u, VI %u, VO %u"
6432 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006433 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 "\n fetched BK %u, BE %u, VI %u, VO %u"
6435 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6436 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006437 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006438 "\n flushed BK %u, BE %u, VI %u, VO %u"
6439 "\n\nReceive"
6440 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6441 "\n\nResetsStats"
6442 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6443 "\n",
6444 pStats->txXmitCalled,
6445 pStats->txXmitDropped,
6446 pStats->txXmitBackPressured,
6447 pStats->txXmitQueued,
6448
6449 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6450 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6451 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6452 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6453
6454 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6455 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6456 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6457 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6458
6459 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6460 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6461 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6462 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6463
6464 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6465 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6466 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6467 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6468
6469 pStats->txFetched,
6470 pStats->txFetchEmpty,
6471 pStats->txFetchLowResources,
6472 pStats->txFetchDequeueError,
6473
6474 pStats->txFetchDequeued,
6475 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006476 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 pStats->txCompleted,
6478 pStats->txFlushed,
6479
6480 pStats->txFetchedAC[WLANTL_AC_BK],
6481 pStats->txFetchedAC[WLANTL_AC_BE],
6482 pStats->txFetchedAC[WLANTL_AC_VI],
6483 pStats->txFetchedAC[WLANTL_AC_VO],
6484
6485 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6486 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6487 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6488 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6489
6490 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6491 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6492 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6493 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6494
Ravi Joshi41914632013-10-21 23:02:21 -07006495 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6496 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6497 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6498 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6499
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 pStats->txFlushedAC[WLANTL_AC_BK],
6501 pStats->txFlushedAC[WLANTL_AC_BE],
6502 pStats->txFlushedAC[WLANTL_AC_VI],
6503 pStats->txFlushedAC[WLANTL_AC_VO],
6504
6505 pStats->rxChains,
6506 pStats->rxPackets,
6507 pStats->rxDropped,
6508 pStats->rxDelivered,
6509 pStats->rxRefused,
6510
6511 pResetStats->totalLogpResets,
6512 pResetStats->totalCMD53Failures,
6513 pResetStats->totalMutexReadFailures,
6514 pResetStats->totalMIFErrorFailures,
6515 pResetStats->totalFWHearbeatFailures,
6516 pResetStats->totalUnknownExceptions
6517 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306518 wrqu->data.length = strlen(extra);
6519
6520 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6521
6522 if (hHal)
6523 pMac = PMAC_STRUCT( hHal );
6524
6525 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6526 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6527 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306528 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6529 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6530 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6531 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306532 "\n",
6533 pMac->pmm.BmpscntSleep,
6534 pMac->pmm.BmpscntAwake,
6535 pMac->pmm.BmpsSleeReqFailCnt,
6536 pMac->pmm.BmpsWakeupReqFailCnt,
6537 pMac->pmm.ImpsCntSleep,
6538 pMac->pmm.ImpsCntAwake,
6539 pMac->pmm.ImpsSleepErrCnt,
6540 pMac->pmm.ImpsWakeupErrCnt,
6541 pMac->pmm.ImpsLastErr
6542 );
6543 }
6544
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 wrqu->data.length = strlen(extra)+1;
6546 break;
6547 }
6548
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306549/* The case prints the current state of the HDD, SME, CSR, PE, TL
6550 *it can be extended for WDI Global State as well.
6551 *And currently it only checks P2P_CLIENT adapter.
6552 *P2P_DEVICE and P2P_GO have not been added as of now.
6553*/
6554 case WE_GET_STATES:
6555 {
6556 int buf = 0, len = 0;
6557 int adapter_num = 0;
6558 int count = 0, check = 1;
6559
6560 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006561 tHalHandle hHal = NULL;
6562 tpAniSirGlobal pMac = NULL;
6563 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306564
6565 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6566 hdd_adapter_t *useAdapter = NULL;
6567
6568 /* Print wlan0 or p2p0 states based on the adapter_num
6569 *by using the correct adapter
6570 */
6571 while ( adapter_num < 2 )
6572 {
6573 if ( WLAN_ADAPTER == adapter_num )
6574 {
6575 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006576 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306577 "\n\n wlan0 States:-");
6578 len += buf;
6579 }
6580 else if ( P2P_ADAPTER == adapter_num )
6581 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006582 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306583 "\n\n p2p0 States:-");
6584 len += buf;
6585
6586 if( !pHddCtx )
6587 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006588 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306589 "\n pHddCtx is NULL");
6590 len += buf;
6591 break;
6592 }
6593
6594 /*Printing p2p0 states only in the case when the device is
6595 configured as a p2p_client*/
6596 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6597 if ( !useAdapter )
6598 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006599 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306600 "\n Device not configured as P2P_CLIENT.");
6601 len += buf;
6602 break;
6603 }
6604 }
6605
6606 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006607 if (!hHal) {
6608 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6609 "\n pMac is NULL");
6610 len += buf;
6611 break;
6612 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306613 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006614 if (!pMac) {
6615 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6616 "\n pMac is NULL");
6617 len += buf;
6618 break;
6619 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306620 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6621 if( !pHddStaCtx )
6622 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006623 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306624 "\n pHddStaCtx is NULL");
6625 len += buf;
6626 break;
6627 }
6628
6629 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6630
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006631 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306632 "\n HDD Conn State - %s "
6633 "\n \n SME State:"
6634 "\n Neighbour Roam State - %s"
6635 "\n CSR State - %s"
6636 "\n CSR Substate - %s"
6637 "\n \n TL STA %d State: %s",
6638 macTraceGetHDDWlanConnState(
6639 pHddStaCtx->conn_info.connState),
6640 macTraceGetNeighbourRoamState(
6641 pMac->roam.neighborRoamInfo.neighborRoamState),
6642 macTraceGetcsrRoamState(
6643 pMac->roam.curState[useAdapter->sessionId]),
6644 macTraceGetcsrRoamSubState(
6645 pMac->roam.curSubState[useAdapter->sessionId]),
6646 pHddStaCtx->conn_info.staId[0],
6647 macTraceGetTLState(tlState)
6648 );
6649 len += buf;
6650 adapter_num++;
6651 }
6652
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006653 if (pMac) {
6654 /* Printing Lim State starting with global lim states */
6655 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6656 "\n \n LIM STATES:-"
6657 "\n Global Sme State - %s "\
6658 "\n Global mlm State - %s "\
6659 "\n",
6660 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6661 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6662 );
6663 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306664
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006665 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05306666 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306667 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006668 if ( pMac->lim.gpSession[count].valid )
6669 {
6670 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6671 "\n Lim Valid Session %d:-"
6672 "\n PE Sme State - %s "
6673 "\n PE Mlm State - %s "
6674 "\n",
6675 check,
6676 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6677 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6678 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306679
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006680 len += buf;
6681 check++;
6682 }
6683 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306684 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306685 }
6686
6687 wrqu->data.length = strlen(extra)+1;
6688 break;
6689 }
6690
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 case WE_GET_CFG:
6692 {
6693 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6694 wrqu->data.length = strlen(extra)+1;
6695 break;
6696 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006697#ifdef WLAN_FEATURE_11AC
6698 case WE_GET_RSSI:
6699 {
6700 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05306701 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07006702 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6703 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6704 wrqu->data.length = strlen(extra)+1;
6705 break;
6706 }
6707#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306708
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006709#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006710 case WE_GET_ROAM_RSSI:
6711 {
6712 v_S7_t s7Rssi = 0;
6713 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6714 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6715 wrqu->data.length = strlen(extra)+1;
6716 break;
6717 }
6718#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 case WE_GET_WMM_STATUS:
6720 {
6721 snprintf(extra, WE_MAX_STR_LEN,
6722 "\nDir: 0=up, 1=down, 3=both\n"
6723 "|------------------------|\n"
6724 "|AC | ACM |Admitted| Dir |\n"
6725 "|------------------------|\n"
6726 "|VO | %d | %3s | %d |\n"
6727 "|VI | %d | %3s | %d |\n"
6728 "|BE | %d | %3s | %d |\n"
6729 "|BK | %d | %3s | %d |\n"
6730 "|------------------------|\n",
6731 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6732 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6733 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6734 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6735 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6736 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6737 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6738 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6739 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6740 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6741 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6742 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6743
Jeff Johnsone7245742012-09-05 17:12:55 -07006744
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 wrqu->data.length = strlen(extra)+1;
6746 break;
6747 }
6748 case WE_GET_CHANNEL_LIST:
6749 {
6750 VOS_STATUS status;
6751 v_U8_t i, len;
6752 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306753 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6754 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6755 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 tChannelListInfo channel_list;
6757
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006758 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006760 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006762 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 return -EINVAL;
6764 }
6765 buf = extra;
6766
6767 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006768 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6769 * needed = 5 * number of channels. Check ifsufficient
6770 * buffer is available and then proceed to fill the buffer.
6771 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6773 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006774 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006775 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006776 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 return -EINVAL;
6778 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006779 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6780 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306781 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6782 {
6783 //Printing Country code in getChannelList
6784 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6785 {
6786 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6787 "%c ", pBuf[i]);
6788 }
6789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 for(i = 0 ; i < channel_list.num_channels; i++)
6791 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006792 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 }
6795 wrqu->data.length = strlen(extra)+1;
6796
6797 break;
6798 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006799#ifdef FEATURE_WLAN_TDLS
6800 case WE_GET_TDLS_PEERS:
6801 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006802 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006803 break;
6804 }
6805#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006806#ifdef WLAN_FEATURE_11W
6807 case WE_GET_11W_INFO:
6808 {
6809 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6810
6811 snprintf(extra, WE_MAX_STR_LEN,
6812 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6813 "\n Number of Unprotected Disassocs %d"
6814 "\n Number of Unprotected Deauths %d",
6815 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6816 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6817 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6818 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6819 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6820
6821 wrqu->data.length = strlen(extra)+1;
6822 break;
6823 }
6824#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306825 case WE_GET_SNR:
6826 {
6827 v_S7_t s7snr = 0;
6828 int status = 0;
6829 hdd_context_t *pHddCtx;
6830 hdd_station_ctx_t *pHddStaCtx;
6831
6832 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6833 status = wlan_hdd_validate_context(pHddCtx);
6834 if (0 != status)
6835 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306836 return status;
6837 }
6838
6839 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6840
6841 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6842 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6843 {
6844 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6845 " ConnectionState-%d", __func__,
6846 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6847 pHddStaCtx->conn_info.connState);
6848 return -ENONET;
6849 }
6850
6851 /*update the stats in TL*/
6852 wlan_hdd_get_station_stats(pAdapter);
6853 wlan_hdd_get_snr(pAdapter, &s7snr);
6854 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6855 wrqu->data.length = strlen(extra) + 1;
6856 break;
6857 }
6858
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306859 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006861 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 break;
6863 }
6864 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306865 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 return 0;
6867}
6868
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306869static int iw_get_char_setnone(struct net_device *dev,
6870 struct iw_request_info *info,
6871 union iwreq_data *wrqu, char *extra)
6872{
6873 int ret;
6874
6875 vos_ssr_protect(__func__);
6876 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6877 vos_ssr_unprotect(__func__);
6878
6879 return ret;
6880}
6881
Jeff Johnson295189b2012-06-20 16:38:30 -07006882/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306883static int __iw_setnone_getnone(struct net_device *dev,
6884 struct iw_request_info *info,
6885 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006886{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306887 hdd_adapter_t *pAdapter;
6888 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306889 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006890 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306891 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006892
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306893 ENTER();
6894
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306895 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6896 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006897 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6899 "%s: Adapter is NULL",__func__);
6900 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006901 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306902 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6903 ret = wlan_hdd_validate_context(pHddCtx);
6904 if (0 != ret)
6905 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306906 return ret;
6907 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306908 /* helper function to get iwreq_data with compat handling. */
6909 if (hdd_priv_get_data(&s_priv_data, wrqu))
6910 {
6911 return -EINVAL;
6912 }
6913
6914 sub_cmd = s_priv_data.flags;
6915
Jeff Johnson295189b2012-06-20 16:38:30 -07006916 switch (sub_cmd)
6917 {
6918 case WE_CLEAR_STATS:
6919 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6922 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6923 break;
6924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 case WE_INIT_AP:
6926 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306927 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6928
6929 /* As Soft AP mode might been changed to STA already with
6930 * killing of Hostapd, need to find the adpater by name
6931 * rather than mode */
6932 hdd_adapter_t* pAdapter_to_stop =
6933 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6934 if( pAdapter_to_stop )
6935 {
6936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6937 "Adapter with name softap.0 already "
6938 "exist, ignoring the request.\nRemove the "
6939 "adapter and try again\n");
6940 break;
6941 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 pr_info("Init AP trigger\n");
6943 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6944 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6945 break;
6946 }
6947 case WE_STOP_AP:
6948 {
6949 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6950 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6951 * this is a dead code and need to find the adpater by name rather than mode */
6952 hdd_adapter_t* pAdapter_to_stop =
6953 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6954 if( pAdapter_to_stop )
6955 {
6956 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6957
6958 pr_info("Stopping AP mode\n");
6959
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306960 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6961 {
6962 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6963 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6964 }
6965
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306967 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306968 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6970
6971 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6972 pAdapter_to_stop->macAddressCurrent.bytes);
6973 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6974 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306975
6976 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6977 {
6978 /* put the device back into BMPS */
6979 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 }
6982 else
6983 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006984 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006985 }
6986
6987 break;
6988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006989#ifdef WLAN_BTAMP_FEATURE
6990 case WE_ENABLE_AMP:
6991 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 WLANBAP_RegisterWithHCI(pAdapter);
6994 break;
6995 }
6996 case WE_DISABLE_AMP:
6997 {
6998 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6999 VOS_STATUS status;
7000
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007002
7003 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7004 status = WLANBAP_StopAmp();
7005 if(VOS_STATUS_SUCCESS != status )
7006 {
7007 pHddCtx->isAmpAllowed = VOS_TRUE;
7008 hddLog(VOS_TRACE_LEVEL_FATAL,
7009 "%s: Failed to stop AMP", __func__);
7010 }
7011 else
7012 {
7013 //a state m/c implementation in PAL is TBD to avoid this delay
7014 msleep(500);
7015 pHddCtx->isAmpAllowed = VOS_FALSE;
7016 WLANBAP_DeregisterFromHCI();
7017 }
7018
7019 break;
7020 }
7021#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007022 case WE_ENABLE_DXE_STALL_DETECT:
7023 {
schang6295e542013-03-12 15:31:23 -07007024 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7025 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007026 break;
7027 }
7028 case WE_DISPLAY_DXE_SNAP_SHOT:
7029 {
schang6295e542013-03-12 15:31:23 -07007030 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7031 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007032 break;
7033 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307034 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7035 {
7036 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7037 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307038 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307039 break;
7040 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307041
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307042 case WE_SET_REASSOC_TRIGGER:
7043 {
7044 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7045 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7046 v_U32_t roamId = 0;
7047 tCsrRoamModifyProfileFields modProfileFields;
7048 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7049 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
7050 return 0;
7051 }
7052
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307053 case WE_STOP_OBSS_SCAN:
7054 {
7055 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7056 2.OBSS scan is stopped by Firmware during the disassociation
7057 3.OBSS stop comamnd is added for debugging purpose*/
7058 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7059 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007060
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307061 if (pAdapter == NULL)
7062 {
7063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7064 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307065 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307066 }
7067 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7068 if (pMac == NULL)
7069 {
7070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7071 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307072 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307073 }
7074 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7075 }
7076 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307077 case WE_DUMP_ROAM_TIMER_LOG:
7078 {
7079 vos_dump_roam_time_log_service();
7080 break;
7081 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307082
Mukul Sharma84f27252014-07-14 18:11:42 +05307083 case WE_RESET_ROAM_TIMER_LOG:
7084 {
7085 vos_reset_roam_timer_log();
7086 break;
7087 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307088 case WE_GET_FW_LOGS:
7089 {
7090 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7091 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307092 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307093 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307094 break;
7095 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307096 case WE_GET_FW_MEMDUMP:
7097 {
7098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7099 "FW_MEM_DUMP requested ");
7100 get_fwr_memdump(dev,info,wrqu,extra);
7101 break;
7102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 default:
7104 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007105 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007106 break;
7107 }
7108 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307109 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 return ret;
7111}
7112
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307113static int iw_setnone_getnone(struct net_device *dev,
7114 struct iw_request_info *info,
7115 union iwreq_data *wrqu, char *extra)
7116{
7117 int ret;
7118
7119 vos_ssr_protect(__func__);
7120 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7121 vos_ssr_unprotect(__func__);
7122
7123 return ret;
7124}
7125
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307126void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7127{
7128 /*
7129 * Function to display HDD WMM information
7130 * for Tx Queues.
7131 * Prints globala as well as per client depending
7132 * whether the clients are registered or not.
7133 */
7134 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307135 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7136 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307137 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7138 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307139 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307140
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307141 for ( i=0; i< NUM_TX_QUEUES; i++)
7142 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307143 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307144 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307145 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307146 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307147
7148 for ( i=0; i< NUM_TX_QUEUES; i++) {
7149 if (tx_queue_count[i]) {
7150 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7151 i, tx_queue_count[i]);
7152 }
7153 }
7154
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307155 if(pSapCtx == NULL){
7156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7157 FL("psapCtx is NULL"));
7158 return;
7159 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307160
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307161 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307162 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7163 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307164 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307165 {
7166 hddLog(LOGE, "******STAIndex: %d*********", i);
7167 for ( j=0; j< NUM_TX_QUEUES; j++)
7168 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307169 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7170 {
7171 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307172 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7173 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307174 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7175 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307176 }
7177 }
7178 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307179 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307180
Katya Nigam1fd24402015-02-16 14:52:19 +05307181 if(pHddStaCtx == NULL){
7182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7183 FL("pHddStaCtx is NULL"));
7184 return;
7185 }
7186
7187 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7188 if(pPeerInfo == NULL){
7189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7190 FL("ppeerinfo is NULL"));
7191 return;
7192 }
7193
7194 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7195 {
7196 if(pPeerInfo->ibssStaInfo[i].isUsed)
7197 {
7198 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7199 for ( j=0; j< NUM_TX_QUEUES; j++)
7200 {
7201 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7202 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7203 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7204 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7205 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7206 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7207 }
7208 }
7209 }
7210
7211
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307212}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307213static int __iw_set_var_ints_getnone(struct net_device *dev,
7214 struct iw_request_info *info,
7215 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007216{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307217 hdd_adapter_t *pAdapter;
7218 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307219 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307220 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007221 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307222 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307223 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007224 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307225 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007226 int cmd = 0;
7227 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307228 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007229
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307230 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307231 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307232 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7234 "%s: NULL extra buffer pointer", __func__);
7235 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307236 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307237 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7238 if (NULL == pAdapter)
7239 {
7240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7241 "%s: Adapter is NULL",__func__);
7242 return -EINVAL;
7243 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307244 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307245 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7246 ret = wlan_hdd_validate_context(pHddCtx);
7247 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007248 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307249 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007250 }
Katya Nigameae74b62015-05-28 17:19:16 +05307251 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307252 {
Katya Nigameae74b62015-05-28 17:19:16 +05307253 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7254 if (NULL == hHal)
7255 {
7256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7257 "%s: Hal Context is NULL",__func__);
7258 return -EINVAL;
7259 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307260 }
7261 sub_cmd = wrqu->data.flags;
7262
7263 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7264
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007265
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007266 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7267 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7268 {
7269 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7270 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7271 {
7272 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7273 staId = pStaCtx->conn_info.staId[0];
7274 }
7275 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7276 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7277 {
7278 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7279 staId = pAPCtx->uBCStaId;
7280 }
7281 else
7282 {
7283 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7284 return 0;
7285 }
7286 }
7287
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 switch (sub_cmd)
7289 {
7290 case WE_LOG_DUMP_CMD:
7291 {
7292 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007293 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007294 apps_args[3], apps_args[4]);
7295
7296 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7297 apps_args[3], apps_args[4]);
7298
7299 }
7300 break;
7301
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 case WE_P2P_NOA_CMD:
7303 {
7304 p2p_app_setP2pPs_t p2pNoA;
7305
7306 p2pNoA.opp_ps = apps_args[0];
7307 p2pNoA.ctWindow = apps_args[1];
7308 p2pNoA.duration = apps_args[2];
7309 p2pNoA.interval = apps_args[3];
7310 p2pNoA.count = apps_args[4];
7311 p2pNoA.single_noa_duration = apps_args[5];
7312 p2pNoA.psSelection = apps_args[6];
7313
7314 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7315 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007316 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007317 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7318
7319 hdd_setP2pPs(dev, &p2pNoA);
7320
7321 }
7322 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007323
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307324 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7325 {
7326 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7327 __func__, apps_args[0], apps_args[1]);
7328 vosTraceEnable(apps_args[0], apps_args[1]);
7329 }
7330 break;
7331
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007332 case WE_MTRACE_DUMP_CMD:
7333 {
7334 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7335 "bitmask_of_module %d ",
7336 __func__, apps_args[0], apps_args[1], apps_args[2],
7337 apps_args[3]);
7338 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7339 apps_args[2], apps_args[3]);
7340
7341 }
7342 break;
7343
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007344 case WE_MCC_CONFIG_CREDENTIAL :
7345 {
7346 cmd = 287; //Command should be updated if there is any change
7347 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007348 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007349 {
7350 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7351 }
7352 else
7353 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007354 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007355 return 0;
7356 }
7357 }
7358 break;
7359
7360 case WE_MCC_CONFIG_PARAMS :
7361 {
7362 cmd = 288; //command Should be updated if there is any change
7363 // in the Riva dump command
7364 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7365 }
7366 break;
7367
Chilam NG571c65a2013-01-19 12:27:36 +05307368#ifdef FEATURE_WLAN_TDLS
7369 case WE_TDLS_CONFIG_PARAMS :
7370 {
7371 tdls_config_params_t tdlsParams;
7372
Chilam Ng01120412013-02-19 18:32:21 -08007373 tdlsParams.tdls = apps_args[0];
7374 tdlsParams.tx_period_t = apps_args[1];
7375 tdlsParams.tx_packet_n = apps_args[2];
7376 tdlsParams.discovery_period_t = apps_args[3];
7377 tdlsParams.discovery_tries_n = apps_args[4];
7378 tdlsParams.idle_timeout_t = apps_args[5];
7379 tdlsParams.idle_packet_n = apps_args[6];
7380 tdlsParams.rssi_hysteresis = apps_args[7];
7381 tdlsParams.rssi_trigger_threshold = apps_args[8];
7382 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307383
Chilam Ng01120412013-02-19 18:32:21 -08007384 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307385 }
7386 break;
7387#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307388 case WE_CONFIGURE_MONITOR_MODE:
7389 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307390 v_U32_t magic = 0;
7391 struct completion cmpVar;
7392 long waitRet = 0;
7393
Katya Nigamf0511f62015-05-05 16:40:57 +05307394 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7395 if( pMonCtx == NULL )
7396 {
7397 hddLog(LOGE, "Monitor Context NULL");
7398 break;
7399 }
7400 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7401 __func__, apps_args[0], apps_args[1], apps_args[2],
7402 apps_args[3], apps_args[4]);
7403 /* Input Validation part of FW */
7404 pMonCtx->ChannelNo = apps_args[0];
7405 pMonCtx->ChannelBW = apps_args[1];
7406 pMonCtx->crcCheckEnabled = apps_args[2];
7407 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7408 pMonCtx->is80211to803ConReq = apps_args[4];
7409 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7410 if( pMonCtx->is80211to803ConReq )
7411 pAdapter->dev->type = ARPHRD_ETHER;
7412 else
7413 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7414 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7415 {
7416 hddLog(LOGE, "%s: Filtering data packets as management and control"
7417 " cannot be converted to 802.3 ",__func__);
7418 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7419 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307420 if (MON_MODE_START == pMonCtx->state) {
7421 magic = MON_MODE_MSG_MAGIC;
7422 init_completion(&cmpVar);
7423 if (VOS_STATUS_SUCCESS !=
7424 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7425 pMonCtx, hdd_monPostMsgCb)) {
7426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7427 FL("failed to post MON MODE REQ"));
7428 magic = 0;
7429 ret = -EIO;
7430 break;
7431 }
7432 waitRet = wait_for_completion_timeout(&cmpVar,
7433 MON_MODE_MSG_TIMEOUT);
7434 magic = 0;
7435 if (waitRet <= 0 ) {
7436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7437 FL("failed to wait on monitor mode completion %ld"),
7438 waitRet);
7439 }
7440 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307441 }
7442 break;
7443
7444 case WE_SET_MONITOR_MODE_FILTER:
7445 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307446 v_U32_t magic = 0;
7447 struct completion cmpVar;
7448 long waitRet = 0;
7449
Katya Nigamf0511f62015-05-05 16:40:57 +05307450 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7451 if( pMonCtx == NULL )
7452 {
7453 hddLog(LOGE, "Monitor Context NULL");
7454 break;
7455 }
7456 /* Input Validation Part of FW */
7457 pMonCtx->numOfMacFilters=1;
7458 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7459 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7460 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7461 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7462 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7463 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7464 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7465 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7466 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7467 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7468 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7469 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307470 if (MON_MODE_START == pMonCtx->state) {
7471 magic = MON_MODE_MSG_MAGIC;
7472 init_completion(&cmpVar);
7473 if (VOS_STATUS_SUCCESS !=
7474 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7475 pMonCtx, hdd_monPostMsgCb)) {
7476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7477 FL("failed to post MON MODE REQ"));
7478 magic = 0;
7479 ret = -EIO;
7480 break;
7481 }
7482 waitRet = wait_for_completion_timeout(&cmpVar,
7483 MON_MODE_MSG_TIMEOUT);
7484 magic = 0;
7485 if (waitRet <= 0 ) {
7486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7487 FL("failed to wait on monitor mode completion %ld"),
7488 waitRet);
7489 }
7490 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307491 }
7492 break;
7493
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 default:
7495 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007496 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7497 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 }
7499 break;
7500 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307501 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007502 return 0;
7503}
7504
Girish Gowlifb9758e2014-11-19 15:19:17 +05307505static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7506 struct iw_request_info *info,
7507 union iwreq_data *wrqu, char *extra)
7508{
7509 int ret;
7510 union iwreq_data u_priv_wrqu;
7511 int apps_args[MAX_VAR_ARGS] = {0};
7512 int num_args;
7513
7514 /* helper function to get iwreq_data with compat handling. */
7515 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7516 {
7517 return -EINVAL;
7518 }
7519
7520 if (NULL == u_priv_wrqu.data.pointer)
7521 {
7522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7523 "%s: NULL data pointer", __func__);
7524 return -EINVAL;
7525 }
7526
7527 num_args = u_priv_wrqu.data.length;
7528 if (num_args > MAX_VAR_ARGS)
7529 {
7530 num_args = MAX_VAR_ARGS;
7531 }
7532
7533 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7534 (sizeof(int)) * num_args))
7535 {
7536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7537 "%s: failed to copy data from user buffer", __func__);
7538 return -EFAULT;
7539 }
7540
7541 vos_ssr_protect(__func__);
7542 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7543 (char *)&apps_args);
7544 vos_ssr_unprotect(__func__);
7545
7546 return ret;
7547}
7548
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307549int iw_set_var_ints_getnone(struct net_device *dev,
7550 struct iw_request_info *info,
7551 union iwreq_data *wrqu, char *extra)
7552{
7553 int ret;
7554 vos_ssr_protect(__func__);
7555 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7556 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007557
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307558 return ret;
7559}
7560
7561static int __iw_add_tspec(struct net_device *dev,
7562 struct iw_request_info *info,
7563 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007564{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307565 hdd_adapter_t *pAdapter;
7566 hdd_station_ctx_t *pHddStaCtx;
7567 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007568 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7569 int params[HDD_WLAN_WMM_PARAM_COUNT];
7570 sme_QosWmmTspecInfo tSpec;
7571 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307572 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307573 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007574
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307575 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307576 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7577 if (NULL == pAdapter)
7578 {
7579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7580 "%s: Adapter is NULL",__func__);
7581 return -EINVAL;
7582 }
7583 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7584 ret = wlan_hdd_validate_context(pHddCtx);
7585 if (0 != ret)
7586 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307587 return ret;
7588 }
7589 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7590 if (NULL == pHddStaCtx)
7591 {
7592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7593 "%s: STA Context is NULL",__func__);
7594 return -EINVAL;
7595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 // make sure the application is sufficiently priviledged
7597 // note that the kernel will do this for "set" ioctls, but since
7598 // this ioctl wants to return status to user space it must be
7599 // defined as a "get" ioctl
7600 if (!capable(CAP_NET_ADMIN))
7601 {
7602 return -EPERM;
7603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007604 // we must be associated in order to add a tspec
7605 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7606 {
7607 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7608 return 0;
7609 }
7610
7611 // since we are defined to be a "get" ioctl, and since the number
7612 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307613 // will pass down in the iwreq_data, we must copy the "set" params.
7614 // We must handle the compat for iwreq_data in 32U/64K environment.
7615
7616 // helper fucntion to get iwreq_data with compat handling.
7617 if (hdd_priv_get_data(&s_priv_data, wrqu))
7618 {
7619 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7620 return 0;
7621 }
7622
7623 // make sure all params are correctly passed to function
7624 if ((NULL == s_priv_data.pointer) ||
7625 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7626 {
7627 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7628 return 0;
7629 }
7630
Jeff Johnson295189b2012-06-20 16:38:30 -07007631 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307632 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 {
7634 // hmmm, can't get them
7635 return -EIO;
7636 }
7637
7638 // clear the tspec
7639 memset(&tSpec, 0, sizeof(tSpec));
7640
7641 // validate the handle
7642 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7643 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7644 {
7645 // that one is reserved
7646 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7647 return 0;
7648 }
7649
7650 // validate the TID
7651 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7652 {
7653 // out of range
7654 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7655 return 0;
7656 }
7657 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7658
7659 // validate the direction
7660 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7661 {
7662 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7663 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7664 break;
7665
7666 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7667 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7668 break;
7669
7670 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7671 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7672 break;
7673
7674 default:
7675 // unknown
7676 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7677 return 0;
7678 }
7679
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307680 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7681
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 // validate the user priority
7683 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7684 {
7685 // out of range
7686 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7687 return 0;
7688 }
7689 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307690 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7691 {
7692 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7693 return 0;
7694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007695
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7697 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7698 tSpec.ts_info.psb, tSpec.ts_info.up);
7699
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7701 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7702 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7703 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7704 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7705 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7706 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7707 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7708 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7709 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7710 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7711 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7712
7713 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7714
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307715 // Save the expected UAPSD settings by application, this will be needed
7716 // when re-negotiating UAPSD settings during BT Coex cases.
7717 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7718
Jeff Johnson295189b2012-06-20 16:38:30 -07007719 // validate the ts info ack policy
7720 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7721 {
7722 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7723 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7724 break;
7725
7726 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7727 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7728 break;
7729
7730 default:
7731 // unknown
7732 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7733 return 0;
7734 }
7735
7736 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307737
7738 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007739 return 0;
7740}
7741
7742
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307743static int iw_add_tspec(struct net_device *dev,
7744 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 union iwreq_data *wrqu, char *extra)
7746{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307747 int ret;
7748
7749 vos_ssr_protect(__func__);
7750 ret = __iw_add_tspec(dev, info, wrqu, extra);
7751 vos_ssr_unprotect(__func__);
7752
7753 return ret;
7754}
7755
7756static int __iw_del_tspec(struct net_device *dev,
7757 struct iw_request_info *info,
7758 union iwreq_data *wrqu, char *extra)
7759{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307760 hdd_adapter_t *pAdapter;
7761 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007762 int *params = (int *)extra;
7763 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7764 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307765 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007766
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307767 ENTER();
7768
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307769 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7770 if (NULL == pAdapter)
7771 {
7772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7773 "%s: Adapter is NULL",__func__);
7774 return -EINVAL;
7775 }
7776
7777 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7778 ret = wlan_hdd_validate_context(pHddCtx);
7779 if (0 != ret)
7780 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307781 return ret;
7782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 // make sure the application is sufficiently priviledged
7784 // note that the kernel will do this for "set" ioctls, but since
7785 // this ioctl wants to return status to user space it must be
7786 // defined as a "get" ioctl
7787 if (!capable(CAP_NET_ADMIN))
7788 {
7789 return -EPERM;
7790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007791 // although we are defined to be a "get" ioctl, the params we require
7792 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7793 // is no need to copy the params from user space
7794
7795 // validate the handle
7796 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7797 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7798 {
7799 // that one is reserved
7800 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7801 return 0;
7802 }
7803
7804 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307805
7806 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007807 return 0;
7808}
7809
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307810static int iw_del_tspec(struct net_device *dev,
7811 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007812 union iwreq_data *wrqu, char *extra)
7813{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307814 int ret;
7815
7816 vos_ssr_protect(__func__);
7817 ret = __iw_del_tspec(dev, info, wrqu, extra);
7818 vos_ssr_unprotect(__func__);
7819
7820 return ret;
7821}
7822
7823
7824static int __iw_get_tspec(struct net_device *dev,
7825 struct iw_request_info *info,
7826 union iwreq_data *wrqu, char *extra)
7827{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307828 hdd_adapter_t *pAdapter;
7829 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 int *params = (int *)extra;
7831 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7832 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307833 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007834
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307835 ENTER();
7836
Jeff Johnson295189b2012-06-20 16:38:30 -07007837 // although we are defined to be a "get" ioctl, the params we require
7838 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7839 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307840 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7841 if (NULL == pAdapter)
7842 {
7843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7844 "%s: Adapter is NULL",__func__);
7845 return -EINVAL;
7846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007847
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307848 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7849 ret = wlan_hdd_validate_context(pHddCtx);
7850 if (0 != ret)
7851 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307852 return ret;
7853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 // validate the handle
7855 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7856 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7857 {
7858 // that one is reserved
7859 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7860 return 0;
7861 }
7862
7863 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307864 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007865 return 0;
7866}
7867
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307868static int iw_get_tspec(struct net_device *dev,
7869 struct iw_request_info *info,
7870 union iwreq_data *wrqu, char *extra)
7871{
7872 int ret;
7873
7874 vos_ssr_protect(__func__);
7875 ret = __iw_get_tspec(dev, info, wrqu, extra);
7876 vos_ssr_unprotect(__func__);
7877
7878 return ret;
7879}
7880
Jeff Johnson295189b2012-06-20 16:38:30 -07007881#ifdef WLAN_FEATURE_VOWIFI_11R
7882//
7883//
7884// Each time the supplicant has the auth_request or reassoc request
7885// IEs ready. This is pushed to the driver. The driver will inturn use
7886// it to send out the auth req and reassoc req for 11r FT Assoc.
7887//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307888static int __iw_set_fties(struct net_device *dev,
7889 struct iw_request_info *info,
7890 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007891{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307892 hdd_adapter_t *pAdapter;
7893 hdd_station_ctx_t *pHddStaCtx;
7894 hdd_context_t *pHddCtx;
7895 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 //v_CONTEXT_t pVosContext;
7897
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307898 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307899 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7900 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007901 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7903 "%s: Adapter is NULL",__func__);
7904 return -EINVAL;
7905 }
7906 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7907 ret = wlan_hdd_validate_context(pHddCtx);
7908 if (0 != ret)
7909 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307910 return ret;
7911 }
7912 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7913 if (NULL == pHddStaCtx)
7914 {
7915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7916 "%s: STA Context is NULL",__func__);
7917 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007919 if (!wrqu->data.length)
7920 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007921 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 return -EINVAL;
7923 }
7924 if (wrqu->data.pointer == NULL)
7925 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007926 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007927 return -EINVAL;
7928 }
7929
7930 // Added for debug on reception of Re-assoc Req.
7931 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7932 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007933 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007934 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007935 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007936 }
7937
7938#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007939 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007940#endif
7941
7942 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007943 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007944 wrqu->data.length);
7945
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307946 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 return 0;
7948}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307949
7950static int iw_set_fties(struct net_device *dev,
7951 struct iw_request_info *info,
7952 union iwreq_data *wrqu, char *extra)
7953{
7954 int ret;
7955
7956 vos_ssr_protect(__func__);
7957 ret = __iw_set_fties(dev, info, wrqu, extra);
7958 vos_ssr_unprotect(__func__);
7959
7960 return ret;
7961}
Jeff Johnson295189b2012-06-20 16:38:30 -07007962#endif
7963
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307964static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007965 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007966 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007967{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307968 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007969 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307970 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007971 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307972 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007973 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7974 int idx;
7975 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007976
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307977 ENTER();
7978
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307979 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7980 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007981 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7983 "%s: Adapter is NULL",__func__);
7984 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007985 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307986 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7987 ret_val = wlan_hdd_validate_context(pHddCtx);
7988 if (0 != ret_val)
7989 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307990 return ret_val;
7991 }
7992 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7993 if (NULL == hHal)
7994 {
7995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7996 "%s: Hal Context is NULL",__func__);
7997 return -EINVAL;
7998 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307999 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8000 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308001#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008002
Amar Singhalf3a6e762013-02-19 15:06:50 -08008003 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8004 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008005 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008006 hddLog(VOS_TRACE_LEVEL_ERROR,
8007 "%s: vos_mem_alloc failed", __func__);
8008 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008009 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008010
8011 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8012
8013 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8014 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8015
8016 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8017 mc_addr_list_ptr->ulMulticastAddrCnt);
8018
8019 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008020 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008021 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8022 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8023
8024 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8025 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008026 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008027
Amar Singhalf3a6e762013-02-19 15:06:50 -08008028 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8029 vos_mem_free(mc_addr_list_ptr);
8030 if (eHAL_STATUS_SUCCESS != ret_val)
8031 {
8032 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8033 __func__);
8034 return -EINVAL;
8035 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308036#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308037 }
8038 else
8039 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008040
Amar Singhalf3a6e762013-02-19 15:06:50 -08008041 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8042 "%s: Set MC BC Filter Config request: %d suspend %d",
8043 __func__, pRequest->mcastBcastFilterSetting,
8044 pHddCtx->hdd_wlan_suspended);
8045
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308046 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008047
8048 if (pHddCtx->hdd_wlan_suspended)
8049 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008050 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8051 if (NULL == wlanRxpFilterParam)
8052 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308053 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008054 "%s: vos_mem_alloc failed", __func__);
8055 return -EINVAL;
8056 }
8057
Amar Singhalf3a6e762013-02-19 15:06:50 -08008058 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8059 pRequest->mcastBcastFilterSetting;
8060 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8061
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308062 hdd_conf_hostoffload(pAdapter, TRUE);
8063 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8064 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008065
8066 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8067 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308068 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008069 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8070 wlanRxpFilterParam->setMcstBcstFilter);
8071
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308072 if (eHAL_STATUS_SUCCESS !=
8073 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8074 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008075 {
8076 hddLog(VOS_TRACE_LEVEL_ERROR,
8077 "%s: Failure to execute set HW MC/BC Filter request",
8078 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008079 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008080 return -EINVAL;
8081 }
8082
c_hpothud3ce76d2014-10-28 10:34:13 +05308083 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8084 {
8085 pHddCtx->sus_res_mcastbcast_filter =
8086 pRequest->mcastBcastFilterSetting;
8087 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008088 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008090
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308091 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008092 return 0;
8093}
8094
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308095static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8096 struct iw_request_info *info,
8097 union iwreq_data *wrqu, char *extra)
8098{
8099 int ret;
8100
8101 vos_ssr_protect(__func__);
8102 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8103 vos_ssr_unprotect(__func__);
8104
8105 return ret;
8106}
8107
8108static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8109 struct iw_request_info *info,
8110 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008111{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308112 hdd_adapter_t *pAdapter;
8113 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308114 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308115 int ret = 0;
8116
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308117 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008118
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308119 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8120 if (NULL == pAdapter)
8121 {
8122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8123 "%s: Adapter is NULL",__func__);
8124 return -EINVAL;
8125 }
8126
8127 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8128 ret = wlan_hdd_validate_context(pHddCtx);
8129 if (0 != ret)
8130 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308131 return ret;
8132 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308133 //Reset the filter to INI value as we have to clear the dynamic filter
8134 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008135
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308136 //Configure FW with new setting
8137 if (pHddCtx->hdd_wlan_suspended)
8138 {
8139 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8140 if (NULL == wlanRxpFilterParam)
8141 {
8142 hddLog(VOS_TRACE_LEVEL_ERROR,
8143 "%s: vos_mem_alloc failed", __func__);
8144 return -EINVAL;
8145 }
8146
8147 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8148 pHddCtx->configuredMcastBcastFilter;
8149 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8150
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308151 hdd_conf_hostoffload(pAdapter, TRUE);
8152 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8153 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308154
8155 if (eHAL_STATUS_SUCCESS !=
8156 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8157 wlanRxpFilterParam))
8158 {
8159 hddLog(VOS_TRACE_LEVEL_ERROR,
8160 "%s: Failure to execute set HW MC/BC Filter request",
8161 __func__);
8162 vos_mem_free(wlanRxpFilterParam);
8163 return -EINVAL;
8164 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308165
8166 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8167 {
8168 pHddCtx->sus_res_mcastbcast_filter =
8169 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8170 }
8171
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308172 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308173 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008174 return 0;
8175}
8176
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308177
8178static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8179 struct iw_request_info *info,
8180 union iwreq_data *wrqu, char *extra)
8181{
8182 int ret;
8183
8184 vos_ssr_protect(__func__);
8185 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8186 vos_ssr_unprotect(__func__);
8187
8188 return ret;
8189}
8190
8191static int __iw_set_host_offload(struct net_device *dev,
8192 struct iw_request_info *info,
8193 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008194{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308195 hdd_adapter_t *pAdapter;
8196 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008197 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308199 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008200
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308201 ENTER();
8202
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308203 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8204 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008205 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8207 "%s: Adapter is NULL",__func__);
8208 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008209 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308210 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8211 ret = wlan_hdd_validate_context(pHddCtx);
8212 if (0 != ret)
8213 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308214 return ret;
8215 }
8216
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 /* Debug display of request components. */
8218 switch (pRequest->offloadType)
8219 {
8220 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008221 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008222 switch (pRequest->enableOrDisable)
8223 {
8224 case WLAN_OFFLOAD_DISABLE:
8225 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8226 break;
8227 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8228 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8229 case WLAN_OFFLOAD_ENABLE:
8230 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8231 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8232 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8233 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8234 }
8235 break;
8236
8237 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008238 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008239 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 switch (pRequest->enableOrDisable)
8241 {
8242 case WLAN_OFFLOAD_DISABLE:
8243 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8244 break;
8245 case WLAN_OFFLOAD_ENABLE:
8246 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8247 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8248 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8249 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8250 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8251 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8252 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8253 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8254 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8255 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8256 }
8257 }
8258
8259 /* Execute offload request. The reason that we can copy the request information
8260 from the ioctl structure to the SME structure is that they are laid out
8261 exactly the same. Otherwise, each piece of information would have to be
8262 copied individually. */
8263 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008264 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8265 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008266 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008267 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 __func__);
8269 return -EINVAL;
8270 }
8271
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308272 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 return 0;
8274}
8275
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308276static int iw_set_host_offload(struct net_device *dev,
8277 struct iw_request_info *info,
8278 union iwreq_data *wrqu, char *extra)
8279{
8280 int ret;
8281
8282 vos_ssr_protect(__func__);
8283 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8284 vos_ssr_unprotect(__func__);
8285
8286 return ret;
8287}
8288
8289static int __iw_set_keepalive_params(struct net_device *dev,
8290 struct iw_request_info *info,
8291 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008292{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308293 hdd_adapter_t *pAdapter;
8294 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008295 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308297 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008298
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308299 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308300 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8301 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8304 "%s: Adapter is NULL",__func__);
8305 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308307 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8308 ret = wlan_hdd_validate_context(pHddCtx);
8309 if (0 != ret)
8310 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308311 return ret;
8312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008314 hddLog(VOS_TRACE_LEVEL_INFO,
8315 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8316 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008317
8318 switch (pRequest->packetType)
8319 {
8320 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008321 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008322 break;
8323
8324 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8325
Arif Hussain6d2a3322013-11-17 19:50:10 -08008326 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008327 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008328
8329 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8330 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8331 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8332
8333 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8334 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8335 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8336
8337 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8338 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8339 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8340 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8341 break;
8342
8343 }
8344
8345 /* Execute keep alive request. The reason that we can copy the request information
8346 from the ioctl structure to the SME structure is that they are laid out
8347 exactly the same. Otherwise, each piece of information would have to be
8348 copied individually. */
8349 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8350
Arif Hussain6d2a3322013-11-17 19:50:10 -08008351 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008352
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008353 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008354 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008356 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 __func__);
8358 return -EINVAL;
8359 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308360 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 return 0;
8362}
8363
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308364static int iw_set_keepalive_params(struct net_device *dev,
8365 struct iw_request_info *info,
8366 union iwreq_data *wrqu, char *extra)
8367{
8368 int ret;
8369 vos_ssr_protect(__func__);
8370 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8371 vos_ssr_unprotect(__func__);
8372
8373 return ret;
8374}
8375
Jeff Johnson295189b2012-06-20 16:38:30 -07008376#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008377int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008378 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008379{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008380 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8381 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 int i=0;
8383
8384 if (pHddCtx->cfg_ini->disablePacketFilter)
8385 {
8386 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008387 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008388 return 0;
8389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 /* Debug display of request components. */
8391 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008392 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008393
8394 switch (pRequest->filterAction)
8395 {
8396 case HDD_RCV_FILTER_SET:
8397 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008398 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008399
8400 packetFilterSetReq.filterId = pRequest->filterId;
8401 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8402 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008403 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 __func__, pRequest->numParams);
8405 return -EINVAL;
8406 }
8407 packetFilterSetReq.numFieldParams = pRequest->numParams;
8408 packetFilterSetReq.coalesceTime = 0;
8409 packetFilterSetReq.filterType = 1;
8410 for (i=0; i < pRequest->numParams; i++)
8411 {
8412 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8413 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8414 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8415 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8416 packetFilterSetReq.paramsData[i].reserved = 0;
8417
Arif Hussain6d2a3322013-11-17 19:50:10 -08008418 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8420 packetFilterSetReq.filterType);
8421
Arif Hussain6d2a3322013-11-17 19:50:10 -08008422 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008423 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8424
8425 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8426 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8427 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8428 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8429
Arif Hussain6d2a3322013-11-17 19:50:10 -08008430 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008431 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8432 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8433 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8434
Arif Hussain6d2a3322013-11-17 19:50:10 -08008435 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8437 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8438 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8439 }
8440
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008441 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008442 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008443 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 __func__);
8445 return -EINVAL;
8446 }
8447
8448 break;
8449
8450 case HDD_RCV_FILTER_CLEAR:
8451
Arif Hussain6d2a3322013-11-17 19:50:10 -08008452 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008453 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008455 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008456 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008457 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008458 __func__);
8459 return -EINVAL;
8460 }
8461 break;
8462
8463 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008464 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008465 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 return -EINVAL;
8467 }
8468 return 0;
8469}
8470
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308471int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8472 tANI_U8 sessionId)
8473{
8474 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8475 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8476
8477 if (NULL == pHddCtx)
8478 {
8479 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8480 return -EINVAL;
8481 }
8482
8483 if (pHddCtx->isLogpInProgress)
8484 {
8485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8486 "%s:LOGP in Progress. Ignore!!!", __func__);
8487 return -EBUSY;
8488 }
8489
8490 if (pHddCtx->cfg_ini->disablePacketFilter)
8491 {
8492 hddLog(VOS_TRACE_LEVEL_ERROR,
8493 "%s: Packet Filtering Disabled. Returning ",
8494 __func__ );
8495 return -EINVAL;
8496 }
8497
8498 switch (filterType)
8499 {
8500 /* For setting IPV6 MC and UC Filter we need to configure
8501 * 2 filters, one for MC and one for UC.
8502 * The Filter ID shouldn't be swapped, which results in making
8503 * UC Filter ineffective.
8504 * We have Hardcode all the values
8505 *
8506 * Reason for a seperate UC filter is because, driver need to
8507 * specify the FW that the specific filter is for unicast
8508 * otherwise FW will not pass the unicast frames by default
8509 * through the filter. This is required to avoid any performance
8510 * hits when no unicast filter is set and only MC/BC are set.
8511 * The way driver informs host is by using the MAC protocol
8512 * layer, CMP flag set to MAX, CMP Data set to 1.
8513 */
8514
8515 case HDD_FILTER_IPV6_MC_UC:
8516 /* Setting IPV6 MC Filter below
8517 */
8518 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8519 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8520 packetFilterSetReq.numFieldParams = 2;
8521 packetFilterSetReq.paramsData[0].protocolLayer =
8522 HDD_FILTER_PROTO_TYPE_MAC;
8523 packetFilterSetReq.paramsData[0].cmpFlag =
8524 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8525 packetFilterSetReq.paramsData[0].dataOffset =
8526 WLAN_HDD_80211_FRM_DA_OFFSET;
8527 packetFilterSetReq.paramsData[0].dataLength = 1;
8528 packetFilterSetReq.paramsData[0].compareData[0] =
8529 HDD_IPV6_MC_CMP_DATA;
8530
8531 packetFilterSetReq.paramsData[1].protocolLayer =
8532 HDD_FILTER_PROTO_TYPE_ARP;
8533 packetFilterSetReq.paramsData[1].cmpFlag =
8534 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8535 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8536 packetFilterSetReq.paramsData[1].dataLength = 2;
8537 packetFilterSetReq.paramsData[1].compareData[0] =
8538 HDD_IPV6_CMP_DATA_0;
8539 packetFilterSetReq.paramsData[1].compareData[1] =
8540 HDD_IPV6_CMP_DATA_1;
8541
8542
8543 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8544 &packetFilterSetReq, sessionId))
8545 {
8546 hddLog(VOS_TRACE_LEVEL_ERROR,
8547 "%s: Failure to execute Set IPv6 Mulicast Filter",
8548 __func__);
8549 return -EINVAL;
8550 }
8551
8552 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8553
8554 /*
8555 * Setting IPV6 UC Filter below
8556 */
8557 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8558 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8559 packetFilterSetReq.numFieldParams = 2;
8560 packetFilterSetReq.paramsData[0].protocolLayer =
8561 HDD_FILTER_PROTO_TYPE_MAC;
8562 packetFilterSetReq.paramsData[0].cmpFlag =
8563 HDD_FILTER_CMP_TYPE_MAX;
8564 packetFilterSetReq.paramsData[0].dataOffset = 0;
8565 packetFilterSetReq.paramsData[0].dataLength = 1;
8566 packetFilterSetReq.paramsData[0].compareData[0] =
8567 HDD_IPV6_UC_CMP_DATA;
8568
8569 packetFilterSetReq.paramsData[1].protocolLayer =
8570 HDD_FILTER_PROTO_TYPE_ARP;
8571 packetFilterSetReq.paramsData[1].cmpFlag =
8572 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8573 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8574 packetFilterSetReq.paramsData[1].dataLength = 2;
8575 packetFilterSetReq.paramsData[1].compareData[0] =
8576 HDD_IPV6_CMP_DATA_0;
8577 packetFilterSetReq.paramsData[1].compareData[1] =
8578 HDD_IPV6_CMP_DATA_1;
8579
8580 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8581 &packetFilterSetReq, sessionId))
8582 {
8583 hddLog(VOS_TRACE_LEVEL_ERROR,
8584 "%s: Failure to execute Set IPv6 Unicast Filter",
8585 __func__);
8586 return -EINVAL;
8587 }
8588
8589 break;
8590
8591 case HDD_FILTER_IPV6_MC:
8592 /*
8593 * IPV6 UC Filter might be already set,
8594 * clear the UC Filter. As the Filter
8595 * IDs are static, we can directly clear it.
8596 */
8597 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8598 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8599 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8600 &packetFilterClrReq, sessionId))
8601 {
8602 hddLog(VOS_TRACE_LEVEL_ERROR,
8603 "%s: Failure to execute Clear IPv6 Unicast Filter",
8604 __func__);
8605 return -EINVAL;
8606 }
8607
8608 /*
8609 * Setting IPV6 MC Filter below
8610 */
8611 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8612 packetFilterSetReq.numFieldParams = 2;
8613 packetFilterSetReq.paramsData[0].protocolLayer =
8614 HDD_FILTER_PROTO_TYPE_MAC;
8615 packetFilterSetReq.paramsData[0].cmpFlag =
8616 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8617 packetFilterSetReq.paramsData[0].dataOffset =
8618 WLAN_HDD_80211_FRM_DA_OFFSET;
8619 packetFilterSetReq.paramsData[0].dataLength = 1;
8620 packetFilterSetReq.paramsData[0].compareData[0] =
8621 HDD_IPV6_MC_CMP_DATA;
8622
8623 packetFilterSetReq.paramsData[1].protocolLayer =
8624 HDD_FILTER_PROTO_TYPE_ARP;
8625 packetFilterSetReq.paramsData[1].cmpFlag =
8626 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8627 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8628 packetFilterSetReq.paramsData[1].dataLength = 2;
8629 packetFilterSetReq.paramsData[1].compareData[0] =
8630 HDD_IPV6_CMP_DATA_0;
8631 packetFilterSetReq.paramsData[1].compareData[1] =
8632 HDD_IPV6_CMP_DATA_1;
8633
8634
8635 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8636 &packetFilterSetReq, sessionId))
8637 {
8638 hddLog(VOS_TRACE_LEVEL_ERROR,
8639 "%s: Failure to execute Set IPv6 Multicast Filter",
8640 __func__);
8641 return -EINVAL;
8642 }
8643 break;
8644
8645 default :
8646 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8647 "%s: Packet Filter Request: Invalid",
8648 __func__);
8649 return -EINVAL;
8650 }
8651 return 0;
8652}
8653
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308654void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008655{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308656 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308657 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008658 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308659 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008660
Yue Ma3ede6052013-08-29 00:33:26 -07008661 if (NULL == pHddCtx)
8662 {
8663 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8664 return;
8665 }
8666
8667 hHal = pHddCtx->hHal;
8668
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308669 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308671 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8672 return;
8673 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308674
8675 /* Check if INI is enabled or not, other wise just return
8676 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308677 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308678 {
8679 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8680 if (NULL == pMulticastAddrs)
8681 {
8682 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8683 return;
8684 }
8685
Jeff Johnson295189b2012-06-20 16:38:30 -07008686 if (set)
8687 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308688 /* Following pre-conditions should be satisfied before wei
8689 * configure the MC address list.
8690 */
8691 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8692 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8693 && pAdapter->mc_addr_list.mc_cnt
8694 && (eConnectionState_Associated ==
8695 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8696 {
8697 pMulticastAddrs->ulMulticastAddrCnt =
8698 pAdapter->mc_addr_list.mc_cnt;
8699 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8700 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008701 memcpy(pMulticastAddrs->multicastAddr[i],
8702 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308703 sizeof(pAdapter->mc_addr_list.addr[i]));
8704 hddLog(VOS_TRACE_LEVEL_INFO,
8705 "%s: %s multicast filter: addr ="
8706 MAC_ADDRESS_STR,
8707 __func__, set ? "setting" : "clearing",
8708 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8709 }
8710 /* Set multicast filter */
8711 sme_8023MulticastList(hHal, pAdapter->sessionId,
8712 pMulticastAddrs);
8713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308715 else
8716 {
8717 /* Need to clear only if it was previously configured
8718 */
8719 if (pAdapter->mc_addr_list.isFilterApplied)
8720 {
8721 pMulticastAddrs->ulMulticastAddrCnt = 0;
8722 sme_8023MulticastList(hHal, pAdapter->sessionId,
8723 pMulticastAddrs);
8724 }
8725
8726 }
8727 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008728 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308730 else
8731 {
8732 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308733 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308734 }
8735 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008736}
8737
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308738static int __iw_set_packet_filter_params(struct net_device *dev,
8739 struct iw_request_info *info,
8740 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308741{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308742 hdd_adapter_t *pAdapter;
8743 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008744 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308745 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308746 struct iw_point s_priv_data;
8747
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308748 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308749 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8750 if (NULL == pAdapter)
8751 {
8752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8753 "%s: Adapter is NULL",__func__);
8754 return -EINVAL;
8755 }
8756 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8757 ret = wlan_hdd_validate_context(pHddCtx);
8758 if (0 != ret)
8759 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308760 return ret;
8761 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308762 if (hdd_priv_get_data(&s_priv_data, wrqu))
8763 {
8764 return -EINVAL;
8765 }
8766
8767 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8768 {
8769 return -EINVAL;
8770 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008771
Arif Hussain0273cba2014-01-07 20:58:29 -08008772 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308773 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8774 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008775 if (NULL == pRequest)
8776 {
8777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8778 "mem_alloc_copy_from_user_helper fail");
8779 return -ENOMEM;
8780 }
8781
8782 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8783 kfree(pRequest);
8784
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308785 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008786 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008787}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308788
8789static int iw_set_packet_filter_params(struct net_device *dev,
8790 struct iw_request_info *info,
8791 union iwreq_data *wrqu, char *extra)
8792{
8793 int ret;
8794
8795 vos_ssr_protect(__func__);
8796 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8797 vos_ssr_unprotect(__func__);
8798
8799 return ret;
8800}
Jeff Johnson295189b2012-06-20 16:38:30 -07008801#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308802static int __iw_get_statistics(struct net_device *dev,
8803 struct iw_request_info *info,
8804 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008805{
8806
8807 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8808 eHalStatus status = eHAL_STATUS_SUCCESS;
8809 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308810 hdd_adapter_t *pAdapter;
8811 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008812 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308813 int tlen = 0, ret = 0;
8814 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008815
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308816 tCsrGlobalClassAStatsInfo *aStats;
8817 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008818
8819 ENTER();
8820
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308821 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8822 if (NULL == pAdapter)
8823 {
8824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8825 "%s: Adapter is NULL",__func__);
8826 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308828 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8829 ret = wlan_hdd_validate_context(pHddCtx);
8830 if (0 != ret)
8831 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308832 return ret;
8833 }
8834 pStats = &(pAdapter->hdd_stats.summary_stat);
8835 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8836 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8838
8839 wrqu->txpower.value = 0;
8840 }
8841 else {
8842 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8843 SME_SUMMARY_STATS |
8844 SME_GLOBAL_CLASSA_STATS |
8845 SME_GLOBAL_CLASSB_STATS |
8846 SME_GLOBAL_CLASSC_STATS |
8847 SME_GLOBAL_CLASSD_STATS |
8848 SME_PER_STA_STATS,
8849 hdd_StatisticsCB, 0, FALSE,
8850 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8851
8852 if (eHAL_STATUS_SUCCESS != status)
8853 {
8854 hddLog(VOS_TRACE_LEVEL_ERROR,
8855 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008856 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 return -EINVAL;
8858 }
8859
8860 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308861 if (NULL == pWextState)
8862 {
8863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8864 "%s: pWextState is NULL",__func__);
8865 return -EINVAL;
8866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008867
8868 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8869 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8870 {
8871 hddLog(VOS_TRACE_LEVEL_ERROR,
8872 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008873 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008874 /*Remove the SME statistics list by passing NULL in callback argument*/
8875 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8876 SME_SUMMARY_STATS |
8877 SME_GLOBAL_CLASSA_STATS |
8878 SME_GLOBAL_CLASSB_STATS |
8879 SME_GLOBAL_CLASSC_STATS |
8880 SME_GLOBAL_CLASSD_STATS |
8881 SME_PER_STA_STATS,
8882 NULL, 0, FALSE,
8883 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8884
8885 return -EINVAL;
8886 }
8887 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8888 (tANI_U8) sizeof (pStats->retry_cnt),
8889 (char*) &(pStats->retry_cnt[0]),
8890 tlen);
8891
8892 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8893 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8894 (char*) &(pStats->multiple_retry_cnt[0]),
8895 tlen);
8896
8897 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8898 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8899 (char*) &(pStats->tx_frm_cnt[0]),
8900 tlen);
8901
8902 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8903 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8904 (char*) &(pStats->rx_frm_cnt),
8905 tlen);
8906
8907 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8908 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8909 (char*) &(pStats->frm_dup_cnt),
8910 tlen);
8911
8912 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8913 (tANI_U8) sizeof (pStats->fail_cnt),
8914 (char*) &(pStats->fail_cnt[0]),
8915 tlen);
8916
8917 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8918 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8919 (char*) &(pStats->rts_fail_cnt),
8920 tlen);
8921
8922 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8923 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8924 (char*) &(pStats->ack_fail_cnt),
8925 tlen);
8926
8927 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8928 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8929 (char*) &(pStats->rts_succ_cnt),
8930 tlen);
8931
8932 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8933 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8934 (char*) &(pStats->rx_discard_cnt),
8935 tlen);
8936
8937 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8938 (tANI_U8) sizeof (pStats->rx_error_cnt),
8939 (char*) &(pStats->rx_error_cnt),
8940 tlen);
8941
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008942 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008943 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008944 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008945 tlen);
8946
8947 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8948 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8949 (char*) &(dStats->rx_byte_cnt),
8950 tlen);
8951
8952 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8953 (tANI_U8) sizeof (dStats->rx_rate),
8954 (char*) &(dStats->rx_rate),
8955 tlen);
8956
8957 /* Transmit rate, in units of 500 kbit/sec */
8958 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8959 (tANI_U8) sizeof (aStats->tx_rate),
8960 (char*) &(aStats->tx_rate),
8961 tlen);
8962
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008963 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8964 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8965 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008966 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008967 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8968 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8969 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008970 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008971 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8972 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8973 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008974 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008975 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8976 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8977 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008978 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008979 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8980 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8981 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008982 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008983 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8984 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8985 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008986 tlen);
8987
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 wrqu->data.length = tlen;
8989
8990 }
8991
8992 EXIT();
8993
8994 return 0;
8995}
8996
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308997static int iw_get_statistics(struct net_device *dev,
8998 struct iw_request_info *info,
8999 union iwreq_data *wrqu, char *extra)
9000{
9001 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009002
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309003 vos_ssr_protect(__func__);
9004 ret = __iw_get_statistics(dev, info, wrqu, extra);
9005 vos_ssr_unprotect(__func__);
9006
9007 return ret;
9008}
Jeff Johnson295189b2012-06-20 16:38:30 -07009009#ifdef FEATURE_WLAN_SCAN_PNO
9010
9011/*Max Len for PNO notification*/
9012#define MAX_PNO_NOTIFY_LEN 100
9013void found_pref_network_cb (void *callbackContext,
9014 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9015{
9016 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9017 union iwreq_data wrqu;
9018 char buf[MAX_PNO_NOTIFY_LEN+1];
9019
9020 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9021 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9022
9023 // create the event
9024 memset(&wrqu, 0, sizeof(wrqu));
9025 memset(buf, 0, sizeof(buf));
9026
9027 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9028 pPrefNetworkFoundInd->ssId.ssId,
9029 (unsigned int)pPrefNetworkFoundInd->rssi);
9030
9031 wrqu.data.pointer = buf;
9032 wrqu.data.length = strlen(buf);
9033
9034 // send the event
9035
9036 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9037
9038}
9039
9040
9041/*string based input*/
9042VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9043 union iwreq_data *wrqu, char *extra, int nOffset)
9044{
9045 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309046 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009047 /* pnoRequest is a large struct, so we make it static to avoid stack
9048 overflow. This API is only invoked via ioctl, so it is
9049 serialized by the kernel rtnl_lock and hence does not need to be
9050 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309051 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009052 char *ptr;
9053 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309054 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009055 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9056
9057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9058 "PNO data len %d data %s",
9059 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009060 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009061
9062 if (wrqu->data.length <= nOffset )
9063 {
9064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9065 return VOS_STATUS_E_FAILURE;
9066 }
9067
9068 pnoRequest.enable = 0;
9069 pnoRequest.ucNetworksCount = 0;
9070 /*-----------------------------------------------------------------------
9071 Input is string based and expected to be like this:
9072
9073 <enabled> <netw_count>
9074 for each network:
9075 <ssid_len> <ssid> <authentication> <encryption>
9076 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9077 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9078
9079 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009080 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 -07009081
9082 this translates into:
9083 -----------------------------
9084 enable PNO
9085 look for 2 networks:
9086 test - with authentication type 0 and encryption type 0,
9087 that can be found on 3 channels: 1 6 and 11 ,
9088 SSID bcast type is unknown (directed probe will be sent if AP not found)
9089 and must meet -40dBm RSSI
9090
9091 test2 - with auth and enrytption type 4/4
9092 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9093 bcast type is non-bcast (directed probe will be sent)
9094 and must not meet any RSSI threshold
9095
Jeff Johnson8301aa12013-03-28 14:27:29 -07009096 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009097 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009098 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009099
Wilson Yang623f6592013-10-08 16:33:37 -07009100 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9101 {
9102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9103 "PNO enable input is not valid %s",ptr);
9104 return VOS_STATUS_E_FAILURE;
9105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009106
9107 if ( 0 == pnoRequest.enable )
9108 {
9109 /*Disable PNO*/
9110 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309111 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9112 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 pAdapter->sessionId,
9114 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309115 if (eHAL_STATUS_SUCCESS != status)
9116 {
9117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9118 "%s: failed to disable PNO", __func__);
9119 return VOS_STATUS_E_FAILURE;
9120 }
9121 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009122 return VOS_STATUS_SUCCESS;
9123 }
9124
c_hpothu37f21312014-04-09 21:49:54 +05309125 if (TRUE == pHddCtx->isPnoEnable)
9126 {
9127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9128 FL("already PNO is enabled"));
9129 return -EBUSY;
9130 }
9131 pHddCtx->isPnoEnable = TRUE;
9132
Jeff Johnson295189b2012-06-20 16:38:30 -07009133 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009134
9135 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9136 {
9137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9138 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309139 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009140 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009141
9142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9143 "PNO enable %d networks count %d offset %d",
9144 pnoRequest.enable,
9145 pnoRequest.ucNetworksCount,
9146 nOffset);
9147
9148 /* Parameters checking:
9149 ucNetworksCount has to be larger than 0*/
9150 if (( 0 == pnoRequest.ucNetworksCount ) ||
9151 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9152 {
9153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309154 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009155 }
9156
9157 ptr += nOffset;
9158
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309159 pnoRequest.aNetworks =
9160 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9161 if (pnoRequest.aNetworks == NULL)
9162 {
9163 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9164 FL("failed to allocate memory aNetworks %u"),
9165 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9166 goto error;
9167 }
9168 vos_mem_zero(pnoRequest.aNetworks,
9169 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9170
Jeff Johnson295189b2012-06-20 16:38:30 -07009171 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9172 {
9173
9174 pnoRequest.aNetworks[i].ssId.length = 0;
9175
Wilson Yang623f6592013-10-08 16:33:37 -07009176 ucParams = sscanf(ptr,"%hhu %n",
9177 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9178
9179 if (1 != ucParams)
9180 {
9181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9182 "PNO ssid length input is not valid %s",ptr);
9183 return VOS_STATUS_E_FAILURE;
9184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009185
9186 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9187 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9188 {
9189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9190 "SSID Len %d is not correct for network %d",
9191 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309192 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009193 }
9194
9195 /*Advance to SSID*/
9196 ptr += nOffset;
9197
Jeff Johnson8301aa12013-03-28 14:27:29 -07009198 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009199 pnoRequest.aNetworks[i].ssId.length);
9200 ptr += pnoRequest.aNetworks[i].ssId.length;
9201
Jeff Johnson02797792013-10-26 19:17:13 -07009202 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009203 &(pnoRequest.aNetworks[i].authentication),
9204 &(pnoRequest.aNetworks[i].encryption),
9205 &(pnoRequest.aNetworks[i].ucChannelCount),
9206 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009207
Wilson Yang623f6592013-10-08 16:33:37 -07009208 if ( 3 != ucParams )
9209 {
9210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9211 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309212 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009213 }
9214
Jeff Johnson295189b2012-06-20 16:38:30 -07009215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009216 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009217 "auth %d encry %d channel count %d offset %d",
9218 pnoRequest.aNetworks[i].ssId.length,
9219 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9220 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9221 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9222 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9223 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9224 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9225 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9226 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9227 pnoRequest.aNetworks[i].authentication,
9228 pnoRequest.aNetworks[i].encryption,
9229 pnoRequest.aNetworks[i].ucChannelCount,
9230 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009231
Jeff Johnson295189b2012-06-20 16:38:30 -07009232 /*Advance to channel list*/
9233 ptr += nOffset;
9234
Wilson Yang623f6592013-10-08 16:33:37 -07009235 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 {
9237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9238 "Incorrect number of channels");
9239 return VOS_STATUS_E_FAILURE;
9240 }
9241
9242 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9243 {
9244 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9245 {
Wilson Yang623f6592013-10-08 16:33:37 -07009246 if (1 != sscanf(ptr,"%hhu %n",
9247 &(pnoRequest.aNetworks[i].aChannels[j]),
9248 &nOffset))
9249 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9250 "PNO network channel input is not valid %s",ptr);
9251 return VOS_STATUS_E_FAILURE;
9252 }
9253 /*Advance to next channel number*/
9254 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 }
9256 }
9257
Jeff Johnson02797792013-10-26 19:17:13 -07009258 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009259 &(pnoRequest.aNetworks[i].bcastNetwType),
9260 &nOffset))
9261 {
9262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9263 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309264 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009266
9267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9268 "PNO bcastNetwType %d offset %d",
9269 pnoRequest.aNetworks[i].bcastNetwType,
9270 nOffset );
9271
9272 /*Advance to rssi Threshold*/
9273 ptr += nOffset;
9274
Wilson Yang623f6592013-10-08 16:33:37 -07009275 if (1 != sscanf(ptr,"%hhu %n",
9276 &(pnoRequest.aNetworks[i].rssiThreshold),
9277 &nOffset))
9278 {
9279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9280 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309281 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009282 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009283
9284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9285 "PNO rssi %d offset %d",
9286 pnoRequest.aNetworks[i].rssiThreshold,
9287 nOffset );
9288 /*Advance to next network*/
9289 ptr += nOffset;
9290 }/*For ucNetworkCount*/
9291
9292 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009293 &(pnoRequest.scanTimers.ucScanTimersCount),
9294 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009295
9296 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009297 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009298 {
9299 ptr += nOffset;
9300
Jeff Johnson8301aa12013-03-28 14:27:29 -07009301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9302 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009303 pnoRequest.scanTimers.ucScanTimersCount,
9304 nOffset );
9305
9306 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9307 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309310 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009311 }
9312
9313 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9314 {
Jeff Johnson02797792013-10-26 19:17:13 -07009315 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009316 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9317 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9318 &nOffset);
9319
Wilson Yang623f6592013-10-08 16:33:37 -07009320 if (2 != ucParams)
9321 {
9322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9323 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309324 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009325 }
9326
Jeff Johnson8301aa12013-03-28 14:27:29 -07009327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9328 "PNO Timer value %d Timer repeat %d offset %d",
9329 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009330 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9331 nOffset );
9332
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 ptr += nOffset;
9334 }
9335
9336 }
9337 else
9338 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9340 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9342
9343 /*Scan timers defaults to 5 minutes*/
9344 pnoRequest.scanTimers.ucScanTimersCount = 1;
9345 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9346 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9347 }
9348
Wilson Yang623f6592013-10-08 16:33:37 -07009349 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009350
9351 pnoRequest.modePNO = ucMode;
9352 /*for LA we just expose suspend option*/
9353 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9354 {
9355 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9356 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309357 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9358 if (pnoRequest.p24GProbeTemplate == NULL){
9359 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9360 FL("failed to allocate memory p24GProbeTemplate %u"),
9361 SIR_PNO_MAX_PB_REQ_SIZE);
9362 goto error;
9363 }
9364
9365 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9366 if (pnoRequest.p5GProbeTemplate == NULL){
9367 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9368 FL("failed to allocate memory p5GProbeTemplate %u"),
9369 SIR_PNO_MAX_PB_REQ_SIZE);
9370 goto error;
9371 }
9372
9373 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9374 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009375
c_hpothu37f21312014-04-09 21:49:54 +05309376 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009377 pAdapter->sessionId,
9378 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309379 if (eHAL_STATUS_SUCCESS == status)
9380 {
9381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9382 "%s: PNO enabled", __func__);
9383 return VOS_STATUS_SUCCESS;
9384 }
9385error:
9386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9387 "%s: Failed to enable PNO", __func__);
9388 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309389 if (pnoRequest.aNetworks)
9390 vos_mem_free(pnoRequest.aNetworks);
9391 if (pnoRequest.p24GProbeTemplate)
9392 vos_mem_free(pnoRequest.p24GProbeTemplate);
9393 if (pnoRequest.p5GProbeTemplate)
9394 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309395 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009396}/*iw_set_pno*/
9397
9398VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9399 union iwreq_data *wrqu, char *extra, int nOffset)
9400{
9401 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9402 v_U8_t rssiThreshold = 0;
9403 v_U8_t nRead;
9404
Arif Hussain7adce1b2013-11-11 22:59:34 -08009405 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009406 &rssiThreshold);
9407
9408 if ( 1 != nRead )
9409 {
9410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9411 "Incorrect format");
9412 return VOS_STATUS_E_FAILURE;
9413 }
9414
9415 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9416 return VOS_STATUS_SUCCESS;
9417}
9418
9419
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309420static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009421 struct iw_request_info *info,
9422 union iwreq_data *wrqu, char *extra)
9423{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309424 hdd_adapter_t *pAdapter;
9425 hdd_context_t *pHddCtx;
9426 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309427 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309428
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309429 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309430 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9431 if (NULL == pAdapter)
9432 {
9433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9434 "%s: Adapter is NULL",__func__);
9435 return -EINVAL;
9436 }
9437
9438 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9439 ret = wlan_hdd_validate_context(pHddCtx);
9440 if (0 != ret)
9441 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309442 return ret;
9443 }
9444
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009445
9446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009448
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309449 status = iw_set_pno(dev,info,wrqu,extra,0);
9450
9451 EXIT();
9452 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009453}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309454
9455static int iw_set_pno_priv(struct net_device *dev,
9456 struct iw_request_info *info,
9457 union iwreq_data *wrqu, char *extra)
9458{
9459 int ret;
9460
9461 vos_ssr_protect(__func__);
9462 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9463 vos_ssr_unprotect(__func__);
9464
9465 return ret;
9466}
Jeff Johnson295189b2012-06-20 16:38:30 -07009467#endif /*FEATURE_WLAN_SCAN_PNO*/
9468
9469//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309470int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009471{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309472 hdd_adapter_t *pAdapter;
9473 tHalHandle hHal;
9474 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309475 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309476 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309477 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009478 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309479 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309480 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309481 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309482
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309483 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309484 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9485 if (NULL == pAdapter)
9486 {
9487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9488 "%s: Adapter is NULL",__func__);
9489 return -EINVAL;
9490 }
9491 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9492 retval = wlan_hdd_validate_context(pHddCtx);
9493 if (0 != retval)
9494 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309495 return retval;
9496 }
9497 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9498 if (NULL == hHal)
9499 {
9500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9501 "%s: Hal Context is NULL",__func__);
9502 return -EINVAL;
9503 }
9504 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009505
Atul Mittal54378cb2014-04-02 16:51:50 +05309506 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 {
9508 case WLAN_HDD_UI_BAND_AUTO:
9509 band = eCSR_BAND_ALL;
9510 break;
9511 case WLAN_HDD_UI_BAND_5_GHZ:
9512 band = eCSR_BAND_5G;
9513 break;
9514 case WLAN_HDD_UI_BAND_2_4_GHZ:
9515 band = eCSR_BAND_24;
9516 break;
9517 default:
9518 band = eCSR_BAND_MAX;
9519 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309520 connectedBand =
9521 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009522
Atul Mittal54378cb2014-04-02 16:51:50 +05309523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009524 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009525
9526 if (band == eCSR_BAND_MAX)
9527 {
9528 /* Received change band request with invalid band value */
9529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309530 "%s: Invalid band value %u", __func__, ui_band);
9531 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 }
9533
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309534 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309535 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309536 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009538 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009539 band, pHddCtx->cfg_ini->nBandCapability);
9540 return -EIO;
9541 }
9542
Sushant Kaushik1165f872015-03-30 20:25:27 +05309543 if (band == eCSR_BAND_ALL)
9544 {
9545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9546 "received. Setting band same as ini value %d"),
9547 pHddCtx->cfg_ini->nBandCapability);
9548 band = pHddCtx->cfg_ini->nBandCapability;
9549 }
9550
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9552 {
9553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9554 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009555 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009556 return -EIO;
9557 }
9558
9559 if (currBand != band)
9560 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309561 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309562 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309563 /* Return failure if current country code is world regulatory domain*/
9564 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9565 pMac->scan.countryCodeCurrent[1] == '0') )
9566 {
9567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9568 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309569 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309570 return -EAGAIN;
9571 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309572 }
9573
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 /* Change band request received.
9575 * Abort pending scan requests, flush the existing scan results,
9576 * and change the band capability
9577 */
9578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9579 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009580 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009581
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309582 /* We need to change the band and flush the scan results here itself
9583 * as we may get timeout for disconnection in which we will return
9584 * with out doing any of these
9585 */
9586 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9587 {
9588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9589 "%s: failed to set the band value to %u ",
9590 __func__, band);
9591 return -EINVAL;
9592 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309593 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9594 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309595 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309596 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9597 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309598 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309599 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9600 * information available in NV so to get the channel information from kernel
9601 * we need to send regulatory hint for the currunt country
9602 * And to set the same country again we need to set the dummy country
9603 * first and then the actual country.
9604 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309605#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9606 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9607#else
9608 regulatory_hint_user("00");
9609#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309610 wait_result = wait_for_completion_interruptible_timeout(
9611 &pHddCtx->linux_reg_req,
9612 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9613
9614 /* if the country information does not exist with the kernel,
9615 then the driver callback would not be called */
9616
9617 if (wait_result >= 0)
9618 {
9619 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9620 "runtime country code is found in kernel db");
9621 }
9622 else
9623 {
9624 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9625 "runtime country code is not found"
9626 " in kernel db");
9627 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309628
9629 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309630
9631 /*
9632 * Update 11dcountry and current country here as the hint
9633 * with 00 results in 11d and current country with 00
9634 */
9635 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9636 WNI_CFG_COUNTRY_CODE_LEN);
9637 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9638 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309639#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9640 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9641#else
9642 regulatory_hint_user(curr_country);
9643#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309644 wait_result = wait_for_completion_interruptible_timeout(
9645 &pHddCtx->linux_reg_req,
9646 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9647
9648 /* if the country information does not exist with the kernel,
9649 then the driver callback would not be called */
9650 if (wait_result >= 0)
9651 {
9652 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9653 "runtime country code is found in kernel db");
9654 }
9655 else
9656 {
9657 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9658 "runtime country code is not found"
9659 " in kernel db");
9660 }
9661
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309662 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309663 }
9664 else
9665 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309666#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309667 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9668 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309669#else
9670 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9671#endif
9672
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309673 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309674 pScanInfo = &pHddCtx->scan_info;
9675 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9676 {
9677 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9678 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9679 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309680 sme_FilterScanResults(hHal, pAdapter->sessionId);
9681
9682 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309683 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9684 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 eHalStatus status = eHAL_STATUS_SUCCESS;
9687 long lrc;
9688
9689 /* STA already connected on current band, So issue disconnect first,
9690 * then change the band*/
9691
9692 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309693 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309694 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009695
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9697
9698 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9699 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9700
Jeff Johnson43971f52012-07-17 12:26:56 -07009701 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009702 {
9703 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009704 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 __func__, (int)status );
9706 return -EINVAL;
9707 }
9708
9709 lrc = wait_for_completion_interruptible_timeout(
9710 &pAdapter->disconnect_comp_var,
9711 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9712
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309713 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009714
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009715 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009716 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009717
9718 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9719 }
9720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309722 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309723 if (TRUE == pHddCtx->isSetBandByNL)
9724 return 0;
9725 else
9726 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07009727}
9728
Atul Mittal54378cb2014-04-02 16:51:50 +05309729int hdd_setBand_helper(struct net_device *dev, const char *command)
9730{
9731 u8 band;
9732
9733 /*convert the band value from ascii to integer*/
9734 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9735
9736 return hdd_setBand(dev, band);
9737
9738}
9739
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309740static int __iw_set_band_config(struct net_device *dev,
9741 struct iw_request_info *info,
9742 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009743{
Atul Mittal54378cb2014-04-02 16:51:50 +05309744 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009745
Arif Hussain0273cba2014-01-07 20:58:29 -08009746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009747
Atul Mittal54378cb2014-04-02 16:51:50 +05309748 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009749}
9750
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309751static int iw_set_band_config(struct net_device *dev,
9752 struct iw_request_info *info,
9753 union iwreq_data *wrqu, char *extra)
9754{
9755 int ret;
9756
9757 vos_ssr_protect(__func__);
9758 ret = __iw_set_band_config(dev, info, wrqu, extra);
9759 vos_ssr_unprotect(__func__);
9760
9761 return ret;
9762}
9763
c_manjeecfd1efb2015-09-25 19:32:34 +05309764static int get_fwr_memdump(struct net_device *dev,
9765 struct iw_request_info *info,
9766 union iwreq_data *wrqu, char *extra)
9767{
9768 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9769 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9770 int ret;
9771 ENTER();
9772 // HddCtx sanity
9773 ret = wlan_hdd_validate_context(pHddCtx);
9774 if (0 != ret)
9775 {
9776 return ret;
9777 }
9778 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
9779 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
9780 {
9781 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
9782 return -EINVAL;
9783 }
9784 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
9785
9786 EXIT();
9787 return ret;
9788}
9789
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309790static int __iw_set_power_params_priv(struct net_device *dev,
9791 struct iw_request_info *info,
9792 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009793{
Arif Hussain0273cba2014-01-07 20:58:29 -08009794 int ret;
9795 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9797 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009798 /* ODD number is used for set, copy data using copy_from_user */
9799 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9800 wrqu->data.length);
9801 if (NULL == ptr)
9802 {
9803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9804 "mem_alloc_copy_from_user_helper fail");
9805 return -ENOMEM;
9806 }
9807
9808 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9809 kfree(ptr);
9810 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009811}
9812
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309813static int iw_set_power_params_priv(struct net_device *dev,
9814 struct iw_request_info *info,
9815 union iwreq_data *wrqu, char *extra)
9816{
9817 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009818
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309819 vos_ssr_protect(__func__);
9820 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9821 vos_ssr_unprotect(__func__);
9822
9823 return ret;
9824}
Jeff Johnson295189b2012-06-20 16:38:30 -07009825
9826/*string based input*/
9827VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9828 union iwreq_data *wrqu, char *extra, int nOffset)
9829{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309830 hdd_adapter_t *pAdapter;
9831 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009832 tSirSetPowerParamsReq powerRequest;
9833 char *ptr;
9834 v_U8_t ucType;
9835 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309836 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009837
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309838 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309839 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9840 if (NULL == pAdapter)
9841 {
9842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9843 "%s: Adapter is NULL",__func__);
9844 return -EINVAL;
9845 }
9846
9847 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9848 ret = wlan_hdd_validate_context(pHddCtx);
9849 if (0 != ret)
9850 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309851 return ret;
9852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9854 "Power Params data len %d data %s",
9855 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009856 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009857
9858 if (wrqu->data.length <= nOffset )
9859 {
9860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9861 return VOS_STATUS_E_FAILURE;
9862 }
9863
9864 uTotalSize = wrqu->data.length - nOffset;
9865
9866 /*-----------------------------------------------------------------------
9867 Input is string based and expected to be like this:
9868
9869 <param_type> <param_value> <param_type> <param_value> ...
9870
9871 e.g:
9872 1 2 2 3 3 0 4 1 5 1
9873
9874 e.g. setting just a few:
9875 1 2 4 1
9876
9877 parameter types:
9878 -----------------------------
9879 1 - Ignore DTIM
9880 2 - Listen Interval
9881 3 - Broadcast Multicas Filter
9882 4 - Beacon Early Termination
9883 5 - Beacon Early Termination Interval
9884 -----------------------------------------------------------------------*/
9885 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9886 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9887 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9888 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9889 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9890
Arif Hussain7adce1b2013-11-11 22:59:34 -08009891 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009892
9893 while ( uTotalSize )
9894 {
Wilson Yang6f971452013-10-08 15:00:00 -07009895 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9896 {
9897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9898 "Invalid input parameter type %s",ptr);
9899 return VOS_STATUS_E_FAILURE;
9900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009901
9902 uTotalSize -= nOffset;
9903
9904 if (!uTotalSize)
9905 {
9906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009907 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009908 ucType, nOffset);
9909 return VOS_STATUS_E_FAILURE;
9910 }
9911
9912 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009913
Jeff Johnson02797792013-10-26 19:17:13 -07009914 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009915 {
9916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9917 "Invalid input parameter value %s",ptr);
9918 return VOS_STATUS_E_FAILURE;
9919 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009920
9921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9922 "Power request parameter %d value %d offset %d",
9923 ucType, uValue, nOffset);
9924
9925 switch (ucType)
9926 {
9927 case eSIR_IGNORE_DTIM:
9928 powerRequest.uIgnoreDTIM = uValue;
9929 break;
9930 case eSIR_LISTEN_INTERVAL:
9931 powerRequest.uListenInterval = uValue;
9932 break;
9933 case eSIR_MCAST_BCAST_FILTER:
9934 powerRequest.uBcastMcastFilter = uValue;
9935 break;
9936 case eSIR_ENABLE_BET:
9937 powerRequest.uEnableBET = uValue;
9938 break;
9939 case eSIR_BET_INTERVAL:
9940 powerRequest.uBETInterval = uValue;
9941 break;
9942 default:
9943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009944 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 ucType, uValue, nOffset);
9946 return VOS_STATUS_E_FAILURE;
9947 }
9948
9949 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9951 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009952 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009954 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009955 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009956 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9957 {
9958 uTotalSize = 0;
9959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009960
9961 }/*Go for as long as we have a valid string*/
9962
9963 /* put the device into full power*/
9964 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9965
9966 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009967 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009968
9969 /* put the device back to power save*/
9970 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9971
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309972 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009973 return VOS_STATUS_SUCCESS;
9974}/*iw_set_power_params*/
9975
Atul Mittalc0f739f2014-07-31 13:47:47 +05309976// tdlsoffchan
9977#ifdef FEATURE_WLAN_TDLS
9978
Atul Mittal87ec2422014-09-24 13:12:50 +05309979int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309980{
9981 if (offchannel < 0 || offchannel > 165)
9982 {
9983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9984 __func__, offchannel);
9985 return -1;
9986
9987 }
9988
9989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9990 __func__, tdlsOffCh, offchannel);
9991
9992 tdlsOffCh = offchannel;
9993 return 0;
9994}
9995
Atul Mittal87ec2422014-09-24 13:12:50 +05309996int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309997{
9998 if (offchanoffset == 0)
9999 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010000 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10002 __func__, tdlsOffChBwOffset);
10003
10004 return 0;
10005
10006 }
10007
10008 if ( offchanoffset == 40 )
10009 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010010 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10012 __func__, tdlsOffChBwOffset);
10013
10014 return 0;
10015
10016 }
10017 if (offchanoffset == -40)
10018 {
10019 tdlsOffChBwOffset = 3;
10020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10021 __func__, tdlsOffChBwOffset);
10022
10023 return 0;
10024
10025 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010026
10027 if ((offchanoffset == 80) &&
10028 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10029 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10030 {
10031 tdlsOffChBwOffset = 4;
10032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10033 "%s: change tdls secondary off channel offset to %u",
10034 __func__, tdlsOffChBwOffset);
10035
10036 return 0;
10037 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10039 __func__, offchanoffset);
10040 return -1;
10041}
10042
Atul Mittal87ec2422014-09-24 13:12:50 +053010043int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010044{
10045 hddTdlsPeer_t *connPeer = NULL;
10046 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10047 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10048
10049 if (offchanmode < 0 || offchanmode > 4)
10050 {
10051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10052 "%s: Invalid tdls off channel mode %d",
10053 __func__, offchanmode);
10054 return -1;
10055 }
10056
10057 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10058 {
10059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10060 "%s: tdls off channel mode req in not associated state %d",
10061 __func__, offchanmode);
10062 return -1;
10063 }
10064
10065 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10066 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10067 {
10068 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010069 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010070 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010071 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010072 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10074 "%s: No TDLS Connected Peer", __func__);
10075 return -1;
10076 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010077 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010078 }
10079 else
10080 {
10081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10082 "%s: TDLS Connection not supported", __func__);
10083 return -1;
10084 }
10085
10086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10087 ("%s: TDLS Channel Switch in swmode=%d"),
10088 __func__, offchanmode);
10089
10090 switch (offchanmode)
10091 {
10092 case 1:/*Enable*/
10093 case 2:/*Disable*/
10094 {
10095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10096 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10097 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10098 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10099 {
10100
10101 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
10102 pAdapter->sessionId, connPeer->peerMac,
10103 tdlsOffCh, tdlsOffChBwOffset,
10104 offchanmode);
10105 }
10106 else
10107 {
10108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10109 "%s: TDLS Off Channel not supported", __func__);
10110 return -1;
10111 }
10112 break;
10113 }
10114 case 3:
10115 {
10116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10117 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10118 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10119
10120 break;
10121 }
10122 case 4:
10123 {
10124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10125 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10126 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10127 break;
10128 }
10129 default:
10130 {
10131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10132 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10133 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10134 break;
10135 }
10136
10137 }
10138
10139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10140 __func__, offchanmode);
10141 return 0;
10142}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010143#endif
10144
Jeff Johnson295189b2012-06-20 16:38:30 -070010145
10146// Define the Wireless Extensions to the Linux Network Device structure
10147// A number of these routines are NULL (meaning they are not implemented.)
10148
10149static const iw_handler we_handler[] =
10150{
10151 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10152 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10153 (iw_handler) NULL, /* SIOCSIWNWID */
10154 (iw_handler) NULL, /* SIOCGIWNWID */
10155 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10156 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10157 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10158 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10159 (iw_handler) NULL, /* SIOCSIWSENS */
10160 (iw_handler) NULL, /* SIOCGIWSENS */
10161 (iw_handler) NULL, /* SIOCSIWRANGE */
10162 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10163 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
10164 (iw_handler) NULL, /* SIOCGIWPRIV */
10165 (iw_handler) NULL, /* SIOCSIWSTATS */
10166 (iw_handler) NULL, /* SIOCGIWSTATS */
10167 iw_handler_set_spy, /* SIOCSIWSPY */
10168 iw_handler_get_spy, /* SIOCGIWSPY */
10169 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10170 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10171 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10172 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10173 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10174 (iw_handler) NULL, /* SIOCGIWAPLIST */
10175 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10176 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10177 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10178 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10179 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10180 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10181 (iw_handler) NULL, /* -- hole -- */
10182 (iw_handler) NULL, /* -- hole -- */
10183 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10184 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10185 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10186 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10187 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10188 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10189 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10190 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10191 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10192 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10193 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10194 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10195 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10196 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10197 (iw_handler) NULL, /* -- hole -- */
10198 (iw_handler) NULL, /* -- hole -- */
10199 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10200 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10201 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10202 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10203 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10204 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10205 (iw_handler) NULL, /* SIOCSIWPMKSA */
10206};
10207
10208static const iw_handler we_private[] = {
10209
10210 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10211 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10212 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10213 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10214 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10215 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010216 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010217 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10218 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10219 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010220#ifdef FEATURE_OEM_DATA_SUPPORT
10221 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10222 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10223#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010224
Jeff Johnson295189b2012-06-20 16:38:30 -070010225#ifdef WLAN_FEATURE_VOWIFI_11R
10226 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10227#endif
10228 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10229 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10230 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10231#ifdef WLAN_FEATURE_PACKET_FILTERING
10232 ,
10233 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10234#endif
10235#ifdef FEATURE_WLAN_SCAN_PNO
10236 ,
10237 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10238#endif
10239 ,
10240 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10241 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10242 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10243 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010244 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010245};
10246
10247/*Maximum command length can be only 15 */
10248static const struct iw_priv_args we_private_args[] = {
10249
Katya Nigamf0511f62015-05-05 16:40:57 +053010250 { WE_SET_MONITOR_STATE,
10251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10252 0, "monitor" },
10253
Jeff Johnson295189b2012-06-20 16:38:30 -070010254 /* handlers for main ioctl */
10255 { WLAN_PRIV_SET_INT_GET_NONE,
10256 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10257 0,
10258 "" },
10259
10260 /* handlers for sub-ioctl */
10261 { WE_SET_11D_STATE,
10262 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10263 0,
10264 "set11Dstate" },
10265
10266 { WE_WOWL,
10267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10268 0,
10269 "wowl" },
10270
10271 { WE_SET_POWER,
10272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10273 0,
10274 "setPower" },
10275
10276 { WE_SET_MAX_ASSOC,
10277 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10278 0,
10279 "setMaxAssoc" },
10280
10281 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10282 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10283 0,
10284 "setAutoChannel" },
10285
10286 { WE_SET_DATA_INACTIVITY_TO,
10287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10288 0,
10289 "inactivityTO" },
10290
10291 { WE_SET_MAX_TX_POWER,
10292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10293 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010294 "setMaxTxPower" },
10295
10296 { WE_SET_MAX_TX_POWER_2_4,
10297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10298 0,
10299 "setTxMaxPower2G" },
10300
10301 { WE_SET_MAX_TX_POWER_5_0,
10302 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10303 0,
10304 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010305
10306 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10307 * as well to keep same syntax as in SAP. Now onwards, STA
10308 * will support both */
10309 { WE_SET_MAX_TX_POWER,
10310 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10311 0,
10312 "setTxMaxPower" },
10313
Jeff Johnson295189b2012-06-20 16:38:30 -070010314 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10315 * 1 = enable and 0 = disable */
10316 {
10317 WE_SET_HIGHER_DTIM_TRANSITION,
10318 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10319 0,
10320 "setHDtimTransn" },
10321
10322 { WE_SET_TM_LEVEL,
10323 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010324 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010325 "setTmLevel" },
10326
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010327 { WE_ENABLE_STRICT_FCC_REG,
10328 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10329 0,
10330 "setStrictFCCreg" },
10331
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010332 { WE_SET_DEBUG_LOG,
10333 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10334 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010335#ifdef FEATURE_WLAN_TDLS
10336 {
10337 WE_SET_TDLS_OFF_CHAN,
10338 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10339 0,
10340 "tdlsoffchan" },
10341 {
10342 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10343 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10344 0,
10345 "tdlsecchnoffst" },
10346 {
10347 WE_SET_TDLS_OFF_CHAN_MODE,
10348 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10349 0,
10350 "tdlsoffchnmode" },
10351#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010352
Peng Xu2446a892014-09-05 17:21:18 +053010353 { WE_SET_SCAN_BAND_PREFERENCE,
10354 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10355 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010356 {
10357 WE_GET_FRAME_LOG,
10358 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10359 0,
10360 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010361
Abhishek Singh01c73d12015-03-12 15:13:44 +053010362 { WE_SET_MIRACAST_VENDOR_CONFIG,
10363 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10364 0, "setMiracstConf" },
10365
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010366#ifdef FEATURE_WLAN_TDLS
10367 {
10368 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10369 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10370 0,
10371 "tdls_2040bsscox" },
10372#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010373 { WE_SET_RTS_CTS_HTVHT,
10374 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10375 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010376 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10377 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10378 0, "setPktStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010379 /* handlers for main ioctl */
10380 { WLAN_PRIV_SET_NONE_GET_INT,
10381 0,
10382 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10383 "" },
10384
10385 /* handlers for sub-ioctl */
10386 { WE_GET_11D_STATE,
10387 0,
10388 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10389 "get11Dstate" },
10390
10391 { WE_IBSS_STATUS,
10392 0,
10393 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10394 "getAdhocStatus" },
10395
10396 { WE_PMC_STATE,
10397 0,
10398 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10399 "pmcState" },
10400
10401 { WE_GET_WLAN_DBG,
10402 0,
10403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10404 "getwlandbg" },
10405
Jeff Johnson295189b2012-06-20 16:38:30 -070010406 { WE_GET_MAX_ASSOC,
10407 0,
10408 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10409 "getMaxAssoc" },
10410
Jeff Johnson295189b2012-06-20 16:38:30 -070010411 { WE_GET_WDI_DBG,
10412 0,
10413 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10414 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010415
10416 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10417 0,
10418 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10419 "getAutoChannel" },
10420
10421 { WE_GET_CONCURRENCY_MODE,
10422 0,
10423 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10424 "getconcurrency" },
10425
Peng Xu2446a892014-09-05 17:21:18 +053010426 { WE_GET_SCAN_BAND_PREFERENCE,
10427 0,
10428 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10429 "get_scan_pref"},
10430
Jeff Johnson295189b2012-06-20 16:38:30 -070010431 /* handlers for main ioctl */
10432 { WLAN_PRIV_SET_CHAR_GET_NONE,
10433 IW_PRIV_TYPE_CHAR| 512,
10434 0,
10435 "" },
10436
10437 /* handlers for sub-ioctl */
10438 { WE_WOWL_ADD_PTRN,
10439 IW_PRIV_TYPE_CHAR| 512,
10440 0,
10441 "wowlAddPtrn" },
10442
10443 { WE_WOWL_DEL_PTRN,
10444 IW_PRIV_TYPE_CHAR| 512,
10445 0,
10446 "wowlDelPtrn" },
10447
10448#if defined WLAN_FEATURE_VOWIFI
10449 /* handlers for sub-ioctl */
10450 { WE_NEIGHBOR_REPORT_REQUEST,
10451 IW_PRIV_TYPE_CHAR | 512,
10452 0,
10453 "neighbor" },
10454#endif
10455 { WE_SET_AP_WPS_IE,
10456 IW_PRIV_TYPE_CHAR| 512,
10457 0,
10458 "set_ap_wps_ie" },
10459
10460 { WE_SET_CONFIG,
10461 IW_PRIV_TYPE_CHAR| 512,
10462 0,
10463 "setConfig" },
10464
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010465 { WE_SET_ENCRYPT_MSG,
10466 IW_PRIV_TYPE_CHAR| 512,
10467 0,
10468 "encryptMsg" },
10469
10470
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 /* handlers for main ioctl */
10472 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10473 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10474 0,
10475 "" },
10476
10477 /* handlers for sub-ioctl */
10478 { WE_SET_WLAN_DBG,
10479 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10480 0,
10481 "setwlandbg" },
10482
Jeff Johnson295189b2012-06-20 16:38:30 -070010483 { WE_SET_WDI_DBG,
10484 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10485 0,
10486 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010487
10488 { WE_SET_SAP_CHANNELS,
10489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10490 0,
10491 "setsapchannels" },
10492
10493 /* handlers for main ioctl */
10494 { WLAN_PRIV_GET_CHAR_SET_NONE,
10495 0,
10496 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10497 "" },
10498
10499 /* handlers for sub-ioctl */
10500 { WE_WLAN_VERSION,
10501 0,
10502 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10503 "version" },
10504 { WE_GET_STATS,
10505 0,
10506 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10507 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010508 { WE_GET_STATES,
10509 0,
10510 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10511 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010512 { WE_GET_CFG,
10513 0,
10514 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10515 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010516#ifdef WLAN_FEATURE_11AC
10517 { WE_GET_RSSI,
10518 0,
10519 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10520 "getRSSI" },
10521#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010522#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010523 { WE_GET_ROAM_RSSI,
10524 0,
10525 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10526 "getRoamRSSI" },
10527#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010528 { WE_GET_WMM_STATUS,
10529 0,
10530 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10531 "getWmmStatus" },
10532 {
10533 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010534 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010535 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10536 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010537#ifdef FEATURE_WLAN_TDLS
10538 {
10539 WE_GET_TDLS_PEERS,
10540 0,
10541 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10542 "getTdlsPeers" },
10543#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010544#ifdef WLAN_FEATURE_11W
10545 {
10546 WE_GET_11W_INFO,
10547 0,
10548 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10549 "getPMFInfo" },
10550#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010551 { WE_GET_SNR,
10552 0,
10553 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10554 "getSNR" },
10555
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 /* handlers for main ioctl */
10557 { WLAN_PRIV_SET_NONE_GET_NONE,
10558 0,
10559 0,
10560 "" },
10561
10562 /* handlers for sub-ioctl */
10563 { WE_CLEAR_STATS,
10564 0,
10565 0,
10566 "clearStats" },
10567 { WE_INIT_AP,
10568 0,
10569 0,
10570 "initAP" },
10571 { WE_STOP_AP,
10572 0,
10573 0,
10574 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010575#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 { WE_ENABLE_AMP,
10577 0,
10578 0,
10579 "enableAMP" },
10580 { WE_DISABLE_AMP,
10581 0,
10582 0,
10583 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010584#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010585 { WE_ENABLE_DXE_STALL_DETECT,
10586 0,
10587 0,
10588 "dxeStallDetect" },
10589 { WE_DISPLAY_DXE_SNAP_SHOT,
10590 0,
10591 0,
10592 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010593 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10594 0,
10595 0,
10596 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010597 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010598 WE_SET_REASSOC_TRIGGER,
10599 0,
10600 0,
10601 "reassoc" },
10602 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010603 WE_STOP_OBSS_SCAN,
10604 0,
10605 0,
10606 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010607 {
10608 WE_DUMP_ROAM_TIMER_LOG,
10609 0,
10610 0,
10611 "dumpRoamDelay" },
10612 {
10613 WE_RESET_ROAM_TIMER_LOG,
10614 0,
10615 0,
10616 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010617 {
10618 WE_GET_FW_LOGS,
10619 0,
10620 0,
10621 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053010622 {
10623 WE_GET_FW_MEMDUMP,
10624 0,
10625 0,
10626 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010627 /* handlers for main ioctl */
10628 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10629 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10630 0,
10631 "" },
10632
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010633
10634
Jeff Johnson295189b2012-06-20 16:38:30 -070010635 /* handlers for sub-ioctl */
10636 { WE_LOG_DUMP_CMD,
10637 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10638 0,
10639 "dump" },
10640
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010641 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010642 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10643 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10644 0,
10645 "setdumplog" },
10646
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010647 { WE_MTRACE_DUMP_CMD,
10648 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10649 0,
10650 "dumplog" },
10651
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010652 /* handlers for sub ioctl */
10653 {
10654 WE_MCC_CONFIG_CREDENTIAL,
10655 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10656 0,
10657 "setMccCrdnl" },
10658
10659 /* handlers for sub ioctl */
10660 {
10661 WE_MCC_CONFIG_PARAMS,
10662 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10663 0,
10664 "setMccConfig" },
10665
Chilam NG571c65a2013-01-19 12:27:36 +053010666#ifdef FEATURE_WLAN_TDLS
10667 /* handlers for sub ioctl */
10668 {
10669 WE_TDLS_CONFIG_PARAMS,
10670 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10671 0,
10672 "setTdlsConfig" },
10673#endif
10674
Katya Nigamf0511f62015-05-05 16:40:57 +053010675 {
10676 WE_CONFIGURE_MONITOR_MODE,
10677 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10678 0,
10679 "MonitorModeConf" },
10680
10681 {
10682 WE_SET_MONITOR_MODE_FILTER,
10683 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10684 0,
10685 "MonitorFilter" },
10686
Jeff Johnson295189b2012-06-20 16:38:30 -070010687 /* handlers for main ioctl */
10688 { WLAN_PRIV_ADD_TSPEC,
10689 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10690 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10691 "addTspec" },
10692
10693 /* handlers for main ioctl */
10694 { WLAN_PRIV_DEL_TSPEC,
10695 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10696 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10697 "delTspec" },
10698
10699 /* handlers for main ioctl */
10700 { WLAN_PRIV_GET_TSPEC,
10701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10702 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10703 "getTspec" },
10704
Jeff Johnsone7245742012-09-05 17:12:55 -070010705#ifdef FEATURE_OEM_DATA_SUPPORT
10706 /* handlers for main ioctl - OEM DATA */
10707 {
10708 WLAN_PRIV_SET_OEM_DATA_REQ,
10709 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10710 0,
10711 "set_oem_data_req" },
10712
10713 /* handlers for main ioctl - OEM DATA */
10714 {
10715 WLAN_PRIV_GET_OEM_DATA_RSP,
10716 0,
10717 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10718 "get_oem_data_rsp" },
10719#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010720
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 /* handlers for main ioctl - host offload */
10722 {
10723 WLAN_PRIV_SET_HOST_OFFLOAD,
10724 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10725 0,
10726 "setHostOffload" },
10727
10728 {
10729 WLAN_GET_WLAN_STATISTICS,
10730 0,
10731 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10732 "getWlanStats" },
10733
10734 {
10735 WLAN_SET_KEEPALIVE_PARAMS,
10736 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10737 0,
10738 "setKeepAlive" },
10739#ifdef WLAN_FEATURE_PACKET_FILTERING
10740 {
10741 WLAN_SET_PACKET_FILTER_PARAMS,
10742 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10743 0,
10744 "setPktFilter" },
10745#endif
10746#ifdef FEATURE_WLAN_SCAN_PNO
10747 {
10748 WLAN_SET_PNO,
10749 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10750 0,
10751 "setpno" },
10752#endif
10753 {
10754 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010755 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010756 0,
10757 "SETBAND" },
10758 /* handlers for dynamic MC BC ioctl */
10759 {
10760 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010761 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010762 0,
10763 "setMCBCFilter" },
10764 {
10765 WLAN_PRIV_CLEAR_MCBC_FILTER,
10766 0,
10767 0,
10768 "clearMCBCFilter" },
10769 {
10770 WLAN_SET_POWER_PARAMS,
10771 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10772 0,
10773 "setpowerparams" },
10774 {
10775 WLAN_GET_LINK_SPEED,
10776 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010777 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010778};
10779
10780
10781
10782const struct iw_handler_def we_handler_def = {
10783 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10784 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10785 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10786
10787 .standard = (iw_handler *)we_handler,
10788 .private = (iw_handler *)we_private,
10789 .private_args = we_private_args,
10790 .get_wireless_stats = get_wireless_stats,
10791};
10792
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010793int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10794{
10795 v_U32_t cmd = 288; //Command to RIVA
10796 hdd_context_t *pHddCtx = NULL;
10797 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10798 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10799 /*
10800 *configMccParam : specify the bit which needs to be modified
10801 *allowed to update based on wlan_qcom_cfg.ini
10802 * configuration
10803 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10804 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10805 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10806 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10807 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10808 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10809 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10810 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10811 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10812 * Bit 9 : Reserved
10813 */
10814 switch (arg1)
10815 {
10816 //Update MCC SCHEDULE_TIME_SLICE parameter
10817 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10818 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10819 {
10820 if((arg2 >= 5) && (arg2 <= 20))
10821 {
10822 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10823 }
10824 else
10825 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010826 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010827 return 0;
10828 }
10829 }
10830 break;
10831
10832 //Update MCC MAX_NULL_SEND_TIME parameter
10833 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10834 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10835 {
10836 if((arg2 >= 1) && (arg2 <= 10))
10837 {
10838 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10839 }
10840 else
10841 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010842 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010843 return 0;
10844 }
10845 }
10846 break;
10847
10848 //Update MCC TX_EARLY_STOP_TIME parameter
10849 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10850 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10851 {
10852 if((arg2 >= 1) && (arg2 <= 10))
10853 {
10854 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10855 }
10856 else
10857 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010858 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010859 return 0;
10860 }
10861 }
10862 break;
10863
10864 //Update MCC RX_DRAIN_TIME parameter
10865 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10866 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10867 {
10868 if((arg2 >= 1) && (arg2 <= 10))
10869 {
10870 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10871 }
10872 else
10873 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010874 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010875 return 0;
10876 }
10877 }
10878 break;
10879
10880 //Update MCC CHANNEL_SWITCH_TIME parameter
10881 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10882 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10883 {
10884 if((arg2 >= 1) && (arg2 <= 20))
10885 {
10886 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10887 }
10888 else
10889 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010890 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010891 return 0;
10892 }
10893 }
10894 break;
10895
10896 //Update MCC MIN_CHANNEL_TIME parameter
10897 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10898 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10899 {
10900 if((arg2 >= 5) && (arg2 <= 20))
10901 {
10902 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10903 }
10904 else
10905 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010906 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010907 return 0;
10908 }
10909 }
10910 break;
10911
10912 //Update MCC PARK_BEFORE_TBTT parameter
10913 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10914 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10915 {
10916 if((arg2 >= 1) && (arg2 <= 5))
10917 {
10918 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10919 }
10920 else
10921 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010922 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010923 return 0;
10924 }
10925 }
10926 break;
10927
10928 //Update MCC MIN_AFTER_DTIM parameter
10929 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10930 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10931 {
10932 if((arg2 >= 5) && (arg2 <= 15))
10933 {
10934 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10935 }
10936 else
10937 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010938 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010939 return 0;
10940 }
10941 }
10942 break;
10943
10944 //Update MCC TOO_CLOSE_MARGIN parameter
10945 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10946 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10947 {
10948 if((arg2 >= 1) && (arg2 <= 3))
10949 {
10950 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10951 }
10952 else
10953 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010954 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010955 return 0;
10956 }
10957 }
10958 break;
10959
10960 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010961 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010962 __FUNCTION__,arg1);
10963 break;
10964 }
10965 return 0;
10966}
10967
Jeff Johnson295189b2012-06-20 16:38:30 -070010968int hdd_set_wext(hdd_adapter_t *pAdapter)
10969{
10970 hdd_wext_state_t *pwextBuf;
10971 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010972 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010973
10974 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10975
10976 // Now configure the roaming profile links. To SSID and bssid.
10977 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10978 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10979
10980 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10981 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10982
10983 /*Set the numOfChannels to zero to scan all the channels*/
10984 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10985 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10986
10987 /* Default is no encryption */
10988 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10989 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10990
10991 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10992 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10993
10994 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10995
10996 /* Default is no authentication */
10997 pwextBuf->roamProfile.AuthType.numEntries = 1;
10998 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10999
11000 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11001 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11002
11003 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011004 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011005
11006 hdd_clearRoamProfileIe(pAdapter);
11007
11008 return VOS_STATUS_SUCCESS;
11009
11010 }
11011
11012int hdd_register_wext(struct net_device *dev)
11013 {
11014 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11015 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11016 VOS_STATUS status;
11017
11018 ENTER();
11019
11020 // Zero the memory. This zeros the profile structure.
11021 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11022
11023 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11024
11025
11026 status = hdd_set_wext(pAdapter);
11027
11028 if(!VOS_IS_STATUS_SUCCESS(status)) {
11029
Arif Hussain6d2a3322013-11-17 19:50:10 -080011030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011031 return eHAL_STATUS_FAILURE;
11032 }
11033
11034 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11035 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011037 return eHAL_STATUS_FAILURE;
11038 }
11039
11040 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11041 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011043 return eHAL_STATUS_FAILURE;
11044 }
11045
11046 // Register as a wireless device
11047 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11048
11049 EXIT();
11050 return 0;
11051}
11052
11053int hdd_UnregisterWext(struct net_device *dev)
11054{
c_hpothu2a13bc32015-01-21 12:48:54 +053011055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11056 if (dev != NULL)
11057 {
11058 rtnl_lock();
11059 dev->wireless_handlers = NULL;
11060 rtnl_unlock();
11061 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011062
Jeff Johnson295189b2012-06-20 16:38:30 -070011063 return 0;
11064}
11065
11066