blob: 7e972de5497b6eb6598f689a8b902b40dbf00e82 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhb3e376c2017-01-04 15:27:13 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Anand N Sunkad0a3436f2015-05-01 14:22:19 +053053#include <linux/wcnss_wlan.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053054#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <wlan_hdd_includes.h>
56#include <wlan_btc_svc.h>
57#include <wlan_nlink_common.h>
58#ifdef WLAN_BTAMP_FEATURE
59#include <bap_hdd_main.h>
60#endif
61#include <vos_api.h>
62#include <net/arp.h>
63#include "ccmApi.h"
64#include "sirParams.h"
65#include "csrApi.h"
66#include "csrInsideApi.h"
67#if defined WLAN_FEATURE_VOWIFI
68#include "smeRrmInternal.h"
69#endif
70#include <aniGlobal.h>
71#include "dot11f.h"
72#include <wlan_hdd_wowl.h>
73#include <wlan_hdd_cfg.h>
74#include <wlan_hdd_wmm.h>
75#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef CONFIG_HAS_EARLYSUSPEND
82#include <linux/earlysuspend.h>
83#endif
84#include "wlan_hdd_power.h"
85#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530107#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530108
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#ifdef CONFIG_HAS_EARLYSUSPEND
110extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
111extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
112#endif
113
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800115#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530119#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
Atul Mittalc0f739f2014-07-31 13:47:47 +0530122// tdlsoffchan
123#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530124static int tdlsOffCh = 1;
125static int tdlsOffChBwOffset = 0;
126#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530127
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700128static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/* To Validate Channel against the Frequency and Vice-Versa */
132static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
133 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
134 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
135 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
136 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
137 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
138 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
139 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800140 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
141 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700142
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800143#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700144
145/* Private ioctls and their sub-ioctls */
146#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
147#define WE_SET_11D_STATE 1
148#define WE_WOWL 2
149#define WE_SET_POWER 3
150#define WE_SET_MAX_ASSOC 4
151#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
152#define WE_SET_DATA_INACTIVITY_TO 6
153#define WE_SET_MAX_TX_POWER 7
154#define WE_SET_HIGHER_DTIM_TRANSITION 8
155#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530156#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700157#define WE_SET_MAX_TX_POWER_2_4 11
158#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800159/* Private IOCTL for debug connection issues */
160#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530161// tdlsoffchan
162#ifdef FEATURE_WLAN_TDLS
163#define WE_SET_TDLS_OFF_CHAN 14
164#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
165#define WE_SET_TDLS_OFF_CHAN_MODE 16
166#endif
Peng Xu2446a892014-09-05 17:21:18 +0530167#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530168#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530169#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530170#ifdef FEATURE_WLAN_TDLS
171#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
172#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530173#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530174#define WE_SET_MONITOR_STATE 22
Sushant Kaushik33200572015-08-05 16:46:20 +0530175#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530176#define WE_SET_PROXIMITY_ENABLE 24
Manjeet Singh3ed79242017-01-11 19:04:32 +0530177#define WE_CAP_TSF 25
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +0530178#define WE_SET_MODULATED_DTIM 26
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +0530179#define WLAN_SET_DYNNAMIC_AGGREGATION 27
Jeff Johnson295189b2012-06-20 16:38:30 -0700180
181/* Private ioctls and their sub-ioctls */
182#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
183#define WE_GET_11D_STATE 1
184#define WE_IBSS_STATUS 2
185#define WE_PMC_STATE 3
186#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700187#define WE_GET_MAX_ASSOC 6
188#define WE_GET_WDI_DBG 7
189#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
190#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530191#define WE_GET_SCAN_BAND_PREFERENCE 10
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +0530192#define WE_GET_ANTENA_DIVERSITY_SELECTION 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700193/* Private ioctls and their sub-ioctls */
194#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
195
196/* Private ioctls and their sub-ioctls */
197#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
198#define WE_WOWL_ADD_PTRN 1
199#define WE_WOWL_DEL_PTRN 2
200#if defined WLAN_FEATURE_VOWIFI
201#define WE_NEIGHBOR_REPORT_REQUEST 3
202#endif
203#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
204#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530205#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700206
207/* Private ioctls and their sub-ioctls */
208#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
209#define WE_SET_WLAN_DBG 1
210#define WE_SET_WDI_DBG 2
211#define WE_SET_SAP_CHANNELS 3
212
213/* Private ioctls and their sub-ioctls */
214#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
215#define WE_WLAN_VERSION 1
216#define WE_GET_STATS 2
217#define WE_GET_CFG 3
218#define WE_GET_WMM_STATUS 4
219#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700220#ifdef WLAN_FEATURE_11AC
221#define WE_GET_RSSI 6
222#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800223#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800224#ifdef FEATURE_WLAN_TDLS
225#define WE_GET_TDLS_PEERS 8
226#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700227#ifdef WLAN_FEATURE_11W
228#define WE_GET_11W_INFO 9
229#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530230#define WE_GET_STATES 10
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530231#ifdef WLAN_FEATURE_RMC
232#define WE_GET_IBSS_STA_INFO 11
233#endif
234#define WE_GET_SNR 12
Jeff Johnson295189b2012-06-20 16:38:30 -0700235
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +0530236#ifdef FEATURE_OEM_DATA_SUPPORT
237#define WE_GET_OEM_DATA_CAP 13
238#endif
239
Jeff Johnson295189b2012-06-20 16:38:30 -0700240/* Private ioctls and their sub-ioctls */
241#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
242#define WE_CLEAR_STATS 1
243#define WE_INIT_AP 2
244#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530245#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700246#define WE_ENABLE_AMP 4
247#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530248#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700249#define WE_ENABLE_DXE_STALL_DETECT 6
250#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700251#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530252#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530253#ifdef WLAN_FEATURE_RMC
254#define WE_IBSS_GET_PEER_INFO_ALL 10
255#endif
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530256#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530257#define WE_DUMP_ROAM_TIMER_LOG 12
258#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530259#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530260#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530261
Jeff Johnson295189b2012-06-20 16:38:30 -0700262/* Private ioctls and their sub-ioctls */
263#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
264#define WE_LOG_DUMP_CMD 1
265
Jeff Johnson295189b2012-06-20 16:38:30 -0700266#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800267//IOCTL to configure MCC params
268#define WE_MCC_CONFIG_CREDENTIAL 3
269#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700270
Chilam NG571c65a2013-01-19 12:27:36 +0530271#ifdef FEATURE_WLAN_TDLS
272#define WE_TDLS_CONFIG_PARAMS 5
273#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530274#ifdef WLAN_FEATURE_RMC
275#define WE_IBSS_GET_PEER_INFO 6
276#endif
Chilam NG571c65a2013-01-19 12:27:36 +0530277
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700278#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530279#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530280#define WE_CONFIGURE_MONITOR_MODE 10
281#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700282
Chilam Ng01120412013-02-19 18:32:21 -0800283#ifdef FEATURE_WLAN_TDLS
284#undef MAX_VAR_ARGS
285#define MAX_VAR_ARGS 10
286#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700287#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800288#endif
289
Jeff Johnson295189b2012-06-20 16:38:30 -0700290/* Private ioctls (with no sub-ioctls) */
291/* note that they must be odd so that they have "get" semantics */
292#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
293#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
294#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
295
Girish Gowli464c9c82014-06-09 19:47:53 +0530296/* (SIOCIWFIRSTPRIV + 8) is currently unused */
297/* (SIOCIWFIRSTPRIV + 16) is currently unused */
298/* (SIOCIWFIRSTPRIV + 10) is currently unused */
299/* (SIOCIWFIRSTPRIV + 12) is currently unused */
300/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manjeet Singh3ed79242017-01-11 19:04:32 +0530301#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
302#define WE_GET_TSF 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700303
Jeff Johnsone7245742012-09-05 17:12:55 -0700304#ifdef FEATURE_OEM_DATA_SUPPORT
305/* Private ioctls for setting the measurement configuration */
306#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
307#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
308#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700309
310#ifdef WLAN_FEATURE_VOWIFI_11R
311#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
312#endif
313
314/* Private ioctl for setting the host offload feature */
315#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
316
317/* Private ioctl to get the statistics */
318#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
319
320/* Private ioctl to set the Keep Alive Params */
321#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
322#ifdef WLAN_FEATURE_PACKET_FILTERING
323/* Private ioctl to set the Packet Filtering Params */
324#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
325#endif
326
327#ifdef FEATURE_WLAN_SCAN_PNO
328/* Private ioctl to get the statistics */
329#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
330#endif
331
332#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
333
334#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
335#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700336/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700337
Jeff Johnson295189b2012-06-20 16:38:30 -0700338#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
339#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
340
341#define WLAN_STATS_INVALID 0
342#define WLAN_STATS_RETRY_CNT 1
343#define WLAN_STATS_MUL_RETRY_CNT 2
344#define WLAN_STATS_TX_FRM_CNT 3
345#define WLAN_STATS_RX_FRM_CNT 4
346#define WLAN_STATS_FRM_DUP_CNT 5
347#define WLAN_STATS_FAIL_CNT 6
348#define WLAN_STATS_RTS_FAIL_CNT 7
349#define WLAN_STATS_ACK_FAIL_CNT 8
350#define WLAN_STATS_RTS_SUC_CNT 9
351#define WLAN_STATS_RX_DISCARD_CNT 10
352#define WLAN_STATS_RX_ERROR_CNT 11
353#define WLAN_STATS_TX_BYTE_CNT 12
354
355#define WLAN_STATS_RX_BYTE_CNT 13
356#define WLAN_STATS_RX_RATE 14
357#define WLAN_STATS_TX_RATE 15
358
Jeff Johnsone7245742012-09-05 17:12:55 -0700359#define WLAN_STATS_RX_UC_BYTE_CNT 16
360#define WLAN_STATS_RX_MC_BYTE_CNT 17
361#define WLAN_STATS_RX_BC_BYTE_CNT 18
362#define WLAN_STATS_TX_UC_BYTE_CNT 19
363#define WLAN_STATS_TX_MC_BYTE_CNT 20
364#define WLAN_STATS_TX_BC_BYTE_CNT 21
365
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800366#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
367 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
368 { \
369 *__p++ = __type; \
370 *__p++ = __size; \
371 memcpy(__p, __val, __size); \
372 __p += __size; \
373 __tlen += __size + 2; \
374 } \
375 else \
376 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800377 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800378 } \
379 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700380
381#define VERSION_VALUE_MAX_LEN 32
382
383#define TX_PER_TRACKING_DEFAULT_RATIO 5
384#define TX_PER_TRACKING_MAX_RATIO 10
385#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
386
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530387#define WLAN_ADAPTER 0
388#define P2P_ADAPTER 1
389
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +0530390#define TX_PWR_MIN 6
391#define TX_PWR_MAX 22
392#define TX_PWR_DEF 50
393
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +0530394/* Dynamic Aggregation */
395#define DISABLE_AGGREGATION 0
396#define ENABLE_AGGREGATION 1
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530397/*
398 * When supplicant sends SETBAND ioctl it queries for channels from
399 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
400 * This is not required if the return type from ioctl is
401 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
402 * event as part of regulatory_hint.
403 */
404enum {
405 SEND_CHANNEL_CHANGE_EVENT = 0,
406 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
407};
408
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800409/*MCC Configuration parameters */
410enum {
411 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
412 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
413 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
414 MCC_RX_DRAIN_TIME_CFG_PARAM,
415 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
416 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
417 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
418 MCC_MIN_AFTER_DTIM_CFG_PARAM,
419 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
420};
421
422int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
423 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
424
Jeff Johnson295189b2012-06-20 16:38:30 -0700425#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +0530426int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest);
Jeff Johnson295189b2012-06-20 16:38:30 -0700427#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530428static int get_fwr_memdump(struct net_device *,
429 struct iw_request_info *,
430 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700431/**---------------------------------------------------------------------------
432
Arif Hussain0273cba2014-01-07 20:58:29 -0800433 \brief mem_alloc_copy_from_user_helper -
434
435 Helper function to allocate buffer and copy user data.
436
437 \param - wrqu - Pointer to IOCTL Data.
438 len - size
439
440 \return - On Success pointer to buffer, On failure NULL
441
442 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530443void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800444{
445 u8 *ptr = NULL;
446
447 /* in order to protect the code, an extra byte is post appended to the buffer
448 * and the null termination is added. However, when allocating (len+1) byte
449 * of memory, we need to make sure that there is no uint overflow when doing
450 * addition. In theory check len < UINT_MAX protects the uint overflow. For
451 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
452 * guess, now, it is assumed that the private command buffer size is no
453 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
454 */
455 if (len > MAX_USER_COMMAND_SIZE)
456 {
457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
458 "Invalid length");
459 return NULL;
460 }
461
462 ptr = kmalloc(len + 1, GFP_KERNEL);
463 if (NULL == ptr)
464 {
465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
466 "unable to allocate memory");
467 return NULL;
468 }
469
470 if (copy_from_user(ptr, wrqu_data, len))
471 {
472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
473 "%s: failed to copy data to user buffer", __func__);
474 kfree(ptr);
475 return NULL;
476 }
477 ptr[len] = '\0';
478 return ptr;
479}
480
Girish Gowli488ef492014-06-12 18:44:33 +0530481// Function to handle and get compatible struct iw_point passed to ioctl.
482int hdd_priv_get_data(struct iw_point *p_priv_data,
483 union iwreq_data *wrqu)
484{
485 if ((NULL == p_priv_data) || (NULL == wrqu))
486 {
487 return -EINVAL;
488 }
489
490#ifdef CONFIG_COMPAT
491 if (is_compat_task())
492 {
493 struct compat_iw_point *p_compat_priv_data;
494
495 // Compat task: typecast to campat structure and copy the members.
496 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
497
498 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
499 p_priv_data->length = p_compat_priv_data->length;
500 p_priv_data->flags = p_compat_priv_data->flags;
501 }//if(is_compat_task())
502 else
503 {
504#endif //#ifdef CONFIG_COMPAT
505
506 // Non compat task: directly copy the structure.
507 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
508
509#ifdef CONFIG_COMPAT
510 }//else of - if(is_compat_task())
511#endif //#ifdef CONFIG_COMPAT
512
513 return 0;
514}
515
Arif Hussain0273cba2014-01-07 20:58:29 -0800516/**---------------------------------------------------------------------------
517
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 \brief hdd_wlan_get_version() -
519
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800520 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700521
522 \param - pAdapter Pointer to the adapter.
523 wrqu - Pointer to IOCTL REQUEST Data.
524 extra - Pointer to char
525
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800526 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700527
528 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800529void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
530 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700531{
532 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800533 tSirVersionString wcnss_SW_version;
534 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530535 tSirVersionString iris_name;
536 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800537 char *pSWversion;
538 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700540
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800541 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
542 sizeof(wcnss_SW_version));
543 if (VOS_IS_STATUS_SUCCESS(status))
544 {
545 pSWversion = wcnss_SW_version;
546 }
547 else
548 {
549 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 }
551
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800552 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
553 sizeof(wcnss_HW_version));
554 if (VOS_IS_STATUS_SUCCESS(status))
555 {
556 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800558 else
559 {
560 pHWversion = "Unknown";
561 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700562
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530563 status = wcnss_get_iris_name(iris_name);
564
565 if (!status) {
566 pIRISversion = iris_name;
567 } else {
568 pIRISversion = "Unknown";
569 }
570
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700571 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530572 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800573 QWLAN_VERSIONSTR,
574 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530575 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800576
577 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700578}
579
Abhishek Singh7cd040e2016-01-07 10:51:04 +0530580#ifdef WLAN_FEATURE_RMC
581void hdd_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp)
582{
583 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData;
584 tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp;
585 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
586 v_U8_t i;
587
588 if (NULL != pPeerInfo && eHAL_STATUS_SUCCESS == pPeerInfo->status)
589 {
590 pStaCtx->ibss_peer_info.status = pPeerInfo->status;
591 pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers;
592 for (i = 0; i < pPeerInfo->numPeers; i++)
593 {
594 memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i],
595 &pPeerInfo->peerInfoParams[i], sizeof(hdd_ibss_peer_info_params_t));
596 }
597 }
598 else
599 {
600 hddLog(LOGE,
601 FL("PEER_INFO_CMD_STATUS is not SUCCESS"));
602 }
603
604 complete(&pAdapter->ibss_peer_info_comp);
605}
606
607v_MACADDR_t* hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter, v_U8_t staIdx)
608{
609 v_U8_t idx;
610 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
611
612 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
613 {
614 if ( 0 != pHddStaCtx->conn_info.staId[ idx ] &&
615 staIdx == pHddStaCtx->conn_info.staId[ idx ])
616 {
617 return (&pHddStaCtx->conn_info.peerMacAddress[ idx ]);
618 }
619 }
620 return NULL;
621}
622
623eHalStatus hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx)
624{
625 eHalStatus status = eHAL_STATUS_FAILURE;
626 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
627 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
628 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
629
630 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
631 VOS_FALSE, staIdx);
632
633 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
634
635 if (eHAL_STATUS_SUCCESS == status)
636 {
637 long ret;
638 ret = wait_for_completion_interruptible_timeout
639 (&pAdapter->ibss_peer_info_comp,
640 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
641 if (ret <= 0)
642 {
643 hddLog(VOS_TRACE_LEVEL_ERROR,
644 FL("failed wait on ibss_peer_info_comp %ld"), ret);
645 return eHAL_STATUS_FAILURE;
646 }
647
648 /** Print the peer info */
649 pr_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numIBSSPeers);
650 pr_info("============================================================");
651 {
652 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
653 staIdx);
654 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
655
656 if (NULL != macAddr)
657 {
658 pr_info("PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
659 MAC_ADDR_ARRAY(macAddr->bytes),
660 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[0].rssi);
661 }
662 else
663 {
664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
665 " ERROR: PEER MAC ADDRESS NOT FOUND ");
666 }
667 }
668 }
669 else
670 {
671 hddLog(VOS_TRACE_LEVEL_WARN,
672 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
673 }
674
675 return status;
676}
677
678eHalStatus hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
679{
680 eHalStatus status = eHAL_STATUS_FAILURE;
681 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
682 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
683 hdd_ibss_peer_info_t *pPeerInfo = &pStaCtx->ibss_peer_info;
684 int i;
685
686 status = sme_RequestIBSSPeerInfo(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
687 VOS_TRUE, 0xFF);
688 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
689
690 if (eHAL_STATUS_SUCCESS == status)
691 {
692 long ret;
693 ret = wait_for_completion_interruptible_timeout
694 (&pAdapter->ibss_peer_info_comp,
695 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
696 if (ret <= 0)
697 {
698 hddLog(VOS_TRACE_LEVEL_ERROR,
699 FL("failed wait on ibss_peer_info_comp %ld"), ret);
700 return eHAL_STATUS_FAILURE;
701 }
702
703 /** Print the peer info */
704 pr_info("pPeerInfo->numIBSSPeers = %d ", (int)pPeerInfo->numIBSSPeers);
705 pr_info("============================================================");
706 for (i = 0; i < pPeerInfo->numIBSSPeers; i++)
707 {
708 v_U8_t staIdx = pPeerInfo->ibssPeerList[i].staIdx;
709 v_MACADDR_t *macAddr = hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter,
710 staIdx);
711 v_U32_t txRateMbps = ((pPeerInfo->ibssPeerList[0].txRate)*500*1000)/1000000;
712
713 pr_info("STAIDX:%d ", (int)pPeerInfo->ibssPeerList[i].staIdx);
714 if (NULL != macAddr)
715 {
716 pr_info(" PEER ADDR :" MAC_ADDRESS_STR " TxRate: %d Mbps RSSI: %d",
717 MAC_ADDR_ARRAY(macAddr->bytes),
718 (int)txRateMbps, (int)pPeerInfo->ibssPeerList[i].rssi);
719 }
720 else
721 {
722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
723 " ERROR: PEER MAC ADDRESS NOT FOUND ");
724 }
725 }
726 }
727 else
728 {
729 hddLog(VOS_TRACE_LEVEL_WARN,
730 "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__);
731 }
732
733 return status;
734}
735#endif /* WLAN_FEATURE_RMC */
736
Jeff Johnson295189b2012-06-20 16:38:30 -0700737int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
738{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530739 tHalHandle hHal;
740 hdd_context_t *pHddCtx;
741 v_U32_t threshold = 0;
742 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700743
744 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530745 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530746 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
748 "%s: Adapter is NULL",__func__);
749 return -EINVAL;
750 }
751
752 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
753 ret = wlan_hdd_validate_context(pHddCtx);
754 if (0 != ret)
755 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530756 return ret;
757 }
758
759 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
760 if (NULL == hHal)
761 {
762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
763 "%s: Hal Context is NULL",__func__);
764 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 }
766
767 if ( eHAL_STATUS_SUCCESS !=
768 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
769 {
c_hpothub8245442013-11-20 23:41:09 +0530770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
771 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 return -EIO;
773 }
774 wrqu->rts.value = threshold;
775
776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800777 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700778
779 EXIT();
780
781 return 0;
782}
783
784int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
785{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530786 tHalHandle hHal;
787 hdd_context_t *pHddCtx;
788 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700789
790 ENTER();
791
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530792 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530793 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
795 "%s: Adapter is NULL",__func__);
796 return -EINVAL;
797 }
798
799 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
800 status = wlan_hdd_validate_context(pHddCtx);
801 if (0 != status)
802 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530803 return status;
804 }
805
806 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
807 if (NULL == hHal)
808 {
809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
810 "%s: Hal Context is NULL",__func__);
811 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 }
813
814 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
815 != eHAL_STATUS_SUCCESS )
816 {
c_hpothub8245442013-11-20 23:41:09 +0530817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
818 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 return -EIO;
820 }
821 wrqu->frag.value = threshold;
822
823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800824 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700825
826 EXIT();
827
828 return 0;
829}
830
831int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
832{
Jeff Johnsone7245742012-09-05 17:12:55 -0700833 int i;
834 if (channel > 0)
835 {
836 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
837 {
838 if (channel == freq_chan_map[i].chan)
839 {
840 *pfreq = freq_chan_map[i].freq;
841 return 1;
842 }
843 }
844 }
845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800846 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700847 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700848}
849
850static v_BOOL_t
851hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
852{
853 v_BOOL_t rsnType = VOS_FALSE;
854 // is the authType supported?
855 switch (authType)
856 {
857 case eCSR_AUTH_TYPE_NONE: //never used
858 rsnType = eANI_BOOLEAN_FALSE;
859 break;
860 // MAC layer authentication types
861 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
862 rsnType = eANI_BOOLEAN_FALSE;
863 break;
864 case eCSR_AUTH_TYPE_SHARED_KEY:
865 rsnType = eANI_BOOLEAN_FALSE;
866 break;
867 case eCSR_AUTH_TYPE_AUTOSWITCH:
868 rsnType = eANI_BOOLEAN_FALSE;
869 break;
870
871 // Upper layer authentication types
872 case eCSR_AUTH_TYPE_WPA:
873 rsnType = eANI_BOOLEAN_TRUE;
874 break;
875 case eCSR_AUTH_TYPE_WPA_PSK:
876 rsnType = eANI_BOOLEAN_TRUE;
877 break;
878 case eCSR_AUTH_TYPE_WPA_NONE:
879 rsnType = eANI_BOOLEAN_TRUE;
880 break;
881#ifdef WLAN_FEATURE_VOWIFI_11R
882 case eCSR_AUTH_TYPE_FT_RSN:
883#endif
884 case eCSR_AUTH_TYPE_RSN:
885 rsnType = eANI_BOOLEAN_TRUE;
886 break;
887#ifdef WLAN_FEATURE_VOWIFI_11R
888 case eCSR_AUTH_TYPE_FT_RSN_PSK:
889#endif
890 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700891#ifdef WLAN_FEATURE_11W
892 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530893 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700894#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 rsnType = eANI_BOOLEAN_TRUE;
896 break;
897 //case eCSR_AUTH_TYPE_FAILED:
898 case eCSR_AUTH_TYPE_UNKNOWN:
899 rsnType = eANI_BOOLEAN_FALSE;
900 break;
901 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800902 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
903 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 rsnType = eANI_BOOLEAN_FALSE;
905 break;
906 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800907 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700908 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 return rsnType;
910}
911
912static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
913{
914 struct statsContext *pStatsContext;
915 hdd_adapter_t *pAdapter;
916
917 if (ioctl_debug)
918 {
919 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700920 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 }
922
923 if (NULL == pContext)
924 {
925 hddLog(VOS_TRACE_LEVEL_ERROR,
926 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700927 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 return;
929 }
930
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 pStatsContext = pContext;
932 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800933
934 /* there is a race condition that exists between this callback
935 function and the caller since the caller could time out either
936 before or while this code is executing. we use a spinlock to
937 serialize these actions */
938 spin_lock(&hdd_context_lock);
939
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
941 {
942 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800943 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 hddLog(VOS_TRACE_LEVEL_WARN,
945 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700946 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 if (ioctl_debug)
948 {
949 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700950 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 }
952 return;
953 }
954
Jeff Johnson72a40512013-12-19 10:14:15 -0800955 /* context is valid so caller is still waiting */
956
957 /* paranoia: invalidate the magic */
958 pStatsContext->magic = 0;
959
Sachin Ahujaa082b672015-10-05 19:51:31 +0530960 /* copy over the rssi.FW will return RSSI as -100
961 * if there are no samples to calculate the average
962 * RSSI
963 */
964 if (rssi != -100)
965 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530966 if (pAdapter->rssi > 0)
967 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800968 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800970
971 /* serialization is complete */
972 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700973}
974
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530975static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
976{
977 struct statsContext *pStatsContext;
978 hdd_adapter_t *pAdapter;
979
980 if (ioctl_debug)
981 {
982 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
983 __func__, (int)snr, (int)staId, pContext);
984 }
985
986 if (NULL == pContext)
987 {
988 hddLog(VOS_TRACE_LEVEL_ERROR,
989 "%s: Bad param, pContext [%p]",
990 __func__, pContext);
991 return;
992 }
993
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530994 pStatsContext = pContext;
995 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800996
997 /* there is a race condition that exists between this callback
998 function and the caller since the caller could time out either
999 before or while this code is executing. we use a spinlock to
1000 serialize these actions */
1001 spin_lock(&hdd_context_lock);
1002
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301003 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
1004 {
1005 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001006 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301007 hddLog(VOS_TRACE_LEVEL_WARN,
1008 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1009 __func__, pAdapter, pStatsContext->magic);
1010 if (ioctl_debug)
1011 {
1012 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1013 __func__, pAdapter, pStatsContext->magic);
1014 }
1015 return;
1016 }
1017
Jeff Johnson72a40512013-12-19 10:14:15 -08001018 /* context is valid so caller is still waiting */
1019
1020 /* paranoia: invalidate the magic */
1021 pStatsContext->magic = 0;
1022
1023 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301024 pAdapter->snr = snr;
1025
Jeff Johnson72a40512013-12-19 10:14:15 -08001026 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301027 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001028
1029 /* serialization is complete */
1030 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301031}
1032
Jeff Johnson295189b2012-06-20 16:38:30 -07001033VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1034{
1035 struct statsContext context;
1036 hdd_context_t *pHddCtx;
1037 hdd_station_ctx_t *pHddStaCtx;
1038 eHalStatus hstatus;
1039 long lrc;
1040
1041 if (NULL == pAdapter)
1042 {
1043 hddLog(VOS_TRACE_LEVEL_WARN,
1044 "%s: Invalid context, pAdapter", __func__);
1045 return VOS_STATUS_E_FAULT;
1046 }
1047 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1048 {
1049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1050 /* return a cached value */
1051 *rssi_value = pAdapter->rssi;
1052 return VOS_STATUS_SUCCESS;
1053 }
1054
1055 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1056 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1057
mukul sharma8aec69b2015-06-10 22:28:43 +05301058 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1059 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
1061 __func__, pAdapter->rssi_on_disconnect);
1062 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +05301063 return VOS_STATUS_SUCCESS;
1064 }
1065
1066 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1067 {
1068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1069 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1070 *rssi_value = pAdapter->rssi;
1071 return VOS_STATUS_SUCCESS;
1072 }
1073
Jeff Johnson295189b2012-06-20 16:38:30 -07001074 init_completion(&context.completion);
1075 context.pAdapter = pAdapter;
1076 context.magic = RSSI_CONTEXT_MAGIC;
1077
1078 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
1079 pHddStaCtx->conn_info.staId[ 0 ],
1080 pHddStaCtx->conn_info.bssId,
1081 &context, pHddCtx->pvosContext);
1082 if (eHAL_STATUS_SUCCESS != hstatus)
1083 {
1084 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001085 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 /* we'll returned a cached value below */
1087 }
1088 else
1089 {
1090 /* request was sent -- wait for the response */
1091 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1092 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 if (lrc <= 0)
1094 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001095 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001096 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 /* we'll now returned a cached value below */
1098 }
1099 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001100
1101 /* either we never sent a request, we sent a request and received a
1102 response or we sent a request and timed out. if we never sent a
1103 request or if we sent a request and got a response, we want to
1104 clear the magic out of paranoia. if we timed out there is a
1105 race condition such that the callback function could be
1106 executing at the same time we are. of primary concern is if the
1107 callback function had already verified the "magic" but had not
1108 yet set the completion variable when a timeout occurred. we
1109 serialize these activities by invalidating the magic while
1110 holding a shared spinlock which will cause us to block if the
1111 callback is currently executing */
1112 spin_lock(&hdd_context_lock);
1113 context.magic = 0;
1114 spin_unlock(&hdd_context_lock);
1115
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 *rssi_value = pAdapter->rssi;
Rajeev Kumar Sirasanagandla4819c182016-11-28 22:25:48 +05301117 hddLog(VOS_TRACE_LEVEL_INFO,
1118 "%s: RSSI = %d", __func__, *rssi_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07001119
1120 return VOS_STATUS_SUCCESS;
1121}
Siddharth Bhal64246172015-02-27 01:04:37 +05301122/**---------------------------------------------------------------------------
1123
1124 \brief wlan_hdd_get_frame_logs() -
1125
1126 This function use to get Frames log.
1127
1128 \param - pAdapter Pointer to the adapter.
1129 flag - Specify type of request. Clear and Send request are
1130 supported.
1131
1132 \return - none
1133
1134 --------------------------------------------------------------------------*/
1135VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
1136{
Siddharth Bhal64246172015-02-27 01:04:37 +05301137 hdd_context_t *pHddCtx;
1138 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +05301139
1140 if (NULL == pAdapter)
1141 {
1142 hddLog(VOS_TRACE_LEVEL_WARN,
1143 "%s: Invalid context, pAdapter", __func__);
1144 return VOS_STATUS_E_FAULT;
1145 }
1146
1147 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1148 if (!pHddCtx->mgmt_frame_logging)
1149 {
Abhishek Singha7d80b12016-02-03 15:27:20 +05301150 hddLog(LOGW, FL("Frame Logging not init!"));
Siddharth Bhal64246172015-02-27 01:04:37 +05301151 return VOS_STATUS_E_AGAIN;
1152 }
1153
Siddharth Bhal4507c262015-04-29 20:20:42 +05301154 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1155 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1156 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301157 {
1158 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1159 return VOS_STATUS_E_INVAL;
1160 }
1161
Siddharth Bhal4507c262015-04-29 20:20:42 +05301162 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1163 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1164 {
1165 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1166 return VOS_STATUS_E_INVAL;
1167 }
1168
Abhishek Singh611295e2015-07-09 11:11:54 +05301169 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +05301170 if (eHAL_STATUS_SUCCESS != hstatus)
1171 {
1172 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +05301173 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +05301174 }
Siddharth Bhal64246172015-02-27 01:04:37 +05301175
1176 return VOS_STATUS_SUCCESS;
1177}
1178
Sachin Ahuja715aafc2015-07-21 23:35:10 +05301179
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301180VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1181{
1182 struct statsContext context;
1183 hdd_context_t *pHddCtx;
1184 hdd_station_ctx_t *pHddStaCtx;
1185 eHalStatus hstatus;
1186 long lrc;
1187 int valid;
1188
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301189 ENTER();
1190
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301191 if (NULL == pAdapter)
1192 {
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 "%s: Invalid context, pAdapter", __func__);
1195 return VOS_STATUS_E_FAULT;
1196 }
1197
1198 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1199
1200 valid = wlan_hdd_validate_context(pHddCtx);
1201 if (0 != valid)
1202 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301203 return VOS_STATUS_E_FAULT;
1204 }
1205
1206 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1207 if (NULL == pHddStaCtx)
1208 {
1209 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1210 return VOS_STATUS_E_FAULT;
1211 }
1212
1213 init_completion(&context.completion);
1214 context.pAdapter = pAdapter;
1215 context.magic = SNR_CONTEXT_MAGIC;
1216
1217 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1218 pHddStaCtx->conn_info.staId[ 0 ],
1219 pHddStaCtx->conn_info.bssId,
1220 &context);
1221 if (eHAL_STATUS_SUCCESS != hstatus)
1222 {
1223 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1224 __func__);
1225 /* we'll returned a cached value below */
1226 }
1227 else
1228 {
1229 /* request was sent -- wait for the response */
1230 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1231 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301232 if (lrc <= 0)
1233 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001234 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301235 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301236 /* we'll now returned a cached value below */
1237 }
1238 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001239
1240 /* either we never sent a request, we sent a request and received a
1241 response or we sent a request and timed out. if we never sent a
1242 request or if we sent a request and got a response, we want to
1243 clear the magic out of paranoia. if we timed out there is a
1244 race condition such that the callback function could be
1245 executing at the same time we are. of primary concern is if the
1246 callback function had already verified the "magic" but had not
1247 yet set the completion variable when a timeout occurred. we
1248 serialize these activities by invalidating the magic while
1249 holding a shared spinlock which will cause us to block if the
1250 callback is currently executing */
1251 spin_lock(&hdd_context_lock);
1252 context.magic = 0;
1253 spin_unlock(&hdd_context_lock);
1254
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301255 *snr = pAdapter->snr;
1256
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301257 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301258 return VOS_STATUS_SUCCESS;
1259}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301260
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001261#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001262
1263static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1264{
1265 struct statsContext *pStatsContext;
1266 hdd_adapter_t *pAdapter;
1267 if (ioctl_debug)
1268 {
1269 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1270 __func__, (int)rssi, (int)staId, pContext);
1271 }
1272
1273 if (NULL == pContext)
1274 {
1275 hddLog(VOS_TRACE_LEVEL_ERROR,
1276 "%s: Bad param, pContext [%p]",
1277 __func__, pContext);
1278 return;
1279 }
1280
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001281 pStatsContext = pContext;
1282 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001283
1284 /* there is a race condition that exists between this callback
1285 function and the caller since the caller could time out either
1286 before or while this code is executing. we use a spinlock to
1287 serialize these actions */
1288 spin_lock(&hdd_context_lock);
1289
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001290 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1291 {
1292 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001293 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001294 hddLog(VOS_TRACE_LEVEL_WARN,
1295 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1296 __func__, pAdapter, pStatsContext->magic);
1297 if (ioctl_debug)
1298 {
1299 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1300 __func__, pAdapter, pStatsContext->magic);
1301 }
1302 return;
1303 }
1304
Jeff Johnson72a40512013-12-19 10:14:15 -08001305 /* context is valid so caller is still waiting */
1306
1307 /* paranoia: invalidate the magic */
1308 pStatsContext->magic = 0;
1309
Sachin Ahujaa082b672015-10-05 19:51:31 +05301310 /* copy over the rssi.FW will return RSSI as -100
1311 * if there are no samples to calculate the average
1312 * RSSI
1313 */
1314 if (rssi != -100)
1315 pAdapter->rssi = rssi;
1316
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301317 if (pAdapter->rssi > 0)
1318 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001319 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001320 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001321
1322 /* serialization is complete */
1323 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001324}
1325
1326
1327
1328VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1329{
1330 struct statsContext context;
1331 hdd_context_t *pHddCtx = NULL;
1332 hdd_station_ctx_t *pHddStaCtx = NULL;
1333 eHalStatus hstatus;
1334 long lrc;
1335
1336 if (NULL == pAdapter)
1337 {
1338 hddLog(VOS_TRACE_LEVEL_WARN,
1339 "%s: Invalid context, pAdapter", __func__);
1340 return VOS_STATUS_E_FAULT;
1341 }
1342 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1343 {
1344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1345 /* return a cached value */
1346 *rssi_value = pAdapter->rssi;
1347 return VOS_STATUS_SUCCESS;
1348 }
1349
1350 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1351 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1352
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301353 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001354 {
1355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1356 /* return a cached value */
1357 *rssi_value = 0;
1358 return VOS_STATUS_SUCCESS;
1359 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301360
1361 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1362 {
1363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1364 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1365 *rssi_value = pAdapter->rssi;
1366 return VOS_STATUS_SUCCESS;
1367 }
1368
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001369 init_completion(&context.completion);
1370 context.pAdapter = pAdapter;
1371 context.magic = RSSI_CONTEXT_MAGIC;
1372
1373 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1374 pHddStaCtx->conn_info.staId[ 0 ],
1375 pHddStaCtx->conn_info.bssId,
1376 &context, pHddCtx->pvosContext);
1377 if (eHAL_STATUS_SUCCESS != hstatus)
1378 {
1379 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1380 __func__);
1381 /* we'll returned a cached value below */
1382 }
1383 else
1384 {
1385 /* request was sent -- wait for the response */
1386 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1387 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001388 if (lrc <= 0)
1389 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001390 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001391 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001392 /* we'll now returned a cached value below */
1393 }
1394 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001395
1396 /* either we never sent a request, we sent a request and received a
1397 response or we sent a request and timed out. if we never sent a
1398 request or if we sent a request and got a response, we want to
1399 clear the magic out of paranoia. if we timed out there is a
1400 race condition such that the callback function could be
1401 executing at the same time we are. of primary concern is if the
1402 callback function had already verified the "magic" but had not
1403 yet set the completion variable when a timeout occurred. we
1404 serialize these activities by invalidating the magic while
1405 holding a shared spinlock which will cause us to block if the
1406 callback is currently executing */
1407 spin_lock(&hdd_context_lock);
1408 context.magic = 0;
1409 spin_unlock(&hdd_context_lock);
1410
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001411 *rssi_value = pAdapter->rssi;
1412
1413 return VOS_STATUS_SUCCESS;
1414}
1415#endif
1416
1417
Jeff Johnson295189b2012-06-20 16:38:30 -07001418void hdd_StatisticsCB( void *pStats, void *pContext )
1419{
1420 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1421 hdd_stats_t *pStatsCache = NULL;
1422 hdd_wext_state_t *pWextState;
1423 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1424
1425 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1426 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1427 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1428 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1429 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1430 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1431
1432 if (pAdapter!= NULL)
1433 pStatsCache = &pAdapter->hdd_stats;
1434
1435
1436 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1437 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1438 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1439 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1440 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1441 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1442
1443 if (pStatsCache!=NULL)
1444 {
1445 // and copy the stats into the cache we keep in the adapter instance structure
1446 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1447 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1448 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1449 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1450 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1451 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1452 }
1453
1454 if(pAdapter)
1455 {
1456 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1457 if(pWextState)
1458 {
1459 vos_status = vos_event_set(&pWextState->vosevent);
1460 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1461 {
1462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001463 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 return;
1465 }
1466 }
1467 }
1468}
1469
1470void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1471{
1472 v_CONTEXT_t pVosContext;
1473 hdd_context_t *pHddCtx;
1474 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1475#if 0
1476 hdd_wext_state_t *pWextState;
1477 v_U32_t roamId;
1478#endif
1479
1480 ENTER();
1481
1482 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1483
1484 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1485 if (NULL == pHddCtx)
1486 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001487 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 return;
1489 }
1490#if 0
1491 pWextState = pAdapter->pWextState;
1492#endif
1493
1494 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1495 {
1496 //TODO Verify is this is really used. If yes need to fix it.
1497 hdd_reconnect_all_adapters( pHddCtx );
1498#if 0
1499 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1500 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1501 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1502
1503 if(VOS_STATUS_SUCCESS == vosStatus)
1504 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1505 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1506
1507 sme_RoamConnect(halHandle,
1508 pAdapter->sessionId, &(pWextState->roamProfile),
1509 &roamId);
1510#endif
1511 }
1512
1513 EXIT();
1514
1515}
1516
1517void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1518{
Jeff Johnson295189b2012-06-20 16:38:30 -07001519 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1520
1521 /* clear WPA/RSN/WSC IE information in the profile */
1522 pWextState->roamProfile.nWPAReqIELength = 0;
1523 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1524 pWextState->roamProfile.nRSNReqIELength = 0;
1525 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1526
Chet Lanctot186b5732013-03-18 10:26:30 -07001527#ifdef FEATURE_WLAN_WAPI
1528 pWextState->roamProfile.nWAPIReqIELength = 0;
1529 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1530#endif
1531
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001533 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301535 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1537 pWextState->roamProfile.nAddIEAssocLength = 0;
1538
1539 pWextState->roamProfile.EncryptionType.numEntries = 1;
1540 pWextState->roamProfile.EncryptionType.encryptionType[0]
1541 = eCSR_ENCRYPT_TYPE_NONE;
1542
1543 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1544 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1545 = eCSR_ENCRYPT_TYPE_NONE;
1546
1547 pWextState->roamProfile.AuthType.numEntries = 1;
1548 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1549
Abhishek Singhb3e376c2017-01-04 15:27:13 +05301550 vos_mem_zero((pWextState->roamProfile.bssid_hint), WNI_CFG_BSSID_LEN);
Chet Lanctot186b5732013-03-18 10:26:30 -07001551#ifdef WLAN_FEATURE_11W
1552 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1553 pWextState->roamProfile.MFPRequired = 0;
1554 pWextState->roamProfile.MFPCapable = 0;
1555#endif
1556
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 pWextState->authKeyMgmt = 0;
1558
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301559 vos_mem_zero(&pWextState->roamProfile.Keys,
1560 sizeof(pWextState->roamProfile.Keys));
1561
Jeff Johnson295189b2012-06-20 16:38:30 -07001562#ifdef FEATURE_WLAN_WAPI
1563 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1564 pAdapter->wapi_info.nWapiMode = 0;
1565#endif
1566
1567 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1568
1569}
1570
1571void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1572{
1573 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001574
Nirav Shahf6bd2672015-03-11 12:53:15 +05301575 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001576 {
1577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301578 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001579 }
1580 else
1581 {
1582 complete(&pAdapter->ula_complete);
1583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001584}
1585
1586VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1587{
1588 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001590 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001591
1592 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1593 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001594 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001595
1596 /*To avoid race condition between the set key and the last EAPOL
1597 packet, notify TL to finish upper layer authentication incase if the
1598 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001599 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001600
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001601 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 {
1603 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1604 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1605 __LINE__, vos_status );
1606 return vos_status;
1607
1608 }
1609
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001610 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301612 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001613 {
1614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301615 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001616 /* we'll still fall through and return success since the
1617 * connection may still get established but is just taking
1618 * too long for us to wait */
1619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 }
1621 return VOS_STATUS_SUCCESS;
1622}
1623
1624v_U8_t* wlan_hdd_get_vendor_oui_ie_ptr(v_U8_t *oui, v_U8_t oui_size, v_U8_t *ie, int ie_len)
1625{
1626
1627 int left = ie_len;
1628 v_U8_t *ptr = ie;
1629 v_U8_t elem_id,elem_len;
1630 v_U8_t eid = 0xDD;
1631
1632 if ( NULL == ie || 0 == ie_len )
1633 return NULL;
1634
1635 while(left >= 2)
1636 {
1637 elem_id = ptr[0];
1638 elem_len = ptr[1];
1639 left -= 2;
1640 if(elem_len > left)
1641 {
1642 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001643 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001644 eid,elem_len,left);
1645 return NULL;
1646 }
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,
3343 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003344 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 return;
3346 }
3347
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003349
Jeff Johnson72a40512013-12-19 10:14:15 -08003350 /* there is a race condition that exists between this callback
3351 function and the caller since the caller could time out either
3352 before or while this code is executing. we use a spinlock to
3353 serialize these actions */
3354 spin_lock(&hdd_context_lock);
3355
3356 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 {
3358 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003359 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003361 "%s: Invalid context, magic [%08x]",
3362 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003363
3364 if (ioctl_debug)
3365 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003366 pr_info("%s: Invalid context, magic [%08x]\n",
3367 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 }
3369 return;
3370 }
3371
Jeff Johnson72a40512013-12-19 10:14:15 -08003372 /* context is valid so caller is still waiting */
3373
3374 /* paranoia: invalidate the magic */
3375 pStatsContext->magic = 0;
3376
3377 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003379
3380 /* serialization is complete */
3381 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003382}
3383
3384/* Callback function for tx per hit */
3385void hdd_tx_per_hit_cb (void *pCallbackContext)
3386{
3387 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3388 unsigned char tx_fail[16];
3389 union iwreq_data wrqu;
3390
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303391 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003393 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 return;
3395 }
3396 memset(&wrqu, 0, sizeof(wrqu));
3397 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3398 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3399}
3400
3401void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3402{
3403 struct statsContext *pStatsContext;
3404 tCsrGlobalClassAStatsInfo *pClassAStats;
3405 hdd_adapter_t *pAdapter;
3406
3407 if (ioctl_debug)
3408 {
3409 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003410 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 }
3412
3413 if ((NULL == pStats) || (NULL == pContext))
3414 {
3415 hddLog(VOS_TRACE_LEVEL_ERROR,
3416 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003417 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 return;
3419 }
3420
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 pClassAStats = pStats;
3422 pStatsContext = pContext;
3423 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003424
3425 /* there is a race condition that exists between this callback
3426 function and the caller since the caller could time out either
3427 before or while this code is executing. we use a spinlock to
3428 serialize these actions */
3429 spin_lock(&hdd_context_lock);
3430
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3432 {
3433 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003434 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 hddLog(VOS_TRACE_LEVEL_WARN,
3436 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003437 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 if (ioctl_debug)
3439 {
3440 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003441 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 }
3443 return;
3444 }
3445
Jeff Johnson72a40512013-12-19 10:14:15 -08003446 /* context is valid so caller is still waiting */
3447
3448 /* paranoia: invalidate the magic */
3449 pStatsContext->magic = 0;
3450
3451 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3453
Jeff Johnson72a40512013-12-19 10:14:15 -08003454 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003456
3457 /* serialization is complete */
3458 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003459}
3460
3461VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3462{
3463 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3464 eHalStatus hstatus;
3465 long lrc;
3466 struct statsContext context;
3467
3468 if (NULL == pAdapter)
3469 {
3470 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3471 return VOS_STATUS_E_FAULT;
3472 }
3473 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3474 {
3475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3476 return VOS_STATUS_SUCCESS;
3477 }
3478
3479 /* we are connected
3480 prepare our callback context */
3481 init_completion(&context.completion);
3482 context.pAdapter = pAdapter;
3483 context.magic = STATS_CONTEXT_MAGIC;
3484 /* query only for Class A statistics (which include link speed) */
3485 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3486 eCSR_HDD,
3487 SME_GLOBAL_CLASSA_STATS,
3488 hdd_GetClassA_statisticsCB,
3489 0, // not periodic
3490 FALSE, //non-cached results
3491 pHddStaCtx->conn_info.staId[0],
3492 &context);
3493 if (eHAL_STATUS_SUCCESS != hstatus)
3494 {
3495 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003496 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003497 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 /* we'll returned a cached value below */
3499 }
3500 else
3501 {
3502 /* request was sent -- wait for the response */
3503 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3504 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 if (lrc <= 0)
3506 {
3507 hddLog(VOS_TRACE_LEVEL_ERROR,
3508 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003509 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 }
3511 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003512
3513 /* either we never sent a request, we sent a request and received a
3514 response or we sent a request and timed out. if we never sent a
3515 request or if we sent a request and got a response, we want to
3516 clear the magic out of paranoia. if we timed out there is a
3517 race condition such that the callback function could be
3518 executing at the same time we are. of primary concern is if the
3519 callback function had already verified the "magic" but had not
3520 yet set the completion variable when a timeout occurred. we
3521 serialize these activities by invalidating the magic while
3522 holding a shared spinlock which will cause us to block if the
3523 callback is currently executing */
3524 spin_lock(&hdd_context_lock);
3525 context.magic = 0;
3526 spin_unlock(&hdd_context_lock);
3527
3528 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 return VOS_STATUS_SUCCESS;
3530}
3531
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003532static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3533{
3534 struct statsContext *pStatsContext;
3535 tCsrSummaryStatsInfo *pSummaryStats;
3536 tCsrGlobalClassAStatsInfo *pClassAStats;
3537 hdd_adapter_t *pAdapter;
3538
3539 if (ioctl_debug)
3540 {
3541 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003542 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003543 }
3544
3545 if ((NULL == pStats) || (NULL == pContext))
3546 {
3547 hddLog(VOS_TRACE_LEVEL_ERROR,
3548 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003549 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003550 return;
3551 }
3552
Jeff Johnson72a40512013-12-19 10:14:15 -08003553 /* there is a race condition that exists between this callback
3554 function and the caller since the caller could time out either
3555 before or while this code is executing. we use a spinlock to
3556 serialize these actions */
3557 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003558
3559 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3560 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3561 pStatsContext = pContext;
3562 pAdapter = pStatsContext->pAdapter;
3563 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3564 {
3565 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003566 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003567 hddLog(VOS_TRACE_LEVEL_WARN,
3568 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003569 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003570 if (ioctl_debug)
3571 {
3572 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003573 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003574 }
3575 return;
3576 }
3577
Jeff Johnson72a40512013-12-19 10:14:15 -08003578 /* context is valid so caller is still waiting */
3579
3580 /* paranoia: invalidate the magic */
3581 pStatsContext->magic = 0;
3582
3583 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003584 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3585 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3586
Jeff Johnson72a40512013-12-19 10:14:15 -08003587 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003588 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003589
3590 /* serialization is complete */
3591 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003592}
3593
3594VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3595{
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,
6632 "%s: Bad param, pContext [%p]",
6633 __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,
6647 "%s: Invalid context, pAdapter [%p] magic [%08x]",
6648 __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 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306988 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6989 ret = wlan_hdd_validate_context(pHddCtx);
6990 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006991 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306992 return ret;
6993 }
6994#ifdef WLAN_FEATURE_11W
6995 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6996 if (NULL == pWextState)
6997 {
6998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6999 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07007000 return -EINVAL;
7001 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307002#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007003
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 switch(sub_cmd)
7005 {
7006 case WE_WLAN_VERSION:
7007 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08007008 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 break;
7010 }
7011
7012 case WE_GET_STATS:
7013 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307014 tHalHandle hHal = NULL;
7015 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7017 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
7018 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307019 hdd_arp_stats_t *parpStats = &pAdapter->hdd_stats.hddArpStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07007020
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307021
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 snprintf(extra, WE_MAX_STR_LEN,
7023 "\nTransmit"
7024 "\ncalled %u, dropped %u, backpressured %u, queued %u"
7025 "\n dropped BK %u, BE %u, VI %u, VO %u"
7026 "\n classified BK %u, BE %u, VI %u, VO %u"
7027 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
7028 "\n queued BK %u, BE %u, VI %u, VO %u"
7029 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007030 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 "\n fetched BK %u, BE %u, VI %u, VO %u"
7032 "\n dequeued BK %u, BE %u, VI %u, VO %u"
7033 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07007034 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007035 "\n flushed BK %u, BE %u, VI %u, VO %u"
7036 "\n\nReceive"
7037 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
7038 "\n\nResetsStats"
7039 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307040 "\n"
7041 "\n\nARP Transmit"
7042 "\nTransmit Count %u, dropped %u"
7043 "\n\nARP Receive"
7044 "\nReceive Count %u, dropped %u, Delivered %u, Refused %u, Drop Reason %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 "\n",
7046 pStats->txXmitCalled,
7047 pStats->txXmitDropped,
7048 pStats->txXmitBackPressured,
7049 pStats->txXmitQueued,
7050
7051 pStats->txXmitDroppedAC[WLANTL_AC_BK],
7052 pStats->txXmitDroppedAC[WLANTL_AC_BE],
7053 pStats->txXmitDroppedAC[WLANTL_AC_VI],
7054 pStats->txXmitDroppedAC[WLANTL_AC_VO],
7055
7056 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
7057 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
7058 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
7059 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
7060
7061 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
7062 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
7063 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
7064 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
7065
7066 pStats->txXmitQueuedAC[WLANTL_AC_BK],
7067 pStats->txXmitQueuedAC[WLANTL_AC_BE],
7068 pStats->txXmitQueuedAC[WLANTL_AC_VI],
7069 pStats->txXmitQueuedAC[WLANTL_AC_VO],
7070
7071 pStats->txFetched,
7072 pStats->txFetchEmpty,
7073 pStats->txFetchLowResources,
7074 pStats->txFetchDequeueError,
7075
7076 pStats->txFetchDequeued,
7077 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07007078 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 pStats->txCompleted,
7080 pStats->txFlushed,
7081
7082 pStats->txFetchedAC[WLANTL_AC_BK],
7083 pStats->txFetchedAC[WLANTL_AC_BE],
7084 pStats->txFetchedAC[WLANTL_AC_VI],
7085 pStats->txFetchedAC[WLANTL_AC_VO],
7086
7087 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
7088 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
7089 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
7090 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
7091
7092 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
7093 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
7094 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
7095 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
7096
Ravi Joshi41914632013-10-21 23:02:21 -07007097 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
7098 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
7099 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
7100 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
7101
Jeff Johnson295189b2012-06-20 16:38:30 -07007102 pStats->txFlushedAC[WLANTL_AC_BK],
7103 pStats->txFlushedAC[WLANTL_AC_BE],
7104 pStats->txFlushedAC[WLANTL_AC_VI],
7105 pStats->txFlushedAC[WLANTL_AC_VO],
7106
7107 pStats->rxChains,
7108 pStats->rxPackets,
7109 pStats->rxDropped,
7110 pStats->rxDelivered,
7111 pStats->rxRefused,
7112
7113 pResetStats->totalLogpResets,
7114 pResetStats->totalCMD53Failures,
7115 pResetStats->totalMutexReadFailures,
7116 pResetStats->totalMIFErrorFailures,
7117 pResetStats->totalFWHearbeatFailures,
Asodi T,Venkateswara Reddy55d27ae2017-01-19 11:44:54 +05307118 pResetStats->totalUnknownExceptions,
7119
7120 parpStats->txCount,
7121 parpStats->txDropped,
7122
7123 parpStats->rxCount,
7124 parpStats->rxDropped,
7125 parpStats->rxDelivered,
7126 parpStats->rxRefused,
7127 parpStats->reason
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307129 wrqu->data.length = strlen(extra);
7130
7131 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
7132
7133 if (hHal)
7134 pMac = PMAC_STRUCT( hHal );
7135
7136 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
7137 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
7138 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05307139 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
7140 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
7141 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
7142 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05307143 "\n",
7144 pMac->pmm.BmpscntSleep,
7145 pMac->pmm.BmpscntAwake,
7146 pMac->pmm.BmpsSleeReqFailCnt,
7147 pMac->pmm.BmpsWakeupReqFailCnt,
7148 pMac->pmm.ImpsCntSleep,
7149 pMac->pmm.ImpsCntAwake,
7150 pMac->pmm.ImpsSleepErrCnt,
7151 pMac->pmm.ImpsWakeupErrCnt,
7152 pMac->pmm.ImpsLastErr
7153 );
7154 }
7155
Jeff Johnson295189b2012-06-20 16:38:30 -07007156 wrqu->data.length = strlen(extra)+1;
7157 break;
7158 }
7159
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307160/* The case prints the current state of the HDD, SME, CSR, PE, TL
7161 *it can be extended for WDI Global State as well.
7162 *And currently it only checks P2P_CLIENT adapter.
7163 *P2P_DEVICE and P2P_GO have not been added as of now.
7164*/
7165 case WE_GET_STATES:
7166 {
7167 int buf = 0, len = 0;
7168 int adapter_num = 0;
7169 int count = 0, check = 1;
7170
7171 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007172 tHalHandle hHal = NULL;
7173 tpAniSirGlobal pMac = NULL;
7174 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307175
7176 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7177 hdd_adapter_t *useAdapter = NULL;
7178
7179 /* Print wlan0 or p2p0 states based on the adapter_num
7180 *by using the correct adapter
7181 */
7182 while ( adapter_num < 2 )
7183 {
7184 if ( WLAN_ADAPTER == adapter_num )
7185 {
7186 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007187 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307188 "\n\n wlan0 States:-");
7189 len += buf;
7190 }
7191 else if ( P2P_ADAPTER == adapter_num )
7192 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007193 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307194 "\n\n p2p0 States:-");
7195 len += buf;
7196
7197 if( !pHddCtx )
7198 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007199 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307200 "\n pHddCtx is NULL");
7201 len += buf;
7202 break;
7203 }
7204
7205 /*Printing p2p0 states only in the case when the device is
7206 configured as a p2p_client*/
7207 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
7208 if ( !useAdapter )
7209 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007210 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307211 "\n Device not configured as P2P_CLIENT.");
7212 len += buf;
7213 break;
7214 }
7215 }
7216
7217 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007218 if (!hHal) {
7219 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7220 "\n pMac is NULL");
7221 len += buf;
7222 break;
7223 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307224 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007225 if (!pMac) {
7226 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7227 "\n pMac is NULL");
7228 len += buf;
7229 break;
7230 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307231 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
7232 if( !pHddStaCtx )
7233 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007234 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307235 "\n pHddStaCtx is NULL");
7236 len += buf;
7237 break;
7238 }
7239
7240 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
7241
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007242 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307243 "\n HDD Conn State - %s "
7244 "\n \n SME State:"
7245 "\n Neighbour Roam State - %s"
7246 "\n CSR State - %s"
7247 "\n CSR Substate - %s"
7248 "\n \n TL STA %d State: %s",
7249 macTraceGetHDDWlanConnState(
7250 pHddStaCtx->conn_info.connState),
7251 macTraceGetNeighbourRoamState(
7252 pMac->roam.neighborRoamInfo.neighborRoamState),
7253 macTraceGetcsrRoamState(
7254 pMac->roam.curState[useAdapter->sessionId]),
7255 macTraceGetcsrRoamSubState(
7256 pMac->roam.curSubState[useAdapter->sessionId]),
7257 pHddStaCtx->conn_info.staId[0],
7258 macTraceGetTLState(tlState)
7259 );
7260 len += buf;
7261 adapter_num++;
7262 }
7263
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007264 if (pMac) {
7265 /* Printing Lim State starting with global lim states */
7266 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7267 "\n \n LIM STATES:-"
7268 "\n Global Sme State - %s "\
7269 "\n Global mlm State - %s "\
7270 "\n",
7271 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
7272 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
7273 );
7274 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307275
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007276 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05307277 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307278 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007279 if ( pMac->lim.gpSession[count].valid )
7280 {
7281 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
7282 "\n Lim Valid Session %d:-"
7283 "\n PE Sme State - %s "
7284 "\n PE Mlm State - %s "
7285 "\n",
7286 check,
7287 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
7288 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
7289 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307290
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007291 len += buf;
7292 check++;
7293 }
7294 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307295 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307296 }
7297
7298 wrqu->data.length = strlen(extra)+1;
7299 break;
7300 }
7301
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 case WE_GET_CFG:
7303 {
7304 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
7305 wrqu->data.length = strlen(extra)+1;
7306 break;
7307 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007308#ifdef WLAN_FEATURE_11AC
7309 case WE_GET_RSSI:
7310 {
7311 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05307312 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07007313 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7314 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
7315 wrqu->data.length = strlen(extra)+1;
7316 break;
7317 }
7318#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307319
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007320#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007321 case WE_GET_ROAM_RSSI:
7322 {
7323 v_S7_t s7Rssi = 0;
7324 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
7325 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7326 wrqu->data.length = strlen(extra)+1;
7327 break;
7328 }
7329#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007330 case WE_GET_WMM_STATUS:
7331 {
7332 snprintf(extra, WE_MAX_STR_LEN,
7333 "\nDir: 0=up, 1=down, 3=both\n"
7334 "|------------------------|\n"
7335 "|AC | ACM |Admitted| Dir |\n"
7336 "|------------------------|\n"
7337 "|VO | %d | %3s | %d |\n"
7338 "|VI | %d | %3s | %d |\n"
7339 "|BE | %d | %3s | %d |\n"
7340 "|BK | %d | %3s | %d |\n"
7341 "|------------------------|\n",
7342 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
7343 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
7344 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
7345 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
7346 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
7347 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
7348 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
7349 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
7350 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
7351 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
7352 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
7353 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
7354
Jeff Johnsone7245742012-09-05 17:12:55 -07007355
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 wrqu->data.length = strlen(extra)+1;
7357 break;
7358 }
7359 case WE_GET_CHANNEL_LIST:
7360 {
7361 VOS_STATUS status;
7362 v_U8_t i, len;
7363 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05307364 tANI_U8 pBuf[COUNTRY_CODE_LEN];
7365 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
7366 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07007367 tChannelListInfo channel_list;
7368
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007369 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007371 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007372 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007373 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 return -EINVAL;
7375 }
7376 buf = extra;
7377
7378 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007379 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
7380 * needed = 5 * number of channels. Check ifsufficient
7381 * buffer is available and then proceed to fill the buffer.
7382 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
7384 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007385 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007386 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007387 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007388 return -EINVAL;
7389 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007390 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7391 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05307392 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
7393 {
7394 //Printing Country code in getChannelList
7395 for(i= 0; i < COUNTRY_CODE_LEN; i++)
7396 {
7397 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
7398 "%c ", pBuf[i]);
7399 }
7400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007401 for(i = 0 ; i < channel_list.num_channels; i++)
7402 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07007403 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 }
7406 wrqu->data.length = strlen(extra)+1;
7407
7408 break;
7409 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007410#ifdef FEATURE_WLAN_TDLS
7411 case WE_GET_TDLS_PEERS:
7412 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007413 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007414 break;
7415 }
7416#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007417#ifdef WLAN_FEATURE_11W
7418 case WE_GET_11W_INFO:
7419 {
7420 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
7421
7422 snprintf(extra, WE_MAX_STR_LEN,
7423 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7424 "\n Number of Unprotected Disassocs %d"
7425 "\n Number of Unprotected Deauths %d",
7426 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
7427 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
7428 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
7429 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
7430 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
7431
7432 wrqu->data.length = strlen(extra)+1;
7433 break;
7434 }
7435#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307436#ifdef WLAN_FEATURE_RMC
7437 case WE_GET_IBSS_STA_INFO:
7438 {
7439 hdd_station_ctx_t *pHddStaCtx =
7440 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7441 int idx = 0;
7442 int length = 0, buf = 0;
7443
7444 for (idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++)
7445 {
7446 if (0 != pHddStaCtx->conn_info.staId[ idx ])
7447 {
7448 buf = snprintf
7449 (
7450 (extra + length), WE_MAX_STR_LEN - length,
7451 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7452 pHddStaCtx->conn_info.staId[ idx ],
7453 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[0],
7454 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[1],
7455 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[2],
7456 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[3],
7457 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[4],
7458 pHddStaCtx->conn_info.peerMacAddress[idx].bytes[5]
7459 );
7460 length += buf;
7461 }
7462 }
7463 wrqu->data.length = strlen(extra)+1;
7464 break;
7465 }
7466#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05307467 case WE_GET_SNR:
7468 {
7469 v_S7_t s7snr = 0;
7470 int status = 0;
7471 hdd_context_t *pHddCtx;
7472 hdd_station_ctx_t *pHddStaCtx;
7473
7474 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7475 status = wlan_hdd_validate_context(pHddCtx);
7476 if (0 != status)
7477 {
Girish Gowlidab72f12014-09-04 15:34:43 +05307478 return status;
7479 }
7480
7481 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7482
7483 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
7484 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7485 {
7486 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
7487 " ConnectionState-%d", __func__,
7488 pHddCtx->cfg_ini->fEnableSNRMonitoring,
7489 pHddStaCtx->conn_info.connState);
7490 return -ENONET;
7491 }
7492
7493 /*update the stats in TL*/
7494 wlan_hdd_get_station_stats(pAdapter);
7495 wlan_hdd_get_snr(pAdapter, &s7snr);
7496 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
7497 wrqu->data.length = strlen(extra) + 1;
7498 break;
7499 }
7500
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +05307501#ifdef FEATURE_OEM_DATA_SUPPORT
7502 case WE_GET_OEM_DATA_CAP:
7503 {
7504 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7505 }
7506#endif /* FEATURE_OEM_DATA_SUPPORT */
7507
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307508 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007510 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007511 break;
7512 }
7513 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307514 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007515 return 0;
7516}
7517
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307518static int iw_get_char_setnone(struct net_device *dev,
7519 struct iw_request_info *info,
7520 union iwreq_data *wrqu, char *extra)
7521{
7522 int ret;
7523
7524 vos_ssr_protect(__func__);
7525 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7526 vos_ssr_unprotect(__func__);
7527
7528 return ret;
7529}
7530
Jeff Johnson295189b2012-06-20 16:38:30 -07007531/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307532static int __iw_setnone_getnone(struct net_device *dev,
7533 struct iw_request_info *info,
7534 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007535{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307536 hdd_adapter_t *pAdapter;
7537 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307538 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08007539 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307540 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07007541
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307542 ENTER();
7543
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307544 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7545 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007546 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7548 "%s: Adapter is NULL",__func__);
7549 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007550 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307551 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7552 ret = wlan_hdd_validate_context(pHddCtx);
7553 if (0 != ret)
7554 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307555 return ret;
7556 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05307557 /* helper function to get iwreq_data with compat handling. */
7558 if (hdd_priv_get_data(&s_priv_data, wrqu))
7559 {
7560 return -EINVAL;
7561 }
7562
7563 sub_cmd = s_priv_data.flags;
7564
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 switch (sub_cmd)
7566 {
7567 case WE_CLEAR_STATS:
7568 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007570 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7571 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7572 break;
7573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 case WE_INIT_AP:
7575 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307576 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7577
7578 /* As Soft AP mode might been changed to STA already with
7579 * killing of Hostapd, need to find the adpater by name
7580 * rather than mode */
7581 hdd_adapter_t* pAdapter_to_stop =
7582 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7583 if( pAdapter_to_stop )
7584 {
7585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7586 "Adapter with name softap.0 already "
7587 "exist, ignoring the request.\nRemove the "
7588 "adapter and try again\n");
7589 break;
7590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007591 pr_info("Init AP trigger\n");
7592 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7593 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7594 break;
7595 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307596#ifdef WLAN_FEATURE_RMC
7597 case WE_IBSS_GET_PEER_INFO_ALL:
7598 {
7599 hdd_wlan_get_ibss_peer_info_all(pAdapter);
7600 break;
7601 }
7602#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 case WE_STOP_AP:
7604 {
7605 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7606 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7607 * this is a dead code and need to find the adpater by name rather than mode */
7608 hdd_adapter_t* pAdapter_to_stop =
7609 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7610 if( pAdapter_to_stop )
7611 {
7612 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7613
7614 pr_info("Stopping AP mode\n");
7615
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307616 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7617 {
7618 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7619 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7620 }
7621
Jeff Johnson295189b2012-06-20 16:38:30 -07007622 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307623 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307624 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007625 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7626
7627 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7628 pAdapter_to_stop->macAddressCurrent.bytes);
7629 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7630 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307631
7632 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7633 {
7634 /* put the device back into BMPS */
7635 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7636 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 }
7638 else
7639 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007640 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 }
7642
7643 break;
7644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007645#ifdef WLAN_BTAMP_FEATURE
7646 case WE_ENABLE_AMP:
7647 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 WLANBAP_RegisterWithHCI(pAdapter);
7650 break;
7651 }
7652 case WE_DISABLE_AMP:
7653 {
7654 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7655 VOS_STATUS status;
7656
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007658
7659 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7660 status = WLANBAP_StopAmp();
7661 if(VOS_STATUS_SUCCESS != status )
7662 {
7663 pHddCtx->isAmpAllowed = VOS_TRUE;
7664 hddLog(VOS_TRACE_LEVEL_FATAL,
7665 "%s: Failed to stop AMP", __func__);
7666 }
7667 else
7668 {
7669 //a state m/c implementation in PAL is TBD to avoid this delay
7670 msleep(500);
7671 pHddCtx->isAmpAllowed = VOS_FALSE;
7672 WLANBAP_DeregisterFromHCI();
7673 }
7674
7675 break;
7676 }
7677#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007678 case WE_ENABLE_DXE_STALL_DETECT:
7679 {
schang6295e542013-03-12 15:31:23 -07007680 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7681 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007682 break;
7683 }
7684 case WE_DISPLAY_DXE_SNAP_SHOT:
7685 {
schang6295e542013-03-12 15:31:23 -07007686 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7687 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007688 break;
7689 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307690 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7691 {
7692 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7693 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307694 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307695 break;
7696 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307697
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307698 case WE_SET_REASSOC_TRIGGER:
7699 {
7700 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7701 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7702 v_U32_t roamId = 0;
7703 tCsrRoamModifyProfileFields modProfileFields;
AnjaneeDevi Kapparapu228d0c52015-11-09 12:32:21 +05307704 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7705 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307706 return 0;
7707 }
7708
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307709 case WE_STOP_OBSS_SCAN:
7710 {
7711 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7712 2.OBSS scan is stopped by Firmware during the disassociation
7713 3.OBSS stop comamnd is added for debugging purpose*/
7714 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7715 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007716
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307717 if (pAdapter == NULL)
7718 {
7719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7720 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307721 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307722 }
7723 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7724 if (pMac == NULL)
7725 {
7726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7727 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307728 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307729 }
7730 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7731 }
7732 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307733 case WE_DUMP_ROAM_TIMER_LOG:
7734 {
7735 vos_dump_roam_time_log_service();
7736 break;
7737 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307738
Mukul Sharma84f27252014-07-14 18:11:42 +05307739 case WE_RESET_ROAM_TIMER_LOG:
7740 {
7741 vos_reset_roam_timer_log();
7742 break;
7743 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307744 case WE_GET_FW_LOGS:
7745 {
7746 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7747 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307748 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307749 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307750 break;
7751 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307752 case WE_GET_FW_MEMDUMP:
7753 {
7754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7755 "FW_MEM_DUMP requested ");
7756 get_fwr_memdump(dev,info,wrqu,extra);
7757 break;
7758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007759 default:
7760 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007761 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007762 break;
7763 }
7764 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307765 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007766 return ret;
7767}
7768
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307769static int iw_setnone_getnone(struct net_device *dev,
7770 struct iw_request_info *info,
7771 union iwreq_data *wrqu, char *extra)
7772{
7773 int ret;
7774
7775 vos_ssr_protect(__func__);
7776 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7777 vos_ssr_unprotect(__func__);
7778
7779 return ret;
7780}
7781
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307782void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7783{
7784 /*
7785 * Function to display HDD WMM information
7786 * for Tx Queues.
7787 * Prints globala as well as per client depending
7788 * whether the clients are registered or not.
7789 */
7790 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307791 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7792 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307793 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7794 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307795 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307796
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307797 for ( i=0; i< NUM_TX_QUEUES; i++)
7798 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307799 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307800 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307801 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307802 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307803
7804 for ( i=0; i< NUM_TX_QUEUES; i++) {
7805 if (tx_queue_count[i]) {
7806 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7807 i, tx_queue_count[i]);
7808 }
7809 }
7810
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307811 if(pSapCtx == NULL){
7812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7813 FL("psapCtx is NULL"));
7814 return;
7815 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307816
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307817 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307818 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7819 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307820 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307821 {
7822 hddLog(LOGE, "******STAIndex: %d*********", i);
7823 for ( j=0; j< NUM_TX_QUEUES; j++)
7824 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307825 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7826 {
7827 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307828 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7829 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307830 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7831 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307832 }
7833 }
7834 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307835 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307836
Katya Nigam1fd24402015-02-16 14:52:19 +05307837 if(pHddStaCtx == NULL){
7838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7839 FL("pHddStaCtx is NULL"));
7840 return;
7841 }
7842
7843 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7844 if(pPeerInfo == NULL){
7845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7846 FL("ppeerinfo is NULL"));
7847 return;
7848 }
7849
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307850 for (i = 0; i < HDD_MAX_NUM_IBSS_STA; i++) {
7851 if (pPeerInfo->ibssStaInfo[i].isUsed) {
7852 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7853 for (j = 0; j < NUM_TX_QUEUES; j++) {
7854 if (pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count) {
7855 spin_lock_bh(
7856 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7857 hddLog(LOGE,
7858 "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7859 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7860 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7861 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7862 spin_unlock_bh(
7863 &pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7864 }
7865 }
Katya Nigam1fd24402015-02-16 14:52:19 +05307866 }
7867 }
7868
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307869}
Sravan Kumar Kairam8bc9e1e2016-01-25 20:50:11 +05307870
Girish Gowlifb9758e2014-11-19 15:19:17 +05307871static int __iw_set_var_ints_getnone(struct net_device *dev,
7872 struct iw_request_info *info,
7873 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007874{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307875 hdd_adapter_t *pAdapter;
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307876 tHalHandle hHal = NULL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307877 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307878 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007879 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307880 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307881 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007882 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307883 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007884 int cmd = 0;
7885 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307886 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007887
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307888 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307889 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307890 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7892 "%s: NULL extra buffer pointer", __func__);
7893 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307894 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307895 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7896 if (NULL == pAdapter)
7897 {
7898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7899 "%s: Adapter is NULL",__func__);
7900 return -EINVAL;
7901 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307902 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307903 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7904 ret = wlan_hdd_validate_context(pHddCtx);
7905 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007906 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307907 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007908 }
Katya Nigameae74b62015-05-28 17:19:16 +05307909 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307910 {
Katya Nigameae74b62015-05-28 17:19:16 +05307911 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7912 if (NULL == hHal)
7913 {
7914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7915 "%s: Hal Context is NULL",__func__);
7916 return -EINVAL;
7917 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307918 }
7919 sub_cmd = wrqu->data.flags;
7920
7921 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7922
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007923
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007924 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7925 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7926 {
7927 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7928 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7929 {
7930 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7931 staId = pStaCtx->conn_info.staId[0];
7932 }
7933 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7934 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7935 {
7936 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7937 staId = pAPCtx->uBCStaId;
7938 }
7939 else
7940 {
7941 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7942 return 0;
7943 }
7944 }
7945
Jeff Johnson295189b2012-06-20 16:38:30 -07007946 switch (sub_cmd)
7947 {
7948 case WE_LOG_DUMP_CMD:
7949 {
Arun Khandavalliffbf9c02015-12-03 16:48:53 +05307950 if(apps_args[0] == 26) {
7951 if (!pHddCtx->cfg_ini->crash_inject_enabled) {
7952 hddLog(LOGE, "Crash Inject ini disabled, Ignore Crash Inject");
7953 return 0;
7954 }
7955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007957 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007958 apps_args[3], apps_args[4]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05307959 if (hHal)
7960 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7961 apps_args[3], apps_args[4]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007962
7963 }
7964 break;
Abhishek Singh7cd040e2016-01-07 10:51:04 +05307965#ifdef WLAN_FEATURE_RMC
7966 case WE_IBSS_GET_PEER_INFO:
7967 {
7968 pr_info ( "Station ID = %d\n",apps_args[0]);
7969 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7970 }
7971 break;
7972#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007973
Jeff Johnson295189b2012-06-20 16:38:30 -07007974 case WE_P2P_NOA_CMD:
7975 {
7976 p2p_app_setP2pPs_t p2pNoA;
7977
Rajeev Kumara4c475d2015-11-27 13:41:24 +05307978 if (pAdapter->device_mode != WLAN_HDD_P2P_GO) {
7979 hddLog(LOGE,
7980 FL("Setting NoA is not allowed in Device mode:%d"),
7981 pAdapter->device_mode);
7982 return -EINVAL;
7983 }
7984
Jeff Johnson295189b2012-06-20 16:38:30 -07007985 p2pNoA.opp_ps = apps_args[0];
7986 p2pNoA.ctWindow = apps_args[1];
7987 p2pNoA.duration = apps_args[2];
7988 p2pNoA.interval = apps_args[3];
7989 p2pNoA.count = apps_args[4];
7990 p2pNoA.single_noa_duration = apps_args[5];
7991 p2pNoA.psSelection = apps_args[6];
7992
7993 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7994 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007995 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007996 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7997
7998 hdd_setP2pPs(dev, &p2pNoA);
7999
8000 }
8001 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008002
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308003 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8004 {
8005 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
8006 __func__, apps_args[0], apps_args[1]);
8007 vosTraceEnable(apps_args[0], apps_args[1]);
8008 }
8009 break;
8010
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008011 case WE_MTRACE_DUMP_CMD:
8012 {
8013 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
8014 "bitmask_of_module %d ",
8015 __func__, apps_args[0], apps_args[1], apps_args[2],
8016 apps_args[3]);
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308017 if (hHal)
8018 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
8019 apps_args[2], apps_args[3]);
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008020
8021 }
8022 break;
8023
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008024 case WE_MCC_CONFIG_CREDENTIAL :
8025 {
8026 cmd = 287; //Command should be updated if there is any change
8027 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08008028 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008029 {
SaidiReddy Yenuga83de6992016-07-12 17:21:11 +05308030 if (hHal)
8031 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1],
8032 apps_args[2]);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008033 }
8034 else
8035 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008036 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008037 return 0;
8038 }
8039 }
8040 break;
8041
8042 case WE_MCC_CONFIG_PARAMS :
8043 {
8044 cmd = 288; //command Should be updated if there is any change
8045 // in the Riva dump command
8046 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
8047 }
8048 break;
8049
Chilam NG571c65a2013-01-19 12:27:36 +05308050#ifdef FEATURE_WLAN_TDLS
8051 case WE_TDLS_CONFIG_PARAMS :
8052 {
8053 tdls_config_params_t tdlsParams;
8054
Chilam Ng01120412013-02-19 18:32:21 -08008055 tdlsParams.tdls = apps_args[0];
8056 tdlsParams.tx_period_t = apps_args[1];
8057 tdlsParams.tx_packet_n = apps_args[2];
8058 tdlsParams.discovery_period_t = apps_args[3];
8059 tdlsParams.discovery_tries_n = apps_args[4];
8060 tdlsParams.idle_timeout_t = apps_args[5];
8061 tdlsParams.idle_packet_n = apps_args[6];
8062 tdlsParams.rssi_hysteresis = apps_args[7];
8063 tdlsParams.rssi_trigger_threshold = apps_args[8];
8064 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05308065
Chilam Ng01120412013-02-19 18:32:21 -08008066 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05308067 }
8068 break;
8069#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05308070 case WE_CONFIGURE_MONITOR_MODE:
8071 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308072 v_U32_t magic = 0;
8073 struct completion cmpVar;
8074 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308075 tVOS_CON_MODE mode = hdd_get_conparam();
8076
8077 if (VOS_MONITOR_MODE != mode) {
8078 hddLog(LOGE, FL("invalid mode %d"), mode);
8079 return -EIO;
8080 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308081
Katya Nigamf0511f62015-05-05 16:40:57 +05308082 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8083 if( pMonCtx == NULL )
8084 {
8085 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308086 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308087 }
8088 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
8089 __func__, apps_args[0], apps_args[1], apps_args[2],
8090 apps_args[3], apps_args[4]);
8091 /* Input Validation part of FW */
8092 pMonCtx->ChannelNo = apps_args[0];
8093 pMonCtx->ChannelBW = apps_args[1];
8094 pMonCtx->crcCheckEnabled = apps_args[2];
8095 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
8096 pMonCtx->is80211to803ConReq = apps_args[4];
8097 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
8098 if( pMonCtx->is80211to803ConReq )
8099 pAdapter->dev->type = ARPHRD_ETHER;
8100 else
8101 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
8102 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
8103 {
8104 hddLog(LOGE, "%s: Filtering data packets as management and control"
8105 " cannot be converted to 802.3 ",__func__);
8106 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
8107 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308108 if (MON_MODE_START == pMonCtx->state) {
8109 magic = MON_MODE_MSG_MAGIC;
8110 init_completion(&cmpVar);
8111 if (VOS_STATUS_SUCCESS !=
8112 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8113 pMonCtx, hdd_monPostMsgCb)) {
8114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8115 FL("failed to post MON MODE REQ"));
8116 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308117 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308118 }
8119 waitRet = wait_for_completion_timeout(&cmpVar,
8120 MON_MODE_MSG_TIMEOUT);
8121 magic = 0;
8122 if (waitRet <= 0 ) {
8123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8124 FL("failed to wait on monitor mode completion %ld"),
8125 waitRet);
8126 }
8127 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308128 }
8129 break;
8130
8131 case WE_SET_MONITOR_MODE_FILTER:
8132 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308133 v_U32_t magic = 0;
8134 struct completion cmpVar;
8135 long waitRet = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308136 tVOS_CON_MODE mode = hdd_get_conparam();
8137
8138 if (VOS_MONITOR_MODE != mode) {
8139 hddLog(LOGE, FL("invalid mode %d"), mode);
8140 return -EIO;
8141 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308142
Katya Nigamf0511f62015-05-05 16:40:57 +05308143 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
8144 if( pMonCtx == NULL )
8145 {
8146 hddLog(LOGE, "Monitor Context NULL");
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308147 return -EIO;
Katya Nigamf0511f62015-05-05 16:40:57 +05308148 }
8149 /* Input Validation Part of FW */
8150 pMonCtx->numOfMacFilters=1;
8151 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
8152 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
8153 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
8154 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
8155 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
8156 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
8157 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
8158 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
8159 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
8160 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
8161 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
8162 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308163 if (MON_MODE_START == pMonCtx->state) {
8164 magic = MON_MODE_MSG_MAGIC;
8165 init_completion(&cmpVar);
8166 if (VOS_STATUS_SUCCESS !=
8167 wlan_hdd_mon_postMsg(&magic, &cmpVar,
8168 pMonCtx, hdd_monPostMsgCb)) {
8169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8170 FL("failed to post MON MODE REQ"));
8171 magic = 0;
Abhishek Singhb95cdb62016-02-16 11:31:00 +05308172 return -EIO;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05308173 }
8174 waitRet = wait_for_completion_timeout(&cmpVar,
8175 MON_MODE_MSG_TIMEOUT);
8176 magic = 0;
8177 if (waitRet <= 0 ) {
8178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8179 FL("failed to wait on monitor mode completion %ld"),
8180 waitRet);
8181 }
8182 }
Katya Nigamf0511f62015-05-05 16:40:57 +05308183 }
8184 break;
8185
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 default:
8187 {
Jeff Johnson11e77032014-02-14 13:22:22 -08008188 hddLog(LOGE, "%s: Invalid IOCTL command %d",
8189 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07008190 }
8191 break;
8192 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308193 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008194 return 0;
8195}
8196
Girish Gowlifb9758e2014-11-19 15:19:17 +05308197static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8198 struct iw_request_info *info,
8199 union iwreq_data *wrqu, char *extra)
8200{
8201 int ret;
8202 union iwreq_data u_priv_wrqu;
8203 int apps_args[MAX_VAR_ARGS] = {0};
8204 int num_args;
8205
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05308206 if (!capable(CAP_NET_ADMIN))
8207 {
8208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8209 FL("permission check failed"));
8210 return -EPERM;
8211 }
8212
Girish Gowlifb9758e2014-11-19 15:19:17 +05308213 /* helper function to get iwreq_data with compat handling. */
8214 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8215 {
8216 return -EINVAL;
8217 }
8218
8219 if (NULL == u_priv_wrqu.data.pointer)
8220 {
8221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8222 "%s: NULL data pointer", __func__);
8223 return -EINVAL;
8224 }
8225
8226 num_args = u_priv_wrqu.data.length;
8227 if (num_args > MAX_VAR_ARGS)
8228 {
8229 num_args = MAX_VAR_ARGS;
8230 }
8231
8232 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8233 (sizeof(int)) * num_args))
8234 {
8235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8236 "%s: failed to copy data from user buffer", __func__);
8237 return -EFAULT;
8238 }
8239
8240 vos_ssr_protect(__func__);
8241 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8242 (char *)&apps_args);
8243 vos_ssr_unprotect(__func__);
8244
8245 return ret;
8246}
8247
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308248int iw_set_var_ints_getnone(struct net_device *dev,
8249 struct iw_request_info *info,
8250 union iwreq_data *wrqu, char *extra)
8251{
8252 int ret;
8253 vos_ssr_protect(__func__);
8254 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8255 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008256
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308257 return ret;
8258}
8259
8260static int __iw_add_tspec(struct net_device *dev,
8261 struct iw_request_info *info,
8262 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008263{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308264 hdd_adapter_t *pAdapter;
8265 hdd_station_ctx_t *pHddStaCtx;
8266 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8268 int params[HDD_WLAN_WMM_PARAM_COUNT];
8269 sme_QosWmmTspecInfo tSpec;
8270 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05308271 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308272 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008273
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308274 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308275 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8276 if (NULL == pAdapter)
8277 {
8278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8279 "%s: Adapter is NULL",__func__);
8280 return -EINVAL;
8281 }
8282 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8283 ret = wlan_hdd_validate_context(pHddCtx);
8284 if (0 != ret)
8285 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308286 return ret;
8287 }
8288 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8289 if (NULL == pHddStaCtx)
8290 {
8291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8292 "%s: STA Context is NULL",__func__);
8293 return -EINVAL;
8294 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 // make sure the application is sufficiently priviledged
8296 // note that the kernel will do this for "set" ioctls, but since
8297 // this ioctl wants to return status to user space it must be
8298 // defined as a "get" ioctl
8299 if (!capable(CAP_NET_ADMIN))
8300 {
8301 return -EPERM;
8302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 // we must be associated in order to add a tspec
8304 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8305 {
8306 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8307 return 0;
8308 }
8309
8310 // since we are defined to be a "get" ioctl, and since the number
8311 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05308312 // will pass down in the iwreq_data, we must copy the "set" params.
8313 // We must handle the compat for iwreq_data in 32U/64K environment.
8314
8315 // helper fucntion to get iwreq_data with compat handling.
8316 if (hdd_priv_get_data(&s_priv_data, wrqu))
8317 {
8318 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8319 return 0;
8320 }
8321
8322 // make sure all params are correctly passed to function
8323 if ((NULL == s_priv_data.pointer) ||
8324 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
8325 {
8326 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8327 return 0;
8328 }
8329
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05308331 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 {
8333 // hmmm, can't get them
8334 return -EIO;
8335 }
8336
8337 // clear the tspec
8338 memset(&tSpec, 0, sizeof(tSpec));
8339
8340 // validate the handle
8341 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8342 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8343 {
8344 // that one is reserved
8345 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8346 return 0;
8347 }
8348
8349 // validate the TID
8350 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
8351 {
8352 // out of range
8353 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8354 return 0;
8355 }
8356 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8357
8358 // validate the direction
8359 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
8360 {
8361 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8362 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8363 break;
8364
8365 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8366 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8367 break;
8368
8369 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8370 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8371 break;
8372
8373 default:
8374 // unknown
8375 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8376 return 0;
8377 }
8378
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05308379 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8380
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 // validate the user priority
8382 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
8383 {
8384 // out of range
8385 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8386 return 0;
8387 }
8388 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05308389 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
8390 {
8391 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
8392 return 0;
8393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008394
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05308395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8396 "%s:TS_INFO PSB %d UP %d !!!", __func__,
8397 tSpec.ts_info.psb, tSpec.ts_info.up);
8398
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8400 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8401 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8402 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8403 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8404 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8405 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8406 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8407 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8408 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8409 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8410 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8411
8412 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8413
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05308414 // Save the expected UAPSD settings by application, this will be needed
8415 // when re-negotiating UAPSD settings during BT Coex cases.
8416 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
8417
Jeff Johnson295189b2012-06-20 16:38:30 -07008418 // validate the ts info ack policy
8419 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
8420 {
8421 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8422 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8423 break;
8424
8425 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8426 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8427 break;
8428
8429 default:
8430 // unknown
8431 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8432 return 0;
8433 }
8434
8435 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308436
8437 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 return 0;
8439}
8440
8441
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308442static int iw_add_tspec(struct net_device *dev,
8443 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 union iwreq_data *wrqu, char *extra)
8445{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308446 int ret;
8447
8448 vos_ssr_protect(__func__);
8449 ret = __iw_add_tspec(dev, info, wrqu, extra);
8450 vos_ssr_unprotect(__func__);
8451
8452 return ret;
8453}
8454
8455static int __iw_del_tspec(struct net_device *dev,
8456 struct iw_request_info *info,
8457 union iwreq_data *wrqu, char *extra)
8458{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308459 hdd_adapter_t *pAdapter;
8460 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 int *params = (int *)extra;
8462 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8463 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308464 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008465
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308466 ENTER();
8467
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308468 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8469 if (NULL == pAdapter)
8470 {
8471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8472 "%s: Adapter is NULL",__func__);
8473 return -EINVAL;
8474 }
8475
8476 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8477 ret = wlan_hdd_validate_context(pHddCtx);
8478 if (0 != ret)
8479 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308480 return ret;
8481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 // make sure the application is sufficiently priviledged
8483 // note that the kernel will do this for "set" ioctls, but since
8484 // this ioctl wants to return status to user space it must be
8485 // defined as a "get" ioctl
8486 if (!capable(CAP_NET_ADMIN))
8487 {
8488 return -EPERM;
8489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008490 // although we are defined to be a "get" ioctl, the params we require
8491 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8492 // is no need to copy the params from user space
8493
8494 // validate the handle
8495 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8496 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8497 {
8498 // that one is reserved
8499 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8500 return 0;
8501 }
8502
8503 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308504
8505 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008506 return 0;
8507}
8508
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308509static int iw_del_tspec(struct net_device *dev,
8510 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 union iwreq_data *wrqu, char *extra)
8512{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308513 int ret;
8514
8515 vos_ssr_protect(__func__);
8516 ret = __iw_del_tspec(dev, info, wrqu, extra);
8517 vos_ssr_unprotect(__func__);
8518
8519 return ret;
8520}
8521
8522
8523static int __iw_get_tspec(struct net_device *dev,
8524 struct iw_request_info *info,
8525 union iwreq_data *wrqu, char *extra)
8526{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308527 hdd_adapter_t *pAdapter;
8528 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008529 int *params = (int *)extra;
8530 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
8531 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308532 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008533
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308534 ENTER();
8535
Jeff Johnson295189b2012-06-20 16:38:30 -07008536 // although we are defined to be a "get" ioctl, the params we require
8537 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
8538 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308539 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8540 if (NULL == pAdapter)
8541 {
8542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8543 "%s: Adapter is NULL",__func__);
8544 return -EINVAL;
8545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008546
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8548 ret = wlan_hdd_validate_context(pHddCtx);
8549 if (0 != ret)
8550 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308551 return ret;
8552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008553 // validate the handle
8554 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8555 if (HDD_WMM_HANDLE_IMPLICIT == handle)
8556 {
8557 // that one is reserved
8558 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8559 return 0;
8560 }
8561
8562 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308563 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 return 0;
8565}
8566
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308567static int iw_get_tspec(struct net_device *dev,
8568 struct iw_request_info *info,
8569 union iwreq_data *wrqu, char *extra)
8570{
8571 int ret;
8572
8573 vos_ssr_protect(__func__);
8574 ret = __iw_get_tspec(dev, info, wrqu, extra);
8575 vos_ssr_unprotect(__func__);
8576
8577 return ret;
8578}
8579
Manjeet Singh3ed79242017-01-11 19:04:32 +05308580/**
8581 * __iw_setnone_get_threeint() - return three value to up layer.
8582 *
8583 * @dev: pointer of net_device of this wireless card
8584 * @info: meta data about Request sent
8585 * @wrqu: include request info
8586 * @extra: buf used for in/Output
8587 *
8588 * Return: execute result
8589 */
8590static int __iw_setnone_get_threeint(struct net_device *dev,
8591 struct iw_request_info *info,
8592 union iwreq_data *wrqu, char *extra)
8593{
8594 int ret = 0; /* success */
8595 uint32_t *value = (int *)extra;
8596 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8597
8598 hddLog(VOS_TRACE_LEVEL_INFO, FL("param = %d"), value[0]);
8599
8600 switch (value[0]) {
8601 case WE_GET_TSF:
8602 ret = hdd_indicate_tsf(adapter, value, 3);
8603 break;
8604 default:
8605 hddLog(VOS_TRACE_LEVEL_ERROR,
8606 FL("Invalid IOCTL get_value command %d"),
8607 value[0]);
8608 break;
8609 }
8610 return ret;
8611}
8612
8613/**
8614 * iw_setnone_get_threeint() - return three value to up layer.
8615 *
8616 * @dev: pointer of net_device of this wireless card
8617 * @info: meta data about Request sent
8618 * @wrqu: include request info
8619 * @extra: buf used for in/Output
8620 *
8621 * Return: execute result
8622 */
8623static int iw_setnone_get_threeint(struct net_device *dev,
8624 struct iw_request_info *info,
8625 union iwreq_data *wrqu, char *extra)
8626{
8627 int ret;
8628
8629 vos_ssr_protect(__func__);
8630 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8631 vos_ssr_unprotect(__func__);
8632
8633 return ret;
8634}
8635
Jeff Johnson295189b2012-06-20 16:38:30 -07008636#ifdef WLAN_FEATURE_VOWIFI_11R
8637//
8638//
8639// Each time the supplicant has the auth_request or reassoc request
8640// IEs ready. This is pushed to the driver. The driver will inturn use
8641// it to send out the auth req and reassoc req for 11r FT Assoc.
8642//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308643static int __iw_set_fties(struct net_device *dev,
8644 struct iw_request_info *info,
8645 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008646{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308647 hdd_adapter_t *pAdapter;
8648 hdd_station_ctx_t *pHddStaCtx;
8649 hdd_context_t *pHddCtx;
8650 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008651 //v_CONTEXT_t pVosContext;
8652
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308653 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308654 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8655 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008656 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8658 "%s: Adapter is NULL",__func__);
8659 return -EINVAL;
8660 }
8661 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8662 ret = wlan_hdd_validate_context(pHddCtx);
8663 if (0 != ret)
8664 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308665 return ret;
8666 }
8667 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8668 if (NULL == pHddStaCtx)
8669 {
8670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8671 "%s: STA Context is NULL",__func__);
8672 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008674 if (!wrqu->data.length)
8675 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008676 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008677 return -EINVAL;
8678 }
8679 if (wrqu->data.pointer == NULL)
8680 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008681 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 return -EINVAL;
8683 }
8684
8685 // Added for debug on reception of Re-assoc Req.
8686 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8687 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008688 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008689 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008690 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008691 }
8692
8693#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008694 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008695#endif
8696
8697 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008698 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008699 wrqu->data.length);
8700
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308701 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008702 return 0;
8703}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308704
8705static int iw_set_fties(struct net_device *dev,
8706 struct iw_request_info *info,
8707 union iwreq_data *wrqu, char *extra)
8708{
8709 int ret;
8710
8711 vos_ssr_protect(__func__);
8712 ret = __iw_set_fties(dev, info, wrqu, extra);
8713 vos_ssr_unprotect(__func__);
8714
8715 return ret;
8716}
Jeff Johnson295189b2012-06-20 16:38:30 -07008717#endif
8718
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308719static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008720 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008722{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308723 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008724 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308725 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008726 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308727 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008728 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8729 int idx;
8730 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308732 ENTER();
8733
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308734 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8735 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008736 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8738 "%s: Adapter is NULL",__func__);
8739 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008740 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308741 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8742 ret_val = wlan_hdd_validate_context(pHddCtx);
8743 if (0 != ret_val)
8744 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308745 return ret_val;
8746 }
8747 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8748 if (NULL == hHal)
8749 {
8750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8751 "%s: Hal Context is NULL",__func__);
8752 return -EINVAL;
8753 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308754 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8755 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308756#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008757
Amar Singhalf3a6e762013-02-19 15:06:50 -08008758 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8759 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008760 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008761 hddLog(VOS_TRACE_LEVEL_ERROR,
8762 "%s: vos_mem_alloc failed", __func__);
8763 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008764 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008765
8766 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8767
8768 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8769 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8770
8771 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8772 mc_addr_list_ptr->ulMulticastAddrCnt);
8773
8774 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008775 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008776 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8777 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8778
8779 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8780 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008781 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008782
Amar Singhalf3a6e762013-02-19 15:06:50 -08008783 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8784 vos_mem_free(mc_addr_list_ptr);
8785 if (eHAL_STATUS_SUCCESS != ret_val)
8786 {
8787 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8788 __func__);
8789 return -EINVAL;
8790 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308791#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308792 }
8793 else
8794 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008795
Amar Singhalf3a6e762013-02-19 15:06:50 -08008796 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8797 "%s: Set MC BC Filter Config request: %d suspend %d",
8798 __func__, pRequest->mcastBcastFilterSetting,
8799 pHddCtx->hdd_wlan_suspended);
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308800 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308801 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308802 spin_unlock(&pHddCtx->filter_lock);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008803
8804 if (pHddCtx->hdd_wlan_suspended)
8805 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008806 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8807 if (NULL == wlanRxpFilterParam)
8808 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308809 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008810 "%s: vos_mem_alloc failed", __func__);
8811 return -EINVAL;
8812 }
8813
Amar Singhalf3a6e762013-02-19 15:06:50 -08008814 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8815 pRequest->mcastBcastFilterSetting;
8816 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308817 /* Fwr expect offload needs to clear before set */
8818 hdd_conf_hostoffload(pAdapter, FALSE);
8819 spin_lock(&pHddCtx->filter_lock);
8820 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
8821 spin_unlock(&pHddCtx->filter_lock);
8822 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8823 {
8824 hddLog(VOS_TRACE_LEVEL_INFO, "%s: pRequest->mcastBcastFilterSetting ", __func__);
8825 pHddCtx->sus_res_mcastbcast_filter =
8826 pRequest->mcastBcastFilterSetting;
8827 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008828
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308829 hdd_conf_hostoffload(pAdapter, TRUE);
8830 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8831 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008832
8833 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8834 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308835 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008836 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8837 wlanRxpFilterParam->setMcstBcstFilter);
8838
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308839 if (eHAL_STATUS_SUCCESS !=
8840 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8841 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008842 {
8843 hddLog(VOS_TRACE_LEVEL_ERROR,
8844 "%s: Failure to execute set HW MC/BC Filter request",
8845 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008846 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008847 return -EINVAL;
8848 }
8849
mukul sharmae4abd892016-11-24 22:03:31 +05308850 /* mc add list cfg item configuration in fwr */
8851 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008852 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008854
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308855 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008856 return 0;
8857}
8858
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308859static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8860 struct iw_request_info *info,
8861 union iwreq_data *wrqu, char *extra)
8862{
8863 int ret;
8864
8865 vos_ssr_protect(__func__);
8866 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8867 vos_ssr_unprotect(__func__);
8868
8869 return ret;
8870}
8871
8872static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8873 struct iw_request_info *info,
8874 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008875{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308876 hdd_adapter_t *pAdapter;
8877 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308878 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308879 int ret = 0;
8880
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308881 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008882
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308883 if (!capable(CAP_NET_ADMIN))
8884 {
8885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8886 FL("permission check failed"));
8887 return -EPERM;
8888 }
8889
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308890 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8891 if (NULL == pAdapter)
8892 {
8893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8894 "%s: Adapter is NULL",__func__);
8895 return -EINVAL;
8896 }
8897
8898 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8899 ret = wlan_hdd_validate_context(pHddCtx);
8900 if (0 != ret)
8901 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308902 return ret;
8903 }
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308904 spin_lock(&pHddCtx->filter_lock);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308905 //Reset the filter to INI value as we have to clear the dynamic filter
8906 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308907 spin_unlock(&pHddCtx->filter_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07008908
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308909 //Configure FW with new setting
8910 if (pHddCtx->hdd_wlan_suspended)
8911 {
8912 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8913 if (NULL == wlanRxpFilterParam)
8914 {
8915 hddLog(VOS_TRACE_LEVEL_ERROR,
8916 "%s: vos_mem_alloc failed", __func__);
8917 return -EINVAL;
8918 }
8919
8920 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8921 pHddCtx->configuredMcastBcastFilter;
8922 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
Mukul Sharma75ee8aa2016-12-01 14:28:10 +05308923 /* Fwr expect offload needs to clear before set */
8924 hdd_conf_hostoffload(pAdapter, FALSE);
8925 spin_lock(&pHddCtx->filter_lock);
8926 pHddCtx->configuredMcastBcastFilter =
8927 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8928 spin_unlock(&pHddCtx->filter_lock);
8929
8930 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8931 {
8932 pHddCtx->sus_res_mcastbcast_filter =
8933 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8934 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308935
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308936 hdd_conf_hostoffload(pAdapter, TRUE);
8937 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8938 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308939 if (eHAL_STATUS_SUCCESS !=
8940 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8941 wlanRxpFilterParam))
8942 {
8943 hddLog(VOS_TRACE_LEVEL_ERROR,
8944 "%s: Failure to execute set HW MC/BC Filter request",
8945 __func__);
8946 vos_mem_free(wlanRxpFilterParam);
8947 return -EINVAL;
8948 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308949
mukul sharmae4abd892016-11-24 22:03:31 +05308950 /* mc add list cfg item configuration in fwr */
8951 hdd_mc_addr_list_cfg_config(pHddCtx, true);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308952 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308953 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008954 return 0;
8955}
8956
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308957
8958static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8959 struct iw_request_info *info,
8960 union iwreq_data *wrqu, char *extra)
8961{
8962 int ret;
8963
8964 vos_ssr_protect(__func__);
8965 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8966 vos_ssr_unprotect(__func__);
8967
8968 return ret;
8969}
8970
8971static int __iw_set_host_offload(struct net_device *dev,
8972 struct iw_request_info *info,
8973 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008974{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308975 hdd_adapter_t *pAdapter;
8976 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008977 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008978 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308979 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008980
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308981 ENTER();
8982
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308983 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8984 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008985 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8987 "%s: Adapter is NULL",__func__);
8988 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008989 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308990 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8991 ret = wlan_hdd_validate_context(pHddCtx);
8992 if (0 != ret)
8993 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308994 return ret;
8995 }
8996
Jeff Johnson295189b2012-06-20 16:38:30 -07008997 /* Debug display of request components. */
8998 switch (pRequest->offloadType)
8999 {
9000 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009001 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009002 switch (pRequest->enableOrDisable)
9003 {
9004 case WLAN_OFFLOAD_DISABLE:
9005 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
9006 break;
9007 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
9008 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
9009 case WLAN_OFFLOAD_ENABLE:
9010 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
9011 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
9012 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
9013 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
9014 }
9015 break;
9016
9017 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08009018 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009019 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009020 switch (pRequest->enableOrDisable)
9021 {
9022 case WLAN_OFFLOAD_DISABLE:
9023 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
9024 break;
9025 case WLAN_OFFLOAD_ENABLE:
9026 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
9027 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
9028 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
9029 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
9030 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
9031 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
9032 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
9033 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
9034 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
9035 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
9036 }
9037 }
9038
9039 /* Execute offload request. The reason that we can copy the request information
9040 from the ioctl structure to the SME structure is that they are laid out
9041 exactly the same. Otherwise, each piece of information would have to be
9042 copied individually. */
9043 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07009044 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
9045 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009047 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 __func__);
9049 return -EINVAL;
9050 }
9051
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309052 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009053 return 0;
9054}
9055
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309056static int iw_set_host_offload(struct net_device *dev,
9057 struct iw_request_info *info,
9058 union iwreq_data *wrqu, char *extra)
9059{
9060 int ret;
9061
9062 vos_ssr_protect(__func__);
9063 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9064 vos_ssr_unprotect(__func__);
9065
9066 return ret;
9067}
9068
9069static int __iw_set_keepalive_params(struct net_device *dev,
9070 struct iw_request_info *info,
9071 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009072{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309073 hdd_adapter_t *pAdapter;
9074 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08009075 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009076 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309077 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009078
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309079 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309080 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9081 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07009082 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9084 "%s: Adapter is NULL",__func__);
9085 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009086 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309087 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9088 ret = wlan_hdd_validate_context(pHddCtx);
9089 if (0 != ret)
9090 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309091 return ret;
9092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009093 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08009094 hddLog(VOS_TRACE_LEVEL_INFO,
9095 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
9096 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07009097
9098 switch (pRequest->packetType)
9099 {
9100 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009101 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009102 break;
9103
9104 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
9105
Arif Hussain6d2a3322013-11-17 19:50:10 -08009106 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009107 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009108
9109 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
9110 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
9111 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
9112
9113 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
9114 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
9115 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
9116
9117 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
9118 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
9119 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
9120 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
9121 break;
9122
9123 }
9124
9125 /* Execute keep alive request. The reason that we can copy the request information
9126 from the ioctl structure to the SME structure is that they are laid out
9127 exactly the same. Otherwise, each piece of information would have to be
9128 copied individually. */
9129 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
9130
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05309131 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
9132 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07009133
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009134 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07009135 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07009136 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009137 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07009138 __func__);
9139 return -EINVAL;
9140 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309141 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 return 0;
9143}
9144
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309145static int iw_set_keepalive_params(struct net_device *dev,
9146 struct iw_request_info *info,
9147 union iwreq_data *wrqu, char *extra)
9148{
9149 int ret;
9150 vos_ssr_protect(__func__);
9151 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9152 vos_ssr_unprotect(__func__);
9153
9154 return ret;
9155}
9156
Jeff Johnson295189b2012-06-20 16:38:30 -07009157#ifdef WLAN_FEATURE_PACKET_FILTERING
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309158/**-----------------------------------------------------------------
9159
9160 \brief hdd_pkt_filter_done - callback to be executed on completion
9161 successful/failure) for clear filter request.
9162
9163 \return - None
9164
9165 --------------------------------------------------------------------------*/
9166static void hdd_pkt_filter_done(void *data, v_U32_t status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009167{
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309168 struct statsContext *cbCtx = (struct statsContext *)data;
9169
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309170 hddLog(VOS_TRACE_LEVEL_INFO,
9171 FL("Pkt Filter Clear Status : %d"), status);
9172
9173 if (data == NULL)
9174 {
9175 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context"));
9176 return;
9177 }
9178
9179 spin_lock(&hdd_context_lock);
9180 if (cbCtx->magic != CLEAR_FILTER_MAGIC)
9181 {
9182 spin_unlock(&hdd_context_lock);
9183 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid context, magic %x"), cbCtx->magic);
9184 if (ioctl_debug)
9185 {
9186 pr_info("%s: Invalid context, magic [%08x]\n",
9187 __func__, cbCtx->magic);
9188 }
9189 return;
9190 }
9191
9192 complete(&cbCtx->completion);
9193 spin_unlock(&hdd_context_lock);
9194}
9195
9196int wlan_hdd_set_filter(hdd_adapter_t *pAdapter, tpPacketFilterCfg pRequest)
9197{
9198 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309199 hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07009200 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9201 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309202 struct statsContext cbCtx;
9203 int i=0, status;
9204
9205 status = wlan_hdd_validate_context(pHddCtx);
9206 if (0 != status)
9207 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009208
9209 if (pHddCtx->cfg_ini->disablePacketFilter)
9210 {
9211 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009212 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 return 0;
9214 }
Agrawal Ashisha2662d22016-10-26 12:41:13 +05309215 if (pHddCtx->isLogpInProgress)
9216 {
9217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9218 "%s:LOGP in Progress. Ignore!!!", __func__);
9219 return -EBUSY;
9220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 /* Debug display of request components. */
9222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009223 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07009224
9225 switch (pRequest->filterAction)
9226 {
9227 case HDD_RCV_FILTER_SET:
9228 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009229 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009230
9231 packetFilterSetReq.filterId = pRequest->filterId;
9232 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
9233 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009234 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 __func__, pRequest->numParams);
9236 return -EINVAL;
9237 }
9238 packetFilterSetReq.numFieldParams = pRequest->numParams;
9239 packetFilterSetReq.coalesceTime = 0;
9240 packetFilterSetReq.filterType = 1;
9241 for (i=0; i < pRequest->numParams; i++)
9242 {
9243 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
9244 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
9245 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
9246 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
9247 packetFilterSetReq.paramsData[i].reserved = 0;
9248
Arif Hussain6d2a3322013-11-17 19:50:10 -08009249 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009250 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
9251 packetFilterSetReq.filterType);
9252
Arif Hussain6d2a3322013-11-17 19:50:10 -08009253 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05309255 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
9256 (pRequest->paramsData[i].dataLength))
9257 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009258
9259 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9260 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
9261 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9262 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
9263
Arif Hussain6d2a3322013-11-17 19:50:10 -08009264 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009265 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
9266 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
9267 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
9268
Arif Hussain6d2a3322013-11-17 19:50:10 -08009269 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009270 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
9271 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
9272 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
9273 }
9274
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309275 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009276 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009277 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009278 __func__);
9279 return -EINVAL;
9280 }
9281
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309282 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9283 pHddStaCtx->conn_info.staId[0], true);
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 break;
9285
9286 case HDD_RCV_FILTER_CLEAR:
9287
Arif Hussain6d2a3322013-11-17 19:50:10 -08009288 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009289 __func__, pRequest->filterId);
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309290
Sravan Kumar Kairam893801a2016-11-01 19:14:23 +05309291 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9292 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) {
9293 WLANTL_ResetRxSSN((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9294 pHddStaCtx->conn_info.staId[0]);
9295 }
9296
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309297 init_completion(&cbCtx.completion);
9298 cbCtx.magic = CLEAR_FILTER_MAGIC;
9299 cbCtx.pAdapter = pAdapter;
9300 packetFilterClrReq.cbCtx = &cbCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009301 packetFilterClrReq.filterId = pRequest->filterId;
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309302 packetFilterClrReq.pktFilterCallback = hdd_pkt_filter_done;
9303 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, pAdapter->sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07009304 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009305 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07009306 __func__);
9307 return -EINVAL;
9308 }
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309309
9310 status = wait_for_completion_interruptible_timeout(&cbCtx.completion,
9311 msecs_to_jiffies(PKT_FILTER_TIMEOUT));
9312 spin_lock(&hdd_context_lock);
9313 cbCtx.magic = 0;
9314 spin_unlock(&hdd_context_lock);
9315 if (0 >= status)
9316 {
9317 hddLog(LOGE, FL("failure waiting for pkt_filter_comp_var %d"),
9318 status);
9319 return -EINVAL;
9320 }
Sravan Kumar Kairama97e2372016-11-11 17:20:03 +05309321
9322 WLANTL_SetDataPktFilter((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
9323 pHddStaCtx->conn_info.staId[0], false);
Jeff Johnson295189b2012-06-20 16:38:30 -07009324 break;
9325
9326 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009327 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009328 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07009329 return -EINVAL;
9330 }
9331 return 0;
9332}
9333
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05309334int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
9335 tANI_U8 sessionId)
9336{
9337 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9338 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9339
9340 if (NULL == pHddCtx)
9341 {
9342 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
9343 return -EINVAL;
9344 }
9345
9346 if (pHddCtx->isLogpInProgress)
9347 {
9348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9349 "%s:LOGP in Progress. Ignore!!!", __func__);
9350 return -EBUSY;
9351 }
9352
9353 if (pHddCtx->cfg_ini->disablePacketFilter)
9354 {
9355 hddLog(VOS_TRACE_LEVEL_ERROR,
9356 "%s: Packet Filtering Disabled. Returning ",
9357 __func__ );
9358 return -EINVAL;
9359 }
9360
9361 switch (filterType)
9362 {
9363 /* For setting IPV6 MC and UC Filter we need to configure
9364 * 2 filters, one for MC and one for UC.
9365 * The Filter ID shouldn't be swapped, which results in making
9366 * UC Filter ineffective.
9367 * We have Hardcode all the values
9368 *
9369 * Reason for a seperate UC filter is because, driver need to
9370 * specify the FW that the specific filter is for unicast
9371 * otherwise FW will not pass the unicast frames by default
9372 * through the filter. This is required to avoid any performance
9373 * hits when no unicast filter is set and only MC/BC are set.
9374 * The way driver informs host is by using the MAC protocol
9375 * layer, CMP flag set to MAX, CMP Data set to 1.
9376 */
9377
9378 case HDD_FILTER_IPV6_MC_UC:
9379 /* Setting IPV6 MC Filter below
9380 */
9381 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9382 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9383 packetFilterSetReq.numFieldParams = 2;
9384 packetFilterSetReq.paramsData[0].protocolLayer =
9385 HDD_FILTER_PROTO_TYPE_MAC;
9386 packetFilterSetReq.paramsData[0].cmpFlag =
9387 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9388 packetFilterSetReq.paramsData[0].dataOffset =
9389 WLAN_HDD_80211_FRM_DA_OFFSET;
9390 packetFilterSetReq.paramsData[0].dataLength = 1;
9391 packetFilterSetReq.paramsData[0].compareData[0] =
9392 HDD_IPV6_MC_CMP_DATA;
9393
9394 packetFilterSetReq.paramsData[1].protocolLayer =
9395 HDD_FILTER_PROTO_TYPE_ARP;
9396 packetFilterSetReq.paramsData[1].cmpFlag =
9397 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9398 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9399 packetFilterSetReq.paramsData[1].dataLength = 2;
9400 packetFilterSetReq.paramsData[1].compareData[0] =
9401 HDD_IPV6_CMP_DATA_0;
9402 packetFilterSetReq.paramsData[1].compareData[1] =
9403 HDD_IPV6_CMP_DATA_1;
9404
9405
9406 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9407 &packetFilterSetReq, sessionId))
9408 {
9409 hddLog(VOS_TRACE_LEVEL_ERROR,
9410 "%s: Failure to execute Set IPv6 Mulicast Filter",
9411 __func__);
9412 return -EINVAL;
9413 }
9414
9415 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
9416
9417 /*
9418 * Setting IPV6 UC Filter below
9419 */
9420 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9421 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
9422 packetFilterSetReq.numFieldParams = 2;
9423 packetFilterSetReq.paramsData[0].protocolLayer =
9424 HDD_FILTER_PROTO_TYPE_MAC;
9425 packetFilterSetReq.paramsData[0].cmpFlag =
9426 HDD_FILTER_CMP_TYPE_MAX;
9427 packetFilterSetReq.paramsData[0].dataOffset = 0;
9428 packetFilterSetReq.paramsData[0].dataLength = 1;
9429 packetFilterSetReq.paramsData[0].compareData[0] =
9430 HDD_IPV6_UC_CMP_DATA;
9431
9432 packetFilterSetReq.paramsData[1].protocolLayer =
9433 HDD_FILTER_PROTO_TYPE_ARP;
9434 packetFilterSetReq.paramsData[1].cmpFlag =
9435 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9436 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9437 packetFilterSetReq.paramsData[1].dataLength = 2;
9438 packetFilterSetReq.paramsData[1].compareData[0] =
9439 HDD_IPV6_CMP_DATA_0;
9440 packetFilterSetReq.paramsData[1].compareData[1] =
9441 HDD_IPV6_CMP_DATA_1;
9442
9443 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9444 &packetFilterSetReq, sessionId))
9445 {
9446 hddLog(VOS_TRACE_LEVEL_ERROR,
9447 "%s: Failure to execute Set IPv6 Unicast Filter",
9448 __func__);
9449 return -EINVAL;
9450 }
9451
9452 break;
9453
9454 case HDD_FILTER_IPV6_MC:
9455 /*
9456 * IPV6 UC Filter might be already set,
9457 * clear the UC Filter. As the Filter
9458 * IDs are static, we can directly clear it.
9459 */
9460 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9461 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
9462 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
9463 &packetFilterClrReq, sessionId))
9464 {
9465 hddLog(VOS_TRACE_LEVEL_ERROR,
9466 "%s: Failure to execute Clear IPv6 Unicast Filter",
9467 __func__);
9468 return -EINVAL;
9469 }
9470
9471 /*
9472 * Setting IPV6 MC Filter below
9473 */
9474 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
9475 packetFilterSetReq.numFieldParams = 2;
9476 packetFilterSetReq.paramsData[0].protocolLayer =
9477 HDD_FILTER_PROTO_TYPE_MAC;
9478 packetFilterSetReq.paramsData[0].cmpFlag =
9479 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9480 packetFilterSetReq.paramsData[0].dataOffset =
9481 WLAN_HDD_80211_FRM_DA_OFFSET;
9482 packetFilterSetReq.paramsData[0].dataLength = 1;
9483 packetFilterSetReq.paramsData[0].compareData[0] =
9484 HDD_IPV6_MC_CMP_DATA;
9485
9486 packetFilterSetReq.paramsData[1].protocolLayer =
9487 HDD_FILTER_PROTO_TYPE_ARP;
9488 packetFilterSetReq.paramsData[1].cmpFlag =
9489 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
9490 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
9491 packetFilterSetReq.paramsData[1].dataLength = 2;
9492 packetFilterSetReq.paramsData[1].compareData[0] =
9493 HDD_IPV6_CMP_DATA_0;
9494 packetFilterSetReq.paramsData[1].compareData[1] =
9495 HDD_IPV6_CMP_DATA_1;
9496
9497
9498 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
9499 &packetFilterSetReq, sessionId))
9500 {
9501 hddLog(VOS_TRACE_LEVEL_ERROR,
9502 "%s: Failure to execute Set IPv6 Multicast Filter",
9503 __func__);
9504 return -EINVAL;
9505 }
9506 break;
9507
9508 default :
9509 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9510 "%s: Packet Filter Request: Invalid",
9511 __func__);
9512 return -EINVAL;
9513 }
9514 return 0;
9515}
9516
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309517void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07009518{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05309519 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309520 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07009521 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309522 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009523
Yue Ma3ede6052013-08-29 00:33:26 -07009524 if (NULL == pHddCtx)
9525 {
9526 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
9527 return;
9528 }
9529
9530 hHal = pHddCtx->hHal;
9531
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309532 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309534 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
9535 return;
9536 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309537
9538 /* Check if INI is enabled or not, other wise just return
9539 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309540 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309541 {
9542 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
9543 if (NULL == pMulticastAddrs)
9544 {
9545 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
9546 return;
9547 }
9548
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 if (set)
9550 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309551 /* Following pre-conditions should be satisfied before wei
9552 * configure the MC address list.
9553 */
9554 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9555 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
9556 && pAdapter->mc_addr_list.mc_cnt
9557 && (eConnectionState_Associated ==
9558 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9559 {
9560 pMulticastAddrs->ulMulticastAddrCnt =
9561 pAdapter->mc_addr_list.mc_cnt;
9562 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
9563 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009564 memcpy(pMulticastAddrs->multicastAddr[i],
9565 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309566 sizeof(pAdapter->mc_addr_list.addr[i]));
9567 hddLog(VOS_TRACE_LEVEL_INFO,
9568 "%s: %s multicast filter: addr ="
9569 MAC_ADDRESS_STR,
9570 __func__, set ? "setting" : "clearing",
9571 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
9572 }
9573 /* Set multicast filter */
9574 sme_8023MulticastList(hHal, pAdapter->sessionId,
9575 pMulticastAddrs);
9576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009577 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309578 else
9579 {
9580 /* Need to clear only if it was previously configured
9581 */
9582 if (pAdapter->mc_addr_list.isFilterApplied)
9583 {
9584 pMulticastAddrs->ulMulticastAddrCnt = 0;
9585 sme_8023MulticastList(hHal, pAdapter->sessionId,
9586 pMulticastAddrs);
9587 }
9588
9589 }
9590 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07009591 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07009592 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309593 else
9594 {
9595 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05309596 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309597 }
9598 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07009599}
9600
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309601static int __iw_set_packet_filter_params(struct net_device *dev,
9602 struct iw_request_info *info,
9603 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05309604{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309605 hdd_adapter_t *pAdapter;
9606 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08009607 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309608 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309609 struct iw_point s_priv_data;
9610
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309611 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05309612
9613 if (!capable(CAP_NET_ADMIN))
9614 {
9615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9616 FL("permission check failed"));
9617 return -EPERM;
9618 }
9619
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309620 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9621 if (NULL == pAdapter)
9622 {
9623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9624 "%s: Adapter is NULL",__func__);
9625 return -EINVAL;
9626 }
9627 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9628 ret = wlan_hdd_validate_context(pHddCtx);
9629 if (0 != ret)
9630 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309631 return ret;
9632 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309633 if (hdd_priv_get_data(&s_priv_data, wrqu))
9634 {
9635 return -EINVAL;
9636 }
9637
9638 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
9639 {
9640 return -EINVAL;
9641 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009642
Arif Hussain0273cba2014-01-07 20:58:29 -08009643 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05309644 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9645 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08009646 if (NULL == pRequest)
9647 {
9648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9649 "mem_alloc_copy_from_user_helper fail");
9650 return -ENOMEM;
9651 }
9652
Hanumanth Reddy Pothula73010b92016-11-01 16:16:58 +05309653 ret = wlan_hdd_set_filter(pAdapter, pRequest);
Arif Hussain0273cba2014-01-07 20:58:29 -08009654 kfree(pRequest);
9655
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309656 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08009657 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009658}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309659
9660static int iw_set_packet_filter_params(struct net_device *dev,
9661 struct iw_request_info *info,
9662 union iwreq_data *wrqu, char *extra)
9663{
9664 int ret;
9665
9666 vos_ssr_protect(__func__);
9667 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9668 vos_ssr_unprotect(__func__);
9669
9670 return ret;
9671}
Jeff Johnson295189b2012-06-20 16:38:30 -07009672#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309673static int __iw_get_statistics(struct net_device *dev,
9674 struct iw_request_info *info,
9675 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009676{
9677
9678 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
9679 eHalStatus status = eHAL_STATUS_SUCCESS;
9680 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309681 hdd_adapter_t *pAdapter;
9682 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309684 int tlen = 0, ret = 0;
9685 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009686
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309687 tCsrGlobalClassAStatsInfo *aStats;
9688 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07009689
9690 ENTER();
9691
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309692 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9693 if (NULL == pAdapter)
9694 {
9695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9696 "%s: Adapter is NULL",__func__);
9697 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009698 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309699 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9700 ret = wlan_hdd_validate_context(pHddCtx);
9701 if (0 != ret)
9702 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309703 return ret;
9704 }
9705 pStats = &(pAdapter->hdd_stats.summary_stat);
9706 aStats = &(pAdapter->hdd_stats.ClassA_stat);
9707 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07009708 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9709
9710 wrqu->txpower.value = 0;
9711 }
9712 else {
9713 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9714 SME_SUMMARY_STATS |
9715 SME_GLOBAL_CLASSA_STATS |
9716 SME_GLOBAL_CLASSB_STATS |
9717 SME_GLOBAL_CLASSC_STATS |
9718 SME_GLOBAL_CLASSD_STATS |
9719 SME_PER_STA_STATS,
9720 hdd_StatisticsCB, 0, FALSE,
9721 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9722
9723 if (eHAL_STATUS_SUCCESS != status)
9724 {
9725 hddLog(VOS_TRACE_LEVEL_ERROR,
9726 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009727 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009728 return -EINVAL;
9729 }
9730
9731 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309732 if (NULL == pWextState)
9733 {
9734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9735 "%s: pWextState is NULL",__func__);
9736 return -EINVAL;
9737 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009738
9739 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
9740 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9741 {
9742 hddLog(VOS_TRACE_LEVEL_ERROR,
9743 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009744 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009745 /*Remove the SME statistics list by passing NULL in callback argument*/
9746 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9747 SME_SUMMARY_STATS |
9748 SME_GLOBAL_CLASSA_STATS |
9749 SME_GLOBAL_CLASSB_STATS |
9750 SME_GLOBAL_CLASSC_STATS |
9751 SME_GLOBAL_CLASSD_STATS |
9752 SME_PER_STA_STATS,
9753 NULL, 0, FALSE,
9754 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9755
9756 return -EINVAL;
9757 }
9758 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9759 (tANI_U8) sizeof (pStats->retry_cnt),
9760 (char*) &(pStats->retry_cnt[0]),
9761 tlen);
9762
9763 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9764 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9765 (char*) &(pStats->multiple_retry_cnt[0]),
9766 tlen);
9767
9768 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9769 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9770 (char*) &(pStats->tx_frm_cnt[0]),
9771 tlen);
9772
9773 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9774 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9775 (char*) &(pStats->rx_frm_cnt),
9776 tlen);
9777
9778 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9779 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9780 (char*) &(pStats->frm_dup_cnt),
9781 tlen);
9782
9783 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9784 (tANI_U8) sizeof (pStats->fail_cnt),
9785 (char*) &(pStats->fail_cnt[0]),
9786 tlen);
9787
9788 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9789 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9790 (char*) &(pStats->rts_fail_cnt),
9791 tlen);
9792
9793 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9794 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9795 (char*) &(pStats->ack_fail_cnt),
9796 tlen);
9797
9798 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9799 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9800 (char*) &(pStats->rts_succ_cnt),
9801 tlen);
9802
9803 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9804 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9805 (char*) &(pStats->rx_discard_cnt),
9806 tlen);
9807
9808 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9809 (tANI_U8) sizeof (pStats->rx_error_cnt),
9810 (char*) &(pStats->rx_error_cnt),
9811 tlen);
9812
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009813 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009814 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009815 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009816 tlen);
9817
9818 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9819 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9820 (char*) &(dStats->rx_byte_cnt),
9821 tlen);
9822
9823 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9824 (tANI_U8) sizeof (dStats->rx_rate),
9825 (char*) &(dStats->rx_rate),
9826 tlen);
9827
9828 /* Transmit rate, in units of 500 kbit/sec */
9829 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9830 (tANI_U8) sizeof (aStats->tx_rate),
9831 (char*) &(aStats->tx_rate),
9832 tlen);
9833
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009834 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9835 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9836 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009837 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009838 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9839 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9840 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009841 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009842 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9843 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9844 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009845 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009846 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9847 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9848 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009849 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009850 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9851 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9852 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009853 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009854 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9855 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9856 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009857 tlen);
9858
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 wrqu->data.length = tlen;
9860
9861 }
9862
9863 EXIT();
9864
9865 return 0;
9866}
9867
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309868static int iw_get_statistics(struct net_device *dev,
9869 struct iw_request_info *info,
9870 union iwreq_data *wrqu, char *extra)
9871{
9872 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009873
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309874 vos_ssr_protect(__func__);
9875 ret = __iw_get_statistics(dev, info, wrqu, extra);
9876 vos_ssr_unprotect(__func__);
9877
9878 return ret;
9879}
Jeff Johnson295189b2012-06-20 16:38:30 -07009880#ifdef FEATURE_WLAN_SCAN_PNO
9881
9882/*Max Len for PNO notification*/
9883#define MAX_PNO_NOTIFY_LEN 100
9884void found_pref_network_cb (void *callbackContext,
9885 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9886{
9887 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9888 union iwreq_data wrqu;
9889 char buf[MAX_PNO_NOTIFY_LEN+1];
9890
9891 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9892 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9893
9894 // create the event
9895 memset(&wrqu, 0, sizeof(wrqu));
9896 memset(buf, 0, sizeof(buf));
9897
9898 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9899 pPrefNetworkFoundInd->ssId.ssId,
9900 (unsigned int)pPrefNetworkFoundInd->rssi);
9901
9902 wrqu.data.pointer = buf;
9903 wrqu.data.length = strlen(buf);
9904
9905 // send the event
9906
9907 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9908
9909}
9910
9911
9912/*string based input*/
9913VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9914 union iwreq_data *wrqu, char *extra, int nOffset)
9915{
9916 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309917 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009918 /* pnoRequest is a large struct, so we make it static to avoid stack
9919 overflow. This API is only invoked via ioctl, so it is
9920 serialized by the kernel rtnl_lock and hence does not need to be
9921 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309922 tSirPNOScanReq pnoRequest = {0};
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309923 char *ptr, *data;
Jeff Johnson295189b2012-06-20 16:38:30 -07009924 v_U8_t i,j, ucParams, ucMode;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309925 size_t len;
c_hpothu37f21312014-04-09 21:49:54 +05309926 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009927 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9928
9929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9930 "PNO data len %d data %s",
9931 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009932 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009933
9934 if (wrqu->data.length <= nOffset )
9935 {
9936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9937 return VOS_STATUS_E_FAILURE;
9938 }
9939
9940 pnoRequest.enable = 0;
9941 pnoRequest.ucNetworksCount = 0;
9942 /*-----------------------------------------------------------------------
9943 Input is string based and expected to be like this:
9944
9945 <enabled> <netw_count>
9946 for each network:
9947 <ssid_len> <ssid> <authentication> <encryption>
9948 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9949 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9950
9951 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009952 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 -07009953
9954 this translates into:
9955 -----------------------------
9956 enable PNO
9957 look for 2 networks:
9958 test - with authentication type 0 and encryption type 0,
9959 that can be found on 3 channels: 1 6 and 11 ,
9960 SSID bcast type is unknown (directed probe will be sent if AP not found)
9961 and must meet -40dBm RSSI
9962
9963 test2 - with auth and enrytption type 4/4
9964 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9965 bcast type is non-bcast (directed probe will be sent)
9966 and must not meet any RSSI threshold
9967
Jeff Johnson8301aa12013-03-28 14:27:29 -07009968 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009969 -----------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07009970
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309971 /* making sure argument string ends with '\0' */
9972 len = (wrqu->data.length-nOffset) + 1;
9973 data = vos_mem_malloc(len);
9974 if (NULL == data) {
9975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9976 FL("fail to allocate memory %zu"), len);
9977 return -EINVAL;
9978 }
9979 vos_mem_zero(data, len);
9980 vos_mem_copy(data, &extra[nOffset], (len-1));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309981 ptr = data;
9982
9983 if (1 != sscanf(ptr," %hhu%n", &(pnoRequest.enable), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -07009984 {
9985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9986 "PNO enable input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +05309987 vos_mem_free(data);
Wilson Yang623f6592013-10-08 16:33:37 -07009988 return VOS_STATUS_E_FAILURE;
9989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009990
9991 if ( 0 == pnoRequest.enable )
9992 {
9993 /*Disable PNO*/
9994 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309995 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9996 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009997 pAdapter->sessionId,
9998 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309999 if (eHAL_STATUS_SUCCESS != status)
10000 {
10001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10002 "%s: failed to disable PNO", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010003 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010004 return VOS_STATUS_E_FAILURE;
10005 }
10006 pHddCtx->isPnoEnable = FALSE;
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010007 vos_mem_free(data);
Jeff Johnson295189b2012-06-20 16:38:30 -070010008 return VOS_STATUS_SUCCESS;
10009 }
10010
c_hpothu37f21312014-04-09 21:49:54 +053010011 if (TRUE == pHddCtx->isPnoEnable)
10012 {
10013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10014 FL("already PNO is enabled"));
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010015 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010016 return -EBUSY;
10017 }
10018 pHddCtx->isPnoEnable = TRUE;
10019
Jeff Johnson295189b2012-06-20 16:38:30 -070010020 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -070010021
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010022 if (1 != sscanf(ptr," %hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
Wilson Yang623f6592013-10-08 16:33:37 -070010023 {
10024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10025 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010026 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010028
10029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10030 "PNO enable %d networks count %d offset %d",
10031 pnoRequest.enable,
10032 pnoRequest.ucNetworksCount,
10033 nOffset);
10034
10035 /* Parameters checking:
10036 ucNetworksCount has to be larger than 0*/
10037 if (( 0 == pnoRequest.ucNetworksCount ) ||
10038 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
10039 {
10040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +053010041 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010042 }
10043
10044 ptr += nOffset;
10045
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010046 pnoRequest.aNetworks =
10047 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10048 if (pnoRequest.aNetworks == NULL)
10049 {
10050 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10051 FL("failed to allocate memory aNetworks %u"),
10052 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10053 goto error;
10054 }
10055 vos_mem_zero(pnoRequest.aNetworks,
10056 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
10057
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
10059 {
10060
10061 pnoRequest.aNetworks[i].ssId.length = 0;
10062
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010063 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010064 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
10065
10066 if (1 != ucParams)
10067 {
10068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10069 "PNO ssid length input is not valid %s",ptr);
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010070 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010071 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010072
10073 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
10074 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
10075 {
10076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10077 "SSID Len %d is not correct for network %d",
10078 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +053010079 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 }
10081
10082 /*Advance to SSID*/
10083 ptr += nOffset;
10084
Jeff Johnson8301aa12013-03-28 14:27:29 -070010085 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -080010086 pnoRequest.aNetworks[i].ssId.length);
10087 ptr += pnoRequest.aNetworks[i].ssId.length;
10088
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010089 ucParams = sscanf(ptr," %u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -080010090 &(pnoRequest.aNetworks[i].authentication),
10091 &(pnoRequest.aNetworks[i].encryption),
10092 &(pnoRequest.aNetworks[i].ucChannelCount),
10093 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010094
Wilson Yang623f6592013-10-08 16:33:37 -070010095 if ( 3 != ucParams )
10096 {
10097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10098 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010099 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010100 }
10101
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010103 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -080010104 "auth %d encry %d channel count %d offset %d",
10105 pnoRequest.aNetworks[i].ssId.length,
10106 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
10107 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
10108 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
10109 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
10110 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
10111 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
10112 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
10113 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
10114 pnoRequest.aNetworks[i].authentication,
10115 pnoRequest.aNetworks[i].encryption,
10116 pnoRequest.aNetworks[i].ucChannelCount,
10117 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -070010118
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 /*Advance to channel list*/
10120 ptr += nOffset;
10121
Wilson Yang623f6592013-10-08 16:33:37 -070010122 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -070010123 {
10124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10125 "Incorrect number of channels");
Gupta, Kapil2ebf3e02016-03-17 19:45:19 +053010126 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 }
10128
10129 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
10130 {
10131 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
10132 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010133 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010134 &(pnoRequest.aNetworks[i].aChannels[j]),
10135 &nOffset))
10136 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10137 "PNO network channel input is not valid %s",ptr);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010138 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010139 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010140 if (!IS_CHANNEL_VALID(pnoRequest.aNetworks[i].aChannels[j])) {
10141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10142 FL("invalid channel: %hhu"),
10143 pnoRequest.aNetworks[i].aChannels[j]);
10144 goto error;
10145 }
10146
Wilson Yang623f6592013-10-08 16:33:37 -070010147 /*Advance to next channel number*/
10148 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010149 }
10150 }
10151
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010152 if (1 != sscanf(ptr," %u %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010153 &(pnoRequest.aNetworks[i].bcastNetwType),
10154 &nOffset))
10155 {
10156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10157 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010158 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010159 }
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010160 if (pnoRequest.aNetworks[i].bcastNetwType > 2) {
10161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10162 FL("invalid bcast nw type: %u"),
10163 pnoRequest.aNetworks[i].bcastNetwType);
10164 goto error;
10165 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010166
10167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10168 "PNO bcastNetwType %d offset %d",
10169 pnoRequest.aNetworks[i].bcastNetwType,
10170 nOffset );
10171
10172 /*Advance to rssi Threshold*/
10173 ptr += nOffset;
10174
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010175 if (1 != sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010176 &(pnoRequest.aNetworks[i].rssiThreshold),
10177 &nOffset))
10178 {
10179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10180 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +053010181 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010182 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010183
10184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10185 "PNO rssi %d offset %d",
10186 pnoRequest.aNetworks[i].rssiThreshold,
10187 nOffset );
10188 /*Advance to next network*/
10189 ptr += nOffset;
10190 }/*For ucNetworkCount*/
10191
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010192 ucParams = sscanf(ptr," %hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -070010193 &(pnoRequest.scanTimers.ucScanTimersCount),
10194 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010195
10196 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -070010197 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 {
10199 ptr += nOffset;
10200
Jeff Johnson8301aa12013-03-28 14:27:29 -070010201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10202 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010203 pnoRequest.scanTimers.ucScanTimersCount,
10204 nOffset );
10205
10206 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
10207 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010209 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +053010210 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -070010211 }
10212
10213 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
10214 {
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010215 ucParams = sscanf(ptr," %u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -070010216 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
10217 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
10218 &nOffset);
10219
Wilson Yang623f6592013-10-08 16:33:37 -070010220 if (2 != ucParams)
10221 {
10222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10223 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +053010224 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -070010225 }
10226
Jeff Johnson8301aa12013-03-28 14:27:29 -070010227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10228 "PNO Timer value %d Timer repeat %d offset %d",
10229 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -070010230 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
10231 nOffset );
10232
Jeff Johnson295189b2012-06-20 16:38:30 -070010233 ptr += nOffset;
10234 }
10235
10236 }
10237 else
10238 {
Jeff Johnson8301aa12013-03-28 14:27:29 -070010239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10240 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010241 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
10242
10243 /*Scan timers defaults to 5 minutes*/
10244 pnoRequest.scanTimers.ucScanTimersCount = 1;
10245 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
10246 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
10247 }
10248
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010249 ucParams = sscanf(ptr," %hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -070010250
10251 pnoRequest.modePNO = ucMode;
10252 /*for LA we just expose suspend option*/
10253 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
10254 {
10255 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10256 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010257 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10258 if (pnoRequest.p24GProbeTemplate == NULL){
10259 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10260 FL("failed to allocate memory p24GProbeTemplate %u"),
10261 SIR_PNO_MAX_PB_REQ_SIZE);
10262 goto error;
10263 }
10264
10265 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
10266 if (pnoRequest.p5GProbeTemplate == NULL){
10267 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10268 FL("failed to allocate memory p5GProbeTemplate %u"),
10269 SIR_PNO_MAX_PB_REQ_SIZE);
10270 goto error;
10271 }
10272
10273 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
10274 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010275
c_hpothu37f21312014-04-09 21:49:54 +053010276 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -070010277 pAdapter->sessionId,
10278 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +053010279 if (eHAL_STATUS_SUCCESS == status)
10280 {
10281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10282 "%s: PNO enabled", __func__);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010283 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010284 return VOS_STATUS_SUCCESS;
10285 }
10286error:
10287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10288 "%s: Failed to enable PNO", __func__);
10289 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053010290 if (pnoRequest.aNetworks)
10291 vos_mem_free(pnoRequest.aNetworks);
10292 if (pnoRequest.p24GProbeTemplate)
10293 vos_mem_free(pnoRequest.p24GProbeTemplate);
10294 if (pnoRequest.p5GProbeTemplate)
10295 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumanth Reddy Pothula7f886be2017-01-12 13:42:53 +053010296
10297 vos_mem_free(data);
c_hpothu37f21312014-04-09 21:49:54 +053010298 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010299}/*iw_set_pno*/
10300
10301VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
10302 union iwreq_data *wrqu, char *extra, int nOffset)
10303{
10304 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10305 v_U8_t rssiThreshold = 0;
10306 v_U8_t nRead;
10307
Arif Hussain7adce1b2013-11-11 22:59:34 -080010308 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010309 &rssiThreshold);
10310
10311 if ( 1 != nRead )
10312 {
10313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10314 "Incorrect format");
10315 return VOS_STATUS_E_FAILURE;
10316 }
10317
10318 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
10319 return VOS_STATUS_SUCCESS;
10320}
10321
10322
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010323static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 struct iw_request_info *info,
10325 union iwreq_data *wrqu, char *extra)
10326{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010327 hdd_adapter_t *pAdapter;
10328 hdd_context_t *pHddCtx;
10329 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010330 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010331
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010332 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010333 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10334 if (NULL == pAdapter)
10335 {
10336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10337 "%s: Adapter is NULL",__func__);
10338 return -EINVAL;
10339 }
10340
10341 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10342 ret = wlan_hdd_validate_context(pHddCtx);
10343 if (0 != ret)
10344 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010345 return ret;
10346 }
10347
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010348
10349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010351
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010352 status = iw_set_pno(dev,info,wrqu,extra,0);
10353
10354 EXIT();
10355 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010356}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010357
10358static int iw_set_pno_priv(struct net_device *dev,
10359 struct iw_request_info *info,
10360 union iwreq_data *wrqu, char *extra)
10361{
10362 int ret;
10363
10364 vos_ssr_protect(__func__);
10365 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
10366 vos_ssr_unprotect(__func__);
10367
10368 return ret;
10369}
Jeff Johnson295189b2012-06-20 16:38:30 -070010370#endif /*FEATURE_WLAN_SCAN_PNO*/
10371
10372//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +053010373int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010374{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010375 hdd_adapter_t *pAdapter;
10376 tHalHandle hHal;
10377 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010378 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +053010379 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010380 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -070010381 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010382 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010383 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010384 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010385
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010386 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010387 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10388 if (NULL == pAdapter)
10389 {
10390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10391 "%s: Adapter is NULL",__func__);
10392 return -EINVAL;
10393 }
10394 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10395 retval = wlan_hdd_validate_context(pHddCtx);
10396 if (0 != retval)
10397 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010398 return retval;
10399 }
10400 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10401 if (NULL == hHal)
10402 {
10403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10404 "%s: Hal Context is NULL",__func__);
10405 return -EINVAL;
10406 }
10407 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -070010408
Atul Mittal54378cb2014-04-02 16:51:50 +053010409 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 {
10411 case WLAN_HDD_UI_BAND_AUTO:
10412 band = eCSR_BAND_ALL;
10413 break;
10414 case WLAN_HDD_UI_BAND_5_GHZ:
10415 band = eCSR_BAND_5G;
10416 break;
10417 case WLAN_HDD_UI_BAND_2_4_GHZ:
10418 band = eCSR_BAND_24;
10419 break;
10420 default:
10421 band = eCSR_BAND_MAX;
10422 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010423 connectedBand =
10424 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -070010425
Atul Mittal54378cb2014-04-02 16:51:50 +053010426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010427 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010428
10429 if (band == eCSR_BAND_MAX)
10430 {
10431 /* Received change band request with invalid band value */
10432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +053010433 "%s: Invalid band value %u", __func__, ui_band);
10434 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010435 }
10436
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010437 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +053010438 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010439 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010441 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010442 band, pHddCtx->cfg_ini->nBandCapability);
10443 return -EIO;
10444 }
10445
Sushant Kaushik1165f872015-03-30 20:25:27 +053010446 if (band == eCSR_BAND_ALL)
10447 {
10448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
10449 "received. Setting band same as ini value %d"),
10450 pHddCtx->cfg_ini->nBandCapability);
10451 band = pHddCtx->cfg_ini->nBandCapability;
10452 }
10453
Jeff Johnson295189b2012-06-20 16:38:30 -070010454 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
10455 {
10456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10457 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010458 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010459 return -EIO;
10460 }
10461
10462 if (currBand != band)
10463 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010464 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010465 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010466 /* Return failure if current country code is world regulatory domain*/
10467 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
10468 pMac->scan.countryCodeCurrent[1] == '0') )
10469 {
10470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10471 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010472 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +053010473 return -EAGAIN;
10474 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010475 }
10476
Jeff Johnson295189b2012-06-20 16:38:30 -070010477 /* Change band request received.
10478 * Abort pending scan requests, flush the existing scan results,
10479 * and change the band capability
10480 */
10481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10482 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010483 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010484
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010485 /* We need to change the band and flush the scan results here itself
10486 * as we may get timeout for disconnection in which we will return
10487 * with out doing any of these
10488 */
10489 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
10490 {
10491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10492 "%s: failed to set the band value to %u ",
10493 __func__, band);
10494 return -EINVAL;
10495 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010496 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
10497 {
Sachin Ahuja120bf632015-02-24 18:06:34 +053010498 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010499 curr_country[0]=pMac->scan.countryCodeCurrent[0];
10500 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +053010501 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010502 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
10503 * information available in NV so to get the channel information from kernel
10504 * we need to send regulatory hint for the currunt country
10505 * And to set the same country again we need to set the dummy country
10506 * first and then the actual country.
10507 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010508#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10509 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
10510#else
10511 regulatory_hint_user("00");
10512#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010513 wait_result = wait_for_completion_interruptible_timeout(
10514 &pHddCtx->linux_reg_req,
10515 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10516
10517 /* if the country information does not exist with the kernel,
10518 then the driver callback would not be called */
10519
10520 if (wait_result >= 0)
10521 {
10522 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10523 "runtime country code is found in kernel db");
10524 }
10525 else
10526 {
10527 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10528 "runtime country code is not found"
10529 " in kernel db");
10530 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010531
10532 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +053010533
10534 /*
10535 * Update 11dcountry and current country here as the hint
10536 * with 00 results in 11d and current country with 00
10537 */
10538 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
10539 WNI_CFG_COUNTRY_CODE_LEN);
10540 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
10541 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010542#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10543 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
10544#else
10545 regulatory_hint_user(curr_country);
10546#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +053010547 wait_result = wait_for_completion_interruptible_timeout(
10548 &pHddCtx->linux_reg_req,
10549 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
10550
10551 /* if the country information does not exist with the kernel,
10552 then the driver callback would not be called */
10553 if (wait_result >= 0)
10554 {
10555 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
10556 "runtime country code is found in kernel db");
10557 }
10558 else
10559 {
10560 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
10561 "runtime country code is not found"
10562 " in kernel db");
10563 }
10564
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010565 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010566 }
10567 else
10568 {
Abhishek Singh678227a2014-11-04 10:52:38 +053010569#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010570 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
10571 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +053010572#else
10573 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
10574#endif
10575
Abhishek Singh2ec36ab2014-08-07 16:14:25 +053010576 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010577 pScanInfo = &pHddCtx->scan_info;
10578 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
10579 {
10580 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
10581 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10582 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +053010583 sme_FilterScanResults(hHal, pAdapter->sessionId);
10584
10585 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +053010586 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
10587 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -070010588 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010589 eHalStatus status = eHAL_STATUS_SUCCESS;
10590 long lrc;
10591
10592 /* STA already connected on current band, So issue disconnect first,
10593 * then change the band*/
10594
10595 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +053010596 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +053010597 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -070010598
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10600
10601 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10602 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
10603
Jeff Johnson43971f52012-07-17 12:26:56 -070010604 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 {
10606 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010607 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010608 __func__, (int)status );
10609 return -EINVAL;
10610 }
10611
10612 lrc = wait_for_completion_interruptible_timeout(
10613 &pAdapter->disconnect_comp_var,
10614 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10615
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +053010616 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -070010617
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -070010618 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010619 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -070010620
10621 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
10622 }
10623 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010625 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +053010626 if (TRUE == pHddCtx->isSetBandByNL)
10627 return 0;
10628 else
10629 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -070010630}
10631
Atul Mittal54378cb2014-04-02 16:51:50 +053010632int hdd_setBand_helper(struct net_device *dev, const char *command)
10633{
10634 u8 band;
10635
10636 /*convert the band value from ascii to integer*/
10637 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
10638
10639 return hdd_setBand(dev, band);
10640
10641}
10642
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010643static int __iw_set_band_config(struct net_device *dev,
10644 struct iw_request_info *info,
10645 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010646{
Atul Mittal54378cb2014-04-02 16:51:50 +053010647 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -070010648
Arif Hussain0273cba2014-01-07 20:58:29 -080010649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010650
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +053010651 if (!capable(CAP_NET_ADMIN))
10652 {
10653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10654 FL("permission check failed"));
10655 return -EPERM;
10656 }
10657
Atul Mittal54378cb2014-04-02 16:51:50 +053010658 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -070010659}
10660
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010661static int iw_set_band_config(struct net_device *dev,
10662 struct iw_request_info *info,
10663 union iwreq_data *wrqu, char *extra)
10664{
10665 int ret;
10666
10667 vos_ssr_protect(__func__);
10668 ret = __iw_set_band_config(dev, info, wrqu, extra);
10669 vos_ssr_unprotect(__func__);
10670
10671 return ret;
10672}
10673
c_manjeecfd1efb2015-09-25 19:32:34 +053010674static int get_fwr_memdump(struct net_device *dev,
10675 struct iw_request_info *info,
10676 union iwreq_data *wrqu, char *extra)
10677{
10678 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10679 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10680 int ret;
10681 ENTER();
10682 // HddCtx sanity
10683 ret = wlan_hdd_validate_context(pHddCtx);
10684 if (0 != ret)
10685 {
10686 return ret;
10687 }
10688 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
10689 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
10690 {
10691 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
10692 return -EINVAL;
10693 }
10694 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
10695
10696 EXIT();
10697 return ret;
10698}
10699
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010700static int __iw_set_power_params_priv(struct net_device *dev,
10701 struct iw_request_info *info,
10702 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -070010703{
Arif Hussain0273cba2014-01-07 20:58:29 -080010704 int ret;
10705 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010706
Jeff Johnson295189b2012-06-20 16:38:30 -070010707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10708 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +053010709
10710 if (!capable(CAP_NET_ADMIN))
10711 {
10712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10713 FL("permission check failed"));
10714 return -EPERM;
10715 }
10716
Arif Hussain0273cba2014-01-07 20:58:29 -080010717 /* ODD number is used for set, copy data using copy_from_user */
10718 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
10719 wrqu->data.length);
10720 if (NULL == ptr)
10721 {
10722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10723 "mem_alloc_copy_from_user_helper fail");
10724 return -ENOMEM;
10725 }
10726
10727 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
10728 kfree(ptr);
10729 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010730}
10731
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010732static int iw_set_power_params_priv(struct net_device *dev,
10733 struct iw_request_info *info,
10734 union iwreq_data *wrqu, char *extra)
10735{
10736 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070010737
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +053010738 vos_ssr_protect(__func__);
10739 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
10740 vos_ssr_unprotect(__func__);
10741
10742 return ret;
10743}
Jeff Johnson295189b2012-06-20 16:38:30 -070010744
10745/*string based input*/
10746VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
10747 union iwreq_data *wrqu, char *extra, int nOffset)
10748{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010749 hdd_adapter_t *pAdapter;
10750 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010751 tSirSetPowerParamsReq powerRequest;
10752 char *ptr;
10753 v_U8_t ucType;
10754 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010755 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010756
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010757 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010758 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10759 if (NULL == pAdapter)
10760 {
10761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10762 "%s: Adapter is NULL",__func__);
10763 return -EINVAL;
10764 }
10765
10766 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10767 ret = wlan_hdd_validate_context(pHddCtx);
10768 if (0 != ret)
10769 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +053010770 return ret;
10771 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10773 "Power Params data len %d data %s",
10774 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010775 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010776
10777 if (wrqu->data.length <= nOffset )
10778 {
10779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10780 return VOS_STATUS_E_FAILURE;
10781 }
10782
10783 uTotalSize = wrqu->data.length - nOffset;
10784
10785 /*-----------------------------------------------------------------------
10786 Input is string based and expected to be like this:
10787
10788 <param_type> <param_value> <param_type> <param_value> ...
10789
10790 e.g:
10791 1 2 2 3 3 0 4 1 5 1
10792
10793 e.g. setting just a few:
10794 1 2 4 1
10795
10796 parameter types:
10797 -----------------------------
10798 1 - Ignore DTIM
10799 2 - Listen Interval
10800 3 - Broadcast Multicas Filter
10801 4 - Beacon Early Termination
10802 5 - Beacon Early Termination Interval
10803 -----------------------------------------------------------------------*/
10804 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10805 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10806 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10807 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10808 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10809
Arif Hussain7adce1b2013-11-11 22:59:34 -080010810 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010811
10812 while ( uTotalSize )
10813 {
Wilson Yang6f971452013-10-08 15:00:00 -070010814 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10815 {
10816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10817 "Invalid input parameter type %s",ptr);
10818 return VOS_STATUS_E_FAILURE;
10819 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010820
10821 uTotalSize -= nOffset;
10822
10823 if (!uTotalSize)
10824 {
10825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010826 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010827 ucType, nOffset);
10828 return VOS_STATUS_E_FAILURE;
10829 }
10830
10831 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010832
Jeff Johnson02797792013-10-26 19:17:13 -070010833 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010834 {
10835 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10836 "Invalid input parameter value %s",ptr);
10837 return VOS_STATUS_E_FAILURE;
10838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010839
10840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10841 "Power request parameter %d value %d offset %d",
10842 ucType, uValue, nOffset);
10843
10844 switch (ucType)
10845 {
10846 case eSIR_IGNORE_DTIM:
10847 powerRequest.uIgnoreDTIM = uValue;
10848 break;
10849 case eSIR_LISTEN_INTERVAL:
10850 powerRequest.uListenInterval = uValue;
10851 break;
10852 case eSIR_MCAST_BCAST_FILTER:
10853 powerRequest.uBcastMcastFilter = uValue;
10854 break;
10855 case eSIR_ENABLE_BET:
10856 powerRequest.uEnableBET = uValue;
10857 break;
10858 case eSIR_BET_INTERVAL:
10859 powerRequest.uBETInterval = uValue;
10860 break;
10861 default:
10862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010863 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010864 ucType, uValue, nOffset);
10865 return VOS_STATUS_E_FAILURE;
10866 }
10867
10868 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10870 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010871 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010872 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010873 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010874 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010875 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10876 {
10877 uTotalSize = 0;
10878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010879
10880 }/*Go for as long as we have a valid string*/
10881
10882 /* put the device into full power*/
10883 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10884
10885 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010886 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010887
10888 /* put the device back to power save*/
10889 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10890
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010891 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010892 return VOS_STATUS_SUCCESS;
10893}/*iw_set_power_params*/
10894
Atul Mittalc0f739f2014-07-31 13:47:47 +053010895// tdlsoffchan
10896#ifdef FEATURE_WLAN_TDLS
10897
Atul Mittal87ec2422014-09-24 13:12:50 +053010898int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010899{
10900 if (offchannel < 0 || offchannel > 165)
10901 {
10902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10903 __func__, offchannel);
10904 return -1;
10905
10906 }
10907
10908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10909 __func__, tdlsOffCh, offchannel);
10910
10911 tdlsOffCh = offchannel;
10912 return 0;
10913}
10914
Atul Mittal87ec2422014-09-24 13:12:50 +053010915int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010916{
10917 if (offchanoffset == 0)
10918 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010919 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10921 __func__, tdlsOffChBwOffset);
10922
10923 return 0;
10924
10925 }
10926
10927 if ( offchanoffset == 40 )
10928 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010929 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10931 __func__, tdlsOffChBwOffset);
10932
10933 return 0;
10934
10935 }
10936 if (offchanoffset == -40)
10937 {
10938 tdlsOffChBwOffset = 3;
10939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10940 __func__, tdlsOffChBwOffset);
10941
10942 return 0;
10943
10944 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010945
10946 if ((offchanoffset == 80) &&
10947 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10948 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10949 {
10950 tdlsOffChBwOffset = 4;
10951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10952 "%s: change tdls secondary off channel offset to %u",
10953 __func__, tdlsOffChBwOffset);
10954
10955 return 0;
10956 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10958 __func__, offchanoffset);
10959 return -1;
10960}
10961
Atul Mittal87ec2422014-09-24 13:12:50 +053010962int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010963{
10964 hddTdlsPeer_t *connPeer = NULL;
10965 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10966 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010967 tSirMacAddr peerMac;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010968 if (offchanmode < 0 || offchanmode > 4)
10969 {
10970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10971 "%s: Invalid tdls off channel mode %d",
10972 __func__, offchanmode);
10973 return -1;
10974 }
10975
10976 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10977 {
10978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10979 "%s: tdls off channel mode req in not associated state %d",
10980 __func__, offchanmode);
10981 return -1;
10982 }
10983
10984 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10985 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10986 {
10987 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010988 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010989 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010990 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010991 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10993 "%s: No TDLS Connected Peer", __func__);
10994 return -1;
10995 }
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053010996 vos_mem_copy(peerMac, connPeer->peerMac, sizeof(tSirMacAddr));
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010997 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010998 }
10999 else
11000 {
11001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11002 "%s: TDLS Connection not supported", __func__);
11003 return -1;
11004 }
11005
11006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11007 ("%s: TDLS Channel Switch in swmode=%d"),
11008 __func__, offchanmode);
11009
11010 switch (offchanmode)
11011 {
11012 case 1:/*Enable*/
11013 case 2:/*Disable*/
11014 {
11015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11016 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
11017 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11018 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
11019 {
11020
11021 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
Masti, Narayanraddi4c30a092015-10-17 16:13:38 +053011022 pAdapter->sessionId, peerMac,
Atul Mittalc0f739f2014-07-31 13:47:47 +053011023 tdlsOffCh, tdlsOffChBwOffset,
11024 offchanmode);
11025 }
11026 else
11027 {
11028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11029 "%s: TDLS Off Channel not supported", __func__);
11030 return -1;
11031 }
11032 break;
11033 }
11034 case 3:
11035 {
11036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11037 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
11038 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11039
11040 break;
11041 }
11042 case 4:
11043 {
11044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11045 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
11046 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11047 break;
11048 }
11049 default:
11050 {
11051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11052 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
11053 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
11054 break;
11055 }
11056
11057 }
11058
11059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
11060 __func__, offchanmode);
11061 return 0;
11062}
Atul Mittalc0f739f2014-07-31 13:47:47 +053011063#endif
11064
Jeff Johnson295189b2012-06-20 16:38:30 -070011065// Define the Wireless Extensions to the Linux Network Device structure
11066// A number of these routines are NULL (meaning they are not implemented.)
11067
11068static const iw_handler we_handler[] =
11069{
11070 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
11071 (iw_handler) iw_get_name, /* SIOCGIWNAME */
11072 (iw_handler) NULL, /* SIOCSIWNWID */
11073 (iw_handler) NULL, /* SIOCGIWNWID */
11074 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
11075 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
11076 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
11077 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
11078 (iw_handler) NULL, /* SIOCSIWSENS */
11079 (iw_handler) NULL, /* SIOCGIWSENS */
11080 (iw_handler) NULL, /* SIOCSIWRANGE */
11081 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
SaidiReddy Yenugae2650932016-08-30 15:34:43 +053011082 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
Jeff Johnson295189b2012-06-20 16:38:30 -070011083 (iw_handler) NULL, /* SIOCGIWPRIV */
11084 (iw_handler) NULL, /* SIOCSIWSTATS */
11085 (iw_handler) NULL, /* SIOCGIWSTATS */
11086 iw_handler_set_spy, /* SIOCSIWSPY */
11087 iw_handler_get_spy, /* SIOCGIWSPY */
11088 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
11089 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
11090 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
11091 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
11092 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
11093 (iw_handler) NULL, /* SIOCGIWAPLIST */
11094 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
11095 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
11096 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
11097 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
11098 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
11099 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
11100 (iw_handler) NULL, /* -- hole -- */
11101 (iw_handler) NULL, /* -- hole -- */
11102 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
11103 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
11104 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
11105 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
11106 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
11107 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
11108 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
11109 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
11110 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
11111 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
11112 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
11113 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
11114 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
11115 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
11116 (iw_handler) NULL, /* -- hole -- */
11117 (iw_handler) NULL, /* -- hole -- */
11118 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
11119 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
11120 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
11121 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
11122 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
11123 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
11124 (iw_handler) NULL, /* SIOCSIWPMKSA */
11125};
11126
11127static const iw_handler we_private[] = {
11128
11129 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
11130 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
11131 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
11132 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
11133 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
11134 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053011135 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070011136 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
11137 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
11138 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Manjeet Singh3ed79242017-01-11 19:04:32 +053011139 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
11140 iw_setnone_get_threeint,
Jeff Johnsone7245742012-09-05 17:12:55 -070011141#ifdef FEATURE_OEM_DATA_SUPPORT
11142 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
11143 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
11144#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011145
Jeff Johnson295189b2012-06-20 16:38:30 -070011146#ifdef WLAN_FEATURE_VOWIFI_11R
11147 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
11148#endif
11149 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
11150 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
11151 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
11152#ifdef WLAN_FEATURE_PACKET_FILTERING
11153 ,
11154 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
11155#endif
11156#ifdef FEATURE_WLAN_SCAN_PNO
11157 ,
11158 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
11159#endif
11160 ,
11161 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
11162 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
11163 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
11164 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070011165 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070011166};
11167
11168/*Maximum command length can be only 15 */
11169static const struct iw_priv_args we_private_args[] = {
11170
Katya Nigamf0511f62015-05-05 16:40:57 +053011171 { WE_SET_MONITOR_STATE,
11172 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11173 0, "monitor" },
11174
Jeff Johnson295189b2012-06-20 16:38:30 -070011175 /* handlers for main ioctl */
11176 { WLAN_PRIV_SET_INT_GET_NONE,
11177 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11178 0,
11179 "" },
11180
11181 /* handlers for sub-ioctl */
11182 { WE_SET_11D_STATE,
11183 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11184 0,
11185 "set11Dstate" },
11186
11187 { WE_WOWL,
11188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11189 0,
11190 "wowl" },
11191
11192 { WE_SET_POWER,
11193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11194 0,
11195 "setPower" },
11196
11197 { WE_SET_MAX_ASSOC,
11198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11199 0,
11200 "setMaxAssoc" },
11201
11202 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
11203 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11204 0,
11205 "setAutoChannel" },
11206
11207 { WE_SET_DATA_INACTIVITY_TO,
11208 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11209 0,
11210 "inactivityTO" },
11211
11212 { WE_SET_MAX_TX_POWER,
11213 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11214 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070011215 "setMaxTxPower" },
11216
11217 { WE_SET_MAX_TX_POWER_2_4,
11218 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11219 0,
11220 "setTxMaxPower2G" },
11221
11222 { WE_SET_MAX_TX_POWER_5_0,
11223 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11224 0,
11225 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070011226
11227 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
11228 * as well to keep same syntax as in SAP. Now onwards, STA
11229 * will support both */
11230 { WE_SET_MAX_TX_POWER,
11231 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11232 0,
11233 "setTxMaxPower" },
11234
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 /* set Higher DTIM Transition (DTIM1 to DTIM3)
11236 * 1 = enable and 0 = disable */
11237 {
11238 WE_SET_HIGHER_DTIM_TRANSITION,
11239 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11240 0,
11241 "setHDtimTransn" },
11242
11243 { WE_SET_TM_LEVEL,
11244 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080011245 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 "setTmLevel" },
11247
Kiet Lam46b8e4e2013-11-06 21:49:53 +053011248 { WE_ENABLE_STRICT_FCC_REG,
11249 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11250 0,
11251 "setStrictFCCreg" },
11252
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011253 { WE_SET_DEBUG_LOG,
11254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11255 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053011256#ifdef FEATURE_WLAN_TDLS
11257 {
11258 WE_SET_TDLS_OFF_CHAN,
11259 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11260 0,
11261 "tdlsoffchan" },
11262 {
11263 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
11264 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11265 0,
11266 "tdlsecchnoffst" },
11267 {
11268 WE_SET_TDLS_OFF_CHAN_MODE,
11269 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11270 0,
11271 "tdlsoffchnmode" },
11272#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080011273
Peng Xu2446a892014-09-05 17:21:18 +053011274 { WE_SET_SCAN_BAND_PREFERENCE,
11275 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11276 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053011277 {
11278 WE_GET_FRAME_LOG,
11279 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11280 0,
11281 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053011282
Abhishek Singh01c73d12015-03-12 15:13:44 +053011283 { WE_SET_MIRACAST_VENDOR_CONFIG,
11284 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11285 0, "setMiracstConf" },
11286
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053011287#ifdef FEATURE_WLAN_TDLS
11288 {
11289 WE_SET_TDLS_2040_BSS_COEXISTENCE,
11290 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11291 0,
11292 "tdls_2040bsscox" },
11293#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053011294 { WE_SET_RTS_CTS_HTVHT,
11295 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11296 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053011297 { WE_SET_PKT_STATS_ENABLE_DISABLE,
11298 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11299 0, "setPktStats" },
Hanumantha Reddy Pothula519a1ea2015-12-09 14:06:03 +053011300 { WE_SET_PROXIMITY_ENABLE,
11301 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11302 0, "setProximity" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011303
11304#ifdef WLAN_FEATURE_TSF
11305 { WE_CAP_TSF,
11306 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11307 0, "cap_tsf" },
11308#endif
SaidiReddy Yenuga9c1a6142017-02-06 16:30:04 +053011309 { WE_SET_MODULATED_DTIM,
11310 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11311 0, "setModDTIM" },
SaidiReddy Yenugac341fbf2017-02-01 20:22:45 +053011312 {
11313 WLAN_SET_DYNNAMIC_AGGREGATION,
11314 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11315 0, "setAggregation" },
11316
Jeff Johnson295189b2012-06-20 16:38:30 -070011317 /* handlers for main ioctl */
11318 { WLAN_PRIV_SET_NONE_GET_INT,
11319 0,
11320 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11321 "" },
11322
11323 /* handlers for sub-ioctl */
11324 { WE_GET_11D_STATE,
11325 0,
11326 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11327 "get11Dstate" },
11328
11329 { WE_IBSS_STATUS,
11330 0,
11331 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11332 "getAdhocStatus" },
11333
11334 { WE_PMC_STATE,
11335 0,
11336 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11337 "pmcState" },
11338
11339 { WE_GET_WLAN_DBG,
11340 0,
11341 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11342 "getwlandbg" },
11343
Jeff Johnson295189b2012-06-20 16:38:30 -070011344 { WE_GET_MAX_ASSOC,
11345 0,
11346 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11347 "getMaxAssoc" },
11348
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 { WE_GET_WDI_DBG,
11350 0,
11351 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11352 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011353
11354 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11355 0,
11356 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11357 "getAutoChannel" },
11358
11359 { WE_GET_CONCURRENCY_MODE,
11360 0,
11361 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11362 "getconcurrency" },
11363
Peng Xu2446a892014-09-05 17:21:18 +053011364 { WE_GET_SCAN_BAND_PREFERENCE,
11365 0,
11366 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11367 "get_scan_pref"},
11368
Mahesh A Saptasagarb63b3e22015-12-22 15:06:10 +053011369 { WE_GET_ANTENA_DIVERSITY_SELECTION,
11370 0,
11371 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11372 "getCurAnt"},
11373
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 /* handlers for main ioctl */
11375 { WLAN_PRIV_SET_CHAR_GET_NONE,
11376 IW_PRIV_TYPE_CHAR| 512,
11377 0,
11378 "" },
11379
11380 /* handlers for sub-ioctl */
11381 { WE_WOWL_ADD_PTRN,
11382 IW_PRIV_TYPE_CHAR| 512,
11383 0,
11384 "wowlAddPtrn" },
11385
11386 { WE_WOWL_DEL_PTRN,
11387 IW_PRIV_TYPE_CHAR| 512,
11388 0,
11389 "wowlDelPtrn" },
11390
11391#if defined WLAN_FEATURE_VOWIFI
11392 /* handlers for sub-ioctl */
11393 { WE_NEIGHBOR_REPORT_REQUEST,
11394 IW_PRIV_TYPE_CHAR | 512,
11395 0,
11396 "neighbor" },
11397#endif
11398 { WE_SET_AP_WPS_IE,
11399 IW_PRIV_TYPE_CHAR| 512,
11400 0,
11401 "set_ap_wps_ie" },
11402
11403 { WE_SET_CONFIG,
11404 IW_PRIV_TYPE_CHAR| 512,
11405 0,
11406 "setConfig" },
11407
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053011408 { WE_SET_ENCRYPT_MSG,
11409 IW_PRIV_TYPE_CHAR| 512,
11410 0,
11411 "encryptMsg" },
11412
11413
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 /* handlers for main ioctl */
11415 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
11416 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11417 0,
11418 "" },
11419
11420 /* handlers for sub-ioctl */
11421 { WE_SET_WLAN_DBG,
11422 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11423 0,
11424 "setwlandbg" },
11425
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 { WE_SET_WDI_DBG,
11427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11428 0,
11429 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011430
11431 { WE_SET_SAP_CHANNELS,
11432 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11433 0,
11434 "setsapchannels" },
11435
11436 /* handlers for main ioctl */
11437 { WLAN_PRIV_GET_CHAR_SET_NONE,
11438 0,
11439 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11440 "" },
11441
11442 /* handlers for sub-ioctl */
11443 { WE_WLAN_VERSION,
11444 0,
11445 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11446 "version" },
11447 { WE_GET_STATS,
11448 0,
11449 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11450 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011451 { WE_GET_STATES,
11452 0,
11453 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11454 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 { WE_GET_CFG,
11456 0,
11457 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11458 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070011459#ifdef WLAN_FEATURE_11AC
11460 { WE_GET_RSSI,
11461 0,
11462 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11463 "getRSSI" },
11464#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011465#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080011466 { WE_GET_ROAM_RSSI,
11467 0,
11468 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11469 "getRoamRSSI" },
11470#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 { WE_GET_WMM_STATUS,
11472 0,
11473 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11474 "getWmmStatus" },
11475 {
11476 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053011477 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070011478 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11479 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080011480#ifdef FEATURE_WLAN_TDLS
11481 {
11482 WE_GET_TDLS_PEERS,
11483 0,
11484 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11485 "getTdlsPeers" },
11486#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070011487#ifdef WLAN_FEATURE_11W
11488 {
11489 WE_GET_11W_INFO,
11490 0,
11491 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11492 "getPMFInfo" },
11493#endif
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011494#ifdef WLAN_FEATURE_RMC
11495 {
11496 WE_GET_IBSS_STA_INFO,
11497 0,
11498 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11499 "getIbssSTAs" },
11500#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053011501 { WE_GET_SNR,
11502 0,
11503 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11504 "getSNR" },
Padma, Santhosh Kumar8dcdb702015-10-20 14:06:21 +053011505#ifdef FEATURE_OEM_DATA_SUPPORT
11506 {
11507 WE_GET_OEM_DATA_CAP,
11508 0,
11509 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11510 "getOemDataCap" },
11511#endif /* FEATURE_OEM_DATA_SUPPORT */
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 /* handlers for main ioctl */
11513 { WLAN_PRIV_SET_NONE_GET_NONE,
11514 0,
11515 0,
11516 "" },
11517
11518 /* handlers for sub-ioctl */
11519 { WE_CLEAR_STATS,
11520 0,
11521 0,
11522 "clearStats" },
11523 { WE_INIT_AP,
11524 0,
11525 0,
11526 "initAP" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011527#ifdef WLAN_FEATURE_RMC
11528 {
11529 WE_IBSS_GET_PEER_INFO_ALL,
11530 0,
11531 0,
11532 "ibssPeerInfoAll" },
11533#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 { WE_STOP_AP,
11535 0,
11536 0,
11537 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011538#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070011539 { WE_ENABLE_AMP,
11540 0,
11541 0,
11542 "enableAMP" },
11543 { WE_DISABLE_AMP,
11544 0,
11545 0,
11546 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053011547#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070011548 { WE_ENABLE_DXE_STALL_DETECT,
11549 0,
11550 0,
11551 "dxeStallDetect" },
11552 { WE_DISPLAY_DXE_SNAP_SHOT,
11553 0,
11554 0,
11555 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053011556 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
11557 0,
11558 0,
11559 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070011560 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053011561 WE_SET_REASSOC_TRIGGER,
11562 0,
11563 0,
11564 "reassoc" },
11565 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053011566 WE_STOP_OBSS_SCAN,
11567 0,
11568 0,
11569 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053011570 {
11571 WE_DUMP_ROAM_TIMER_LOG,
11572 0,
11573 0,
11574 "dumpRoamDelay" },
11575 {
11576 WE_RESET_ROAM_TIMER_LOG,
11577 0,
11578 0,
11579 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011580 {
11581 WE_GET_FW_LOGS,
11582 0,
11583 0,
11584 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053011585 {
11586 WE_GET_FW_MEMDUMP,
11587 0,
11588 0,
11589 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011590 /* handlers for main ioctl */
11591 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
11592 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11593 0,
11594 "" },
11595
Sachin Ahuja715aafc2015-07-21 23:35:10 +053011596
11597
Jeff Johnson295189b2012-06-20 16:38:30 -070011598 /* handlers for sub-ioctl */
11599 { WE_LOG_DUMP_CMD,
11600 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11601 0,
11602 "dump" },
Abhishek Singh7cd040e2016-01-07 10:51:04 +053011603#ifdef WLAN_FEATURE_RMC
11604 { WE_IBSS_GET_PEER_INFO,
11605 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11606 0,
11607 "ibssPeerInfo" },
11608#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011609
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011610 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053011611 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11612 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11613 0,
11614 "setdumplog" },
11615
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070011616 { WE_MTRACE_DUMP_CMD,
11617 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11618 0,
11619 "dumplog" },
11620
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011621 /* handlers for sub ioctl */
11622 {
11623 WE_MCC_CONFIG_CREDENTIAL,
11624 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11625 0,
11626 "setMccCrdnl" },
11627
11628 /* handlers for sub ioctl */
11629 {
11630 WE_MCC_CONFIG_PARAMS,
11631 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11632 0,
11633 "setMccConfig" },
11634
Chilam NG571c65a2013-01-19 12:27:36 +053011635#ifdef FEATURE_WLAN_TDLS
11636 /* handlers for sub ioctl */
11637 {
11638 WE_TDLS_CONFIG_PARAMS,
11639 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11640 0,
11641 "setTdlsConfig" },
11642#endif
11643
Katya Nigamf0511f62015-05-05 16:40:57 +053011644 {
11645 WE_CONFIGURE_MONITOR_MODE,
11646 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11647 0,
11648 "MonitorModeConf" },
11649
11650 {
11651 WE_SET_MONITOR_MODE_FILTER,
11652 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11653 0,
11654 "MonitorFilter" },
11655
Jeff Johnson295189b2012-06-20 16:38:30 -070011656 /* handlers for main ioctl */
11657 { WLAN_PRIV_ADD_TSPEC,
11658 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11659 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11660 "addTspec" },
11661
11662 /* handlers for main ioctl */
11663 { WLAN_PRIV_DEL_TSPEC,
11664 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11665 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11666 "delTspec" },
11667
11668 /* handlers for main ioctl */
11669 { WLAN_PRIV_GET_TSPEC,
11670 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11671 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11672 "getTspec" },
Manjeet Singh3ed79242017-01-11 19:04:32 +053011673 /* handlers for main ioctl */
11674 { WLAN_PRIV_SET_NONE_GET_THREE_INT,
11675 0,
11676 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11677 "" },
11678#ifdef WLAN_FEATURE_TSF
11679 { WE_GET_TSF,
11680 0,
11681 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11682 "get_tsf" },
11683#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070011684#ifdef FEATURE_OEM_DATA_SUPPORT
11685 /* handlers for main ioctl - OEM DATA */
11686 {
11687 WLAN_PRIV_SET_OEM_DATA_REQ,
11688 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
11689 0,
11690 "set_oem_data_req" },
11691
11692 /* handlers for main ioctl - OEM DATA */
11693 {
11694 WLAN_PRIV_GET_OEM_DATA_RSP,
11695 0,
11696 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
11697 "get_oem_data_rsp" },
11698#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011699
Jeff Johnson295189b2012-06-20 16:38:30 -070011700 /* handlers for main ioctl - host offload */
11701 {
11702 WLAN_PRIV_SET_HOST_OFFLOAD,
11703 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11704 0,
11705 "setHostOffload" },
11706
11707 {
11708 WLAN_GET_WLAN_STATISTICS,
11709 0,
11710 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11711 "getWlanStats" },
11712
11713 {
11714 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagarf18c62b2016-02-10 16:03:48 +053011715 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest) |
11716 IW_PRIV_SIZE_FIXED,
Jeff Johnson295189b2012-06-20 16:38:30 -070011717 0,
11718 "setKeepAlive" },
11719#ifdef WLAN_FEATURE_PACKET_FILTERING
11720 {
11721 WLAN_SET_PACKET_FILTER_PARAMS,
11722 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
11723 0,
11724 "setPktFilter" },
11725#endif
11726#ifdef FEATURE_WLAN_SCAN_PNO
11727 {
11728 WLAN_SET_PNO,
11729 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11730 0,
11731 "setpno" },
11732#endif
11733 {
11734 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053011735 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070011736 0,
11737 "SETBAND" },
11738 /* handlers for dynamic MC BC ioctl */
11739 {
11740 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080011741 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 0,
11743 "setMCBCFilter" },
11744 {
11745 WLAN_PRIV_CLEAR_MCBC_FILTER,
11746 0,
11747 0,
11748 "clearMCBCFilter" },
11749 {
11750 WLAN_SET_POWER_PARAMS,
11751 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
11752 0,
11753 "setpowerparams" },
11754 {
11755 WLAN_GET_LINK_SPEED,
11756 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053011757 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070011758};
11759
11760
11761
11762const struct iw_handler_def we_handler_def = {
11763 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
11764 .num_private = sizeof(we_private) / sizeof(we_private[0]),
11765 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
11766
11767 .standard = (iw_handler *)we_handler,
11768 .private = (iw_handler *)we_private,
11769 .private_args = we_private_args,
11770 .get_wireless_stats = get_wireless_stats,
11771};
11772
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011773int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
11774{
11775 v_U32_t cmd = 288; //Command to RIVA
11776 hdd_context_t *pHddCtx = NULL;
11777 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11778 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11779 /*
11780 *configMccParam : specify the bit which needs to be modified
11781 *allowed to update based on wlan_qcom_cfg.ini
11782 * configuration
11783 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
11784 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
11785 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
11786 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
11787 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
11788 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
11789 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
11790 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
11791 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
11792 * Bit 9 : Reserved
11793 */
11794 switch (arg1)
11795 {
11796 //Update MCC SCHEDULE_TIME_SLICE parameter
11797 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
11798 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
11799 {
11800 if((arg2 >= 5) && (arg2 <= 20))
11801 {
11802 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11803 }
11804 else
11805 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011806 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011807 return 0;
11808 }
11809 }
11810 break;
11811
11812 //Update MCC MAX_NULL_SEND_TIME parameter
11813 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
11814 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
11815 {
11816 if((arg2 >= 1) && (arg2 <= 10))
11817 {
11818 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11819 }
11820 else
11821 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011822 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011823 return 0;
11824 }
11825 }
11826 break;
11827
11828 //Update MCC TX_EARLY_STOP_TIME parameter
11829 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
11830 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
11831 {
11832 if((arg2 >= 1) && (arg2 <= 10))
11833 {
11834 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11835 }
11836 else
11837 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011838 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011839 return 0;
11840 }
11841 }
11842 break;
11843
11844 //Update MCC RX_DRAIN_TIME parameter
11845 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11846 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11847 {
11848 if((arg2 >= 1) && (arg2 <= 10))
11849 {
11850 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11851 }
11852 else
11853 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011854 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011855 return 0;
11856 }
11857 }
11858 break;
11859
11860 //Update MCC CHANNEL_SWITCH_TIME parameter
11861 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11862 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11863 {
11864 if((arg2 >= 1) && (arg2 <= 20))
11865 {
11866 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11867 }
11868 else
11869 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011870 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011871 return 0;
11872 }
11873 }
11874 break;
11875
11876 //Update MCC MIN_CHANNEL_TIME parameter
11877 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11878 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11879 {
11880 if((arg2 >= 5) && (arg2 <= 20))
11881 {
11882 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11883 }
11884 else
11885 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011886 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011887 return 0;
11888 }
11889 }
11890 break;
11891
11892 //Update MCC PARK_BEFORE_TBTT parameter
11893 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11894 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11895 {
11896 if((arg2 >= 1) && (arg2 <= 5))
11897 {
11898 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11899 }
11900 else
11901 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011902 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011903 return 0;
11904 }
11905 }
11906 break;
11907
11908 //Update MCC MIN_AFTER_DTIM parameter
11909 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11910 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11911 {
11912 if((arg2 >= 5) && (arg2 <= 15))
11913 {
11914 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11915 }
11916 else
11917 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011918 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011919 return 0;
11920 }
11921 }
11922 break;
11923
11924 //Update MCC TOO_CLOSE_MARGIN parameter
11925 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11926 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11927 {
11928 if((arg2 >= 1) && (arg2 <= 3))
11929 {
11930 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11931 }
11932 else
11933 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011934 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011935 return 0;
11936 }
11937 }
11938 break;
11939
11940 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011941 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011942 __FUNCTION__,arg1);
11943 break;
11944 }
11945 return 0;
11946}
11947
Jeff Johnson295189b2012-06-20 16:38:30 -070011948int hdd_set_wext(hdd_adapter_t *pAdapter)
11949{
11950 hdd_wext_state_t *pwextBuf;
11951 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011952 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011953
11954 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11955
11956 // Now configure the roaming profile links. To SSID and bssid.
11957 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11958 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11959
11960 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11961 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11962
11963 /*Set the numOfChannels to zero to scan all the channels*/
11964 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11965 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11966
11967 /* Default is no encryption */
11968 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11969 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11970
11971 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11972 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11973
11974 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11975
11976 /* Default is no authentication */
11977 pwextBuf->roamProfile.AuthType.numEntries = 1;
11978 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11979
11980 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11981 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11982
11983 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011984 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011985
11986 hdd_clearRoamProfileIe(pAdapter);
11987
11988 return VOS_STATUS_SUCCESS;
11989
11990 }
11991
11992int hdd_register_wext(struct net_device *dev)
11993 {
11994 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11995 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11996 VOS_STATUS status;
11997
11998 ENTER();
11999
12000 // Zero the memory. This zeros the profile structure.
12001 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
12002
12003 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
12004
12005
12006 status = hdd_set_wext(pAdapter);
12007
12008 if(!VOS_IS_STATUS_SUCCESS(status)) {
12009
Arif Hussain6d2a3322013-11-17 19:50:10 -080012010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012011 return eHAL_STATUS_FAILURE;
12012 }
12013
12014 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
12015 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012017 return eHAL_STATUS_FAILURE;
12018 }
12019
12020 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
12021 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012023 return eHAL_STATUS_FAILURE;
12024 }
12025
12026 // Register as a wireless device
12027 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
12028
12029 EXIT();
12030 return 0;
12031}
12032
12033int hdd_UnregisterWext(struct net_device *dev)
12034{
c_hpothu2a13bc32015-01-21 12:48:54 +053012035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
12036 if (dev != NULL)
12037 {
12038 rtnl_lock();
12039 dev->wireless_handlers = NULL;
12040 rtnl_unlock();
12041 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053012042
Jeff Johnson295189b2012-06-20 16:38:30 -070012043 return 0;
12044}
12045
12046