blob: 55d3740be187d1f1f26193ca0618d45e8bafe7f0 [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 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700919 pr_info("%s: rssi [%d] STA [%d] pContext [%pK]\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,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700926 "%s: Bad param, pContext [%pK]",
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,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700945 "%s: Invalid context, pAdapter [%pK] 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 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700949 pr_info("%s: Invalid context, pAdapter [%pK] 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 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700982 pr_info("%s: snr [%d] STA [%d] pContext [%pK]\n",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530983 __func__, (int)snr, (int)staId, pContext);
984 }
985
986 if (NULL == pContext)
987 {
988 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -0700989 "%s: Bad param, pContext [%pK]",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530990 __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,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001008 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301009 __func__, pAdapter, pStatsContext->magic);
1010 if (ioctl_debug)
1011 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001012 pr_info("%s: Invalid context, pAdapter [%pK] magic [%08x]\n",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301013 __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 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001269 pr_info("%s: rssi [%d] STA [%d] pContext [%pK]\n",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001270 __func__, (int)rssi, (int)staId, pContext);
1271 }
1272
1273 if (NULL == pContext)
1274 {
1275 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001276 "%s: Bad param, pContext [%pK]",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001277 __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,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001295 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001296 __func__, pAdapter, pStatsContext->magic);
1297 if (ioctl_debug)
1298 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001299 pr_info("%s: Invalid context, pAdapter [%pK] magic [%08x]\n",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001300 __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 }
SaidiReddy Yenuga764a9d22017-05-26 18:37:53 +05301647 if ((elem_id == eid) && (elem_len >= oui_size))
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 {
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,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003343 "%s: Bad param, pContext [%pK]",
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 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003409 pr_info("%s: pStats [%pK] pContext [%pK]\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,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003416 "%s: Bad param, pStats [%pK] pContext [%pK]",
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,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003436 "%s: Invalid context, pAdapter [%pK] 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 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003440 pr_info("%s: Invalid context, pAdapter [%pK] 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 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003541 pr_info("%s: pStats [%pK] pContext [%pK]\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,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003548 "%s: Bad param, pStats [%pK] pContext [%pK]",
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,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003568 "%s: Invalid context, pAdapter [%pK] 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 {
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003572 pr_info("%s: Invalid context, pAdapter [%pK] 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{
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303596 hdd_station_ctx_t *pHddStaCtx;
3597 hdd_ap_ctx_t *sap_ctx;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003598 eHalStatus hstatus;
3599 long lrc;
3600 struct statsContext context;
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303601 tANI_U8 sta_id;
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003602
3603 if (NULL == pAdapter)
3604 {
3605 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3606 return VOS_STATUS_SUCCESS;
3607 }
3608
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303609 if (pAdapter->device_mode == WLAN_HDD_SOFTAP) {
3610 sap_ctx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3611 sta_id = sap_ctx->uBCStaId;
3612 } else {
3613 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3614 sta_id = pHddStaCtx->conn_info.staId[0];
3615 }
3616
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003617 /* we are connected
3618 prepare our callback context */
3619 init_completion(&context.completion);
3620 context.pAdapter = pAdapter;
3621 context.magic = STATS_CONTEXT_MAGIC;
3622
3623 /* query only for Summary & Class A statistics */
3624 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3625 eCSR_HDD,
3626 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303627 SME_GLOBAL_CLASSA_STATS |
3628 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003629 hdd_get_station_statisticsCB,
3630 0, // not periodic
3631 FALSE, //non-cached results
Hanumanth Reddy Pothula9b2038f2017-08-03 16:37:42 +05303632 sta_id,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003633 &context);
3634 if (eHAL_STATUS_SUCCESS != hstatus)
3635 {
3636 hddLog(VOS_TRACE_LEVEL_ERROR,
3637 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003638 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003639 /* we'll return with cached values */
3640 }
3641 else
3642 {
3643 /* request was sent -- wait for the response */
3644 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3645 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003646
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003647 if (lrc <= 0)
3648 {
3649 hddLog(VOS_TRACE_LEVEL_ERROR,
3650 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003651 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003652 }
3653 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003654
3655 /* either we never sent a request, we sent a request and received a
3656 response or we sent a request and timed out. if we never sent a
3657 request or if we sent a request and got a response, we want to
3658 clear the magic out of paranoia. if we timed out there is a
3659 race condition such that the callback function could be
3660 executing at the same time we are. of primary concern is if the
3661 callback function had already verified the "magic" but had not
3662 yet set the completion variable when a timeout occurred. we
3663 serialize these activities by invalidating the magic while
3664 holding a shared spinlock which will cause us to block if the
3665 callback is currently executing */
3666 spin_lock(&hdd_context_lock);
3667 context.magic = 0;
3668 spin_unlock(&hdd_context_lock);
3669
3670 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003671 return VOS_STATUS_SUCCESS;
3672}
3673
3674
Jeff Johnson295189b2012-06-20 16:38:30 -07003675/*
3676 * Support for the LINKSPEED private command
3677 * Per the WiFi framework the response must be of the form
3678 * "LinkSpeed xx"
3679 */
3680static int iw_get_linkspeed(struct net_device *dev,
3681 struct iw_request_info *info,
3682 union iwreq_data *wrqu, char *extra)
3683{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303684 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303685 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303687 int len = sizeof(v_U32_t) + 1;
3688 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303689 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303690 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303691 int rc, valid = 0;
3692
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303693 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303694 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3695 if (NULL == pAdapter)
3696 {
3697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3698 "%s: Adapter is NULL",__func__);
3699 return -EINVAL;
3700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003701
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303702 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303703 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303704 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003705 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303706 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003707 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303708 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3709 if (NULL == pHddStaCtx)
3710 {
3711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3712 "%s: STA Context is NULL",__func__);
3713 return -EINVAL;
3714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3716 {
3717 /* we are not connected so we don't have a classAstats */
3718 link_speed = 0;
3719 }
3720 else
3721 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303722 status = wlan_hdd_get_classAstats(pAdapter);
3723
3724 if (!VOS_IS_STATUS_SUCCESS(status ))
3725 {
3726 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3727 return -EINVAL;
3728 }
3729
3730 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3731 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3732 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3733 &link_speed);
3734
3735 link_speed = link_speed / 10;
3736
3737 if (0 == link_speed)
3738 {
3739 /* The linkspeed returned by HAL is in units of 500kbps.
3740 * converting it to mbps.
3741 * This is required to support legacy firmware which does
3742 * not return link capacity.
3743 */
3744 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3745 }
3746
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 }
3748
3749 wrqu->data.length = len;
3750 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003751 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 if ((rc < 0) || (rc >= len))
3753 {
3754 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303755 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 return -EIO;
3757 }
3758
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303759 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003761 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003762}
3763
Arif Hussain695279c2014-03-24 14:06:07 -07003764/*
3765 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3766 *
3767 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303768static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003769 struct iw_request_info *info,
3770 union iwreq_data *wrqu, char *extra)
3771{
3772 int rc;
3773
3774 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3775
3776 if (rc < 0)
3777 return rc;
3778
3779 /* a value is being successfully returned */
3780 return 0;
3781}
Jeff Johnson295189b2012-06-20 16:38:30 -07003782
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303783static int iw_get_linkspeed_priv(struct net_device *dev,
3784 struct iw_request_info *info,
3785 union iwreq_data *wrqu, char *extra)
3786{
3787 int ret;
3788
3789 vos_ssr_protect(__func__);
3790 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3791 vos_ssr_unprotect(__func__);
3792
3793 return ret;
3794}
3795
Jeff Johnson295189b2012-06-20 16:38:30 -07003796/*
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303797 * Support for the RSSI & RSSI-APPROX private commands
3798 * Per the WiFi framework the response must be of the form
3799 * "<ssid> rssi <xx>"
3800 * unless we are not associated, in which case the response is
3801 * "OK"
3802 */
3803static int iw_get_rssi(struct net_device *dev,
3804 struct iw_request_info *info,
3805 union iwreq_data *wrqu, char *extra)
3806{
3807 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3808 char *cmd = extra;
3809 int len = wrqu->data.length;
3810 v_S7_t s7Rssi = 0;
3811 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3812 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3813 VOS_STATUS vosStatus;
3814 int rc;
3815
3816 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3817 (0 == ssidlen) || (ssidlen >= len))
3818 {
3819 /* we are not connected or our SSID is too long
3820 so we cannot report an rssi */
3821 rc = scnprintf(cmd, len, "OK");
3822 }
3823 else
3824 {
3825 /* we are connected with a valid SSID
3826 so we can write the SSID into the return buffer
3827 (note that it is not NUL-terminated) */
3828 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3829
Hanumanth Reddy Pothula01abc502016-08-30 15:34:43 +05303830 wlan_hdd_get_station_stats(pAdapter);
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05303831 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3832
3833 if (VOS_STATUS_SUCCESS == vosStatus)
3834 {
3835 /* append the rssi to the ssid in the format required by
3836 the WiFI Framework */
3837 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
3838 rc += ssidlen;
3839 }
3840 else
3841 {
3842 rc = -1;
3843 }
3844 }
3845
3846 /* verify that we wrote a valid response */
3847 if ((rc < 0) || (rc >= len))
3848 {
3849 // encoding or length error?
3850 hddLog(VOS_TRACE_LEVEL_ERROR,
3851 "%s: Unable to encode RSSI, got [%s]",
3852 __func__, cmd);
3853 return -EIO;
3854 }
3855
3856 /* a value is being successfully returned */
3857 return rc;
3858}
3859
3860/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 * Support for SoftAP channel range private command
3862 */
3863static int iw_softap_set_channel_range( struct net_device *dev,
3864 int startChannel,
3865 int endChannel,
3866 int band)
3867{
Jeff Johnson43971f52012-07-17 12:26:56 -07003868 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 int ret = 0;
3870 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3871 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003872 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3873
Jeff Johnson295189b2012-06-20 16:38:30 -07003874
3875 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3876 if (VOS_STATUS_SUCCESS != status)
3877 {
3878 ret = -EINVAL;
3879 }
Yathish9f22e662012-12-10 14:21:35 -08003880 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 return ret;
3882}
3883
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303884static uint8 chartohex(char c)
3885{
3886 uint8 val = 0;
3887 if (c >= '0' && c <= '9')
3888 val = c - '0';
3889 else if (c >= 'a' && c <= 'f')
3890 val = c - 'a' + 10;
3891 else if (c >= 'A' && c <= 'F')
3892 val = c - 'A' + 10;
3893 else
3894 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3895
3896 return val;
3897}
3898
3899uint8 getByte(char **buf)
3900{
3901 uint8 byte = 0;
3902 char *temp = *buf;
3903 byte = chartohex(*temp) * 16;
3904 temp++;
3905 byte += chartohex(*temp);
3906 temp++;
3907 *buf = temp;
3908 return byte;
3909}
3910
3911static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3912{
3913 tSir80211Header *macHeader;
3914 int i = 0, j = 0, length = 0;
3915 uint8 byte = 0;
3916 char *temp = pBuffer;
3917 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303918 char *pHeader;
3919 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303920
3921 macHeader = &pkt->macHeader;
3922
3923 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3924
3925 temp++;
3926
3927 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3928 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3929 pkt->encParams.keyParams.key[0].keyId);
3930
3931 for (i = 0; i< 16; i++) {
3932 pkt->encParams.keyParams.key[0].key[i]
3933 = getByte(&temp);
3934 }
3935
3936 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3937 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3938
3939 for (i = 0; i< 6; i++) {
3940 pkt->encParams.pn[i]
3941 = getByte(&temp);
3942 }
3943
3944 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3945 &pkt->encParams.pn[0], 6, 0);
3946
3947 for (i = 0, j= 5; i< 3; i++, j--) {
3948 byte = pkt->encParams.pn[i];
3949 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3950 pkt->encParams.pn[j] = byte;
3951 }
3952
3953 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303954 if (length > sizeof(tSir80211Header))
3955 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303956
Srinivas Dasari2382de62015-01-22 15:00:04 +05303957 pHeader = temp;
3958 vos_mem_zero(&header, sizeof(tSir80211Header));
3959 for (i = 0; i < length; i++) {
3960 *((uint8 *)&header + i) = getByte(&pHeader);
3961 }
3962
3963 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3964 (char *)&header, length, 0);
3965
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303966 byte = getByte(&temp);
3967
3968 macHeader->frameCtrl.protVer = byte & 0x3;
3969 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3970 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3971
3972 byte = getByte(&temp);
3973 macHeader->frameCtrl.toDS = (byte) & 0x1;
3974 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3975 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3976 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3977 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3978 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3979 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3980 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3981
3982 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3983 "macHeader->frameCtrl.type : %x "
3984 "macHeader->frameCtrl.subType : %x "
3985 "macHeader->frameCtrl.toDS : %x "
3986 "macHeader->frameCtrl.fromDS : %x "
3987 "macHeader->frameCtrl.moreFrag : %x "
3988 "macHeader->frameCtrl.retry : %x "
3989 "macHeader->frameCtrl.powerMgmt : %x "
3990 "macHeader->frameCtrl.MoreData : %x "
3991 "macHeader->frameCtrl.wep : %x "
3992 "macHeader->frameCtrl.order : %x "
3993 , macHeader->frameCtrl.protVer
3994 , macHeader->frameCtrl.type
3995 , macHeader->frameCtrl.subType
3996 , macHeader->frameCtrl.toDS
3997 , macHeader->frameCtrl.fromDS
3998 , macHeader->frameCtrl.moreFrag
3999 , macHeader->frameCtrl.retry
4000 , macHeader->frameCtrl.powerMgmt
4001 , macHeader->frameCtrl.moreData
4002 , macHeader->frameCtrl.wep
4003 , macHeader->frameCtrl.order);
4004
4005
4006 macHeader->usDurationId = getByte(&temp);
4007 macHeader->usDurationId += getByte(&temp) << 8;
4008
4009 macHeader->vA1[0] = getByte(&temp);
4010 macHeader->vA1[1] = getByte(&temp);
4011 macHeader->vA1[2] = getByte(&temp);
4012 macHeader->vA1[3] = getByte(&temp);
4013 macHeader->vA1[4] = getByte(&temp);
4014 macHeader->vA1[5] = getByte(&temp);
4015
4016 macHeader->vA2[0] = getByte(&temp);
4017 macHeader->vA2[1] = getByte(&temp);
4018 macHeader->vA2[2] = getByte(&temp);
4019 macHeader->vA2[3] = getByte(&temp);
4020 macHeader->vA2[4] = getByte(&temp);
4021 macHeader->vA2[5] = getByte(&temp);
4022
4023 macHeader->vA3[0] = getByte(&temp);
4024 macHeader->vA3[1] = getByte(&temp);
4025 macHeader->vA3[2] = getByte(&temp);
4026 macHeader->vA3[3] = getByte(&temp);
4027 macHeader->vA3[4] = getByte(&temp);
4028 macHeader->vA3[5] = getByte(&temp);
4029
4030 macHeader->sSeqCtrl = getByte(&temp);
4031 fragNum = macHeader->sSeqCtrl & 0xF;
4032 macHeader->sSeqCtrl >>= 4;
4033
4034 macHeader->sSeqCtrl += getByte(&temp) << 4;
4035
4036 macHeader->sSeqCtrl |= fragNum << 12;
4037
4038 if (length == 30 || length == 32) {
4039 macHeader->optvA4[0] = getByte(&temp);
4040 macHeader->optvA4[1] = getByte(&temp);
4041 macHeader->optvA4[2] = getByte(&temp);
4042 macHeader->optvA4[3] = getByte(&temp);
4043 macHeader->optvA4[4] = getByte(&temp);
4044 macHeader->optvA4[5] = getByte(&temp);
4045 }
4046
4047 if (length == 26 || length == 32) {
4048 macHeader->usQosCtrl = getByte(&temp);
4049 macHeader->usQosCtrl += getByte(&temp) << 8;
4050 }
4051
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304052 //parse payload
4053 length = getByte(&temp);
4054 length += getByte(&temp) << 8;
4055 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
4056
Manjeet Singh5830f142016-11-21 18:21:17 +05304057 if (length >= WLAN_DISA_MAX_PAYLOAD_SIZE)
4058 length = WLAN_DISA_MAX_PAYLOAD_SIZE;
4059
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05304060 pkt->data.length = length;
4061
4062 for (i = 0; i< length; i++) {
4063 pkt->data.data[i] = getByte(&temp);
4064 }
4065
4066 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
4067 &pkt->data.data[0], pkt->data.length, 0);
4068}
4069
4070/**---------------------------------------------------------------------------
4071
4072 \brief hdd_encrypt_msg_cb() - Callback function for DISA
4073 encrypt message request
4074 This is an asynchronous callback function from SME when the encrypted data
4075 is received
4076
4077 \pEncInfoRsp -> Encrypted data info
4078
4079 \return - 0 for success non-zero for failure
4080 --------------------------------------------------------------------------*/
4081static void
4082hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
4083{
4084 tpSetEncryptedDataRspParams pEncryptedDataRsp;
4085
4086 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
4087
4088 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
4089 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
4090 pEncryptedDataRsp->encryptedPayload.length);
4091 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
4092 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
4093 pEncryptedDataRsp->encryptedPayload.data,
4094 pEncryptedDataRsp->encryptedPayload.length, 0);
4095}
4096
Jeff Johnson295189b2012-06-20 16:38:30 -07004097VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
4098{
4099 struct statsContext context;
4100 eHalStatus status;
4101 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304102 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004103
4104 if (NULL == pAdapter)
4105 {
4106 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
4107 return VOS_STATUS_E_FAULT;
4108 }
4109
4110 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
4111 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05304112 if (pHddCtx->isLogpInProgress) {
4113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4114 "%s:LOGP in Progress. Ignore!!!", __func__);
4115 return VOS_STATUS_E_FAILURE;
4116 }
4117
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 init_completion(&context.completion);
4119
4120 context.pAdapter = pAdapter;
4121 context.magic = POWER_CONTEXT_MAGIC;
4122
4123 if (DRIVER_POWER_MODE_ACTIVE == mode)
4124 {
4125 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
4126 "Full Power", __func__);
4127 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4128 iw_power_callback_fn, &context,
4129 eSME_FULL_PWR_NEEDED_BY_HDD);
4130 // Enter Full power command received from GUI this means we are disconnected
4131 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
4132 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
4133 if (eHAL_STATUS_PMC_PENDING == status)
4134 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004135 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 int lrc = wait_for_completion_interruptible_timeout(
4137 &context.completion,
4138 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004139
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 if (lrc <= 0)
4141 {
4142 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004143 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 }
4145 }
4146 }
4147 else if (DRIVER_POWER_MODE_AUTO == mode)
4148 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304149 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
4150 * was already in BMPS state and thus either STA or P2P-CLI is in
4151 * associated state and authenticated, so even if STA connState is
4152 * not associated it can be assumed that P2P-CLI is associated and
4153 * authenticated. Thus driver can enter BMPS. And even if we try to enter
4154 * BMPS with no adaptor in associated state, pmcRequestBmps will check
4155 * if all condition are satisfied for entering BMPS.
4156 */
4157 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4158 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304159 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05304160 hddLog(LOGE,
4161 FL("Station is associated but, still not Authenticated ignore "
4162 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05304163 return VOS_STATUS_E_AGAIN;
4164 }
4165
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
4167 {
4168 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
4169 __func__);
4170 // Enter BMPS command received from GUI this means DHCP is completed
4171 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
4172 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4173 FALSE);
4174 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4175 iw_power_callback_fn, &context);
4176 if (eHAL_STATUS_PMC_PENDING == status)
4177 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004178 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 int lrc = wait_for_completion_interruptible_timeout(
4180 &context.completion,
4181 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 if (lrc <= 0)
4183 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004184 hddLog(VOS_TRACE_LEVEL_ERROR,
4185 "%s: SME %s while requesting BMPS",
4186 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 }
4188 }
4189 }
4190 else
4191 {
4192 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
4193 "enabled in the cfg");
4194 }
4195 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004196
4197 /* either we never sent a request, we sent a request and received a
4198 response or we sent a request and timed out. if we never sent a
4199 request or if we sent a request and got a response, we want to
4200 clear the magic out of paranoia. if we timed out there is a
4201 race condition such that the callback function could be
4202 executing at the same time we are. of primary concern is if the
4203 callback function had already verified the "magic" but had not
4204 yet set the completion variable when a timeout occurred. we
4205 serialize these activities by invalidating the magic while
4206 holding a shared spinlock which will cause us to block if the
4207 callback is currently executing */
4208 spin_lock(&hdd_context_lock);
4209 context.magic = 0;
4210 spin_unlock(&hdd_context_lock);
4211
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 return VOS_STATUS_SUCCESS;
4213}
4214
4215VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4216 hdd_adapter_t *pAdapter)
4217{
4218 VOS_STATUS vos_Status;
4219
4220 if ((NULL == pAdapter) || (NULL == pHddCtx))
4221 {
4222 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4223 return VOS_STATUS_E_FAULT;
4224 }
4225
4226 /**Exit from Deep sleep or standby if we get the driver
4227 START cmd from android GUI
4228 */
4229 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4230 {
4231 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4232 "from Stand by",__func__);
4233 vos_Status = hdd_exit_standby(pHddCtx);
4234 }
4235 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4236 {
4237 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4238 "from deep sleep",__func__);
4239 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4240 }
4241 else
4242 {
4243 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4244 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4245 vos_Status = VOS_STATUS_SUCCESS;
4246 }
4247
4248 return vos_Status;
4249}
4250
4251VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4252{
4253 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4254
4255 if (NULL == pHddCtx)
4256 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304257 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 return VOS_STATUS_E_FAULT;
4259 }
4260
4261 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4262 {
4263 //Execute standby procedure.
4264 //Executing standby procedure will cause the STA to
4265 //disassociate first and then the chip will be put into standby.
4266 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4267 vos_Status = hdd_enter_standby(pHddCtx);
4268 }
4269 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4270 pHddCtx->cfg_ini->nEnableDriverStop)
4271 {
4272 //Execute deep sleep procedure
4273 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004274 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 //Deep sleep not supported
4276 vos_Status = hdd_enter_standby(pHddCtx);
4277 }
4278 else
4279 {
4280 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4281 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4282 vos_Status = VOS_STATUS_SUCCESS;
4283 }
4284
4285 return vos_Status;
4286}
4287
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004288
4289void* wlan_hdd_change_country_code_callback(void *pAdapter)
4290{
4291
4292 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004293 complete(&call_back_pAdapter->change_country_code);
4294
4295 return NULL;
4296}
4297
SaidiReddy Yenugae2650932016-08-30 15:34:43 +05304298static int __iw_set_priv(struct net_device *dev,
4299 struct iw_request_info *info,
4300 union iwreq_data *wrqu, char *extra)
4301{
4302 hdd_adapter_t *pAdapter;
4303 char *cmd = NULL;
4304 int cmd_len = wrqu->data.length;
4305 int rc = 0, ret = 0;
4306 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4307
4308 hdd_context_t *pHddCtx;
4309
4310 ENTER();
4311
4312 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4313 if (NULL == pAdapter)
4314 {
4315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4316 "mem_alloc_copy_from_user_helper fail");
4317 return -EINVAL;
4318 }
4319 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4320 rc = wlan_hdd_validate_context(pHddCtx);
4321 if (0 != rc)
4322 {
4323 return rc;
4324 }
4325
4326 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4327 wrqu->data.length);
4328 if (NULL == cmd)
4329 {
4330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4331 "mem_alloc_copy_from_user_helper fail");
4332 return -ENOMEM;
4333 }
4334
4335 if (ioctl_debug)
4336 {
4337 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
4338 }
4339
4340 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4341 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
4342
4343 if (strncmp(cmd, "CSCAN", 5) == 0 )
4344 {
4345 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4347 "%s: Error in iw_set_scan!", __func__);
4348 rc = -EINVAL;
4349 }
4350 }
4351 else if( strcasecmp(cmd, "start") == 0 ) {
4352
4353 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
4354 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
4355
4356 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4357 if (vos_status == VOS_STATUS_SUCCESS)
4358 {
4359 union iwreq_data wrqu;
4360 char buf[10];
4361
4362 memset(&wrqu, 0, sizeof(wrqu));
4363 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4364 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4365 }
4366 else
4367 {
4368 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4369 rc = -EIO;
4370 }
4371 goto done;
4372 }
4373 else if( strcasecmp(cmd, "stop") == 0 )
4374 {
4375 union iwreq_data wrqu;
4376 char buf[10];
4377
4378 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
4379
4380 wlan_hdd_enter_lowpower(pHddCtx);
4381 memset(&wrqu, 0, sizeof(wrqu));
4382 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4383 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4384 goto done;
4385 }
4386 else if (strcasecmp(cmd, "macaddr") == 0)
4387 {
4388 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4389 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4390 }
4391 else if (strcasecmp(cmd, "scan-active") == 0)
4392 {
4393 hddLog(LOG1,
4394 FL("making default scan to active"));
4395 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
4396 ret = snprintf(cmd, cmd_len, "OK");
4397 }
4398 else if (strcasecmp(cmd, "scan-passive") == 0)
4399 {
4400 hddLog(LOG1,
4401 FL("making default scan to passive"));
4402 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
4403 ret = snprintf(cmd, cmd_len, "OK");
4404 }
4405 else if( strcasecmp(cmd, "scan-mode") == 0 )
4406 {
4407 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
4408 }
4409 else if( strcasecmp(cmd, "linkspeed") == 0 )
4410 {
4411 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
4412 }
4413 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4414 {
4415 ret = iw_get_rssi(dev, info, wrqu, cmd);
4416 }
4417 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4418 int mode;
4419 char *ptr;
4420
4421 if (9 < cmd_len)
4422 {
4423 ptr = (char*)(cmd + 9);
4424
4425 }else{
4426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4427 "CMD LENGTH %d is not correct",cmd_len);
4428 kfree(cmd);
4429 return -EINVAL;
4430 }
4431
4432 if (1 != sscanf(ptr,"%d",&mode))
4433 {
4434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4435 "powermode input %s is not correct",ptr);
4436 kfree(cmd);
4437 return -EIO;
4438 }
4439
4440 wlan_hdd_enter_bmps(pAdapter, mode);
4441 /*TODO:Set the power mode*/
4442 }
4443 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4444 v_U32_t pmc_state;
4445 v_U16_t value;
4446
4447 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4448 if(pmc_state == BMPS) {
4449 value = DRIVER_POWER_MODE_AUTO;
4450 }
4451 else {
4452 value = DRIVER_POWER_MODE_ACTIVE;
4453 }
4454 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4455 }
4456 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
4457 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
4458 /*TODO: set the btcoexmode*/
4459 }
4460 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4461
4462 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
4463 /*TODO: Return the btcoex status*/
4464 }
4465 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4466
4467 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
4468
4469 /*TODO: Enable Rx data Filter*/
4470 }
4471 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4472
4473 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
4474
4475 /*TODO: Disable Rx data Filter*/
4476 }
4477 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4478
4479 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
4480 /*TODO: rxfilter-statistics*/
4481 }
4482 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4483
4484 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
4485 /*TODO: rxfilter-add*/
4486 }
4487 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4488
4489 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
4490 /*TODO: rxfilter-remove*/
4491 }
4492#ifdef FEATURE_WLAN_SCAN_PNO
4493 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4494 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4495 /*TODO: support pnosetup*/
4496 }
4497 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4498 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4499 /*TODO: support pnoforce*/
4500 }
4501 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4502
4503 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
4504 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4505 kfree(cmd);
4506 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4507 }
4508 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
4509 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
4510 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4511 kfree(cmd);
4512 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4513 }
4514#endif /*FEATURE_WLAN_SCAN_PNO*/
4515 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
4516 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
4517 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4518 kfree(cmd);
4519 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
4520 }
4521 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4522 tSirTxPerTrackingParam tTxPerTrackingParam;
4523 char *ptr;
4524
4525 if (18 < cmd_len)
4526 {
4527 ptr = (char*)(cmd + 18);
4528 }else{
4529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4530 "CMD LENGTH %d is not correct",cmd_len);
4531 kfree(cmd);
4532 return -EINVAL;
4533 }
4534
4535 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
4536 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4537 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4538 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4539 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4540 {
4541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4542 "CONFIG-TX-TRACKING %s input is not correct",ptr);
4543 kfree(cmd);
4544 return -EIO;
4545 }
4546
4547 // parameters checking
4548 // period has to be larger than 0
4549 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4550 {
4551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
4552 kfree(cmd);
4553 return -EIO;
4554 }
4555
4556 // use default value 5 is the input is not reasonable. in unit of 10%
4557 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4558 {
4559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4560 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4561 }
4562
4563 // default is 5
4564 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4565 {
4566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4567 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4568 }
4569
4570 if (eHAL_STATUS_SUCCESS !=
4571 sme_SetTxPerTracking(pHddCtx->hHal,
4572 hdd_tx_per_hit_cb,
4573 (void*)pAdapter, &tTxPerTrackingParam)) {
4574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
4575 rc = -EIO;
4576 }
4577 }
4578 else {
4579 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4580 __func__, cmd);
4581 }
4582done:
4583 /* many of the commands write information back into the command
4584 string using snprintf(). check the return value here in one
4585 place */
4586 if ((ret < 0) || (ret >= cmd_len))
4587 {
4588 /* there was an encoding error or overflow */
4589 rc = -EINVAL;
4590 }
4591 else if (ret > 0)
4592 {
4593 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4594 {
4595 hddLog(VOS_TRACE_LEVEL_ERROR,
4596 "%s: failed to copy data to user buffer", __func__);
4597 kfree(cmd);
4598 return -EFAULT;
4599 }
4600 wrqu->data.length = ret;
4601 }
4602
4603 if (ioctl_debug)
4604 {
4605 pr_info("%s: rsp [%s] len [%d] status %d\n",
4606 __func__, cmd, wrqu->data.length, rc);
4607 }
4608 kfree(cmd);
4609 EXIT();
4610 return rc;
4611}
4612
4613static int iw_set_priv(struct net_device *dev,
4614 struct iw_request_info *info,
4615 union iwreq_data *wrqu, char *extra)
4616{
4617 int ret;
4618 vos_ssr_protect(__func__);
4619 ret = __iw_set_priv(dev, info, wrqu, extra);
4620 vos_ssr_unprotect(__func__);
4621
4622 return ret;
4623}
4624
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304625static int __iw_set_nick(struct net_device *dev,
4626 struct iw_request_info *info,
4627 union iwreq_data *wrqu, char *extra)
4628{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304629 hdd_adapter_t *pAdapter;
4630 hdd_context_t *pHddCtx;
4631 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304632
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304633 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304634
4635 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4636 if (NULL == pAdapter)
4637 {
4638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4639 "%s: Adapter is NULL",__func__);
4640 return -EINVAL;
4641 }
4642
4643 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4644 ret = wlan_hdd_validate_context(pHddCtx);
4645 if (0 != ret)
4646 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304647 return ret;
4648 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304649 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304650 return 0;
4651}
4652
Jeff Johnson295189b2012-06-20 16:38:30 -07004653static int iw_set_nick(struct net_device *dev,
4654 struct iw_request_info *info,
4655 union iwreq_data *wrqu, char *extra)
4656{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304657 int ret;
4658
4659 vos_ssr_protect(__func__);
4660 ret = __iw_set_nick(dev, info, wrqu, extra);
4661 vos_ssr_unprotect(__func__);
4662
4663 return ret;
4664}
4665
4666static int __iw_get_nick(struct net_device *dev,
4667 struct iw_request_info *info,
4668 union iwreq_data *wrqu, char *extra)
4669{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304670 hdd_adapter_t *pAdapter;
4671 hdd_context_t *pHddCtx;
4672 int ret = 0;
4673
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304675
4676 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4677 if (NULL == pAdapter)
4678 {
4679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4680 "%s: Adapter is NULL",__func__);
4681 return -EINVAL;
4682 }
4683
4684 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4685 ret = wlan_hdd_validate_context(pHddCtx);
4686 if (0 != ret)
4687 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304688 return ret;
4689 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304690 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 return 0;
4692}
4693
4694static int iw_get_nick(struct net_device *dev,
4695 struct iw_request_info *info,
4696 union iwreq_data *wrqu, char *extra)
4697{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304698 int ret;
4699
4700 vos_ssr_protect(__func__);
4701 ret = __iw_get_nick(dev, info, wrqu, extra);
4702 vos_ssr_unprotect(__func__);
4703
4704 return ret;
4705}
4706
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304707/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304708static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4709{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304710 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4711 hdd_context_t *pHddCtx;
4712 hdd_station_ctx_t *pHddStaCtx;
4713 v_S7_t snr = 0, rssi = 0;
4714 eHalStatus status = eHAL_STATUS_SUCCESS;
4715
4716 ENTER();
4717
4718 if (NULL == pAdapter)
4719 {
4720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4721 "%s: Adapter is NULL",__func__);
4722 return NULL;
4723 }
4724
4725 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4726 status = wlan_hdd_validate_context(pHddCtx);
4727 if (0 != status)
4728 {
4729 return NULL;
4730 }
4731
4732 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4733 if (NULL == pHddStaCtx)
4734 {
4735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4736 "%s: STA Context is NULL",__func__);
4737 return NULL;
4738 }
4739
4740 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4741 {
4742 wlan_hdd_get_station_stats(pAdapter);
4743 wlan_hdd_get_snr(pAdapter, &snr);
4744 wlan_hdd_get_rssi(pAdapter, &rssi);
4745
4746 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4747 pAdapter->iwStats.status = 0;
4748 pAdapter->iwStats.qual.qual = snr;
4749 pAdapter->iwStats.qual.level = rssi;
4750 pAdapter->iwStats.qual.noise = rssi - snr;
4751 pAdapter->iwStats.discard.code = 0;
4752 pAdapter->iwStats.discard.retries= 0;
4753 pAdapter->iwStats.miss.beacon = 0;
4754 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4755 }
4756 else
4757 {
4758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4759 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4760 return NULL;
4761 }
4762
4763 EXIT();
4764 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004765}
4766
4767static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4768{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304769
4770 struct iw_statistics *stats;
4771
4772 vos_ssr_protect(__func__);
4773 stats = __get_wireless_stats(dev);
4774 vos_ssr_unprotect(__func__);
4775
4776 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004777}
4778
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304779static int __iw_set_encode(struct net_device *dev,
4780 struct iw_request_info *info,
4781 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004782
4783{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304784 hdd_adapter_t *pAdapter;
4785 hdd_station_ctx_t *pHddStaCtx;
4786 hdd_wext_state_t *pWextState;
4787 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 struct iw_point *encoderq = &(wrqu->encoding);
4789 v_U32_t keyId;
4790 v_U8_t key_length;
4791 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4792 v_BOOL_t fKeyPresent = 0;
4793 int i;
4794 eHalStatus status = eHAL_STATUS_SUCCESS;
4795
4796
4797 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304798 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4799 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4802 "%s: Adapter is NULL",__func__);
4803 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 }
4805
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304806 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4807 status = wlan_hdd_validate_context(pHddCtx);
4808 if (0 != status)
4809 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304810 return status;
4811 }
4812 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4813 if (NULL == pWextState)
4814 {
4815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4816 "%s: pWextState is NULL ",__func__);
4817 return -EINVAL;
4818 }
4819 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4820 if (NULL == pHddStaCtx)
4821 {
4822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4823 "%s: STA Context is NULL",__func__);
4824 return -EINVAL;
4825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004826
4827 keyId = encoderq->flags & IW_ENCODE_INDEX;
4828
4829 if(keyId)
4830 {
4831 if(keyId > MAX_WEP_KEYS)
4832 {
4833 return -EINVAL;
4834 }
4835
4836 fKeyPresent = 1;
4837 keyId--;
4838 }
4839 else
4840 {
4841 fKeyPresent = 0;
4842 }
4843
4844
4845 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4846 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 if(!fKeyPresent) {
4849
4850 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4851
4852 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4853 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4854 }
4855 }
4856 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4857 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4858 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4859 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4860
4861 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4862 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4863
4864 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4865 {
4866 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4867 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004868 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304869 {
4870 long ret;
4871 ret = wait_for_completion_interruptible_timeout(
4872 &pAdapter->disconnect_comp_var,
4873 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4874 if (ret <= 0)
4875 hddLog(VOS_TRACE_LEVEL_ERROR,
4876 FL("failed wait on disconnect_comp_var %ld"), ret);
4877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 }
4879
4880 return status;
4881
4882 }
4883
4884 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4885 {
4886 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4887
4888 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4889
4890 }
4891
4892
4893 if(wrqu->data.length > 0)
4894 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004895 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004896
4897 key_length = wrqu->data.length;
4898
4899 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4900
4901 if(5 == key_length)
4902 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004903 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904
4905 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4906 {
4907 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4908 }
4909 else
4910 {
4911 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4912 }
4913 }
4914 else if(13 == key_length)
4915 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004916 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004917
4918 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4919 {
4920 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4921 }
4922 else
4923 {
4924 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4925 }
4926 }
4927 else
4928 {
4929 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004930 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 return -EINVAL;
4932 }
4933
4934 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4935 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4936 pWextState->roamProfile.EncryptionType.numEntries = 1;
4937 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4938 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4939 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4940
4941 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4942 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4943 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4944 {
4945
4946 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4947
4948 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4949 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4950
4951 return status;
4952 }
4953 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304954 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 return 0;
4956}
4957
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304958static int iw_set_encode(struct net_device *dev,
4959 struct iw_request_info *info,
4960 union iwreq_data *wrqu,char *extra)
4961{
4962 int ret;
4963
4964 vos_ssr_protect(__func__);
4965 ret = __iw_set_encode(dev, info, wrqu, extra);
4966 vos_ssr_unprotect(__func__);
4967
4968 return ret;
4969}
4970
4971static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 struct iw_request_info *info,
4973 struct iw_point *dwrq,
4974 char *extra)
4975{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304976 hdd_adapter_t *pAdapter;
4977 hdd_wext_state_t *pWextState;
4978 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 int keyId;
4980 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4981 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304982 int i, ret = 0;
4983 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004984
4985 ENTER();
4986
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304987 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4988 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004989 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4991 "%s: Adapter is NULL",__func__);
4992 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004993 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304994 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4995 ret = wlan_hdd_validate_context(pHddCtx);
4996 if (0 != ret)
4997 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304998 return ret;
4999 }
5000 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5001 if (NULL == pWextState)
5002 {
5003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5004 "%s: pWextState is NULL",__func__);
5005 return -EINVAL;
5006 }
5007 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005008
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 keyId = pRoamProfile->Keys.defaultIndex;
5010
5011 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
5012 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005013 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 return -EINVAL;
5015 }
5016
5017 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
5018 {
5019 dwrq->flags |= IW_ENCODE_ENABLED;
5020 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05305021 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
5022 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 }
5024 else
5025 {
5026 dwrq->flags |= IW_ENCODE_DISABLED;
5027 }
5028
5029 for(i=0; i < MAX_WEP_KEYS; i++)
5030 {
5031 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
5032 {
5033 continue;
5034 }
5035 else
5036 {
5037 break;
5038 }
5039 }
5040
5041 if(MAX_WEP_KEYS == i)
5042 {
5043 dwrq->flags |= IW_ENCODE_NOKEY;
5044 }
5045 else
5046 {
5047 dwrq->flags |= IW_ENCODE_ENABLED;
5048 }
5049
5050 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
5051
5052 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
5053 {
5054 dwrq->flags |= IW_ENCODE_DISABLED;
5055 }
5056
5057 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
5058
5059 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
5060 {
5061 dwrq->flags |= IW_ENCODE_OPEN;
5062 }
5063 else
5064 {
5065 dwrq->flags |= IW_ENCODE_RESTRICTED;
5066 }
5067 EXIT();
5068 return 0;
5069
5070}
5071
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305072static int iw_get_encodeext(struct net_device *dev,
5073 struct iw_request_info *info,
5074 struct iw_point *dwrq,
5075 char *extra)
5076{
5077 int ret;
5078 vos_ssr_protect(__func__);
5079 ret = __iw_get_encodeext(dev, info, dwrq, extra);
5080 vos_ssr_unprotect(__func__);
5081
5082 return ret;
5083}
5084
5085static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 struct iw_request_info *info,
5087 union iwreq_data *wrqu, char *extra)
5088{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305089 hdd_adapter_t *pAdapter;
5090 hdd_station_ctx_t *pHddStaCtx;
5091 hdd_wext_state_t *pWextState;
5092 hdd_context_t *pHddCtx;
5093 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005094
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305095 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 v_U32_t status = 0;
5097
5098 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
5099
5100 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5101
5102 int key_index;
5103 struct iw_point *encoding = &wrqu->encoding;
5104 tCsrRoamSetKey setKey;
5105 v_U32_t roamId= 0xFF;
5106 VOS_STATUS vos_status;
5107
5108 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305109 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5110 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005111 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5113 "%s: Adapter is NULL",__func__);
5114 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305116 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5117 status = wlan_hdd_validate_context(pHddCtx);
5118 if (0 != status)
5119 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305120 return status;
5121 }
5122 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5123 if (NULL == pHddStaCtx)
5124 {
5125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5126 "%s: STA Context is NULL",__func__);
5127 return -EINVAL;
5128 }
5129 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5130 if (NULL == pWextState)
5131 {
5132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5133 "%s: pWextState is NULL",__func__);
5134 return -EINVAL;
5135 }
5136 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 key_index = encoding->flags & IW_ENCODE_INDEX;
5138
5139 if(key_index > 0) {
5140
5141 /*Convert from 1-based to 0-based keying*/
5142 key_index--;
5143 }
5144 if(!ext->key_len) {
5145
5146 /*Set the encrytion type to NONE*/
5147 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5148 return status;
5149 }
5150
5151 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
5152 (IW_ENCODE_ALG_WEP == ext->alg))
5153 {
5154 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
5155
Agarwal Ashish971c2882013-10-30 20:11:12 +05305156 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5157 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 return -EINVAL;
5159 }
5160 else {
5161 /*Static wep, update the roam profile with the keys */
5162 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
5163 key_index < CSR_MAX_NUM_KEY) {
5164 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
5165 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
5166
5167 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
5168 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
5169
5170 }
5171 }
5172 return status;
5173 }
5174
5175 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5176
5177 setKey.keyId = key_index;
5178 setKey.keyLength = ext->key_len;
5179
5180 if(ext->key_len <= CSR_MAX_KEY_LEN) {
5181 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
5182 }
5183
5184 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5185 /*Key direction for group is RX only*/
5186 setKey.keyDirection = eSIR_RX_ONLY;
5187 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5188 }
5189 else {
5190
5191 setKey.keyDirection = eSIR_TX_RX;
5192 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
5193 }
5194
5195 /*For supplicant pae role is zero*/
5196 setKey.paeRole = 0;
5197
5198 switch(ext->alg)
5199 {
5200 case IW_ENCODE_ALG_NONE:
5201 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5202 break;
5203
5204 case IW_ENCODE_ALG_WEP:
5205 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5206 break;
5207
5208 case IW_ENCODE_ALG_TKIP:
5209 {
5210 v_U8_t *pKey = &setKey.Key[0];
5211
5212 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5213
5214 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5215
5216 /*Supplicant sends the 32bytes key in this order
5217
5218 |--------------|----------|----------|
5219 | Tk1 |TX-MIC | RX Mic |
5220 |--------------|----------|----------|
5221 <---16bytes---><--8bytes--><--8bytes-->
5222
5223 */
5224 /*Sme expects the 32 bytes key to be in the below order
5225
5226 |--------------|----------|----------|
5227 | Tk1 |RX-MIC | TX Mic |
5228 |--------------|----------|----------|
5229 <---16bytes---><--8bytes--><--8bytes-->
5230 */
5231 /* Copy the Temporal Key 1 (TK1) */
5232 vos_mem_copy(pKey,ext->key,16);
5233
5234 /*Copy the rx mic first*/
5235 vos_mem_copy(&pKey[16],&ext->key[24],8);
5236
5237 /*Copy the tx mic */
5238 vos_mem_copy(&pKey[24],&ext->key[16],8);
5239
5240 }
5241 break;
5242
5243 case IW_ENCODE_ALG_CCMP:
5244 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5245 break;
5246
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005247#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005248#define IW_ENCODE_ALG_KRK 6
5249 case IW_ENCODE_ALG_KRK:
5250 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5251 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005252#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005253
5254 default:
5255 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5256 break;
5257 }
5258
5259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005260 ("%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 -07005261
5262#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305263 /* The supplicant may attempt to set the PTK once pre-authentication
5264 is done. Save the key in the UMAC and include it in the ADD
5265 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305267 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305269 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5270 "%s: Update PreAuth Key success", __func__);
5271 return 0;
5272 }
5273 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5274 {
5275 hddLog(VOS_TRACE_LEVEL_ERROR,
5276 "%s: Update PreAuth Key failed", __func__);
5277 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 }
5279#endif /* WLAN_FEATURE_VOWIFI_11R */
5280
5281 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5282
5283 vos_status = wlan_hdd_check_ula_done(pAdapter);
5284 if ( vos_status != VOS_STATUS_SUCCESS )
5285 {
5286 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5287 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5288 __LINE__, vos_status );
5289
5290 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5291 }
5292
5293 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5294
5295 if ( halStatus != eHAL_STATUS_SUCCESS )
5296 {
5297 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5298 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5299 __LINE__, halStatus );
5300
5301 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5302 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305303 EXIT();
5304 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005305}
5306
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305307static int iw_set_encodeext(struct net_device *dev,
5308 struct iw_request_info *info,
5309 union iwreq_data *wrqu, char *extra)
5310{
5311 int ret;
5312
5313 vos_ssr_protect(__func__);
5314 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5315 vos_ssr_unprotect(__func__);
5316
5317 return ret;
5318}
5319
5320static int __iw_set_retry(struct net_device *dev,
5321 struct iw_request_info *info,
5322 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005323{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305324 hdd_adapter_t *pAdapter;
5325 tHalHandle hHal;
5326 hdd_context_t *pHddCtx;
5327 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005328
5329 ENTER();
5330
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305331 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5332 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005333 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5335 "%s: Adapter is NULL",__func__);
5336 return -EINVAL;
5337 }
5338
5339 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5340 ret = wlan_hdd_validate_context(pHddCtx);
5341 if (0 != ret)
5342 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305343 return ret;
5344 }
5345
5346 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5347 if (NULL == hHal)
5348 {
5349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5350 "%s: Hal Context is NULL",__func__);
5351 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005352 }
5353
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5355 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5356
Arif Hussain6d2a3322013-11-17 19:50:10 -08005357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005358
5359 return -EINVAL;
5360 }
5361
5362 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5363
5364 if((wrqu->retry.flags & IW_RETRY_LONG))
5365 {
5366 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5367 {
c_hpothub8245442013-11-20 23:41:09 +05305368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5369 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 return -EIO;
5371 }
5372 }
5373 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5374 {
5375 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5376 {
c_hpothub8245442013-11-20 23:41:09 +05305377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5378 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 return -EIO;
5380 }
5381 }
5382 }
5383 else
5384 {
5385 return -EOPNOTSUPP;
5386 }
5387
Arif Hussain6d2a3322013-11-17 19:50:10 -08005388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005389
5390 EXIT();
5391
5392 return 0;
5393
5394}
5395
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305396static int iw_set_retry(struct net_device *dev,
5397 struct iw_request_info *info,
5398 union iwreq_data *wrqu, char *extra)
5399{
5400 int ret;
5401
5402 vos_ssr_protect(__func__);
5403 ret = __iw_set_retry(dev, info, wrqu, extra);
5404 vos_ssr_unprotect(__func__);
5405
5406 return ret;
5407}
5408
5409static int __iw_get_retry(struct net_device *dev,
5410 struct iw_request_info *info,
5411 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005412{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305413 hdd_adapter_t *pAdapter;
5414 hdd_context_t *pHddCtx;
5415 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305417 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005418
5419 ENTER();
5420
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305421 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5422 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005423 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5425 "%s: Adapter is NULL",__func__);
5426 return -EINVAL;
5427 }
5428
5429 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5430 ret = wlan_hdd_validate_context(pHddCtx);
5431 if (0 != ret)
5432 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305433 return ret;
5434 }
5435
5436 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5437 if (NULL == hHal)
5438 {
5439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5440 "%s: Hal Context is NULL",__func__);
5441 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005442 }
5443
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 if((wrqu->retry.flags & IW_RETRY_LONG))
5445 {
5446 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5447
5448 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5449 {
c_hpothub8245442013-11-20 23:41:09 +05305450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5451 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 return -EIO;
5453 }
5454
5455 wrqu->retry.value = retry;
5456 }
5457 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5458 {
5459 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5460
5461 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5462 {
c_hpothub8245442013-11-20 23:41:09 +05305463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5464 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 return -EIO;
5466 }
5467
5468 wrqu->retry.value = retry;
5469 }
5470 else {
5471 return -EOPNOTSUPP;
5472 }
5473
Arif Hussain6d2a3322013-11-17 19:50:10 -08005474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005475
5476 EXIT();
5477
5478 return 0;
5479}
5480
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305481static int iw_get_retry(struct net_device *dev,
5482 struct iw_request_info *info,
5483 union iwreq_data *wrqu, char *extra)
5484{
5485 int ret;
5486
5487 vos_ssr_protect(__func__);
5488 ret = __iw_get_retry(dev, info, wrqu, extra);
5489 vos_ssr_unprotect(__func__);
5490
5491 return ret;
5492}
5493
5494static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 struct iw_request_info *info,
5496 union iwreq_data *wrqu,
5497 char *extra)
5498{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305499 hdd_adapter_t *pAdapter;
5500 hdd_context_t *pHddCtx;
5501 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5503 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305504 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005505
5506 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305507 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5508 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5511 "%s:Adapter is NULL",__func__);
5512 return -EINVAL;
5513 }
5514 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5515 ret = wlan_hdd_validate_context(pHddCtx);
5516 if (0 != ret)
5517 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305518 return ret;
5519 }
5520 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5521 if (NULL == pHddStaCtx)
5522 {
5523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5524 "%s:STA context is NULL",__func__);
5525 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 }
5527
5528 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5529 switch (mlme->cmd) {
5530 case IW_MLME_DISASSOC:
5531 case IW_MLME_DEAUTH:
5532
5533 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5534 {
5535 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5536
5537 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5538 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5539
5540 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5541 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5542
Jeff Johnson43971f52012-07-17 12:26:56 -07005543 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305544 {
5545 long ret;
5546 ret = wait_for_completion_interruptible_timeout(
5547 &pAdapter->disconnect_comp_var,
5548 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5549 if (ret <= 0)
5550 hddLog(VOS_TRACE_LEVEL_ERROR,
5551 FL("failed wait on disconnect_comp_var %ld"), ret);
5552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005554 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005555 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005556
5557 /* Resetting authKeyMgmt */
5558 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5559
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305560 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 netif_tx_disable(dev);
5562 netif_carrier_off(dev);
5563
5564 }
5565 else
5566 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005567 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 -07005568 }
5569 break;
5570 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005571 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 return -EINVAL;
5573 }//end of switch
5574
5575 EXIT();
5576
5577 return status;
5578
5579}
5580
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305581static int iw_set_mlme(struct net_device *dev,
5582 struct iw_request_info *info,
5583 union iwreq_data *wrqu,
5584 char *extra)
5585{
5586 int ret;
5587
5588 vos_ssr_protect(__func__);
5589 ret = __iw_set_mlme(dev, info, wrqu, extra);
5590 vos_ssr_unprotect(__func__);
5591
5592 return ret;
5593}
5594
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305595int wlan_hdd_set_proximity(int set_value, tHalHandle hal)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305596{
5597 sHwCalValues hwCalValues;
5598 uint16 hwCalTxPower;
5599 uint8 txPwr = TX_PWR_DEF;
5600
5601 hddLog(LOG1, FL("WE_SET_PROXIMITY_ENABLE: %d"), set_value);
5602
5603 if (TRUE == set_value) {
5604 if(vos_nv_read( VNV_HW_CAL_VALUES, &hwCalValues,
5605 NULL, sizeof(sHwCalValues) )
5606 != VOS_STATUS_SUCCESS) {
5607 return -EINVAL;
5608 }
5609 hwCalTxPower = (uint16)(hwCalValues.calData.hwParam7 >> 16);
5610
5611 hddLog(LOG1, FL("hwCalTxPower:%x nv_data:%x"),
5612 hwCalTxPower, hwCalValues.calData.hwParam7);
5613
5614 txPwr = (int8)(hwCalTxPower & 0x00FF);
5615 txPwr = txPwr/10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305616 if (txPwr == 0)
5617 txPwr = TX_PWR_DEF;
5618 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305619 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305620 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305621 txPwr = TX_PWR_MAX;
5622
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305623 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305624 eHAL_STATUS_SUCCESS) {
5625 hddLog(VOS_TRACE_LEVEL_ERROR,
5626 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5627 return -EIO;
5628 }
5629
5630 txPwr = (int8)((hwCalTxPower >> 8) & 0x00FF);
5631 txPwr /= 10;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305632 if (txPwr == 0)
5633 txPwr = TX_PWR_DEF;
5634 else if (txPwr < TX_PWR_MIN)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305635 txPwr = TX_PWR_MIN;
Hanumanth Reddy Pothula82c02ab2017-01-31 16:29:53 +05305636 else if (txPwr > TX_PWR_MAX)
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305637 txPwr = TX_PWR_MAX;
5638
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305639 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305640 eHAL_STATUS_SUCCESS) {
5641 hddLog(VOS_TRACE_LEVEL_ERROR,
5642 FL("setting tx power failed for 5GHz band %d"), txPwr);
5643 return -EIO;
5644 }
5645 }
5646 else if(FALSE == set_value) {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305647 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305648 eHAL_STATUS_SUCCESS) {
5649 hddLog(VOS_TRACE_LEVEL_ERROR,
5650 FL("Setting tx power failed for 2.4GHz band %d"), txPwr);
5651 return -EIO;
5652 }
5653
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05305654 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, txPwr, hal) !=
Hanumantha Reddy Pothula166676a2016-01-08 15:39:47 +05305655 eHAL_STATUS_SUCCESS) {
5656 hddLog(VOS_TRACE_LEVEL_ERROR,
5657 FL("setting tx power failed for 5GHz band %d"), txPwr);
5658 return -EIO;
5659 }
5660 }
5661 else {
5662 return -EINVAL;
5663 }
5664
5665 return eHAL_STATUS_SUCCESS;
5666}
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05305667
5668static int hdd_set_dynamic_aggregation(int value, hdd_adapter_t *adapter)
5669{
5670 int ret = 0;
5671 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5672 tDelBaParams del_session;
5673
5674 del_session.session_id = adapter->sessionId;
5675 hddLog(LOG1, FL("WLAN_SET_DYNNAMIC_AGGREGATION: %d"), value);
5676
5677 if ((value == DISABLE_AGGREGATION) || (value == ENABLE_AGGREGATION))
5678 {
5679 ret = ccmCfgSetInt(hal, WNI_CFG_ENABLE_TX_RX_AGGREGATION,
5680 value,NULL, eANI_BOOLEAN_FALSE);
5681 if (ret != eHAL_STATUS_SUCCESS)
5682 {
5683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5684 FL("failed to set ini parameter, WNI_CFG_ENABLE_TX_RX_AGGREGATION"));
5685 return -EIO;
5686 }
5687
5688 } else {
5689 hddLog(VOS_TRACE_LEVEL_ERROR,
5690 FL("Invalid command input"));
5691 return -EINVAL;
5692 }
5693 ret = sme_del_sta_ba_session_req(hal, del_session);
5694 if (ret != VOS_STATUS_SUCCESS) {
5695 hddLog(VOS_TRACE_LEVEL_ERROR, FL("send ba session req fail"));
5696 return -EINVAL;
5697 }
5698
5699 EXIT();
5700 return ret;
5701}
5702
Jeff Johnson295189b2012-06-20 16:38:30 -07005703/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305704static int __iw_setint_getnone(struct net_device *dev,
5705 struct iw_request_info *info,
5706 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005707{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305708 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305709 tHalHandle hHal = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305710 hdd_wext_state_t *pWextState;
5711 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305712 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 int *value = (int *)extra;
5714 int sub_cmd = value[0];
5715 int set_value = value[1];
5716 int ret = 0; /* success */
5717 int enable_pbm, enable_mp;
5718#ifdef CONFIG_HAS_EARLYSUSPEND
5719 v_U8_t nEnableSuspendOld;
5720#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005721
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305722 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305723 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5724 if (NULL == pAdapter)
5725 {
5726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5727 "%s: Adapter is NULL",__func__);
5728 return -EINVAL;
5729 }
5730 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5731 ret = wlan_hdd_validate_context(pHddCtx);
5732 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005733 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305734 return ret;
5735 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305736
Katya Nigameae74b62015-05-28 17:19:16 +05305737 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305738 {
Sravan Kumar Kairam57ea7b12015-12-07 12:09:35 +05305739 /* In monitor mode hHal is NULL */
5740 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5741 if (NULL == hHal)
5742 {
5743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5744 "%s: Hal Context is NULL",__func__);
5745 return -EINVAL;
5746 }
Katya Nigameae74b62015-05-28 17:19:16 +05305747 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5748 if (NULL == pWextState)
5749 {
5750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5751 "%s: pWextState is NULL",__func__);
5752 return -EINVAL;
5753 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005754
Katya Nigameae74b62015-05-28 17:19:16 +05305755 INIT_COMPLETION(pWextState->completion_var);
5756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 switch(sub_cmd)
5758 {
5759 case WE_SET_11D_STATE:
5760 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005761 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005762 memset(&smeConfig, 0x00, sizeof(smeConfig));
5763
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305764 if(((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) &&
5765 (hHal)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 sme_GetConfigParam(hHal,&smeConfig);
5767 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5768
Arif Hussain6d2a3322013-11-17 19:50:10 -08005769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005770
5771 sme_UpdateConfig(hHal,&smeConfig);
5772 }
5773 else {
5774 return -EINVAL;
5775 }
5776 break;
5777 }
5778
5779 case WE_WOWL:
5780 {
5781 switch (set_value)
5782 {
5783 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305784 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 break;
5786 case 0x01:
5787 case 0x02:
5788 case 0x03:
5789 enable_mp = (set_value & 0x01) ? 1 : 0;
5790 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005791 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5793 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5794 break;
5795 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005796 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 ret = -EINVAL;
5798 break;
5799 }
5800
5801 break;
5802 }
5803 case WE_SET_POWER:
5804 {
5805 switch (set_value)
5806 {
5807 case 0: //Full Power
5808 {
5809 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305810 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005811
5812 init_completion(&context.completion);
5813
5814 context.pAdapter = pAdapter;
5815 context.magic = POWER_CONTEXT_MAGIC;
5816
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305817 if (NULL == hHal)
5818 return -EINVAL;
5819
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5821 iw_power_callback_fn, &context,
5822 eSME_FULL_PWR_NEEDED_BY_HDD);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305823
Jeff Johnson72a40512013-12-19 10:14:15 -08005824 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 {
5826 int lrc = wait_for_completion_interruptible_timeout(
5827 &context.completion,
5828 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005829
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 if (lrc <= 0)
5831 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005832 hddLog(VOS_TRACE_LEVEL_ERROR,
5833 "%s: SME %s while requesting fullpower",
5834 __func__, (0 == lrc) ?
5835 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 }
5837 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005838 /* either we have a response or we timed out. if we timed
5839 out there is a race condition such that the callback
5840 function could be executing at the same time we are. of
5841 primary concern is if the callback function had already
5842 verified the "magic" but had not yet set the completion
5843 variable when a timeout occurred. we serialize these
5844 activities by invalidating the magic while holding a
5845 shared spinlock which will cause us to block if the
5846 callback is currently executing */
5847 spin_lock(&hdd_context_lock);
5848 context.magic = 0;
5849 spin_unlock(&hdd_context_lock);
5850
Arif Hussain6d2a3322013-11-17 19:50:10 -08005851 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 break;
5853 }
5854 case 1: //Enable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305855 if (hHal)
5856 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5857 else
5858 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 break;
5860 case 2: //Disable BMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305861 if (hHal)
5862 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5863 else
5864 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 break;
5866 case 3: //Request Bmps
5867 {
5868 struct statsContext context;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305869 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005870
5871 init_completion(&context.completion);
5872
5873 context.pAdapter = pAdapter;
5874 context.magic = POWER_CONTEXT_MAGIC;
5875
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305876 if (NULL == hHal)
5877 return -EINVAL;
5878
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305880 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005881 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 {
5883 int lrc = wait_for_completion_interruptible_timeout(
5884 &context.completion,
5885 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 if (lrc <= 0)
5887 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005888 hddLog(VOS_TRACE_LEVEL_ERROR,
5889 "%s: SME %s while requesting BMPS",
5890 __func__, (0 == lrc) ? "timeout" :
5891 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 }
5893 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005894 /* either we have a response or we timed out. if we
5895 timed out there is a race condition such that the
5896 callback function could be executing at the same
5897 time we are. of primary concern is if the callback
5898 function had already verified the "magic" but had
5899 not yet set the completion variable when a timeout
5900 occurred. we serialize these activities by
5901 invalidating the magic while holding a shared
5902 spinlock which will cause us to block if the
5903 callback is currently executing */
5904 spin_lock(&hdd_context_lock);
5905 context.magic = 0;
5906 spin_unlock(&hdd_context_lock);
5907
Arif Hussain6d2a3322013-11-17 19:50:10 -08005908 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 break;
5910 }
5911 case 4: //Enable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305912 if (hHal)
5913 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5914 else
5915 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 break;
5917 case 5: //Disable IMPS
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305918 if (hHal)
5919 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5920 else
5921 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 break;
5923 case 6: //Enable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305924 if (hHal)
5925 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5926 else
5927 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 break;
5929 case 7: //Disable Standby
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305930 if (hHal)
5931 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5932 else
5933 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 break;
5935 case 8: //Request Standby
5936#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005937#endif
5938 break;
5939 case 9: //Start Auto Bmps Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305940 if (hHal)
5941 sme_StartAutoBmpsTimer(hHal);
5942 else
5943 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 break;
5945 case 10://Stop Auto BMPS Timer
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305946 if (hHal)
5947 sme_StopAutoBmpsTimer(hHal);
5948 else
5949 ret = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 break;
5951#ifdef CONFIG_HAS_EARLYSUSPEND
5952 case 11://suspend to standby
5953#ifdef CONFIG_HAS_EARLYSUSPEND
5954 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5955 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5957#endif
5958 break;
5959 case 12://suspend to deep sleep
5960#ifdef CONFIG_HAS_EARLYSUSPEND
5961 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5962 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5964#endif
5965 break;
5966 case 13://resume from suspend
5967#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005968#endif
5969 break;
5970#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005972 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 ret = -EINVAL;
5974 break;
5975 }
5976 break;
5977 }
5978
5979 case WE_SET_MAX_ASSOC:
5980 {
5981 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05305982 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value) ||
5983 (NULL == hHal))
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 {
5985 ret = -EINVAL;
5986 }
5987 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5988 set_value, NULL, eANI_BOOLEAN_FALSE)
5989 != eHAL_STATUS_SUCCESS )
5990 {
c_hpothub8245442013-11-20 23:41:09 +05305991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5992 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 ret = -EIO;
5994 }
5995 break;
5996 }
5997
5998 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5999 {
6000 if( 0 == set_value )
6001 {
6002 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
6003 }
6004 else if ( 1 == set_value )
6005 {
6006 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
6007 }
6008 else
6009 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006010 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 ret = -EINVAL;
6012 }
6013 break;
6014 }
6015
6016 case WE_SET_DATA_INACTIVITY_TO:
6017 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306018 if (NULL == hHal)
6019 return -EINVAL;
6020
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
6022 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
6023 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
6024 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
6025 set_value,
6026 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
6027 {
6028 hddLog(LOGE,"Failure: Could not pass on "
6029 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006030 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 ret = -EINVAL;
6032 }
6033 break;
6034 }
6035 case WE_SET_MAX_TX_POWER:
6036 {
6037 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6038 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6039
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306040 if (NULL == hHal)
6041 return -EINVAL;
6042
Jeff Johnson295189b2012-06-20 16:38:30 -07006043 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
6044 __func__, set_value);
6045 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
6046 eHAL_STATUS_SUCCESS )
6047 {
6048 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6049 __func__);
6050 return -EIO;
6051 }
6052
6053 break;
6054 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07006055 case WE_SET_MAX_TX_POWER_2_4:
6056 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306057 if (NULL == hHal)
6058 return -EINVAL;
6059
Arif Hussaina5ebce02013-08-09 15:09:58 -07006060 hddLog(VOS_TRACE_LEVEL_INFO,
6061 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
6062 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306063 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006064 eHAL_STATUS_SUCCESS)
6065 {
6066 hddLog(VOS_TRACE_LEVEL_ERROR,
6067 "%s: Setting maximum tx power failed for 2.4 GHz band",
6068 __func__);
6069 return -EIO;
6070 }
6071
6072 break;
6073 }
6074 case WE_SET_MAX_TX_POWER_5_0:
6075 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306076 if (NULL == hHal)
6077 return -EINVAL;
6078
Arif Hussaina5ebce02013-08-09 15:09:58 -07006079 hddLog(VOS_TRACE_LEVEL_INFO,
6080 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
6081 __func__, set_value);
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306082 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value, hHal) !=
Arif Hussaina5ebce02013-08-09 15:09:58 -07006083 eHAL_STATUS_SUCCESS)
6084 {
6085 hddLog(VOS_TRACE_LEVEL_ERROR,
6086 "%s: Setting maximum tx power failed for 5.0 GHz band",
6087 __func__);
6088 return -EIO;
6089 }
6090
6091 break;
6092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 case WE_SET_HIGHER_DTIM_TRANSITION:
6094 {
6095 if(!((set_value == eANI_BOOLEAN_FALSE) ||
6096 (set_value == eANI_BOOLEAN_TRUE)))
6097 {
6098 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
6099 ret = -EINVAL;
6100 }
6101 else
6102 {
6103 if(pAdapter->higherDtimTransition != set_value)
6104 {
6105 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006106 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 }
6108 }
6109
6110 break;
6111 }
6112
6113 case WE_SET_TM_LEVEL:
6114 {
6115 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006116 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
6118
6119 break;
6120 }
6121
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306122 case WE_ENABLE_STRICT_FCC_REG:
6123 {
6124 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
6125 struct wiphy *wiphy = NULL;
6126 long lrc;
6127 int status;
6128
6129 wiphy = hddCtxt->wiphy;
6130 if(wiphy == NULL)
6131 {
6132 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
6133 break;
6134 }
6135 init_completion(&hddCtxt->wiphy_channel_update_event);
6136
6137 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
6138
6139 status = regulatory_hint(wiphy, "00");
6140 if(status < 0)
6141 {
6142 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
6143 break;
6144 }
6145
6146 /* Wait for completion */
6147 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
6148 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
6149 if (lrc <= 0)
6150 {
6151 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
6152 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
6153 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
6154 }
6155 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
6156
6157 break;
6158 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006159 case WE_SET_DEBUG_LOG:
6160 {
6161 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6162 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306163 if (hHal)
6164 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
6165 else
6166 ret = -1;
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08006167 break;
6168 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05306169#ifdef FEATURE_WLAN_TDLS
6170 case WE_SET_TDLS_OFF_CHAN:
6171 {
6172 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
6174 __func__, set_value);
6175 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
6176 break;
6177 }
6178 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
6179 {
6180 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
6182 __func__, set_value);
6183 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
6184 break;
6185 }
6186 case WE_SET_TDLS_OFF_CHAN_MODE:
6187 {
6188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
6189 __func__, set_value);
6190 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
6191 break;
6192 }
6193#endif
Peng Xu2446a892014-09-05 17:21:18 +05306194 case WE_SET_SCAN_BAND_PREFERENCE:
6195 {
6196 tSmeConfigParams smeConfig;
6197 memset(&smeConfig, 0x00, sizeof(smeConfig));
6198 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
6199 ret = -EINVAL;
6200 break;
6201 }
6202 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
6203
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306204 if ((eCSR_BAND_ALL == set_value ||
6205 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) &&
6206 (hHal)) {
Peng Xu2446a892014-09-05 17:21:18 +05306207 sme_GetConfigParam(hHal, &smeConfig);
6208 smeConfig.csrConfig.scanBandPreference = set_value;
6209
6210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6211 "set band scan preference = %d\n",
6212 smeConfig.csrConfig.scanBandPreference);
6213
6214 sme_UpdateConfig(hHal, &smeConfig);
6215 }
6216 else {
6217 ret = -EINVAL;
6218 }
6219 break;
6220 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306221 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
6222 * connection happens so that the params can take effect during
6223 * association. Also this should not be used in STA+p2p concurrency
6224 * as the param will also effect the STA mode.
6225 */
6226 case WE_SET_MIRACAST_VENDOR_CONFIG:
6227 {
6228 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05306229
Abhishek Singh01c73d12015-03-12 15:13:44 +05306230 hddLog(LOG1, FL(
6231 "Set Miracast vendor tuning %d"), set_value);
6232
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306233 if (NULL == hHal)
6234 return -EINVAL;
6235
Abhishek Singh01c73d12015-03-12 15:13:44 +05306236 if (1 == set_value || 0 == set_value)
6237 {
6238 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
6239 pHddCtx->cfg_ini->numBuffAdvert, set_value))
6240 {
6241 hddLog( LOGE, FL("set vendor miracast config failed"));
6242 ret = -EIO;
6243 }
6244 }
6245 else
6246 {
6247 hddLog(LOGE,
6248 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
6249 ret = -EINVAL;
6250 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05306251 break;
6252 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05306253
6254 case WE_GET_FRAME_LOG:
6255 {
6256 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
6257 != VOS_STATUS_SUCCESS)
6258 {
6259 ret = -EINVAL;
6260 }
6261 break;
6262 }
6263
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306264 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
6265 {
6266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6267 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306268 if ((set_value == 0 || set_value == 1) && (hHal))
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306269 {
6270 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
6271 set_value);
6272 }
6273 else
6274 ret = -EINVAL;
6275
6276 break;
6277 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05306278 /* Bit mask value to enable RTS/CTS for different modes
6279 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
6280 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
6281 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
6282 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
6283 * for 5 GHz, VHT80 - 0x1000
6284 */
6285 case WE_SET_RTS_CTS_HTVHT:
6286 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05306287
Abhishek Singh41988ba2015-05-25 19:42:29 +05306288 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
6289
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05306290 if (NULL == hHal)
6291 return -EINVAL;
6292
Abhishek Singh41988ba2015-05-25 19:42:29 +05306293 if (eHAL_STATUS_SUCCESS !=
6294 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
6295 {
6296 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
6297 ret = -EINVAL;
6298 }
6299 break;
6300 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306301 case WE_SET_MONITOR_STATE:
6302 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306303 v_U32_t magic = 0;
6304 struct completion cmpVar;
6305 long waitRet = 0;
6306 tVOS_CON_MODE mode = hdd_get_conparam();
6307
6308 if( VOS_MONITOR_MODE != mode)
6309 {
6310 hddLog(LOGE, "invalid mode %d", mode);
6311 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306312 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306313 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306314
6315 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
6316 if( pMonCtx == NULL )
6317 {
6318 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306319 ret = -EIO;
Abhishek Singh10b209b2016-02-10 12:34:41 +05306320 break;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306321 }
6322 if (pMonCtx->state == set_value)
6323 {
6324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6325 FL("already in same mode curr_mode:%d req_mode: %d"),
6326 pMonCtx->state, set_value);
6327 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306328 }
6329 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05306330 magic = MON_MODE_MSG_MAGIC;
6331 init_completion(&cmpVar);
6332 if (VOS_STATUS_SUCCESS !=
6333 wlan_hdd_mon_postMsg(&magic, &cmpVar,
6334 pMonCtx, hdd_monPostMsgCb)) {
6335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6336 FL("failed to post MON MODE REQ"));
6337 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
6338 MON_MODE_STOP : MON_MODE_START;
6339 magic = 0;
6340 ret = -EIO;
6341 break;
6342 }
6343 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
6344 magic = 0;
6345 if (waitRet <= 0 ){
6346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6347 FL("failed to wait on monitor mode completion %ld"),
6348 waitRet);
6349 }
6350 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05306351 }
Sushant Kaushik33200572015-08-05 16:46:20 +05306352 case WE_SET_PKT_STATS_ENABLE_DISABLE:
6353 {
6354 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6355 tAniWifiStartLog start_log;
6356 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
6357 !vos_isPktStatsEnabled())
6358 {
6359 hddLog(LOGE, FL("per pkt stats not enabled"));
6360 return -EINVAL;
6361 }
6362 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6363
6364 if (1 == set_value || 0 == set_value)
6365 {
6366 start_log.ringId = RING_ID_PER_PACKET_STATS;
6367 start_log.flag = 0;
6368 if (set_value)
6369 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6370 else
6371 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6372
6373 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6374 }
6375 else
6376 {
6377 hddLog(LOGE,
6378 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6379 set_value);
6380 ret = -EINVAL;
6381 }
6382 break;
6383 }
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306384 case WE_SET_PROXIMITY_ENABLE:
6385 {
Padma, Santhosh Kumar42511ea2016-10-17 17:30:41 +05306386 if (NULL == hHal)
6387 return -EINVAL;
6388
6389 ret = wlan_hdd_set_proximity(set_value, hHal);
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +05306390 break;
6391 }
Manjeet Singh3ed79242017-01-11 19:04:32 +05306392 case WE_CAP_TSF:
6393 {
6394 if (NULL == hHal)
6395 return -EINVAL;
6396
6397 ret = hdd_capture_tsf(pAdapter, (uint32_t *)&set_value, 1);
6398 break;
6399 }
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306400 case WE_SET_MODULATED_DTIM:
6401 {
6402 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6403 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6404 hddLog(LOGE, FL("Invalid value %d in gEnableModuleDTIM"),
6405 set_value);
6406 return -EINVAL;
6407 } else {
6408 ret = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->
6409 enableModulatedDTIM = set_value;
6410 }
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +05306411 }
6412 case WLAN_SET_DYNNAMIC_AGGREGATION:
6413 {
6414 if (NULL == hHal)
6415 return -EINVAL;
6416
6417 ret = hdd_set_dynamic_aggregation(set_value, pAdapter);
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +05306418 break;
6419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 default:
6421 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006422 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006423 sub_cmd, set_value);
6424 break;
6425 }
6426 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306427 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 return ret;
6429}
6430
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306431static int iw_setint_getnone(struct net_device *dev,
6432 struct iw_request_info *info,
6433 union iwreq_data *wrqu, char *extra)
6434{
6435 int ret;
6436
6437 vos_ssr_protect(__func__);
6438 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6439 vos_ssr_unprotect(__func__);
6440
6441 return 0;
6442}
Jeff Johnson295189b2012-06-20 16:38:30 -07006443/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306444static int __iw_setchar_getnone(struct net_device *dev,
6445 struct iw_request_info *info,
6446 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006447{
6448 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306449 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006451 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306452 hdd_adapter_t *pAdapter;
6453 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006454#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306455 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006456#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306457 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306458 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006459
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306460 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306461
6462 if (!capable(CAP_NET_ADMIN))
6463 {
6464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6465 FL("permission check failed"));
6466 return -EPERM;
6467 }
6468
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306469 pAdapter = (netdev_priv(dev));
6470 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006471 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6473 "%s: Adapter is NULL",__func__);
6474 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006475 }
6476
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306477 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6478 ret = wlan_hdd_validate_context(pHddCtx);
6479 if (0 != ret)
6480 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306481 return ret;
6482 }
6483#ifdef WLAN_FEATURE_VOWIFI
6484 pConfig = pHddCtx->cfg_ini;
6485#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306486 /* helper function to get iwreq_data with compat handling. */
6487 if (hdd_priv_get_data(&s_priv_data, wrqu))
6488 {
6489 return -EINVAL;
6490 }
6491
6492 /* make sure all params are correctly passed to function */
6493 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6494 {
6495 return -EINVAL;
6496 }
6497
6498 sub_cmd = s_priv_data.flags;
6499
Arif Hussain0273cba2014-01-07 20:58:29 -08006500 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306501 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6502 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006503 if (NULL == pBuffer)
6504 {
6505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6506 "mem_alloc_copy_from_user_helper fail");
6507 return -ENOMEM;
6508 }
6509
6510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306511 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6513 "%s: Received data %s", __func__, pBuffer);
6514
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 switch(sub_cmd)
6516 {
6517 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006519 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 break;
6521 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006523 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 break;
6525#if defined WLAN_FEATURE_VOWIFI
6526 case WE_NEIGHBOR_REPORT_REQUEST:
6527 {
6528 tRrmNeighborReq neighborReq;
6529 tRrmNeighborRspCallbackInfo callbackInfo;
6530
6531 if (pConfig->fRrmEnable)
6532 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306534 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 if( !neighborReq.no_ssid )
6536 {
Girish Gowli552fc072014-06-14 18:26:16 +05306537 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006538 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 }
6540
6541 callbackInfo.neighborRspCallback = NULL;
6542 callbackInfo.neighborRspCallbackContext = NULL;
6543 callbackInfo.timeout = 5000; //5 seconds
6544 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6545 }
6546 else
6547 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006548 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 ret = -EINVAL;
6550 }
6551 }
6552 break;
6553#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006554 case WE_SET_AP_WPS_IE:
6555 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306556 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006558 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006559 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 if (VOS_STATUS_SUCCESS != vstatus)
6561 {
6562 ret = -EINVAL;
6563 }
6564 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306565 case WE_SET_ENCRYPT_MSG:
6566 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6567 if (NULL == pkt)
6568 {
6569 hddLog(VOS_TRACE_LEVEL_ERROR,
6570 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306571 ret = -ENOMEM;
6572 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306573 }
6574
6575 memset(pkt, 0, sizeof(tSirpkt80211));
6576
6577 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6578 hddLog(VOS_TRACE_LEVEL_ERROR,
6579 FL("Firmware is not DISA capable"));
6580 ret = -EINVAL;
6581 vos_mem_free(pkt);
6582 break;
6583 }
6584
6585 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6586
6587 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6588 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6589 if (eHAL_STATUS_SUCCESS != ret) {
6590 hddLog(VOS_TRACE_LEVEL_ERROR,
6591 FL("SENDEncryptMSG: fail to post WDA cmd"));
6592 ret = -EINVAL;
6593 }
6594 vos_mem_free(pkt);
6595
6596 break;
6597
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 default:
6599 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006600 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 ret = -EINVAL;
6602 break;
6603 }
6604 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006605 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306606
6607 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 return ret;
6609}
6610
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306611static int iw_setchar_getnone(struct net_device *dev,
6612 struct iw_request_info *info,
6613 union iwreq_data *wrqu, char *extra)
6614{
6615 int ret;
6616
6617 vos_ssr_protect(__func__);
6618 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6619 vos_ssr_unprotect(__func__);
6620
6621 return ret;
6622}
6623
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306624static void hdd_GetCurrentAntennaIndex(int antennaId, void *pContext)
6625{
6626 struct statsContext *context;
6627 hdd_adapter_t *pAdapter;
6628
6629 if (NULL == pContext)
6630 {
6631 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07006632 "%s: Bad param, pContext [%pK]",
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306633 __func__, pContext);
6634 return;
6635 }
6636
6637 context = pContext;
6638 pAdapter = context->pAdapter;
6639
6640 spin_lock(&hdd_context_lock);
6641
6642 if ((NULL == pAdapter) || (ANTENNA_CONTEXT_MAGIC != context->magic))
6643 {
6644 /* the caller presumably timed out so there is nothing we can do */
6645 spin_unlock(&hdd_context_lock);
6646 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07006647 "%s: Invalid context, pAdapter [%pK] magic [%08x]",
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306648 __func__, pAdapter, context->magic);
6649 return;
6650 }
6651
6652 context->magic = 0;
6653 pAdapter->antennaIndex = antennaId;
6654
6655 complete(&context->completion);
6656 spin_unlock(&hdd_context_lock);
6657}
6658
6659static VOS_STATUS wlan_hdd_get_current_antenna_index(hdd_adapter_t *pAdapter,
6660 int *antennaIndex)
6661{
6662 hdd_context_t *pHddCtx;
6663 eHalStatus halStatus;
6664 struct statsContext context;
6665 long lrc;
6666
6667 ENTER();
6668 if (NULL == pAdapter)
6669 {
6670 hddLog(VOS_TRACE_LEVEL_WARN,
6671 "%s: Invalid context, pAdapter", __func__);
6672 return VOS_STATUS_E_FAULT;
6673 }
6674 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6675 if (0 != (wlan_hdd_validate_context(pHddCtx)))
6676 {
6677 return VOS_STATUS_E_FAULT;
6678 }
6679 if (TRUE != sme_IsFeatureSupportedByFW(ANTENNA_DIVERSITY_SELECTION))
6680 {
6681 hddLog(VOS_TRACE_LEVEL_ERROR,
6682 "%s: ANTENNA_DIVERSITY_SELECTION is not supported by Firwmare",
6683 __func__);
6684 return VOS_STATUS_E_NOSUPPORT;
6685 }
6686 init_completion(&context.completion);
6687 context.pAdapter = pAdapter;
6688 context.magic = ANTENNA_CONTEXT_MAGIC;
6689
6690 halStatus = sme_GetCurrentAntennaIndex(pHddCtx->hHal,
6691 hdd_GetCurrentAntennaIndex,
6692 &context, pAdapter->sessionId);
6693 if (eHAL_STATUS_SUCCESS != halStatus)
6694 {
6695 spin_lock(&hdd_context_lock);
6696 context.magic = 0;
6697 spin_unlock(&hdd_context_lock);
6698 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve Antenna Index",
6699 __func__);
6700 /* we'll returned a cached value below */
6701 *antennaIndex = -1;
6702 return VOS_STATUS_E_FAILURE;
6703 }
6704 else
6705 {
6706 /* request was sent -- wait for the response */
6707 lrc = wait_for_completion_interruptible_timeout(&context.completion,
6708 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
6709 if (lrc <= 0)
6710 {
6711 spin_lock(&hdd_context_lock);
6712 context.magic = 0;
6713 spin_unlock(&hdd_context_lock);
6714 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:SME %s while retrieving Antenna"
6715 " Index",
6716 __func__, (0 == lrc) ? "timeout" : "interrupt");
6717 *antennaIndex = -1;
6718 return VOS_STATUS_E_FAILURE;
6719 }
6720 }
6721 spin_lock(&hdd_context_lock);
6722 context.magic = 0;
6723 spin_unlock(&hdd_context_lock);
6724
6725 *antennaIndex = pAdapter->antennaIndex;
6726
6727 EXIT();
6728 return VOS_STATUS_SUCCESS;
6729}
6730
Jeff Johnson295189b2012-06-20 16:38:30 -07006731/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306732static int __iw_setnone_getint(struct net_device *dev,
6733 struct iw_request_info *info,
6734 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006735{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306736 hdd_adapter_t *pAdapter;
6737 tHalHandle hHal;
6738 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 int *value = (int *)extra;
6740 int ret = 0; /* success */
6741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306742 ENTER();
6743
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306744 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6745 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006746 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6748 "%s: Adapter is NULL",__func__);
6749 return -EINVAL;
6750 }
6751 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6752 ret = wlan_hdd_validate_context(pHddCtx);
6753 if (0 != ret)
6754 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306755 return ret;
6756 }
6757 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6758 if (NULL == hHal)
6759 {
6760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6761 "%s: Hal Context is NULL",__func__);
6762 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006764
6765 switch (value[0])
6766 {
6767 case WE_GET_11D_STATE:
6768 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006769 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306771
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6773
Arif Hussain6d2a3322013-11-17 19:50:10 -08006774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006775
6776 break;
6777 }
6778
6779 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006781 break;
6782
6783 case WE_PMC_STATE:
6784 {
6785 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006787 break;
6788 }
6789 case WE_GET_WLAN_DBG:
6790 {
6791 vos_trace_display();
6792 *value = 0;
6793 break;
6794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006795 case WE_GET_MAX_ASSOC:
6796 {
6797 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6798 {
c_hpothub8245442013-11-20 23:41:09 +05306799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6800 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 ret = -EIO;
6802 }
Girish Gowli385be612014-09-18 11:17:20 +05306803#ifdef WLAN_SOFTAP_VSTA_FEATURE
6804 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6805 {
6806 if (*value > VSTA_NUM_ASSOC_STA)
6807 {
6808 *value = VSTA_NUM_ASSOC_STA;
6809 }
6810 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6811 (*value > (VSTA_NUM_ASSOC_STA -
6812 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6813 {
6814 *value = (VSTA_NUM_ASSOC_STA -
6815 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6816 }
6817 }
6818 else
6819#endif
6820 {
6821 if (*value > NUM_ASSOC_STA)
6822 {
6823 *value = NUM_ASSOC_STA;
6824 }
6825 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6826 (*value > (NUM_ASSOC_STA -
6827 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6828 {
6829 *value = (NUM_ASSOC_STA -
6830 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6831 }
6832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006833 break;
6834 }
6835
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 case WE_GET_WDI_DBG:
6837 {
6838 wpalTraceDisplay();
6839 *value = 0;
6840 break;
6841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006842
6843 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6844 {
6845 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6846 break;
6847 }
6848 case WE_GET_CONCURRENCY_MODE:
6849 {
6850 *value = hdd_get_concurrency_mode ( );
6851
Arif Hussain6d2a3322013-11-17 19:50:10 -08006852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 break;
6854 }
6855
Peng Xu2446a892014-09-05 17:21:18 +05306856 case WE_GET_SCAN_BAND_PREFERENCE:
6857 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306858 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306859 sme_GetConfigParam(hHal, &smeConfig);
6860 *value = smeConfig.csrConfig.scanBandPreference;
6861
6862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6863 "scanBandPreference = %d\n", *value);
6864 break;
6865 }
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +05306866 case WE_GET_ANTENA_DIVERSITY_SELECTION:
6867 {
6868 wlan_hdd_get_current_antenna_index(pAdapter, value);
6869 break;
6870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 default:
6872 {
6873 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6874 break;
6875 }
6876 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306877 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 return ret;
6879}
6880
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306881static int iw_setnone_getint(struct net_device *dev,
6882 struct iw_request_info *info,
6883 union iwreq_data *wrqu, char *extra)
6884{
6885 int ret;
6886
6887 vos_ssr_protect(__func__);
6888 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6889 vos_ssr_unprotect(__func__);
6890
6891 return ret;
6892
6893}
Jeff Johnson295189b2012-06-20 16:38:30 -07006894/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306895int __iw_set_three_ints_getnone(struct net_device *dev,
6896 struct iw_request_info *info,
6897 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006898{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306899 hdd_adapter_t *pAdapter;
6900 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 int *value = (int *)extra;
6902 int sub_cmd = value[0];
6903 int ret = 0;
6904
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306905 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306906
6907 if (!capable(CAP_NET_ADMIN))
6908 {
6909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6910 FL("permission check failed"));
6911 return -EPERM;
6912 }
6913
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306914 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6915 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006916 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6918 "%s: Adapter is NULL",__func__);
6919 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006920 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306921 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6922 ret = wlan_hdd_validate_context(pHddCtx);
6923 if (0 != ret)
6924 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306925 return ret;
6926 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 switch(sub_cmd)
6928 {
6929 case WE_SET_WLAN_DBG:
6930 {
6931 vos_trace_setValue( value[1], value[2], value[3]);
6932 break;
6933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 case WE_SET_WDI_DBG:
6935 {
6936 wpalTraceSetLevel( value[1], value[2], value[3]);
6937 break;
6938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 case WE_SET_SAP_CHANNELS:
6940 {
6941 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6942 break;
6943 }
6944
6945 default:
6946 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006947 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 break;
6949 }
6950 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306951 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 return ret;
6953}
6954
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306955int iw_set_three_ints_getnone(struct net_device *dev,
6956 struct iw_request_info *info,
6957 union iwreq_data *wrqu, char *extra)
6958{
6959 int ret;
6960
6961 vos_ssr_protect(__func__);
6962 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6963 vos_ssr_unprotect(__func__);
6964
6965 return ret;
6966}
6967
6968static int __iw_get_char_setnone(struct net_device *dev,
6969 struct iw_request_info *info,
6970 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006971{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306972 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306974 hdd_context_t *pHddCtx;
6975 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006976#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006977 hdd_wext_state_t *pWextState;
6978#endif
6979
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306980 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306981 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006982 if (pAdapter == NULL)
6983 {
6984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6985 "%s: pAdapter is NULL!", __func__);
6986 return -EINVAL;
6987 }
Alok Kumar69a8b752017-11-08 15:24:32 +05306988
6989 if (WLAN_HDD_MONITOR == pAdapter->device_mode ||
6990 WLAN_HDD_FTM == pAdapter->device_mode)
6991 return ret;
6992
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306993 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6994 ret = wlan_hdd_validate_context(pHddCtx);
6995 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006996 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306997 return ret;
6998 }
6999#ifdef WLAN_FEATURE_11W
7000 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7001 if (NULL == pWextState)
7002 {
7003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7004 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07007005 return -EINVAL;
7006 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307007#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007008
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 switch(sub_cmd)
7010 {
7011 case WE_WLAN_VERSION:
7012 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08007013 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 break;
7015 }
7016
7017 case WE_GET_STATS:
7018 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307019 tHalHandle hHal = NULL;
7020 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7022 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
7023 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307024 hdd_arp_stats_t *parpStats = &pAdapter->hdd_stats.hddArpStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07007025
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307026
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 snprintf(extra, WE_MAX_STR_LEN,
7028 "\nTransmit"
7029 "\ncalled %u, dropped %u, backpressured %u, queued %u"
7030 "\n dropped BK %u, BE %u, VI %u, VO %u"
7031 "\n classified BK %u, BE %u, VI %u, VO %u"
7032 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
7033 "\n queued BK %u, BE %u, VI %u, VO %u"
7034 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007035 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007036 "\n fetched BK %u, BE %u, VI %u, VO %u"
7037 "\n dequeued BK %u, BE %u, VI %u, VO %u"
7038 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007039 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 "\n flushed BK %u, BE %u, VI %u, VO %u"
7041 "\n\nReceive"
7042 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
7043 "\n\nResetsStats"
7044 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307045 "\n"
7046 "\n\nARP Transmit"
7047 "\nTransmit Count %u, dropped %u"
7048 "\n\nARP Receive"
7049 "\nReceive Count %u, dropped %u, Delivered %u, Refused %u, Drop Reason %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007050 "\n",
7051 pStats->txXmitCalled,
7052 pStats->txXmitDropped,
7053 pStats->txXmitBackPressured,
7054 pStats->txXmitQueued,
7055
7056 pStats->txXmitDroppedAC[WLANTL_AC_BK],
7057 pStats->txXmitDroppedAC[WLANTL_AC_BE],
7058 pStats->txXmitDroppedAC[WLANTL_AC_VI],
7059 pStats->txXmitDroppedAC[WLANTL_AC_VO],
7060
7061 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
7062 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
7063 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
7064 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
7065
7066 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
7067 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
7068 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
7069 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
7070
7071 pStats->txXmitQueuedAC[WLANTL_AC_BK],
7072 pStats->txXmitQueuedAC[WLANTL_AC_BE],
7073 pStats->txXmitQueuedAC[WLANTL_AC_VI],
7074 pStats->txXmitQueuedAC[WLANTL_AC_VO],
7075
7076 pStats->txFetched,
7077 pStats->txFetchEmpty,
7078 pStats->txFetchLowResources,
7079 pStats->txFetchDequeueError,
7080
7081 pStats->txFetchDequeued,
7082 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07007083 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 pStats->txCompleted,
7085 pStats->txFlushed,
7086
7087 pStats->txFetchedAC[WLANTL_AC_BK],
7088 pStats->txFetchedAC[WLANTL_AC_BE],
7089 pStats->txFetchedAC[WLANTL_AC_VI],
7090 pStats->txFetchedAC[WLANTL_AC_VO],
7091
7092 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
7093 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
7094 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
7095 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
7096
7097 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
7098 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
7099 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
7100 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
7101
Ravi Joshi41914632013-10-21 23:02:21 -07007102 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
7103 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
7104 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
7105 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
7106
Jeff Johnson295189b2012-06-20 16:38:30 -07007107 pStats->txFlushedAC[WLANTL_AC_BK],
7108 pStats->txFlushedAC[WLANTL_AC_BE],
7109 pStats->txFlushedAC[WLANTL_AC_VI],
7110 pStats->txFlushedAC[WLANTL_AC_VO],
7111
7112 pStats->rxChains,
7113 pStats->rxPackets,
7114 pStats->rxDropped,
7115 pStats->rxDelivered,
7116 pStats->rxRefused,
7117
7118 pResetStats->totalLogpResets,
7119 pResetStats->totalCMD53Failures,
7120 pResetStats->totalMutexReadFailures,
7121 pResetStats->totalMIFErrorFailures,
7122 pResetStats->totalFWHearbeatFailures,
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307123 pResetStats->totalUnknownExceptions,
7124
7125 parpStats->txCount,
7126 parpStats->txDropped,
7127
7128 parpStats->rxCount,
7129 parpStats->rxDropped,
7130 parpStats->rxDelivered,
7131 parpStats->rxRefused,
7132 parpStats->reason
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307134 wrqu->data.length = strlen(extra);
7135
7136 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7137
7138 if (hHal)
7139 pMac = PMAC_STRUCT( hHal );
7140
7141 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7142 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7143 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307144 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7145 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7146 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7147 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307148 "\n",
7149 pMac->pmm.BmpscntSleep,
7150 pMac->pmm.BmpscntAwake,
7151 pMac->pmm.BmpsSleeReqFailCnt,
7152 pMac->pmm.BmpsWakeupReqFailCnt,
7153 pMac->pmm.ImpsCntSleep,
7154 pMac->pmm.ImpsCntAwake,
7155 pMac->pmm.ImpsSleepErrCnt,
7156 pMac->pmm.ImpsWakeupErrCnt,
7157 pMac->pmm.ImpsLastErr
7158 );
7159 }
7160
Jeff Johnson295189b2012-06-20 16:38:30 -07007161 wrqu->data.length = strlen(extra)+1;
7162 break;
7163 }
7164
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307165/* The case prints the current state of the HDD, SME, CSR, PE, TL
7166 *it can be extended for WDI Global State as well.
7167 *And currently it only checks P2P_CLIENT adapter.
7168 *P2P_DEVICE and P2P_GO have not been added as of now.
7169*/
7170 case WE_GET_STATES:
7171 {
7172 int buf = 0, len = 0;
7173 int adapter_num = 0;
7174 int count = 0, check = 1;
7175
7176 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007177 tHalHandle hHal = NULL;
7178 tpAniSirGlobal pMac = NULL;
7179 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307180
7181 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7182 hdd_adapter_t *useAdapter = NULL;
7183
7184 /* Print wlan0 or p2p0 states based on the adapter_num
7185 *by using the correct adapter
7186 */
7187 while ( adapter_num < 2 )
7188 {
7189 if ( WLAN_ADAPTER == adapter_num )
7190 {
7191 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007192 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307193 "\n\n wlan0 States:-");
7194 len += buf;
7195 }
7196 else if ( P2P_ADAPTER == adapter_num )
7197 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007198 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307199 "\n\n p2p0 States:-");
7200 len += buf;
7201
7202 if( !pHddCtx )
7203 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007204 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307205 "\n pHddCtx is NULL");
7206 len += buf;
7207 break;
7208 }
7209
7210 /*Printing p2p0 states only in the case when the device is
7211 configured as a p2p_client*/
7212 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7213 if ( !useAdapter )
7214 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007215 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307216 "\n Device not configured as P2P_CLIENT.");
7217 len += buf;
7218 break;
7219 }
7220 }
7221
7222 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007223 if (!hHal) {
7224 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7225 "\n pMac is NULL");
7226 len += buf;
7227 break;
7228 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307229 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007230 if (!pMac) {
7231 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7232 "\n pMac is NULL");
7233 len += buf;
7234 break;
7235 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307236 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7237 if( !pHddStaCtx )
7238 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007239 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307240 "\n pHddStaCtx is NULL");
7241 len += buf;
7242 break;
7243 }
7244
7245 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7246
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007247 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307248 "\n HDD Conn State - %s "
7249 "\n \n SME State:"
7250 "\n Neighbour Roam State - %s"
7251 "\n CSR State - %s"
7252 "\n CSR Substate - %s"
7253 "\n \n TL STA %d State: %s",
7254 macTraceGetHDDWlanConnState(
7255 pHddStaCtx->conn_info.connState),
7256 macTraceGetNeighbourRoamState(
7257 pMac->roam.neighborRoamInfo.neighborRoamState),
7258 macTraceGetcsrRoamState(
7259 pMac->roam.curState[useAdapter->sessionId]),
7260 macTraceGetcsrRoamSubState(
7261 pMac->roam.curSubState[useAdapter->sessionId]),
7262 pHddStaCtx->conn_info.staId[0],
7263 macTraceGetTLState(tlState)
7264 );
7265 len += buf;
7266 adapter_num++;
7267 }
7268
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007269 if (pMac) {
7270 /* Printing Lim State starting with global lim states */
7271 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7272 "\n \n LIM STATES:-"
7273 "\n Global Sme State - %s "\
7274 "\n Global mlm State - %s "\
7275 "\n",
7276 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7277 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7278 );
7279 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307280
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007281 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307282 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307283 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007284 if ( pMac->lim.gpSession[count].valid )
7285 {
7286 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7287 "\n Lim Valid Session %d:-"
7288 "\n PE Sme State - %s "
7289 "\n PE Mlm State - %s "
7290 "\n",
7291 check,
7292 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7293 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7294 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307295
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007296 len += buf;
7297 check++;
7298 }
7299 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307300 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307301 }
7302
7303 wrqu->data.length = strlen(extra)+1;
7304 break;
7305 }
7306
Jeff Johnson295189b2012-06-20 16:38:30 -07007307 case WE_GET_CFG:
7308 {
7309 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7310 wrqu->data.length = strlen(extra)+1;
7311 break;
7312 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007313#ifdef WLAN_FEATURE_11AC
7314 case WE_GET_RSSI:
7315 {
7316 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307317 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007318 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7319 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7320 wrqu->data.length = strlen(extra)+1;
7321 break;
7322 }
7323#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307324
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007325#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007326 case WE_GET_ROAM_RSSI:
7327 {
7328 v_S7_t s7Rssi = 0;
7329 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7330 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7331 wrqu->data.length = strlen(extra)+1;
7332 break;
7333 }
7334#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 case WE_GET_WMM_STATUS:
7336 {
7337 snprintf(extra, WE_MAX_STR_LEN,
7338 "\nDir: 0=up, 1=down, 3=both\n"
7339 "|------------------------|\n"
7340 "|AC | ACM |Admitted| Dir |\n"
7341 "|------------------------|\n"
7342 "|VO | %d | %3s | %d |\n"
7343 "|VI | %d | %3s | %d |\n"
7344 "|BE | %d | %3s | %d |\n"
7345 "|BK | %d | %3s | %d |\n"
7346 "|------------------------|\n",
7347 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7348 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7349 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7350 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7351 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7352 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7353 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7354 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7355 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7356 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7357 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7358 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7359
Jeff Johnsone7245742012-09-05 17:12:55 -07007360
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 wrqu->data.length = strlen(extra)+1;
7362 break;
7363 }
7364 case WE_GET_CHANNEL_LIST:
7365 {
7366 VOS_STATUS status;
7367 v_U8_t i, len;
7368 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307369 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7370 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7371 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007372 tChannelListInfo channel_list;
7373
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007374 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007376 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007378 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 return -EINVAL;
7380 }
7381 buf = extra;
7382
7383 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007384 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7385 * needed = 5 * number of channels. Check ifsufficient
7386 * buffer is available and then proceed to fill the buffer.
7387 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007388 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7389 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007390 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007391 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007392 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 return -EINVAL;
7394 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007395 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7396 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307397 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7398 {
7399 //Printing Country code in getChannelList
7400 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7401 {
7402 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7403 "%c ", pBuf[i]);
7404 }
7405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 for(i = 0 ; i < channel_list.num_channels; i++)
7407 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007408 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007410 }
7411 wrqu->data.length = strlen(extra)+1;
7412
7413 break;
7414 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007415#ifdef FEATURE_WLAN_TDLS
7416 case WE_GET_TDLS_PEERS:
7417 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007418 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007419 break;
7420 }
7421#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007422#ifdef WLAN_FEATURE_11W
7423 case WE_GET_11W_INFO:
7424 {
7425 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7426
7427 snprintf(extra, WE_MAX_STR_LEN,
7428 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7429 "\n Number of Unprotected Disassocs %d"
7430 "\n Number of Unprotected Deauths %d",
7431 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7432 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7433 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7434 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7435 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7436
7437 wrqu->data.length = strlen(extra)+1;
7438 break;
7439 }
7440#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307441#ifdef WLAN_FEATURE_RMC
7442 case WE_GET_IBSS_STA_INFO:
7443 {
7444 hdd_station_ctx_t *pHddStaCtx =
7445 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7446 int idx = 0;
7447 int length = 0, buf = 0;
7448
7449 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7450 {
7451 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7452 {
7453 buf = snprintf
7454 (
7455 (extra + length), WE_MAX_STR_LEN - length,
7456 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7457 pHddStaCtx->conn_info.staId[ idx ],
7458 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7459 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7460 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7461 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7462 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7463 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7464 );
7465 length += buf;
7466 }
7467 }
7468 wrqu->data.length = strlen(extra)+1;
7469 break;
7470 }
7471#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307472 case WE_GET_SNR:
7473 {
7474 v_S7_t s7snr = 0;
7475 int status = 0;
7476 hdd_context_t *pHddCtx;
7477 hdd_station_ctx_t *pHddStaCtx;
7478
7479 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7480 status = wlan_hdd_validate_context(pHddCtx);
7481 if (0 != status)
7482 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307483 return status;
7484 }
7485
7486 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7487
7488 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7489 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7490 {
7491 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7492 " ConnectionState-%d", __func__,
7493 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7494 pHddStaCtx->conn_info.connState);
7495 return -ENONET;
7496 }
7497
7498 /*update the stats in TL*/
7499 wlan_hdd_get_station_stats(pAdapter);
7500 wlan_hdd_get_snr(pAdapter, &s7snr);
7501 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7502 wrqu->data.length = strlen(extra) + 1;
7503 break;
7504 }
7505
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307506#ifdef FEATURE_OEM_DATA_SUPPORT
7507 case WE_GET_OEM_DATA_CAP:
7508 {
7509 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7510 }
7511#endif /* FEATURE_OEM_DATA_SUPPORT */
7512
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307513 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007514 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007515 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007516 break;
7517 }
7518 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307519 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007520 return 0;
7521}
7522
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307523static int iw_get_char_setnone(struct net_device *dev,
7524 struct iw_request_info *info,
7525 union iwreq_data *wrqu, char *extra)
7526{
7527 int ret;
7528
7529 vos_ssr_protect(__func__);
7530 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7531 vos_ssr_unprotect(__func__);
7532
7533 return ret;
7534}
7535
Jeff Johnson295189b2012-06-20 16:38:30 -07007536/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307537static int __iw_setnone_getnone(struct net_device *dev,
7538 struct iw_request_info *info,
7539 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007540{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307541 hdd_adapter_t *pAdapter;
7542 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307543 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007544 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307545 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007546
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307547 ENTER();
7548
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307549 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7550 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007551 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7553 "%s: Adapter is NULL",__func__);
7554 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007555 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307556 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7557 ret = wlan_hdd_validate_context(pHddCtx);
7558 if (0 != ret)
7559 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307560 return ret;
7561 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307562 /* helper function to get iwreq_data with compat handling. */
7563 if (hdd_priv_get_data(&s_priv_data, wrqu))
7564 {
7565 return -EINVAL;
7566 }
7567
7568 sub_cmd = s_priv_data.flags;
7569
Jeff Johnson295189b2012-06-20 16:38:30 -07007570 switch (sub_cmd)
7571 {
7572 case WE_CLEAR_STATS:
7573 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007575 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7576 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7577 break;
7578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 case WE_INIT_AP:
7580 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307581 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7582
7583 /* As Soft AP mode might been changed to STA already with
7584 * killing of Hostapd, need to find the adpater by name
7585 * rather than mode */
7586 hdd_adapter_t* pAdapter_to_stop =
7587 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7588 if( pAdapter_to_stop )
7589 {
7590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7591 "Adapter with name softap.0 already "
7592 "exist, ignoring the request.\nRemove the "
7593 "adapter and try again\n");
7594 break;
7595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 pr_info("Init AP trigger\n");
7597 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7598 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7599 break;
7600 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307601#ifdef WLAN_FEATURE_RMC
7602 case WE_IBSS_GET_PEER_INFO_ALL:
7603 {
7604 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7605 break;
7606 }
7607#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007608 case WE_STOP_AP:
7609 {
7610 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7611 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7612 * this is a dead code and need to find the adpater by name rather than mode */
7613 hdd_adapter_t* pAdapter_to_stop =
7614 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7615 if( pAdapter_to_stop )
7616 {
7617 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7618
7619 pr_info("Stopping AP mode\n");
7620
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307621 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7622 {
7623 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7624 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7625 }
7626
Jeff Johnson295189b2012-06-20 16:38:30 -07007627 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307628 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307629 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7631
7632 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7633 pAdapter_to_stop->macAddressCurrent.bytes);
7634 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7635 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307636
7637 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7638 {
7639 /* put the device back into BMPS */
7640 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7641 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007642 }
7643 else
7644 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007645 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 }
7647
7648 break;
7649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007650#ifdef WLAN_BTAMP_FEATURE
7651 case WE_ENABLE_AMP:
7652 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007654 WLANBAP_RegisterWithHCI(pAdapter);
7655 break;
7656 }
7657 case WE_DISABLE_AMP:
7658 {
7659 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7660 VOS_STATUS status;
7661
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007663
7664 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7665 status = WLANBAP_StopAmp();
7666 if(VOS_STATUS_SUCCESS != status )
7667 {
7668 pHddCtx->isAmpAllowed = VOS_TRUE;
7669 hddLog(VOS_TRACE_LEVEL_FATAL,
7670 "%s: Failed to stop AMP", __func__);
7671 }
7672 else
7673 {
7674 //a state m/c implementation in PAL is TBD to avoid this delay
7675 msleep(500);
7676 pHddCtx->isAmpAllowed = VOS_FALSE;
7677 WLANBAP_DeregisterFromHCI();
7678 }
7679
7680 break;
7681 }
7682#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007683 case WE_ENABLE_DXE_STALL_DETECT:
7684 {
schang6295e542013-03-12 15:31:23 -07007685 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7686 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007687 break;
7688 }
7689 case WE_DISPLAY_DXE_SNAP_SHOT:
7690 {
schang6295e542013-03-12 15:31:23 -07007691 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7692 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007693 break;
7694 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307695 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7696 {
7697 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7698 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307699 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307700 break;
7701 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307702
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307703 case WE_SET_REASSOC_TRIGGER:
7704 {
7705 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7706 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7707 v_U32_t roamId = 0;
7708 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307709 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7710 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307711 return 0;
7712 }
7713
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307714 case WE_STOP_OBSS_SCAN:
7715 {
7716 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7717 2.OBSS scan is stopped by Firmware during the disassociation
7718 3.OBSS stop comamnd is added for debugging purpose*/
7719 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7720 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007721
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307722 if (pAdapter == NULL)
7723 {
7724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7725 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307726 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307727 }
7728 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7729 if (pMac == NULL)
7730 {
7731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7732 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307733 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307734 }
7735 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7736 }
7737 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307738 case WE_DUMP_ROAM_TIMER_LOG:
7739 {
7740 vos_dump_roam_time_log_service();
7741 break;
7742 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307743
Mukul Sharma84f27252014-07-14 18:11:42 +05307744 case WE_RESET_ROAM_TIMER_LOG:
7745 {
7746 vos_reset_roam_timer_log();
7747 break;
7748 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307749 case WE_GET_FW_LOGS:
7750 {
7751 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7752 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307753 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307754 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307755 break;
7756 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307757 case WE_GET_FW_MEMDUMP:
7758 {
7759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7760 "FW_MEM_DUMP requested ");
7761 get_fwr_memdump(dev,info,wrqu,extra);
7762 break;
7763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007764 default:
7765 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007766 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007767 break;
7768 }
7769 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307770 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007771 return ret;
7772}
7773
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307774static int iw_setnone_getnone(struct net_device *dev,
7775 struct iw_request_info *info,
7776 union iwreq_data *wrqu, char *extra)
7777{
7778 int ret;
7779
7780 vos_ssr_protect(__func__);
7781 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7782 vos_ssr_unprotect(__func__);
7783
7784 return ret;
7785}
7786
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307787void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7788{
7789 /*
7790 * Function to display HDD WMM information
7791 * for Tx Queues.
7792 * Prints globala as well as per client depending
7793 * whether the clients are registered or not.
7794 */
7795 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307796 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7797 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307798 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7799 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307800 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307801
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307802 for ( i=0; i< NUM_TX_QUEUES; i++)
7803 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307804 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307805 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307806 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307807 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307808
7809 for ( i=0; i< NUM_TX_QUEUES; i++) {
7810 if (tx_queue_count[i]) {
7811 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7812 i, tx_queue_count[i]);
7813 }
7814 }
7815
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307816 if(pSapCtx == NULL){
7817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7818 FL("psapCtx is NULL"));
7819 return;
7820 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307821
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307822 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307823 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7824 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307825 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307826 {
7827 hddLog(LOGE, "******STAIndex: %d*********", i);
7828 for ( j=0; j< NUM_TX_QUEUES; j++)
7829 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307830 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7831 {
7832 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307833 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7834 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307835 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7836 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307837 }
7838 }
7839 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307840 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307841
Katya Nigam1fd24402015-02-16 14:52:19 +05307842 if(pHddStaCtx == NULL){
7843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7844 FL("pHddStaCtx is NULL"));
7845 return;
7846 }
7847
7848 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7849 if(pPeerInfo == NULL){
7850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7851 FL("ppeerinfo is NULL"));
7852 return;
7853 }
7854
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307855 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7856 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7857 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7858 for (j = 0; j < NUM_TX_QUEUES; j++) {
7859 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7860 spin_lock_bh(
7861 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7862 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07007863 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%pK, NextAddress:%pK",
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307864 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7865 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7866 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7867 spin_unlock_bh(
7868 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7869 }
7870 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307871 }
7872 }
7873
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307874}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307875
Girish Gowlifb9758e2014-11-19 15:19:17 +05307876static int __iw_set_var_ints_getnone(struct net_device *dev,
7877 struct iw_request_info *info,
7878 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007879{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307880 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307881 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307882 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307883 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007884 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307885 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307886 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007887 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307888 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007889 int cmd = 0;
7890 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307891 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007892
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307893 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307894 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307895 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7897 "%s: NULL extra buffer pointer", __func__);
7898 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307899 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307900 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7901 if (NULL == pAdapter)
7902 {
7903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7904 "%s: Adapter is NULL",__func__);
7905 return -EINVAL;
7906 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307907 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307908 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7909 ret = wlan_hdd_validate_context(pHddCtx);
7910 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007911 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307912 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007913 }
Katya Nigameae74b62015-05-28 17:19:16 +05307914 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307915 {
Katya Nigameae74b62015-05-28 17:19:16 +05307916 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7917 if (NULL == hHal)
7918 {
7919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7920 "%s: Hal Context is NULL",__func__);
7921 return -EINVAL;
7922 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307923 }
7924 sub_cmd = wrqu->data.flags;
7925
7926 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7927
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007928
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007929 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7930 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7931 {
7932 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7933 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7934 {
7935 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7936 staId = pStaCtx->conn_info.staId[0];
7937 }
7938 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7939 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7940 {
7941 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7942 staId = pAPCtx->uBCStaId;
7943 }
7944 else
7945 {
7946 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7947 return 0;
7948 }
7949 }
7950
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 switch (sub_cmd)
7952 {
7953 case WE_LOG_DUMP_CMD:
7954 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307955 if(apps_args[0] == 26) {
7956 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7957 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7958 return 0;
7959 }
7960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007961 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007962 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007963 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307964 if (hHal)
7965 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7966 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007967
7968 }
7969 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307970#ifdef WLAN_FEATURE_RMC
7971 case WE_IBSS_GET_PEER_INFO:
7972 {
7973 pr_info ( "Station ID = %d\n",apps_args[0]);
7974 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7975 }
7976 break;
7977#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007978
Jeff Johnson295189b2012-06-20 16:38:30 -07007979 case WE_P2P_NOA_CMD:
7980 {
7981 p2p_app_setP2pPs_t p2pNoA;
7982
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307983 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7984 hddLog(LOGE,
7985 FL("Setting NoA is not allowed in Device mode:%d"),
7986 pAdapter->device_mode);
7987 return -EINVAL;
7988 }
7989
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 p2pNoA.opp_ps = apps_args[0];
7991 p2pNoA.ctWindow = apps_args[1];
7992 p2pNoA.duration = apps_args[2];
7993 p2pNoA.interval = apps_args[3];
7994 p2pNoA.count = apps_args[4];
7995 p2pNoA.single_noa_duration = apps_args[5];
7996 p2pNoA.psSelection = apps_args[6];
7997
7998 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7999 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008000 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
8002
8003 hdd_setP2pPs(dev, &p2pNoA);
8004
8005 }
8006 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008007
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308008 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8009 {
8010 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
8011 __func__, apps_args[0], apps_args[1]);
8012 vosTraceEnable(apps_args[0], apps_args[1]);
8013 }
8014 break;
8015
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008016 case WE_MTRACE_DUMP_CMD:
8017 {
8018 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
8019 "bitmask_of_module %d ",
8020 __func__, apps_args[0], apps_args[1], apps_args[2],
8021 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308022 if (hHal)
8023 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
8024 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008025
8026 }
8027 break;
8028
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008029 case WE_MCC_CONFIG_CREDENTIAL :
8030 {
8031 cmd = 287; //Command should be updated if there is any change
8032 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08008033 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008034 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308035 if (hHal)
8036 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
8037 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008038 }
8039 else
8040 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008041 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008042 return 0;
8043 }
8044 }
8045 break;
8046
8047 case WE_MCC_CONFIG_PARAMS :
8048 {
8049 cmd = 288; //command Should be updated if there is any change
8050 // in the Riva dump command
8051 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
8052 }
8053 break;
8054
Chilam NG571c65a2013-01-19 12:27:36 +05308055#ifdef FEATURE_WLAN_TDLS
8056 case WE_TDLS_CONFIG_PARAMS :
8057 {
8058 tdls_config_params_t tdlsParams;
8059
Chilam Ng01120412013-02-19 18:32:21 -08008060 tdlsParams.tdls = apps_args[0];
8061 tdlsParams.tx_period_t = apps_args[1];
8062 tdlsParams.tx_packet_n = apps_args[2];
8063 tdlsParams.discovery_period_t = apps_args[3];
8064 tdlsParams.discovery_tries_n = apps_args[4];
8065 tdlsParams.idle_timeout_t = apps_args[5];
8066 tdlsParams.idle_packet_n = apps_args[6];
8067 tdlsParams.rssi_hysteresis = apps_args[7];
8068 tdlsParams.rssi_trigger_threshold = apps_args[8];
8069 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05308070
Chilam Ng01120412013-02-19 18:32:21 -08008071 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05308072 }
8073 break;
8074#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05308075 case WE_CONFIGURE_MONITOR_MODE:
8076 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308077 v_U32_t magic = 0;
8078 struct completion cmpVar;
8079 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308080 tVOS_CON_MODE mode = hdd_get_conparam();
8081
8082 if (VOS_MONITOR_MODE != mode) {
8083 hddLog(LOGE, FL("invalid mode %d"), mode);
8084 return -EIO;
8085 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308086
Katya Nigamf0511f62015-05-05 16:40:57 +05308087 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8088 if( pMonCtx == NULL )
8089 {
8090 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308091 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308092 }
8093 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
8094 __func__, apps_args[0], apps_args[1], apps_args[2],
8095 apps_args[3], apps_args[4]);
8096 /* Input Validation part of FW */
8097 pMonCtx->ChannelNo = apps_args[0];
8098 pMonCtx->ChannelBW = apps_args[1];
8099 pMonCtx->crcCheckEnabled = apps_args[2];
8100 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
8101 pMonCtx->is80211to803ConReq = apps_args[4];
8102 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
8103 if( pMonCtx->is80211to803ConReq )
8104 pAdapter->dev->type = ARPHRD_ETHER;
8105 else
8106 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
8107 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
8108 {
8109 hddLog(LOGE, "%s: Filtering data packets as management and control"
8110 " cannot be converted to 802.3 ",__func__);
8111 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
8112 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308113 if (MON_MODE_START == pMonCtx->state) {
8114 magic = MON_MODE_MSG_MAGIC;
8115 init_completion(&cmpVar);
8116 if (VOS_STATUS_SUCCESS !=
8117 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8118 pMonCtx, hdd_monPostMsgCb)) {
8119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8120 FL("failed to post MON MODE REQ"));
8121 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308122 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308123 }
8124 waitRet = wait_for_completion_timeout(&cmpVar,
8125 MON_MODE_MSG_TIMEOUT);
8126 magic = 0;
8127 if (waitRet <= 0 ) {
8128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8129 FL("failed to wait on monitor mode completion %ld"),
8130 waitRet);
8131 }
8132 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308133 }
8134 break;
8135
8136 case WE_SET_MONITOR_MODE_FILTER:
8137 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308138 v_U32_t magic = 0;
8139 struct completion cmpVar;
8140 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308141 tVOS_CON_MODE mode = hdd_get_conparam();
8142
8143 if (VOS_MONITOR_MODE != mode) {
8144 hddLog(LOGE, FL("invalid mode %d"), mode);
8145 return -EIO;
8146 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308147
Katya Nigamf0511f62015-05-05 16:40:57 +05308148 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8149 if( pMonCtx == NULL )
8150 {
8151 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308152 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308153 }
8154 /* Input Validation Part of FW */
8155 pMonCtx->numOfMacFilters=1;
8156 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8157 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8158 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8159 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8160 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8161 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8162 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8163 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8164 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8165 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8166 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8167 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308168 if (MON_MODE_START == pMonCtx->state) {
8169 magic = MON_MODE_MSG_MAGIC;
8170 init_completion(&cmpVar);
8171 if (VOS_STATUS_SUCCESS !=
8172 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8173 pMonCtx, hdd_monPostMsgCb)) {
8174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8175 FL("failed to post MON MODE REQ"));
8176 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308177 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308178 }
8179 waitRet = wait_for_completion_timeout(&cmpVar,
8180 MON_MODE_MSG_TIMEOUT);
8181 magic = 0;
8182 if (waitRet <= 0 ) {
8183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8184 FL("failed to wait on monitor mode completion %ld"),
8185 waitRet);
8186 }
8187 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308188 }
8189 break;
8190
Jeff Johnson295189b2012-06-20 16:38:30 -07008191 default:
8192 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008193 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8194 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008195 }
8196 break;
8197 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308198 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 return 0;
8200}
8201
Girish Gowlifb9758e2014-11-19 15:19:17 +05308202static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8203 struct iw_request_info *info,
8204 union iwreq_data *wrqu, char *extra)
8205{
8206 int ret;
8207 union iwreq_data u_priv_wrqu;
8208 int apps_args[MAX_VAR_ARGS] = {0};
8209 int num_args;
8210
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308211 if (!capable(CAP_NET_ADMIN))
8212 {
8213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8214 FL("permission check failed"));
8215 return -EPERM;
8216 }
8217
Girish Gowlifb9758e2014-11-19 15:19:17 +05308218 /* helper function to get iwreq_data with compat handling. */
8219 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8220 {
8221 return -EINVAL;
8222 }
8223
8224 if (NULL == u_priv_wrqu.data.pointer)
8225 {
8226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8227 "%s: NULL data pointer", __func__);
8228 return -EINVAL;
8229 }
8230
8231 num_args = u_priv_wrqu.data.length;
8232 if (num_args > MAX_VAR_ARGS)
8233 {
8234 num_args = MAX_VAR_ARGS;
8235 }
8236
8237 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8238 (sizeof(int)) * num_args))
8239 {
8240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8241 "%s: failed to copy data from user buffer", __func__);
8242 return -EFAULT;
8243 }
8244
8245 vos_ssr_protect(__func__);
8246 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8247 (char *)&apps_args);
8248 vos_ssr_unprotect(__func__);
8249
8250 return ret;
8251}
8252
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308253int iw_set_var_ints_getnone(struct net_device *dev,
8254 struct iw_request_info *info,
8255 union iwreq_data *wrqu, char *extra)
8256{
8257 int ret;
8258 vos_ssr_protect(__func__);
8259 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8260 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008261
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308262 return ret;
8263}
8264
8265static int __iw_add_tspec(struct net_device *dev,
8266 struct iw_request_info *info,
8267 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008268{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308269 hdd_adapter_t *pAdapter;
8270 hdd_station_ctx_t *pHddStaCtx;
8271 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8273 int params[HDD_WLAN_WMM_PARAM_COUNT];
8274 sme_QosWmmTspecInfo tSpec;
8275 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308276 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308277 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008278
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308279 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308280 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8281 if (NULL == pAdapter)
8282 {
8283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8284 "%s: Adapter is NULL",__func__);
8285 return -EINVAL;
8286 }
8287 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8288 ret = wlan_hdd_validate_context(pHddCtx);
8289 if (0 != ret)
8290 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308291 return ret;
8292 }
8293 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8294 if (NULL == pHddStaCtx)
8295 {
8296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8297 "%s: STA Context is NULL",__func__);
8298 return -EINVAL;
8299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008300 // make sure the application is sufficiently priviledged
8301 // note that the kernel will do this for "set" ioctls, but since
8302 // this ioctl wants to return status to user space it must be
8303 // defined as a "get" ioctl
8304 if (!capable(CAP_NET_ADMIN))
8305 {
8306 return -EPERM;
8307 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 // we must be associated in order to add a tspec
8309 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8310 {
8311 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8312 return 0;
8313 }
8314
8315 // since we are defined to be a "get" ioctl, and since the number
8316 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308317 // will pass down in the iwreq_data, we must copy the "set" params.
8318 // We must handle the compat for iwreq_data in 32U/64K environment.
8319
8320 // helper fucntion to get iwreq_data with compat handling.
8321 if (hdd_priv_get_data(&s_priv_data, wrqu))
8322 {
8323 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8324 return 0;
8325 }
8326
8327 // make sure all params are correctly passed to function
8328 if ((NULL == s_priv_data.pointer) ||
8329 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8330 {
8331 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8332 return 0;
8333 }
8334
Jeff Johnson295189b2012-06-20 16:38:30 -07008335 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308336 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 {
8338 // hmmm, can't get them
8339 return -EIO;
8340 }
8341
8342 // clear the tspec
8343 memset(&tSpec, 0, sizeof(tSpec));
8344
8345 // validate the handle
8346 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8347 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8348 {
8349 // that one is reserved
8350 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8351 return 0;
8352 }
8353
8354 // validate the TID
8355 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8356 {
8357 // out of range
8358 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8359 return 0;
8360 }
8361 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8362
8363 // validate the direction
8364 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8365 {
8366 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8367 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8368 break;
8369
8370 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8371 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8372 break;
8373
8374 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8375 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8376 break;
8377
8378 default:
8379 // unknown
8380 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8381 return 0;
8382 }
8383
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308384 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8385
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 // validate the user priority
8387 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8388 {
8389 // out of range
8390 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8391 return 0;
8392 }
8393 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308394 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8395 {
8396 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8397 return 0;
8398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008399
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8401 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8402 tSpec.ts_info.psb, tSpec.ts_info.up);
8403
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8405 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8406 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8407 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8408 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8409 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8410 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8411 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8412 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8413 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8414 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8415 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8416
8417 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8418
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308419 // Save the expected UAPSD settings by application, this will be needed
8420 // when re-negotiating UAPSD settings during BT Coex cases.
8421 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8422
Jeff Johnson295189b2012-06-20 16:38:30 -07008423 // validate the ts info ack policy
8424 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8425 {
8426 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8427 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8428 break;
8429
8430 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8431 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8432 break;
8433
8434 default:
8435 // unknown
8436 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8437 return 0;
8438 }
8439
8440 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308441
8442 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 return 0;
8444}
8445
8446
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308447static int iw_add_tspec(struct net_device *dev,
8448 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 union iwreq_data *wrqu, char *extra)
8450{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308451 int ret;
8452
8453 vos_ssr_protect(__func__);
8454 ret = __iw_add_tspec(dev, info, wrqu, extra);
8455 vos_ssr_unprotect(__func__);
8456
8457 return ret;
8458}
8459
8460static int __iw_del_tspec(struct net_device *dev,
8461 struct iw_request_info *info,
8462 union iwreq_data *wrqu, char *extra)
8463{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308464 hdd_adapter_t *pAdapter;
8465 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 int *params = (int *)extra;
8467 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8468 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308469 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008470
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308471 ENTER();
8472
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308473 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8474 if (NULL == pAdapter)
8475 {
8476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8477 "%s: Adapter is NULL",__func__);
8478 return -EINVAL;
8479 }
8480
8481 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8482 ret = wlan_hdd_validate_context(pHddCtx);
8483 if (0 != ret)
8484 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308485 return ret;
8486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 // make sure the application is sufficiently priviledged
8488 // note that the kernel will do this for "set" ioctls, but since
8489 // this ioctl wants to return status to user space it must be
8490 // defined as a "get" ioctl
8491 if (!capable(CAP_NET_ADMIN))
8492 {
8493 return -EPERM;
8494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 // although we are defined to be a "get" ioctl, the params we require
8496 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8497 // is no need to copy the params from user space
8498
8499 // validate the handle
8500 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8501 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8502 {
8503 // that one is reserved
8504 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8505 return 0;
8506 }
8507
8508 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308509
8510 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 return 0;
8512}
8513
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308514static int iw_del_tspec(struct net_device *dev,
8515 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008516 union iwreq_data *wrqu, char *extra)
8517{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308518 int ret;
8519
8520 vos_ssr_protect(__func__);
8521 ret = __iw_del_tspec(dev, info, wrqu, extra);
8522 vos_ssr_unprotect(__func__);
8523
8524 return ret;
8525}
8526
8527
8528static int __iw_get_tspec(struct net_device *dev,
8529 struct iw_request_info *info,
8530 union iwreq_data *wrqu, char *extra)
8531{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308532 hdd_adapter_t *pAdapter;
8533 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008534 int *params = (int *)extra;
8535 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8536 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308537 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008538
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308539 ENTER();
8540
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 // although we are defined to be a "get" ioctl, the params we require
8542 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8543 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308544 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8545 if (NULL == pAdapter)
8546 {
8547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8548 "%s: Adapter is NULL",__func__);
8549 return -EINVAL;
8550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008551
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308552 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8553 ret = wlan_hdd_validate_context(pHddCtx);
8554 if (0 != ret)
8555 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308556 return ret;
8557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008558 // validate the handle
8559 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8560 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8561 {
8562 // that one is reserved
8563 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8564 return 0;
8565 }
8566
8567 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308568 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 return 0;
8570}
8571
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308572static int iw_get_tspec(struct net_device *dev,
8573 struct iw_request_info *info,
8574 union iwreq_data *wrqu, char *extra)
8575{
8576 int ret;
8577
8578 vos_ssr_protect(__func__);
8579 ret = __iw_get_tspec(dev, info, wrqu, extra);
8580 vos_ssr_unprotect(__func__);
8581
8582 return ret;
8583}
8584
Manjeet Singh3ed79242017-01-11 19:04:32 +05308585/**
8586 * __iw_setnone_get_threeint() - return three value to up layer.
8587 *
8588 * @dev: pointer of net_device of this wireless card
8589 * @info: meta data about Request sent
8590 * @wrqu: include request info
8591 * @extra: buf used for in/Output
8592 *
8593 * Return: execute result
8594 */
8595static int __iw_setnone_get_threeint(struct net_device *dev,
8596 struct iw_request_info *info,
8597 union iwreq_data *wrqu, char *extra)
8598{
8599 int ret = 0; /* success */
8600 uint32_t *value = (int *)extra;
8601 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8602
8603 hddLog(VOS_TRACE_LEVEL_INFO, FL("param = %d"), value[0]);
8604
8605 switch (value[0]) {
8606 case WE_GET_TSF:
8607 ret = hdd_indicate_tsf(adapter, value, 3);
8608 break;
8609 default:
8610 hddLog(VOS_TRACE_LEVEL_ERROR,
8611 FL("Invalid IOCTL get_value command %d"),
8612 value[0]);
8613 break;
8614 }
8615 return ret;
8616}
8617
8618/**
8619 * iw_setnone_get_threeint() - return three value to up layer.
8620 *
8621 * @dev: pointer of net_device of this wireless card
8622 * @info: meta data about Request sent
8623 * @wrqu: include request info
8624 * @extra: buf used for in/Output
8625 *
8626 * Return: execute result
8627 */
8628static int iw_setnone_get_threeint(struct net_device *dev,
8629 struct iw_request_info *info,
8630 union iwreq_data *wrqu, char *extra)
8631{
8632 int ret;
8633
8634 vos_ssr_protect(__func__);
8635 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8636 vos_ssr_unprotect(__func__);
8637
8638 return ret;
8639}
8640
Jeff Johnson295189b2012-06-20 16:38:30 -07008641#ifdef WLAN_FEATURE_VOWIFI_11R
8642//
8643//
8644// Each time the supplicant has the auth_request or reassoc request
8645// IEs ready. This is pushed to the driver. The driver will inturn use
8646// it to send out the auth req and reassoc req for 11r FT Assoc.
8647//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308648static int __iw_set_fties(struct net_device *dev,
8649 struct iw_request_info *info,
8650 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008651{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308652 hdd_adapter_t *pAdapter;
8653 hdd_station_ctx_t *pHddStaCtx;
8654 hdd_context_t *pHddCtx;
8655 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 //v_CONTEXT_t pVosContext;
8657
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308658 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308659 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8660 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008661 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8663 "%s: Adapter is NULL",__func__);
8664 return -EINVAL;
8665 }
8666 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8667 ret = wlan_hdd_validate_context(pHddCtx);
8668 if (0 != ret)
8669 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308670 return ret;
8671 }
8672 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8673 if (NULL == pHddStaCtx)
8674 {
8675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8676 "%s: STA Context is NULL",__func__);
8677 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008679 if (!wrqu->data.length)
8680 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008681 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 return -EINVAL;
8683 }
8684 if (wrqu->data.pointer == NULL)
8685 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008686 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 return -EINVAL;
8688 }
8689
8690 // Added for debug on reception of Re-assoc Req.
8691 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8692 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008693 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008694 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008695 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 }
8697
8698#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008699 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008700#endif
8701
8702 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008703 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008704 wrqu->data.length);
8705
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308706 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 return 0;
8708}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308709
8710static int iw_set_fties(struct net_device *dev,
8711 struct iw_request_info *info,
8712 union iwreq_data *wrqu, char *extra)
8713{
8714 int ret;
8715
8716 vos_ssr_protect(__func__);
8717 ret = __iw_set_fties(dev, info, wrqu, extra);
8718 vos_ssr_unprotect(__func__);
8719
8720 return ret;
8721}
Jeff Johnson295189b2012-06-20 16:38:30 -07008722#endif
8723
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308724static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008725 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008727{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308728 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008729 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308730 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008731 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308732 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008733 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8734 int idx;
8735 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008736
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308737 ENTER();
8738
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308739 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8740 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008741 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8743 "%s: Adapter is NULL",__func__);
8744 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008745 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308746 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8747 ret_val = wlan_hdd_validate_context(pHddCtx);
8748 if (0 != ret_val)
8749 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308750 return ret_val;
8751 }
8752 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8753 if (NULL == hHal)
8754 {
8755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8756 "%s: Hal Context is NULL",__func__);
8757 return -EINVAL;
8758 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308759 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8760 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308761#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008762
Amar Singhalf3a6e762013-02-19 15:06:50 -08008763 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8764 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008765 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008766 hddLog(VOS_TRACE_LEVEL_ERROR,
8767 "%s: vos_mem_alloc failed", __func__);
8768 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008769 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008770
8771 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8772
8773 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8774 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8775
8776 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8777 mc_addr_list_ptr->ulMulticastAddrCnt);
8778
8779 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008780 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008781 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8782 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8783
8784 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8785 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008786 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008787
Amar Singhalf3a6e762013-02-19 15:06:50 -08008788 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8789 vos_mem_free(mc_addr_list_ptr);
8790 if (eHAL_STATUS_SUCCESS != ret_val)
8791 {
8792 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8793 __func__);
8794 return -EINVAL;
8795 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308796#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308797 }
8798 else
8799 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008800
Amar Singhalf3a6e762013-02-19 15:06:50 -08008801 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8802 "%s: Set MC BC Filter Config request: %d suspend %d",
8803 __func__, pRequest->mcastBcastFilterSetting,
8804 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308805 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308806 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308807 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008808
8809 if (pHddCtx->hdd_wlan_suspended)
8810 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008811 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8812 if (NULL == wlanRxpFilterParam)
8813 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308814 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008815 "%s: vos_mem_alloc failed", __func__);
8816 return -EINVAL;
8817 }
8818
Amar Singhalf3a6e762013-02-19 15:06:50 -08008819 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8820 pRequest->mcastBcastFilterSetting;
8821 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308822 /* Fwr expect offload needs to clear before set */
8823 hdd_conf_hostoffload(pAdapter, FALSE);
8824 spin_lock(&pHddCtx->filter_lock);
8825 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
8826 spin_unlock(&pHddCtx->filter_lock);
8827 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8828 {
8829 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
8830 pHddCtx->sus_res_mcastbcast_filter =
8831 pRequest->mcastBcastFilterSetting;
8832 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008833
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308834 hdd_conf_hostoffload(pAdapter, TRUE);
8835 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8836 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008837
8838 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8839 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308840 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008841 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8842 wlanRxpFilterParam->setMcstBcstFilter);
8843
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308844 if (eHAL_STATUS_SUCCESS !=
8845 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8846 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008847 {
8848 hddLog(VOS_TRACE_LEVEL_ERROR,
8849 "%s: Failure to execute set HW MC/BC Filter request",
8850 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008851 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008852 return -EINVAL;
8853 }
8854
mukul sharmae4abd892016-11-24 22:03:31 +05308855 /* mc add list cfg item configuration in fwr */
8856 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008857 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008859
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308860 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008861 return 0;
8862}
8863
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308864static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8865 struct iw_request_info *info,
8866 union iwreq_data *wrqu, char *extra)
8867{
8868 int ret;
8869
8870 vos_ssr_protect(__func__);
8871 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8872 vos_ssr_unprotect(__func__);
8873
8874 return ret;
8875}
8876
8877static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8878 struct iw_request_info *info,
8879 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008880{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308881 hdd_adapter_t *pAdapter;
8882 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308883 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308884 int ret = 0;
8885
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308886 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008887
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308888 if (!capable(CAP_NET_ADMIN))
8889 {
8890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8891 FL("permission check failed"));
8892 return -EPERM;
8893 }
8894
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308895 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8896 if (NULL == pAdapter)
8897 {
8898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8899 "%s: Adapter is NULL",__func__);
8900 return -EINVAL;
8901 }
8902
8903 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8904 ret = wlan_hdd_validate_context(pHddCtx);
8905 if (0 != ret)
8906 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308907 return ret;
8908 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308909 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308910 //Reset the filter to INI value as we have to clear the dynamic filter
8911 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308912 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008913
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308914 //Configure FW with new setting
8915 if (pHddCtx->hdd_wlan_suspended)
8916 {
8917 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8918 if (NULL == wlanRxpFilterParam)
8919 {
8920 hddLog(VOS_TRACE_LEVEL_ERROR,
8921 "%s: vos_mem_alloc failed", __func__);
8922 return -EINVAL;
8923 }
8924
8925 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8926 pHddCtx->configuredMcastBcastFilter;
8927 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308928 /* Fwr expect offload needs to clear before set */
8929 hdd_conf_hostoffload(pAdapter, FALSE);
8930 spin_lock(&pHddCtx->filter_lock);
8931 pHddCtx->configuredMcastBcastFilter =
8932 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8933 spin_unlock(&pHddCtx->filter_lock);
8934
8935 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8936 {
8937 pHddCtx->sus_res_mcastbcast_filter =
8938 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8939 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308940
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308941 hdd_conf_hostoffload(pAdapter, TRUE);
8942 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8943 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308944 if (eHAL_STATUS_SUCCESS !=
8945 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8946 wlanRxpFilterParam))
8947 {
8948 hddLog(VOS_TRACE_LEVEL_ERROR,
8949 "%s: Failure to execute set HW MC/BC Filter request",
8950 __func__);
8951 vos_mem_free(wlanRxpFilterParam);
8952 return -EINVAL;
8953 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308954
mukul sharmae4abd892016-11-24 22:03:31 +05308955 /* mc add list cfg item configuration in fwr */
8956 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308957 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308958 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008959 return 0;
8960}
8961
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308962
8963static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8964 struct iw_request_info *info,
8965 union iwreq_data *wrqu, char *extra)
8966{
8967 int ret;
8968
8969 vos_ssr_protect(__func__);
8970 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8971 vos_ssr_unprotect(__func__);
8972
8973 return ret;
8974}
8975
8976static int __iw_set_host_offload(struct net_device *dev,
8977 struct iw_request_info *info,
8978 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008979{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308980 hdd_adapter_t *pAdapter;
8981 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008982 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008983 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308984 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008985
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308986 ENTER();
8987
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308988 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8989 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008990 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8992 "%s: Adapter is NULL",__func__);
8993 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008994 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308995 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8996 ret = wlan_hdd_validate_context(pHddCtx);
8997 if (0 != ret)
8998 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308999 return ret;
9000 }
9001
Jeff Johnson295189b2012-06-20 16:38:30 -07009002 /* Debug display of request components. */
9003 switch (pRequest->offloadType)
9004 {
9005 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009006 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009007 switch (pRequest->enableOrDisable)
9008 {
9009 case WLAN_OFFLOAD_DISABLE:
9010 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
9011 break;
9012 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
9013 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
9014 case WLAN_OFFLOAD_ENABLE:
9015 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
9016 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
9017 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
9018 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
9019 }
9020 break;
9021
9022 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08009023 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009024 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009025 switch (pRequest->enableOrDisable)
9026 {
9027 case WLAN_OFFLOAD_DISABLE:
9028 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
9029 break;
9030 case WLAN_OFFLOAD_ENABLE:
9031 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
9032 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
9033 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
9034 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
9035 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
9036 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
9037 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
9038 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
9039 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
9040 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
9041 }
9042 }
9043
9044 /* Execute offload request. The reason that we can copy the request information
9045 from the ioctl structure to the SME structure is that they are laid out
9046 exactly the same. Otherwise, each piece of information would have to be
9047 copied individually. */
9048 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07009049 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
9050 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009052 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07009053 __func__);
9054 return -EINVAL;
9055 }
9056
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309057 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009058 return 0;
9059}
9060
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309061static int iw_set_host_offload(struct net_device *dev,
9062 struct iw_request_info *info,
9063 union iwreq_data *wrqu, char *extra)
9064{
9065 int ret;
9066
9067 vos_ssr_protect(__func__);
9068 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9069 vos_ssr_unprotect(__func__);
9070
9071 return ret;
9072}
9073
9074static int __iw_set_keepalive_params(struct net_device *dev,
9075 struct iw_request_info *info,
9076 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009077{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309078 hdd_adapter_t *pAdapter;
9079 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08009080 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009081 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309082 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009083
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309084 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309085 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9086 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9089 "%s: Adapter is NULL",__func__);
9090 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009091 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309092 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9093 ret = wlan_hdd_validate_context(pHddCtx);
9094 if (0 != ret)
9095 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309096 return ret;
9097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009098 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08009099 hddLog(VOS_TRACE_LEVEL_INFO,
9100 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
9101 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07009102
9103 switch (pRequest->packetType)
9104 {
9105 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009106 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009107 break;
9108
9109 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
9110
Arif Hussain6d2a3322013-11-17 19:50:10 -08009111 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009112 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009113
9114 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
9115 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
9116 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
9117
9118 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
9119 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
9120 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
9121
9122 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
9123 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
9124 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
9125 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
9126 break;
9127
9128 }
9129
9130 /* Execute keep alive request. The reason that we can copy the request information
9131 from the ioctl structure to the SME structure is that they are laid out
9132 exactly the same. Otherwise, each piece of information would have to be
9133 copied individually. */
9134 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
9135
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05309136 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
9137 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07009138
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009139 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07009140 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009142 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 __func__);
9144 return -EINVAL;
9145 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309146 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009147 return 0;
9148}
9149
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309150static int iw_set_keepalive_params(struct net_device *dev,
9151 struct iw_request_info *info,
9152 union iwreq_data *wrqu, char *extra)
9153{
9154 int ret;
9155 vos_ssr_protect(__func__);
9156 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9157 vos_ssr_unprotect(__func__);
9158
9159 return ret;
9160}
9161
Jeff Johnson295189b2012-06-20 16:38:30 -07009162#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309163/**-----------------------------------------------------------------
9164
9165 \brief hdd_pkt_filter_done - callback to be executed on completion
9166 successful/failure) for clear filter request.
9167
9168 \return - None
9169
9170 --------------------------------------------------------------------------*/
9171static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009172{
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309173 struct statsContext *cbCtx = (struct statsContext *)data;
9174
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309175 hddLog(VOS_TRACE_LEVEL_INFO,
9176 FL("Pkt Filter Clear Status : %d"), status);
9177
9178 if (data == NULL)
9179 {
9180 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context"));
9181 return;
9182 }
9183
9184 spin_lock(&hdd_context_lock);
9185 if (cbCtx->magic != CLEAR_FILTER_MAGIC)
9186 {
9187 spin_unlock(&hdd_context_lock);
9188 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context, magic %x"), cbCtx->magic);
9189 if (ioctl_debug)
9190 {
9191 pr_info("%s: Invalid context, magic [%08x]\n",
9192 __func__, cbCtx->magic);
9193 }
9194 return;
9195 }
9196
9197 complete(&cbCtx->completion);
9198 spin_unlock(&hdd_context_lock);
9199}
9200
9201int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9202{
9203 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309204 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009205 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9206 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309207 struct statsContext cbCtx;
9208 int i=0, status;
9209
9210 status = wlan_hdd_validate_context(pHddCtx);
9211 if (0 != status)
9212 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009213
9214 if (pHddCtx->cfg_ini->disablePacketFilter)
9215 {
9216 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009217 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009218 return 0;
9219 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309220 if (pHddCtx->isLogpInProgress)
9221 {
9222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9223 "%s:LOGP in Progress. Ignore!!!", __func__);
9224 return -EBUSY;
9225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 /* Debug display of request components. */
9227 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009228 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009229
9230 switch (pRequest->filterAction)
9231 {
9232 case HDD_RCV_FILTER_SET:
9233 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009234 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009235
9236 packetFilterSetReq.filterId = pRequest->filterId;
9237 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9238 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009239 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009240 __func__, pRequest->numParams);
9241 return -EINVAL;
9242 }
9243 packetFilterSetReq.numFieldParams = pRequest->numParams;
9244 packetFilterSetReq.coalesceTime = 0;
9245 packetFilterSetReq.filterType = 1;
9246 for (i=0; i < pRequest->numParams; i++)
9247 {
9248 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9249 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9250 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9251 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9252 packetFilterSetReq.paramsData[i].reserved = 0;
9253
Arif Hussain6d2a3322013-11-17 19:50:10 -08009254 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9256 packetFilterSetReq.filterType);
9257
Arif Hussain6d2a3322013-11-17 19:50:10 -08009258 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309260 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9261 (pRequest->paramsData[i].dataLength))
9262 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009263
9264 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9265 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9266 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9267 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9268
Arif Hussain6d2a3322013-11-17 19:50:10 -08009269 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009270 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9271 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9272 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9273
Arif Hussain6d2a3322013-11-17 19:50:10 -08009274 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009275 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9276 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9277 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9278 }
9279
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309280 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009282 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009283 __func__);
9284 return -EINVAL;
9285 }
9286
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309287 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9288 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009289 break;
9290
9291 case HDD_RCV_FILTER_CLEAR:
9292
Arif Hussain6d2a3322013-11-17 19:50:10 -08009293 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009294 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309295
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309296 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9297 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9298 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9299 pHddStaCtx->conn_info.staId[0]);
9300 }
9301
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309302 init_completion(&cbCtx.completion);
9303 cbCtx.magic = CLEAR_FILTER_MAGIC;
9304 cbCtx.pAdapter = pAdapter;
9305 packetFilterClrReq.cbCtx = &cbCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009306 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309307 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
9308 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009311 __func__);
9312 return -EINVAL;
9313 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309314
9315 status = wait_for_completion_interruptible_timeout(&cbCtx.completion,
9316 msecs_to_jiffies(PKT_FILTER_TIMEOUT));
9317 spin_lock(&hdd_context_lock);
9318 cbCtx.magic = 0;
9319 spin_unlock(&hdd_context_lock);
9320 if (0 >= status)
9321 {
9322 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9323 status);
9324 return -EINVAL;
9325 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309326
9327 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9328 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009329 break;
9330
9331 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009332 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009333 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 return -EINVAL;
9335 }
9336 return 0;
9337}
9338
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309339int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9340 tANI_U8 sessionId)
9341{
9342 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9343 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9344
9345 if (NULL == pHddCtx)
9346 {
9347 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9348 return -EINVAL;
9349 }
9350
9351 if (pHddCtx->isLogpInProgress)
9352 {
9353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9354 "%s:LOGP in Progress. Ignore!!!", __func__);
9355 return -EBUSY;
9356 }
9357
9358 if (pHddCtx->cfg_ini->disablePacketFilter)
9359 {
9360 hddLog(VOS_TRACE_LEVEL_ERROR,
9361 "%s: Packet Filtering Disabled. Returning ",
9362 __func__ );
9363 return -EINVAL;
9364 }
9365
9366 switch (filterType)
9367 {
9368 /* For setting IPV6 MC and UC Filter we need to configure
9369 * 2 filters, one for MC and one for UC.
9370 * The Filter ID shouldn't be swapped, which results in making
9371 * UC Filter ineffective.
9372 * We have Hardcode all the values
9373 *
9374 * Reason for a seperate UC filter is because, driver need to
9375 * specify the FW that the specific filter is for unicast
9376 * otherwise FW will not pass the unicast frames by default
9377 * through the filter. This is required to avoid any performance
9378 * hits when no unicast filter is set and only MC/BC are set.
9379 * The way driver informs host is by using the MAC protocol
9380 * layer, CMP flag set to MAX, CMP Data set to 1.
9381 */
9382
9383 case HDD_FILTER_IPV6_MC_UC:
9384 /* Setting IPV6 MC Filter below
9385 */
9386 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9387 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9388 packetFilterSetReq.numFieldParams = 2;
9389 packetFilterSetReq.paramsData[0].protocolLayer =
9390 HDD_FILTER_PROTO_TYPE_MAC;
9391 packetFilterSetReq.paramsData[0].cmpFlag =
9392 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9393 packetFilterSetReq.paramsData[0].dataOffset =
9394 WLAN_HDD_80211_FRM_DA_OFFSET;
9395 packetFilterSetReq.paramsData[0].dataLength = 1;
9396 packetFilterSetReq.paramsData[0].compareData[0] =
9397 HDD_IPV6_MC_CMP_DATA;
9398
9399 packetFilterSetReq.paramsData[1].protocolLayer =
9400 HDD_FILTER_PROTO_TYPE_ARP;
9401 packetFilterSetReq.paramsData[1].cmpFlag =
9402 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9403 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9404 packetFilterSetReq.paramsData[1].dataLength = 2;
9405 packetFilterSetReq.paramsData[1].compareData[0] =
9406 HDD_IPV6_CMP_DATA_0;
9407 packetFilterSetReq.paramsData[1].compareData[1] =
9408 HDD_IPV6_CMP_DATA_1;
9409
9410
9411 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9412 &packetFilterSetReq, sessionId))
9413 {
9414 hddLog(VOS_TRACE_LEVEL_ERROR,
9415 "%s: Failure to execute Set IPv6 Mulicast Filter",
9416 __func__);
9417 return -EINVAL;
9418 }
9419
9420 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9421
9422 /*
9423 * Setting IPV6 UC Filter below
9424 */
9425 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9426 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9427 packetFilterSetReq.numFieldParams = 2;
9428 packetFilterSetReq.paramsData[0].protocolLayer =
9429 HDD_FILTER_PROTO_TYPE_MAC;
9430 packetFilterSetReq.paramsData[0].cmpFlag =
9431 HDD_FILTER_CMP_TYPE_MAX;
9432 packetFilterSetReq.paramsData[0].dataOffset = 0;
9433 packetFilterSetReq.paramsData[0].dataLength = 1;
9434 packetFilterSetReq.paramsData[0].compareData[0] =
9435 HDD_IPV6_UC_CMP_DATA;
9436
9437 packetFilterSetReq.paramsData[1].protocolLayer =
9438 HDD_FILTER_PROTO_TYPE_ARP;
9439 packetFilterSetReq.paramsData[1].cmpFlag =
9440 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9441 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9442 packetFilterSetReq.paramsData[1].dataLength = 2;
9443 packetFilterSetReq.paramsData[1].compareData[0] =
9444 HDD_IPV6_CMP_DATA_0;
9445 packetFilterSetReq.paramsData[1].compareData[1] =
9446 HDD_IPV6_CMP_DATA_1;
9447
9448 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9449 &packetFilterSetReq, sessionId))
9450 {
9451 hddLog(VOS_TRACE_LEVEL_ERROR,
9452 "%s: Failure to execute Set IPv6 Unicast Filter",
9453 __func__);
9454 return -EINVAL;
9455 }
9456
9457 break;
9458
9459 case HDD_FILTER_IPV6_MC:
9460 /*
9461 * IPV6 UC Filter might be already set,
9462 * clear the UC Filter. As the Filter
9463 * IDs are static, we can directly clear it.
9464 */
9465 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9466 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9467 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9468 &packetFilterClrReq, sessionId))
9469 {
9470 hddLog(VOS_TRACE_LEVEL_ERROR,
9471 "%s: Failure to execute Clear IPv6 Unicast Filter",
9472 __func__);
9473 return -EINVAL;
9474 }
9475
9476 /*
9477 * Setting IPV6 MC Filter below
9478 */
9479 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9480 packetFilterSetReq.numFieldParams = 2;
9481 packetFilterSetReq.paramsData[0].protocolLayer =
9482 HDD_FILTER_PROTO_TYPE_MAC;
9483 packetFilterSetReq.paramsData[0].cmpFlag =
9484 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9485 packetFilterSetReq.paramsData[0].dataOffset =
9486 WLAN_HDD_80211_FRM_DA_OFFSET;
9487 packetFilterSetReq.paramsData[0].dataLength = 1;
9488 packetFilterSetReq.paramsData[0].compareData[0] =
9489 HDD_IPV6_MC_CMP_DATA;
9490
9491 packetFilterSetReq.paramsData[1].protocolLayer =
9492 HDD_FILTER_PROTO_TYPE_ARP;
9493 packetFilterSetReq.paramsData[1].cmpFlag =
9494 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9495 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9496 packetFilterSetReq.paramsData[1].dataLength = 2;
9497 packetFilterSetReq.paramsData[1].compareData[0] =
9498 HDD_IPV6_CMP_DATA_0;
9499 packetFilterSetReq.paramsData[1].compareData[1] =
9500 HDD_IPV6_CMP_DATA_1;
9501
9502
9503 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9504 &packetFilterSetReq, sessionId))
9505 {
9506 hddLog(VOS_TRACE_LEVEL_ERROR,
9507 "%s: Failure to execute Set IPv6 Multicast Filter",
9508 __func__);
9509 return -EINVAL;
9510 }
9511 break;
9512
9513 default :
9514 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9515 "%s: Packet Filter Request: Invalid",
9516 __func__);
9517 return -EINVAL;
9518 }
9519 return 0;
9520}
9521
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309522void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009523{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309524 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309525 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009526 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309527 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009528
Yue Ma3ede6052013-08-29 00:33:26 -07009529 if (NULL == pHddCtx)
9530 {
9531 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9532 return;
9533 }
9534
9535 hHal = pHddCtx->hHal;
9536
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309537 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309539 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9540 return;
9541 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309542
9543 /* Check if INI is enabled or not, other wise just return
9544 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309545 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309546 {
9547 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9548 if (NULL == pMulticastAddrs)
9549 {
9550 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9551 return;
9552 }
9553
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 if (set)
9555 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309556 /* Following pre-conditions should be satisfied before wei
9557 * configure the MC address list.
9558 */
9559 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9560 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9561 && pAdapter->mc_addr_list.mc_cnt
9562 && (eConnectionState_Associated ==
9563 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9564 {
9565 pMulticastAddrs->ulMulticastAddrCnt =
9566 pAdapter->mc_addr_list.mc_cnt;
9567 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9568 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009569 memcpy(pMulticastAddrs->multicastAddr[i],
9570 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309571 sizeof(pAdapter->mc_addr_list.addr[i]));
9572 hddLog(VOS_TRACE_LEVEL_INFO,
9573 "%s: %s multicast filter: addr ="
9574 MAC_ADDRESS_STR,
9575 __func__, set ? "setting" : "clearing",
9576 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9577 }
9578 /* Set multicast filter */
9579 sme_8023MulticastList(hHal, pAdapter->sessionId,
9580 pMulticastAddrs);
9581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009582 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309583 else
9584 {
9585 /* Need to clear only if it was previously configured
9586 */
9587 if (pAdapter->mc_addr_list.isFilterApplied)
9588 {
9589 pMulticastAddrs->ulMulticastAddrCnt = 0;
9590 sme_8023MulticastList(hHal, pAdapter->sessionId,
9591 pMulticastAddrs);
9592 }
9593
9594 }
9595 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009596 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309598 else
9599 {
9600 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309601 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309602 }
9603 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009604}
9605
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309606static int __iw_set_packet_filter_params(struct net_device *dev,
9607 struct iw_request_info *info,
9608 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309609{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309610 hdd_adapter_t *pAdapter;
9611 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009612 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309613 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309614 struct iw_point s_priv_data;
9615
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309616 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309617
9618 if (!capable(CAP_NET_ADMIN))
9619 {
9620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9621 FL("permission check failed"));
9622 return -EPERM;
9623 }
9624
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309625 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9626 if (NULL == pAdapter)
9627 {
9628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9629 "%s: Adapter is NULL",__func__);
9630 return -EINVAL;
9631 }
9632 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9633 ret = wlan_hdd_validate_context(pHddCtx);
9634 if (0 != ret)
9635 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309636 return ret;
9637 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309638 if (hdd_priv_get_data(&s_priv_data, wrqu))
9639 {
9640 return -EINVAL;
9641 }
9642
9643 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9644 {
9645 return -EINVAL;
9646 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009647
Arif Hussain0273cba2014-01-07 20:58:29 -08009648 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309649 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9650 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009651 if (NULL == pRequest)
9652 {
9653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9654 "mem_alloc_copy_from_user_helper fail");
9655 return -ENOMEM;
9656 }
9657
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309658 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009659 kfree(pRequest);
9660
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309661 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009662 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009663}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309664
9665static int iw_set_packet_filter_params(struct net_device *dev,
9666 struct iw_request_info *info,
9667 union iwreq_data *wrqu, char *extra)
9668{
9669 int ret;
9670
9671 vos_ssr_protect(__func__);
9672 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9673 vos_ssr_unprotect(__func__);
9674
9675 return ret;
9676}
Jeff Johnson295189b2012-06-20 16:38:30 -07009677#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309678static int __iw_get_statistics(struct net_device *dev,
9679 struct iw_request_info *info,
9680 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009681{
9682
9683 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9684 eHalStatus status = eHAL_STATUS_SUCCESS;
9685 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309686 hdd_adapter_t *pAdapter;
9687 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309689 int tlen = 0, ret = 0;
9690 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009691
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309692 tCsrGlobalClassAStatsInfo *aStats;
9693 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009694
9695 ENTER();
9696
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309697 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9698 if (NULL == pAdapter)
9699 {
9700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9701 "%s: Adapter is NULL",__func__);
9702 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309704 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9705 ret = wlan_hdd_validate_context(pHddCtx);
9706 if (0 != ret)
9707 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309708 return ret;
9709 }
9710 pStats = &(pAdapter->hdd_stats.summary_stat);
9711 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9712 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9714
9715 wrqu->txpower.value = 0;
9716 }
9717 else {
9718 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9719 SME_SUMMARY_STATS |
9720 SME_GLOBAL_CLASSA_STATS |
9721 SME_GLOBAL_CLASSB_STATS |
9722 SME_GLOBAL_CLASSC_STATS |
9723 SME_GLOBAL_CLASSD_STATS |
9724 SME_PER_STA_STATS,
9725 hdd_StatisticsCB, 0, FALSE,
9726 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9727
9728 if (eHAL_STATUS_SUCCESS != status)
9729 {
9730 hddLog(VOS_TRACE_LEVEL_ERROR,
9731 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009732 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 return -EINVAL;
9734 }
9735
9736 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309737 if (NULL == pWextState)
9738 {
9739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9740 "%s: pWextState is NULL",__func__);
9741 return -EINVAL;
9742 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009743
9744 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9745 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9746 {
9747 hddLog(VOS_TRACE_LEVEL_ERROR,
9748 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009749 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009750 /*Remove the SME statistics list by passing NULL in callback argument*/
9751 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9752 SME_SUMMARY_STATS |
9753 SME_GLOBAL_CLASSA_STATS |
9754 SME_GLOBAL_CLASSB_STATS |
9755 SME_GLOBAL_CLASSC_STATS |
9756 SME_GLOBAL_CLASSD_STATS |
9757 SME_PER_STA_STATS,
9758 NULL, 0, FALSE,
9759 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9760
9761 return -EINVAL;
9762 }
9763 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9764 (tANI_U8) sizeof (pStats->retry_cnt),
9765 (char*) &(pStats->retry_cnt[0]),
9766 tlen);
9767
9768 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9769 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9770 (char*) &(pStats->multiple_retry_cnt[0]),
9771 tlen);
9772
9773 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9774 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9775 (char*) &(pStats->tx_frm_cnt[0]),
9776 tlen);
9777
9778 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9779 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9780 (char*) &(pStats->rx_frm_cnt),
9781 tlen);
9782
9783 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9784 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9785 (char*) &(pStats->frm_dup_cnt),
9786 tlen);
9787
9788 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9789 (tANI_U8) sizeof (pStats->fail_cnt),
9790 (char*) &(pStats->fail_cnt[0]),
9791 tlen);
9792
9793 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9794 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9795 (char*) &(pStats->rts_fail_cnt),
9796 tlen);
9797
9798 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9799 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9800 (char*) &(pStats->ack_fail_cnt),
9801 tlen);
9802
9803 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9804 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9805 (char*) &(pStats->rts_succ_cnt),
9806 tlen);
9807
9808 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9809 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9810 (char*) &(pStats->rx_discard_cnt),
9811 tlen);
9812
9813 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9814 (tANI_U8) sizeof (pStats->rx_error_cnt),
9815 (char*) &(pStats->rx_error_cnt),
9816 tlen);
9817
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009818 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009819 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009820 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009821 tlen);
9822
9823 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9824 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9825 (char*) &(dStats->rx_byte_cnt),
9826 tlen);
9827
9828 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9829 (tANI_U8) sizeof (dStats->rx_rate),
9830 (char*) &(dStats->rx_rate),
9831 tlen);
9832
9833 /* Transmit rate, in units of 500 kbit/sec */
9834 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9835 (tANI_U8) sizeof (aStats->tx_rate),
9836 (char*) &(aStats->tx_rate),
9837 tlen);
9838
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009839 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9840 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9841 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009842 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009843 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9844 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9845 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009846 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009847 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9848 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9849 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009850 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009851 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9852 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9853 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009854 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009855 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9856 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9857 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009858 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009859 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9860 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9861 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009862 tlen);
9863
Jeff Johnson295189b2012-06-20 16:38:30 -07009864 wrqu->data.length = tlen;
9865
9866 }
9867
9868 EXIT();
9869
9870 return 0;
9871}
9872
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309873static int iw_get_statistics(struct net_device *dev,
9874 struct iw_request_info *info,
9875 union iwreq_data *wrqu, char *extra)
9876{
9877 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009878
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309879 vos_ssr_protect(__func__);
9880 ret = __iw_get_statistics(dev, info, wrqu, extra);
9881 vos_ssr_unprotect(__func__);
9882
9883 return ret;
9884}
Jeff Johnson295189b2012-06-20 16:38:30 -07009885#ifdef FEATURE_WLAN_SCAN_PNO
9886
9887/*Max Len for PNO notification*/
9888#define MAX_PNO_NOTIFY_LEN 100
9889void found_pref_network_cb (void *callbackContext,
9890 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9891{
9892 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9893 union iwreq_data wrqu;
9894 char buf[MAX_PNO_NOTIFY_LEN+1];
9895
9896 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9897 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9898
9899 // create the event
9900 memset(&wrqu, 0, sizeof(wrqu));
9901 memset(buf, 0, sizeof(buf));
9902
9903 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9904 pPrefNetworkFoundInd->ssId.ssId,
9905 (unsigned int)pPrefNetworkFoundInd->rssi);
9906
9907 wrqu.data.pointer = buf;
9908 wrqu.data.length = strlen(buf);
9909
9910 // send the event
9911
9912 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9913
9914}
9915
9916
9917/*string based input*/
9918VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9919 union iwreq_data *wrqu, char *extra, int nOffset)
9920{
9921 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309922 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009923 /* pnoRequest is a large struct, so we make it static to avoid stack
9924 overflow. This API is only invoked via ioctl, so it is
9925 serialized by the kernel rtnl_lock and hence does not need to be
9926 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309927 tSirPNOScanReq pnoRequest = {0};
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309928 char *ptr, *data;
Jeff Johnson295189b2012-06-20 16:38:30 -07009929 v_U8_t i,j, ucParams, ucMode;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309930 size_t len;
c_hpothu37f21312014-04-09 21:49:54 +05309931 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009932 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9933
9934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9935 "PNO data len %d data %s",
9936 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009937 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009938
9939 if (wrqu->data.length <= nOffset )
9940 {
9941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9942 return VOS_STATUS_E_FAILURE;
9943 }
9944
9945 pnoRequest.enable = 0;
9946 pnoRequest.ucNetworksCount = 0;
9947 /*-----------------------------------------------------------------------
9948 Input is string based and expected to be like this:
9949
9950 <enabled> <netw_count>
9951 for each network:
9952 <ssid_len> <ssid> <authentication> <encryption>
9953 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9954 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9955
9956 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009957 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 -07009958
9959 this translates into:
9960 -----------------------------
9961 enable PNO
9962 look for 2 networks:
9963 test - with authentication type 0 and encryption type 0,
9964 that can be found on 3 channels: 1 6 and 11 ,
9965 SSID bcast type is unknown (directed probe will be sent if AP not found)
9966 and must meet -40dBm RSSI
9967
9968 test2 - with auth and enrytption type 4/4
9969 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9970 bcast type is non-bcast (directed probe will be sent)
9971 and must not meet any RSSI threshold
9972
Jeff Johnson8301aa12013-03-28 14:27:29 -07009973 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009975
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309976 /* making sure argument string ends with '\0' */
9977 len = (wrqu->data.length-nOffset) + 1;
9978 data = vos_mem_malloc(len);
9979 if (NULL == data) {
9980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9981 FL("fail to allocate memory %zu"), len);
9982 return -EINVAL;
9983 }
9984 vos_mem_zero(data, len);
9985 vos_mem_copy(data, &extra[nOffset], (len-1));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309986 ptr = data;
9987
9988 if (1 != sscanf(ptr," %hhu%n", &(pnoRequest.enable), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -07009989 {
9990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9991 "PNO enable input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309992 vos_mem_free(data);
Wilson Yang623f6592013-10-08 16:33:37 -07009993 return VOS_STATUS_E_FAILURE;
9994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009995
9996 if ( 0 == pnoRequest.enable )
9997 {
9998 /*Disable PNO*/
9999 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +053010000 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
10001 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 pAdapter->sessionId,
10003 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010004 if (eHAL_STATUS_SUCCESS != status)
10005 {
10006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10007 "%s: failed to disable PNO", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010008 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010009 return VOS_STATUS_E_FAILURE;
10010 }
10011 pHddCtx->isPnoEnable = FALSE;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010012 vos_mem_free(data);
Jeff Johnson295189b2012-06-20 16:38:30 -070010013 return VOS_STATUS_SUCCESS;
10014 }
10015
c_hpothu37f21312014-04-09 21:49:54 +053010016 if (TRUE == pHddCtx->isPnoEnable)
10017 {
10018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10019 FL("already PNO is enabled"));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010020 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010021 return -EBUSY;
10022 }
10023 pHddCtx->isPnoEnable = TRUE;
10024
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -070010026
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010027 if (1 != sscanf(ptr," %hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -070010028 {
10029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10030 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010031 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010033
10034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10035 "PNO enable %d networks count %d offset %d",
10036 pnoRequest.enable,
10037 pnoRequest.ucNetworksCount,
10038 nOffset);
10039
10040 /* Parameters checking:
10041 ucNetworksCount has to be larger than 0*/
10042 if (( 0 == pnoRequest.ucNetworksCount ) ||
10043 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
10044 {
10045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +053010046 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010047 }
10048
10049 ptr += nOffset;
10050
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010051 pnoRequest.aNetworks =
10052 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10053 if (pnoRequest.aNetworks == NULL)
10054 {
10055 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10056 FL("failed to allocate memory aNetworks %u"),
10057 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10058 goto error;
10059 }
10060 vos_mem_zero(pnoRequest.aNetworks,
10061 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10062
Jeff Johnson295189b2012-06-20 16:38:30 -070010063 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
10064 {
10065
10066 pnoRequest.aNetworks[i].ssId.length = 0;
10067
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010068 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010069 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
10070
10071 if (1 != ucParams)
10072 {
10073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10074 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010075 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010076 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010077
10078 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
10079 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
10080 {
10081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10082 "SSID Len %d is not correct for network %d",
10083 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +053010084 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 }
10086
10087 /*Advance to SSID*/
10088 ptr += nOffset;
10089
Jeff Johnson8301aa12013-03-28 14:27:29 -070010090 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -080010091 pnoRequest.aNetworks[i].ssId.length);
10092 ptr += pnoRequest.aNetworks[i].ssId.length;
10093
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010094 ucParams = sscanf(ptr," %u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -080010095 &(pnoRequest.aNetworks[i].authentication),
10096 &(pnoRequest.aNetworks[i].encryption),
10097 &(pnoRequest.aNetworks[i].ucChannelCount),
10098 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010099
Wilson Yang623f6592013-10-08 16:33:37 -070010100 if ( 3 != ucParams )
10101 {
10102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10103 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010104 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010105 }
10106
Jeff Johnson295189b2012-06-20 16:38:30 -070010107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010108 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -080010109 "auth %d encry %d channel count %d offset %d",
10110 pnoRequest.aNetworks[i].ssId.length,
10111 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
10112 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
10113 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
10114 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
10115 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
10116 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
10117 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
10118 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
10119 pnoRequest.aNetworks[i].authentication,
10120 pnoRequest.aNetworks[i].encryption,
10121 pnoRequest.aNetworks[i].ucChannelCount,
10122 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -070010123
Jeff Johnson295189b2012-06-20 16:38:30 -070010124 /*Advance to channel list*/
10125 ptr += nOffset;
10126
Wilson Yang623f6592013-10-08 16:33:37 -070010127 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -070010128 {
10129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10130 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010131 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 }
10133
10134 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
10135 {
10136 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
10137 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010138 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010139 &(pnoRequest.aNetworks[i].aChannels[j]),
10140 &nOffset))
10141 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10142 "PNO network channel input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010143 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010144 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010145 if (!IS_CHANNEL_VALID(pnoRequest.aNetworks[i].aChannels[j])) {
10146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10147 FL("invalid channel: %hhu"),
10148 pnoRequest.aNetworks[i].aChannels[j]);
10149 goto error;
10150 }
10151
Wilson Yang623f6592013-10-08 16:33:37 -070010152 /*Advance to next channel number*/
10153 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 }
10155 }
10156
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010157 if (1 != sscanf(ptr," %u %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010158 &(pnoRequest.aNetworks[i].bcastNetwType),
10159 &nOffset))
10160 {
10161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10162 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010163 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010164 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010165 if (pnoRequest.aNetworks[i].bcastNetwType > 2) {
10166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10167 FL("invalid bcast nw type: %u"),
10168 pnoRequest.aNetworks[i].bcastNetwType);
10169 goto error;
10170 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010171
10172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10173 "PNO bcastNetwType %d offset %d",
10174 pnoRequest.aNetworks[i].bcastNetwType,
10175 nOffset );
10176
10177 /*Advance to rssi Threshold*/
10178 ptr += nOffset;
10179
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010180 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010181 &(pnoRequest.aNetworks[i].rssiThreshold),
10182 &nOffset))
10183 {
10184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10185 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010186 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010187 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010188
10189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10190 "PNO rssi %d offset %d",
10191 pnoRequest.aNetworks[i].rssiThreshold,
10192 nOffset );
10193 /*Advance to next network*/
10194 ptr += nOffset;
10195 }/*For ucNetworkCount*/
10196
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010197 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010198 &(pnoRequest.scanTimers.ucScanTimersCount),
10199 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010200
10201 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -070010202 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010203 {
10204 ptr += nOffset;
10205
Jeff Johnson8301aa12013-03-28 14:27:29 -070010206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10207 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 pnoRequest.scanTimers.ucScanTimersCount,
10209 nOffset );
10210
10211 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
10212 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +053010215 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010216 }
10217
10218 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
10219 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010220 ucParams = sscanf(ptr," %u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -070010221 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
10222 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
10223 &nOffset);
10224
Wilson Yang623f6592013-10-08 16:33:37 -070010225 if (2 != ucParams)
10226 {
10227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10228 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +053010229 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010230 }
10231
Jeff Johnson8301aa12013-03-28 14:27:29 -070010232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10233 "PNO Timer value %d Timer repeat %d offset %d",
10234 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
10236 nOffset );
10237
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 ptr += nOffset;
10239 }
10240
10241 }
10242 else
10243 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10245 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010246 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
10247
10248 /*Scan timers defaults to 5 minutes*/
10249 pnoRequest.scanTimers.ucScanTimersCount = 1;
10250 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
10251 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
10252 }
10253
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010254 ucParams = sscanf(ptr," %hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010255
10256 pnoRequest.modePNO = ucMode;
10257 /*for LA we just expose suspend option*/
10258 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
10259 {
10260 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10261 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010262 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10263 if (pnoRequest.p24GProbeTemplate == NULL){
10264 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10265 FL("failed to allocate memory p24GProbeTemplate %u"),
10266 SIR_PNO_MAX_PB_REQ_SIZE);
10267 goto error;
10268 }
10269
10270 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10271 if (pnoRequest.p5GProbeTemplate == NULL){
10272 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10273 FL("failed to allocate memory p5GProbeTemplate %u"),
10274 SIR_PNO_MAX_PB_REQ_SIZE);
10275 goto error;
10276 }
10277
10278 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
10279 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010280
c_hpothu37f21312014-04-09 21:49:54 +053010281 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010282 pAdapter->sessionId,
10283 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010284 if (eHAL_STATUS_SUCCESS == status)
10285 {
10286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10287 "%s: PNO enabled", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010288 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010289 return VOS_STATUS_SUCCESS;
10290 }
10291error:
10292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10293 "%s: Failed to enable PNO", __func__);
10294 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010295 if (pnoRequest.aNetworks)
10296 vos_mem_free(pnoRequest.aNetworks);
10297 if (pnoRequest.p24GProbeTemplate)
10298 vos_mem_free(pnoRequest.p24GProbeTemplate);
10299 if (pnoRequest.p5GProbeTemplate)
10300 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010301
10302 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010303 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010304}/*iw_set_pno*/
10305
10306VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10307 union iwreq_data *wrqu, char *extra, int nOffset)
10308{
10309 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10310 v_U8_t rssiThreshold = 0;
10311 v_U8_t nRead;
10312
Arif Hussain7adce1b2013-11-11 22:59:34 -080010313 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010314 &rssiThreshold);
10315
10316 if ( 1 != nRead )
10317 {
10318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10319 "Incorrect format");
10320 return VOS_STATUS_E_FAILURE;
10321 }
10322
10323 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10324 return VOS_STATUS_SUCCESS;
10325}
10326
10327
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010328static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010329 struct iw_request_info *info,
10330 union iwreq_data *wrqu, char *extra)
10331{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010332 hdd_adapter_t *pAdapter;
10333 hdd_context_t *pHddCtx;
10334 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010335 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010336
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010337 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010338 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10339 if (NULL == pAdapter)
10340 {
10341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10342 "%s: Adapter is NULL",__func__);
10343 return -EINVAL;
10344 }
10345
10346 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10347 ret = wlan_hdd_validate_context(pHddCtx);
10348 if (0 != ret)
10349 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010350 return ret;
10351 }
10352
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010353
10354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010355 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010356
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010357 status = iw_set_pno(dev,info,wrqu,extra,0);
10358
10359 EXIT();
10360 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010361}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010362
10363static int iw_set_pno_priv(struct net_device *dev,
10364 struct iw_request_info *info,
10365 union iwreq_data *wrqu, char *extra)
10366{
10367 int ret;
10368
10369 vos_ssr_protect(__func__);
10370 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10371 vos_ssr_unprotect(__func__);
10372
10373 return ret;
10374}
Jeff Johnson295189b2012-06-20 16:38:30 -070010375#endif /*FEATURE_WLAN_SCAN_PNO*/
10376
10377//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010378int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010379{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010380 hdd_adapter_t *pAdapter;
10381 tHalHandle hHal;
10382 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010383 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010384 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010385 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010386 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010387 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010388 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010389 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010390
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010391 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010392 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10393 if (NULL == pAdapter)
10394 {
10395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10396 "%s: Adapter is NULL",__func__);
10397 return -EINVAL;
10398 }
10399 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10400 retval = wlan_hdd_validate_context(pHddCtx);
10401 if (0 != retval)
10402 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010403 return retval;
10404 }
10405 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10406 if (NULL == hHal)
10407 {
10408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10409 "%s: Hal Context is NULL",__func__);
10410 return -EINVAL;
10411 }
10412 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010413
Atul Mittal54378cb2014-04-02 16:51:50 +053010414 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 {
10416 case WLAN_HDD_UI_BAND_AUTO:
10417 band = eCSR_BAND_ALL;
10418 break;
10419 case WLAN_HDD_UI_BAND_5_GHZ:
10420 band = eCSR_BAND_5G;
10421 break;
10422 case WLAN_HDD_UI_BAND_2_4_GHZ:
10423 band = eCSR_BAND_24;
10424 break;
10425 default:
10426 band = eCSR_BAND_MAX;
10427 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010428 connectedBand =
10429 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010430
Atul Mittal54378cb2014-04-02 16:51:50 +053010431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010432 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010433
10434 if (band == eCSR_BAND_MAX)
10435 {
10436 /* Received change band request with invalid band value */
10437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010438 "%s: Invalid band value %u", __func__, ui_band);
10439 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010440 }
10441
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010442 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010443 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010444 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010446 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010447 band, pHddCtx->cfg_ini->nBandCapability);
10448 return -EIO;
10449 }
10450
Sushant Kaushik1165f872015-03-30 20:25:27 +053010451 if (band == eCSR_BAND_ALL)
10452 {
10453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10454 "received. Setting band same as ini value %d"),
10455 pHddCtx->cfg_ini->nBandCapability);
10456 band = pHddCtx->cfg_ini->nBandCapability;
10457 }
10458
Jeff Johnson295189b2012-06-20 16:38:30 -070010459 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10460 {
10461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10462 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010463 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010464 return -EIO;
10465 }
10466
10467 if (currBand != band)
10468 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010469 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010470 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010471 /* Return failure if current country code is world regulatory domain*/
10472 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10473 pMac->scan.countryCodeCurrent[1] == '0') )
10474 {
10475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10476 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010477 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010478 return -EAGAIN;
10479 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010480 }
10481
Jeff Johnson295189b2012-06-20 16:38:30 -070010482 /* Change band request received.
10483 * Abort pending scan requests, flush the existing scan results,
10484 * and change the band capability
10485 */
10486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10487 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010488 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010489
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010490 /* We need to change the band and flush the scan results here itself
10491 * as we may get timeout for disconnection in which we will return
10492 * with out doing any of these
10493 */
10494 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10495 {
10496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10497 "%s: failed to set the band value to %u ",
10498 __func__, band);
10499 return -EINVAL;
10500 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010501 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10502 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010503 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010504 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10505 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010506 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010507 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10508 * information available in NV so to get the channel information from kernel
10509 * we need to send regulatory hint for the currunt country
10510 * And to set the same country again we need to set the dummy country
10511 * first and then the actual country.
10512 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010513#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10514 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
10515#else
10516 regulatory_hint_user("00");
10517#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010518 wait_result = wait_for_completion_interruptible_timeout(
10519 &pHddCtx->linux_reg_req,
10520 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10521
10522 /* if the country information does not exist with the kernel,
10523 then the driver callback would not be called */
10524
10525 if (wait_result >= 0)
10526 {
10527 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10528 "runtime country code is found in kernel db");
10529 }
10530 else
10531 {
10532 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10533 "runtime country code is not found"
10534 " in kernel db");
10535 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010536
10537 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010538
10539 /*
10540 * Update 11dcountry and current country here as the hint
10541 * with 00 results in 11d and current country with 00
10542 */
10543 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10544 WNI_CFG_COUNTRY_CODE_LEN);
10545 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10546 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010547#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10548 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10549#else
10550 regulatory_hint_user(curr_country);
10551#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010552 wait_result = wait_for_completion_interruptible_timeout(
10553 &pHddCtx->linux_reg_req,
10554 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10555
10556 /* if the country information does not exist with the kernel,
10557 then the driver callback would not be called */
10558 if (wait_result >= 0)
10559 {
10560 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10561 "runtime country code is found in kernel db");
10562 }
10563 else
10564 {
10565 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10566 "runtime country code is not found"
10567 " in kernel db");
10568 }
10569
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010570 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010571 }
10572 else
10573 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010574#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010575 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10576 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010577#else
10578 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10579#endif
10580
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010581 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010582 pScanInfo = &pHddCtx->scan_info;
10583 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10584 {
10585 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10586 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10587 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010588 sme_FilterScanResults(hHal, pAdapter->sessionId);
10589
10590 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010591 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10592 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 eHalStatus status = eHAL_STATUS_SUCCESS;
10595 long lrc;
10596
10597 /* STA already connected on current band, So issue disconnect first,
10598 * then change the band*/
10599
10600 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010601 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010602 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010603
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10605
10606 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10607 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10608
Jeff Johnson43971f52012-07-17 12:26:56 -070010609 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010610 {
10611 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010612 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010613 __func__, (int)status );
10614 return -EINVAL;
10615 }
10616
10617 lrc = wait_for_completion_interruptible_timeout(
10618 &pAdapter->disconnect_comp_var,
10619 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10620
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010621 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010622
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010623 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010624 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010625
10626 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10627 }
10628 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010630 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010631 if (TRUE == pHddCtx->isSetBandByNL)
10632 return 0;
10633 else
10634 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010635}
10636
Atul Mittal54378cb2014-04-02 16:51:50 +053010637int hdd_setBand_helper(struct net_device *dev, const char *command)
10638{
10639 u8 band;
10640
10641 /*convert the band value from ascii to integer*/
10642 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10643
10644 return hdd_setBand(dev, band);
10645
10646}
10647
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010648static int __iw_set_band_config(struct net_device *dev,
10649 struct iw_request_info *info,
10650 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010651{
Atul Mittal54378cb2014-04-02 16:51:50 +053010652 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010653
Arif Hussain0273cba2014-01-07 20:58:29 -080010654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010655
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010656 if (!capable(CAP_NET_ADMIN))
10657 {
10658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10659 FL("permission check failed"));
10660 return -EPERM;
10661 }
10662
Atul Mittal54378cb2014-04-02 16:51:50 +053010663 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010664}
10665
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010666static int iw_set_band_config(struct net_device *dev,
10667 struct iw_request_info *info,
10668 union iwreq_data *wrqu, char *extra)
10669{
10670 int ret;
10671
10672 vos_ssr_protect(__func__);
10673 ret = __iw_set_band_config(dev, info, wrqu, extra);
10674 vos_ssr_unprotect(__func__);
10675
10676 return ret;
10677}
10678
c_manjeecfd1efb2015-09-25 19:32:34 +053010679static int get_fwr_memdump(struct net_device *dev,
10680 struct iw_request_info *info,
10681 union iwreq_data *wrqu, char *extra)
10682{
10683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10684 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10685 int ret;
10686 ENTER();
10687 // HddCtx sanity
10688 ret = wlan_hdd_validate_context(pHddCtx);
10689 if (0 != ret)
10690 {
10691 return ret;
10692 }
10693 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10694 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10695 {
10696 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10697 return -EINVAL;
10698 }
10699 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10700
10701 EXIT();
10702 return ret;
10703}
10704
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010705static int __iw_set_power_params_priv(struct net_device *dev,
10706 struct iw_request_info *info,
10707 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010708{
Arif Hussain0273cba2014-01-07 20:58:29 -080010709 int ret;
10710 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010711
Jeff Johnson295189b2012-06-20 16:38:30 -070010712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10713 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010714
10715 if (!capable(CAP_NET_ADMIN))
10716 {
10717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10718 FL("permission check failed"));
10719 return -EPERM;
10720 }
10721
Arif Hussain0273cba2014-01-07 20:58:29 -080010722 /* ODD number is used for set, copy data using copy_from_user */
10723 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10724 wrqu->data.length);
10725 if (NULL == ptr)
10726 {
10727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10728 "mem_alloc_copy_from_user_helper fail");
10729 return -ENOMEM;
10730 }
10731
10732 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10733 kfree(ptr);
10734 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010735}
10736
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010737static int iw_set_power_params_priv(struct net_device *dev,
10738 struct iw_request_info *info,
10739 union iwreq_data *wrqu, char *extra)
10740{
10741 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010742
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010743 vos_ssr_protect(__func__);
10744 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10745 vos_ssr_unprotect(__func__);
10746
10747 return ret;
10748}
Jeff Johnson295189b2012-06-20 16:38:30 -070010749
10750/*string based input*/
10751VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10752 union iwreq_data *wrqu, char *extra, int nOffset)
10753{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010754 hdd_adapter_t *pAdapter;
10755 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010756 tSirSetPowerParamsReq powerRequest;
10757 char *ptr;
10758 v_U8_t ucType;
10759 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010760 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010761
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010762 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010763 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10764 if (NULL == pAdapter)
10765 {
10766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10767 "%s: Adapter is NULL",__func__);
10768 return -EINVAL;
10769 }
10770
10771 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10772 ret = wlan_hdd_validate_context(pHddCtx);
10773 if (0 != ret)
10774 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010775 return ret;
10776 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10778 "Power Params data len %d data %s",
10779 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010780 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010781
10782 if (wrqu->data.length <= nOffset )
10783 {
10784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10785 return VOS_STATUS_E_FAILURE;
10786 }
10787
10788 uTotalSize = wrqu->data.length - nOffset;
10789
10790 /*-----------------------------------------------------------------------
10791 Input is string based and expected to be like this:
10792
10793 <param_type> <param_value> <param_type> <param_value> ...
10794
10795 e.g:
10796 1 2 2 3 3 0 4 1 5 1
10797
10798 e.g. setting just a few:
10799 1 2 4 1
10800
10801 parameter types:
10802 -----------------------------
10803 1 - Ignore DTIM
10804 2 - Listen Interval
10805 3 - Broadcast Multicas Filter
10806 4 - Beacon Early Termination
10807 5 - Beacon Early Termination Interval
10808 -----------------------------------------------------------------------*/
10809 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10810 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10811 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10812 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10813 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10814
Arif Hussain7adce1b2013-11-11 22:59:34 -080010815 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010816
10817 while ( uTotalSize )
10818 {
Wilson Yang6f971452013-10-08 15:00:00 -070010819 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10820 {
10821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10822 "Invalid input parameter type %s",ptr);
10823 return VOS_STATUS_E_FAILURE;
10824 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010825
10826 uTotalSize -= nOffset;
10827
10828 if (!uTotalSize)
10829 {
10830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010831 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 ucType, nOffset);
10833 return VOS_STATUS_E_FAILURE;
10834 }
10835
10836 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010837
Jeff Johnson02797792013-10-26 19:17:13 -070010838 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010839 {
10840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10841 "Invalid input parameter value %s",ptr);
10842 return VOS_STATUS_E_FAILURE;
10843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010844
10845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10846 "Power request parameter %d value %d offset %d",
10847 ucType, uValue, nOffset);
10848
10849 switch (ucType)
10850 {
10851 case eSIR_IGNORE_DTIM:
10852 powerRequest.uIgnoreDTIM = uValue;
10853 break;
10854 case eSIR_LISTEN_INTERVAL:
10855 powerRequest.uListenInterval = uValue;
10856 break;
10857 case eSIR_MCAST_BCAST_FILTER:
10858 powerRequest.uBcastMcastFilter = uValue;
10859 break;
10860 case eSIR_ENABLE_BET:
10861 powerRequest.uEnableBET = uValue;
10862 break;
10863 case eSIR_BET_INTERVAL:
10864 powerRequest.uBETInterval = uValue;
10865 break;
10866 default:
10867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010868 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010869 ucType, uValue, nOffset);
10870 return VOS_STATUS_E_FAILURE;
10871 }
10872
10873 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10875 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010876 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010877 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010878 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010879 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010880 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10881 {
10882 uTotalSize = 0;
10883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010884
10885 }/*Go for as long as we have a valid string*/
10886
10887 /* put the device into full power*/
10888 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10889
10890 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010891 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010892
10893 /* put the device back to power save*/
10894 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10895
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010896 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010897 return VOS_STATUS_SUCCESS;
10898}/*iw_set_power_params*/
10899
Atul Mittalc0f739f2014-07-31 13:47:47 +053010900// tdlsoffchan
10901#ifdef FEATURE_WLAN_TDLS
10902
Atul Mittal87ec2422014-09-24 13:12:50 +053010903int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010904{
10905 if (offchannel < 0 || offchannel > 165)
10906 {
10907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10908 __func__, offchannel);
10909 return -1;
10910
10911 }
10912
10913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10914 __func__, tdlsOffCh, offchannel);
10915
10916 tdlsOffCh = offchannel;
10917 return 0;
10918}
10919
Atul Mittal87ec2422014-09-24 13:12:50 +053010920int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010921{
10922 if (offchanoffset == 0)
10923 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010924 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10926 __func__, tdlsOffChBwOffset);
10927
10928 return 0;
10929
10930 }
10931
10932 if ( offchanoffset == 40 )
10933 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010934 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10936 __func__, tdlsOffChBwOffset);
10937
10938 return 0;
10939
10940 }
10941 if (offchanoffset == -40)
10942 {
10943 tdlsOffChBwOffset = 3;
10944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10945 __func__, tdlsOffChBwOffset);
10946
10947 return 0;
10948
10949 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010950
10951 if ((offchanoffset == 80) &&
10952 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10953 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10954 {
10955 tdlsOffChBwOffset = 4;
10956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10957 "%s: change tdls secondary off channel offset to %u",
10958 __func__, tdlsOffChBwOffset);
10959
10960 return 0;
10961 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10963 __func__, offchanoffset);
10964 return -1;
10965}
10966
Atul Mittal87ec2422014-09-24 13:12:50 +053010967int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010968{
10969 hddTdlsPeer_t *connPeer = NULL;
10970 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10971 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010972 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010973 if (offchanmode < 0 || offchanmode > 4)
10974 {
10975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10976 "%s: Invalid tdls off channel mode %d",
10977 __func__, offchanmode);
10978 return -1;
10979 }
10980
10981 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10982 {
10983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10984 "%s: tdls off channel mode req in not associated state %d",
10985 __func__, offchanmode);
10986 return -1;
10987 }
10988
10989 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10990 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10991 {
10992 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010993 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010994 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010995 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010996 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10998 "%s: No TDLS Connected Peer", __func__);
10999 return -1;
11000 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011001 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053011002 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053011003 }
11004 else
11005 {
11006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11007 "%s: TDLS Connection not supported", __func__);
11008 return -1;
11009 }
11010
11011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11012 ("%s: TDLS Channel Switch in swmode=%d"),
11013 __func__, offchanmode);
11014
11015 switch (offchanmode)
11016 {
11017 case 1:/*Enable*/
11018 case 2:/*Disable*/
11019 {
11020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11021 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
11022 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11023 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
11024 {
11025
11026 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011027 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053011028 tdlsOffCh, tdlsOffChBwOffset,
11029 offchanmode);
11030 }
11031 else
11032 {
11033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11034 "%s: TDLS Off Channel not supported", __func__);
11035 return -1;
11036 }
11037 break;
11038 }
11039 case 3:
11040 {
11041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11042 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
11043 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11044
11045 break;
11046 }
11047 case 4:
11048 {
11049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11050 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
11051 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11052 break;
11053 }
11054 default:
11055 {
11056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11057 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
11058 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11059 break;
11060 }
11061
11062 }
11063
11064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
11065 __func__, offchanmode);
11066 return 0;
11067}
Atul Mittalc0f739f2014-07-31 13:47:47 +053011068#endif
11069
Jeff Johnson295189b2012-06-20 16:38:30 -070011070// Define the Wireless Extensions to the Linux Network Device structure
11071// A number of these routines are NULL (meaning they are not implemented.)
11072
11073static const iw_handler we_handler[] =
11074{
11075 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
11076 (iw_handler) iw_get_name, /* SIOCGIWNAME */
11077 (iw_handler) NULL, /* SIOCSIWNWID */
11078 (iw_handler) NULL, /* SIOCGIWNWID */
11079 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
11080 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
11081 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
11082 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
11083 (iw_handler) NULL, /* SIOCSIWSENS */
11084 (iw_handler) NULL, /* SIOCGIWSENS */
11085 (iw_handler) NULL, /* SIOCSIWRANGE */
11086 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053011087 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070011088 (iw_handler) NULL, /* SIOCGIWPRIV */
11089 (iw_handler) NULL, /* SIOCSIWSTATS */
11090 (iw_handler) NULL, /* SIOCGIWSTATS */
11091 iw_handler_set_spy, /* SIOCSIWSPY */
11092 iw_handler_get_spy, /* SIOCGIWSPY */
11093 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
11094 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
11095 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
11096 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
11097 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
11098 (iw_handler) NULL, /* SIOCGIWAPLIST */
11099 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
11100 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
11101 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
11102 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
11103 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
11104 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
11105 (iw_handler) NULL, /* -- hole -- */
11106 (iw_handler) NULL, /* -- hole -- */
11107 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
11108 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
11109 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
11110 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
11111 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
11112 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
11113 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
11114 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
11115 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
11116 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
11117 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
11118 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
11119 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
11120 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
11121 (iw_handler) NULL, /* -- hole -- */
11122 (iw_handler) NULL, /* -- hole -- */
11123 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
11124 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
11125 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
11126 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
11127 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
11128 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
11129 (iw_handler) NULL, /* SIOCSIWPMKSA */
11130};
11131
11132static const iw_handler we_private[] = {
11133
11134 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
11135 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
11136 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
11137 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
11138 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
11139 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053011140 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070011141 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
11142 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
11143 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Manjeet Singh3ed79242017-01-11 19:04:32 +053011144 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
11145 iw_setnone_get_threeint,
Jeff Johnsone7245742012-09-05 17:12:55 -070011146#ifdef FEATURE_OEM_DATA_SUPPORT
11147 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
11148 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
11149#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011150
Jeff Johnson295189b2012-06-20 16:38:30 -070011151#ifdef WLAN_FEATURE_VOWIFI_11R
11152 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
11153#endif
11154 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
11155 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
11156 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
11157#ifdef WLAN_FEATURE_PACKET_FILTERING
11158 ,
11159 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
11160#endif
11161#ifdef FEATURE_WLAN_SCAN_PNO
11162 ,
11163 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
11164#endif
11165 ,
11166 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
11167 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
11168 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
11169 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070011170 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070011171};
11172
11173/*Maximum command length can be only 15 */
11174static const struct iw_priv_args we_private_args[] = {
11175
Katya Nigamf0511f62015-05-05 16:40:57 +053011176 { WE_SET_MONITOR_STATE,
11177 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11178 0, "monitor" },
11179
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 /* handlers for main ioctl */
11181 { WLAN_PRIV_SET_INT_GET_NONE,
11182 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11183 0,
11184 "" },
11185
11186 /* handlers for sub-ioctl */
11187 { WE_SET_11D_STATE,
11188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11189 0,
11190 "set11Dstate" },
11191
11192 { WE_WOWL,
11193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11194 0,
11195 "wowl" },
11196
11197 { WE_SET_POWER,
11198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11199 0,
11200 "setPower" },
11201
11202 { WE_SET_MAX_ASSOC,
11203 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11204 0,
11205 "setMaxAssoc" },
11206
11207 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
11208 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11209 0,
11210 "setAutoChannel" },
11211
11212 { WE_SET_DATA_INACTIVITY_TO,
11213 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11214 0,
11215 "inactivityTO" },
11216
11217 { WE_SET_MAX_TX_POWER,
11218 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11219 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070011220 "setMaxTxPower" },
11221
11222 { WE_SET_MAX_TX_POWER_2_4,
11223 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11224 0,
11225 "setTxMaxPower2G" },
11226
11227 { WE_SET_MAX_TX_POWER_5_0,
11228 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11229 0,
11230 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070011231
11232 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
11233 * as well to keep same syntax as in SAP. Now onwards, STA
11234 * will support both */
11235 { WE_SET_MAX_TX_POWER,
11236 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11237 0,
11238 "setTxMaxPower" },
11239
Jeff Johnson295189b2012-06-20 16:38:30 -070011240 /* set Higher DTIM Transition (DTIM1 to DTIM3)
11241 * 1 = enable and 0 = disable */
11242 {
11243 WE_SET_HIGHER_DTIM_TRANSITION,
11244 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11245 0,
11246 "setHDtimTransn" },
11247
11248 { WE_SET_TM_LEVEL,
11249 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011250 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011251 "setTmLevel" },
11252
Kiet Lam46b8e4e2013-11-06 21:49:53 +053011253 { WE_ENABLE_STRICT_FCC_REG,
11254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11255 0,
11256 "setStrictFCCreg" },
11257
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011258 { WE_SET_DEBUG_LOG,
11259 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11260 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053011261#ifdef FEATURE_WLAN_TDLS
11262 {
11263 WE_SET_TDLS_OFF_CHAN,
11264 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11265 0,
11266 "tdlsoffchan" },
11267 {
11268 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
11269 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11270 0,
11271 "tdlsecchnoffst" },
11272 {
11273 WE_SET_TDLS_OFF_CHAN_MODE,
11274 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11275 0,
11276 "tdlsoffchnmode" },
11277#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011278
Peng Xu2446a892014-09-05 17:21:18 +053011279 { WE_SET_SCAN_BAND_PREFERENCE,
11280 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11281 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053011282 {
11283 WE_GET_FRAME_LOG,
11284 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11285 0,
11286 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053011287
Abhishek Singh01c73d12015-03-12 15:13:44 +053011288 { WE_SET_MIRACAST_VENDOR_CONFIG,
11289 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11290 0, "setMiracstConf" },
11291
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053011292#ifdef FEATURE_WLAN_TDLS
11293 {
11294 WE_SET_TDLS_2040_BSS_COEXISTENCE,
11295 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11296 0,
11297 "tdls_2040bsscox" },
11298#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053011299 { WE_SET_RTS_CTS_HTVHT,
11300 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11301 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053011302 { WE_SET_PKT_STATS_ENABLE_DISABLE,
11303 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11304 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053011305 { WE_SET_PROXIMITY_ENABLE,
11306 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11307 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011308
11309#ifdef WLAN_FEATURE_TSF
11310 { WE_CAP_TSF,
11311 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11312 0, "cap_tsf" },
11313#endif
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +053011314 { WE_SET_MODULATED_DTIM,
11315 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11316 0, "setModDTIM" },
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053011317 {
11318 WLAN_SET_DYNNAMIC_AGGREGATION,
11319 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11320 0, "setAggregation" },
11321
Jeff Johnson295189b2012-06-20 16:38:30 -070011322 /* handlers for main ioctl */
11323 { WLAN_PRIV_SET_NONE_GET_INT,
11324 0,
11325 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11326 "" },
11327
11328 /* handlers for sub-ioctl */
11329 { WE_GET_11D_STATE,
11330 0,
11331 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11332 "get11Dstate" },
11333
11334 { WE_IBSS_STATUS,
11335 0,
11336 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11337 "getAdhocStatus" },
11338
11339 { WE_PMC_STATE,
11340 0,
11341 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11342 "pmcState" },
11343
11344 { WE_GET_WLAN_DBG,
11345 0,
11346 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11347 "getwlandbg" },
11348
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 { WE_GET_MAX_ASSOC,
11350 0,
11351 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11352 "getMaxAssoc" },
11353
Jeff Johnson295189b2012-06-20 16:38:30 -070011354 { WE_GET_WDI_DBG,
11355 0,
11356 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11357 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011358
11359 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11360 0,
11361 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11362 "getAutoChannel" },
11363
11364 { WE_GET_CONCURRENCY_MODE,
11365 0,
11366 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11367 "getconcurrency" },
11368
Peng Xu2446a892014-09-05 17:21:18 +053011369 { WE_GET_SCAN_BAND_PREFERENCE,
11370 0,
11371 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11372 "get_scan_pref"},
11373
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011374 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11375 0,
11376 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11377 "getCurAnt"},
11378
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 /* handlers for main ioctl */
11380 { WLAN_PRIV_SET_CHAR_GET_NONE,
11381 IW_PRIV_TYPE_CHAR| 512,
11382 0,
11383 "" },
11384
11385 /* handlers for sub-ioctl */
11386 { WE_WOWL_ADD_PTRN,
11387 IW_PRIV_TYPE_CHAR| 512,
11388 0,
11389 "wowlAddPtrn" },
11390
11391 { WE_WOWL_DEL_PTRN,
11392 IW_PRIV_TYPE_CHAR| 512,
11393 0,
11394 "wowlDelPtrn" },
11395
11396#if defined WLAN_FEATURE_VOWIFI
11397 /* handlers for sub-ioctl */
11398 { WE_NEIGHBOR_REPORT_REQUEST,
11399 IW_PRIV_TYPE_CHAR | 512,
11400 0,
11401 "neighbor" },
11402#endif
11403 { WE_SET_AP_WPS_IE,
11404 IW_PRIV_TYPE_CHAR| 512,
11405 0,
11406 "set_ap_wps_ie" },
11407
11408 { WE_SET_CONFIG,
11409 IW_PRIV_TYPE_CHAR| 512,
11410 0,
11411 "setConfig" },
11412
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011413 { WE_SET_ENCRYPT_MSG,
11414 IW_PRIV_TYPE_CHAR| 512,
11415 0,
11416 "encryptMsg" },
11417
11418
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 /* handlers for main ioctl */
11420 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11421 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11422 0,
11423 "" },
11424
11425 /* handlers for sub-ioctl */
11426 { WE_SET_WLAN_DBG,
11427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11428 0,
11429 "setwlandbg" },
11430
Jeff Johnson295189b2012-06-20 16:38:30 -070011431 { WE_SET_WDI_DBG,
11432 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11433 0,
11434 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011435
11436 { WE_SET_SAP_CHANNELS,
11437 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11438 0,
11439 "setsapchannels" },
11440
11441 /* handlers for main ioctl */
11442 { WLAN_PRIV_GET_CHAR_SET_NONE,
11443 0,
11444 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11445 "" },
11446
11447 /* handlers for sub-ioctl */
11448 { WE_WLAN_VERSION,
11449 0,
11450 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11451 "version" },
11452 { WE_GET_STATS,
11453 0,
11454 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11455 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011456 { WE_GET_STATES,
11457 0,
11458 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11459 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011460 { WE_GET_CFG,
11461 0,
11462 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11463 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011464#ifdef WLAN_FEATURE_11AC
11465 { WE_GET_RSSI,
11466 0,
11467 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11468 "getRSSI" },
11469#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011470#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011471 { WE_GET_ROAM_RSSI,
11472 0,
11473 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11474 "getRoamRSSI" },
11475#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011476 { WE_GET_WMM_STATUS,
11477 0,
11478 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11479 "getWmmStatus" },
11480 {
11481 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011482 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11484 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011485#ifdef FEATURE_WLAN_TDLS
11486 {
11487 WE_GET_TDLS_PEERS,
11488 0,
11489 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11490 "getTdlsPeers" },
11491#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011492#ifdef WLAN_FEATURE_11W
11493 {
11494 WE_GET_11W_INFO,
11495 0,
11496 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11497 "getPMFInfo" },
11498#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011499#ifdef WLAN_FEATURE_RMC
11500 {
11501 WE_GET_IBSS_STA_INFO,
11502 0,
11503 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11504 "getIbssSTAs" },
11505#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011506 { WE_GET_SNR,
11507 0,
11508 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11509 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011510#ifdef FEATURE_OEM_DATA_SUPPORT
11511 {
11512 WE_GET_OEM_DATA_CAP,
11513 0,
11514 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11515 "getOemDataCap" },
11516#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011517 /* handlers for main ioctl */
11518 { WLAN_PRIV_SET_NONE_GET_NONE,
11519 0,
11520 0,
11521 "" },
11522
11523 /* handlers for sub-ioctl */
11524 { WE_CLEAR_STATS,
11525 0,
11526 0,
11527 "clearStats" },
11528 { WE_INIT_AP,
11529 0,
11530 0,
11531 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011532#ifdef WLAN_FEATURE_RMC
11533 {
11534 WE_IBSS_GET_PEER_INFO_ALL,
11535 0,
11536 0,
11537 "ibssPeerInfoAll" },
11538#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011539 { WE_STOP_AP,
11540 0,
11541 0,
11542 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011543#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011544 { WE_ENABLE_AMP,
11545 0,
11546 0,
11547 "enableAMP" },
11548 { WE_DISABLE_AMP,
11549 0,
11550 0,
11551 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011552#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011553 { WE_ENABLE_DXE_STALL_DETECT,
11554 0,
11555 0,
11556 "dxeStallDetect" },
11557 { WE_DISPLAY_DXE_SNAP_SHOT,
11558 0,
11559 0,
11560 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011561 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11562 0,
11563 0,
11564 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011565 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011566 WE_SET_REASSOC_TRIGGER,
11567 0,
11568 0,
11569 "reassoc" },
11570 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011571 WE_STOP_OBSS_SCAN,
11572 0,
11573 0,
11574 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011575 {
11576 WE_DUMP_ROAM_TIMER_LOG,
11577 0,
11578 0,
11579 "dumpRoamDelay" },
11580 {
11581 WE_RESET_ROAM_TIMER_LOG,
11582 0,
11583 0,
11584 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011585 {
11586 WE_GET_FW_LOGS,
11587 0,
11588 0,
11589 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011590 {
11591 WE_GET_FW_MEMDUMP,
11592 0,
11593 0,
11594 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011595 /* handlers for main ioctl */
11596 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11597 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11598 0,
11599 "" },
11600
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011601
11602
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 /* handlers for sub-ioctl */
11604 { WE_LOG_DUMP_CMD,
11605 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11606 0,
11607 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011608#ifdef WLAN_FEATURE_RMC
11609 { WE_IBSS_GET_PEER_INFO,
11610 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11611 0,
11612 "ibssPeerInfo" },
11613#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011614
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011615 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011616 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11617 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11618 0,
11619 "setdumplog" },
11620
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011621 { WE_MTRACE_DUMP_CMD,
11622 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11623 0,
11624 "dumplog" },
11625
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011626 /* handlers for sub ioctl */
11627 {
11628 WE_MCC_CONFIG_CREDENTIAL,
11629 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11630 0,
11631 "setMccCrdnl" },
11632
11633 /* handlers for sub ioctl */
11634 {
11635 WE_MCC_CONFIG_PARAMS,
11636 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11637 0,
11638 "setMccConfig" },
11639
Chilam NG571c65a2013-01-19 12:27:36 +053011640#ifdef FEATURE_WLAN_TDLS
11641 /* handlers for sub ioctl */
11642 {
11643 WE_TDLS_CONFIG_PARAMS,
11644 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11645 0,
11646 "setTdlsConfig" },
11647#endif
11648
Katya Nigamf0511f62015-05-05 16:40:57 +053011649 {
11650 WE_CONFIGURE_MONITOR_MODE,
11651 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11652 0,
11653 "MonitorModeConf" },
11654
11655 {
11656 WE_SET_MONITOR_MODE_FILTER,
11657 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11658 0,
11659 "MonitorFilter" },
11660
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 /* handlers for main ioctl */
11662 { WLAN_PRIV_ADD_TSPEC,
11663 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11664 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11665 "addTspec" },
11666
11667 /* handlers for main ioctl */
11668 { WLAN_PRIV_DEL_TSPEC,
11669 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11670 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11671 "delTspec" },
11672
11673 /* handlers for main ioctl */
11674 { WLAN_PRIV_GET_TSPEC,
11675 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11676 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11677 "getTspec" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011678 /* handlers for main ioctl */
11679 { WLAN_PRIV_SET_NONE_GET_THREE_INT,
11680 0,
11681 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11682 "" },
11683#ifdef WLAN_FEATURE_TSF
11684 { WE_GET_TSF,
11685 0,
11686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11687 "get_tsf" },
11688#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011689#ifdef FEATURE_OEM_DATA_SUPPORT
11690 /* handlers for main ioctl - OEM DATA */
11691 {
11692 WLAN_PRIV_SET_OEM_DATA_REQ,
11693 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11694 0,
11695 "set_oem_data_req" },
11696
11697 /* handlers for main ioctl - OEM DATA */
11698 {
11699 WLAN_PRIV_GET_OEM_DATA_RSP,
11700 0,
11701 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11702 "get_oem_data_rsp" },
11703#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011704
Jeff Johnson295189b2012-06-20 16:38:30 -070011705 /* handlers for main ioctl - host offload */
11706 {
11707 WLAN_PRIV_SET_HOST_OFFLOAD,
11708 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11709 0,
11710 "setHostOffload" },
11711
11712 {
11713 WLAN_GET_WLAN_STATISTICS,
11714 0,
11715 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11716 "getWlanStats" },
11717
11718 {
11719 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011720 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11721 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011722 0,
11723 "setKeepAlive" },
11724#ifdef WLAN_FEATURE_PACKET_FILTERING
11725 {
11726 WLAN_SET_PACKET_FILTER_PARAMS,
11727 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11728 0,
11729 "setPktFilter" },
11730#endif
11731#ifdef FEATURE_WLAN_SCAN_PNO
11732 {
11733 WLAN_SET_PNO,
11734 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11735 0,
11736 "setpno" },
11737#endif
11738 {
11739 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011741 0,
11742 "SETBAND" },
11743 /* handlers for dynamic MC BC ioctl */
11744 {
11745 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011746 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011747 0,
11748 "setMCBCFilter" },
11749 {
11750 WLAN_PRIV_CLEAR_MCBC_FILTER,
11751 0,
11752 0,
11753 "clearMCBCFilter" },
11754 {
11755 WLAN_SET_POWER_PARAMS,
11756 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11757 0,
11758 "setpowerparams" },
11759 {
11760 WLAN_GET_LINK_SPEED,
11761 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011762 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Nishank Aggarwal87a36882017-07-11 15:28:27 +053011763 {
11764 WLAN_PRIV_SET_FTIES,
11765 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
11766 0, "set_ft_ies"},
Jeff Johnson295189b2012-06-20 16:38:30 -070011767};
11768
11769
11770
11771const struct iw_handler_def we_handler_def = {
11772 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11773 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11774 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11775
11776 .standard = (iw_handler *)we_handler,
11777 .private = (iw_handler *)we_private,
11778 .private_args = we_private_args,
11779 .get_wireless_stats = get_wireless_stats,
11780};
11781
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011782int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11783{
11784 v_U32_t cmd = 288; //Command to RIVA
11785 hdd_context_t *pHddCtx = NULL;
11786 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11787 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11788 /*
11789 *configMccParam : specify the bit which needs to be modified
11790 *allowed to update based on wlan_qcom_cfg.ini
11791 * configuration
11792 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11793 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11794 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11795 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11796 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11797 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11798 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11799 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11800 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11801 * Bit 9 : Reserved
11802 */
11803 switch (arg1)
11804 {
11805 //Update MCC SCHEDULE_TIME_SLICE parameter
11806 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11807 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11808 {
11809 if((arg2 >= 5) && (arg2 <= 20))
11810 {
11811 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11812 }
11813 else
11814 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011815 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011816 return 0;
11817 }
11818 }
11819 break;
11820
11821 //Update MCC MAX_NULL_SEND_TIME parameter
11822 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11823 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11824 {
11825 if((arg2 >= 1) && (arg2 <= 10))
11826 {
11827 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11828 }
11829 else
11830 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011831 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011832 return 0;
11833 }
11834 }
11835 break;
11836
11837 //Update MCC TX_EARLY_STOP_TIME parameter
11838 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11839 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11840 {
11841 if((arg2 >= 1) && (arg2 <= 10))
11842 {
11843 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11844 }
11845 else
11846 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011847 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011848 return 0;
11849 }
11850 }
11851 break;
11852
11853 //Update MCC RX_DRAIN_TIME parameter
11854 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11855 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11856 {
11857 if((arg2 >= 1) && (arg2 <= 10))
11858 {
11859 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11860 }
11861 else
11862 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011863 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011864 return 0;
11865 }
11866 }
11867 break;
11868
11869 //Update MCC CHANNEL_SWITCH_TIME parameter
11870 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11871 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11872 {
11873 if((arg2 >= 1) && (arg2 <= 20))
11874 {
11875 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11876 }
11877 else
11878 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011879 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011880 return 0;
11881 }
11882 }
11883 break;
11884
11885 //Update MCC MIN_CHANNEL_TIME parameter
11886 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11887 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11888 {
11889 if((arg2 >= 5) && (arg2 <= 20))
11890 {
11891 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11892 }
11893 else
11894 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011895 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011896 return 0;
11897 }
11898 }
11899 break;
11900
11901 //Update MCC PARK_BEFORE_TBTT parameter
11902 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11903 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11904 {
11905 if((arg2 >= 1) && (arg2 <= 5))
11906 {
11907 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11908 }
11909 else
11910 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011911 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011912 return 0;
11913 }
11914 }
11915 break;
11916
11917 //Update MCC MIN_AFTER_DTIM parameter
11918 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11919 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11920 {
11921 if((arg2 >= 5) && (arg2 <= 15))
11922 {
11923 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11924 }
11925 else
11926 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011927 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011928 return 0;
11929 }
11930 }
11931 break;
11932
11933 //Update MCC TOO_CLOSE_MARGIN parameter
11934 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11935 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11936 {
11937 if((arg2 >= 1) && (arg2 <= 3))
11938 {
11939 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11940 }
11941 else
11942 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011943 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011944 return 0;
11945 }
11946 }
11947 break;
11948
11949 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011950 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011951 __FUNCTION__,arg1);
11952 break;
11953 }
11954 return 0;
11955}
11956
Jeff Johnson295189b2012-06-20 16:38:30 -070011957int hdd_set_wext(hdd_adapter_t *pAdapter)
11958{
11959 hdd_wext_state_t *pwextBuf;
11960 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011961 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011962
11963 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11964
11965 // Now configure the roaming profile links. To SSID and bssid.
11966 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11967 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11968
11969 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11970 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11971
11972 /*Set the numOfChannels to zero to scan all the channels*/
11973 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11974 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11975
11976 /* Default is no encryption */
11977 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11978 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11979
11980 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11981 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11982
11983 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11984
11985 /* Default is no authentication */
11986 pwextBuf->roamProfile.AuthType.numEntries = 1;
11987 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11988
11989 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11990 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11991
11992 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011993 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011994
11995 hdd_clearRoamProfileIe(pAdapter);
11996
11997 return VOS_STATUS_SUCCESS;
11998
11999 }
12000
12001int hdd_register_wext(struct net_device *dev)
12002 {
12003 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12004 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12005 VOS_STATUS status;
12006
12007 ENTER();
12008
12009 // Zero the memory. This zeros the profile structure.
12010 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
12011
12012 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
12013
12014
12015 status = hdd_set_wext(pAdapter);
12016
12017 if(!VOS_IS_STATUS_SUCCESS(status)) {
12018
Arif Hussain6d2a3322013-11-17 19:50:10 -080012019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012020 return eHAL_STATUS_FAILURE;
12021 }
12022
12023 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
12024 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012026 return eHAL_STATUS_FAILURE;
12027 }
12028
12029 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
12030 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012032 return eHAL_STATUS_FAILURE;
12033 }
12034
12035 // Register as a wireless device
12036 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
12037
12038 EXIT();
12039 return 0;
12040}
12041
12042int hdd_UnregisterWext(struct net_device *dev)
12043{
Jeff Johnsonc135a9a2017-09-19 08:37:24 -070012044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %pK", __func__, dev);
c_hpothu2a13bc32015-01-21 12:48:54 +053012045 if (dev != NULL)
12046 {
12047 rtnl_lock();
12048 dev->wireless_handlers = NULL;
12049 rtnl_unlock();
12050 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053012051
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 return 0;
12053}
12054
12055