blob: 7140f24510a4107c0ca0e514beccba38234d8515 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhb3e376c2017-01-04 15:27:13 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Anand N Sunkad0a3436f2015-05-01 14:22:19 +053053#include <linux/wcnss_wlan.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053054#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <wlan_hdd_includes.h>
56#include <wlan_btc_svc.h>
57#include <wlan_nlink_common.h>
58#ifdef WLAN_BTAMP_FEATURE
59#include <bap_hdd_main.h>
60#endif
61#include <vos_api.h>
62#include <net/arp.h>
63#include "ccmApi.h"
64#include "sirParams.h"
65#include "csrApi.h"
66#include "csrInsideApi.h"
67#if defined WLAN_FEATURE_VOWIFI
68#include "smeRrmInternal.h"
69#endif
70#include <aniGlobal.h>
71#include "dot11f.h"
72#include <wlan_hdd_wowl.h>
73#include <wlan_hdd_cfg.h>
74#include <wlan_hdd_wmm.h>
75#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef CONFIG_HAS_EARLYSUSPEND
82#include <linux/earlysuspend.h>
83#endif
84#include "wlan_hdd_power.h"
85#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530107#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530108
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#ifdef CONFIG_HAS_EARLYSUSPEND
110extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
111extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
112#endif
113
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800115#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530119#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
Atul Mittalc0f739f2014-07-31 13:47:47 +0530122// tdlsoffchan
123#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530124static int tdlsOffCh = 1;
125static int tdlsOffChBwOffset = 0;
126#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530127
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700128static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/* To Validate Channel against the Frequency and Vice-Versa */
132static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
133 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
134 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
135 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
136 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
137 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
138 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
139 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800140 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
141 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700142
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800143#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700144
145/* Private ioctls and their sub-ioctls */
146#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
147#define WE_SET_11D_STATE 1
148#define WE_WOWL 2
149#define WE_SET_POWER 3
150#define WE_SET_MAX_ASSOC 4
151#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
152#define WE_SET_DATA_INACTIVITY_TO 6
153#define WE_SET_MAX_TX_POWER 7
154#define WE_SET_HIGHER_DTIM_TRANSITION 8
155#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530156#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700157#define WE_SET_MAX_TX_POWER_2_4 11
158#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800159/* Private IOCTL for debug connection issues */
160#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530161// tdlsoffchan
162#ifdef FEATURE_WLAN_TDLS
163#define WE_SET_TDLS_OFF_CHAN 14
164#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
165#define WE_SET_TDLS_OFF_CHAN_MODE 16
166#endif
Peng Xu2446a892014-09-05 17:21:18 +0530167#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530168#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530169#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530170#ifdef FEATURE_WLAN_TDLS
171#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
172#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530173#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530174#define WE_SET_MONITOR_STATE 22
Sushant Kaushik33200572015-08-05 16:46:20 +0530175#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530176#define WE_SET_PROXIMITY_ENABLE 24
Manjeet Singh3ed79242017-01-11 19:04:32 +0530177#define WE_CAP_TSF 25
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +0530178#define WE_SET_MODULATED_DTIM 26
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +0530179#define WLAN_SET_DYNNAMIC_AGGREGATION 27
Jeff Johnson295189b2012-06-20 16:38:30 -0700180
181/* Private ioctls and their sub-ioctls */
182#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
183#define WE_GET_11D_STATE 1
184#define WE_IBSS_STATUS 2
185#define WE_PMC_STATE 3
186#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700187#define WE_GET_MAX_ASSOC 6
188#define WE_GET_WDI_DBG 7
189#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
190#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530191#define WE_GET_SCAN_BAND_PREFERENCE 10
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +0530192#define WE_GET_ANTENA_DIVERSITY_SELECTION 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700193/* Private ioctls and their sub-ioctls */
194#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
195
196/* Private ioctls and their sub-ioctls */
197#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
198#define WE_WOWL_ADD_PTRN 1
199#define WE_WOWL_DEL_PTRN 2
200#if defined WLAN_FEATURE_VOWIFI
201#define WE_NEIGHBOR_REPORT_REQUEST 3
202#endif
203#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
204#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530205#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700206
207/* Private ioctls and their sub-ioctls */
208#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
209#define WE_SET_WLAN_DBG 1
210#define WE_SET_WDI_DBG 2
211#define WE_SET_SAP_CHANNELS 3
212
213/* Private ioctls and their sub-ioctls */
214#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
215#define WE_WLAN_VERSION 1
216#define WE_GET_STATS 2
217#define WE_GET_CFG 3
218#define WE_GET_WMM_STATUS 4
219#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700220#ifdef WLAN_FEATURE_11AC
221#define WE_GET_RSSI 6
222#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800223#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800224#ifdef FEATURE_WLAN_TDLS
225#define WE_GET_TDLS_PEERS 8
226#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700227#ifdef WLAN_FEATURE_11W
228#define WE_GET_11W_INFO 9
229#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530230#define WE_GET_STATES 10
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530231#ifdef WLAN_FEATURE_RMC
232#define WE_GET_IBSS_STA_INFO 11
233#endif
234#define WE_GET_SNR 12
Jeff Johnson295189b2012-06-20 16:38:30 -0700235
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530236#ifdef FEATURE_OEM_DATA_SUPPORT
237#define WE_GET_OEM_DATA_CAP 13
238#endif
239
Jeff Johnson295189b2012-06-20 16:38:30 -0700240/* Private ioctls and their sub-ioctls */
241#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
242#define WE_CLEAR_STATS 1
243#define WE_INIT_AP 2
244#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530245#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700246#define WE_ENABLE_AMP 4
247#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530248#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700249#define WE_ENABLE_DXE_STALL_DETECT 6
250#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700251#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530252#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530253#ifdef WLAN_FEATURE_RMC
254#define WE_IBSS_GET_PEER_INFO_ALL 10
255#endif
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530256#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530257#define WE_DUMP_ROAM_TIMER_LOG 12
258#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530259#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530260#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530261
Jeff Johnson295189b2012-06-20 16:38:30 -0700262/* Private ioctls and their sub-ioctls */
263#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
264#define WE_LOG_DUMP_CMD 1
265
Jeff Johnson295189b2012-06-20 16:38:30 -0700266#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800267//IOCTL to configure MCC params
268#define WE_MCC_CONFIG_CREDENTIAL 3
269#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700270
Chilam NG571c65a2013-01-19 12:27:36 +0530271#ifdef FEATURE_WLAN_TDLS
272#define WE_TDLS_CONFIG_PARAMS 5
273#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530274#ifdef WLAN_FEATURE_RMC
275#define WE_IBSS_GET_PEER_INFO 6
276#endif
Chilam NG571c65a2013-01-19 12:27:36 +0530277
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700278#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530279#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530280#define WE_CONFIGURE_MONITOR_MODE 10
281#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700282
Chilam Ng01120412013-02-19 18:32:21 -0800283#ifdef FEATURE_WLAN_TDLS
284#undef MAX_VAR_ARGS
285#define MAX_VAR_ARGS 10
286#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700287#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800288#endif
289
Jeff Johnson295189b2012-06-20 16:38:30 -0700290/* Private ioctls (with no sub-ioctls) */
291/* note that they must be odd so that they have "get" semantics */
292#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
293#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
294#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
295
Girish Gowli464c9c82014-06-09 19:47:53 +0530296/* (SIOCIWFIRSTPRIV + 8) is currently unused */
297/* (SIOCIWFIRSTPRIV + 16) is currently unused */
298/* (SIOCIWFIRSTPRIV + 10) is currently unused */
299/* (SIOCIWFIRSTPRIV + 12) is currently unused */
300/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manjeet Singh3ed79242017-01-11 19:04:32 +0530301#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
302#define WE_GET_TSF 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700303
Jeff Johnsone7245742012-09-05 17:12:55 -0700304#ifdef FEATURE_OEM_DATA_SUPPORT
305/* Private ioctls for setting the measurement configuration */
306#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
307#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
308#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700309
310#ifdef WLAN_FEATURE_VOWIFI_11R
311#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
312#endif
313
314/* Private ioctl for setting the host offload feature */
315#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
316
317/* Private ioctl to get the statistics */
318#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
319
320/* Private ioctl to set the Keep Alive Params */
321#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
322#ifdef WLAN_FEATURE_PACKET_FILTERING
323/* Private ioctl to set the Packet Filtering Params */
324#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
325#endif
326
327#ifdef FEATURE_WLAN_SCAN_PNO
328/* Private ioctl to get the statistics */
329#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
330#endif
331
332#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
333
334#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
335#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700336/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700337
Jeff Johnson295189b2012-06-20 16:38:30 -0700338#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
339#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
340
341#define WLAN_STATS_INVALID 0
342#define WLAN_STATS_RETRY_CNT 1
343#define WLAN_STATS_MUL_RETRY_CNT 2
344#define WLAN_STATS_TX_FRM_CNT 3
345#define WLAN_STATS_RX_FRM_CNT 4
346#define WLAN_STATS_FRM_DUP_CNT 5
347#define WLAN_STATS_FAIL_CNT 6
348#define WLAN_STATS_RTS_FAIL_CNT 7
349#define WLAN_STATS_ACK_FAIL_CNT 8
350#define WLAN_STATS_RTS_SUC_CNT 9
351#define WLAN_STATS_RX_DISCARD_CNT 10
352#define WLAN_STATS_RX_ERROR_CNT 11
353#define WLAN_STATS_TX_BYTE_CNT 12
354
355#define WLAN_STATS_RX_BYTE_CNT 13
356#define WLAN_STATS_RX_RATE 14
357#define WLAN_STATS_TX_RATE 15
358
Jeff Johnsone7245742012-09-05 17:12:55 -0700359#define WLAN_STATS_RX_UC_BYTE_CNT 16
360#define WLAN_STATS_RX_MC_BYTE_CNT 17
361#define WLAN_STATS_RX_BC_BYTE_CNT 18
362#define WLAN_STATS_TX_UC_BYTE_CNT 19
363#define WLAN_STATS_TX_MC_BYTE_CNT 20
364#define WLAN_STATS_TX_BC_BYTE_CNT 21
365
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800366#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
367 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
368 { \
369 *__p++ = __type; \
370 *__p++ = __size; \
371 memcpy(__p, __val, __size); \
372 __p += __size; \
373 __tlen += __size + 2; \
374 } \
375 else \
376 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800377 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800378 } \
379 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700380
381#define VERSION_VALUE_MAX_LEN 32
382
383#define TX_PER_TRACKING_DEFAULT_RATIO 5
384#define TX_PER_TRACKING_MAX_RATIO 10
385#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
386
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530387#define WLAN_ADAPTER 0
388#define P2P_ADAPTER 1
389
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530390#define TX_PWR_MIN 6
391#define TX_PWR_MAX 22
392#define TX_PWR_DEF 50
393
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +0530394/* Dynamic Aggregation */
395#define DISABLE_AGGREGATION 0
396#define ENABLE_AGGREGATION 1
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530397/*
398 * When supplicant sends SETBAND ioctl it queries for channels from
399 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
400 * This is not required if the return type from ioctl is
401 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
402 * event as part of regulatory_hint.
403 */
404enum {
405 SEND_CHANNEL_CHANGE_EVENT = 0,
406 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
407};
408
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800409/*MCC Configuration parameters */
410enum {
411 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
412 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
413 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
414 MCC_RX_DRAIN_TIME_CFG_PARAM,
415 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
416 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
417 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
418 MCC_MIN_AFTER_DTIM_CFG_PARAM,
419 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
420};
421
422int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
423 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
424
Jeff Johnson295189b2012-06-20 16:38:30 -0700425#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +0530426int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest);
Jeff Johnson295189b2012-06-20 16:38:30 -0700427#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530428static int get_fwr_memdump(struct net_device *,
429 struct iw_request_info *,
430 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700431/**---------------------------------------------------------------------------
432
Arif Hussain0273cba2014-01-07 20:58:29 -0800433 \brief mem_alloc_copy_from_user_helper -
434
435 Helper function to allocate buffer and copy user data.
436
437 \param - wrqu - Pointer to IOCTL Data.
438 len - size
439
440 \return - On Success pointer to buffer, On failure NULL
441
442 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530443void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800444{
445 u8 *ptr = NULL;
446
447 /* in order to protect the code, an extra byte is post appended to the buffer
448 * and the null termination is added. However, when allocating (len+1) byte
449 * of memory, we need to make sure that there is no uint overflow when doing
450 * addition. In theory check len < UINT_MAX protects the uint overflow. For
451 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
452 * guess, now, it is assumed that the private command buffer size is no
453 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
454 */
455 if (len > MAX_USER_COMMAND_SIZE)
456 {
457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
458 "Invalid length");
459 return NULL;
460 }
461
462 ptr = kmalloc(len + 1, GFP_KERNEL);
463 if (NULL == ptr)
464 {
465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
466 "unable to allocate memory");
467 return NULL;
468 }
469
470 if (copy_from_user(ptr, wrqu_data, len))
471 {
472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
473 "%s: failed to copy data to user buffer", __func__);
474 kfree(ptr);
475 return NULL;
476 }
477 ptr[len] = '\0';
478 return ptr;
479}
480
Girish Gowli488ef492014-06-12 18:44:33 +0530481// Function to handle and get compatible struct iw_point passed to ioctl.
482int hdd_priv_get_data(struct iw_point *p_priv_data,
483 union iwreq_data *wrqu)
484{
485 if ((NULL == p_priv_data) || (NULL == wrqu))
486 {
487 return -EINVAL;
488 }
489
490#ifdef CONFIG_COMPAT
491 if (is_compat_task())
492 {
493 struct compat_iw_point *p_compat_priv_data;
494
495 // Compat task: typecast to campat structure and copy the members.
496 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
497
498 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
499 p_priv_data->length = p_compat_priv_data->length;
500 p_priv_data->flags = p_compat_priv_data->flags;
501 }//if(is_compat_task())
502 else
503 {
504#endif //#ifdef CONFIG_COMPAT
505
506 // Non compat task: directly copy the structure.
507 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
508
509#ifdef CONFIG_COMPAT
510 }//else of - if(is_compat_task())
511#endif //#ifdef CONFIG_COMPAT
512
513 return 0;
514}
515
Arif Hussain0273cba2014-01-07 20:58:29 -0800516/**---------------------------------------------------------------------------
517
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 \brief hdd_wlan_get_version() -
519
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800520 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700521
522 \param - pAdapter Pointer to the adapter.
523 wrqu - Pointer to IOCTL REQUEST Data.
524 extra - Pointer to char
525
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800526 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700527
528 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800529void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
530 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700531{
532 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800533 tSirVersionString wcnss_SW_version;
534 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530535 tSirVersionString iris_name;
536 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800537 char *pSWversion;
538 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700540
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800541 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
542 sizeof(wcnss_SW_version));
543 if (VOS_IS_STATUS_SUCCESS(status))
544 {
545 pSWversion = wcnss_SW_version;
546 }
547 else
548 {
549 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 }
551
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800552 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
553 sizeof(wcnss_HW_version));
554 if (VOS_IS_STATUS_SUCCESS(status))
555 {
556 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800558 else
559 {
560 pHWversion = "Unknown";
561 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700562
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530563 status = wcnss_get_iris_name(iris_name);
564
565 if (!status) {
566 pIRISversion = iris_name;
567 } else {
568 pIRISversion = "Unknown";
569 }
570
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700571 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530572 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800573 QWLAN_VERSIONSTR,
574 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530575 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800576
577 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700578}
579
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530580#ifdef WLAN_FEATURE_RMC
581void hdd_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp)
582{
583 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData;
584 tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp;
585 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
586 v_U8_t i;
587
588 if (NULL != pPeerInfo && eHAL_STATUS_SUCCESS == pPeerInfo->status)
589 {
590 pStaCtx->ibss_peer_info.status = pPeerInfo->status;
591 pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers;
592 for (i = 0; i < pPeerInfo->numPeers; i++)
593 {
594 memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i],
595 &pPeerInfo->peerInfoParams[i], sizeof(hdd_ibss_peer_info_params_t));
596 }
597 }
598 else
599 {
600 hddLog(LOGE,
601 FL("PEER_INFO_CMD_STATUS is not SUCCESS"));
602 }
603
604 complete(&pAdapter->ibss_peer_info_comp);
605}
606
607v_MACADDR_t* hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter, v_U8_t staIdx)
608{
609 v_U8_t idx;
610 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
611
612 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
613 {
614 if ( 0 != pHddStaCtx->conn_info.staId[ idx ] &&
615 staIdx == pHddStaCtx->conn_info.staId[ idx ])
616 {
617 return (&pHddStaCtx->conn_info.peerMacAddress[ idx ]);
618 }
619 }
620 return NULL;
621}
622
623eHalStatus hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx)
624{
625 eHalStatus status = eHAL_STATUS_FAILURE;
626 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
627 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
628 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
629
630 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
631 VOS_FALSE, staIdx);
632
633 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
634
635 if (eHAL_STATUS_SUCCESS == status)
636 {
637 long ret;
638 ret = wait_for_completion_interruptible_timeout
639 (&pAdapter->ibss_peer_info_comp,
640 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
641 if (ret <= 0)
642 {
643 hddLog(VOS_TRACE_LEVEL_ERROR,
644 FL("failed wait on ibss_peer_info_comp %ld"), ret);
645 return eHAL_STATUS_FAILURE;
646 }
647
648 /** Print the peer info */
649 pr_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numIBSSPeers);
650 pr_info("============================================================");
651 {
652 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
653 staIdx);
654 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
655
656 if (NULL != macAddr)
657 {
658 pr_info("PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
659 MAC_ADDR_ARRAY(macAddr->bytes),
660 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[0].rssi);
661 }
662 else
663 {
664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
665 " ERROR: PEER MAC ADDRESS NOT FOUND ");
666 }
667 }
668 }
669 else
670 {
671 hddLog(VOS_TRACE_LEVEL_WARN,
672 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
673 }
674
675 return status;
676}
677
678eHalStatus hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
679{
680 eHalStatus status = eHAL_STATUS_FAILURE;
681 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
682 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
683 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
684 int i;
685
686 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
687 VOS_TRUE, 0xFF);
688 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
689
690 if (eHAL_STATUS_SUCCESS == status)
691 {
692 long ret;
693 ret = wait_for_completion_interruptible_timeout
694 (&pAdapter->ibss_peer_info_comp,
695 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
696 if (ret <= 0)
697 {
698 hddLog(VOS_TRACE_LEVEL_ERROR,
699 FL("failed wait on ibss_peer_info_comp %ld"), ret);
700 return eHAL_STATUS_FAILURE;
701 }
702
703 /** Print the peer info */
704 pr_info("pPeerInfo->numIBSSPeers = %d ", (int)pPeerInfo->numIBSSPeers);
705 pr_info("============================================================");
706 for (i = 0; i < pPeerInfo->numIBSSPeers; i++)
707 {
708 v_U8_t staIdx = pPeerInfo->ibssPeerList[i].staIdx;
709 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
710 staIdx);
711 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
712
713 pr_info("STAIDX:%d ", (int)pPeerInfo->ibssPeerList[i].staIdx);
714 if (NULL != macAddr)
715 {
716 pr_info(" PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
717 MAC_ADDR_ARRAY(macAddr->bytes),
718 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[i].rssi);
719 }
720 else
721 {
722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
723 " ERROR: PEER MAC ADDRESS NOT FOUND ");
724 }
725 }
726 }
727 else
728 {
729 hddLog(VOS_TRACE_LEVEL_WARN,
730 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
731 }
732
733 return status;
734}
735#endif /* WLAN_FEATURE_RMC */
736
Jeff Johnson295189b2012-06-20 16:38:30 -0700737int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
738{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530739 tHalHandle hHal;
740 hdd_context_t *pHddCtx;
741 v_U32_t threshold = 0;
742 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700743
744 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530745 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530746 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
748 "%s: Adapter is NULL",__func__);
749 return -EINVAL;
750 }
751
752 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
753 ret = wlan_hdd_validate_context(pHddCtx);
754 if (0 != ret)
755 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530756 return ret;
757 }
758
759 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
760 if (NULL == hHal)
761 {
762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
763 "%s: Hal Context is NULL",__func__);
764 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 }
766
767 if ( eHAL_STATUS_SUCCESS !=
768 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
769 {
c_hpothub8245442013-11-20 23:41:09 +0530770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
771 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 return -EIO;
773 }
774 wrqu->rts.value = threshold;
775
776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800777 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700778
779 EXIT();
780
781 return 0;
782}
783
784int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
785{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530786 tHalHandle hHal;
787 hdd_context_t *pHddCtx;
788 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700789
790 ENTER();
791
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530792 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530793 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
795 "%s: Adapter is NULL",__func__);
796 return -EINVAL;
797 }
798
799 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
800 status = wlan_hdd_validate_context(pHddCtx);
801 if (0 != status)
802 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530803 return status;
804 }
805
806 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
807 if (NULL == hHal)
808 {
809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
810 "%s: Hal Context is NULL",__func__);
811 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 }
813
814 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
815 != eHAL_STATUS_SUCCESS )
816 {
c_hpothub8245442013-11-20 23:41:09 +0530817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
818 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 return -EIO;
820 }
821 wrqu->frag.value = threshold;
822
823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800824 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700825
826 EXIT();
827
828 return 0;
829}
830
831int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
832{
Jeff Johnsone7245742012-09-05 17:12:55 -0700833 int i;
834 if (channel > 0)
835 {
836 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
837 {
838 if (channel == freq_chan_map[i].chan)
839 {
840 *pfreq = freq_chan_map[i].freq;
841 return 1;
842 }
843 }
844 }
845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800846 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700847 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700848}
849
850static v_BOOL_t
851hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
852{
853 v_BOOL_t rsnType = VOS_FALSE;
854 // is the authType supported?
855 switch (authType)
856 {
857 case eCSR_AUTH_TYPE_NONE: //never used
858 rsnType = eANI_BOOLEAN_FALSE;
859 break;
860 // MAC layer authentication types
861 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
862 rsnType = eANI_BOOLEAN_FALSE;
863 break;
864 case eCSR_AUTH_TYPE_SHARED_KEY:
865 rsnType = eANI_BOOLEAN_FALSE;
866 break;
867 case eCSR_AUTH_TYPE_AUTOSWITCH:
868 rsnType = eANI_BOOLEAN_FALSE;
869 break;
870
871 // Upper layer authentication types
872 case eCSR_AUTH_TYPE_WPA:
873 rsnType = eANI_BOOLEAN_TRUE;
874 break;
875 case eCSR_AUTH_TYPE_WPA_PSK:
876 rsnType = eANI_BOOLEAN_TRUE;
877 break;
878 case eCSR_AUTH_TYPE_WPA_NONE:
879 rsnType = eANI_BOOLEAN_TRUE;
880 break;
881#ifdef WLAN_FEATURE_VOWIFI_11R
882 case eCSR_AUTH_TYPE_FT_RSN:
883#endif
884 case eCSR_AUTH_TYPE_RSN:
885 rsnType = eANI_BOOLEAN_TRUE;
886 break;
887#ifdef WLAN_FEATURE_VOWIFI_11R
888 case eCSR_AUTH_TYPE_FT_RSN_PSK:
889#endif
890 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700891#ifdef WLAN_FEATURE_11W
892 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530893 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700894#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 rsnType = eANI_BOOLEAN_TRUE;
896 break;
897 //case eCSR_AUTH_TYPE_FAILED:
898 case eCSR_AUTH_TYPE_UNKNOWN:
899 rsnType = eANI_BOOLEAN_FALSE;
900 break;
901 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800902 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
903 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 rsnType = eANI_BOOLEAN_FALSE;
905 break;
906 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800907 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700908 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 return rsnType;
910}
911
912static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
913{
914 struct statsContext *pStatsContext;
915 hdd_adapter_t *pAdapter;
916
917 if (ioctl_debug)
918 {
919 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700920 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 }
922
923 if (NULL == pContext)
924 {
925 hddLog(VOS_TRACE_LEVEL_ERROR,
926 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700927 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 return;
929 }
930
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 pStatsContext = pContext;
932 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800933
934 /* there is a race condition that exists between this callback
935 function and the caller since the caller could time out either
936 before or while this code is executing. we use a spinlock to
937 serialize these actions */
938 spin_lock(&hdd_context_lock);
939
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
941 {
942 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800943 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 hddLog(VOS_TRACE_LEVEL_WARN,
945 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700946 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 if (ioctl_debug)
948 {
949 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700950 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 }
952 return;
953 }
954
Jeff Johnson72a40512013-12-19 10:14:15 -0800955 /* context is valid so caller is still waiting */
956
957 /* paranoia: invalidate the magic */
958 pStatsContext->magic = 0;
959
Sachin Ahujaa082b672015-10-05 19:51:31 +0530960 /* copy over the rssi.FW will return RSSI as -100
961 * if there are no samples to calculate the average
962 * RSSI
963 */
964 if (rssi != -100)
965 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530966 if (pAdapter->rssi > 0)
967 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800968 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800970
971 /* serialization is complete */
972 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700973}
974
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530975static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
976{
977 struct statsContext *pStatsContext;
978 hdd_adapter_t *pAdapter;
979
980 if (ioctl_debug)
981 {
982 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
983 __func__, (int)snr, (int)staId, pContext);
984 }
985
986 if (NULL == pContext)
987 {
988 hddLog(VOS_TRACE_LEVEL_ERROR,
989 "%s: Bad param, pContext [%p]",
990 __func__, pContext);
991 return;
992 }
993
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530994 pStatsContext = pContext;
995 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800996
997 /* there is a race condition that exists between this callback
998 function and the caller since the caller could time out either
999 before or while this code is executing. we use a spinlock to
1000 serialize these actions */
1001 spin_lock(&hdd_context_lock);
1002
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301003 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
1004 {
1005 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001006 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301007 hddLog(VOS_TRACE_LEVEL_WARN,
1008 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1009 __func__, pAdapter, pStatsContext->magic);
1010 if (ioctl_debug)
1011 {
1012 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1013 __func__, pAdapter, pStatsContext->magic);
1014 }
1015 return;
1016 }
1017
Jeff Johnson72a40512013-12-19 10:14:15 -08001018 /* context is valid so caller is still waiting */
1019
1020 /* paranoia: invalidate the magic */
1021 pStatsContext->magic = 0;
1022
1023 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301024 pAdapter->snr = snr;
1025
Jeff Johnson72a40512013-12-19 10:14:15 -08001026 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301027 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001028
1029 /* serialization is complete */
1030 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301031}
1032
Jeff Johnson295189b2012-06-20 16:38:30 -07001033VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1034{
1035 struct statsContext context;
1036 hdd_context_t *pHddCtx;
1037 hdd_station_ctx_t *pHddStaCtx;
1038 eHalStatus hstatus;
1039 long lrc;
1040
1041 if (NULL == pAdapter)
1042 {
1043 hddLog(VOS_TRACE_LEVEL_WARN,
1044 "%s: Invalid context, pAdapter", __func__);
1045 return VOS_STATUS_E_FAULT;
1046 }
1047 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1048 {
1049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1050 /* return a cached value */
1051 *rssi_value = pAdapter->rssi;
1052 return VOS_STATUS_SUCCESS;
1053 }
1054
1055 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1056 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1057
mukul sharma8aec69b2015-06-10 22:28:43 +05301058 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1059 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
1061 __func__, pAdapter->rssi_on_disconnect);
1062 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +05301063 return VOS_STATUS_SUCCESS;
1064 }
1065
1066 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1067 {
1068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1069 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1070 *rssi_value = pAdapter->rssi;
1071 return VOS_STATUS_SUCCESS;
1072 }
1073
Jeff Johnson295189b2012-06-20 16:38:30 -07001074 init_completion(&context.completion);
1075 context.pAdapter = pAdapter;
1076 context.magic = RSSI_CONTEXT_MAGIC;
1077
1078 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
1079 pHddStaCtx->conn_info.staId[ 0 ],
1080 pHddStaCtx->conn_info.bssId,
1081 &context, pHddCtx->pvosContext);
1082 if (eHAL_STATUS_SUCCESS != hstatus)
1083 {
1084 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001085 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 /* we'll returned a cached value below */
1087 }
1088 else
1089 {
1090 /* request was sent -- wait for the response */
1091 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1092 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 if (lrc <= 0)
1094 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001095 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001096 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 /* we'll now returned a cached value below */
1098 }
1099 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001100
1101 /* either we never sent a request, we sent a request and received a
1102 response or we sent a request and timed out. if we never sent a
1103 request or if we sent a request and got a response, we want to
1104 clear the magic out of paranoia. if we timed out there is a
1105 race condition such that the callback function could be
1106 executing at the same time we are. of primary concern is if the
1107 callback function had already verified the "magic" but had not
1108 yet set the completion variable when a timeout occurred. we
1109 serialize these activities by invalidating the magic while
1110 holding a shared spinlock which will cause us to block if the
1111 callback is currently executing */
1112 spin_lock(&hdd_context_lock);
1113 context.magic = 0;
1114 spin_unlock(&hdd_context_lock);
1115
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 *rssi_value = pAdapter->rssi;
Rajeev Kumar Sirasanagandla4819c182016-11-28 22:25:48 +05301117 hddLog(VOS_TRACE_LEVEL_INFO,
1118 "%s: RSSI = %d", __func__, *rssi_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07001119
1120 return VOS_STATUS_SUCCESS;
1121}
Siddharth Bhal64246172015-02-27 01:04:37 +05301122/**---------------------------------------------------------------------------
1123
1124 \brief wlan_hdd_get_frame_logs() -
1125
1126 This function use to get Frames log.
1127
1128 \param - pAdapter Pointer to the adapter.
1129 flag - Specify type of request. Clear and Send request are
1130 supported.
1131
1132 \return - none
1133
1134 --------------------------------------------------------------------------*/
1135VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
1136{
Siddharth Bhal64246172015-02-27 01:04:37 +05301137 hdd_context_t *pHddCtx;
1138 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +05301139
1140 if (NULL == pAdapter)
1141 {
1142 hddLog(VOS_TRACE_LEVEL_WARN,
1143 "%s: Invalid context, pAdapter", __func__);
1144 return VOS_STATUS_E_FAULT;
1145 }
1146
1147 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1148 if (!pHddCtx->mgmt_frame_logging)
1149 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05301150 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +05301151 return VOS_STATUS_E_AGAIN;
1152 }
1153
Siddharth Bhal4507c262015-04-29 20:20:42 +05301154 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1155 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1156 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301157 {
1158 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1159 return VOS_STATUS_E_INVAL;
1160 }
1161
Siddharth Bhal4507c262015-04-29 20:20:42 +05301162 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1163 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1164 {
1165 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1166 return VOS_STATUS_E_INVAL;
1167 }
1168
Abhishek Singh611295e2015-07-09 11:11:54 +05301169 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +05301170 if (eHAL_STATUS_SUCCESS != hstatus)
1171 {
1172 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +05301173 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301174 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301175
1176 return VOS_STATUS_SUCCESS;
1177}
1178
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301179
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301180VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1181{
1182 struct statsContext context;
1183 hdd_context_t *pHddCtx;
1184 hdd_station_ctx_t *pHddStaCtx;
1185 eHalStatus hstatus;
1186 long lrc;
1187 int valid;
1188
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301189 ENTER();
1190
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301191 if (NULL == pAdapter)
1192 {
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 "%s: Invalid context, pAdapter", __func__);
1195 return VOS_STATUS_E_FAULT;
1196 }
1197
1198 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1199
1200 valid = wlan_hdd_validate_context(pHddCtx);
1201 if (0 != valid)
1202 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301203 return VOS_STATUS_E_FAULT;
1204 }
1205
1206 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1207 if (NULL == pHddStaCtx)
1208 {
1209 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1210 return VOS_STATUS_E_FAULT;
1211 }
1212
1213 init_completion(&context.completion);
1214 context.pAdapter = pAdapter;
1215 context.magic = SNR_CONTEXT_MAGIC;
1216
1217 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1218 pHddStaCtx->conn_info.staId[ 0 ],
1219 pHddStaCtx->conn_info.bssId,
1220 &context);
1221 if (eHAL_STATUS_SUCCESS != hstatus)
1222 {
1223 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1224 __func__);
1225 /* we'll returned a cached value below */
1226 }
1227 else
1228 {
1229 /* request was sent -- wait for the response */
1230 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1231 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301232 if (lrc <= 0)
1233 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001234 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301235 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301236 /* we'll now returned a cached value below */
1237 }
1238 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001239
1240 /* either we never sent a request, we sent a request and received a
1241 response or we sent a request and timed out. if we never sent a
1242 request or if we sent a request and got a response, we want to
1243 clear the magic out of paranoia. if we timed out there is a
1244 race condition such that the callback function could be
1245 executing at the same time we are. of primary concern is if the
1246 callback function had already verified the "magic" but had not
1247 yet set the completion variable when a timeout occurred. we
1248 serialize these activities by invalidating the magic while
1249 holding a shared spinlock which will cause us to block if the
1250 callback is currently executing */
1251 spin_lock(&hdd_context_lock);
1252 context.magic = 0;
1253 spin_unlock(&hdd_context_lock);
1254
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301255 *snr = pAdapter->snr;
1256
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301257 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301258 return VOS_STATUS_SUCCESS;
1259}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301260
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001261#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001262
1263static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1264{
1265 struct statsContext *pStatsContext;
1266 hdd_adapter_t *pAdapter;
1267 if (ioctl_debug)
1268 {
1269 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1270 __func__, (int)rssi, (int)staId, pContext);
1271 }
1272
1273 if (NULL == pContext)
1274 {
1275 hddLog(VOS_TRACE_LEVEL_ERROR,
1276 "%s: Bad param, pContext [%p]",
1277 __func__, pContext);
1278 return;
1279 }
1280
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001281 pStatsContext = pContext;
1282 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001283
1284 /* there is a race condition that exists between this callback
1285 function and the caller since the caller could time out either
1286 before or while this code is executing. we use a spinlock to
1287 serialize these actions */
1288 spin_lock(&hdd_context_lock);
1289
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001290 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1291 {
1292 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001293 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001294 hddLog(VOS_TRACE_LEVEL_WARN,
1295 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1296 __func__, pAdapter, pStatsContext->magic);
1297 if (ioctl_debug)
1298 {
1299 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1300 __func__, pAdapter, pStatsContext->magic);
1301 }
1302 return;
1303 }
1304
Jeff Johnson72a40512013-12-19 10:14:15 -08001305 /* context is valid so caller is still waiting */
1306
1307 /* paranoia: invalidate the magic */
1308 pStatsContext->magic = 0;
1309
Sachin Ahujaa082b672015-10-05 19:51:31 +05301310 /* copy over the rssi.FW will return RSSI as -100
1311 * if there are no samples to calculate the average
1312 * RSSI
1313 */
1314 if (rssi != -100)
1315 pAdapter->rssi = rssi;
1316
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301317 if (pAdapter->rssi > 0)
1318 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001319 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001320 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001321
1322 /* serialization is complete */
1323 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001324}
1325
1326
1327
1328VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1329{
1330 struct statsContext context;
1331 hdd_context_t *pHddCtx = NULL;
1332 hdd_station_ctx_t *pHddStaCtx = NULL;
1333 eHalStatus hstatus;
1334 long lrc;
1335
1336 if (NULL == pAdapter)
1337 {
1338 hddLog(VOS_TRACE_LEVEL_WARN,
1339 "%s: Invalid context, pAdapter", __func__);
1340 return VOS_STATUS_E_FAULT;
1341 }
1342 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1343 {
1344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1345 /* return a cached value */
1346 *rssi_value = pAdapter->rssi;
1347 return VOS_STATUS_SUCCESS;
1348 }
1349
1350 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1351 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1352
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301353 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001354 {
1355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1356 /* return a cached value */
1357 *rssi_value = 0;
1358 return VOS_STATUS_SUCCESS;
1359 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301360
1361 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1362 {
1363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1364 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1365 *rssi_value = pAdapter->rssi;
1366 return VOS_STATUS_SUCCESS;
1367 }
1368
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001369 init_completion(&context.completion);
1370 context.pAdapter = pAdapter;
1371 context.magic = RSSI_CONTEXT_MAGIC;
1372
1373 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1374 pHddStaCtx->conn_info.staId[ 0 ],
1375 pHddStaCtx->conn_info.bssId,
1376 &context, pHddCtx->pvosContext);
1377 if (eHAL_STATUS_SUCCESS != hstatus)
1378 {
1379 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1380 __func__);
1381 /* we'll returned a cached value below */
1382 }
1383 else
1384 {
1385 /* request was sent -- wait for the response */
1386 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1387 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001388 if (lrc <= 0)
1389 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001390 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001391 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001392 /* we'll now returned a cached value below */
1393 }
1394 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001395
1396 /* either we never sent a request, we sent a request and received a
1397 response or we sent a request and timed out. if we never sent a
1398 request or if we sent a request and got a response, we want to
1399 clear the magic out of paranoia. if we timed out there is a
1400 race condition such that the callback function could be
1401 executing at the same time we are. of primary concern is if the
1402 callback function had already verified the "magic" but had not
1403 yet set the completion variable when a timeout occurred. we
1404 serialize these activities by invalidating the magic while
1405 holding a shared spinlock which will cause us to block if the
1406 callback is currently executing */
1407 spin_lock(&hdd_context_lock);
1408 context.magic = 0;
1409 spin_unlock(&hdd_context_lock);
1410
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001411 *rssi_value = pAdapter->rssi;
1412
1413 return VOS_STATUS_SUCCESS;
1414}
1415#endif
1416
1417
Jeff Johnson295189b2012-06-20 16:38:30 -07001418void hdd_StatisticsCB( void *pStats, void *pContext )
1419{
1420 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1421 hdd_stats_t *pStatsCache = NULL;
1422 hdd_wext_state_t *pWextState;
1423 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1424
1425 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1426 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1427 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1428 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1429 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1430 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1431
1432 if (pAdapter!= NULL)
1433 pStatsCache = &pAdapter->hdd_stats;
1434
1435
1436 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1437 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1438 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1439 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1440 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1441 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1442
1443 if (pStatsCache!=NULL)
1444 {
1445 // and copy the stats into the cache we keep in the adapter instance structure
1446 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1447 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1448 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1449 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1450 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1451 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1452 }
1453
1454 if(pAdapter)
1455 {
1456 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1457 if(pWextState)
1458 {
1459 vos_status = vos_event_set(&pWextState->vosevent);
1460 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1461 {
1462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001463 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 return;
1465 }
1466 }
1467 }
1468}
1469
1470void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1471{
1472 v_CONTEXT_t pVosContext;
1473 hdd_context_t *pHddCtx;
1474 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1475#if 0
1476 hdd_wext_state_t *pWextState;
1477 v_U32_t roamId;
1478#endif
1479
1480 ENTER();
1481
1482 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1483
1484 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1485 if (NULL == pHddCtx)
1486 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001487 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 return;
1489 }
1490#if 0
1491 pWextState = pAdapter->pWextState;
1492#endif
1493
1494 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1495 {
1496 //TODO Verify is this is really used. If yes need to fix it.
1497 hdd_reconnect_all_adapters( pHddCtx );
1498#if 0
1499 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1500 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1501 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1502
1503 if(VOS_STATUS_SUCCESS == vosStatus)
1504 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1505 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1506
1507 sme_RoamConnect(halHandle,
1508 pAdapter->sessionId, &(pWextState->roamProfile),
1509 &roamId);
1510#endif
1511 }
1512
1513 EXIT();
1514
1515}
1516
1517void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1518{
Jeff Johnson295189b2012-06-20 16:38:30 -07001519 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1520
1521 /* clear WPA/RSN/WSC IE information in the profile */
1522 pWextState->roamProfile.nWPAReqIELength = 0;
1523 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1524 pWextState->roamProfile.nRSNReqIELength = 0;
1525 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1526
Chet Lanctot186b5732013-03-18 10:26:30 -07001527#ifdef FEATURE_WLAN_WAPI
1528 pWextState->roamProfile.nWAPIReqIELength = 0;
1529 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1530#endif
1531
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001533 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301535 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1537 pWextState->roamProfile.nAddIEAssocLength = 0;
1538
1539 pWextState->roamProfile.EncryptionType.numEntries = 1;
1540 pWextState->roamProfile.EncryptionType.encryptionType[0]
1541 = eCSR_ENCRYPT_TYPE_NONE;
1542
1543 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1544 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1545 = eCSR_ENCRYPT_TYPE_NONE;
1546
1547 pWextState->roamProfile.AuthType.numEntries = 1;
1548 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1549
Abhishek Singhb3e376c2017-01-04 15:27:13 +05301550 vos_mem_zero((pWextState->roamProfile.bssid_hint), WNI_CFG_BSSID_LEN);
Chet Lanctot186b5732013-03-18 10:26:30 -07001551#ifdef WLAN_FEATURE_11W
1552 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1553 pWextState->roamProfile.MFPRequired = 0;
1554 pWextState->roamProfile.MFPCapable = 0;
1555#endif
1556
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 pWextState->authKeyMgmt = 0;
1558
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301559 vos_mem_zero(&pWextState->roamProfile.Keys,
1560 sizeof(pWextState->roamProfile.Keys));
1561
Jeff Johnson295189b2012-06-20 16:38:30 -07001562#ifdef FEATURE_WLAN_WAPI
1563 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1564 pAdapter->wapi_info.nWapiMode = 0;
1565#endif
1566
1567 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1568
1569}
1570
1571void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1572{
1573 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001574
Nirav Shahf6bd2672015-03-11 12:53:15 +05301575 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001576 {
1577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301578 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001579 }
1580 else
1581 {
1582 complete(&pAdapter->ula_complete);
1583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001584}
1585
1586VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1587{
1588 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001590 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001591
1592 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1593 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001594 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001595
1596 /*To avoid race condition between the set key and the last EAPOL
1597 packet, notify TL to finish upper layer authentication incase if the
1598 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001599 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001600
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001601 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 {
1603 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1604 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1605 __LINE__, vos_status );
1606 return vos_status;
1607
1608 }
1609
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001610 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301612 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001613 {
1614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301615 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001616 /* we'll still fall through and return success since the
1617 * connection may still get established but is just taking
1618 * too long for us to wait */
1619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 }
1621 return VOS_STATUS_SUCCESS;
1622}
1623
1624v_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)
1625{
1626
1627 int left = ie_len;
1628 v_U8_t *ptr = ie;
1629 v_U8_t elem_id,elem_len;
1630 v_U8_t eid = 0xDD;
1631
1632 if ( NULL == ie || 0 == ie_len )
1633 return NULL;
1634
1635 while(left >= 2)
1636 {
1637 elem_id = ptr[0];
1638 elem_len = ptr[1];
1639 left -= 2;
1640 if(elem_len > left)
1641 {
1642 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001643 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001644 eid,elem_len,left);
1645 return NULL;
1646 }
1647 if (elem_id == eid)
1648 {
1649 if(memcmp( &ptr[2], oui, oui_size)==0)
1650 return ptr;
1651 }
1652
1653 left -= elem_len;
1654 ptr += (elem_len + 2);
1655 }
1656 return NULL;
1657}
1658
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301659static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 union iwreq_data *wrqu, char *extra)
1661{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301662 hdd_adapter_t *pAdapter;
1663 hdd_context_t *pHddCtx;
1664 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301665
1666 ENTER();
1667
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301668 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1669 if (NULL == pAdapter)
1670 {
1671 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1672 "%s: pAdapter is NULL\n", __func__);
1673 return -EINVAL;
1674 }
1675 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1676 ret = wlan_hdd_validate_context(pHddCtx);
1677 if (0 != ret)
1678 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301679 return ret;
1680 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301681
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301683
1684 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301685 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001686}
1687
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301688static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1689 union iwreq_data *wrqu, char *extra)
1690{
1691 int ret;
1692
1693 vos_ssr_protect(__func__);
1694 ret = __iw_set_commit(dev, info, wrqu, extra);
1695 vos_ssr_unprotect(__func__);
1696
1697 return ret;
1698}
1699
1700static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 struct iw_request_info *info,
1702 char *wrqu, char *extra)
1703{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301704 hdd_adapter_t *pAdapter;
1705 hdd_context_t *pHddCtx;
1706 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301707
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301709 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1710 if (NULL == pAdapter)
1711 {
1712 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1713 "%s: pAdapter is NULL\n", __func__);
1714 return -EINVAL;
1715 }
1716 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1717 ret = wlan_hdd_validate_context(pHddCtx);
1718 if (0 != ret)
1719 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301720 return ret;
1721 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1723 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301724 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001725}
1726
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301727static int iw_get_name(struct net_device *dev,
1728 struct iw_request_info *info,
1729 char *wrqu, char *extra)
1730{
1731 int ret;
1732
1733 vos_ssr_protect(__func__);
1734 ret = __iw_get_name(dev, info, wrqu, extra);
1735 vos_ssr_unprotect(__func__);
1736
1737 return ret;
1738}
1739
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301740static int __iw_set_mode(struct net_device *dev,
1741 struct iw_request_info *info,
1742 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001743{
1744 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301745 hdd_adapter_t *pAdapter;
1746 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 tCsrRoamProfile *pRoamProfile;
1748 eCsrRoamBssType LastBSSType;
1749 eMib_dot11DesiredBssType connectedBssType;
1750 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301752 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001753
1754 ENTER();
1755
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301756 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 if (NULL == pAdapter)
1758 {
1759 hddLog(VOS_TRACE_LEVEL_WARN,
1760 "%s: Invalid context, pAdapter", __func__);
1761 return 0;
1762 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301763 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1764 status = wlan_hdd_validate_context(pHddCtx);
1765 if (0 != status)
1766 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301767 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 }
1769
1770 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1771 if (pWextState == NULL)
1772 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301773 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 return -EINVAL;
1775 }
1776
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 pRoamProfile = &pWextState->roamProfile;
1779 LastBSSType = pRoamProfile->BSSType;
1780
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301781 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001782
1783 switch (wrqu->mode)
1784 {
1785 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301786 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1788 // Set the phymode correctly for IBSS.
1789 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1790 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001791 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 break;
1794 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301795 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 break;
1799 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301800 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1802 break;
1803 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301804 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 return -EOPNOTSUPP;
1806 }
1807
1808 if ( LastBSSType != pRoamProfile->BSSType )
1809 {
1810 //the BSS mode changed
1811 // We need to issue disconnect if connected or in IBSS disconnect state
1812 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1813 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1814 {
1815 VOS_STATUS vosStatus;
1816 // need to issue a disconnect to CSR.
1817 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1818 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1819 pAdapter->sessionId,
1820 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1821 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301822 {
1823 long ret;
1824 ret = wait_for_completion_interruptible_timeout(
1825 &pAdapter->disconnect_comp_var,
1826 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1827 if (ret <= 0)
1828 hddLog(VOS_TRACE_LEVEL_ERROR,
1829 FL("failed wait on disconnect_comp_var %ld"), ret);
1830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 }
1832 }
1833
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 EXIT();
1835 return 0;
1836}
1837
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301838static int iw_set_mode(struct net_device *dev,
1839 struct iw_request_info *info,
1840 union iwreq_data *wrqu, char *extra)
1841{
1842 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001843
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301844 vos_ssr_protect(__func__);
1845 ret = __iw_set_mode(dev, info, wrqu, extra);
1846 vos_ssr_unprotect(__func__);
1847
1848 return ret;
1849}
1850
1851static int __iw_get_mode(struct net_device *dev,
1852 struct iw_request_info *info,
1853 union iwreq_data *wrqu,
1854 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001855{
1856
1857 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301858 hdd_adapter_t *pAdapter;
1859 hdd_context_t *pHddCtx;
1860 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001861
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301862 ENTER();
1863
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301864 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 if (NULL == pAdapter)
1866 {
1867 hddLog(VOS_TRACE_LEVEL_WARN,
1868 "%s: Invalid context, pAdapter", __func__);
1869 return 0;
1870 }
1871
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301872 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1873 ret = wlan_hdd_validate_context(pHddCtx);
1874 if (0 != ret)
1875 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301876 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1879 if (pWextState == NULL)
1880 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301881 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 return -EINVAL;
1883 }
1884
1885 switch (pWextState->roamProfile.BSSType)
1886 {
1887 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001888 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301889 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 break;
1891 case eCSR_BSS_TYPE_IBSS:
1892 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001893 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301894 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 break;
1896 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001897 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301898 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 break;
1900 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001901 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001902 break;
1903 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301904
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301905 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 return 0;
1907}
1908
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301909static int iw_get_mode(struct net_device *dev,
1910 struct iw_request_info *info,
1911 union iwreq_data *wrqu,
1912 char *extra)
1913{
1914 int ret;
1915
1916 vos_ssr_protect(__func__);
1917 ret = __iw_get_mode(dev, info, wrqu, extra);
1918 vos_ssr_unprotect(__func__);
1919
1920 return ret;
1921}
1922
1923static int __iw_set_freq(struct net_device *dev,
1924 struct iw_request_info *info,
1925 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001926{
1927 v_U32_t numChans = 0;
1928 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1929 v_U32_t indx = 0;
1930 v_U32_t status = 0;
1931
1932 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301933 hdd_adapter_t *pAdapter;
1934 hdd_context_t *pHddCtx;
1935 tHalHandle hHal;
1936 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301938
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 ENTER();
1940
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301941 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1942 if (NULL == pAdapter)
1943 {
1944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1945 "%s:Invalid Adapter",__func__);
1946 return -EINVAL;
1947 }
1948
1949 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1950 status = wlan_hdd_validate_context(pHddCtx);
1951 if (0 != status)
1952 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 return status;
1954 }
1955
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301956 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1957 if (NULL == hHal)
1958 {
1959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1960 "%s: Hal Context is NULL",__func__);
1961 return -EINVAL;
1962 }
1963
1964 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1965 if (NULL == pHddStaCtx)
1966 {
1967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1968 "%s:STA context is NULL",__func__);
1969 return -EINVAL;
1970 }
1971
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301973 if (NULL == pWextState)
1974 {
1975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1976 "%s: pWextState is NULL",__func__);
1977 return -EINVAL;
1978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001979
1980 pRoamProfile = &pWextState->roamProfile;
1981
Arif Hussain6d2a3322013-11-17 19:50:10 -08001982 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001983
1984 /* Link is up then return cant set channel*/
1985 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1986 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1987 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001988 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 return -EOPNOTSUPP;
1990 }
1991
1992 /* Settings by Frequency as input */
1993 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1994 (wrqu->freq.m <= (tANI_U32)5.825e8))
1995 {
1996 tANI_U32 freq = wrqu->freq.m / 100000;
1997
1998 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1999 indx++;
2000 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
2001 {
2002 return -EINVAL;
2003 }
2004 wrqu->freq.e = 0;
2005 wrqu->freq.m = freq_chan_map[indx].chan;
2006
2007 }
2008
2009 if (wrqu->freq.e == 0)
2010 {
2011 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2012 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
2013 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002014 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002015 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 WNI_CFG_CURRENT_CHANNEL_STAMAX);
2017 return -EINVAL;
2018 }
2019
2020 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2021
2022 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2023 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05302024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2025 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 return -EIO;
2027 }
2028
2029 for (indx = 0; indx < numChans; indx++) {
2030 if (wrqu->freq.m == validChan[indx]){
2031 break;
2032 }
2033 }
2034 }
2035 else{
2036
2037 return -EINVAL;
2038 }
2039
2040 if(indx >= numChans)
2041 {
2042 return -EINVAL;
2043 }
2044
2045 /* Set the Operational Channel */
2046 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2047 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2048 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
2049
Arif Hussain6d2a3322013-11-17 19:50:10 -08002050 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07002051
2052 EXIT();
2053
2054 return status;
2055}
2056
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302057static int iw_set_freq(struct net_device *dev,
2058 struct iw_request_info *info,
2059 union iwreq_data *wrqu, char *extra)
2060{
2061 int ret;
2062
2063 vos_ssr_protect(__func__);
2064 ret = __iw_set_freq(dev, info, wrqu, extra);
2065 vos_ssr_unprotect(__func__);
2066
2067 return ret;
2068}
2069
2070static int __iw_get_freq(struct net_device *dev,
2071 struct iw_request_info *info,
2072 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002073{
Jeff Johnsone7245742012-09-05 17:12:55 -07002074 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302075 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 tHalHandle hHal;
2077 hdd_wext_state_t *pWextState;
2078 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302079 hdd_station_ctx_t *pHddStaCtx;
2080 hdd_context_t *pHddCtx;
2081 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002082
2083 ENTER();
2084
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302085 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2086 if (NULL == pAdapter)
2087 {
2088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2089 "%s: Adapter is NULL", __func__);
2090 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302092 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2093 ret = wlan_hdd_validate_context(pHddCtx);
2094 if (0 != ret)
2095 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302096 return ret;
2097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302099 if (NULL == hHal)
2100 {
2101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2102 "%s: Hal Context is NULL",__func__);
2103 return -EINVAL;
2104 }
2105 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2106 if (NULL == pHddStaCtx)
2107 {
2108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2109 "%s: HddStaCtx is NULL", __func__);
2110 return -EINVAL;
2111 }
2112 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2113 if (NULL == pWextState)
2114 {
2115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2116 "%s: pWextState is NULL",__func__);
2117 return -EINVAL;
2118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 pRoamProfile = &pWextState->roamProfile;
2120
2121 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
2122 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002123 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 {
c_hpothub8245442013-11-20 23:41:09 +05302125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2126 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 return -EIO;
2128 }
2129 else
2130 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002131 status = hdd_wlan_get_freq(channel, &freq);
2132 if( TRUE == status )
2133 {
2134 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2135 * iwlist & iwconfig command shows frequency into proper
2136 * format (2.412 GHz instead of 246.2 MHz)*/
2137 fwrq->m = freq;
2138 fwrq->e = MHZ;
2139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 }
2141 }
2142 else
2143 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07002144 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2145 * iwlist & iwconfig command shows frequency into proper
2146 * format (2.412 GHz instead of 246.2 MHz)*/
2147 fwrq->m = 0;
2148 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302150
2151 EXIT();
2152 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002153}
2154
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302155static int iw_get_freq(struct net_device *dev,
2156 struct iw_request_info *info,
2157 struct iw_freq *fwrq, char *extra)
2158{
2159 int ret;
2160
2161 vos_ssr_protect(__func__);
2162 ret = __iw_get_freq(dev, info, fwrq, extra);
2163 vos_ssr_unprotect(__func__);
2164
2165 return ret;
2166}
2167
2168static int __iw_get_tx_power(struct net_device *dev,
2169 struct iw_request_info *info,
2170 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002171{
2172
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302173 hdd_adapter_t *pAdapter;
2174 hdd_context_t *pHddCtx;
2175 hdd_station_ctx_t *pHddStaCtx;
2176 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002177
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302178 ENTER();
2179
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302180 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2181 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2184 "%s: Adapter is NULL",__func__);
2185 return -EINVAL;
2186 }
2187 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2188 ret = wlan_hdd_validate_context(pHddCtx);
2189 if (0 != ret)
2190 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302191 return ret;
2192 }
2193
2194 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2195 if (NULL == pHddStaCtx)
2196 {
2197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2198 "%s: STA Context is NULL",__func__);
2199 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 }
2201
2202 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2203 {
2204 wrqu->txpower.value = 0;
2205 return 0;
2206 }
2207 wlan_hdd_get_classAstats(pAdapter);
2208 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2209
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302210 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 return 0;
2212}
2213
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302214static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 struct iw_request_info *info,
2216 union iwreq_data *wrqu, char *extra)
2217{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302218 int ret;
2219
2220 vos_ssr_protect(__func__);
2221 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2222 vos_ssr_unprotect(__func__);
2223
2224 return ret;
2225}
2226
2227static int __iw_set_tx_power(struct net_device *dev,
2228 struct iw_request_info *info,
2229 union iwreq_data *wrqu, char *extra)
2230{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302231 hdd_adapter_t *pAdapter;
2232 tHalHandle hHal;
2233 hdd_context_t *pHddCtx;
2234 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002235
2236 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302237 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2238 if (NULL == pAdapter)
2239 {
2240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2241 "%s: Adapter is NULL",__func__);
2242 return -EINVAL;
2243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002244
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302245 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2246 ret = wlan_hdd_validate_context(pHddCtx);
2247 if (0 != ret)
2248 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302249 return ret;
2250 }
2251
2252 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2253 if (NULL == hHal)
2254 {
2255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2256 "%s: Hal Context is NULL",__func__);
2257 return -EINVAL;
2258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2260 {
c_hpothub8245442013-11-20 23:41:09 +05302261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2262 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 return -EIO;
2264 }
2265
2266 EXIT();
2267
2268 return 0;
2269}
2270
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302271static int iw_set_tx_power(struct net_device *dev,
2272 struct iw_request_info *info,
2273 union iwreq_data *wrqu, char *extra)
2274{
2275 int ret;
2276
2277 vos_ssr_protect(__func__);
2278 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2279 vos_ssr_unprotect(__func__);
2280
2281 return ret;
2282}
2283
2284static int __iw_get_bitrate(struct net_device *dev,
2285 struct iw_request_info *info,
2286 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002287{
2288 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2289 eHalStatus status = eHAL_STATUS_SUCCESS;
2290 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302291 hdd_adapter_t *pAdapter;
2292 hdd_context_t *pHddCtx;
2293 hdd_station_ctx_t *pHddStaCtx;
2294 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002295
2296 ENTER();
2297
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302298 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2299 if (NULL == pAdapter)
2300 {
2301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2302 "%s: Adapter is NULL",__func__);
2303 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 }
2305
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302306 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2307 ret = wlan_hdd_validate_context(pHddCtx);
2308 if (0 != ret)
2309 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302310 return ret;
2311 }
2312
2313 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2314 if (NULL == pHddStaCtx)
2315 {
2316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2317 "%s: STA Context is NULL",__func__);
2318 return -EINVAL;
2319 }
2320
2321 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 wrqu->bitrate.value = 0;
2323 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302324 else
2325 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2327 SME_SUMMARY_STATS |
2328 SME_GLOBAL_CLASSA_STATS |
2329 SME_GLOBAL_CLASSB_STATS |
2330 SME_GLOBAL_CLASSC_STATS |
2331 SME_GLOBAL_CLASSD_STATS |
2332 SME_PER_STA_STATS,
2333 hdd_StatisticsCB, 0, FALSE,
2334 pHddStaCtx->conn_info.staId[0], pAdapter );
2335
2336 if(eHAL_STATUS_SUCCESS != status)
2337 {
2338 hddLog(VOS_TRACE_LEVEL_ERROR,
2339 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002340 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 return status;
2342 }
2343
2344 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302345 if (NULL == pWextState)
2346 {
2347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2348 "%s: pWextState is NULL",__func__);
2349 return -EINVAL;
2350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002351
2352 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2353
2354 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2355 {
2356 hddLog(VOS_TRACE_LEVEL_ERROR,
2357 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002358 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 return VOS_STATUS_E_FAILURE;
2360 }
2361
2362 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2363 }
2364
2365 EXIT();
2366
2367 return vos_status;
2368}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302369
2370static int iw_get_bitrate(struct net_device *dev,
2371 struct iw_request_info *info,
2372 union iwreq_data *wrqu, char *extra)
2373{
2374 int ret;
2375
2376 vos_ssr_protect(__func__);
2377 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2378 vos_ssr_unprotect(__func__);
2379
2380 return ret;
2381}
2382
2383
Jeff Johnson295189b2012-06-20 16:38:30 -07002384/* ccm call back function */
2385
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302386static int __iw_set_bitrate(struct net_device *dev,
2387 struct iw_request_info *info,
2388 union iwreq_data *wrqu,
2389 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002390{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302391 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302393 hdd_station_ctx_t *pHddStaCtx;
2394 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2396 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2397 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2398 v_U32_t i, rate;
2399 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302400 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002401
2402 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302403 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2404 if (NULL == pAdapter)
2405 {
2406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2407 "%s: Adapter is NULL",__func__);
2408 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 }
2410
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302411 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2412 ret = wlan_hdd_validate_context(pHddCtx);
2413 if (0 != ret)
2414 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302415 return ret;
2416 }
2417
2418 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2419 if (NULL == pHddStaCtx)
2420 {
2421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2422 "%s: STA Context is NULL",__func__);
2423 return -EINVAL;
2424 }
2425
2426
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302428 if (NULL == pWextState)
2429 {
2430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2431 "%s: pWextState is NULL",__func__);
2432 return -EINVAL;
2433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002434
2435 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2436 {
2437 return -ENXIO ;
2438 }
2439
2440 rate = wrqu->bitrate.value;
2441
2442 if (rate == -1)
2443 {
2444 rate = WNI_CFG_FIXED_RATE_AUTO;
2445 valid_rate = TRUE;
2446 }
2447 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2448 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2449 {
2450 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2451 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2452 {
2453 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2454 WNI_CFG_SUPPORTED_RATES_11A,
2455 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2456 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2457 WNI_CFG_SUPPORTED_RATES_11B,
2458 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2459 {
2460 for (i = 0; i < (b_len + a_len); ++i)
2461 {
2462 /* supported rates returned is double the actual rate so we divide it by 2 */
2463 if ((supp_rates[i]&0x7F)/2 == rate)
2464 {
2465 valid_rate = TRUE;
2466 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2467 break;
2468 }
2469 }
2470 }
2471 }
2472 }
2473 if (valid_rate != TRUE)
2474 {
2475 return -EINVAL;
2476 }
2477 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2478 WNI_CFG_FIXED_RATE, rate,
2479 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2480 {
c_hpothub8245442013-11-20 23:41:09 +05302481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2482 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 return -EIO;
2484 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302485
2486 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 return 0;
2488}
2489
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302490static int iw_set_bitrate(struct net_device *dev,
2491 struct iw_request_info *info,
2492 union iwreq_data *wrqu,
2493 char *extra)
2494{
2495 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002496
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302497 vos_ssr_protect(__func__);
2498 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2499 vos_ssr_unprotect(__func__);
2500
2501 return ret;
2502}
2503
2504static int __iw_set_genie(struct net_device *dev,
2505 struct iw_request_info *info,
2506 union iwreq_data *wrqu,
2507 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002508{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302509 hdd_adapter_t *pAdapter;
2510 hdd_context_t *pHddCtx;
2511 hdd_wext_state_t *pWextState;
2512 u_int8_t *genie = NULL;
2513 u_int8_t *base_genie = NULL;
2514 v_U16_t remLen;
2515 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002516
2517 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002518
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302519 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2520 if (NULL == pAdapter)
2521 {
2522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2523 "%s: Adapter is NULL",__func__);
2524 return -EINVAL;
2525 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002526
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302527 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2528 ret = wlan_hdd_validate_context(pHddCtx);
2529 if (0 != ret)
2530 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302531 return ret;
2532 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002533
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302534 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2535 if (NULL == pWextState)
2536 {
2537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2538 "%s: pWextState is NULL",__func__);
2539 return -EINVAL;
2540 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002541
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302542 if (!wrqu->data.length) {
2543 hdd_clearRoamProfileIe(pAdapter);
2544 EXIT();
2545 return 0;
2546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002547
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302548 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2549 wrqu->data.length);
2550 if (NULL == base_genie)
2551 {
2552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2553 "mem_alloc_copy_from_user_helper fail");
2554 return -ENOMEM;
2555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002556
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302557 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002558
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302559 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002560
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302561 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2562
2563 /* clear any previous genIE before this call */
2564 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2565
2566 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 {
2568 v_U16_t eLen = 0;
2569 v_U8_t elementId;
2570 elementId = *genie++;
2571 eLen = *genie++;
2572 remLen -= 2;
2573
Arif Hussain6d2a3322013-11-17 19:50:10 -08002574 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 __func__, elementId, eLen);
2576
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302577 if (remLen < eLen) {
2578 hddLog(LOGE, "Remaining len: %u less than ie len: %u",
2579 remLen, eLen);
2580 ret = -EINVAL;
2581 goto exit;
2582 }
2583
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 switch ( elementId )
2585 {
2586 case IE_EID_VENDOR:
2587 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002588 {
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302589 ret = -EINVAL;
2590 goto exit;
Arif Hussain24bfa702014-01-22 13:51:30 -08002591 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002592
2593 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2594 {
2595 v_U16_t curGenIELen = pWextState->genIE.length;
2596 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2597 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2598
2599 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2600 {
2601 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002602 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302604 ret = -EINVAL;
2605 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 }
2607 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2608 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2609 pWextState->genIE.length += eLen + 2;
2610 }
2611 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2612 {
2613 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302614 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2615 {
2616 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2617 "Need bigger buffer space");
2618 ret = -EINVAL;
2619 VOS_ASSERT(0);
2620 goto exit;
2621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2623 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2624 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2625 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2626 }
2627 else /* any vendorId except WPA IE should be accumulated to genIE */
2628 {
2629 v_U16_t curGenIELen = pWextState->genIE.length;
2630 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2631 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2632
2633 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2634 {
2635 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002636 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 VOS_ASSERT(0);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302638 ret = -ENOMEM;
2639 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 }
2641 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2642 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2643 pWextState->genIE.length += eLen + 2;
2644 }
2645 break;
2646 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002647 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302648 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE)))
2649 {
2650 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
2651 "Need bigger buffer space");
2652 ret = -EINVAL;
2653 VOS_ASSERT(0);
2654 goto exit;
2655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2657 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2658 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2659 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2660 break;
2661
2662 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002663 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302664 goto exit;
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 remLen -= eLen;
Pothula Hanumantha Reddyf5278fc2016-12-28 17:55:19 +05302667
2668 /* Move genie only if next element is present */
2669 if (remLen >= 2)
2670 genie += eLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302672
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302673exit:
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002675 kfree(base_genie);
Mahesh A Saptasagar73730f02015-10-28 13:08:42 +05302676 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002677}
2678
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302679static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 struct iw_request_info *info,
2681 union iwreq_data *wrqu,
2682 char *extra)
2683{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302684 int ret;
2685
2686 vos_ssr_protect(__func__);
2687 ret = __iw_set_genie(dev, info, wrqu, extra);
2688 vos_ssr_unprotect(__func__);
2689
2690 return ret;
2691}
2692
2693static int __iw_get_genie(struct net_device *dev,
2694 struct iw_request_info *info,
2695 union iwreq_data *wrqu,
2696 char *extra)
2697{
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302699 hdd_context_t *pHddCtx;
2700 hdd_adapter_t *pAdapter;
2701 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 eHalStatus status;
2703 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2704 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2705
2706 ENTER();
2707
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302708 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2709 if (NULL == pAdapter)
2710 {
2711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2712 "%s: Adapter is NULL",__func__);
2713 return -EINVAL;
2714 }
2715 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2716 status = wlan_hdd_validate_context(pHddCtx);
2717 if (0 != status)
2718 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302719 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 }
2721
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302723 if (NULL == pWextState)
2724 {
2725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2726 "%s: pWextState is NULL",__func__);
2727 return -EINVAL;
2728 }
2729
2730 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2731 if (NULL == pHddStaCtx)
2732 {
2733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2734 "%s: STA Context is NULL",__func__);
2735 return -EINVAL;
2736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002737
2738 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2739 {
2740 return -ENXIO;
2741 }
2742
2743 // Return something ONLY if we are associated with an RSN or WPA network
2744 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2745 pWextState->roamProfile.negotiatedAuthType))
2746 {
2747 return -ENXIO;
2748 }
2749
2750 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2751 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2752 pAdapter->sessionId,
2753 &length,
2754 genIeBytes);
Manjeet Singh715d47e2016-08-02 19:08:02 +05302755 if (eHAL_STATUS_SUCCESS != status) {
2756 hddLog(LOGE, FL("failed to get WPA-RSN IE data"));
Arif Hussain7adce1b2013-11-11 22:59:34 -08002757 return -EFAULT;
2758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002759
Manjeet Singh715d47e2016-08-02 19:08:02 +05302760 wrqu->data.length = length;
2761 if (length > DOT11F_IE_RSN_MAX_LEN) {
2762 hddLog(LOGE,
2763 FL("invalid buffer length length:%d"), length);
2764 return -E2BIG;
2765 }
2766
2767 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
2768
2769 hddLog(LOG1, FL("RSN IE of %d bytes returned"), wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002770
2771 EXIT();
2772
2773 return 0;
2774}
2775
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302776static int iw_get_genie(struct net_device *dev,
2777 struct iw_request_info *info,
2778 union iwreq_data *wrqu,
2779 char *extra)
2780{
2781 int ret;
2782
2783 vos_ssr_protect(__func__);
2784 ret = __iw_get_genie(dev, info, wrqu, extra);
2785 vos_ssr_unprotect(__func__);
2786
2787 return ret;
2788}
2789
2790
2791static int __iw_get_encode(struct net_device *dev,
2792 struct iw_request_info *info,
2793 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002794{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302795 hdd_adapter_t *pAdapter;
2796 hdd_context_t *pHddCtx;
2797 hdd_wext_state_t *pWextState;
2798 tCsrRoamProfile *pRoamProfile;
2799 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002801
2802 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302803 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2804 if (NULL == pAdapter)
2805 {
2806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2807 "%s: Adapter is NULL",__func__);
2808 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 }
2810
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302811 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2812 ret = wlan_hdd_validate_context(pHddCtx);
2813 if (0 != ret)
2814 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302815 return ret;
2816 }
2817 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2818 if (NULL == pWextState)
2819 {
2820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2821 "%s: pWextState is NULL",__func__);
2822 return -EINVAL;
2823 }
2824
2825 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 keyId = pRoamProfile->Keys.defaultIndex;
2827
2828 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2829 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002830 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 return -EINVAL;
2832 }
2833
2834 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2835 {
2836 dwrq->flags |= IW_ENCODE_ENABLED;
2837 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2838 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2839
2840 dwrq->flags |= (keyId + 1);
2841
2842 }
2843 else
2844 {
2845 dwrq->flags |= IW_ENCODE_DISABLED;
2846 }
2847
2848 for(i=0; i < MAX_WEP_KEYS; i++)
2849 {
2850 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2851 {
2852 continue;
2853 }
2854 else
2855 {
2856 break;
2857 }
2858 }
2859
2860 if(MAX_WEP_KEYS == i)
2861 {
2862 dwrq->flags |= IW_ENCODE_NOKEY;
2863 }
2864
2865 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2866
2867 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2868 {
2869 dwrq->flags |= IW_ENCODE_OPEN;
2870 }
2871 else
2872 {
2873 dwrq->flags |= IW_ENCODE_RESTRICTED;
2874 }
2875 EXIT();
2876 return 0;
2877}
2878
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302879static int iw_get_encode(struct net_device *dev,
2880 struct iw_request_info *info,
2881 struct iw_point *dwrq, char *extra)
2882{
2883 int ret;
2884
2885 vos_ssr_protect(__func__);
2886 ret = __iw_get_encode(dev, info, dwrq, extra);
2887 vos_ssr_unprotect(__func__);
2888
2889 return ret;
2890}
2891
Jeff Johnson295189b2012-06-20 16:38:30 -07002892#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2893#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2894
2895
2896/*
2897 * This function sends a single 'key' to LIM at all time.
2898 */
2899
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302900static int __iw_get_rts_threshold(struct net_device *dev,
2901 struct iw_request_info *info,
2902 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002903{
2904 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2905 v_U32_t status = 0;
2906
2907 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2908
2909 return status;
2910}
2911
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302912static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 struct iw_request_info *info,
2914 union iwreq_data *wrqu, char *extra)
2915{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302916 int ret;
2917
2918 vos_ssr_protect(__func__);
2919 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2920 vos_ssr_unprotect(__func__);
2921
2922 return ret;
2923}
2924
2925static int __iw_set_rts_threshold(struct net_device *dev,
2926 struct iw_request_info *info,
2927 union iwreq_data *wrqu, char *extra)
2928{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302929 hdd_adapter_t *pAdapter;
2930 hdd_context_t *pHddCtx;
2931 tHalHandle hHal;
2932 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002933
2934 ENTER();
2935
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302936 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2937 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002938 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2940 "%s: Adapter is NULL",__func__);
2941 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002942 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302943
2944 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2945 ret = wlan_hdd_validate_context(pHddCtx);
2946 if (0 != ret)
2947 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302948 return ret;
2949 }
2950
2951 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2952 if (NULL == hHal)
2953 {
2954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2955 "%s: Hal Context is NULL",__func__);
2956 return -EINVAL;
2957 }
2958
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2960 {
2961 return -EINVAL;
2962 }
2963
2964 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2965 {
c_hpothub8245442013-11-20 23:41:09 +05302966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2967 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 return -EIO;
2969 }
2970
2971 EXIT();
2972
2973 return 0;
2974}
2975
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302976static int iw_set_rts_threshold(struct net_device *dev,
2977 struct iw_request_info *info,
2978 union iwreq_data *wrqu, char *extra)
2979{
2980 int ret;
2981
2982 vos_ssr_protect(__func__);
2983 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2984 vos_ssr_unprotect(__func__);
2985
2986 return ret;
2987}
2988
2989static int __iw_get_frag_threshold(struct net_device *dev,
2990 struct iw_request_info *info,
2991 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002992{
2993 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2994 v_U32_t status = 0;
2995
2996 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2997
2998 return status;
2999}
3000
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303001static int iw_get_frag_threshold(struct net_device *dev,
3002 struct iw_request_info *info,
3003 union iwreq_data *wrqu, char *extra)
3004{
3005 int ret;
3006
3007 vos_ssr_protect(__func__);
3008 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3009 vos_ssr_unprotect(__func__);
3010
3011 return ret;
3012}
3013
3014static int __iw_set_frag_threshold(struct net_device *dev,
3015 struct iw_request_info *info,
3016 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003017{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303018 hdd_adapter_t *pAdapter;
3019 hdd_context_t *pHddCtx;
3020 tHalHandle hHal;
3021 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003022
3023 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303024 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3025 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003026 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3028 "%s: Adapter is NULL",__func__);
3029 return -EINVAL;
3030 }
3031
3032 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3033 ret = wlan_hdd_validate_context(pHddCtx);
3034 if (0 != ret)
3035 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303036 return ret;
3037 }
3038
3039 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3040 if (NULL == hHal)
3041 {
3042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3043 "%s: Hal Context is NULL",__func__);
3044 return -EINVAL;
3045 }
3046
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
3048 {
3049 return -EINVAL;
3050 }
3051
3052 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3053 {
c_hpothub8245442013-11-20 23:41:09 +05303054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3055 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 return -EIO;
3057 }
3058
3059 EXIT();
3060
3061 return 0;
3062}
3063
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303064static int iw_set_frag_threshold(struct net_device *dev,
3065 struct iw_request_info *info,
3066 union iwreq_data *wrqu, char *extra)
3067{
3068 int ret;
3069
3070 vos_ssr_protect(__func__);
3071 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3072 vos_ssr_unprotect(__func__);
3073
3074 return ret;
3075}
3076
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303077static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 struct iw_request_info *info,
3079 union iwreq_data *wrqu, char *extra)
3080{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303081 hdd_adapter_t *pAdapter;
3082 hdd_context_t *pHddCtx;
3083 int ret = 0;
3084
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303086 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3087 if (NULL == pAdapter)
3088 {
3089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3090 "%s: Adapter is NULL",__func__);
3091 return -EINVAL;
3092 }
3093 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3094 ret = wlan_hdd_validate_context(pHddCtx);
3095 if (0 != ret)
3096 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303097 return ret;
3098 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303099
3100 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 return -EOPNOTSUPP;
3102}
3103
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303104static int iw_get_power_mode(struct net_device *dev,
3105 struct iw_request_info *info,
3106 union iwreq_data *wrqu, char *extra)
3107{
3108 int ret;
3109
3110 vos_ssr_protect(__func__);
3111 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3112 vos_ssr_unprotect(__func__);
3113
3114 return ret;
3115}
3116static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 struct iw_request_info *info,
3118 union iwreq_data *wrqu, char *extra)
3119{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303120 hdd_adapter_t *pAdapter;
3121 hdd_context_t *pHddCtx;
3122 int ret = 0;
3123
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303125 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3126 if (NULL == pAdapter)
3127 {
3128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3129 "%s: Adapter is NULL",__func__);
3130 return -EINVAL;
3131 }
3132 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3133 ret = wlan_hdd_validate_context(pHddCtx);
3134 if (0 != ret)
3135 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303136 return ret;
3137 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303138
3139 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 return -EOPNOTSUPP;
3141}
3142
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303143static int iw_set_power_mode(struct net_device *dev,
3144 struct iw_request_info *info,
3145 union iwreq_data *wrqu, char *extra)
3146{
3147 int ret;
3148
3149 vos_ssr_protect(__func__);
3150 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3151 vos_ssr_unprotect(__func__);
3152
3153 return ret;
3154}
3155
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303156static int __iw_get_range(struct net_device *dev,
3157 struct iw_request_info *info,
3158 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003159{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303160 hdd_adapter_t *pAdapter;
3161 tHalHandle hHal;
3162 hdd_context_t *pHddCtx;
3163 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 struct iw_range *range = (struct iw_range *) extra;
3165
3166 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3167
3168 v_U32_t num_channels = sizeof(channels);
3169 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3170 v_U32_t a_len;
3171 v_U32_t b_len;
3172 v_U32_t active_phy_mode = 0;
3173 v_U8_t index = 0, i;
3174
3175 ENTER();
3176
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303177 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3178 if (NULL == pAdapter)
3179 {
3180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3181 "%s: pAdapter is NULL", __func__);
3182 return -EINVAL;
3183 }
3184 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3185 ret = wlan_hdd_validate_context(pHddCtx);
3186 if (0 != ret)
3187 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303188 return ret;
3189 }
3190 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3191 if (NULL == hHal)
3192 {
3193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3194 "%s: pAdapter is NULL", __func__);
3195 return -EINVAL;
3196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 wrqu->data.length = sizeof(struct iw_range);
3198 memset(range, 0, sizeof(struct iw_range));
3199
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 /*Get the phy mode*/
3201 if (ccmCfgGetInt(hHal,
3202 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3203 {
3204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003205 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003206
3207 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3208 {
3209 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003210 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 if (ccmCfgGetStr(hHal,
3212 WNI_CFG_SUPPORTED_RATES_11A,
3213 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3214 {
3215 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3216 {
3217 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3218 }
3219 for (i = 0; i < a_len; i++)
3220 {
3221 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3222 }
3223 range->num_bitrates = a_len;
3224 }
3225 else
3226 {
3227 return -EIO;
3228 }
3229 }
3230 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3231 {
3232 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003233 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 if (ccmCfgGetStr(hHal,
3235 WNI_CFG_SUPPORTED_RATES_11B,
3236 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3237 {
3238 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3239 {
3240 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3241 }
3242 for (i = 0; i < b_len; i++)
3243 {
3244 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3245 }
3246 range->num_bitrates = b_len;
3247 }
3248 else
3249 {
3250 return -EIO;
3251 }
3252 }
3253 }
3254
3255 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3256 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3257 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3258
3259 range->encoding_size[0] = 5;
3260 range->encoding_size[1] = 13;
3261 range->num_encoding_sizes = 2;
3262 range->max_encoding_tokens = MAX_WEP_KEYS;
3263
3264 // we support through Wireless Extensions 22
3265 range->we_version_compiled = WIRELESS_EXT;
3266 range->we_version_source = 22;
3267
3268 /*Supported Channels and Frequencies*/
3269 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3270 {
c_hpothub8245442013-11-20 23:41:09 +05303271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3272 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 return -EIO;
3274 }
3275 if (num_channels > IW_MAX_FREQUENCIES)
3276 {
3277 num_channels = IW_MAX_FREQUENCIES;
3278 }
3279
3280 range->num_channels = num_channels;
3281 range->num_frequency = num_channels;
3282
3283 for (index=0; index < num_channels; index++)
3284 {
3285 v_U32_t frq_indx = 0;
3286
3287 range->freq[index].i = channels[index];
3288 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3289 {
3290 if(channels[index] == freq_chan_map[frq_indx].chan)
3291 {
3292 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3293 range->freq[index].e = 1;
3294 break;
3295 }
3296 frq_indx++;
3297 }
3298 }
3299
3300 /* Event capability (kernel + driver) */
3301 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3302 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3303 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3304 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3305
3306 /*Encryption capability*/
3307 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3308 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3309
3310 /* Txpower capability */
3311 range->txpower_capa = IW_TXPOW_MWATT;
3312
3313 /*Scanning capability*/
3314 #if WIRELESS_EXT >= 22
3315 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3316 #endif
3317
3318 EXIT();
3319 return 0;
3320}
3321
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303322static int iw_get_range(struct net_device *dev,
3323 struct iw_request_info *info,
3324 union iwreq_data *wrqu, char *extra)
3325{
3326 int ret;
3327
3328 vos_ssr_protect(__func__);
3329 ret = __iw_get_range(dev, info, wrqu, extra);
3330 vos_ssr_unprotect(__func__);
3331
3332 return ret;
3333}
3334
Jeff Johnson295189b2012-06-20 16:38:30 -07003335/* Callback function registered with PMC to know status of PMC request */
3336static void iw_power_callback_fn (void *pContext, eHalStatus status)
3337{
3338 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003339
3340 if (NULL == pContext)
3341 {
3342 hddLog(VOS_TRACE_LEVEL_ERROR,
3343 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003344 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 return;
3346 }
3347
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003349
Jeff Johnson72a40512013-12-19 10:14:15 -08003350 /* there is a race condition that exists between this callback
3351 function and the caller since the caller could time out either
3352 before or while this code is executing. we use a spinlock to
3353 serialize these actions */
3354 spin_lock(&hdd_context_lock);
3355
3356 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 {
3358 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003359 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003361 "%s: Invalid context, magic [%08x]",
3362 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003363
3364 if (ioctl_debug)
3365 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003366 pr_info("%s: Invalid context, magic [%08x]\n",
3367 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 }
3369 return;
3370 }
3371
Jeff Johnson72a40512013-12-19 10:14:15 -08003372 /* context is valid so caller is still waiting */
3373
3374 /* paranoia: invalidate the magic */
3375 pStatsContext->magic = 0;
3376
3377 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003379
3380 /* serialization is complete */
3381 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003382}
3383
3384/* Callback function for tx per hit */
3385void hdd_tx_per_hit_cb (void *pCallbackContext)
3386{
3387 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3388 unsigned char tx_fail[16];
3389 union iwreq_data wrqu;
3390
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303391 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003393 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 return;
3395 }
3396 memset(&wrqu, 0, sizeof(wrqu));
3397 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3398 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3399}
3400
3401void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3402{
3403 struct statsContext *pStatsContext;
3404 tCsrGlobalClassAStatsInfo *pClassAStats;
3405 hdd_adapter_t *pAdapter;
3406
3407 if (ioctl_debug)
3408 {
3409 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003410 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 }
3412
3413 if ((NULL == pStats) || (NULL == pContext))
3414 {
3415 hddLog(VOS_TRACE_LEVEL_ERROR,
3416 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003417 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 return;
3419 }
3420
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 pClassAStats = pStats;
3422 pStatsContext = pContext;
3423 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003424
3425 /* there is a race condition that exists between this callback
3426 function and the caller since the caller could time out either
3427 before or while this code is executing. we use a spinlock to
3428 serialize these actions */
3429 spin_lock(&hdd_context_lock);
3430
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3432 {
3433 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003434 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 hddLog(VOS_TRACE_LEVEL_WARN,
3436 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003437 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 if (ioctl_debug)
3439 {
3440 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003441 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 }
3443 return;
3444 }
3445
Jeff Johnson72a40512013-12-19 10:14:15 -08003446 /* context is valid so caller is still waiting */
3447
3448 /* paranoia: invalidate the magic */
3449 pStatsContext->magic = 0;
3450
3451 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3453
Jeff Johnson72a40512013-12-19 10:14:15 -08003454 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003456
3457 /* serialization is complete */
3458 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003459}
3460
3461VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3462{
3463 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3464 eHalStatus hstatus;
3465 long lrc;
3466 struct statsContext context;
3467
3468 if (NULL == pAdapter)
3469 {
3470 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3471 return VOS_STATUS_E_FAULT;
3472 }
3473 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3474 {
3475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3476 return VOS_STATUS_SUCCESS;
3477 }
3478
3479 /* we are connected
3480 prepare our callback context */
3481 init_completion(&context.completion);
3482 context.pAdapter = pAdapter;
3483 context.magic = STATS_CONTEXT_MAGIC;
3484 /* query only for Class A statistics (which include link speed) */
3485 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3486 eCSR_HDD,
3487 SME_GLOBAL_CLASSA_STATS,
3488 hdd_GetClassA_statisticsCB,
3489 0, // not periodic
3490 FALSE, //non-cached results
3491 pHddStaCtx->conn_info.staId[0],
3492 &context);
3493 if (eHAL_STATUS_SUCCESS != hstatus)
3494 {
3495 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003496 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003497 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 /* we'll returned a cached value below */
3499 }
3500 else
3501 {
3502 /* request was sent -- wait for the response */
3503 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3504 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 if (lrc <= 0)
3506 {
3507 hddLog(VOS_TRACE_LEVEL_ERROR,
3508 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003509 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 }
3511 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003512
3513 /* either we never sent a request, we sent a request and received a
3514 response or we sent a request and timed out. if we never sent a
3515 request or if we sent a request and got a response, we want to
3516 clear the magic out of paranoia. if we timed out there is a
3517 race condition such that the callback function could be
3518 executing at the same time we are. of primary concern is if the
3519 callback function had already verified the "magic" but had not
3520 yet set the completion variable when a timeout occurred. we
3521 serialize these activities by invalidating the magic while
3522 holding a shared spinlock which will cause us to block if the
3523 callback is currently executing */
3524 spin_lock(&hdd_context_lock);
3525 context.magic = 0;
3526 spin_unlock(&hdd_context_lock);
3527
3528 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 return VOS_STATUS_SUCCESS;
3530}
3531
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003532static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3533{
3534 struct statsContext *pStatsContext;
3535 tCsrSummaryStatsInfo *pSummaryStats;
3536 tCsrGlobalClassAStatsInfo *pClassAStats;
3537 hdd_adapter_t *pAdapter;
3538
3539 if (ioctl_debug)
3540 {
3541 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003542 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003543 }
3544
3545 if ((NULL == pStats) || (NULL == pContext))
3546 {
3547 hddLog(VOS_TRACE_LEVEL_ERROR,
3548 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003549 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003550 return;
3551 }
3552
Jeff Johnson72a40512013-12-19 10:14:15 -08003553 /* there is a race condition that exists between this callback
3554 function and the caller since the caller could time out either
3555 before or while this code is executing. we use a spinlock to
3556 serialize these actions */
3557 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003558
3559 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3560 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3561 pStatsContext = pContext;
3562 pAdapter = pStatsContext->pAdapter;
3563 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3564 {
3565 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003566 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003567 hddLog(VOS_TRACE_LEVEL_WARN,
3568 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003569 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003570 if (ioctl_debug)
3571 {
3572 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003573 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003574 }
3575 return;
3576 }
3577
Jeff Johnson72a40512013-12-19 10:14:15 -08003578 /* context is valid so caller is still waiting */
3579
3580 /* paranoia: invalidate the magic */
3581 pStatsContext->magic = 0;
3582
3583 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003584 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3585 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3586
Jeff Johnson72a40512013-12-19 10:14:15 -08003587 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003588 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003589
3590 /* serialization is complete */
3591 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003592}
3593
3594VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3595{
3596 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3597 eHalStatus hstatus;
3598 long lrc;
3599 struct statsContext context;
3600
3601 if (NULL == pAdapter)
3602 {
3603 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3604 return VOS_STATUS_SUCCESS;
3605 }
3606
3607 /* we are connected
3608 prepare our callback context */
3609 init_completion(&context.completion);
3610 context.pAdapter = pAdapter;
3611 context.magic = STATS_CONTEXT_MAGIC;
3612
3613 /* query only for Summary & Class A statistics */
3614 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3615 eCSR_HDD,
3616 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303617 SME_GLOBAL_CLASSA_STATS |
3618 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003619 hdd_get_station_statisticsCB,
3620 0, // not periodic
3621 FALSE, //non-cached results
3622 pHddStaCtx->conn_info.staId[0],
3623 &context);
3624 if (eHAL_STATUS_SUCCESS != hstatus)
3625 {
3626 hddLog(VOS_TRACE_LEVEL_ERROR,
3627 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003628 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003629 /* we'll return with cached values */
3630 }
3631 else
3632 {
3633 /* request was sent -- wait for the response */
3634 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3635 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003636
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003637 if (lrc <= 0)
3638 {
3639 hddLog(VOS_TRACE_LEVEL_ERROR,
3640 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003641 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003642 }
3643 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003644
3645 /* either we never sent a request, we sent a request and received a
3646 response or we sent a request and timed out. if we never sent a
3647 request or if we sent a request and got a response, we want to
3648 clear the magic out of paranoia. if we timed out there is a
3649 race condition such that the callback function could be
3650 executing at the same time we are. of primary concern is if the
3651 callback function had already verified the "magic" but had not
3652 yet set the completion variable when a timeout occurred. we
3653 serialize these activities by invalidating the magic while
3654 holding a shared spinlock which will cause us to block if the
3655 callback is currently executing */
3656 spin_lock(&hdd_context_lock);
3657 context.magic = 0;
3658 spin_unlock(&hdd_context_lock);
3659
3660 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003661 return VOS_STATUS_SUCCESS;
3662}
3663
3664
Jeff Johnson295189b2012-06-20 16:38:30 -07003665/*
3666 * Support for the LINKSPEED private command
3667 * Per the WiFi framework the response must be of the form
3668 * "LinkSpeed xx"
3669 */
3670static int iw_get_linkspeed(struct net_device *dev,
3671 struct iw_request_info *info,
3672 union iwreq_data *wrqu, char *extra)
3673{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303674 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303675 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303677 int len = sizeof(v_U32_t) + 1;
3678 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303679 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303680 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303681 int rc, valid = 0;
3682
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303683 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303684 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3685 if (NULL == pAdapter)
3686 {
3687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3688 "%s: Adapter is NULL",__func__);
3689 return -EINVAL;
3690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003691
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303692 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303693 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303694 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003695 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303696 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003697 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303698 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3699 if (NULL == pHddStaCtx)
3700 {
3701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3702 "%s: STA Context is NULL",__func__);
3703 return -EINVAL;
3704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3706 {
3707 /* we are not connected so we don't have a classAstats */
3708 link_speed = 0;
3709 }
3710 else
3711 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303712 status = wlan_hdd_get_classAstats(pAdapter);
3713
3714 if (!VOS_IS_STATUS_SUCCESS(status ))
3715 {
3716 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3717 return -EINVAL;
3718 }
3719
3720 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3721 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3722 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3723 &link_speed);
3724
3725 link_speed = link_speed / 10;
3726
3727 if (0 == link_speed)
3728 {
3729 /* The linkspeed returned by HAL is in units of 500kbps.
3730 * converting it to mbps.
3731 * This is required to support legacy firmware which does
3732 * not return link capacity.
3733 */
3734 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3735 }
3736
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 }
3738
3739 wrqu->data.length = len;
3740 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003741 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 if ((rc < 0) || (rc >= len))
3743 {
3744 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303745 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 return -EIO;
3747 }
3748
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303749 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003751 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003752}
3753
Arif Hussain695279c2014-03-24 14:06:07 -07003754/*
3755 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3756 *
3757 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303758static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003759 struct iw_request_info *info,
3760 union iwreq_data *wrqu, char *extra)
3761{
3762 int rc;
3763
3764 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3765
3766 if (rc < 0)
3767 return rc;
3768
3769 /* a value is being successfully returned */
3770 return 0;
3771}
Jeff Johnson295189b2012-06-20 16:38:30 -07003772
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303773static int iw_get_linkspeed_priv(struct net_device *dev,
3774 struct iw_request_info *info,
3775 union iwreq_data *wrqu, char *extra)
3776{
3777 int ret;
3778
3779 vos_ssr_protect(__func__);
3780 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3781 vos_ssr_unprotect(__func__);
3782
3783 return ret;
3784}
3785
Jeff Johnson295189b2012-06-20 16:38:30 -07003786/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303787 * Support for the RSSI & RSSI-APPROX private commands
3788 * Per the WiFi framework the response must be of the form
3789 * "<ssid> rssi <xx>"
3790 * unless we are not associated, in which case the response is
3791 * "OK"
3792 */
3793static int iw_get_rssi(struct net_device *dev,
3794 struct iw_request_info *info,
3795 union iwreq_data *wrqu, char *extra)
3796{
3797 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3798 char *cmd = extra;
3799 int len = wrqu->data.length;
3800 v_S7_t s7Rssi = 0;
3801 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3802 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3803 VOS_STATUS vosStatus;
3804 int rc;
3805
3806 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3807 (0 == ssidlen) || (ssidlen >= len))
3808 {
3809 /* we are not connected or our SSID is too long
3810 so we cannot report an rssi */
3811 rc = scnprintf(cmd, len, "OK");
3812 }
3813 else
3814 {
3815 /* we are connected with a valid SSID
3816 so we can write the SSID into the return buffer
3817 (note that it is not NUL-terminated) */
3818 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3819
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303820 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303821 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3822
3823 if (VOS_STATUS_SUCCESS == vosStatus)
3824 {
3825 /* append the rssi to the ssid in the format required by
3826 the WiFI Framework */
3827 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3828 rc += ssidlen;
3829 }
3830 else
3831 {
3832 rc = -1;
3833 }
3834 }
3835
3836 /* verify that we wrote a valid response */
3837 if ((rc < 0) || (rc >= len))
3838 {
3839 // encoding or length error?
3840 hddLog(VOS_TRACE_LEVEL_ERROR,
3841 "%s: Unable to encode RSSI, got [%s]",
3842 __func__, cmd);
3843 return -EIO;
3844 }
3845
3846 /* a value is being successfully returned */
3847 return rc;
3848}
3849
3850/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 * Support for SoftAP channel range private command
3852 */
3853static int iw_softap_set_channel_range( struct net_device *dev,
3854 int startChannel,
3855 int endChannel,
3856 int band)
3857{
Jeff Johnson43971f52012-07-17 12:26:56 -07003858 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003859 int ret = 0;
3860 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3861 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003862 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3863
Jeff Johnson295189b2012-06-20 16:38:30 -07003864
3865 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3866 if (VOS_STATUS_SUCCESS != status)
3867 {
3868 ret = -EINVAL;
3869 }
Yathish9f22e662012-12-10 14:21:35 -08003870 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 return ret;
3872}
3873
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303874static uint8 chartohex(char c)
3875{
3876 uint8 val = 0;
3877 if (c >= '0' && c <= '9')
3878 val = c - '0';
3879 else if (c >= 'a' && c <= 'f')
3880 val = c - 'a' + 10;
3881 else if (c >= 'A' && c <= 'F')
3882 val = c - 'A' + 10;
3883 else
3884 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3885
3886 return val;
3887}
3888
3889uint8 getByte(char **buf)
3890{
3891 uint8 byte = 0;
3892 char *temp = *buf;
3893 byte = chartohex(*temp) * 16;
3894 temp++;
3895 byte += chartohex(*temp);
3896 temp++;
3897 *buf = temp;
3898 return byte;
3899}
3900
3901static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3902{
3903 tSir80211Header *macHeader;
3904 int i = 0, j = 0, length = 0;
3905 uint8 byte = 0;
3906 char *temp = pBuffer;
3907 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303908 char *pHeader;
3909 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303910
3911 macHeader = &pkt->macHeader;
3912
3913 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3914
3915 temp++;
3916
3917 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3918 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3919 pkt->encParams.keyParams.key[0].keyId);
3920
3921 for (i = 0; i< 16; i++) {
3922 pkt->encParams.keyParams.key[0].key[i]
3923 = getByte(&temp);
3924 }
3925
3926 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3927 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3928
3929 for (i = 0; i< 6; i++) {
3930 pkt->encParams.pn[i]
3931 = getByte(&temp);
3932 }
3933
3934 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3935 &pkt->encParams.pn[0], 6, 0);
3936
3937 for (i = 0, j= 5; i< 3; i++, j--) {
3938 byte = pkt->encParams.pn[i];
3939 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3940 pkt->encParams.pn[j] = byte;
3941 }
3942
3943 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303944 if (length > sizeof(tSir80211Header))
3945 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303946
Srinivas Dasari2382de62015-01-22 15:00:04 +05303947 pHeader = temp;
3948 vos_mem_zero(&header, sizeof(tSir80211Header));
3949 for (i = 0; i < length; i++) {
3950 *((uint8 *)&header + i) = getByte(&pHeader);
3951 }
3952
3953 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3954 (char *)&header, length, 0);
3955
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303956 byte = getByte(&temp);
3957
3958 macHeader->frameCtrl.protVer = byte & 0x3;
3959 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3960 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3961
3962 byte = getByte(&temp);
3963 macHeader->frameCtrl.toDS = (byte) & 0x1;
3964 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3965 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3966 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3967 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3968 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3969 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3970 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3971
3972 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3973 "macHeader->frameCtrl.type : %x "
3974 "macHeader->frameCtrl.subType : %x "
3975 "macHeader->frameCtrl.toDS : %x "
3976 "macHeader->frameCtrl.fromDS : %x "
3977 "macHeader->frameCtrl.moreFrag : %x "
3978 "macHeader->frameCtrl.retry : %x "
3979 "macHeader->frameCtrl.powerMgmt : %x "
3980 "macHeader->frameCtrl.MoreData : %x "
3981 "macHeader->frameCtrl.wep : %x "
3982 "macHeader->frameCtrl.order : %x "
3983 , macHeader->frameCtrl.protVer
3984 , macHeader->frameCtrl.type
3985 , macHeader->frameCtrl.subType
3986 , macHeader->frameCtrl.toDS
3987 , macHeader->frameCtrl.fromDS
3988 , macHeader->frameCtrl.moreFrag
3989 , macHeader->frameCtrl.retry
3990 , macHeader->frameCtrl.powerMgmt
3991 , macHeader->frameCtrl.moreData
3992 , macHeader->frameCtrl.wep
3993 , macHeader->frameCtrl.order);
3994
3995
3996 macHeader->usDurationId = getByte(&temp);
3997 macHeader->usDurationId += getByte(&temp) << 8;
3998
3999 macHeader->vA1[0] = getByte(&temp);
4000 macHeader->vA1[1] = getByte(&temp);
4001 macHeader->vA1[2] = getByte(&temp);
4002 macHeader->vA1[3] = getByte(&temp);
4003 macHeader->vA1[4] = getByte(&temp);
4004 macHeader->vA1[5] = getByte(&temp);
4005
4006 macHeader->vA2[0] = getByte(&temp);
4007 macHeader->vA2[1] = getByte(&temp);
4008 macHeader->vA2[2] = getByte(&temp);
4009 macHeader->vA2[3] = getByte(&temp);
4010 macHeader->vA2[4] = getByte(&temp);
4011 macHeader->vA2[5] = getByte(&temp);
4012
4013 macHeader->vA3[0] = getByte(&temp);
4014 macHeader->vA3[1] = getByte(&temp);
4015 macHeader->vA3[2] = getByte(&temp);
4016 macHeader->vA3[3] = getByte(&temp);
4017 macHeader->vA3[4] = getByte(&temp);
4018 macHeader->vA3[5] = getByte(&temp);
4019
4020 macHeader->sSeqCtrl = getByte(&temp);
4021 fragNum = macHeader->sSeqCtrl & 0xF;
4022 macHeader->sSeqCtrl >>= 4;
4023
4024 macHeader->sSeqCtrl += getByte(&temp) << 4;
4025
4026 macHeader->sSeqCtrl |= fragNum << 12;
4027
4028 if (length == 30 || length == 32) {
4029 macHeader->optvA4[0] = getByte(&temp);
4030 macHeader->optvA4[1] = getByte(&temp);
4031 macHeader->optvA4[2] = getByte(&temp);
4032 macHeader->optvA4[3] = getByte(&temp);
4033 macHeader->optvA4[4] = getByte(&temp);
4034 macHeader->optvA4[5] = getByte(&temp);
4035 }
4036
4037 if (length == 26 || length == 32) {
4038 macHeader->usQosCtrl = getByte(&temp);
4039 macHeader->usQosCtrl += getByte(&temp) << 8;
4040 }
4041
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304042 //parse payload
4043 length = getByte(&temp);
4044 length += getByte(&temp) << 8;
4045 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
4046
Manjeet Singh5830f142016-11-21 18:21:17 +05304047 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
4048 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
4049
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304050 pkt->data.length = length;
4051
4052 for (i = 0; i< length; i++) {
4053 pkt->data.data[i] = getByte(&temp);
4054 }
4055
4056 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
4057 &pkt->data.data[0], pkt->data.length, 0);
4058}
4059
4060/**---------------------------------------------------------------------------
4061
4062 \brief hdd_encrypt_msg_cb() - Callback function for DISA
4063 encrypt message request
4064 This is an asynchronous callback function from SME when the encrypted data
4065 is received
4066
4067 \pEncInfoRsp -> Encrypted data info
4068
4069 \return - 0 for success non-zero for failure
4070 --------------------------------------------------------------------------*/
4071static void
4072hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
4073{
4074 tpSetEncryptedDataRspParams pEncryptedDataRsp;
4075
4076 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
4077
4078 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
4079 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
4080 pEncryptedDataRsp->encryptedPayload.length);
4081 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
4082 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
4083 pEncryptedDataRsp->encryptedPayload.data,
4084 pEncryptedDataRsp->encryptedPayload.length, 0);
4085}
4086
Jeff Johnson295189b2012-06-20 16:38:30 -07004087VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
4088{
4089 struct statsContext context;
4090 eHalStatus status;
4091 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304092 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004093
4094 if (NULL == pAdapter)
4095 {
4096 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
4097 return VOS_STATUS_E_FAULT;
4098 }
4099
4100 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
4101 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05304102 if (pHddCtx->isLogpInProgress) {
4103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4104 "%s:LOGP in Progress. Ignore!!!", __func__);
4105 return VOS_STATUS_E_FAILURE;
4106 }
4107
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 init_completion(&context.completion);
4109
4110 context.pAdapter = pAdapter;
4111 context.magic = POWER_CONTEXT_MAGIC;
4112
4113 if (DRIVER_POWER_MODE_ACTIVE == mode)
4114 {
4115 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
4116 "Full Power", __func__);
4117 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4118 iw_power_callback_fn, &context,
4119 eSME_FULL_PWR_NEEDED_BY_HDD);
4120 // Enter Full power command received from GUI this means we are disconnected
4121 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
4122 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
4123 if (eHAL_STATUS_PMC_PENDING == status)
4124 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004125 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 int lrc = wait_for_completion_interruptible_timeout(
4127 &context.completion,
4128 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004129
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 if (lrc <= 0)
4131 {
4132 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004133 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 }
4135 }
4136 }
4137 else if (DRIVER_POWER_MODE_AUTO == mode)
4138 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304139 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
4140 * was already in BMPS state and thus either STA or P2P-CLI is in
4141 * associated state and authenticated, so even if STA connState is
4142 * not associated it can be assumed that P2P-CLI is associated and
4143 * authenticated. Thus driver can enter BMPS. And even if we try to enter
4144 * BMPS with no adaptor in associated state, pmcRequestBmps will check
4145 * if all condition are satisfied for entering BMPS.
4146 */
4147 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4148 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304149 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304150 hddLog(LOGE,
4151 FL("Station is associated but, still not Authenticated ignore "
4152 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304153 return VOS_STATUS_E_AGAIN;
4154 }
4155
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4157 {
4158 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
4159 __func__);
4160 // Enter BMPS command received from GUI this means DHCP is completed
4161 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
4162 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4163 FALSE);
4164 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4165 iw_power_callback_fn, &context);
4166 if (eHAL_STATUS_PMC_PENDING == status)
4167 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004168 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 int lrc = wait_for_completion_interruptible_timeout(
4170 &context.completion,
4171 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004172 if (lrc <= 0)
4173 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004174 hddLog(VOS_TRACE_LEVEL_ERROR,
4175 "%s: SME %s while requesting BMPS",
4176 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 }
4178 }
4179 }
4180 else
4181 {
4182 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
4183 "enabled in the cfg");
4184 }
4185 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004186
4187 /* either we never sent a request, we sent a request and received a
4188 response or we sent a request and timed out. if we never sent a
4189 request or if we sent a request and got a response, we want to
4190 clear the magic out of paranoia. if we timed out there is a
4191 race condition such that the callback function could be
4192 executing at the same time we are. of primary concern is if the
4193 callback function had already verified the "magic" but had not
4194 yet set the completion variable when a timeout occurred. we
4195 serialize these activities by invalidating the magic while
4196 holding a shared spinlock which will cause us to block if the
4197 callback is currently executing */
4198 spin_lock(&hdd_context_lock);
4199 context.magic = 0;
4200 spin_unlock(&hdd_context_lock);
4201
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 return VOS_STATUS_SUCCESS;
4203}
4204
4205VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4206 hdd_adapter_t *pAdapter)
4207{
4208 VOS_STATUS vos_Status;
4209
4210 if ((NULL == pAdapter) || (NULL == pHddCtx))
4211 {
4212 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4213 return VOS_STATUS_E_FAULT;
4214 }
4215
4216 /**Exit from Deep sleep or standby if we get the driver
4217 START cmd from android GUI
4218 */
4219 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4220 {
4221 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4222 "from Stand by",__func__);
4223 vos_Status = hdd_exit_standby(pHddCtx);
4224 }
4225 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4226 {
4227 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4228 "from deep sleep",__func__);
4229 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4230 }
4231 else
4232 {
4233 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4234 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4235 vos_Status = VOS_STATUS_SUCCESS;
4236 }
4237
4238 return vos_Status;
4239}
4240
4241VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4242{
4243 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4244
4245 if (NULL == pHddCtx)
4246 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304247 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 return VOS_STATUS_E_FAULT;
4249 }
4250
4251 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4252 {
4253 //Execute standby procedure.
4254 //Executing standby procedure will cause the STA to
4255 //disassociate first and then the chip will be put into standby.
4256 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4257 vos_Status = hdd_enter_standby(pHddCtx);
4258 }
4259 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4260 pHddCtx->cfg_ini->nEnableDriverStop)
4261 {
4262 //Execute deep sleep procedure
4263 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004264 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 //Deep sleep not supported
4266 vos_Status = hdd_enter_standby(pHddCtx);
4267 }
4268 else
4269 {
4270 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4271 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4272 vos_Status = VOS_STATUS_SUCCESS;
4273 }
4274
4275 return vos_Status;
4276}
4277
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004278
4279void* wlan_hdd_change_country_code_callback(void *pAdapter)
4280{
4281
4282 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004283 complete(&call_back_pAdapter->change_country_code);
4284
4285 return NULL;
4286}
4287
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304288static int __iw_set_priv(struct net_device *dev,
4289 struct iw_request_info *info,
4290 union iwreq_data *wrqu, char *extra)
4291{
4292 hdd_adapter_t *pAdapter;
4293 char *cmd = NULL;
4294 int cmd_len = wrqu->data.length;
4295 int rc = 0, ret = 0;
4296 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4297
4298 hdd_context_t *pHddCtx;
4299
4300 ENTER();
4301
4302 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4303 if (NULL == pAdapter)
4304 {
4305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4306 "mem_alloc_copy_from_user_helper fail");
4307 return -EINVAL;
4308 }
4309 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4310 rc = wlan_hdd_validate_context(pHddCtx);
4311 if (0 != rc)
4312 {
4313 return rc;
4314 }
4315
4316 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4317 wrqu->data.length);
4318 if (NULL == cmd)
4319 {
4320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4321 "mem_alloc_copy_from_user_helper fail");
4322 return -ENOMEM;
4323 }
4324
4325 if (ioctl_debug)
4326 {
4327 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
4328 }
4329
4330 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4331 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
4332
4333 if (strncmp(cmd, "CSCAN", 5) == 0 )
4334 {
4335 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4337 "%s: Error in iw_set_scan!", __func__);
4338 rc = -EINVAL;
4339 }
4340 }
4341 else if( strcasecmp(cmd, "start") == 0 ) {
4342
4343 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
4344 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
4345
4346 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4347 if (vos_status == VOS_STATUS_SUCCESS)
4348 {
4349 union iwreq_data wrqu;
4350 char buf[10];
4351
4352 memset(&wrqu, 0, sizeof(wrqu));
4353 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4354 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4355 }
4356 else
4357 {
4358 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4359 rc = -EIO;
4360 }
4361 goto done;
4362 }
4363 else if( strcasecmp(cmd, "stop") == 0 )
4364 {
4365 union iwreq_data wrqu;
4366 char buf[10];
4367
4368 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4369
4370 wlan_hdd_enter_lowpower(pHddCtx);
4371 memset(&wrqu, 0, sizeof(wrqu));
4372 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4373 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4374 goto done;
4375 }
4376 else if (strcasecmp(cmd, "macaddr") == 0)
4377 {
4378 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4379 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4380 }
4381 else if (strcasecmp(cmd, "scan-active") == 0)
4382 {
4383 hddLog(LOG1,
4384 FL("making default scan to active"));
4385 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4386 ret = snprintf(cmd, cmd_len, "OK");
4387 }
4388 else if (strcasecmp(cmd, "scan-passive") == 0)
4389 {
4390 hddLog(LOG1,
4391 FL("making default scan to passive"));
4392 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4393 ret = snprintf(cmd, cmd_len, "OK");
4394 }
4395 else if( strcasecmp(cmd, "scan-mode") == 0 )
4396 {
4397 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4398 }
4399 else if( strcasecmp(cmd, "linkspeed") == 0 )
4400 {
4401 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4402 }
4403 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4404 {
4405 ret = iw_get_rssi(dev, info, wrqu, cmd);
4406 }
4407 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4408 int mode;
4409 char *ptr;
4410
4411 if (9 < cmd_len)
4412 {
4413 ptr = (char*)(cmd + 9);
4414
4415 }else{
4416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4417 "CMD LENGTH %d is not correct",cmd_len);
4418 kfree(cmd);
4419 return -EINVAL;
4420 }
4421
4422 if (1 != sscanf(ptr,"%d",&mode))
4423 {
4424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4425 "powermode input %s is not correct",ptr);
4426 kfree(cmd);
4427 return -EIO;
4428 }
4429
4430 wlan_hdd_enter_bmps(pAdapter, mode);
4431 /*TODO:Set the power mode*/
4432 }
4433 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4434 v_U32_t pmc_state;
4435 v_U16_t value;
4436
4437 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4438 if(pmc_state == BMPS) {
4439 value = DRIVER_POWER_MODE_AUTO;
4440 }
4441 else {
4442 value = DRIVER_POWER_MODE_ACTIVE;
4443 }
4444 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4445 }
4446 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4447 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4448 /*TODO: set the btcoexmode*/
4449 }
4450 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4451
4452 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4453 /*TODO: Return the btcoex status*/
4454 }
4455 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4456
4457 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4458
4459 /*TODO: Enable Rx data Filter*/
4460 }
4461 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4462
4463 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4464
4465 /*TODO: Disable Rx data Filter*/
4466 }
4467 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4468
4469 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4470 /*TODO: rxfilter-statistics*/
4471 }
4472 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4473
4474 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4475 /*TODO: rxfilter-add*/
4476 }
4477 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4478
4479 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4480 /*TODO: rxfilter-remove*/
4481 }
4482#ifdef FEATURE_WLAN_SCAN_PNO
4483 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4484 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4485 /*TODO: support pnosetup*/
4486 }
4487 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4488 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4489 /*TODO: support pnoforce*/
4490 }
4491 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4492
4493 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4494 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4495 kfree(cmd);
4496 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4497 }
4498 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4499 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4500 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4501 kfree(cmd);
4502 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4503 }
4504#endif /*FEATURE_WLAN_SCAN_PNO*/
4505 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4506 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4507 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4508 kfree(cmd);
4509 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4510 }
4511 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4512 tSirTxPerTrackingParam tTxPerTrackingParam;
4513 char *ptr;
4514
4515 if (18 < cmd_len)
4516 {
4517 ptr = (char*)(cmd + 18);
4518 }else{
4519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4520 "CMD LENGTH %d is not correct",cmd_len);
4521 kfree(cmd);
4522 return -EINVAL;
4523 }
4524
4525 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4526 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4527 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4528 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4529 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4530 {
4531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4532 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4533 kfree(cmd);
4534 return -EIO;
4535 }
4536
4537 // parameters checking
4538 // period has to be larger than 0
4539 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4540 {
4541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4542 kfree(cmd);
4543 return -EIO;
4544 }
4545
4546 // use default value 5 is the input is not reasonable. in unit of 10%
4547 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4548 {
4549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4550 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4551 }
4552
4553 // default is 5
4554 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4555 {
4556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4557 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4558 }
4559
4560 if (eHAL_STATUS_SUCCESS !=
4561 sme_SetTxPerTracking(pHddCtx->hHal,
4562 hdd_tx_per_hit_cb,
4563 (void*)pAdapter, &tTxPerTrackingParam)) {
4564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4565 rc = -EIO;
4566 }
4567 }
4568 else {
4569 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4570 __func__, cmd);
4571 }
4572done:
4573 /* many of the commands write information back into the command
4574 string using snprintf(). check the return value here in one
4575 place */
4576 if ((ret < 0) || (ret >= cmd_len))
4577 {
4578 /* there was an encoding error or overflow */
4579 rc = -EINVAL;
4580 }
4581 else if (ret > 0)
4582 {
4583 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4584 {
4585 hddLog(VOS_TRACE_LEVEL_ERROR,
4586 "%s: failed to copy data to user buffer", __func__);
4587 kfree(cmd);
4588 return -EFAULT;
4589 }
4590 wrqu->data.length = ret;
4591 }
4592
4593 if (ioctl_debug)
4594 {
4595 pr_info("%s: rsp [%s] len [%d] status %d\n",
4596 __func__, cmd, wrqu->data.length, rc);
4597 }
4598 kfree(cmd);
4599 EXIT();
4600 return rc;
4601}
4602
4603static int iw_set_priv(struct net_device *dev,
4604 struct iw_request_info *info,
4605 union iwreq_data *wrqu, char *extra)
4606{
4607 int ret;
4608 vos_ssr_protect(__func__);
4609 ret = __iw_set_priv(dev, info, wrqu, extra);
4610 vos_ssr_unprotect(__func__);
4611
4612 return ret;
4613}
4614
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304615static int __iw_set_nick(struct net_device *dev,
4616 struct iw_request_info *info,
4617 union iwreq_data *wrqu, char *extra)
4618{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304619 hdd_adapter_t *pAdapter;
4620 hdd_context_t *pHddCtx;
4621 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304622
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304623 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304624
4625 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4626 if (NULL == pAdapter)
4627 {
4628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4629 "%s: Adapter is NULL",__func__);
4630 return -EINVAL;
4631 }
4632
4633 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4634 ret = wlan_hdd_validate_context(pHddCtx);
4635 if (0 != ret)
4636 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304637 return ret;
4638 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304639 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304640 return 0;
4641}
4642
Jeff Johnson295189b2012-06-20 16:38:30 -07004643static int iw_set_nick(struct net_device *dev,
4644 struct iw_request_info *info,
4645 union iwreq_data *wrqu, char *extra)
4646{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304647 int ret;
4648
4649 vos_ssr_protect(__func__);
4650 ret = __iw_set_nick(dev, info, wrqu, extra);
4651 vos_ssr_unprotect(__func__);
4652
4653 return ret;
4654}
4655
4656static int __iw_get_nick(struct net_device *dev,
4657 struct iw_request_info *info,
4658 union iwreq_data *wrqu, char *extra)
4659{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304660 hdd_adapter_t *pAdapter;
4661 hdd_context_t *pHddCtx;
4662 int ret = 0;
4663
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304665
4666 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4667 if (NULL == pAdapter)
4668 {
4669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4670 "%s: Adapter is NULL",__func__);
4671 return -EINVAL;
4672 }
4673
4674 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4675 ret = wlan_hdd_validate_context(pHddCtx);
4676 if (0 != ret)
4677 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304678 return ret;
4679 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304680 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 return 0;
4682}
4683
4684static int iw_get_nick(struct net_device *dev,
4685 struct iw_request_info *info,
4686 union iwreq_data *wrqu, char *extra)
4687{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304688 int ret;
4689
4690 vos_ssr_protect(__func__);
4691 ret = __iw_get_nick(dev, info, wrqu, extra);
4692 vos_ssr_unprotect(__func__);
4693
4694 return ret;
4695}
4696
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304697/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304698static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4699{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304700 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4701 hdd_context_t *pHddCtx;
4702 hdd_station_ctx_t *pHddStaCtx;
4703 v_S7_t snr = 0, rssi = 0;
4704 eHalStatus status = eHAL_STATUS_SUCCESS;
4705
4706 ENTER();
4707
4708 if (NULL == pAdapter)
4709 {
4710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4711 "%s: Adapter is NULL",__func__);
4712 return NULL;
4713 }
4714
4715 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4716 status = wlan_hdd_validate_context(pHddCtx);
4717 if (0 != status)
4718 {
4719 return NULL;
4720 }
4721
4722 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4723 if (NULL == pHddStaCtx)
4724 {
4725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4726 "%s: STA Context is NULL",__func__);
4727 return NULL;
4728 }
4729
4730 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4731 {
4732 wlan_hdd_get_station_stats(pAdapter);
4733 wlan_hdd_get_snr(pAdapter, &snr);
4734 wlan_hdd_get_rssi(pAdapter, &rssi);
4735
4736 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4737 pAdapter->iwStats.status = 0;
4738 pAdapter->iwStats.qual.qual = snr;
4739 pAdapter->iwStats.qual.level = rssi;
4740 pAdapter->iwStats.qual.noise = rssi - snr;
4741 pAdapter->iwStats.discard.code = 0;
4742 pAdapter->iwStats.discard.retries= 0;
4743 pAdapter->iwStats.miss.beacon = 0;
4744 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4745 }
4746 else
4747 {
4748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4749 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4750 return NULL;
4751 }
4752
4753 EXIT();
4754 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004755}
4756
4757static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4758{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304759
4760 struct iw_statistics *stats;
4761
4762 vos_ssr_protect(__func__);
4763 stats = __get_wireless_stats(dev);
4764 vos_ssr_unprotect(__func__);
4765
4766 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004767}
4768
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304769static int __iw_set_encode(struct net_device *dev,
4770 struct iw_request_info *info,
4771 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004772
4773{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304774 hdd_adapter_t *pAdapter;
4775 hdd_station_ctx_t *pHddStaCtx;
4776 hdd_wext_state_t *pWextState;
4777 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 struct iw_point *encoderq = &(wrqu->encoding);
4779 v_U32_t keyId;
4780 v_U8_t key_length;
4781 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4782 v_BOOL_t fKeyPresent = 0;
4783 int i;
4784 eHalStatus status = eHAL_STATUS_SUCCESS;
4785
4786
4787 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304788 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4789 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4792 "%s: Adapter is NULL",__func__);
4793 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 }
4795
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304796 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4797 status = wlan_hdd_validate_context(pHddCtx);
4798 if (0 != status)
4799 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304800 return status;
4801 }
4802 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4803 if (NULL == pWextState)
4804 {
4805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4806 "%s: pWextState is NULL ",__func__);
4807 return -EINVAL;
4808 }
4809 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4810 if (NULL == pHddStaCtx)
4811 {
4812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4813 "%s: STA Context is NULL",__func__);
4814 return -EINVAL;
4815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004816
4817 keyId = encoderq->flags & IW_ENCODE_INDEX;
4818
4819 if(keyId)
4820 {
4821 if(keyId > MAX_WEP_KEYS)
4822 {
4823 return -EINVAL;
4824 }
4825
4826 fKeyPresent = 1;
4827 keyId--;
4828 }
4829 else
4830 {
4831 fKeyPresent = 0;
4832 }
4833
4834
4835 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4836 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 if(!fKeyPresent) {
4839
4840 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4841
4842 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4843 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4844 }
4845 }
4846 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4847 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4848 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4849 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4850
4851 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4852 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4853
4854 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4855 {
4856 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4857 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004858 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304859 {
4860 long ret;
4861 ret = wait_for_completion_interruptible_timeout(
4862 &pAdapter->disconnect_comp_var,
4863 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4864 if (ret <= 0)
4865 hddLog(VOS_TRACE_LEVEL_ERROR,
4866 FL("failed wait on disconnect_comp_var %ld"), ret);
4867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 }
4869
4870 return status;
4871
4872 }
4873
4874 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4875 {
4876 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4877
4878 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4879
4880 }
4881
4882
4883 if(wrqu->data.length > 0)
4884 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004885 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004886
4887 key_length = wrqu->data.length;
4888
4889 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4890
4891 if(5 == key_length)
4892 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004893 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004894
4895 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4896 {
4897 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4898 }
4899 else
4900 {
4901 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4902 }
4903 }
4904 else if(13 == key_length)
4905 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004906 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004907
4908 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4909 {
4910 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4911 }
4912 else
4913 {
4914 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4915 }
4916 }
4917 else
4918 {
4919 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004920 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 return -EINVAL;
4922 }
4923
4924 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4925 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4926 pWextState->roamProfile.EncryptionType.numEntries = 1;
4927 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4928 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4929 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4930
4931 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4932 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4933 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4934 {
4935
4936 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4937
4938 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4939 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4940
4941 return status;
4942 }
4943 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304944 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 return 0;
4946}
4947
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304948static int iw_set_encode(struct net_device *dev,
4949 struct iw_request_info *info,
4950 union iwreq_data *wrqu,char *extra)
4951{
4952 int ret;
4953
4954 vos_ssr_protect(__func__);
4955 ret = __iw_set_encode(dev, info, wrqu, extra);
4956 vos_ssr_unprotect(__func__);
4957
4958 return ret;
4959}
4960
4961static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 struct iw_request_info *info,
4963 struct iw_point *dwrq,
4964 char *extra)
4965{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304966 hdd_adapter_t *pAdapter;
4967 hdd_wext_state_t *pWextState;
4968 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 int keyId;
4970 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4971 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304972 int i, ret = 0;
4973 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004974
4975 ENTER();
4976
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304977 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4978 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004979 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4981 "%s: Adapter is NULL",__func__);
4982 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004983 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304984 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4985 ret = wlan_hdd_validate_context(pHddCtx);
4986 if (0 != ret)
4987 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304988 return ret;
4989 }
4990 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4991 if (NULL == pWextState)
4992 {
4993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4994 "%s: pWextState is NULL",__func__);
4995 return -EINVAL;
4996 }
4997 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004998
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 keyId = pRoamProfile->Keys.defaultIndex;
5000
5001 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
5002 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005003 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 return -EINVAL;
5005 }
5006
5007 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
5008 {
5009 dwrq->flags |= IW_ENCODE_ENABLED;
5010 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05305011 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
5012 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 }
5014 else
5015 {
5016 dwrq->flags |= IW_ENCODE_DISABLED;
5017 }
5018
5019 for(i=0; i < MAX_WEP_KEYS; i++)
5020 {
5021 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
5022 {
5023 continue;
5024 }
5025 else
5026 {
5027 break;
5028 }
5029 }
5030
5031 if(MAX_WEP_KEYS == i)
5032 {
5033 dwrq->flags |= IW_ENCODE_NOKEY;
5034 }
5035 else
5036 {
5037 dwrq->flags |= IW_ENCODE_ENABLED;
5038 }
5039
5040 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
5041
5042 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
5043 {
5044 dwrq->flags |= IW_ENCODE_DISABLED;
5045 }
5046
5047 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
5048
5049 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
5050 {
5051 dwrq->flags |= IW_ENCODE_OPEN;
5052 }
5053 else
5054 {
5055 dwrq->flags |= IW_ENCODE_RESTRICTED;
5056 }
5057 EXIT();
5058 return 0;
5059
5060}
5061
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305062static int iw_get_encodeext(struct net_device *dev,
5063 struct iw_request_info *info,
5064 struct iw_point *dwrq,
5065 char *extra)
5066{
5067 int ret;
5068 vos_ssr_protect(__func__);
5069 ret = __iw_get_encodeext(dev, info, dwrq, extra);
5070 vos_ssr_unprotect(__func__);
5071
5072 return ret;
5073}
5074
5075static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 struct iw_request_info *info,
5077 union iwreq_data *wrqu, char *extra)
5078{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305079 hdd_adapter_t *pAdapter;
5080 hdd_station_ctx_t *pHddStaCtx;
5081 hdd_wext_state_t *pWextState;
5082 hdd_context_t *pHddCtx;
5083 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005084
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305085 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 v_U32_t status = 0;
5087
5088 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
5089
5090 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5091
5092 int key_index;
5093 struct iw_point *encoding = &wrqu->encoding;
5094 tCsrRoamSetKey setKey;
5095 v_U32_t roamId= 0xFF;
5096 VOS_STATUS vos_status;
5097
5098 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305099 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5100 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5103 "%s: Adapter is NULL",__func__);
5104 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305106 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5107 status = wlan_hdd_validate_context(pHddCtx);
5108 if (0 != status)
5109 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305110 return status;
5111 }
5112 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5113 if (NULL == pHddStaCtx)
5114 {
5115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5116 "%s: STA Context is NULL",__func__);
5117 return -EINVAL;
5118 }
5119 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5120 if (NULL == pWextState)
5121 {
5122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5123 "%s: pWextState is NULL",__func__);
5124 return -EINVAL;
5125 }
5126 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005127 key_index = encoding->flags & IW_ENCODE_INDEX;
5128
5129 if(key_index > 0) {
5130
5131 /*Convert from 1-based to 0-based keying*/
5132 key_index--;
5133 }
5134 if(!ext->key_len) {
5135
5136 /*Set the encrytion type to NONE*/
5137 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5138 return status;
5139 }
5140
5141 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
5142 (IW_ENCODE_ALG_WEP == ext->alg))
5143 {
5144 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
5145
Agarwal Ashish971c2882013-10-30 20:11:12 +05305146 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5147 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005148 return -EINVAL;
5149 }
5150 else {
5151 /*Static wep, update the roam profile with the keys */
5152 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
5153 key_index < CSR_MAX_NUM_KEY) {
5154 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
5155 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
5156
5157 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5158 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5159
5160 }
5161 }
5162 return status;
5163 }
5164
5165 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5166
5167 setKey.keyId = key_index;
5168 setKey.keyLength = ext->key_len;
5169
5170 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5171 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5172 }
5173
5174 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5175 /*Key direction for group is RX only*/
5176 setKey.keyDirection = eSIR_RX_ONLY;
5177 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5178 }
5179 else {
5180
5181 setKey.keyDirection = eSIR_TX_RX;
5182 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5183 }
5184
5185 /*For supplicant pae role is zero*/
5186 setKey.paeRole = 0;
5187
5188 switch(ext->alg)
5189 {
5190 case IW_ENCODE_ALG_NONE:
5191 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5192 break;
5193
5194 case IW_ENCODE_ALG_WEP:
5195 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5196 break;
5197
5198 case IW_ENCODE_ALG_TKIP:
5199 {
5200 v_U8_t *pKey = &setKey.Key[0];
5201
5202 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5203
5204 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5205
5206 /*Supplicant sends the 32bytes key in this order
5207
5208 |--------------|----------|----------|
5209 | Tk1 |TX-MIC | RX Mic |
5210 |--------------|----------|----------|
5211 <---16bytes---><--8bytes--><--8bytes-->
5212
5213 */
5214 /*Sme expects the 32 bytes key to be in the below order
5215
5216 |--------------|----------|----------|
5217 | Tk1 |RX-MIC | TX Mic |
5218 |--------------|----------|----------|
5219 <---16bytes---><--8bytes--><--8bytes-->
5220 */
5221 /* Copy the Temporal Key 1 (TK1) */
5222 vos_mem_copy(pKey,ext->key,16);
5223
5224 /*Copy the rx mic first*/
5225 vos_mem_copy(&pKey[16],&ext->key[24],8);
5226
5227 /*Copy the tx mic */
5228 vos_mem_copy(&pKey[24],&ext->key[16],8);
5229
5230 }
5231 break;
5232
5233 case IW_ENCODE_ALG_CCMP:
5234 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5235 break;
5236
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005237#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005238#define IW_ENCODE_ALG_KRK 6
5239 case IW_ENCODE_ALG_KRK:
5240 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5241 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005242#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005243
5244 default:
5245 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5246 break;
5247 }
5248
5249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005250 ("%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 -07005251
5252#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305253 /* The supplicant may attempt to set the PTK once pre-authentication
5254 is done. Save the key in the UMAC and include it in the ADD
5255 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305257 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005258 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305259 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5260 "%s: Update PreAuth Key success", __func__);
5261 return 0;
5262 }
5263 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5264 {
5265 hddLog(VOS_TRACE_LEVEL_ERROR,
5266 "%s: Update PreAuth Key failed", __func__);
5267 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 }
5269#endif /* WLAN_FEATURE_VOWIFI_11R */
5270
5271 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5272
5273 vos_status = wlan_hdd_check_ula_done(pAdapter);
5274 if ( vos_status != VOS_STATUS_SUCCESS )
5275 {
5276 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5277 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5278 __LINE__, vos_status );
5279
5280 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5281 }
5282
5283 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5284
5285 if ( halStatus != eHAL_STATUS_SUCCESS )
5286 {
5287 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5288 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5289 __LINE__, halStatus );
5290
5291 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5292 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305293 EXIT();
5294 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005295}
5296
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305297static int iw_set_encodeext(struct net_device *dev,
5298 struct iw_request_info *info,
5299 union iwreq_data *wrqu, char *extra)
5300{
5301 int ret;
5302
5303 vos_ssr_protect(__func__);
5304 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5305 vos_ssr_unprotect(__func__);
5306
5307 return ret;
5308}
5309
5310static int __iw_set_retry(struct net_device *dev,
5311 struct iw_request_info *info,
5312 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005313{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305314 hdd_adapter_t *pAdapter;
5315 tHalHandle hHal;
5316 hdd_context_t *pHddCtx;
5317 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005318
5319 ENTER();
5320
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305321 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5322 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005323 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5325 "%s: Adapter is NULL",__func__);
5326 return -EINVAL;
5327 }
5328
5329 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5330 ret = wlan_hdd_validate_context(pHddCtx);
5331 if (0 != ret)
5332 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305333 return ret;
5334 }
5335
5336 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5337 if (NULL == hHal)
5338 {
5339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5340 "%s: Hal Context is NULL",__func__);
5341 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005342 }
5343
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5345 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5346
Arif Hussain6d2a3322013-11-17 19:50:10 -08005347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005348
5349 return -EINVAL;
5350 }
5351
5352 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5353
5354 if((wrqu->retry.flags & IW_RETRY_LONG))
5355 {
5356 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5357 {
c_hpothub8245442013-11-20 23:41:09 +05305358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5359 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 return -EIO;
5361 }
5362 }
5363 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5364 {
5365 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5366 {
c_hpothub8245442013-11-20 23:41:09 +05305367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5368 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 return -EIO;
5370 }
5371 }
5372 }
5373 else
5374 {
5375 return -EOPNOTSUPP;
5376 }
5377
Arif Hussain6d2a3322013-11-17 19:50:10 -08005378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005379
5380 EXIT();
5381
5382 return 0;
5383
5384}
5385
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305386static int iw_set_retry(struct net_device *dev,
5387 struct iw_request_info *info,
5388 union iwreq_data *wrqu, char *extra)
5389{
5390 int ret;
5391
5392 vos_ssr_protect(__func__);
5393 ret = __iw_set_retry(dev, info, wrqu, extra);
5394 vos_ssr_unprotect(__func__);
5395
5396 return ret;
5397}
5398
5399static int __iw_get_retry(struct net_device *dev,
5400 struct iw_request_info *info,
5401 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005402{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305403 hdd_adapter_t *pAdapter;
5404 hdd_context_t *pHddCtx;
5405 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305407 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005408
5409 ENTER();
5410
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305411 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5412 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005413 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5415 "%s: Adapter is NULL",__func__);
5416 return -EINVAL;
5417 }
5418
5419 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5420 ret = wlan_hdd_validate_context(pHddCtx);
5421 if (0 != ret)
5422 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305423 return ret;
5424 }
5425
5426 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5427 if (NULL == hHal)
5428 {
5429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5430 "%s: Hal Context is NULL",__func__);
5431 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005432 }
5433
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 if((wrqu->retry.flags & IW_RETRY_LONG))
5435 {
5436 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5437
5438 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5439 {
c_hpothub8245442013-11-20 23:41:09 +05305440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5441 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 return -EIO;
5443 }
5444
5445 wrqu->retry.value = retry;
5446 }
5447 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5448 {
5449 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5450
5451 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5452 {
c_hpothub8245442013-11-20 23:41:09 +05305453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5454 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 return -EIO;
5456 }
5457
5458 wrqu->retry.value = retry;
5459 }
5460 else {
5461 return -EOPNOTSUPP;
5462 }
5463
Arif Hussain6d2a3322013-11-17 19:50:10 -08005464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005465
5466 EXIT();
5467
5468 return 0;
5469}
5470
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305471static int iw_get_retry(struct net_device *dev,
5472 struct iw_request_info *info,
5473 union iwreq_data *wrqu, char *extra)
5474{
5475 int ret;
5476
5477 vos_ssr_protect(__func__);
5478 ret = __iw_get_retry(dev, info, wrqu, extra);
5479 vos_ssr_unprotect(__func__);
5480
5481 return ret;
5482}
5483
5484static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 struct iw_request_info *info,
5486 union iwreq_data *wrqu,
5487 char *extra)
5488{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305489 hdd_adapter_t *pAdapter;
5490 hdd_context_t *pHddCtx;
5491 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5493 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305494 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005495
5496 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305497 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5498 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5501 "%s:Adapter is NULL",__func__);
5502 return -EINVAL;
5503 }
5504 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5505 ret = wlan_hdd_validate_context(pHddCtx);
5506 if (0 != ret)
5507 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305508 return ret;
5509 }
5510 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5511 if (NULL == pHddStaCtx)
5512 {
5513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5514 "%s:STA context is NULL",__func__);
5515 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 }
5517
5518 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5519 switch (mlme->cmd) {
5520 case IW_MLME_DISASSOC:
5521 case IW_MLME_DEAUTH:
5522
5523 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5524 {
5525 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5526
5527 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5528 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5529
5530 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5531 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5532
Jeff Johnson43971f52012-07-17 12:26:56 -07005533 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305534 {
5535 long ret;
5536 ret = wait_for_completion_interruptible_timeout(
5537 &pAdapter->disconnect_comp_var,
5538 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5539 if (ret <= 0)
5540 hddLog(VOS_TRACE_LEVEL_ERROR,
5541 FL("failed wait on disconnect_comp_var %ld"), ret);
5542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005544 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005545 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005546
5547 /* Resetting authKeyMgmt */
5548 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5549
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305550 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 netif_tx_disable(dev);
5552 netif_carrier_off(dev);
5553
5554 }
5555 else
5556 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005557 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 -07005558 }
5559 break;
5560 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005561 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 return -EINVAL;
5563 }//end of switch
5564
5565 EXIT();
5566
5567 return status;
5568
5569}
5570
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305571static int iw_set_mlme(struct net_device *dev,
5572 struct iw_request_info *info,
5573 union iwreq_data *wrqu,
5574 char *extra)
5575{
5576 int ret;
5577
5578 vos_ssr_protect(__func__);
5579 ret = __iw_set_mlme(dev, info, wrqu, extra);
5580 vos_ssr_unprotect(__func__);
5581
5582 return ret;
5583}
5584
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305585int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305586{
5587 sHwCalValues hwCalValues;
5588 uint16 hwCalTxPower;
5589 uint8 txPwr = TX_PWR_DEF;
5590
5591 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5592
5593 if (TRUE == set_value) {
5594 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5595 NULL, sizeof(sHwCalValues) )
5596 != VOS_STATUS_SUCCESS) {
5597 return -EINVAL;
5598 }
5599 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5600
5601 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5602 hwCalTxPower, hwCalValues.calData.hwParam7);
5603
5604 txPwr = (int8)(hwCalTxPower & 0x00FF);
5605 txPwr = txPwr/10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305606 if (txPwr == 0)
5607 txPwr = TX_PWR_DEF;
5608 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305609 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305610 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305611 txPwr = TX_PWR_MAX;
5612
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305613 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305614 eHAL_STATUS_SUCCESS) {
5615 hddLog(VOS_TRACE_LEVEL_ERROR,
5616 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5617 return -EIO;
5618 }
5619
5620 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5621 txPwr /= 10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305622 if (txPwr == 0)
5623 txPwr = TX_PWR_DEF;
5624 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305625 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305626 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305627 txPwr = TX_PWR_MAX;
5628
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305629 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305630 eHAL_STATUS_SUCCESS) {
5631 hddLog(VOS_TRACE_LEVEL_ERROR,
5632 FL("setting tx power failed for 5GHz band %d"), txPwr);
5633 return -EIO;
5634 }
5635 }
5636 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305637 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305638 eHAL_STATUS_SUCCESS) {
5639 hddLog(VOS_TRACE_LEVEL_ERROR,
5640 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5641 return -EIO;
5642 }
5643
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305644 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305645 eHAL_STATUS_SUCCESS) {
5646 hddLog(VOS_TRACE_LEVEL_ERROR,
5647 FL("setting tx power failed for 5GHz band %d"), txPwr);
5648 return -EIO;
5649 }
5650 }
5651 else {
5652 return -EINVAL;
5653 }
5654
5655 return eHAL_STATUS_SUCCESS;
5656}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05305657
5658static int hdd_set_dynamic_aggregation(int value, hdd_adapter_t *adapter)
5659{
5660 int ret = 0;
5661 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5662 tDelBaParams del_session;
5663
5664 del_session.session_id = adapter->sessionId;
5665 hddLog(LOG1, FL("WLAN_SET_DYNNAMIC_AGGREGATION: %d"), value);
5666
5667 if ((value == DISABLE_AGGREGATION) || (value == ENABLE_AGGREGATION))
5668 {
5669 ret = ccmCfgSetInt(hal, WNI_CFG_ENABLE_TX_RX_AGGREGATION,
5670 value,NULL, eANI_BOOLEAN_FALSE);
5671 if (ret != eHAL_STATUS_SUCCESS)
5672 {
5673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5674 FL("failed to set ini parameter, WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
5675 return -EIO;
5676 }
5677
5678 } else {
5679 hddLog(VOS_TRACE_LEVEL_ERROR,
5680 FL("Invalid command input"));
5681 return -EINVAL;
5682 }
5683 ret = sme_del_sta_ba_session_req(hal, del_session);
5684 if (ret != VOS_STATUS_SUCCESS) {
5685 hddLog(VOS_TRACE_LEVEL_ERROR, FL("send ba session req fail"));
5686 return -EINVAL;
5687 }
5688
5689 EXIT();
5690 return ret;
5691}
5692
Jeff Johnson295189b2012-06-20 16:38:30 -07005693/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305694static int __iw_setint_getnone(struct net_device *dev,
5695 struct iw_request_info *info,
5696 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005697{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305698 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305699 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305700 hdd_wext_state_t *pWextState;
5701 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305702 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 int *value = (int *)extra;
5704 int sub_cmd = value[0];
5705 int set_value = value[1];
5706 int ret = 0; /* success */
5707 int enable_pbm, enable_mp;
5708#ifdef CONFIG_HAS_EARLYSUSPEND
5709 v_U8_t nEnableSuspendOld;
5710#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005711
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305712 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305713 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5714 if (NULL == pAdapter)
5715 {
5716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5717 "%s: Adapter is NULL",__func__);
5718 return -EINVAL;
5719 }
5720 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5721 ret = wlan_hdd_validate_context(pHddCtx);
5722 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005723 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305724 return ret;
5725 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305726
Katya Nigameae74b62015-05-28 17:19:16 +05305727 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305728 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305729 /* In monitor mode hHal is NULL */
5730 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5731 if (NULL == hHal)
5732 {
5733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5734 "%s: Hal Context is NULL",__func__);
5735 return -EINVAL;
5736 }
Katya Nigameae74b62015-05-28 17:19:16 +05305737 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5738 if (NULL == pWextState)
5739 {
5740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5741 "%s: pWextState is NULL",__func__);
5742 return -EINVAL;
5743 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005744
Katya Nigameae74b62015-05-28 17:19:16 +05305745 INIT_COMPLETION(pWextState->completion_var);
5746 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 switch(sub_cmd)
5748 {
5749 case WE_SET_11D_STATE:
5750 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005751 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005752 memset(&smeConfig, 0x00, sizeof(smeConfig));
5753
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305754 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5755 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 sme_GetConfigParam(hHal,&smeConfig);
5757 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5758
Arif Hussain6d2a3322013-11-17 19:50:10 -08005759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005760
5761 sme_UpdateConfig(hHal,&smeConfig);
5762 }
5763 else {
5764 return -EINVAL;
5765 }
5766 break;
5767 }
5768
5769 case WE_WOWL:
5770 {
5771 switch (set_value)
5772 {
5773 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305774 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 break;
5776 case 0x01:
5777 case 0x02:
5778 case 0x03:
5779 enable_mp = (set_value & 0x01) ? 1 : 0;
5780 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005781 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5783 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5784 break;
5785 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005786 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005787 ret = -EINVAL;
5788 break;
5789 }
5790
5791 break;
5792 }
5793 case WE_SET_POWER:
5794 {
5795 switch (set_value)
5796 {
5797 case 0: //Full Power
5798 {
5799 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305800 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005801
5802 init_completion(&context.completion);
5803
5804 context.pAdapter = pAdapter;
5805 context.magic = POWER_CONTEXT_MAGIC;
5806
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305807 if (NULL == hHal)
5808 return -EINVAL;
5809
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5811 iw_power_callback_fn, &context,
5812 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305813
Jeff Johnson72a40512013-12-19 10:14:15 -08005814 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 {
5816 int lrc = wait_for_completion_interruptible_timeout(
5817 &context.completion,
5818 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005819
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 if (lrc <= 0)
5821 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005822 hddLog(VOS_TRACE_LEVEL_ERROR,
5823 "%s: SME %s while requesting fullpower",
5824 __func__, (0 == lrc) ?
5825 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 }
5827 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005828 /* either we have a response or we timed out. if we timed
5829 out there is a race condition such that the callback
5830 function could be executing at the same time we are. of
5831 primary concern is if the callback function had already
5832 verified the "magic" but had not yet set the completion
5833 variable when a timeout occurred. we serialize these
5834 activities by invalidating the magic while holding a
5835 shared spinlock which will cause us to block if the
5836 callback is currently executing */
5837 spin_lock(&hdd_context_lock);
5838 context.magic = 0;
5839 spin_unlock(&hdd_context_lock);
5840
Arif Hussain6d2a3322013-11-17 19:50:10 -08005841 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 break;
5843 }
5844 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305845 if (hHal)
5846 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5847 else
5848 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 break;
5850 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305851 if (hHal)
5852 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5853 else
5854 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 break;
5856 case 3: //Request Bmps
5857 {
5858 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305859 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005860
5861 init_completion(&context.completion);
5862
5863 context.pAdapter = pAdapter;
5864 context.magic = POWER_CONTEXT_MAGIC;
5865
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305866 if (NULL == hHal)
5867 return -EINVAL;
5868
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305870 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005871 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 {
5873 int lrc = wait_for_completion_interruptible_timeout(
5874 &context.completion,
5875 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 if (lrc <= 0)
5877 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005878 hddLog(VOS_TRACE_LEVEL_ERROR,
5879 "%s: SME %s while requesting BMPS",
5880 __func__, (0 == lrc) ? "timeout" :
5881 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 }
5883 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005884 /* either we have a response or we timed out. if we
5885 timed out there is a race condition such that the
5886 callback function could be executing at the same
5887 time we are. of primary concern is if the callback
5888 function had already verified the "magic" but had
5889 not yet set the completion variable when a timeout
5890 occurred. we serialize these activities by
5891 invalidating the magic while holding a shared
5892 spinlock which will cause us to block if the
5893 callback is currently executing */
5894 spin_lock(&hdd_context_lock);
5895 context.magic = 0;
5896 spin_unlock(&hdd_context_lock);
5897
Arif Hussain6d2a3322013-11-17 19:50:10 -08005898 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 break;
5900 }
5901 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305902 if (hHal)
5903 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5904 else
5905 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 break;
5907 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305908 if (hHal)
5909 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5910 else
5911 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 break;
5913 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305914 if (hHal)
5915 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5916 else
5917 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 break;
5919 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305920 if (hHal)
5921 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5922 else
5923 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 break;
5925 case 8: //Request Standby
5926#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005927#endif
5928 break;
5929 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305930 if (hHal)
5931 sme_StartAutoBmpsTimer(hHal);
5932 else
5933 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 break;
5935 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305936 if (hHal)
5937 sme_StopAutoBmpsTimer(hHal);
5938 else
5939 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 break;
5941#ifdef CONFIG_HAS_EARLYSUSPEND
5942 case 11://suspend to standby
5943#ifdef CONFIG_HAS_EARLYSUSPEND
5944 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5945 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5947#endif
5948 break;
5949 case 12://suspend to deep sleep
5950#ifdef CONFIG_HAS_EARLYSUSPEND
5951 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5952 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5954#endif
5955 break;
5956 case 13://resume from suspend
5957#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005958#endif
5959 break;
5960#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005962 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 ret = -EINVAL;
5964 break;
5965 }
5966 break;
5967 }
5968
5969 case WE_SET_MAX_ASSOC:
5970 {
5971 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305972 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
5973 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 {
5975 ret = -EINVAL;
5976 }
5977 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5978 set_value, NULL, eANI_BOOLEAN_FALSE)
5979 != eHAL_STATUS_SUCCESS )
5980 {
c_hpothub8245442013-11-20 23:41:09 +05305981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5982 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 ret = -EIO;
5984 }
5985 break;
5986 }
5987
5988 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5989 {
5990 if( 0 == set_value )
5991 {
5992 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5993 }
5994 else if ( 1 == set_value )
5995 {
5996 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5997 }
5998 else
5999 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006000 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006001 ret = -EINVAL;
6002 }
6003 break;
6004 }
6005
6006 case WE_SET_DATA_INACTIVITY_TO:
6007 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306008 if (NULL == hHal)
6009 return -EINVAL;
6010
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
6012 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
6013 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
6014 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
6015 set_value,
6016 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
6017 {
6018 hddLog(LOGE,"Failure: Could not pass on "
6019 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006020 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 ret = -EINVAL;
6022 }
6023 break;
6024 }
6025 case WE_SET_MAX_TX_POWER:
6026 {
6027 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6028 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6029
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306030 if (NULL == hHal)
6031 return -EINVAL;
6032
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
6034 __func__, set_value);
6035 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
6036 eHAL_STATUS_SUCCESS )
6037 {
6038 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6039 __func__);
6040 return -EIO;
6041 }
6042
6043 break;
6044 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07006045 case WE_SET_MAX_TX_POWER_2_4:
6046 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306047 if (NULL == hHal)
6048 return -EINVAL;
6049
Arif Hussaina5ebce02013-08-09 15:09:58 -07006050 hddLog(VOS_TRACE_LEVEL_INFO,
6051 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
6052 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306053 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006054 eHAL_STATUS_SUCCESS)
6055 {
6056 hddLog(VOS_TRACE_LEVEL_ERROR,
6057 "%s: Setting maximum tx power failed for 2.4 GHz band",
6058 __func__);
6059 return -EIO;
6060 }
6061
6062 break;
6063 }
6064 case WE_SET_MAX_TX_POWER_5_0:
6065 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306066 if (NULL == hHal)
6067 return -EINVAL;
6068
Arif Hussaina5ebce02013-08-09 15:09:58 -07006069 hddLog(VOS_TRACE_LEVEL_INFO,
6070 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
6071 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306072 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006073 eHAL_STATUS_SUCCESS)
6074 {
6075 hddLog(VOS_TRACE_LEVEL_ERROR,
6076 "%s: Setting maximum tx power failed for 5.0 GHz band",
6077 __func__);
6078 return -EIO;
6079 }
6080
6081 break;
6082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 case WE_SET_HIGHER_DTIM_TRANSITION:
6084 {
6085 if(!((set_value == eANI_BOOLEAN_FALSE) ||
6086 (set_value == eANI_BOOLEAN_TRUE)))
6087 {
6088 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
6089 ret = -EINVAL;
6090 }
6091 else
6092 {
6093 if(pAdapter->higherDtimTransition != set_value)
6094 {
6095 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006096 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 }
6098 }
6099
6100 break;
6101 }
6102
6103 case WE_SET_TM_LEVEL:
6104 {
6105 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006106 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
6108
6109 break;
6110 }
6111
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306112 case WE_ENABLE_STRICT_FCC_REG:
6113 {
6114 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
6115 struct wiphy *wiphy = NULL;
6116 long lrc;
6117 int status;
6118
6119 wiphy = hddCtxt->wiphy;
6120 if(wiphy == NULL)
6121 {
6122 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
6123 break;
6124 }
6125 init_completion(&hddCtxt->wiphy_channel_update_event);
6126
6127 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
6128
6129 status = regulatory_hint(wiphy, "00");
6130 if(status < 0)
6131 {
6132 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
6133 break;
6134 }
6135
6136 /* Wait for completion */
6137 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
6138 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
6139 if (lrc <= 0)
6140 {
6141 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
6142 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
6143 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6144 }
6145 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
6146
6147 break;
6148 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006149 case WE_SET_DEBUG_LOG:
6150 {
6151 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6152 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306153 if (hHal)
6154 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
6155 else
6156 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006157 break;
6158 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05306159#ifdef FEATURE_WLAN_TDLS
6160 case WE_SET_TDLS_OFF_CHAN:
6161 {
6162 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
6164 __func__, set_value);
6165 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
6166 break;
6167 }
6168 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
6169 {
6170 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
6172 __func__, set_value);
6173 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
6174 break;
6175 }
6176 case WE_SET_TDLS_OFF_CHAN_MODE:
6177 {
6178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
6179 __func__, set_value);
6180 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
6181 break;
6182 }
6183#endif
Peng Xu2446a892014-09-05 17:21:18 +05306184 case WE_SET_SCAN_BAND_PREFERENCE:
6185 {
6186 tSmeConfigParams smeConfig;
6187 memset(&smeConfig, 0x00, sizeof(smeConfig));
6188 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6189 ret = -EINVAL;
6190 break;
6191 }
6192 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6193
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306194 if ((eCSR_BAND_ALL == set_value ||
6195 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6196 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306197 sme_GetConfigParam(hHal, &smeConfig);
6198 smeConfig.csrConfig.scanBandPreference = set_value;
6199
6200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6201 "set band scan preference = %d\n",
6202 smeConfig.csrConfig.scanBandPreference);
6203
6204 sme_UpdateConfig(hHal, &smeConfig);
6205 }
6206 else {
6207 ret = -EINVAL;
6208 }
6209 break;
6210 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306211 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6212 * connection happens so that the params can take effect during
6213 * association. Also this should not be used in STA+p2p concurrency
6214 * as the param will also effect the STA mode.
6215 */
6216 case WE_SET_MIRACAST_VENDOR_CONFIG:
6217 {
6218 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306219
Abhishek Singh01c73d12015-03-12 15:13:44 +05306220 hddLog(LOG1, FL(
6221 "Set Miracast vendor tuning %d"), set_value);
6222
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306223 if (NULL == hHal)
6224 return -EINVAL;
6225
Abhishek Singh01c73d12015-03-12 15:13:44 +05306226 if (1 == set_value || 0 == set_value)
6227 {
6228 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6229 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6230 {
6231 hddLog( LOGE, FL("set vendor miracast config failed"));
6232 ret = -EIO;
6233 }
6234 }
6235 else
6236 {
6237 hddLog(LOGE,
6238 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6239 ret = -EINVAL;
6240 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306241 break;
6242 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306243
6244 case WE_GET_FRAME_LOG:
6245 {
6246 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6247 != VOS_STATUS_SUCCESS)
6248 {
6249 ret = -EINVAL;
6250 }
6251 break;
6252 }
6253
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306254 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6255 {
6256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6257 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306258 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306259 {
6260 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6261 set_value);
6262 }
6263 else
6264 ret = -EINVAL;
6265
6266 break;
6267 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306268 /* Bit mask value to enable RTS/CTS for different modes
6269 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6270 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6271 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6272 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6273 * for 5 GHz, VHT80 - 0x1000
6274 */
6275 case WE_SET_RTS_CTS_HTVHT:
6276 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306277
Abhishek Singh41988ba2015-05-25 19:42:29 +05306278 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6279
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306280 if (NULL == hHal)
6281 return -EINVAL;
6282
Abhishek Singh41988ba2015-05-25 19:42:29 +05306283 if (eHAL_STATUS_SUCCESS !=
6284 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6285 {
6286 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6287 ret = -EINVAL;
6288 }
6289 break;
6290 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306291 case WE_SET_MONITOR_STATE:
6292 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306293 v_U32_t magic = 0;
6294 struct completion cmpVar;
6295 long waitRet = 0;
6296 tVOS_CON_MODE mode = hdd_get_conparam();
6297
6298 if( VOS_MONITOR_MODE != mode)
6299 {
6300 hddLog(LOGE, "invalid mode %d", mode);
6301 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306302 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306303 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306304
6305 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6306 if( pMonCtx == NULL )
6307 {
6308 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306309 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306310 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306311 }
6312 if (pMonCtx->state == set_value)
6313 {
6314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6315 FL("already in same mode curr_mode:%d req_mode: %d"),
6316 pMonCtx->state, set_value);
6317 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306318 }
6319 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306320 magic = MON_MODE_MSG_MAGIC;
6321 init_completion(&cmpVar);
6322 if (VOS_STATUS_SUCCESS !=
6323 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6324 pMonCtx, hdd_monPostMsgCb)) {
6325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6326 FL("failed to post MON MODE REQ"));
6327 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6328 MON_MODE_STOP : MON_MODE_START;
6329 magic = 0;
6330 ret = -EIO;
6331 break;
6332 }
6333 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6334 magic = 0;
6335 if (waitRet <= 0 ){
6336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6337 FL("failed to wait on monitor mode completion %ld"),
6338 waitRet);
6339 }
6340 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306341 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306342 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6343 {
6344 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6345 tAniWifiStartLog start_log;
6346 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6347 !vos_isPktStatsEnabled())
6348 {
6349 hddLog(LOGE, FL("per pkt stats not enabled"));
6350 return -EINVAL;
6351 }
6352 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6353
6354 if (1 == set_value || 0 == set_value)
6355 {
6356 start_log.ringId = RING_ID_PER_PACKET_STATS;
6357 start_log.flag = 0;
6358 if (set_value)
6359 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6360 else
6361 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6362
6363 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6364 }
6365 else
6366 {
6367 hddLog(LOGE,
6368 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6369 set_value);
6370 ret = -EINVAL;
6371 }
6372 break;
6373 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306374 case WE_SET_PROXIMITY_ENABLE:
6375 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306376 if (NULL == hHal)
6377 return -EINVAL;
6378
6379 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306380 break;
6381 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05306382 case WE_CAP_TSF:
6383 {
6384 if (NULL == hHal)
6385 return -EINVAL;
6386
6387 ret = hdd_capture_tsf(pAdapter, (uint32_t *)&set_value, 1);
6388 break;
6389 }
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306390 case WE_SET_MODULATED_DTIM:
6391 {
6392 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6393 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6394 hddLog(LOGE, FL("Invalid value %d in gEnableModuleDTIM"),
6395 set_value);
6396 return -EINVAL;
6397 } else {
6398 ret = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->
6399 enableModulatedDTIM = set_value;
6400 }
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05306401 }
6402 case WLAN_SET_DYNNAMIC_AGGREGATION:
6403 {
6404 if (NULL == hHal)
6405 return -EINVAL;
6406
6407 ret = hdd_set_dynamic_aggregation(set_value, pAdapter);
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306408 break;
6409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 default:
6411 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006412 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 sub_cmd, set_value);
6414 break;
6415 }
6416 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306417 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 return ret;
6419}
6420
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306421static int iw_setint_getnone(struct net_device *dev,
6422 struct iw_request_info *info,
6423 union iwreq_data *wrqu, char *extra)
6424{
6425 int ret;
6426
6427 vos_ssr_protect(__func__);
6428 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6429 vos_ssr_unprotect(__func__);
6430
6431 return 0;
6432}
Jeff Johnson295189b2012-06-20 16:38:30 -07006433/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306434static int __iw_setchar_getnone(struct net_device *dev,
6435 struct iw_request_info *info,
6436 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006437{
6438 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306439 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006441 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306442 hdd_adapter_t *pAdapter;
6443 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006444#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306445 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006446#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306447 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306448 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006449
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306450 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306451
6452 if (!capable(CAP_NET_ADMIN))
6453 {
6454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6455 FL("permission check failed"));
6456 return -EPERM;
6457 }
6458
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306459 pAdapter = (netdev_priv(dev));
6460 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006461 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6463 "%s: Adapter is NULL",__func__);
6464 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006465 }
6466
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306467 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6468 ret = wlan_hdd_validate_context(pHddCtx);
6469 if (0 != ret)
6470 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306471 return ret;
6472 }
6473#ifdef WLAN_FEATURE_VOWIFI
6474 pConfig = pHddCtx->cfg_ini;
6475#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306476 /* helper function to get iwreq_data with compat handling. */
6477 if (hdd_priv_get_data(&s_priv_data, wrqu))
6478 {
6479 return -EINVAL;
6480 }
6481
6482 /* make sure all params are correctly passed to function */
6483 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6484 {
6485 return -EINVAL;
6486 }
6487
6488 sub_cmd = s_priv_data.flags;
6489
Arif Hussain0273cba2014-01-07 20:58:29 -08006490 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306491 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6492 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006493 if (NULL == pBuffer)
6494 {
6495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6496 "mem_alloc_copy_from_user_helper fail");
6497 return -ENOMEM;
6498 }
6499
6500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306501 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6503 "%s: Received data %s", __func__, pBuffer);
6504
Jeff Johnson295189b2012-06-20 16:38:30 -07006505 switch(sub_cmd)
6506 {
6507 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006509 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 break;
6511 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006513 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 break;
6515#if defined WLAN_FEATURE_VOWIFI
6516 case WE_NEIGHBOR_REPORT_REQUEST:
6517 {
6518 tRrmNeighborReq neighborReq;
6519 tRrmNeighborRspCallbackInfo callbackInfo;
6520
6521 if (pConfig->fRrmEnable)
6522 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306524 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006525 if( !neighborReq.no_ssid )
6526 {
Girish Gowli552fc072014-06-14 18:26:16 +05306527 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006528 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 }
6530
6531 callbackInfo.neighborRspCallback = NULL;
6532 callbackInfo.neighborRspCallbackContext = NULL;
6533 callbackInfo.timeout = 5000; //5 seconds
6534 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6535 }
6536 else
6537 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006538 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 ret = -EINVAL;
6540 }
6541 }
6542 break;
6543#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 case WE_SET_AP_WPS_IE:
6545 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306546 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006549 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 if (VOS_STATUS_SUCCESS != vstatus)
6551 {
6552 ret = -EINVAL;
6553 }
6554 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306555 case WE_SET_ENCRYPT_MSG:
6556 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6557 if (NULL == pkt)
6558 {
6559 hddLog(VOS_TRACE_LEVEL_ERROR,
6560 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306561 ret = -ENOMEM;
6562 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306563 }
6564
6565 memset(pkt, 0, sizeof(tSirpkt80211));
6566
6567 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6568 hddLog(VOS_TRACE_LEVEL_ERROR,
6569 FL("Firmware is not DISA capable"));
6570 ret = -EINVAL;
6571 vos_mem_free(pkt);
6572 break;
6573 }
6574
6575 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6576
6577 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6578 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6579 if (eHAL_STATUS_SUCCESS != ret) {
6580 hddLog(VOS_TRACE_LEVEL_ERROR,
6581 FL("SENDEncryptMSG: fail to post WDA cmd"));
6582 ret = -EINVAL;
6583 }
6584 vos_mem_free(pkt);
6585
6586 break;
6587
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 default:
6589 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006590 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006591 ret = -EINVAL;
6592 break;
6593 }
6594 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006595 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306596
6597 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 return ret;
6599}
6600
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306601static int iw_setchar_getnone(struct net_device *dev,
6602 struct iw_request_info *info,
6603 union iwreq_data *wrqu, char *extra)
6604{
6605 int ret;
6606
6607 vos_ssr_protect(__func__);
6608 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6609 vos_ssr_unprotect(__func__);
6610
6611 return ret;
6612}
6613
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306614static void hdd_GetCurrentAntennaIndex(int antennaId, void *pContext)
6615{
6616 struct statsContext *context;
6617 hdd_adapter_t *pAdapter;
6618
6619 if (NULL == pContext)
6620 {
6621 hddLog(VOS_TRACE_LEVEL_ERROR,
6622 "%s: Bad param, pContext [%p]",
6623 __func__, pContext);
6624 return;
6625 }
6626
6627 context = pContext;
6628 pAdapter = context->pAdapter;
6629
6630 spin_lock(&hdd_context_lock);
6631
6632 if ((NULL == pAdapter) || (ANTENNA_CONTEXT_MAGIC != context->magic))
6633 {
6634 /* the caller presumably timed out so there is nothing we can do */
6635 spin_unlock(&hdd_context_lock);
6636 hddLog(VOS_TRACE_LEVEL_WARN,
6637 "%s: Invalid context, pAdapter [%p] magic [%08x]",
6638 __func__, pAdapter, context->magic);
6639 return;
6640 }
6641
6642 context->magic = 0;
6643 pAdapter->antennaIndex = antennaId;
6644
6645 complete(&context->completion);
6646 spin_unlock(&hdd_context_lock);
6647}
6648
6649static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6650 int *antennaIndex)
6651{
6652 hdd_context_t *pHddCtx;
6653 eHalStatus halStatus;
6654 struct statsContext context;
6655 long lrc;
6656
6657 ENTER();
6658 if (NULL == pAdapter)
6659 {
6660 hddLog(VOS_TRACE_LEVEL_WARN,
6661 "%s: Invalid context, pAdapter", __func__);
6662 return VOS_STATUS_E_FAULT;
6663 }
6664 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6665 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6666 {
6667 return VOS_STATUS_E_FAULT;
6668 }
6669 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6670 {
6671 hddLog(VOS_TRACE_LEVEL_ERROR,
6672 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6673 __func__);
6674 return VOS_STATUS_E_NOSUPPORT;
6675 }
6676 init_completion(&context.completion);
6677 context.pAdapter = pAdapter;
6678 context.magic = ANTENNA_CONTEXT_MAGIC;
6679
6680 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
6681 hdd_GetCurrentAntennaIndex,
6682 &context, pAdapter->sessionId);
6683 if (eHAL_STATUS_SUCCESS != halStatus)
6684 {
6685 spin_lock(&hdd_context_lock);
6686 context.magic = 0;
6687 spin_unlock(&hdd_context_lock);
6688 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6689 __func__);
6690 /* we'll returned a cached value below */
6691 *antennaIndex = -1;
6692 return VOS_STATUS_E_FAILURE;
6693 }
6694 else
6695 {
6696 /* request was sent -- wait for the response */
6697 lrc = wait_for_completion_interruptible_timeout(&context.completion,
6698 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
6699 if (lrc <= 0)
6700 {
6701 spin_lock(&hdd_context_lock);
6702 context.magic = 0;
6703 spin_unlock(&hdd_context_lock);
6704 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:SME %s while retrieving Antenna"
6705 " Index",
6706 __func__, (0 == lrc) ? "timeout" : "interrupt");
6707 *antennaIndex = -1;
6708 return VOS_STATUS_E_FAILURE;
6709 }
6710 }
6711 spin_lock(&hdd_context_lock);
6712 context.magic = 0;
6713 spin_unlock(&hdd_context_lock);
6714
6715 *antennaIndex = pAdapter->antennaIndex;
6716
6717 EXIT();
6718 return VOS_STATUS_SUCCESS;
6719}
6720
Jeff Johnson295189b2012-06-20 16:38:30 -07006721/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306722static int __iw_setnone_getint(struct net_device *dev,
6723 struct iw_request_info *info,
6724 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006725{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306726 hdd_adapter_t *pAdapter;
6727 tHalHandle hHal;
6728 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 int *value = (int *)extra;
6730 int ret = 0; /* success */
6731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306732 ENTER();
6733
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306734 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6735 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006736 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6738 "%s: Adapter is NULL",__func__);
6739 return -EINVAL;
6740 }
6741 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6742 ret = wlan_hdd_validate_context(pHddCtx);
6743 if (0 != ret)
6744 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306745 return ret;
6746 }
6747 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6748 if (NULL == hHal)
6749 {
6750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6751 "%s: Hal Context is NULL",__func__);
6752 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006754
6755 switch (value[0])
6756 {
6757 case WE_GET_11D_STATE:
6758 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006759 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006760 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306761
Jeff Johnson295189b2012-06-20 16:38:30 -07006762 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6763
Arif Hussain6d2a3322013-11-17 19:50:10 -08006764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006765
6766 break;
6767 }
6768
6769 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 break;
6772
6773 case WE_PMC_STATE:
6774 {
6775 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 break;
6778 }
6779 case WE_GET_WLAN_DBG:
6780 {
6781 vos_trace_display();
6782 *value = 0;
6783 break;
6784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 case WE_GET_MAX_ASSOC:
6786 {
6787 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6788 {
c_hpothub8245442013-11-20 23:41:09 +05306789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6790 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006791 ret = -EIO;
6792 }
Girish Gowli385be612014-09-18 11:17:20 +05306793#ifdef WLAN_SOFTAP_VSTA_FEATURE
6794 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6795 {
6796 if (*value > VSTA_NUM_ASSOC_STA)
6797 {
6798 *value = VSTA_NUM_ASSOC_STA;
6799 }
6800 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6801 (*value > (VSTA_NUM_ASSOC_STA -
6802 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6803 {
6804 *value = (VSTA_NUM_ASSOC_STA -
6805 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6806 }
6807 }
6808 else
6809#endif
6810 {
6811 if (*value > NUM_ASSOC_STA)
6812 {
6813 *value = NUM_ASSOC_STA;
6814 }
6815 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6816 (*value > (NUM_ASSOC_STA -
6817 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6818 {
6819 *value = (NUM_ASSOC_STA -
6820 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6821 }
6822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006823 break;
6824 }
6825
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 case WE_GET_WDI_DBG:
6827 {
6828 wpalTraceDisplay();
6829 *value = 0;
6830 break;
6831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006832
6833 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6834 {
6835 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6836 break;
6837 }
6838 case WE_GET_CONCURRENCY_MODE:
6839 {
6840 *value = hdd_get_concurrency_mode ( );
6841
Arif Hussain6d2a3322013-11-17 19:50:10 -08006842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 break;
6844 }
6845
Peng Xu2446a892014-09-05 17:21:18 +05306846 case WE_GET_SCAN_BAND_PREFERENCE:
6847 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306848 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306849 sme_GetConfigParam(hHal, &smeConfig);
6850 *value = smeConfig.csrConfig.scanBandPreference;
6851
6852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6853 "scanBandPreference = %d\n", *value);
6854 break;
6855 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306856 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6857 {
6858 wlan_hdd_get_current_antenna_index(pAdapter, value);
6859 break;
6860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006861 default:
6862 {
6863 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6864 break;
6865 }
6866 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306867 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 return ret;
6869}
6870
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306871static int iw_setnone_getint(struct net_device *dev,
6872 struct iw_request_info *info,
6873 union iwreq_data *wrqu, char *extra)
6874{
6875 int ret;
6876
6877 vos_ssr_protect(__func__);
6878 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6879 vos_ssr_unprotect(__func__);
6880
6881 return ret;
6882
6883}
Jeff Johnson295189b2012-06-20 16:38:30 -07006884/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306885int __iw_set_three_ints_getnone(struct net_device *dev,
6886 struct iw_request_info *info,
6887 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006888{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306889 hdd_adapter_t *pAdapter;
6890 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 int *value = (int *)extra;
6892 int sub_cmd = value[0];
6893 int ret = 0;
6894
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306895 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306896
6897 if (!capable(CAP_NET_ADMIN))
6898 {
6899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6900 FL("permission check failed"));
6901 return -EPERM;
6902 }
6903
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306904 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6905 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006906 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6908 "%s: Adapter is NULL",__func__);
6909 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006910 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306911 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6912 ret = wlan_hdd_validate_context(pHddCtx);
6913 if (0 != ret)
6914 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306915 return ret;
6916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006917 switch(sub_cmd)
6918 {
6919 case WE_SET_WLAN_DBG:
6920 {
6921 vos_trace_setValue( value[1], value[2], value[3]);
6922 break;
6923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 case WE_SET_WDI_DBG:
6925 {
6926 wpalTraceSetLevel( value[1], value[2], value[3]);
6927 break;
6928 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 case WE_SET_SAP_CHANNELS:
6930 {
6931 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6932 break;
6933 }
6934
6935 default:
6936 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006937 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 break;
6939 }
6940 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306941 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 return ret;
6943}
6944
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306945int iw_set_three_ints_getnone(struct net_device *dev,
6946 struct iw_request_info *info,
6947 union iwreq_data *wrqu, char *extra)
6948{
6949 int ret;
6950
6951 vos_ssr_protect(__func__);
6952 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6953 vos_ssr_unprotect(__func__);
6954
6955 return ret;
6956}
6957
6958static int __iw_get_char_setnone(struct net_device *dev,
6959 struct iw_request_info *info,
6960 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006961{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306962 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306964 hdd_context_t *pHddCtx;
6965 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006966#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006967 hdd_wext_state_t *pWextState;
6968#endif
6969
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306970 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306971 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006972 if (pAdapter == NULL)
6973 {
6974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6975 "%s: pAdapter is NULL!", __func__);
6976 return -EINVAL;
6977 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306978 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6979 ret = wlan_hdd_validate_context(pHddCtx);
6980 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006981 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306982 return ret;
6983 }
6984#ifdef WLAN_FEATURE_11W
6985 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6986 if (NULL == pWextState)
6987 {
6988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6989 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006990 return -EINVAL;
6991 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306992#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006993
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 switch(sub_cmd)
6995 {
6996 case WE_WLAN_VERSION:
6997 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006998 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006999 break;
7000 }
7001
7002 case WE_GET_STATS:
7003 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307004 tHalHandle hHal = NULL;
7005 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7007 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
7008 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
7009
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307010
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 snprintf(extra, WE_MAX_STR_LEN,
7012 "\nTransmit"
7013 "\ncalled %u, dropped %u, backpressured %u, queued %u"
7014 "\n dropped BK %u, BE %u, VI %u, VO %u"
7015 "\n classified BK %u, BE %u, VI %u, VO %u"
7016 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
7017 "\n queued BK %u, BE %u, VI %u, VO %u"
7018 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007019 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 "\n fetched BK %u, BE %u, VI %u, VO %u"
7021 "\n dequeued BK %u, BE %u, VI %u, VO %u"
7022 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007023 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 "\n flushed BK %u, BE %u, VI %u, VO %u"
7025 "\n\nReceive"
7026 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
7027 "\n\nResetsStats"
7028 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
7029 "\n",
7030 pStats->txXmitCalled,
7031 pStats->txXmitDropped,
7032 pStats->txXmitBackPressured,
7033 pStats->txXmitQueued,
7034
7035 pStats->txXmitDroppedAC[WLANTL_AC_BK],
7036 pStats->txXmitDroppedAC[WLANTL_AC_BE],
7037 pStats->txXmitDroppedAC[WLANTL_AC_VI],
7038 pStats->txXmitDroppedAC[WLANTL_AC_VO],
7039
7040 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
7041 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
7042 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
7043 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
7044
7045 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
7046 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
7047 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
7048 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
7049
7050 pStats->txXmitQueuedAC[WLANTL_AC_BK],
7051 pStats->txXmitQueuedAC[WLANTL_AC_BE],
7052 pStats->txXmitQueuedAC[WLANTL_AC_VI],
7053 pStats->txXmitQueuedAC[WLANTL_AC_VO],
7054
7055 pStats->txFetched,
7056 pStats->txFetchEmpty,
7057 pStats->txFetchLowResources,
7058 pStats->txFetchDequeueError,
7059
7060 pStats->txFetchDequeued,
7061 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07007062 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 pStats->txCompleted,
7064 pStats->txFlushed,
7065
7066 pStats->txFetchedAC[WLANTL_AC_BK],
7067 pStats->txFetchedAC[WLANTL_AC_BE],
7068 pStats->txFetchedAC[WLANTL_AC_VI],
7069 pStats->txFetchedAC[WLANTL_AC_VO],
7070
7071 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
7072 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
7073 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
7074 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
7075
7076 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
7077 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
7078 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
7079 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
7080
Ravi Joshi41914632013-10-21 23:02:21 -07007081 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
7082 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
7083 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
7084 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
7085
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 pStats->txFlushedAC[WLANTL_AC_BK],
7087 pStats->txFlushedAC[WLANTL_AC_BE],
7088 pStats->txFlushedAC[WLANTL_AC_VI],
7089 pStats->txFlushedAC[WLANTL_AC_VO],
7090
7091 pStats->rxChains,
7092 pStats->rxPackets,
7093 pStats->rxDropped,
7094 pStats->rxDelivered,
7095 pStats->rxRefused,
7096
7097 pResetStats->totalLogpResets,
7098 pResetStats->totalCMD53Failures,
7099 pResetStats->totalMutexReadFailures,
7100 pResetStats->totalMIFErrorFailures,
7101 pResetStats->totalFWHearbeatFailures,
7102 pResetStats->totalUnknownExceptions
7103 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307104 wrqu->data.length = strlen(extra);
7105
7106 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7107
7108 if (hHal)
7109 pMac = PMAC_STRUCT( hHal );
7110
7111 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7112 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7113 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307114 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7115 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7116 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7117 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307118 "\n",
7119 pMac->pmm.BmpscntSleep,
7120 pMac->pmm.BmpscntAwake,
7121 pMac->pmm.BmpsSleeReqFailCnt,
7122 pMac->pmm.BmpsWakeupReqFailCnt,
7123 pMac->pmm.ImpsCntSleep,
7124 pMac->pmm.ImpsCntAwake,
7125 pMac->pmm.ImpsSleepErrCnt,
7126 pMac->pmm.ImpsWakeupErrCnt,
7127 pMac->pmm.ImpsLastErr
7128 );
7129 }
7130
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 wrqu->data.length = strlen(extra)+1;
7132 break;
7133 }
7134
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307135/* The case prints the current state of the HDD, SME, CSR, PE, TL
7136 *it can be extended for WDI Global State as well.
7137 *And currently it only checks P2P_CLIENT adapter.
7138 *P2P_DEVICE and P2P_GO have not been added as of now.
7139*/
7140 case WE_GET_STATES:
7141 {
7142 int buf = 0, len = 0;
7143 int adapter_num = 0;
7144 int count = 0, check = 1;
7145
7146 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007147 tHalHandle hHal = NULL;
7148 tpAniSirGlobal pMac = NULL;
7149 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307150
7151 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7152 hdd_adapter_t *useAdapter = NULL;
7153
7154 /* Print wlan0 or p2p0 states based on the adapter_num
7155 *by using the correct adapter
7156 */
7157 while ( adapter_num < 2 )
7158 {
7159 if ( WLAN_ADAPTER == adapter_num )
7160 {
7161 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007162 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307163 "\n\n wlan0 States:-");
7164 len += buf;
7165 }
7166 else if ( P2P_ADAPTER == adapter_num )
7167 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007168 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307169 "\n\n p2p0 States:-");
7170 len += buf;
7171
7172 if( !pHddCtx )
7173 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007174 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307175 "\n pHddCtx is NULL");
7176 len += buf;
7177 break;
7178 }
7179
7180 /*Printing p2p0 states only in the case when the device is
7181 configured as a p2p_client*/
7182 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7183 if ( !useAdapter )
7184 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007185 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307186 "\n Device not configured as P2P_CLIENT.");
7187 len += buf;
7188 break;
7189 }
7190 }
7191
7192 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007193 if (!hHal) {
7194 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7195 "\n pMac is NULL");
7196 len += buf;
7197 break;
7198 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307199 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007200 if (!pMac) {
7201 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7202 "\n pMac is NULL");
7203 len += buf;
7204 break;
7205 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307206 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7207 if( !pHddStaCtx )
7208 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007209 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307210 "\n pHddStaCtx is NULL");
7211 len += buf;
7212 break;
7213 }
7214
7215 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7216
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007217 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307218 "\n HDD Conn State - %s "
7219 "\n \n SME State:"
7220 "\n Neighbour Roam State - %s"
7221 "\n CSR State - %s"
7222 "\n CSR Substate - %s"
7223 "\n \n TL STA %d State: %s",
7224 macTraceGetHDDWlanConnState(
7225 pHddStaCtx->conn_info.connState),
7226 macTraceGetNeighbourRoamState(
7227 pMac->roam.neighborRoamInfo.neighborRoamState),
7228 macTraceGetcsrRoamState(
7229 pMac->roam.curState[useAdapter->sessionId]),
7230 macTraceGetcsrRoamSubState(
7231 pMac->roam.curSubState[useAdapter->sessionId]),
7232 pHddStaCtx->conn_info.staId[0],
7233 macTraceGetTLState(tlState)
7234 );
7235 len += buf;
7236 adapter_num++;
7237 }
7238
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007239 if (pMac) {
7240 /* Printing Lim State starting with global lim states */
7241 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7242 "\n \n LIM STATES:-"
7243 "\n Global Sme State - %s "\
7244 "\n Global mlm State - %s "\
7245 "\n",
7246 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7247 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7248 );
7249 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307250
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007251 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307252 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307253 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007254 if ( pMac->lim.gpSession[count].valid )
7255 {
7256 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7257 "\n Lim Valid Session %d:-"
7258 "\n PE Sme State - %s "
7259 "\n PE Mlm State - %s "
7260 "\n",
7261 check,
7262 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7263 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7264 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307265
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007266 len += buf;
7267 check++;
7268 }
7269 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307270 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307271 }
7272
7273 wrqu->data.length = strlen(extra)+1;
7274 break;
7275 }
7276
Jeff Johnson295189b2012-06-20 16:38:30 -07007277 case WE_GET_CFG:
7278 {
7279 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7280 wrqu->data.length = strlen(extra)+1;
7281 break;
7282 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007283#ifdef WLAN_FEATURE_11AC
7284 case WE_GET_RSSI:
7285 {
7286 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307287 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007288 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7289 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7290 wrqu->data.length = strlen(extra)+1;
7291 break;
7292 }
7293#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307294
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007295#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007296 case WE_GET_ROAM_RSSI:
7297 {
7298 v_S7_t s7Rssi = 0;
7299 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7300 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7301 wrqu->data.length = strlen(extra)+1;
7302 break;
7303 }
7304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 case WE_GET_WMM_STATUS:
7306 {
7307 snprintf(extra, WE_MAX_STR_LEN,
7308 "\nDir: 0=up, 1=down, 3=both\n"
7309 "|------------------------|\n"
7310 "|AC | ACM |Admitted| Dir |\n"
7311 "|------------------------|\n"
7312 "|VO | %d | %3s | %d |\n"
7313 "|VI | %d | %3s | %d |\n"
7314 "|BE | %d | %3s | %d |\n"
7315 "|BK | %d | %3s | %d |\n"
7316 "|------------------------|\n",
7317 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7318 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7319 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7320 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7321 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7322 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7323 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7324 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7325 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7326 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7327 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7328 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7329
Jeff Johnsone7245742012-09-05 17:12:55 -07007330
Jeff Johnson295189b2012-06-20 16:38:30 -07007331 wrqu->data.length = strlen(extra)+1;
7332 break;
7333 }
7334 case WE_GET_CHANNEL_LIST:
7335 {
7336 VOS_STATUS status;
7337 v_U8_t i, len;
7338 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307339 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7340 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7341 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 tChannelListInfo channel_list;
7343
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007344 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007346 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007348 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007349 return -EINVAL;
7350 }
7351 buf = extra;
7352
7353 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007354 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7355 * needed = 5 * number of channels. Check ifsufficient
7356 * buffer is available and then proceed to fill the buffer.
7357 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7359 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007360 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007361 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007362 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007363 return -EINVAL;
7364 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007365 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7366 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307367 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7368 {
7369 //Printing Country code in getChannelList
7370 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7371 {
7372 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7373 "%c ", pBuf[i]);
7374 }
7375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007376 for(i = 0 ; i < channel_list.num_channels; i++)
7377 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007378 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007380 }
7381 wrqu->data.length = strlen(extra)+1;
7382
7383 break;
7384 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007385#ifdef FEATURE_WLAN_TDLS
7386 case WE_GET_TDLS_PEERS:
7387 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007388 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007389 break;
7390 }
7391#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007392#ifdef WLAN_FEATURE_11W
7393 case WE_GET_11W_INFO:
7394 {
7395 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7396
7397 snprintf(extra, WE_MAX_STR_LEN,
7398 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7399 "\n Number of Unprotected Disassocs %d"
7400 "\n Number of Unprotected Deauths %d",
7401 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7402 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7403 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7404 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7405 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7406
7407 wrqu->data.length = strlen(extra)+1;
7408 break;
7409 }
7410#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307411#ifdef WLAN_FEATURE_RMC
7412 case WE_GET_IBSS_STA_INFO:
7413 {
7414 hdd_station_ctx_t *pHddStaCtx =
7415 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7416 int idx = 0;
7417 int length = 0, buf = 0;
7418
7419 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7420 {
7421 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7422 {
7423 buf = snprintf
7424 (
7425 (extra + length), WE_MAX_STR_LEN - length,
7426 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7427 pHddStaCtx->conn_info.staId[ idx ],
7428 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7429 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7430 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7431 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7432 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7433 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7434 );
7435 length += buf;
7436 }
7437 }
7438 wrqu->data.length = strlen(extra)+1;
7439 break;
7440 }
7441#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307442 case WE_GET_SNR:
7443 {
7444 v_S7_t s7snr = 0;
7445 int status = 0;
7446 hdd_context_t *pHddCtx;
7447 hdd_station_ctx_t *pHddStaCtx;
7448
7449 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7450 status = wlan_hdd_validate_context(pHddCtx);
7451 if (0 != status)
7452 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307453 return status;
7454 }
7455
7456 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7457
7458 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7459 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7460 {
7461 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7462 " ConnectionState-%d", __func__,
7463 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7464 pHddStaCtx->conn_info.connState);
7465 return -ENONET;
7466 }
7467
7468 /*update the stats in TL*/
7469 wlan_hdd_get_station_stats(pAdapter);
7470 wlan_hdd_get_snr(pAdapter, &s7snr);
7471 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7472 wrqu->data.length = strlen(extra) + 1;
7473 break;
7474 }
7475
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307476#ifdef FEATURE_OEM_DATA_SUPPORT
7477 case WE_GET_OEM_DATA_CAP:
7478 {
7479 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7480 }
7481#endif /* FEATURE_OEM_DATA_SUPPORT */
7482
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307483 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007484 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007485 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 break;
7487 }
7488 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307489 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 return 0;
7491}
7492
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307493static int iw_get_char_setnone(struct net_device *dev,
7494 struct iw_request_info *info,
7495 union iwreq_data *wrqu, char *extra)
7496{
7497 int ret;
7498
7499 vos_ssr_protect(__func__);
7500 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7501 vos_ssr_unprotect(__func__);
7502
7503 return ret;
7504}
7505
Jeff Johnson295189b2012-06-20 16:38:30 -07007506/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307507static int __iw_setnone_getnone(struct net_device *dev,
7508 struct iw_request_info *info,
7509 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007510{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307511 hdd_adapter_t *pAdapter;
7512 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307513 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007514 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307515 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007516
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307517 ENTER();
7518
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307519 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7520 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007521 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7523 "%s: Adapter is NULL",__func__);
7524 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007525 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307526 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7527 ret = wlan_hdd_validate_context(pHddCtx);
7528 if (0 != ret)
7529 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307530 return ret;
7531 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307532 /* helper function to get iwreq_data with compat handling. */
7533 if (hdd_priv_get_data(&s_priv_data, wrqu))
7534 {
7535 return -EINVAL;
7536 }
7537
7538 sub_cmd = s_priv_data.flags;
7539
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 switch (sub_cmd)
7541 {
7542 case WE_CLEAR_STATS:
7543 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7546 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7547 break;
7548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 case WE_INIT_AP:
7550 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307551 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7552
7553 /* As Soft AP mode might been changed to STA already with
7554 * killing of Hostapd, need to find the adpater by name
7555 * rather than mode */
7556 hdd_adapter_t* pAdapter_to_stop =
7557 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7558 if( pAdapter_to_stop )
7559 {
7560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7561 "Adapter with name softap.0 already "
7562 "exist, ignoring the request.\nRemove the "
7563 "adapter and try again\n");
7564 break;
7565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 pr_info("Init AP trigger\n");
7567 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7568 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7569 break;
7570 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307571#ifdef WLAN_FEATURE_RMC
7572 case WE_IBSS_GET_PEER_INFO_ALL:
7573 {
7574 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7575 break;
7576 }
7577#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 case WE_STOP_AP:
7579 {
7580 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7581 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7582 * this is a dead code and need to find the adpater by name rather than mode */
7583 hdd_adapter_t* pAdapter_to_stop =
7584 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7585 if( pAdapter_to_stop )
7586 {
7587 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7588
7589 pr_info("Stopping AP mode\n");
7590
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307591 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7592 {
7593 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7594 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7595 }
7596
Jeff Johnson295189b2012-06-20 16:38:30 -07007597 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307598 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307599 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007600 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7601
7602 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7603 pAdapter_to_stop->macAddressCurrent.bytes);
7604 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7605 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307606
7607 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7608 {
7609 /* put the device back into BMPS */
7610 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 }
7613 else
7614 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007615 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 }
7617
7618 break;
7619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007620#ifdef WLAN_BTAMP_FEATURE
7621 case WE_ENABLE_AMP:
7622 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007624 WLANBAP_RegisterWithHCI(pAdapter);
7625 break;
7626 }
7627 case WE_DISABLE_AMP:
7628 {
7629 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7630 VOS_STATUS status;
7631
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007633
7634 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7635 status = WLANBAP_StopAmp();
7636 if(VOS_STATUS_SUCCESS != status )
7637 {
7638 pHddCtx->isAmpAllowed = VOS_TRUE;
7639 hddLog(VOS_TRACE_LEVEL_FATAL,
7640 "%s: Failed to stop AMP", __func__);
7641 }
7642 else
7643 {
7644 //a state m/c implementation in PAL is TBD to avoid this delay
7645 msleep(500);
7646 pHddCtx->isAmpAllowed = VOS_FALSE;
7647 WLANBAP_DeregisterFromHCI();
7648 }
7649
7650 break;
7651 }
7652#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007653 case WE_ENABLE_DXE_STALL_DETECT:
7654 {
schang6295e542013-03-12 15:31:23 -07007655 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7656 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007657 break;
7658 }
7659 case WE_DISPLAY_DXE_SNAP_SHOT:
7660 {
schang6295e542013-03-12 15:31:23 -07007661 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7662 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007663 break;
7664 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307665 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7666 {
7667 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7668 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307669 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307670 break;
7671 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307672
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307673 case WE_SET_REASSOC_TRIGGER:
7674 {
7675 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7676 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7677 v_U32_t roamId = 0;
7678 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307679 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7680 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307681 return 0;
7682 }
7683
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307684 case WE_STOP_OBSS_SCAN:
7685 {
7686 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7687 2.OBSS scan is stopped by Firmware during the disassociation
7688 3.OBSS stop comamnd is added for debugging purpose*/
7689 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7690 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007691
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307692 if (pAdapter == NULL)
7693 {
7694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7695 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307696 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307697 }
7698 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7699 if (pMac == NULL)
7700 {
7701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7702 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307703 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307704 }
7705 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7706 }
7707 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307708 case WE_DUMP_ROAM_TIMER_LOG:
7709 {
7710 vos_dump_roam_time_log_service();
7711 break;
7712 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307713
Mukul Sharma84f27252014-07-14 18:11:42 +05307714 case WE_RESET_ROAM_TIMER_LOG:
7715 {
7716 vos_reset_roam_timer_log();
7717 break;
7718 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307719 case WE_GET_FW_LOGS:
7720 {
7721 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7722 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307723 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307724 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307725 break;
7726 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307727 case WE_GET_FW_MEMDUMP:
7728 {
7729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7730 "FW_MEM_DUMP requested ");
7731 get_fwr_memdump(dev,info,wrqu,extra);
7732 break;
7733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007734 default:
7735 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007736 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 break;
7738 }
7739 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307740 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 return ret;
7742}
7743
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307744static int iw_setnone_getnone(struct net_device *dev,
7745 struct iw_request_info *info,
7746 union iwreq_data *wrqu, char *extra)
7747{
7748 int ret;
7749
7750 vos_ssr_protect(__func__);
7751 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7752 vos_ssr_unprotect(__func__);
7753
7754 return ret;
7755}
7756
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307757void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7758{
7759 /*
7760 * Function to display HDD WMM information
7761 * for Tx Queues.
7762 * Prints globala as well as per client depending
7763 * whether the clients are registered or not.
7764 */
7765 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307766 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7767 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307768 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7769 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307770 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307771
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307772 for ( i=0; i< NUM_TX_QUEUES; i++)
7773 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307774 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307775 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307776 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307777 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307778
7779 for ( i=0; i< NUM_TX_QUEUES; i++) {
7780 if (tx_queue_count[i]) {
7781 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7782 i, tx_queue_count[i]);
7783 }
7784 }
7785
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307786 if(pSapCtx == NULL){
7787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7788 FL("psapCtx is NULL"));
7789 return;
7790 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307791
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307792 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307793 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7794 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307795 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307796 {
7797 hddLog(LOGE, "******STAIndex: %d*********", i);
7798 for ( j=0; j< NUM_TX_QUEUES; j++)
7799 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307800 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7801 {
7802 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307803 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7804 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307805 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7806 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307807 }
7808 }
7809 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307810 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307811
Katya Nigam1fd24402015-02-16 14:52:19 +05307812 if(pHddStaCtx == NULL){
7813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7814 FL("pHddStaCtx is NULL"));
7815 return;
7816 }
7817
7818 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7819 if(pPeerInfo == NULL){
7820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7821 FL("ppeerinfo is NULL"));
7822 return;
7823 }
7824
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307825 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7826 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7827 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7828 for (j = 0; j < NUM_TX_QUEUES; j++) {
7829 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7830 spin_lock_bh(
7831 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7832 hddLog(LOGE,
7833 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7834 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7835 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7836 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7837 spin_unlock_bh(
7838 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7839 }
7840 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307841 }
7842 }
7843
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307844}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307845
Girish Gowlifb9758e2014-11-19 15:19:17 +05307846static int __iw_set_var_ints_getnone(struct net_device *dev,
7847 struct iw_request_info *info,
7848 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007849{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307850 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307851 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307852 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307853 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007854 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307855 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307856 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007857 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307858 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007859 int cmd = 0;
7860 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307861 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007862
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307863 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307864 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307865 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7867 "%s: NULL extra buffer pointer", __func__);
7868 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307869 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307870 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7871 if (NULL == pAdapter)
7872 {
7873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7874 "%s: Adapter is NULL",__func__);
7875 return -EINVAL;
7876 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307877 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307878 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7879 ret = wlan_hdd_validate_context(pHddCtx);
7880 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007881 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307882 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007883 }
Katya Nigameae74b62015-05-28 17:19:16 +05307884 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307885 {
Katya Nigameae74b62015-05-28 17:19:16 +05307886 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7887 if (NULL == hHal)
7888 {
7889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7890 "%s: Hal Context is NULL",__func__);
7891 return -EINVAL;
7892 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307893 }
7894 sub_cmd = wrqu->data.flags;
7895
7896 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7897
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007898
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007899 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7900 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7901 {
7902 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7903 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7904 {
7905 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7906 staId = pStaCtx->conn_info.staId[0];
7907 }
7908 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7909 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7910 {
7911 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7912 staId = pAPCtx->uBCStaId;
7913 }
7914 else
7915 {
7916 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7917 return 0;
7918 }
7919 }
7920
Jeff Johnson295189b2012-06-20 16:38:30 -07007921 switch (sub_cmd)
7922 {
7923 case WE_LOG_DUMP_CMD:
7924 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307925 if(apps_args[0] == 26) {
7926 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7927 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7928 return 0;
7929 }
7930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007932 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007933 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307934 if (hHal)
7935 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7936 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007937
7938 }
7939 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307940#ifdef WLAN_FEATURE_RMC
7941 case WE_IBSS_GET_PEER_INFO:
7942 {
7943 pr_info ( "Station ID = %d\n",apps_args[0]);
7944 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7945 }
7946 break;
7947#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007948
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 case WE_P2P_NOA_CMD:
7950 {
7951 p2p_app_setP2pPs_t p2pNoA;
7952
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307953 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7954 hddLog(LOGE,
7955 FL("Setting NoA is not allowed in Device mode:%d"),
7956 pAdapter->device_mode);
7957 return -EINVAL;
7958 }
7959
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 p2pNoA.opp_ps = apps_args[0];
7961 p2pNoA.ctWindow = apps_args[1];
7962 p2pNoA.duration = apps_args[2];
7963 p2pNoA.interval = apps_args[3];
7964 p2pNoA.count = apps_args[4];
7965 p2pNoA.single_noa_duration = apps_args[5];
7966 p2pNoA.psSelection = apps_args[6];
7967
7968 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7969 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007970 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7972
7973 hdd_setP2pPs(dev, &p2pNoA);
7974
7975 }
7976 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007977
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307978 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7979 {
7980 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7981 __func__, apps_args[0], apps_args[1]);
7982 vosTraceEnable(apps_args[0], apps_args[1]);
7983 }
7984 break;
7985
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007986 case WE_MTRACE_DUMP_CMD:
7987 {
7988 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7989 "bitmask_of_module %d ",
7990 __func__, apps_args[0], apps_args[1], apps_args[2],
7991 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307992 if (hHal)
7993 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7994 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007995
7996 }
7997 break;
7998
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007999 case WE_MCC_CONFIG_CREDENTIAL :
8000 {
8001 cmd = 287; //Command should be updated if there is any change
8002 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08008003 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008004 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308005 if (hHal)
8006 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
8007 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008008 }
8009 else
8010 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008011 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008012 return 0;
8013 }
8014 }
8015 break;
8016
8017 case WE_MCC_CONFIG_PARAMS :
8018 {
8019 cmd = 288; //command Should be updated if there is any change
8020 // in the Riva dump command
8021 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
8022 }
8023 break;
8024
Chilam NG571c65a2013-01-19 12:27:36 +05308025#ifdef FEATURE_WLAN_TDLS
8026 case WE_TDLS_CONFIG_PARAMS :
8027 {
8028 tdls_config_params_t tdlsParams;
8029
Chilam Ng01120412013-02-19 18:32:21 -08008030 tdlsParams.tdls = apps_args[0];
8031 tdlsParams.tx_period_t = apps_args[1];
8032 tdlsParams.tx_packet_n = apps_args[2];
8033 tdlsParams.discovery_period_t = apps_args[3];
8034 tdlsParams.discovery_tries_n = apps_args[4];
8035 tdlsParams.idle_timeout_t = apps_args[5];
8036 tdlsParams.idle_packet_n = apps_args[6];
8037 tdlsParams.rssi_hysteresis = apps_args[7];
8038 tdlsParams.rssi_trigger_threshold = apps_args[8];
8039 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05308040
Chilam Ng01120412013-02-19 18:32:21 -08008041 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05308042 }
8043 break;
8044#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05308045 case WE_CONFIGURE_MONITOR_MODE:
8046 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308047 v_U32_t magic = 0;
8048 struct completion cmpVar;
8049 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308050 tVOS_CON_MODE mode = hdd_get_conparam();
8051
8052 if (VOS_MONITOR_MODE != mode) {
8053 hddLog(LOGE, FL("invalid mode %d"), mode);
8054 return -EIO;
8055 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308056
Katya Nigamf0511f62015-05-05 16:40:57 +05308057 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8058 if( pMonCtx == NULL )
8059 {
8060 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308061 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308062 }
8063 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
8064 __func__, apps_args[0], apps_args[1], apps_args[2],
8065 apps_args[3], apps_args[4]);
8066 /* Input Validation part of FW */
8067 pMonCtx->ChannelNo = apps_args[0];
8068 pMonCtx->ChannelBW = apps_args[1];
8069 pMonCtx->crcCheckEnabled = apps_args[2];
8070 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
8071 pMonCtx->is80211to803ConReq = apps_args[4];
8072 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
8073 if( pMonCtx->is80211to803ConReq )
8074 pAdapter->dev->type = ARPHRD_ETHER;
8075 else
8076 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
8077 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
8078 {
8079 hddLog(LOGE, "%s: Filtering data packets as management and control"
8080 " cannot be converted to 802.3 ",__func__);
8081 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
8082 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308083 if (MON_MODE_START == pMonCtx->state) {
8084 magic = MON_MODE_MSG_MAGIC;
8085 init_completion(&cmpVar);
8086 if (VOS_STATUS_SUCCESS !=
8087 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8088 pMonCtx, hdd_monPostMsgCb)) {
8089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8090 FL("failed to post MON MODE REQ"));
8091 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308092 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308093 }
8094 waitRet = wait_for_completion_timeout(&cmpVar,
8095 MON_MODE_MSG_TIMEOUT);
8096 magic = 0;
8097 if (waitRet <= 0 ) {
8098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8099 FL("failed to wait on monitor mode completion %ld"),
8100 waitRet);
8101 }
8102 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308103 }
8104 break;
8105
8106 case WE_SET_MONITOR_MODE_FILTER:
8107 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308108 v_U32_t magic = 0;
8109 struct completion cmpVar;
8110 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308111 tVOS_CON_MODE mode = hdd_get_conparam();
8112
8113 if (VOS_MONITOR_MODE != mode) {
8114 hddLog(LOGE, FL("invalid mode %d"), mode);
8115 return -EIO;
8116 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308117
Katya Nigamf0511f62015-05-05 16:40:57 +05308118 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8119 if( pMonCtx == NULL )
8120 {
8121 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308122 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308123 }
8124 /* Input Validation Part of FW */
8125 pMonCtx->numOfMacFilters=1;
8126 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8127 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8128 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8129 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8130 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8131 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8132 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8133 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8134 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8135 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8136 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8137 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308138 if (MON_MODE_START == pMonCtx->state) {
8139 magic = MON_MODE_MSG_MAGIC;
8140 init_completion(&cmpVar);
8141 if (VOS_STATUS_SUCCESS !=
8142 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8143 pMonCtx, hdd_monPostMsgCb)) {
8144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8145 FL("failed to post MON MODE REQ"));
8146 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308147 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308148 }
8149 waitRet = wait_for_completion_timeout(&cmpVar,
8150 MON_MODE_MSG_TIMEOUT);
8151 magic = 0;
8152 if (waitRet <= 0 ) {
8153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8154 FL("failed to wait on monitor mode completion %ld"),
8155 waitRet);
8156 }
8157 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308158 }
8159 break;
8160
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 default:
8162 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008163 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8164 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 }
8166 break;
8167 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308168 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 return 0;
8170}
8171
Girish Gowlifb9758e2014-11-19 15:19:17 +05308172static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8173 struct iw_request_info *info,
8174 union iwreq_data *wrqu, char *extra)
8175{
8176 int ret;
8177 union iwreq_data u_priv_wrqu;
8178 int apps_args[MAX_VAR_ARGS] = {0};
8179 int num_args;
8180
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308181 if (!capable(CAP_NET_ADMIN))
8182 {
8183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8184 FL("permission check failed"));
8185 return -EPERM;
8186 }
8187
Girish Gowlifb9758e2014-11-19 15:19:17 +05308188 /* helper function to get iwreq_data with compat handling. */
8189 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8190 {
8191 return -EINVAL;
8192 }
8193
8194 if (NULL == u_priv_wrqu.data.pointer)
8195 {
8196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8197 "%s: NULL data pointer", __func__);
8198 return -EINVAL;
8199 }
8200
8201 num_args = u_priv_wrqu.data.length;
8202 if (num_args > MAX_VAR_ARGS)
8203 {
8204 num_args = MAX_VAR_ARGS;
8205 }
8206
8207 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8208 (sizeof(int)) * num_args))
8209 {
8210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8211 "%s: failed to copy data from user buffer", __func__);
8212 return -EFAULT;
8213 }
8214
8215 vos_ssr_protect(__func__);
8216 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8217 (char *)&apps_args);
8218 vos_ssr_unprotect(__func__);
8219
8220 return ret;
8221}
8222
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308223int iw_set_var_ints_getnone(struct net_device *dev,
8224 struct iw_request_info *info,
8225 union iwreq_data *wrqu, char *extra)
8226{
8227 int ret;
8228 vos_ssr_protect(__func__);
8229 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8230 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008231
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308232 return ret;
8233}
8234
8235static int __iw_add_tspec(struct net_device *dev,
8236 struct iw_request_info *info,
8237 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008238{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308239 hdd_adapter_t *pAdapter;
8240 hdd_station_ctx_t *pHddStaCtx;
8241 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8243 int params[HDD_WLAN_WMM_PARAM_COUNT];
8244 sme_QosWmmTspecInfo tSpec;
8245 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308246 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308247 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008248
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308249 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308250 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8251 if (NULL == pAdapter)
8252 {
8253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8254 "%s: Adapter is NULL",__func__);
8255 return -EINVAL;
8256 }
8257 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8258 ret = wlan_hdd_validate_context(pHddCtx);
8259 if (0 != ret)
8260 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308261 return ret;
8262 }
8263 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8264 if (NULL == pHddStaCtx)
8265 {
8266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8267 "%s: STA Context is NULL",__func__);
8268 return -EINVAL;
8269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008270 // make sure the application is sufficiently priviledged
8271 // note that the kernel will do this for "set" ioctls, but since
8272 // this ioctl wants to return status to user space it must be
8273 // defined as a "get" ioctl
8274 if (!capable(CAP_NET_ADMIN))
8275 {
8276 return -EPERM;
8277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 // we must be associated in order to add a tspec
8279 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8280 {
8281 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8282 return 0;
8283 }
8284
8285 // since we are defined to be a "get" ioctl, and since the number
8286 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308287 // will pass down in the iwreq_data, we must copy the "set" params.
8288 // We must handle the compat for iwreq_data in 32U/64K environment.
8289
8290 // helper fucntion to get iwreq_data with compat handling.
8291 if (hdd_priv_get_data(&s_priv_data, wrqu))
8292 {
8293 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8294 return 0;
8295 }
8296
8297 // make sure all params are correctly passed to function
8298 if ((NULL == s_priv_data.pointer) ||
8299 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8300 {
8301 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8302 return 0;
8303 }
8304
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308306 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 {
8308 // hmmm, can't get them
8309 return -EIO;
8310 }
8311
8312 // clear the tspec
8313 memset(&tSpec, 0, sizeof(tSpec));
8314
8315 // validate the handle
8316 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8317 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8318 {
8319 // that one is reserved
8320 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8321 return 0;
8322 }
8323
8324 // validate the TID
8325 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8326 {
8327 // out of range
8328 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8329 return 0;
8330 }
8331 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8332
8333 // validate the direction
8334 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8335 {
8336 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8337 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8338 break;
8339
8340 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8341 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8342 break;
8343
8344 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8345 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8346 break;
8347
8348 default:
8349 // unknown
8350 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8351 return 0;
8352 }
8353
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308354 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8355
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 // validate the user priority
8357 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8358 {
8359 // out of range
8360 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8361 return 0;
8362 }
8363 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308364 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8365 {
8366 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8367 return 0;
8368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008369
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8371 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8372 tSpec.ts_info.psb, tSpec.ts_info.up);
8373
Jeff Johnson295189b2012-06-20 16:38:30 -07008374 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8375 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8376 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8377 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8378 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8379 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8380 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8381 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8382 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8383 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8384 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8385 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8386
8387 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8388
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308389 // Save the expected UAPSD settings by application, this will be needed
8390 // when re-negotiating UAPSD settings during BT Coex cases.
8391 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8392
Jeff Johnson295189b2012-06-20 16:38:30 -07008393 // validate the ts info ack policy
8394 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8395 {
8396 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8397 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8398 break;
8399
8400 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8401 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8402 break;
8403
8404 default:
8405 // unknown
8406 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8407 return 0;
8408 }
8409
8410 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308411
8412 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008413 return 0;
8414}
8415
8416
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308417static int iw_add_tspec(struct net_device *dev,
8418 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 union iwreq_data *wrqu, char *extra)
8420{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308421 int ret;
8422
8423 vos_ssr_protect(__func__);
8424 ret = __iw_add_tspec(dev, info, wrqu, extra);
8425 vos_ssr_unprotect(__func__);
8426
8427 return ret;
8428}
8429
8430static int __iw_del_tspec(struct net_device *dev,
8431 struct iw_request_info *info,
8432 union iwreq_data *wrqu, char *extra)
8433{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308434 hdd_adapter_t *pAdapter;
8435 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 int *params = (int *)extra;
8437 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8438 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308439 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008440
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308441 ENTER();
8442
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308443 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8444 if (NULL == pAdapter)
8445 {
8446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8447 "%s: Adapter is NULL",__func__);
8448 return -EINVAL;
8449 }
8450
8451 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8452 ret = wlan_hdd_validate_context(pHddCtx);
8453 if (0 != ret)
8454 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308455 return ret;
8456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 // make sure the application is sufficiently priviledged
8458 // note that the kernel will do this for "set" ioctls, but since
8459 // this ioctl wants to return status to user space it must be
8460 // defined as a "get" ioctl
8461 if (!capable(CAP_NET_ADMIN))
8462 {
8463 return -EPERM;
8464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008465 // although we are defined to be a "get" ioctl, the params we require
8466 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8467 // is no need to copy the params from user space
8468
8469 // validate the handle
8470 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8471 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8472 {
8473 // that one is reserved
8474 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8475 return 0;
8476 }
8477
8478 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308479
8480 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 return 0;
8482}
8483
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308484static int iw_del_tspec(struct net_device *dev,
8485 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008486 union iwreq_data *wrqu, char *extra)
8487{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308488 int ret;
8489
8490 vos_ssr_protect(__func__);
8491 ret = __iw_del_tspec(dev, info, wrqu, extra);
8492 vos_ssr_unprotect(__func__);
8493
8494 return ret;
8495}
8496
8497
8498static int __iw_get_tspec(struct net_device *dev,
8499 struct iw_request_info *info,
8500 union iwreq_data *wrqu, char *extra)
8501{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308502 hdd_adapter_t *pAdapter;
8503 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 int *params = (int *)extra;
8505 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8506 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308507 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008508
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308509 ENTER();
8510
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 // although we are defined to be a "get" ioctl, the params we require
8512 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8513 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308514 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8515 if (NULL == pAdapter)
8516 {
8517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8518 "%s: Adapter is NULL",__func__);
8519 return -EINVAL;
8520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008521
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308522 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8523 ret = wlan_hdd_validate_context(pHddCtx);
8524 if (0 != ret)
8525 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308526 return ret;
8527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 // validate the handle
8529 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8530 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8531 {
8532 // that one is reserved
8533 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8534 return 0;
8535 }
8536
8537 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308538 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008539 return 0;
8540}
8541
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308542static int iw_get_tspec(struct net_device *dev,
8543 struct iw_request_info *info,
8544 union iwreq_data *wrqu, char *extra)
8545{
8546 int ret;
8547
8548 vos_ssr_protect(__func__);
8549 ret = __iw_get_tspec(dev, info, wrqu, extra);
8550 vos_ssr_unprotect(__func__);
8551
8552 return ret;
8553}
8554
Manjeet Singh3ed79242017-01-11 19:04:32 +05308555/**
8556 * __iw_setnone_get_threeint() - return three value to up layer.
8557 *
8558 * @dev: pointer of net_device of this wireless card
8559 * @info: meta data about Request sent
8560 * @wrqu: include request info
8561 * @extra: buf used for in/Output
8562 *
8563 * Return: execute result
8564 */
8565static int __iw_setnone_get_threeint(struct net_device *dev,
8566 struct iw_request_info *info,
8567 union iwreq_data *wrqu, char *extra)
8568{
8569 int ret = 0; /* success */
8570 uint32_t *value = (int *)extra;
8571 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8572
8573 hddLog(VOS_TRACE_LEVEL_INFO, FL("param = %d"), value[0]);
8574
8575 switch (value[0]) {
8576 case WE_GET_TSF:
8577 ret = hdd_indicate_tsf(adapter, value, 3);
8578 break;
8579 default:
8580 hddLog(VOS_TRACE_LEVEL_ERROR,
8581 FL("Invalid IOCTL get_value command %d"),
8582 value[0]);
8583 break;
8584 }
8585 return ret;
8586}
8587
8588/**
8589 * iw_setnone_get_threeint() - return three value to up layer.
8590 *
8591 * @dev: pointer of net_device of this wireless card
8592 * @info: meta data about Request sent
8593 * @wrqu: include request info
8594 * @extra: buf used for in/Output
8595 *
8596 * Return: execute result
8597 */
8598static int iw_setnone_get_threeint(struct net_device *dev,
8599 struct iw_request_info *info,
8600 union iwreq_data *wrqu, char *extra)
8601{
8602 int ret;
8603
8604 vos_ssr_protect(__func__);
8605 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8606 vos_ssr_unprotect(__func__);
8607
8608 return ret;
8609}
8610
Jeff Johnson295189b2012-06-20 16:38:30 -07008611#ifdef WLAN_FEATURE_VOWIFI_11R
8612//
8613//
8614// Each time the supplicant has the auth_request or reassoc request
8615// IEs ready. This is pushed to the driver. The driver will inturn use
8616// it to send out the auth req and reassoc req for 11r FT Assoc.
8617//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308618static int __iw_set_fties(struct net_device *dev,
8619 struct iw_request_info *info,
8620 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008621{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308622 hdd_adapter_t *pAdapter;
8623 hdd_station_ctx_t *pHddStaCtx;
8624 hdd_context_t *pHddCtx;
8625 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008626 //v_CONTEXT_t pVosContext;
8627
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308628 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308629 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8630 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008631 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8633 "%s: Adapter is NULL",__func__);
8634 return -EINVAL;
8635 }
8636 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8637 ret = wlan_hdd_validate_context(pHddCtx);
8638 if (0 != ret)
8639 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308640 return ret;
8641 }
8642 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8643 if (NULL == pHddStaCtx)
8644 {
8645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8646 "%s: STA Context is NULL",__func__);
8647 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 if (!wrqu->data.length)
8650 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008651 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 return -EINVAL;
8653 }
8654 if (wrqu->data.pointer == NULL)
8655 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008656 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 return -EINVAL;
8658 }
8659
8660 // Added for debug on reception of Re-assoc Req.
8661 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8662 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008663 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008664 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008665 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 }
8667
8668#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008669 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008670#endif
8671
8672 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008673 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008674 wrqu->data.length);
8675
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308676 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008677 return 0;
8678}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308679
8680static int iw_set_fties(struct net_device *dev,
8681 struct iw_request_info *info,
8682 union iwreq_data *wrqu, char *extra)
8683{
8684 int ret;
8685
8686 vos_ssr_protect(__func__);
8687 ret = __iw_set_fties(dev, info, wrqu, extra);
8688 vos_ssr_unprotect(__func__);
8689
8690 return ret;
8691}
Jeff Johnson295189b2012-06-20 16:38:30 -07008692#endif
8693
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308694static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008695 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008697{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308698 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008699 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308700 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008701 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308702 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008703 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8704 int idx;
8705 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008706
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308707 ENTER();
8708
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308709 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8710 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008711 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8713 "%s: Adapter is NULL",__func__);
8714 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008715 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308716 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8717 ret_val = wlan_hdd_validate_context(pHddCtx);
8718 if (0 != ret_val)
8719 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308720 return ret_val;
8721 }
8722 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8723 if (NULL == hHal)
8724 {
8725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8726 "%s: Hal Context is NULL",__func__);
8727 return -EINVAL;
8728 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308729 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8730 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308731#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008732
Amar Singhalf3a6e762013-02-19 15:06:50 -08008733 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8734 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008735 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008736 hddLog(VOS_TRACE_LEVEL_ERROR,
8737 "%s: vos_mem_alloc failed", __func__);
8738 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008739 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008740
8741 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8742
8743 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8744 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8745
8746 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8747 mc_addr_list_ptr->ulMulticastAddrCnt);
8748
8749 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008750 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008751 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8752 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8753
8754 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8755 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008756 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008757
Amar Singhalf3a6e762013-02-19 15:06:50 -08008758 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8759 vos_mem_free(mc_addr_list_ptr);
8760 if (eHAL_STATUS_SUCCESS != ret_val)
8761 {
8762 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8763 __func__);
8764 return -EINVAL;
8765 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308766#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308767 }
8768 else
8769 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008770
Amar Singhalf3a6e762013-02-19 15:06:50 -08008771 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8772 "%s: Set MC BC Filter Config request: %d suspend %d",
8773 __func__, pRequest->mcastBcastFilterSetting,
8774 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308775 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308776 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308777 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008778
8779 if (pHddCtx->hdd_wlan_suspended)
8780 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008781 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8782 if (NULL == wlanRxpFilterParam)
8783 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308784 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008785 "%s: vos_mem_alloc failed", __func__);
8786 return -EINVAL;
8787 }
8788
Amar Singhalf3a6e762013-02-19 15:06:50 -08008789 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8790 pRequest->mcastBcastFilterSetting;
8791 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308792 /* Fwr expect offload needs to clear before set */
8793 hdd_conf_hostoffload(pAdapter, FALSE);
8794 spin_lock(&pHddCtx->filter_lock);
8795 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
8796 spin_unlock(&pHddCtx->filter_lock);
8797 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8798 {
8799 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
8800 pHddCtx->sus_res_mcastbcast_filter =
8801 pRequest->mcastBcastFilterSetting;
8802 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008803
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308804 hdd_conf_hostoffload(pAdapter, TRUE);
8805 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8806 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008807
8808 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8809 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308810 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008811 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8812 wlanRxpFilterParam->setMcstBcstFilter);
8813
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308814 if (eHAL_STATUS_SUCCESS !=
8815 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8816 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008817 {
8818 hddLog(VOS_TRACE_LEVEL_ERROR,
8819 "%s: Failure to execute set HW MC/BC Filter request",
8820 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008821 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008822 return -EINVAL;
8823 }
8824
mukul sharmae4abd892016-11-24 22:03:31 +05308825 /* mc add list cfg item configuration in fwr */
8826 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008827 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308830 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 return 0;
8832}
8833
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308834static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8835 struct iw_request_info *info,
8836 union iwreq_data *wrqu, char *extra)
8837{
8838 int ret;
8839
8840 vos_ssr_protect(__func__);
8841 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8842 vos_ssr_unprotect(__func__);
8843
8844 return ret;
8845}
8846
8847static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8848 struct iw_request_info *info,
8849 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008850{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308851 hdd_adapter_t *pAdapter;
8852 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308853 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308854 int ret = 0;
8855
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308856 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008857
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308858 if (!capable(CAP_NET_ADMIN))
8859 {
8860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8861 FL("permission check failed"));
8862 return -EPERM;
8863 }
8864
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308865 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8866 if (NULL == pAdapter)
8867 {
8868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8869 "%s: Adapter is NULL",__func__);
8870 return -EINVAL;
8871 }
8872
8873 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8874 ret = wlan_hdd_validate_context(pHddCtx);
8875 if (0 != ret)
8876 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308877 return ret;
8878 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308879 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308880 //Reset the filter to INI value as we have to clear the dynamic filter
8881 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308882 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008883
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308884 //Configure FW with new setting
8885 if (pHddCtx->hdd_wlan_suspended)
8886 {
8887 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8888 if (NULL == wlanRxpFilterParam)
8889 {
8890 hddLog(VOS_TRACE_LEVEL_ERROR,
8891 "%s: vos_mem_alloc failed", __func__);
8892 return -EINVAL;
8893 }
8894
8895 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8896 pHddCtx->configuredMcastBcastFilter;
8897 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308898 /* Fwr expect offload needs to clear before set */
8899 hdd_conf_hostoffload(pAdapter, FALSE);
8900 spin_lock(&pHddCtx->filter_lock);
8901 pHddCtx->configuredMcastBcastFilter =
8902 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8903 spin_unlock(&pHddCtx->filter_lock);
8904
8905 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8906 {
8907 pHddCtx->sus_res_mcastbcast_filter =
8908 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8909 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308910
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308911 hdd_conf_hostoffload(pAdapter, TRUE);
8912 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8913 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308914 if (eHAL_STATUS_SUCCESS !=
8915 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8916 wlanRxpFilterParam))
8917 {
8918 hddLog(VOS_TRACE_LEVEL_ERROR,
8919 "%s: Failure to execute set HW MC/BC Filter request",
8920 __func__);
8921 vos_mem_free(wlanRxpFilterParam);
8922 return -EINVAL;
8923 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308924
mukul sharmae4abd892016-11-24 22:03:31 +05308925 /* mc add list cfg item configuration in fwr */
8926 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308927 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308928 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008929 return 0;
8930}
8931
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308932
8933static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8934 struct iw_request_info *info,
8935 union iwreq_data *wrqu, char *extra)
8936{
8937 int ret;
8938
8939 vos_ssr_protect(__func__);
8940 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8941 vos_ssr_unprotect(__func__);
8942
8943 return ret;
8944}
8945
8946static int __iw_set_host_offload(struct net_device *dev,
8947 struct iw_request_info *info,
8948 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008949{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308950 hdd_adapter_t *pAdapter;
8951 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008952 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008953 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308954 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308956 ENTER();
8957
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308958 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8959 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008960 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308961 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8962 "%s: Adapter is NULL",__func__);
8963 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008964 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308965 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8966 ret = wlan_hdd_validate_context(pHddCtx);
8967 if (0 != ret)
8968 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308969 return ret;
8970 }
8971
Jeff Johnson295189b2012-06-20 16:38:30 -07008972 /* Debug display of request components. */
8973 switch (pRequest->offloadType)
8974 {
8975 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008976 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008977 switch (pRequest->enableOrDisable)
8978 {
8979 case WLAN_OFFLOAD_DISABLE:
8980 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8981 break;
8982 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8983 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8984 case WLAN_OFFLOAD_ENABLE:
8985 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8986 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8987 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8988 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8989 }
8990 break;
8991
8992 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008993 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008994 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008995 switch (pRequest->enableOrDisable)
8996 {
8997 case WLAN_OFFLOAD_DISABLE:
8998 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8999 break;
9000 case WLAN_OFFLOAD_ENABLE:
9001 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
9002 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
9003 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
9004 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
9005 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
9006 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
9007 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
9008 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
9009 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
9010 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
9011 }
9012 }
9013
9014 /* Execute offload request. The reason that we can copy the request information
9015 from the ioctl structure to the SME structure is that they are laid out
9016 exactly the same. Otherwise, each piece of information would have to be
9017 copied individually. */
9018 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07009019 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
9020 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009021 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009022 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07009023 __func__);
9024 return -EINVAL;
9025 }
9026
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309027 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009028 return 0;
9029}
9030
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309031static int iw_set_host_offload(struct net_device *dev,
9032 struct iw_request_info *info,
9033 union iwreq_data *wrqu, char *extra)
9034{
9035 int ret;
9036
9037 vos_ssr_protect(__func__);
9038 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9039 vos_ssr_unprotect(__func__);
9040
9041 return ret;
9042}
9043
9044static int __iw_set_keepalive_params(struct net_device *dev,
9045 struct iw_request_info *info,
9046 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009047{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309048 hdd_adapter_t *pAdapter;
9049 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08009050 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309052 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009053
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309054 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309055 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9056 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9059 "%s: Adapter is NULL",__func__);
9060 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009061 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309062 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9063 ret = wlan_hdd_validate_context(pHddCtx);
9064 if (0 != ret)
9065 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309066 return ret;
9067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009068 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08009069 hddLog(VOS_TRACE_LEVEL_INFO,
9070 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
9071 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07009072
9073 switch (pRequest->packetType)
9074 {
9075 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009076 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009077 break;
9078
9079 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
9080
Arif Hussain6d2a3322013-11-17 19:50:10 -08009081 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009082 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009083
9084 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
9085 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
9086 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
9087
9088 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
9089 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
9090 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
9091
9092 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
9093 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
9094 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
9095 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
9096 break;
9097
9098 }
9099
9100 /* Execute keep alive request. The reason that we can copy the request information
9101 from the ioctl structure to the SME structure is that they are laid out
9102 exactly the same. Otherwise, each piece of information would have to be
9103 copied individually. */
9104 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
9105
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05309106 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
9107 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07009108
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009109 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07009110 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009111 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009112 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 __func__);
9114 return -EINVAL;
9115 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309116 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009117 return 0;
9118}
9119
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309120static int iw_set_keepalive_params(struct net_device *dev,
9121 struct iw_request_info *info,
9122 union iwreq_data *wrqu, char *extra)
9123{
9124 int ret;
9125 vos_ssr_protect(__func__);
9126 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9127 vos_ssr_unprotect(__func__);
9128
9129 return ret;
9130}
9131
Jeff Johnson295189b2012-06-20 16:38:30 -07009132#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309133/**-----------------------------------------------------------------
9134
9135 \brief hdd_pkt_filter_done - callback to be executed on completion
9136 successful/failure) for clear filter request.
9137
9138 \return - None
9139
9140 --------------------------------------------------------------------------*/
9141static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009142{
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309143 struct statsContext *cbCtx = (struct statsContext *)data;
9144
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309145 hddLog(VOS_TRACE_LEVEL_INFO,
9146 FL("Pkt Filter Clear Status : %d"), status);
9147
9148 if (data == NULL)
9149 {
9150 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context"));
9151 return;
9152 }
9153
9154 spin_lock(&hdd_context_lock);
9155 if (cbCtx->magic != CLEAR_FILTER_MAGIC)
9156 {
9157 spin_unlock(&hdd_context_lock);
9158 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context, magic %x"), cbCtx->magic);
9159 if (ioctl_debug)
9160 {
9161 pr_info("%s: Invalid context, magic [%08x]\n",
9162 __func__, cbCtx->magic);
9163 }
9164 return;
9165 }
9166
9167 complete(&cbCtx->completion);
9168 spin_unlock(&hdd_context_lock);
9169}
9170
9171int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9172{
9173 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309174 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009175 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9176 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309177 struct statsContext cbCtx;
9178 int i=0, status;
9179
9180 status = wlan_hdd_validate_context(pHddCtx);
9181 if (0 != status)
9182 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009183
9184 if (pHddCtx->cfg_ini->disablePacketFilter)
9185 {
9186 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009187 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009188 return 0;
9189 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309190 if (pHddCtx->isLogpInProgress)
9191 {
9192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9193 "%s:LOGP in Progress. Ignore!!!", __func__);
9194 return -EBUSY;
9195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009196 /* Debug display of request components. */
9197 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009198 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009199
9200 switch (pRequest->filterAction)
9201 {
9202 case HDD_RCV_FILTER_SET:
9203 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009204 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009205
9206 packetFilterSetReq.filterId = pRequest->filterId;
9207 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9208 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009209 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 __func__, pRequest->numParams);
9211 return -EINVAL;
9212 }
9213 packetFilterSetReq.numFieldParams = pRequest->numParams;
9214 packetFilterSetReq.coalesceTime = 0;
9215 packetFilterSetReq.filterType = 1;
9216 for (i=0; i < pRequest->numParams; i++)
9217 {
9218 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9219 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9220 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9221 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9222 packetFilterSetReq.paramsData[i].reserved = 0;
9223
Arif Hussain6d2a3322013-11-17 19:50:10 -08009224 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9226 packetFilterSetReq.filterType);
9227
Arif Hussain6d2a3322013-11-17 19:50:10 -08009228 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009229 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309230 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9231 (pRequest->paramsData[i].dataLength))
9232 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009233
9234 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9235 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9236 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9237 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9238
Arif Hussain6d2a3322013-11-17 19:50:10 -08009239 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009240 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9241 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9242 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9243
Arif Hussain6d2a3322013-11-17 19:50:10 -08009244 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009245 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9246 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9247 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9248 }
9249
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309250 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009252 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009253 __func__);
9254 return -EINVAL;
9255 }
9256
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309257 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9258 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 break;
9260
9261 case HDD_RCV_FILTER_CLEAR:
9262
Arif Hussain6d2a3322013-11-17 19:50:10 -08009263 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009264 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309265
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309266 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9267 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9268 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9269 pHddStaCtx->conn_info.staId[0]);
9270 }
9271
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309272 init_completion(&cbCtx.completion);
9273 cbCtx.magic = CLEAR_FILTER_MAGIC;
9274 cbCtx.pAdapter = pAdapter;
9275 packetFilterClrReq.cbCtx = &cbCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009276 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309277 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
9278 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009279 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009280 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 __func__);
9282 return -EINVAL;
9283 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309284
9285 status = wait_for_completion_interruptible_timeout(&cbCtx.completion,
9286 msecs_to_jiffies(PKT_FILTER_TIMEOUT));
9287 spin_lock(&hdd_context_lock);
9288 cbCtx.magic = 0;
9289 spin_unlock(&hdd_context_lock);
9290 if (0 >= status)
9291 {
9292 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9293 status);
9294 return -EINVAL;
9295 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309296
9297 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9298 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009299 break;
9300
9301 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009302 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009303 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009304 return -EINVAL;
9305 }
9306 return 0;
9307}
9308
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309309int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9310 tANI_U8 sessionId)
9311{
9312 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9313 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9314
9315 if (NULL == pHddCtx)
9316 {
9317 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9318 return -EINVAL;
9319 }
9320
9321 if (pHddCtx->isLogpInProgress)
9322 {
9323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9324 "%s:LOGP in Progress. Ignore!!!", __func__);
9325 return -EBUSY;
9326 }
9327
9328 if (pHddCtx->cfg_ini->disablePacketFilter)
9329 {
9330 hddLog(VOS_TRACE_LEVEL_ERROR,
9331 "%s: Packet Filtering Disabled. Returning ",
9332 __func__ );
9333 return -EINVAL;
9334 }
9335
9336 switch (filterType)
9337 {
9338 /* For setting IPV6 MC and UC Filter we need to configure
9339 * 2 filters, one for MC and one for UC.
9340 * The Filter ID shouldn't be swapped, which results in making
9341 * UC Filter ineffective.
9342 * We have Hardcode all the values
9343 *
9344 * Reason for a seperate UC filter is because, driver need to
9345 * specify the FW that the specific filter is for unicast
9346 * otherwise FW will not pass the unicast frames by default
9347 * through the filter. This is required to avoid any performance
9348 * hits when no unicast filter is set and only MC/BC are set.
9349 * The way driver informs host is by using the MAC protocol
9350 * layer, CMP flag set to MAX, CMP Data set to 1.
9351 */
9352
9353 case HDD_FILTER_IPV6_MC_UC:
9354 /* Setting IPV6 MC Filter below
9355 */
9356 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9357 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9358 packetFilterSetReq.numFieldParams = 2;
9359 packetFilterSetReq.paramsData[0].protocolLayer =
9360 HDD_FILTER_PROTO_TYPE_MAC;
9361 packetFilterSetReq.paramsData[0].cmpFlag =
9362 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9363 packetFilterSetReq.paramsData[0].dataOffset =
9364 WLAN_HDD_80211_FRM_DA_OFFSET;
9365 packetFilterSetReq.paramsData[0].dataLength = 1;
9366 packetFilterSetReq.paramsData[0].compareData[0] =
9367 HDD_IPV6_MC_CMP_DATA;
9368
9369 packetFilterSetReq.paramsData[1].protocolLayer =
9370 HDD_FILTER_PROTO_TYPE_ARP;
9371 packetFilterSetReq.paramsData[1].cmpFlag =
9372 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9373 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9374 packetFilterSetReq.paramsData[1].dataLength = 2;
9375 packetFilterSetReq.paramsData[1].compareData[0] =
9376 HDD_IPV6_CMP_DATA_0;
9377 packetFilterSetReq.paramsData[1].compareData[1] =
9378 HDD_IPV6_CMP_DATA_1;
9379
9380
9381 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9382 &packetFilterSetReq, sessionId))
9383 {
9384 hddLog(VOS_TRACE_LEVEL_ERROR,
9385 "%s: Failure to execute Set IPv6 Mulicast Filter",
9386 __func__);
9387 return -EINVAL;
9388 }
9389
9390 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9391
9392 /*
9393 * Setting IPV6 UC Filter below
9394 */
9395 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9396 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9397 packetFilterSetReq.numFieldParams = 2;
9398 packetFilterSetReq.paramsData[0].protocolLayer =
9399 HDD_FILTER_PROTO_TYPE_MAC;
9400 packetFilterSetReq.paramsData[0].cmpFlag =
9401 HDD_FILTER_CMP_TYPE_MAX;
9402 packetFilterSetReq.paramsData[0].dataOffset = 0;
9403 packetFilterSetReq.paramsData[0].dataLength = 1;
9404 packetFilterSetReq.paramsData[0].compareData[0] =
9405 HDD_IPV6_UC_CMP_DATA;
9406
9407 packetFilterSetReq.paramsData[1].protocolLayer =
9408 HDD_FILTER_PROTO_TYPE_ARP;
9409 packetFilterSetReq.paramsData[1].cmpFlag =
9410 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9411 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9412 packetFilterSetReq.paramsData[1].dataLength = 2;
9413 packetFilterSetReq.paramsData[1].compareData[0] =
9414 HDD_IPV6_CMP_DATA_0;
9415 packetFilterSetReq.paramsData[1].compareData[1] =
9416 HDD_IPV6_CMP_DATA_1;
9417
9418 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9419 &packetFilterSetReq, sessionId))
9420 {
9421 hddLog(VOS_TRACE_LEVEL_ERROR,
9422 "%s: Failure to execute Set IPv6 Unicast Filter",
9423 __func__);
9424 return -EINVAL;
9425 }
9426
9427 break;
9428
9429 case HDD_FILTER_IPV6_MC:
9430 /*
9431 * IPV6 UC Filter might be already set,
9432 * clear the UC Filter. As the Filter
9433 * IDs are static, we can directly clear it.
9434 */
9435 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9436 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9437 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9438 &packetFilterClrReq, sessionId))
9439 {
9440 hddLog(VOS_TRACE_LEVEL_ERROR,
9441 "%s: Failure to execute Clear IPv6 Unicast Filter",
9442 __func__);
9443 return -EINVAL;
9444 }
9445
9446 /*
9447 * Setting IPV6 MC Filter below
9448 */
9449 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9450 packetFilterSetReq.numFieldParams = 2;
9451 packetFilterSetReq.paramsData[0].protocolLayer =
9452 HDD_FILTER_PROTO_TYPE_MAC;
9453 packetFilterSetReq.paramsData[0].cmpFlag =
9454 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9455 packetFilterSetReq.paramsData[0].dataOffset =
9456 WLAN_HDD_80211_FRM_DA_OFFSET;
9457 packetFilterSetReq.paramsData[0].dataLength = 1;
9458 packetFilterSetReq.paramsData[0].compareData[0] =
9459 HDD_IPV6_MC_CMP_DATA;
9460
9461 packetFilterSetReq.paramsData[1].protocolLayer =
9462 HDD_FILTER_PROTO_TYPE_ARP;
9463 packetFilterSetReq.paramsData[1].cmpFlag =
9464 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9465 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9466 packetFilterSetReq.paramsData[1].dataLength = 2;
9467 packetFilterSetReq.paramsData[1].compareData[0] =
9468 HDD_IPV6_CMP_DATA_0;
9469 packetFilterSetReq.paramsData[1].compareData[1] =
9470 HDD_IPV6_CMP_DATA_1;
9471
9472
9473 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9474 &packetFilterSetReq, sessionId))
9475 {
9476 hddLog(VOS_TRACE_LEVEL_ERROR,
9477 "%s: Failure to execute Set IPv6 Multicast Filter",
9478 __func__);
9479 return -EINVAL;
9480 }
9481 break;
9482
9483 default :
9484 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9485 "%s: Packet Filter Request: Invalid",
9486 __func__);
9487 return -EINVAL;
9488 }
9489 return 0;
9490}
9491
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309492void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009493{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309494 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309495 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009496 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309497 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009498
Yue Ma3ede6052013-08-29 00:33:26 -07009499 if (NULL == pHddCtx)
9500 {
9501 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9502 return;
9503 }
9504
9505 hHal = pHddCtx->hHal;
9506
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309507 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009508 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309509 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9510 return;
9511 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309512
9513 /* Check if INI is enabled or not, other wise just return
9514 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309515 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309516 {
9517 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9518 if (NULL == pMulticastAddrs)
9519 {
9520 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9521 return;
9522 }
9523
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 if (set)
9525 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309526 /* Following pre-conditions should be satisfied before wei
9527 * configure the MC address list.
9528 */
9529 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9530 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9531 && pAdapter->mc_addr_list.mc_cnt
9532 && (eConnectionState_Associated ==
9533 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9534 {
9535 pMulticastAddrs->ulMulticastAddrCnt =
9536 pAdapter->mc_addr_list.mc_cnt;
9537 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9538 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009539 memcpy(pMulticastAddrs->multicastAddr[i],
9540 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309541 sizeof(pAdapter->mc_addr_list.addr[i]));
9542 hddLog(VOS_TRACE_LEVEL_INFO,
9543 "%s: %s multicast filter: addr ="
9544 MAC_ADDRESS_STR,
9545 __func__, set ? "setting" : "clearing",
9546 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9547 }
9548 /* Set multicast filter */
9549 sme_8023MulticastList(hHal, pAdapter->sessionId,
9550 pMulticastAddrs);
9551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309553 else
9554 {
9555 /* Need to clear only if it was previously configured
9556 */
9557 if (pAdapter->mc_addr_list.isFilterApplied)
9558 {
9559 pMulticastAddrs->ulMulticastAddrCnt = 0;
9560 sme_8023MulticastList(hHal, pAdapter->sessionId,
9561 pMulticastAddrs);
9562 }
9563
9564 }
9565 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009566 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009567 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309568 else
9569 {
9570 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309571 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309572 }
9573 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009574}
9575
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309576static int __iw_set_packet_filter_params(struct net_device *dev,
9577 struct iw_request_info *info,
9578 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309579{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309580 hdd_adapter_t *pAdapter;
9581 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009582 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309583 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309584 struct iw_point s_priv_data;
9585
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309586 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309587
9588 if (!capable(CAP_NET_ADMIN))
9589 {
9590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9591 FL("permission check failed"));
9592 return -EPERM;
9593 }
9594
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309595 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9596 if (NULL == pAdapter)
9597 {
9598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9599 "%s: Adapter is NULL",__func__);
9600 return -EINVAL;
9601 }
9602 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9603 ret = wlan_hdd_validate_context(pHddCtx);
9604 if (0 != ret)
9605 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309606 return ret;
9607 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309608 if (hdd_priv_get_data(&s_priv_data, wrqu))
9609 {
9610 return -EINVAL;
9611 }
9612
9613 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9614 {
9615 return -EINVAL;
9616 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009617
Arif Hussain0273cba2014-01-07 20:58:29 -08009618 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309619 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9620 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009621 if (NULL == pRequest)
9622 {
9623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9624 "mem_alloc_copy_from_user_helper fail");
9625 return -ENOMEM;
9626 }
9627
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309628 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009629 kfree(pRequest);
9630
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309631 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009632 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009633}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309634
9635static int iw_set_packet_filter_params(struct net_device *dev,
9636 struct iw_request_info *info,
9637 union iwreq_data *wrqu, char *extra)
9638{
9639 int ret;
9640
9641 vos_ssr_protect(__func__);
9642 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9643 vos_ssr_unprotect(__func__);
9644
9645 return ret;
9646}
Jeff Johnson295189b2012-06-20 16:38:30 -07009647#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309648static int __iw_get_statistics(struct net_device *dev,
9649 struct iw_request_info *info,
9650 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009651{
9652
9653 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9654 eHalStatus status = eHAL_STATUS_SUCCESS;
9655 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309656 hdd_adapter_t *pAdapter;
9657 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309659 int tlen = 0, ret = 0;
9660 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009661
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309662 tCsrGlobalClassAStatsInfo *aStats;
9663 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009664
9665 ENTER();
9666
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309667 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9668 if (NULL == pAdapter)
9669 {
9670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9671 "%s: Adapter is NULL",__func__);
9672 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309674 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9675 ret = wlan_hdd_validate_context(pHddCtx);
9676 if (0 != ret)
9677 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309678 return ret;
9679 }
9680 pStats = &(pAdapter->hdd_stats.summary_stat);
9681 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9682 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9684
9685 wrqu->txpower.value = 0;
9686 }
9687 else {
9688 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9689 SME_SUMMARY_STATS |
9690 SME_GLOBAL_CLASSA_STATS |
9691 SME_GLOBAL_CLASSB_STATS |
9692 SME_GLOBAL_CLASSC_STATS |
9693 SME_GLOBAL_CLASSD_STATS |
9694 SME_PER_STA_STATS,
9695 hdd_StatisticsCB, 0, FALSE,
9696 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9697
9698 if (eHAL_STATUS_SUCCESS != status)
9699 {
9700 hddLog(VOS_TRACE_LEVEL_ERROR,
9701 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009702 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 return -EINVAL;
9704 }
9705
9706 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309707 if (NULL == pWextState)
9708 {
9709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9710 "%s: pWextState is NULL",__func__);
9711 return -EINVAL;
9712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009713
9714 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9715 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9716 {
9717 hddLog(VOS_TRACE_LEVEL_ERROR,
9718 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009719 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009720 /*Remove the SME statistics list by passing NULL in callback argument*/
9721 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9722 SME_SUMMARY_STATS |
9723 SME_GLOBAL_CLASSA_STATS |
9724 SME_GLOBAL_CLASSB_STATS |
9725 SME_GLOBAL_CLASSC_STATS |
9726 SME_GLOBAL_CLASSD_STATS |
9727 SME_PER_STA_STATS,
9728 NULL, 0, FALSE,
9729 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9730
9731 return -EINVAL;
9732 }
9733 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9734 (tANI_U8) sizeof (pStats->retry_cnt),
9735 (char*) &(pStats->retry_cnt[0]),
9736 tlen);
9737
9738 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9739 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9740 (char*) &(pStats->multiple_retry_cnt[0]),
9741 tlen);
9742
9743 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9744 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9745 (char*) &(pStats->tx_frm_cnt[0]),
9746 tlen);
9747
9748 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9749 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9750 (char*) &(pStats->rx_frm_cnt),
9751 tlen);
9752
9753 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9754 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9755 (char*) &(pStats->frm_dup_cnt),
9756 tlen);
9757
9758 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9759 (tANI_U8) sizeof (pStats->fail_cnt),
9760 (char*) &(pStats->fail_cnt[0]),
9761 tlen);
9762
9763 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9764 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9765 (char*) &(pStats->rts_fail_cnt),
9766 tlen);
9767
9768 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9769 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9770 (char*) &(pStats->ack_fail_cnt),
9771 tlen);
9772
9773 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9774 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9775 (char*) &(pStats->rts_succ_cnt),
9776 tlen);
9777
9778 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9779 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9780 (char*) &(pStats->rx_discard_cnt),
9781 tlen);
9782
9783 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9784 (tANI_U8) sizeof (pStats->rx_error_cnt),
9785 (char*) &(pStats->rx_error_cnt),
9786 tlen);
9787
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009788 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009789 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009790 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 tlen);
9792
9793 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9794 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9795 (char*) &(dStats->rx_byte_cnt),
9796 tlen);
9797
9798 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9799 (tANI_U8) sizeof (dStats->rx_rate),
9800 (char*) &(dStats->rx_rate),
9801 tlen);
9802
9803 /* Transmit rate, in units of 500 kbit/sec */
9804 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9805 (tANI_U8) sizeof (aStats->tx_rate),
9806 (char*) &(aStats->tx_rate),
9807 tlen);
9808
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009809 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9810 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9811 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009812 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009813 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9814 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9815 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009816 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009817 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9818 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9819 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009820 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009821 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9822 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9823 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009824 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009825 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9826 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9827 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009828 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009829 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9830 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9831 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009832 tlen);
9833
Jeff Johnson295189b2012-06-20 16:38:30 -07009834 wrqu->data.length = tlen;
9835
9836 }
9837
9838 EXIT();
9839
9840 return 0;
9841}
9842
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309843static int iw_get_statistics(struct net_device *dev,
9844 struct iw_request_info *info,
9845 union iwreq_data *wrqu, char *extra)
9846{
9847 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009848
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309849 vos_ssr_protect(__func__);
9850 ret = __iw_get_statistics(dev, info, wrqu, extra);
9851 vos_ssr_unprotect(__func__);
9852
9853 return ret;
9854}
Jeff Johnson295189b2012-06-20 16:38:30 -07009855#ifdef FEATURE_WLAN_SCAN_PNO
9856
9857/*Max Len for PNO notification*/
9858#define MAX_PNO_NOTIFY_LEN 100
9859void found_pref_network_cb (void *callbackContext,
9860 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9861{
9862 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9863 union iwreq_data wrqu;
9864 char buf[MAX_PNO_NOTIFY_LEN+1];
9865
9866 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9867 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9868
9869 // create the event
9870 memset(&wrqu, 0, sizeof(wrqu));
9871 memset(buf, 0, sizeof(buf));
9872
9873 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9874 pPrefNetworkFoundInd->ssId.ssId,
9875 (unsigned int)pPrefNetworkFoundInd->rssi);
9876
9877 wrqu.data.pointer = buf;
9878 wrqu.data.length = strlen(buf);
9879
9880 // send the event
9881
9882 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9883
9884}
9885
9886
9887/*string based input*/
9888VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9889 union iwreq_data *wrqu, char *extra, int nOffset)
9890{
9891 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309892 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009893 /* pnoRequest is a large struct, so we make it static to avoid stack
9894 overflow. This API is only invoked via ioctl, so it is
9895 serialized by the kernel rtnl_lock and hence does not need to be
9896 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309897 tSirPNOScanReq pnoRequest = {0};
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309898 char *ptr, *data;
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 v_U8_t i,j, ucParams, ucMode;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309900 size_t len;
c_hpothu37f21312014-04-09 21:49:54 +05309901 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9903
9904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9905 "PNO data len %d data %s",
9906 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009907 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009908
9909 if (wrqu->data.length <= nOffset )
9910 {
9911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9912 return VOS_STATUS_E_FAILURE;
9913 }
9914
9915 pnoRequest.enable = 0;
9916 pnoRequest.ucNetworksCount = 0;
9917 /*-----------------------------------------------------------------------
9918 Input is string based and expected to be like this:
9919
9920 <enabled> <netw_count>
9921 for each network:
9922 <ssid_len> <ssid> <authentication> <encryption>
9923 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9924 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9925
9926 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009927 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 -07009928
9929 this translates into:
9930 -----------------------------
9931 enable PNO
9932 look for 2 networks:
9933 test - with authentication type 0 and encryption type 0,
9934 that can be found on 3 channels: 1 6 and 11 ,
9935 SSID bcast type is unknown (directed probe will be sent if AP not found)
9936 and must meet -40dBm RSSI
9937
9938 test2 - with auth and enrytption type 4/4
9939 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9940 bcast type is non-bcast (directed probe will be sent)
9941 and must not meet any RSSI threshold
9942
Jeff Johnson8301aa12013-03-28 14:27:29 -07009943 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009945
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309946 /* making sure argument string ends with '\0' */
9947 len = (wrqu->data.length-nOffset) + 1;
9948 data = vos_mem_malloc(len);
9949 if (NULL == data) {
9950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9951 FL("fail to allocate memory %zu"), len);
9952 return -EINVAL;
9953 }
9954 vos_mem_zero(data, len);
9955 vos_mem_copy(data, &extra[nOffset], (len-1));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309956 ptr = data;
9957
9958 if (1 != sscanf(ptr," %hhu%n", &(pnoRequest.enable), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -07009959 {
9960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9961 "PNO enable input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309962 vos_mem_free(data);
Wilson Yang623f6592013-10-08 16:33:37 -07009963 return VOS_STATUS_E_FAILURE;
9964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009965
9966 if ( 0 == pnoRequest.enable )
9967 {
9968 /*Disable PNO*/
9969 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309970 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9971 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 pAdapter->sessionId,
9973 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309974 if (eHAL_STATUS_SUCCESS != status)
9975 {
9976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9977 "%s: failed to disable PNO", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309978 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +05309979 return VOS_STATUS_E_FAILURE;
9980 }
9981 pHddCtx->isPnoEnable = FALSE;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309982 vos_mem_free(data);
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 return VOS_STATUS_SUCCESS;
9984 }
9985
c_hpothu37f21312014-04-09 21:49:54 +05309986 if (TRUE == pHddCtx->isPnoEnable)
9987 {
9988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9989 FL("already PNO is enabled"));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309990 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +05309991 return -EBUSY;
9992 }
9993 pHddCtx->isPnoEnable = TRUE;
9994
Jeff Johnson295189b2012-06-20 16:38:30 -07009995 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009996
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309997 if (1 != sscanf(ptr," %hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -07009998 {
9999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10000 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010001 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010003
10004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10005 "PNO enable %d networks count %d offset %d",
10006 pnoRequest.enable,
10007 pnoRequest.ucNetworksCount,
10008 nOffset);
10009
10010 /* Parameters checking:
10011 ucNetworksCount has to be larger than 0*/
10012 if (( 0 == pnoRequest.ucNetworksCount ) ||
10013 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
10014 {
10015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +053010016 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010017 }
10018
10019 ptr += nOffset;
10020
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010021 pnoRequest.aNetworks =
10022 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10023 if (pnoRequest.aNetworks == NULL)
10024 {
10025 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10026 FL("failed to allocate memory aNetworks %u"),
10027 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10028 goto error;
10029 }
10030 vos_mem_zero(pnoRequest.aNetworks,
10031 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10032
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
10034 {
10035
10036 pnoRequest.aNetworks[i].ssId.length = 0;
10037
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010038 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010039 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
10040
10041 if (1 != ucParams)
10042 {
10043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10044 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010045 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010046 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010047
10048 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
10049 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
10050 {
10051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10052 "SSID Len %d is not correct for network %d",
10053 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +053010054 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010055 }
10056
10057 /*Advance to SSID*/
10058 ptr += nOffset;
10059
Jeff Johnson8301aa12013-03-28 14:27:29 -070010060 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -080010061 pnoRequest.aNetworks[i].ssId.length);
10062 ptr += pnoRequest.aNetworks[i].ssId.length;
10063
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010064 ucParams = sscanf(ptr," %u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -080010065 &(pnoRequest.aNetworks[i].authentication),
10066 &(pnoRequest.aNetworks[i].encryption),
10067 &(pnoRequest.aNetworks[i].ucChannelCount),
10068 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010069
Wilson Yang623f6592013-10-08 16:33:37 -070010070 if ( 3 != ucParams )
10071 {
10072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10073 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010074 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010075 }
10076
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010078 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -080010079 "auth %d encry %d channel count %d offset %d",
10080 pnoRequest.aNetworks[i].ssId.length,
10081 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
10082 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
10083 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
10084 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
10085 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
10086 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
10087 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
10088 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
10089 pnoRequest.aNetworks[i].authentication,
10090 pnoRequest.aNetworks[i].encryption,
10091 pnoRequest.aNetworks[i].ucChannelCount,
10092 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -070010093
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 /*Advance to channel list*/
10095 ptr += nOffset;
10096
Wilson Yang623f6592013-10-08 16:33:37 -070010097 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 {
10099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10100 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010101 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 }
10103
10104 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
10105 {
10106 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
10107 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010108 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010109 &(pnoRequest.aNetworks[i].aChannels[j]),
10110 &nOffset))
10111 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10112 "PNO network channel input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010113 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010114 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010115 if (!IS_CHANNEL_VALID(pnoRequest.aNetworks[i].aChannels[j])) {
10116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10117 FL("invalid channel: %hhu"),
10118 pnoRequest.aNetworks[i].aChannels[j]);
10119 goto error;
10120 }
10121
Wilson Yang623f6592013-10-08 16:33:37 -070010122 /*Advance to next channel number*/
10123 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010124 }
10125 }
10126
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010127 if (1 != sscanf(ptr," %u %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010128 &(pnoRequest.aNetworks[i].bcastNetwType),
10129 &nOffset))
10130 {
10131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10132 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010133 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010134 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010135 if (pnoRequest.aNetworks[i].bcastNetwType > 2) {
10136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10137 FL("invalid bcast nw type: %u"),
10138 pnoRequest.aNetworks[i].bcastNetwType);
10139 goto error;
10140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010141
10142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10143 "PNO bcastNetwType %d offset %d",
10144 pnoRequest.aNetworks[i].bcastNetwType,
10145 nOffset );
10146
10147 /*Advance to rssi Threshold*/
10148 ptr += nOffset;
10149
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010150 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010151 &(pnoRequest.aNetworks[i].rssiThreshold),
10152 &nOffset))
10153 {
10154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10155 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010156 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010158
10159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10160 "PNO rssi %d offset %d",
10161 pnoRequest.aNetworks[i].rssiThreshold,
10162 nOffset );
10163 /*Advance to next network*/
10164 ptr += nOffset;
10165 }/*For ucNetworkCount*/
10166
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010167 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010168 &(pnoRequest.scanTimers.ucScanTimersCount),
10169 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010170
10171 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -070010172 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010173 {
10174 ptr += nOffset;
10175
Jeff Johnson8301aa12013-03-28 14:27:29 -070010176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10177 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010178 pnoRequest.scanTimers.ucScanTimersCount,
10179 nOffset );
10180
10181 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
10182 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +053010185 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010186 }
10187
10188 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
10189 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010190 ucParams = sscanf(ptr," %u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -070010191 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
10192 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
10193 &nOffset);
10194
Wilson Yang623f6592013-10-08 16:33:37 -070010195 if (2 != ucParams)
10196 {
10197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10198 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +053010199 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010200 }
10201
Jeff Johnson8301aa12013-03-28 14:27:29 -070010202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10203 "PNO Timer value %d Timer repeat %d offset %d",
10204 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -070010205 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
10206 nOffset );
10207
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 ptr += nOffset;
10209 }
10210
10211 }
10212 else
10213 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10215 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010216 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
10217
10218 /*Scan timers defaults to 5 minutes*/
10219 pnoRequest.scanTimers.ucScanTimersCount = 1;
10220 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
10221 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
10222 }
10223
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010224 ucParams = sscanf(ptr," %hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010225
10226 pnoRequest.modePNO = ucMode;
10227 /*for LA we just expose suspend option*/
10228 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
10229 {
10230 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10231 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010232 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10233 if (pnoRequest.p24GProbeTemplate == NULL){
10234 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10235 FL("failed to allocate memory p24GProbeTemplate %u"),
10236 SIR_PNO_MAX_PB_REQ_SIZE);
10237 goto error;
10238 }
10239
10240 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10241 if (pnoRequest.p5GProbeTemplate == NULL){
10242 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10243 FL("failed to allocate memory p5GProbeTemplate %u"),
10244 SIR_PNO_MAX_PB_REQ_SIZE);
10245 goto error;
10246 }
10247
10248 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
10249 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010250
c_hpothu37f21312014-04-09 21:49:54 +053010251 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010252 pAdapter->sessionId,
10253 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010254 if (eHAL_STATUS_SUCCESS == status)
10255 {
10256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10257 "%s: PNO enabled", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010258 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010259 return VOS_STATUS_SUCCESS;
10260 }
10261error:
10262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10263 "%s: Failed to enable PNO", __func__);
10264 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010265 if (pnoRequest.aNetworks)
10266 vos_mem_free(pnoRequest.aNetworks);
10267 if (pnoRequest.p24GProbeTemplate)
10268 vos_mem_free(pnoRequest.p24GProbeTemplate);
10269 if (pnoRequest.p5GProbeTemplate)
10270 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010271
10272 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010273 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010274}/*iw_set_pno*/
10275
10276VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10277 union iwreq_data *wrqu, char *extra, int nOffset)
10278{
10279 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10280 v_U8_t rssiThreshold = 0;
10281 v_U8_t nRead;
10282
Arif Hussain7adce1b2013-11-11 22:59:34 -080010283 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010284 &rssiThreshold);
10285
10286 if ( 1 != nRead )
10287 {
10288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10289 "Incorrect format");
10290 return VOS_STATUS_E_FAILURE;
10291 }
10292
10293 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10294 return VOS_STATUS_SUCCESS;
10295}
10296
10297
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010298static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010299 struct iw_request_info *info,
10300 union iwreq_data *wrqu, char *extra)
10301{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010302 hdd_adapter_t *pAdapter;
10303 hdd_context_t *pHddCtx;
10304 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010305 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010306
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010307 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010308 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10309 if (NULL == pAdapter)
10310 {
10311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10312 "%s: Adapter is NULL",__func__);
10313 return -EINVAL;
10314 }
10315
10316 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10317 ret = wlan_hdd_validate_context(pHddCtx);
10318 if (0 != ret)
10319 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010320 return ret;
10321 }
10322
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010323
10324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010325 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010326
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010327 status = iw_set_pno(dev,info,wrqu,extra,0);
10328
10329 EXIT();
10330 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010331}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010332
10333static int iw_set_pno_priv(struct net_device *dev,
10334 struct iw_request_info *info,
10335 union iwreq_data *wrqu, char *extra)
10336{
10337 int ret;
10338
10339 vos_ssr_protect(__func__);
10340 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10341 vos_ssr_unprotect(__func__);
10342
10343 return ret;
10344}
Jeff Johnson295189b2012-06-20 16:38:30 -070010345#endif /*FEATURE_WLAN_SCAN_PNO*/
10346
10347//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010348int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010349{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010350 hdd_adapter_t *pAdapter;
10351 tHalHandle hHal;
10352 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010353 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010354 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010355 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010356 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010357 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010358 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010359 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010360
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010361 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010362 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10363 if (NULL == pAdapter)
10364 {
10365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10366 "%s: Adapter is NULL",__func__);
10367 return -EINVAL;
10368 }
10369 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10370 retval = wlan_hdd_validate_context(pHddCtx);
10371 if (0 != retval)
10372 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010373 return retval;
10374 }
10375 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10376 if (NULL == hHal)
10377 {
10378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10379 "%s: Hal Context is NULL",__func__);
10380 return -EINVAL;
10381 }
10382 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010383
Atul Mittal54378cb2014-04-02 16:51:50 +053010384 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 {
10386 case WLAN_HDD_UI_BAND_AUTO:
10387 band = eCSR_BAND_ALL;
10388 break;
10389 case WLAN_HDD_UI_BAND_5_GHZ:
10390 band = eCSR_BAND_5G;
10391 break;
10392 case WLAN_HDD_UI_BAND_2_4_GHZ:
10393 band = eCSR_BAND_24;
10394 break;
10395 default:
10396 band = eCSR_BAND_MAX;
10397 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010398 connectedBand =
10399 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010400
Atul Mittal54378cb2014-04-02 16:51:50 +053010401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010402 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010403
10404 if (band == eCSR_BAND_MAX)
10405 {
10406 /* Received change band request with invalid band value */
10407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010408 "%s: Invalid band value %u", __func__, ui_band);
10409 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 }
10411
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010412 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010413 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010414 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010416 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010417 band, pHddCtx->cfg_ini->nBandCapability);
10418 return -EIO;
10419 }
10420
Sushant Kaushik1165f872015-03-30 20:25:27 +053010421 if (band == eCSR_BAND_ALL)
10422 {
10423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10424 "received. Setting band same as ini value %d"),
10425 pHddCtx->cfg_ini->nBandCapability);
10426 band = pHddCtx->cfg_ini->nBandCapability;
10427 }
10428
Jeff Johnson295189b2012-06-20 16:38:30 -070010429 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10430 {
10431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10432 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010433 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010434 return -EIO;
10435 }
10436
10437 if (currBand != band)
10438 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010439 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010440 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010441 /* Return failure if current country code is world regulatory domain*/
10442 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10443 pMac->scan.countryCodeCurrent[1] == '0') )
10444 {
10445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10446 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010447 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010448 return -EAGAIN;
10449 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010450 }
10451
Jeff Johnson295189b2012-06-20 16:38:30 -070010452 /* Change band request received.
10453 * Abort pending scan requests, flush the existing scan results,
10454 * and change the band capability
10455 */
10456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10457 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010458 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010459
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010460 /* We need to change the band and flush the scan results here itself
10461 * as we may get timeout for disconnection in which we will return
10462 * with out doing any of these
10463 */
10464 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10465 {
10466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10467 "%s: failed to set the band value to %u ",
10468 __func__, band);
10469 return -EINVAL;
10470 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010471 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10472 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010473 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010474 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10475 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010476 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010477 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10478 * information available in NV so to get the channel information from kernel
10479 * we need to send regulatory hint for the currunt country
10480 * And to set the same country again we need to set the dummy country
10481 * first and then the actual country.
10482 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010483#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10484 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
10485#else
10486 regulatory_hint_user("00");
10487#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010488 wait_result = wait_for_completion_interruptible_timeout(
10489 &pHddCtx->linux_reg_req,
10490 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10491
10492 /* if the country information does not exist with the kernel,
10493 then the driver callback would not be called */
10494
10495 if (wait_result >= 0)
10496 {
10497 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10498 "runtime country code is found in kernel db");
10499 }
10500 else
10501 {
10502 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10503 "runtime country code is not found"
10504 " in kernel db");
10505 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010506
10507 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010508
10509 /*
10510 * Update 11dcountry and current country here as the hint
10511 * with 00 results in 11d and current country with 00
10512 */
10513 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10514 WNI_CFG_COUNTRY_CODE_LEN);
10515 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10516 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010517#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10518 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10519#else
10520 regulatory_hint_user(curr_country);
10521#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010522 wait_result = wait_for_completion_interruptible_timeout(
10523 &pHddCtx->linux_reg_req,
10524 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10525
10526 /* if the country information does not exist with the kernel,
10527 then the driver callback would not be called */
10528 if (wait_result >= 0)
10529 {
10530 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10531 "runtime country code is found in kernel db");
10532 }
10533 else
10534 {
10535 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10536 "runtime country code is not found"
10537 " in kernel db");
10538 }
10539
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010540 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010541 }
10542 else
10543 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010544#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010545 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10546 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010547#else
10548 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10549#endif
10550
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010551 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010552 pScanInfo = &pHddCtx->scan_info;
10553 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10554 {
10555 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10556 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10557 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010558 sme_FilterScanResults(hHal, pAdapter->sessionId);
10559
10560 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010561 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10562 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010563 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 eHalStatus status = eHAL_STATUS_SUCCESS;
10565 long lrc;
10566
10567 /* STA already connected on current band, So issue disconnect first,
10568 * then change the band*/
10569
10570 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010571 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010572 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010573
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10575
10576 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10577 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10578
Jeff Johnson43971f52012-07-17 12:26:56 -070010579 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010580 {
10581 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010582 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 __func__, (int)status );
10584 return -EINVAL;
10585 }
10586
10587 lrc = wait_for_completion_interruptible_timeout(
10588 &pAdapter->disconnect_comp_var,
10589 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10590
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010591 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010592
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010593 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010594 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010595
10596 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10597 }
10598 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010600 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010601 if (TRUE == pHddCtx->isSetBandByNL)
10602 return 0;
10603 else
10604 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010605}
10606
Atul Mittal54378cb2014-04-02 16:51:50 +053010607int hdd_setBand_helper(struct net_device *dev, const char *command)
10608{
10609 u8 band;
10610
10611 /*convert the band value from ascii to integer*/
10612 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10613
10614 return hdd_setBand(dev, band);
10615
10616}
10617
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010618static int __iw_set_band_config(struct net_device *dev,
10619 struct iw_request_info *info,
10620 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010621{
Atul Mittal54378cb2014-04-02 16:51:50 +053010622 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010623
Arif Hussain0273cba2014-01-07 20:58:29 -080010624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010625
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010626 if (!capable(CAP_NET_ADMIN))
10627 {
10628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10629 FL("permission check failed"));
10630 return -EPERM;
10631 }
10632
Atul Mittal54378cb2014-04-02 16:51:50 +053010633 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010634}
10635
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010636static int iw_set_band_config(struct net_device *dev,
10637 struct iw_request_info *info,
10638 union iwreq_data *wrqu, char *extra)
10639{
10640 int ret;
10641
10642 vos_ssr_protect(__func__);
10643 ret = __iw_set_band_config(dev, info, wrqu, extra);
10644 vos_ssr_unprotect(__func__);
10645
10646 return ret;
10647}
10648
c_manjeecfd1efb2015-09-25 19:32:34 +053010649static int get_fwr_memdump(struct net_device *dev,
10650 struct iw_request_info *info,
10651 union iwreq_data *wrqu, char *extra)
10652{
10653 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10654 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10655 int ret;
10656 ENTER();
10657 // HddCtx sanity
10658 ret = wlan_hdd_validate_context(pHddCtx);
10659 if (0 != ret)
10660 {
10661 return ret;
10662 }
10663 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10664 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10665 {
10666 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10667 return -EINVAL;
10668 }
10669 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10670
10671 EXIT();
10672 return ret;
10673}
10674
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010675static int __iw_set_power_params_priv(struct net_device *dev,
10676 struct iw_request_info *info,
10677 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010678{
Arif Hussain0273cba2014-01-07 20:58:29 -080010679 int ret;
10680 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010681
Jeff Johnson295189b2012-06-20 16:38:30 -070010682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10683 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010684
10685 if (!capable(CAP_NET_ADMIN))
10686 {
10687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10688 FL("permission check failed"));
10689 return -EPERM;
10690 }
10691
Arif Hussain0273cba2014-01-07 20:58:29 -080010692 /* ODD number is used for set, copy data using copy_from_user */
10693 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10694 wrqu->data.length);
10695 if (NULL == ptr)
10696 {
10697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10698 "mem_alloc_copy_from_user_helper fail");
10699 return -ENOMEM;
10700 }
10701
10702 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10703 kfree(ptr);
10704 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010705}
10706
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010707static int iw_set_power_params_priv(struct net_device *dev,
10708 struct iw_request_info *info,
10709 union iwreq_data *wrqu, char *extra)
10710{
10711 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010712
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010713 vos_ssr_protect(__func__);
10714 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10715 vos_ssr_unprotect(__func__);
10716
10717 return ret;
10718}
Jeff Johnson295189b2012-06-20 16:38:30 -070010719
10720/*string based input*/
10721VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10722 union iwreq_data *wrqu, char *extra, int nOffset)
10723{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010724 hdd_adapter_t *pAdapter;
10725 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010726 tSirSetPowerParamsReq powerRequest;
10727 char *ptr;
10728 v_U8_t ucType;
10729 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010730 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010732 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010733 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10734 if (NULL == pAdapter)
10735 {
10736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10737 "%s: Adapter is NULL",__func__);
10738 return -EINVAL;
10739 }
10740
10741 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10742 ret = wlan_hdd_validate_context(pHddCtx);
10743 if (0 != ret)
10744 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010745 return ret;
10746 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10748 "Power Params data len %d data %s",
10749 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010750 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010751
10752 if (wrqu->data.length <= nOffset )
10753 {
10754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10755 return VOS_STATUS_E_FAILURE;
10756 }
10757
10758 uTotalSize = wrqu->data.length - nOffset;
10759
10760 /*-----------------------------------------------------------------------
10761 Input is string based and expected to be like this:
10762
10763 <param_type> <param_value> <param_type> <param_value> ...
10764
10765 e.g:
10766 1 2 2 3 3 0 4 1 5 1
10767
10768 e.g. setting just a few:
10769 1 2 4 1
10770
10771 parameter types:
10772 -----------------------------
10773 1 - Ignore DTIM
10774 2 - Listen Interval
10775 3 - Broadcast Multicas Filter
10776 4 - Beacon Early Termination
10777 5 - Beacon Early Termination Interval
10778 -----------------------------------------------------------------------*/
10779 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10780 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10781 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10782 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10783 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10784
Arif Hussain7adce1b2013-11-11 22:59:34 -080010785 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010786
10787 while ( uTotalSize )
10788 {
Wilson Yang6f971452013-10-08 15:00:00 -070010789 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10790 {
10791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10792 "Invalid input parameter type %s",ptr);
10793 return VOS_STATUS_E_FAILURE;
10794 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010795
10796 uTotalSize -= nOffset;
10797
10798 if (!uTotalSize)
10799 {
10800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010801 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010802 ucType, nOffset);
10803 return VOS_STATUS_E_FAILURE;
10804 }
10805
10806 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010807
Jeff Johnson02797792013-10-26 19:17:13 -070010808 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010809 {
10810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10811 "Invalid input parameter value %s",ptr);
10812 return VOS_STATUS_E_FAILURE;
10813 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010814
10815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10816 "Power request parameter %d value %d offset %d",
10817 ucType, uValue, nOffset);
10818
10819 switch (ucType)
10820 {
10821 case eSIR_IGNORE_DTIM:
10822 powerRequest.uIgnoreDTIM = uValue;
10823 break;
10824 case eSIR_LISTEN_INTERVAL:
10825 powerRequest.uListenInterval = uValue;
10826 break;
10827 case eSIR_MCAST_BCAST_FILTER:
10828 powerRequest.uBcastMcastFilter = uValue;
10829 break;
10830 case eSIR_ENABLE_BET:
10831 powerRequest.uEnableBET = uValue;
10832 break;
10833 case eSIR_BET_INTERVAL:
10834 powerRequest.uBETInterval = uValue;
10835 break;
10836 default:
10837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010838 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010839 ucType, uValue, nOffset);
10840 return VOS_STATUS_E_FAILURE;
10841 }
10842
10843 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10845 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010846 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010848 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010849 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010850 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10851 {
10852 uTotalSize = 0;
10853 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010854
10855 }/*Go for as long as we have a valid string*/
10856
10857 /* put the device into full power*/
10858 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10859
10860 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010861 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010862
10863 /* put the device back to power save*/
10864 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10865
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010866 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010867 return VOS_STATUS_SUCCESS;
10868}/*iw_set_power_params*/
10869
Atul Mittalc0f739f2014-07-31 13:47:47 +053010870// tdlsoffchan
10871#ifdef FEATURE_WLAN_TDLS
10872
Atul Mittal87ec2422014-09-24 13:12:50 +053010873int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010874{
10875 if (offchannel < 0 || offchannel > 165)
10876 {
10877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10878 __func__, offchannel);
10879 return -1;
10880
10881 }
10882
10883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10884 __func__, tdlsOffCh, offchannel);
10885
10886 tdlsOffCh = offchannel;
10887 return 0;
10888}
10889
Atul Mittal87ec2422014-09-24 13:12:50 +053010890int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010891{
10892 if (offchanoffset == 0)
10893 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010894 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10896 __func__, tdlsOffChBwOffset);
10897
10898 return 0;
10899
10900 }
10901
10902 if ( offchanoffset == 40 )
10903 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010904 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10906 __func__, tdlsOffChBwOffset);
10907
10908 return 0;
10909
10910 }
10911 if (offchanoffset == -40)
10912 {
10913 tdlsOffChBwOffset = 3;
10914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10915 __func__, tdlsOffChBwOffset);
10916
10917 return 0;
10918
10919 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010920
10921 if ((offchanoffset == 80) &&
10922 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10923 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10924 {
10925 tdlsOffChBwOffset = 4;
10926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10927 "%s: change tdls secondary off channel offset to %u",
10928 __func__, tdlsOffChBwOffset);
10929
10930 return 0;
10931 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10933 __func__, offchanoffset);
10934 return -1;
10935}
10936
Atul Mittal87ec2422014-09-24 13:12:50 +053010937int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010938{
10939 hddTdlsPeer_t *connPeer = NULL;
10940 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10941 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010942 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010943 if (offchanmode < 0 || offchanmode > 4)
10944 {
10945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10946 "%s: Invalid tdls off channel mode %d",
10947 __func__, offchanmode);
10948 return -1;
10949 }
10950
10951 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10952 {
10953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10954 "%s: tdls off channel mode req in not associated state %d",
10955 __func__, offchanmode);
10956 return -1;
10957 }
10958
10959 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10960 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10961 {
10962 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010963 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010964 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010965 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010966 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10968 "%s: No TDLS Connected Peer", __func__);
10969 return -1;
10970 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010971 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010972 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010973 }
10974 else
10975 {
10976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10977 "%s: TDLS Connection not supported", __func__);
10978 return -1;
10979 }
10980
10981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10982 ("%s: TDLS Channel Switch in swmode=%d"),
10983 __func__, offchanmode);
10984
10985 switch (offchanmode)
10986 {
10987 case 1:/*Enable*/
10988 case 2:/*Disable*/
10989 {
10990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10991 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10992 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10993 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10994 {
10995
10996 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010997 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053010998 tdlsOffCh, tdlsOffChBwOffset,
10999 offchanmode);
11000 }
11001 else
11002 {
11003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11004 "%s: TDLS Off Channel not supported", __func__);
11005 return -1;
11006 }
11007 break;
11008 }
11009 case 3:
11010 {
11011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11012 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
11013 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11014
11015 break;
11016 }
11017 case 4:
11018 {
11019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11020 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
11021 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11022 break;
11023 }
11024 default:
11025 {
11026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11027 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
11028 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11029 break;
11030 }
11031
11032 }
11033
11034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
11035 __func__, offchanmode);
11036 return 0;
11037}
Atul Mittalc0f739f2014-07-31 13:47:47 +053011038#endif
11039
Jeff Johnson295189b2012-06-20 16:38:30 -070011040// Define the Wireless Extensions to the Linux Network Device structure
11041// A number of these routines are NULL (meaning they are not implemented.)
11042
11043static const iw_handler we_handler[] =
11044{
11045 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
11046 (iw_handler) iw_get_name, /* SIOCGIWNAME */
11047 (iw_handler) NULL, /* SIOCSIWNWID */
11048 (iw_handler) NULL, /* SIOCGIWNWID */
11049 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
11050 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
11051 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
11052 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
11053 (iw_handler) NULL, /* SIOCSIWSENS */
11054 (iw_handler) NULL, /* SIOCGIWSENS */
11055 (iw_handler) NULL, /* SIOCSIWRANGE */
11056 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053011057 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070011058 (iw_handler) NULL, /* SIOCGIWPRIV */
11059 (iw_handler) NULL, /* SIOCSIWSTATS */
11060 (iw_handler) NULL, /* SIOCGIWSTATS */
11061 iw_handler_set_spy, /* SIOCSIWSPY */
11062 iw_handler_get_spy, /* SIOCGIWSPY */
11063 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
11064 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
11065 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
11066 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
11067 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
11068 (iw_handler) NULL, /* SIOCGIWAPLIST */
11069 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
11070 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
11071 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
11072 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
11073 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
11074 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
11075 (iw_handler) NULL, /* -- hole -- */
11076 (iw_handler) NULL, /* -- hole -- */
11077 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
11078 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
11079 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
11080 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
11081 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
11082 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
11083 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
11084 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
11085 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
11086 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
11087 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
11088 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
11089 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
11090 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
11091 (iw_handler) NULL, /* -- hole -- */
11092 (iw_handler) NULL, /* -- hole -- */
11093 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
11094 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
11095 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
11096 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
11097 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
11098 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
11099 (iw_handler) NULL, /* SIOCSIWPMKSA */
11100};
11101
11102static const iw_handler we_private[] = {
11103
11104 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
11105 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
11106 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
11107 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
11108 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
11109 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053011110 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070011111 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
11112 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
11113 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Manjeet Singh3ed79242017-01-11 19:04:32 +053011114 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
11115 iw_setnone_get_threeint,
Jeff Johnsone7245742012-09-05 17:12:55 -070011116#ifdef FEATURE_OEM_DATA_SUPPORT
11117 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
11118 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
11119#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011120
Jeff Johnson295189b2012-06-20 16:38:30 -070011121#ifdef WLAN_FEATURE_VOWIFI_11R
11122 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
11123#endif
11124 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
11125 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
11126 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
11127#ifdef WLAN_FEATURE_PACKET_FILTERING
11128 ,
11129 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
11130#endif
11131#ifdef FEATURE_WLAN_SCAN_PNO
11132 ,
11133 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
11134#endif
11135 ,
11136 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
11137 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
11138 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
11139 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070011140 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070011141};
11142
11143/*Maximum command length can be only 15 */
11144static const struct iw_priv_args we_private_args[] = {
11145
Katya Nigamf0511f62015-05-05 16:40:57 +053011146 { WE_SET_MONITOR_STATE,
11147 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11148 0, "monitor" },
11149
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 /* handlers for main ioctl */
11151 { WLAN_PRIV_SET_INT_GET_NONE,
11152 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11153 0,
11154 "" },
11155
11156 /* handlers for sub-ioctl */
11157 { WE_SET_11D_STATE,
11158 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11159 0,
11160 "set11Dstate" },
11161
11162 { WE_WOWL,
11163 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11164 0,
11165 "wowl" },
11166
11167 { WE_SET_POWER,
11168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11169 0,
11170 "setPower" },
11171
11172 { WE_SET_MAX_ASSOC,
11173 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11174 0,
11175 "setMaxAssoc" },
11176
11177 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
11178 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11179 0,
11180 "setAutoChannel" },
11181
11182 { WE_SET_DATA_INACTIVITY_TO,
11183 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11184 0,
11185 "inactivityTO" },
11186
11187 { WE_SET_MAX_TX_POWER,
11188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11189 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070011190 "setMaxTxPower" },
11191
11192 { WE_SET_MAX_TX_POWER_2_4,
11193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11194 0,
11195 "setTxMaxPower2G" },
11196
11197 { WE_SET_MAX_TX_POWER_5_0,
11198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11199 0,
11200 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070011201
11202 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
11203 * as well to keep same syntax as in SAP. Now onwards, STA
11204 * will support both */
11205 { WE_SET_MAX_TX_POWER,
11206 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11207 0,
11208 "setTxMaxPower" },
11209
Jeff Johnson295189b2012-06-20 16:38:30 -070011210 /* set Higher DTIM Transition (DTIM1 to DTIM3)
11211 * 1 = enable and 0 = disable */
11212 {
11213 WE_SET_HIGHER_DTIM_TRANSITION,
11214 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11215 0,
11216 "setHDtimTransn" },
11217
11218 { WE_SET_TM_LEVEL,
11219 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011220 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011221 "setTmLevel" },
11222
Kiet Lam46b8e4e2013-11-06 21:49:53 +053011223 { WE_ENABLE_STRICT_FCC_REG,
11224 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11225 0,
11226 "setStrictFCCreg" },
11227
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011228 { WE_SET_DEBUG_LOG,
11229 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11230 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053011231#ifdef FEATURE_WLAN_TDLS
11232 {
11233 WE_SET_TDLS_OFF_CHAN,
11234 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11235 0,
11236 "tdlsoffchan" },
11237 {
11238 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
11239 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11240 0,
11241 "tdlsecchnoffst" },
11242 {
11243 WE_SET_TDLS_OFF_CHAN_MODE,
11244 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11245 0,
11246 "tdlsoffchnmode" },
11247#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011248
Peng Xu2446a892014-09-05 17:21:18 +053011249 { WE_SET_SCAN_BAND_PREFERENCE,
11250 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11251 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053011252 {
11253 WE_GET_FRAME_LOG,
11254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11255 0,
11256 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053011257
Abhishek Singh01c73d12015-03-12 15:13:44 +053011258 { WE_SET_MIRACAST_VENDOR_CONFIG,
11259 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11260 0, "setMiracstConf" },
11261
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053011262#ifdef FEATURE_WLAN_TDLS
11263 {
11264 WE_SET_TDLS_2040_BSS_COEXISTENCE,
11265 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11266 0,
11267 "tdls_2040bsscox" },
11268#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053011269 { WE_SET_RTS_CTS_HTVHT,
11270 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11271 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053011272 { WE_SET_PKT_STATS_ENABLE_DISABLE,
11273 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11274 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053011275 { WE_SET_PROXIMITY_ENABLE,
11276 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11277 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011278
11279#ifdef WLAN_FEATURE_TSF
11280 { WE_CAP_TSF,
11281 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11282 0, "cap_tsf" },
11283#endif
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +053011284 { WE_SET_MODULATED_DTIM,
11285 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11286 0, "setModDTIM" },
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053011287 {
11288 WLAN_SET_DYNNAMIC_AGGREGATION,
11289 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11290 0, "setAggregation" },
11291
Jeff Johnson295189b2012-06-20 16:38:30 -070011292 /* handlers for main ioctl */
11293 { WLAN_PRIV_SET_NONE_GET_INT,
11294 0,
11295 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11296 "" },
11297
11298 /* handlers for sub-ioctl */
11299 { WE_GET_11D_STATE,
11300 0,
11301 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11302 "get11Dstate" },
11303
11304 { WE_IBSS_STATUS,
11305 0,
11306 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11307 "getAdhocStatus" },
11308
11309 { WE_PMC_STATE,
11310 0,
11311 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11312 "pmcState" },
11313
11314 { WE_GET_WLAN_DBG,
11315 0,
11316 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11317 "getwlandbg" },
11318
Jeff Johnson295189b2012-06-20 16:38:30 -070011319 { WE_GET_MAX_ASSOC,
11320 0,
11321 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11322 "getMaxAssoc" },
11323
Jeff Johnson295189b2012-06-20 16:38:30 -070011324 { WE_GET_WDI_DBG,
11325 0,
11326 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11327 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011328
11329 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11330 0,
11331 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11332 "getAutoChannel" },
11333
11334 { WE_GET_CONCURRENCY_MODE,
11335 0,
11336 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11337 "getconcurrency" },
11338
Peng Xu2446a892014-09-05 17:21:18 +053011339 { WE_GET_SCAN_BAND_PREFERENCE,
11340 0,
11341 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11342 "get_scan_pref"},
11343
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011344 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11345 0,
11346 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11347 "getCurAnt"},
11348
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 /* handlers for main ioctl */
11350 { WLAN_PRIV_SET_CHAR_GET_NONE,
11351 IW_PRIV_TYPE_CHAR| 512,
11352 0,
11353 "" },
11354
11355 /* handlers for sub-ioctl */
11356 { WE_WOWL_ADD_PTRN,
11357 IW_PRIV_TYPE_CHAR| 512,
11358 0,
11359 "wowlAddPtrn" },
11360
11361 { WE_WOWL_DEL_PTRN,
11362 IW_PRIV_TYPE_CHAR| 512,
11363 0,
11364 "wowlDelPtrn" },
11365
11366#if defined WLAN_FEATURE_VOWIFI
11367 /* handlers for sub-ioctl */
11368 { WE_NEIGHBOR_REPORT_REQUEST,
11369 IW_PRIV_TYPE_CHAR | 512,
11370 0,
11371 "neighbor" },
11372#endif
11373 { WE_SET_AP_WPS_IE,
11374 IW_PRIV_TYPE_CHAR| 512,
11375 0,
11376 "set_ap_wps_ie" },
11377
11378 { WE_SET_CONFIG,
11379 IW_PRIV_TYPE_CHAR| 512,
11380 0,
11381 "setConfig" },
11382
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011383 { WE_SET_ENCRYPT_MSG,
11384 IW_PRIV_TYPE_CHAR| 512,
11385 0,
11386 "encryptMsg" },
11387
11388
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 /* handlers for main ioctl */
11390 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11391 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11392 0,
11393 "" },
11394
11395 /* handlers for sub-ioctl */
11396 { WE_SET_WLAN_DBG,
11397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11398 0,
11399 "setwlandbg" },
11400
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 { WE_SET_WDI_DBG,
11402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11403 0,
11404 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011405
11406 { WE_SET_SAP_CHANNELS,
11407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11408 0,
11409 "setsapchannels" },
11410
11411 /* handlers for main ioctl */
11412 { WLAN_PRIV_GET_CHAR_SET_NONE,
11413 0,
11414 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11415 "" },
11416
11417 /* handlers for sub-ioctl */
11418 { WE_WLAN_VERSION,
11419 0,
11420 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11421 "version" },
11422 { WE_GET_STATS,
11423 0,
11424 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11425 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011426 { WE_GET_STATES,
11427 0,
11428 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11429 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 { WE_GET_CFG,
11431 0,
11432 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11433 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011434#ifdef WLAN_FEATURE_11AC
11435 { WE_GET_RSSI,
11436 0,
11437 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11438 "getRSSI" },
11439#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011440#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011441 { WE_GET_ROAM_RSSI,
11442 0,
11443 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11444 "getRoamRSSI" },
11445#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 { WE_GET_WMM_STATUS,
11447 0,
11448 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11449 "getWmmStatus" },
11450 {
11451 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011452 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11454 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011455#ifdef FEATURE_WLAN_TDLS
11456 {
11457 WE_GET_TDLS_PEERS,
11458 0,
11459 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11460 "getTdlsPeers" },
11461#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011462#ifdef WLAN_FEATURE_11W
11463 {
11464 WE_GET_11W_INFO,
11465 0,
11466 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11467 "getPMFInfo" },
11468#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011469#ifdef WLAN_FEATURE_RMC
11470 {
11471 WE_GET_IBSS_STA_INFO,
11472 0,
11473 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11474 "getIbssSTAs" },
11475#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011476 { WE_GET_SNR,
11477 0,
11478 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11479 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011480#ifdef FEATURE_OEM_DATA_SUPPORT
11481 {
11482 WE_GET_OEM_DATA_CAP,
11483 0,
11484 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11485 "getOemDataCap" },
11486#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 /* handlers for main ioctl */
11488 { WLAN_PRIV_SET_NONE_GET_NONE,
11489 0,
11490 0,
11491 "" },
11492
11493 /* handlers for sub-ioctl */
11494 { WE_CLEAR_STATS,
11495 0,
11496 0,
11497 "clearStats" },
11498 { WE_INIT_AP,
11499 0,
11500 0,
11501 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011502#ifdef WLAN_FEATURE_RMC
11503 {
11504 WE_IBSS_GET_PEER_INFO_ALL,
11505 0,
11506 0,
11507 "ibssPeerInfoAll" },
11508#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011509 { WE_STOP_AP,
11510 0,
11511 0,
11512 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011513#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011514 { WE_ENABLE_AMP,
11515 0,
11516 0,
11517 "enableAMP" },
11518 { WE_DISABLE_AMP,
11519 0,
11520 0,
11521 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011522#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011523 { WE_ENABLE_DXE_STALL_DETECT,
11524 0,
11525 0,
11526 "dxeStallDetect" },
11527 { WE_DISPLAY_DXE_SNAP_SHOT,
11528 0,
11529 0,
11530 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011531 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11532 0,
11533 0,
11534 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011535 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011536 WE_SET_REASSOC_TRIGGER,
11537 0,
11538 0,
11539 "reassoc" },
11540 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011541 WE_STOP_OBSS_SCAN,
11542 0,
11543 0,
11544 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011545 {
11546 WE_DUMP_ROAM_TIMER_LOG,
11547 0,
11548 0,
11549 "dumpRoamDelay" },
11550 {
11551 WE_RESET_ROAM_TIMER_LOG,
11552 0,
11553 0,
11554 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011555 {
11556 WE_GET_FW_LOGS,
11557 0,
11558 0,
11559 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011560 {
11561 WE_GET_FW_MEMDUMP,
11562 0,
11563 0,
11564 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 /* handlers for main ioctl */
11566 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11567 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11568 0,
11569 "" },
11570
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011571
11572
Jeff Johnson295189b2012-06-20 16:38:30 -070011573 /* handlers for sub-ioctl */
11574 { WE_LOG_DUMP_CMD,
11575 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11576 0,
11577 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011578#ifdef WLAN_FEATURE_RMC
11579 { WE_IBSS_GET_PEER_INFO,
11580 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11581 0,
11582 "ibssPeerInfo" },
11583#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011584
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011585 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011586 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11587 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11588 0,
11589 "setdumplog" },
11590
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011591 { WE_MTRACE_DUMP_CMD,
11592 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11593 0,
11594 "dumplog" },
11595
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011596 /* handlers for sub ioctl */
11597 {
11598 WE_MCC_CONFIG_CREDENTIAL,
11599 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11600 0,
11601 "setMccCrdnl" },
11602
11603 /* handlers for sub ioctl */
11604 {
11605 WE_MCC_CONFIG_PARAMS,
11606 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11607 0,
11608 "setMccConfig" },
11609
Chilam NG571c65a2013-01-19 12:27:36 +053011610#ifdef FEATURE_WLAN_TDLS
11611 /* handlers for sub ioctl */
11612 {
11613 WE_TDLS_CONFIG_PARAMS,
11614 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11615 0,
11616 "setTdlsConfig" },
11617#endif
11618
Katya Nigamf0511f62015-05-05 16:40:57 +053011619 {
11620 WE_CONFIGURE_MONITOR_MODE,
11621 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11622 0,
11623 "MonitorModeConf" },
11624
11625 {
11626 WE_SET_MONITOR_MODE_FILTER,
11627 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11628 0,
11629 "MonitorFilter" },
11630
Jeff Johnson295189b2012-06-20 16:38:30 -070011631 /* handlers for main ioctl */
11632 { WLAN_PRIV_ADD_TSPEC,
11633 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11634 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11635 "addTspec" },
11636
11637 /* handlers for main ioctl */
11638 { WLAN_PRIV_DEL_TSPEC,
11639 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11640 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11641 "delTspec" },
11642
11643 /* handlers for main ioctl */
11644 { WLAN_PRIV_GET_TSPEC,
11645 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11646 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11647 "getTspec" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011648 /* handlers for main ioctl */
11649 { WLAN_PRIV_SET_NONE_GET_THREE_INT,
11650 0,
11651 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11652 "" },
11653#ifdef WLAN_FEATURE_TSF
11654 { WE_GET_TSF,
11655 0,
11656 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11657 "get_tsf" },
11658#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011659#ifdef FEATURE_OEM_DATA_SUPPORT
11660 /* handlers for main ioctl - OEM DATA */
11661 {
11662 WLAN_PRIV_SET_OEM_DATA_REQ,
11663 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11664 0,
11665 "set_oem_data_req" },
11666
11667 /* handlers for main ioctl - OEM DATA */
11668 {
11669 WLAN_PRIV_GET_OEM_DATA_RSP,
11670 0,
11671 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11672 "get_oem_data_rsp" },
11673#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011674
Jeff Johnson295189b2012-06-20 16:38:30 -070011675 /* handlers for main ioctl - host offload */
11676 {
11677 WLAN_PRIV_SET_HOST_OFFLOAD,
11678 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11679 0,
11680 "setHostOffload" },
11681
11682 {
11683 WLAN_GET_WLAN_STATISTICS,
11684 0,
11685 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11686 "getWlanStats" },
11687
11688 {
11689 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011690 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11691 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 0,
11693 "setKeepAlive" },
11694#ifdef WLAN_FEATURE_PACKET_FILTERING
11695 {
11696 WLAN_SET_PACKET_FILTER_PARAMS,
11697 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11698 0,
11699 "setPktFilter" },
11700#endif
11701#ifdef FEATURE_WLAN_SCAN_PNO
11702 {
11703 WLAN_SET_PNO,
11704 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11705 0,
11706 "setpno" },
11707#endif
11708 {
11709 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011710 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011711 0,
11712 "SETBAND" },
11713 /* handlers for dynamic MC BC ioctl */
11714 {
11715 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011716 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011717 0,
11718 "setMCBCFilter" },
11719 {
11720 WLAN_PRIV_CLEAR_MCBC_FILTER,
11721 0,
11722 0,
11723 "clearMCBCFilter" },
11724 {
11725 WLAN_SET_POWER_PARAMS,
11726 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11727 0,
11728 "setpowerparams" },
11729 {
11730 WLAN_GET_LINK_SPEED,
11731 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011732 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011733};
11734
11735
11736
11737const struct iw_handler_def we_handler_def = {
11738 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11739 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11740 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11741
11742 .standard = (iw_handler *)we_handler,
11743 .private = (iw_handler *)we_private,
11744 .private_args = we_private_args,
11745 .get_wireless_stats = get_wireless_stats,
11746};
11747
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011748int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11749{
11750 v_U32_t cmd = 288; //Command to RIVA
11751 hdd_context_t *pHddCtx = NULL;
11752 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11753 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11754 /*
11755 *configMccParam : specify the bit which needs to be modified
11756 *allowed to update based on wlan_qcom_cfg.ini
11757 * configuration
11758 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11759 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11760 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11761 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11762 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11763 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11764 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11765 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11766 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11767 * Bit 9 : Reserved
11768 */
11769 switch (arg1)
11770 {
11771 //Update MCC SCHEDULE_TIME_SLICE parameter
11772 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11773 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11774 {
11775 if((arg2 >= 5) && (arg2 <= 20))
11776 {
11777 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11778 }
11779 else
11780 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011781 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011782 return 0;
11783 }
11784 }
11785 break;
11786
11787 //Update MCC MAX_NULL_SEND_TIME parameter
11788 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11789 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11790 {
11791 if((arg2 >= 1) && (arg2 <= 10))
11792 {
11793 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11794 }
11795 else
11796 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011797 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011798 return 0;
11799 }
11800 }
11801 break;
11802
11803 //Update MCC TX_EARLY_STOP_TIME parameter
11804 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11805 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11806 {
11807 if((arg2 >= 1) && (arg2 <= 10))
11808 {
11809 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11810 }
11811 else
11812 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011813 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011814 return 0;
11815 }
11816 }
11817 break;
11818
11819 //Update MCC RX_DRAIN_TIME parameter
11820 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11821 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11822 {
11823 if((arg2 >= 1) && (arg2 <= 10))
11824 {
11825 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11826 }
11827 else
11828 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011829 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011830 return 0;
11831 }
11832 }
11833 break;
11834
11835 //Update MCC CHANNEL_SWITCH_TIME parameter
11836 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11837 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11838 {
11839 if((arg2 >= 1) && (arg2 <= 20))
11840 {
11841 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11842 }
11843 else
11844 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011845 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011846 return 0;
11847 }
11848 }
11849 break;
11850
11851 //Update MCC MIN_CHANNEL_TIME parameter
11852 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11853 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11854 {
11855 if((arg2 >= 5) && (arg2 <= 20))
11856 {
11857 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11858 }
11859 else
11860 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011861 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011862 return 0;
11863 }
11864 }
11865 break;
11866
11867 //Update MCC PARK_BEFORE_TBTT parameter
11868 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11869 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11870 {
11871 if((arg2 >= 1) && (arg2 <= 5))
11872 {
11873 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11874 }
11875 else
11876 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011877 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011878 return 0;
11879 }
11880 }
11881 break;
11882
11883 //Update MCC MIN_AFTER_DTIM parameter
11884 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11885 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11886 {
11887 if((arg2 >= 5) && (arg2 <= 15))
11888 {
11889 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11890 }
11891 else
11892 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011893 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011894 return 0;
11895 }
11896 }
11897 break;
11898
11899 //Update MCC TOO_CLOSE_MARGIN parameter
11900 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11901 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11902 {
11903 if((arg2 >= 1) && (arg2 <= 3))
11904 {
11905 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11906 }
11907 else
11908 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011909 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011910 return 0;
11911 }
11912 }
11913 break;
11914
11915 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011916 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011917 __FUNCTION__,arg1);
11918 break;
11919 }
11920 return 0;
11921}
11922
Jeff Johnson295189b2012-06-20 16:38:30 -070011923int hdd_set_wext(hdd_adapter_t *pAdapter)
11924{
11925 hdd_wext_state_t *pwextBuf;
11926 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011927 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011928
11929 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11930
11931 // Now configure the roaming profile links. To SSID and bssid.
11932 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11933 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11934
11935 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11936 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11937
11938 /*Set the numOfChannels to zero to scan all the channels*/
11939 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11940 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11941
11942 /* Default is no encryption */
11943 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11944 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11945
11946 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11947 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11948
11949 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11950
11951 /* Default is no authentication */
11952 pwextBuf->roamProfile.AuthType.numEntries = 1;
11953 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11954
11955 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11956 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11957
11958 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011959 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011960
11961 hdd_clearRoamProfileIe(pAdapter);
11962
11963 return VOS_STATUS_SUCCESS;
11964
11965 }
11966
11967int hdd_register_wext(struct net_device *dev)
11968 {
11969 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11970 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11971 VOS_STATUS status;
11972
11973 ENTER();
11974
11975 // Zero the memory. This zeros the profile structure.
11976 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11977
11978 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11979
11980
11981 status = hdd_set_wext(pAdapter);
11982
11983 if(!VOS_IS_STATUS_SUCCESS(status)) {
11984
Arif Hussain6d2a3322013-11-17 19:50:10 -080011985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011986 return eHAL_STATUS_FAILURE;
11987 }
11988
11989 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11990 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011992 return eHAL_STATUS_FAILURE;
11993 }
11994
11995 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11996 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011998 return eHAL_STATUS_FAILURE;
11999 }
12000
12001 // Register as a wireless device
12002 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
12003
12004 EXIT();
12005 return 0;
12006}
12007
12008int hdd_UnregisterWext(struct net_device *dev)
12009{
c_hpothu2a13bc32015-01-21 12:48:54 +053012010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
12011 if (dev != NULL)
12012 {
12013 rtnl_lock();
12014 dev->wireless_handlers = NULL;
12015 rtnl_unlock();
12016 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053012017
Jeff Johnson295189b2012-06-20 16:38:30 -070012018 return 0;
12019}
12020
12021