blob: 923ebb0b4fbd042e5ef2d512208fcae77ba9b103 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
c_hpothu002231a2015-02-05 14:58:51 +05302 * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Anand N Sunkad0a3436f2015-05-01 14:22:19 +053053#include <linux/wcnss_wlan.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053054#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <wlan_hdd_includes.h>
56#include <wlan_btc_svc.h>
57#include <wlan_nlink_common.h>
58#ifdef WLAN_BTAMP_FEATURE
59#include <bap_hdd_main.h>
60#endif
61#include <vos_api.h>
62#include <net/arp.h>
63#include "ccmApi.h"
64#include "sirParams.h"
65#include "csrApi.h"
66#include "csrInsideApi.h"
67#if defined WLAN_FEATURE_VOWIFI
68#include "smeRrmInternal.h"
69#endif
70#include <aniGlobal.h>
71#include "dot11f.h"
72#include <wlan_hdd_wowl.h>
73#include <wlan_hdd_cfg.h>
74#include <wlan_hdd_wmm.h>
75#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef CONFIG_HAS_EARLYSUSPEND
82#include <linux/earlysuspend.h>
83#endif
84#include "wlan_hdd_power.h"
85#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530107#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530108
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#ifdef CONFIG_HAS_EARLYSUSPEND
110extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
111extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
112#endif
113
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800115#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530119#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
Atul Mittalc0f739f2014-07-31 13:47:47 +0530122// tdlsoffchan
123#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530124static int tdlsOffCh = 1;
125static int tdlsOffChBwOffset = 0;
126#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530127
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700128static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/* To Validate Channel against the Frequency and Vice-Versa */
132static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
133 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
134 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
135 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
136 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
137 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
138 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
139 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800140 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
141 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700142
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800143#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700144
145/* Private ioctls and their sub-ioctls */
146#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
147#define WE_SET_11D_STATE 1
148#define WE_WOWL 2
149#define WE_SET_POWER 3
150#define WE_SET_MAX_ASSOC 4
151#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
152#define WE_SET_DATA_INACTIVITY_TO 6
153#define WE_SET_MAX_TX_POWER 7
154#define WE_SET_HIGHER_DTIM_TRANSITION 8
155#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530156#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700157#define WE_SET_MAX_TX_POWER_2_4 11
158#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800159/* Private IOCTL for debug connection issues */
160#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530161// tdlsoffchan
162#ifdef FEATURE_WLAN_TDLS
163#define WE_SET_TDLS_OFF_CHAN 14
164#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
165#define WE_SET_TDLS_OFF_CHAN_MODE 16
166#endif
Peng Xu2446a892014-09-05 17:21:18 +0530167#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530168#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530169#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530170#ifdef FEATURE_WLAN_TDLS
171#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
172#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530173#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530174#define WE_SET_MONITOR_STATE 22
Sushant Kaushik33200572015-08-05 16:46:20 +0530175#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Jeff Johnson295189b2012-06-20 16:38:30 -0700176
177/* Private ioctls and their sub-ioctls */
178#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
179#define WE_GET_11D_STATE 1
180#define WE_IBSS_STATUS 2
181#define WE_PMC_STATE 3
182#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700183#define WE_GET_MAX_ASSOC 6
184#define WE_GET_WDI_DBG 7
185#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
186#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530187#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700188/* Private ioctls and their sub-ioctls */
189#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
190
191/* Private ioctls and their sub-ioctls */
192#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
193#define WE_WOWL_ADD_PTRN 1
194#define WE_WOWL_DEL_PTRN 2
195#if defined WLAN_FEATURE_VOWIFI
196#define WE_NEIGHBOR_REPORT_REQUEST 3
197#endif
198#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
199#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530200#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
202/* Private ioctls and their sub-ioctls */
203#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
204#define WE_SET_WLAN_DBG 1
205#define WE_SET_WDI_DBG 2
206#define WE_SET_SAP_CHANNELS 3
207
208/* Private ioctls and their sub-ioctls */
209#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
210#define WE_WLAN_VERSION 1
211#define WE_GET_STATS 2
212#define WE_GET_CFG 3
213#define WE_GET_WMM_STATUS 4
214#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700215#ifdef WLAN_FEATURE_11AC
216#define WE_GET_RSSI 6
217#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800218#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800219#ifdef FEATURE_WLAN_TDLS
220#define WE_GET_TDLS_PEERS 8
221#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700222#ifdef WLAN_FEATURE_11W
223#define WE_GET_11W_INFO 9
224#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530225#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530226#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700227
228/* Private ioctls and their sub-ioctls */
229#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
230#define WE_CLEAR_STATS 1
231#define WE_INIT_AP 2
232#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530233#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700234#define WE_ENABLE_AMP 4
235#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530236#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700237#define WE_ENABLE_DXE_STALL_DETECT 6
238#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700239#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530240#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530241#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530242#define WE_DUMP_ROAM_TIMER_LOG 12
243#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530244#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530245#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530246
Jeff Johnson295189b2012-06-20 16:38:30 -0700247/* Private ioctls and their sub-ioctls */
248#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
249#define WE_LOG_DUMP_CMD 1
250
Jeff Johnson295189b2012-06-20 16:38:30 -0700251#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800252//IOCTL to configure MCC params
253#define WE_MCC_CONFIG_CREDENTIAL 3
254#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700255
Chilam NG571c65a2013-01-19 12:27:36 +0530256#ifdef FEATURE_WLAN_TDLS
257#define WE_TDLS_CONFIG_PARAMS 5
258#endif
259
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700260#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530261#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530262#define WE_CONFIGURE_MONITOR_MODE 10
263#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700264
Chilam Ng01120412013-02-19 18:32:21 -0800265#ifdef FEATURE_WLAN_TDLS
266#undef MAX_VAR_ARGS
267#define MAX_VAR_ARGS 10
268#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700269#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800270#endif
271
Jeff Johnson295189b2012-06-20 16:38:30 -0700272/* Private ioctls (with no sub-ioctls) */
273/* note that they must be odd so that they have "get" semantics */
274#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
275#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
276#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
277
Girish Gowli464c9c82014-06-09 19:47:53 +0530278/* (SIOCIWFIRSTPRIV + 8) is currently unused */
279/* (SIOCIWFIRSTPRIV + 16) is currently unused */
280/* (SIOCIWFIRSTPRIV + 10) is currently unused */
281/* (SIOCIWFIRSTPRIV + 12) is currently unused */
282/* (SIOCIWFIRSTPRIV + 14) is currently unused */
283/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
Jeff Johnsone7245742012-09-05 17:12:55 -0700285#ifdef FEATURE_OEM_DATA_SUPPORT
286/* Private ioctls for setting the measurement configuration */
287#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
288#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700290
291#ifdef WLAN_FEATURE_VOWIFI_11R
292#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
293#endif
294
295/* Private ioctl for setting the host offload feature */
296#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
297
298/* Private ioctl to get the statistics */
299#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
300
301/* Private ioctl to set the Keep Alive Params */
302#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
303#ifdef WLAN_FEATURE_PACKET_FILTERING
304/* Private ioctl to set the Packet Filtering Params */
305#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
306#endif
307
308#ifdef FEATURE_WLAN_SCAN_PNO
309/* Private ioctl to get the statistics */
310#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
311#endif
312
313#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
314
315#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
316#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700317/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700318
Jeff Johnson295189b2012-06-20 16:38:30 -0700319#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
320#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
321
322#define WLAN_STATS_INVALID 0
323#define WLAN_STATS_RETRY_CNT 1
324#define WLAN_STATS_MUL_RETRY_CNT 2
325#define WLAN_STATS_TX_FRM_CNT 3
326#define WLAN_STATS_RX_FRM_CNT 4
327#define WLAN_STATS_FRM_DUP_CNT 5
328#define WLAN_STATS_FAIL_CNT 6
329#define WLAN_STATS_RTS_FAIL_CNT 7
330#define WLAN_STATS_ACK_FAIL_CNT 8
331#define WLAN_STATS_RTS_SUC_CNT 9
332#define WLAN_STATS_RX_DISCARD_CNT 10
333#define WLAN_STATS_RX_ERROR_CNT 11
334#define WLAN_STATS_TX_BYTE_CNT 12
335
336#define WLAN_STATS_RX_BYTE_CNT 13
337#define WLAN_STATS_RX_RATE 14
338#define WLAN_STATS_TX_RATE 15
339
Jeff Johnsone7245742012-09-05 17:12:55 -0700340#define WLAN_STATS_RX_UC_BYTE_CNT 16
341#define WLAN_STATS_RX_MC_BYTE_CNT 17
342#define WLAN_STATS_RX_BC_BYTE_CNT 18
343#define WLAN_STATS_TX_UC_BYTE_CNT 19
344#define WLAN_STATS_TX_MC_BYTE_CNT 20
345#define WLAN_STATS_TX_BC_BYTE_CNT 21
346
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800347#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
348 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
349 { \
350 *__p++ = __type; \
351 *__p++ = __size; \
352 memcpy(__p, __val, __size); \
353 __p += __size; \
354 __tlen += __size + 2; \
355 } \
356 else \
357 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800358 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800359 } \
360 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700361
362#define VERSION_VALUE_MAX_LEN 32
363
364#define TX_PER_TRACKING_DEFAULT_RATIO 5
365#define TX_PER_TRACKING_MAX_RATIO 10
366#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
367
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530368#define WLAN_ADAPTER 0
369#define P2P_ADAPTER 1
370
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530371/*
372 * When supplicant sends SETBAND ioctl it queries for channels from
373 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
374 * This is not required if the return type from ioctl is
375 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
376 * event as part of regulatory_hint.
377 */
378enum {
379 SEND_CHANNEL_CHANGE_EVENT = 0,
380 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
381};
382
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800383/*MCC Configuration parameters */
384enum {
385 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
386 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
387 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
388 MCC_RX_DRAIN_TIME_CFG_PARAM,
389 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
390 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
391 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
392 MCC_MIN_AFTER_DTIM_CFG_PARAM,
393 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
394};
395
396int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
397 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
398
Jeff Johnson295189b2012-06-20 16:38:30 -0700399#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800400int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700401 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700402#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530403static int get_fwr_memdump(struct net_device *,
404 struct iw_request_info *,
405 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700406/**---------------------------------------------------------------------------
407
Arif Hussain0273cba2014-01-07 20:58:29 -0800408 \brief mem_alloc_copy_from_user_helper -
409
410 Helper function to allocate buffer and copy user data.
411
412 \param - wrqu - Pointer to IOCTL Data.
413 len - size
414
415 \return - On Success pointer to buffer, On failure NULL
416
417 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530418void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800419{
420 u8 *ptr = NULL;
421
422 /* in order to protect the code, an extra byte is post appended to the buffer
423 * and the null termination is added. However, when allocating (len+1) byte
424 * of memory, we need to make sure that there is no uint overflow when doing
425 * addition. In theory check len < UINT_MAX protects the uint overflow. For
426 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
427 * guess, now, it is assumed that the private command buffer size is no
428 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
429 */
430 if (len > MAX_USER_COMMAND_SIZE)
431 {
432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
433 "Invalid length");
434 return NULL;
435 }
436
437 ptr = kmalloc(len + 1, GFP_KERNEL);
438 if (NULL == ptr)
439 {
440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
441 "unable to allocate memory");
442 return NULL;
443 }
444
445 if (copy_from_user(ptr, wrqu_data, len))
446 {
447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
448 "%s: failed to copy data to user buffer", __func__);
449 kfree(ptr);
450 return NULL;
451 }
452 ptr[len] = '\0';
453 return ptr;
454}
455
Girish Gowli488ef492014-06-12 18:44:33 +0530456// Function to handle and get compatible struct iw_point passed to ioctl.
457int hdd_priv_get_data(struct iw_point *p_priv_data,
458 union iwreq_data *wrqu)
459{
460 if ((NULL == p_priv_data) || (NULL == wrqu))
461 {
462 return -EINVAL;
463 }
464
465#ifdef CONFIG_COMPAT
466 if (is_compat_task())
467 {
468 struct compat_iw_point *p_compat_priv_data;
469
470 // Compat task: typecast to campat structure and copy the members.
471 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
472
473 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
474 p_priv_data->length = p_compat_priv_data->length;
475 p_priv_data->flags = p_compat_priv_data->flags;
476 }//if(is_compat_task())
477 else
478 {
479#endif //#ifdef CONFIG_COMPAT
480
481 // Non compat task: directly copy the structure.
482 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
483
484#ifdef CONFIG_COMPAT
485 }//else of - if(is_compat_task())
486#endif //#ifdef CONFIG_COMPAT
487
488 return 0;
489}
490
Arif Hussain0273cba2014-01-07 20:58:29 -0800491/**---------------------------------------------------------------------------
492
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 \brief hdd_wlan_get_version() -
494
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800495 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700496
497 \param - pAdapter Pointer to the adapter.
498 wrqu - Pointer to IOCTL REQUEST Data.
499 extra - Pointer to char
500
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800501 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700502
503 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800504void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
505 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700506{
507 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800508 tSirVersionString wcnss_SW_version;
509 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530510 tSirVersionString iris_name;
511 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800512 char *pSWversion;
513 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800516 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
517 sizeof(wcnss_SW_version));
518 if (VOS_IS_STATUS_SUCCESS(status))
519 {
520 pSWversion = wcnss_SW_version;
521 }
522 else
523 {
524 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 }
526
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800527 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
528 sizeof(wcnss_HW_version));
529 if (VOS_IS_STATUS_SUCCESS(status))
530 {
531 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800533 else
534 {
535 pHWversion = "Unknown";
536 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700537
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530538 status = wcnss_get_iris_name(iris_name);
539
540 if (!status) {
541 pIRISversion = iris_name;
542 } else {
543 pIRISversion = "Unknown";
544 }
545
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700546 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530547 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800548 QWLAN_VERSIONSTR,
549 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530550 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800551
552 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700553}
554
Jeff Johnson295189b2012-06-20 16:38:30 -0700555int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
556{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530557 tHalHandle hHal;
558 hdd_context_t *pHddCtx;
559 v_U32_t threshold = 0;
560 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700561
562 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530563 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530564 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
566 "%s: Adapter is NULL",__func__);
567 return -EINVAL;
568 }
569
570 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
571 ret = wlan_hdd_validate_context(pHddCtx);
572 if (0 != ret)
573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530574 return ret;
575 }
576
577 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
578 if (NULL == hHal)
579 {
580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
581 "%s: Hal Context is NULL",__func__);
582 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 }
584
585 if ( eHAL_STATUS_SUCCESS !=
586 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
587 {
c_hpothub8245442013-11-20 23:41:09 +0530588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
589 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700590 return -EIO;
591 }
592 wrqu->rts.value = threshold;
593
594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800595 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700596
597 EXIT();
598
599 return 0;
600}
601
602int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
603{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530604 tHalHandle hHal;
605 hdd_context_t *pHddCtx;
606 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700607
608 ENTER();
609
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530610 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530611 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
613 "%s: Adapter is NULL",__func__);
614 return -EINVAL;
615 }
616
617 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
618 status = wlan_hdd_validate_context(pHddCtx);
619 if (0 != status)
620 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530621 return status;
622 }
623
624 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
625 if (NULL == hHal)
626 {
627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
628 "%s: Hal Context is NULL",__func__);
629 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 }
631
632 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
633 != eHAL_STATUS_SUCCESS )
634 {
c_hpothub8245442013-11-20 23:41:09 +0530635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
636 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 return -EIO;
638 }
639 wrqu->frag.value = threshold;
640
641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800642 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700643
644 EXIT();
645
646 return 0;
647}
648
649int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
650{
Jeff Johnsone7245742012-09-05 17:12:55 -0700651 int i;
652 if (channel > 0)
653 {
654 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
655 {
656 if (channel == freq_chan_map[i].chan)
657 {
658 *pfreq = freq_chan_map[i].freq;
659 return 1;
660 }
661 }
662 }
663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800664 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700665 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700666}
667
668static v_BOOL_t
669hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
670{
671 v_BOOL_t rsnType = VOS_FALSE;
672 // is the authType supported?
673 switch (authType)
674 {
675 case eCSR_AUTH_TYPE_NONE: //never used
676 rsnType = eANI_BOOLEAN_FALSE;
677 break;
678 // MAC layer authentication types
679 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
680 rsnType = eANI_BOOLEAN_FALSE;
681 break;
682 case eCSR_AUTH_TYPE_SHARED_KEY:
683 rsnType = eANI_BOOLEAN_FALSE;
684 break;
685 case eCSR_AUTH_TYPE_AUTOSWITCH:
686 rsnType = eANI_BOOLEAN_FALSE;
687 break;
688
689 // Upper layer authentication types
690 case eCSR_AUTH_TYPE_WPA:
691 rsnType = eANI_BOOLEAN_TRUE;
692 break;
693 case eCSR_AUTH_TYPE_WPA_PSK:
694 rsnType = eANI_BOOLEAN_TRUE;
695 break;
696 case eCSR_AUTH_TYPE_WPA_NONE:
697 rsnType = eANI_BOOLEAN_TRUE;
698 break;
699#ifdef WLAN_FEATURE_VOWIFI_11R
700 case eCSR_AUTH_TYPE_FT_RSN:
701#endif
702 case eCSR_AUTH_TYPE_RSN:
703 rsnType = eANI_BOOLEAN_TRUE;
704 break;
705#ifdef WLAN_FEATURE_VOWIFI_11R
706 case eCSR_AUTH_TYPE_FT_RSN_PSK:
707#endif
708 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700709#ifdef WLAN_FEATURE_11W
710 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530711 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700712#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 rsnType = eANI_BOOLEAN_TRUE;
714 break;
715 //case eCSR_AUTH_TYPE_FAILED:
716 case eCSR_AUTH_TYPE_UNKNOWN:
717 rsnType = eANI_BOOLEAN_FALSE;
718 break;
719 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800720 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
721 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 rsnType = eANI_BOOLEAN_FALSE;
723 break;
724 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800725 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700726 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 return rsnType;
728}
729
730static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
731{
732 struct statsContext *pStatsContext;
733 hdd_adapter_t *pAdapter;
734
735 if (ioctl_debug)
736 {
737 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700738 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 }
740
741 if (NULL == pContext)
742 {
743 hddLog(VOS_TRACE_LEVEL_ERROR,
744 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700745 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 return;
747 }
748
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 pStatsContext = pContext;
750 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800751
752 /* there is a race condition that exists between this callback
753 function and the caller since the caller could time out either
754 before or while this code is executing. we use a spinlock to
755 serialize these actions */
756 spin_lock(&hdd_context_lock);
757
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
759 {
760 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800761 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 hddLog(VOS_TRACE_LEVEL_WARN,
763 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700764 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 if (ioctl_debug)
766 {
767 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700768 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 }
770 return;
771 }
772
Jeff Johnson72a40512013-12-19 10:14:15 -0800773 /* context is valid so caller is still waiting */
774
775 /* paranoia: invalidate the magic */
776 pStatsContext->magic = 0;
777
Sachin Ahujaa082b672015-10-05 19:51:31 +0530778 /* copy over the rssi.FW will return RSSI as -100
779 * if there are no samples to calculate the average
780 * RSSI
781 */
782 if (rssi != -100)
783 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530784 if (pAdapter->rssi > 0)
785 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800786 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800788
789 /* serialization is complete */
790 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700791}
792
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530793static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
794{
795 struct statsContext *pStatsContext;
796 hdd_adapter_t *pAdapter;
797
798 if (ioctl_debug)
799 {
800 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
801 __func__, (int)snr, (int)staId, pContext);
802 }
803
804 if (NULL == pContext)
805 {
806 hddLog(VOS_TRACE_LEVEL_ERROR,
807 "%s: Bad param, pContext [%p]",
808 __func__, pContext);
809 return;
810 }
811
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530812 pStatsContext = pContext;
813 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800814
815 /* there is a race condition that exists between this callback
816 function and the caller since the caller could time out either
817 before or while this code is executing. we use a spinlock to
818 serialize these actions */
819 spin_lock(&hdd_context_lock);
820
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530821 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
822 {
823 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800824 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530825 hddLog(VOS_TRACE_LEVEL_WARN,
826 "%s: Invalid context, pAdapter [%p] magic [%08x]",
827 __func__, pAdapter, pStatsContext->magic);
828 if (ioctl_debug)
829 {
830 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
831 __func__, pAdapter, pStatsContext->magic);
832 }
833 return;
834 }
835
Jeff Johnson72a40512013-12-19 10:14:15 -0800836 /* context is valid so caller is still waiting */
837
838 /* paranoia: invalidate the magic */
839 pStatsContext->magic = 0;
840
841 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530842 pAdapter->snr = snr;
843
Jeff Johnson72a40512013-12-19 10:14:15 -0800844 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530845 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800846
847 /* serialization is complete */
848 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530849}
850
Jeff Johnson295189b2012-06-20 16:38:30 -0700851VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
852{
853 struct statsContext context;
854 hdd_context_t *pHddCtx;
855 hdd_station_ctx_t *pHddStaCtx;
856 eHalStatus hstatus;
857 long lrc;
858
859 if (NULL == pAdapter)
860 {
861 hddLog(VOS_TRACE_LEVEL_WARN,
862 "%s: Invalid context, pAdapter", __func__);
863 return VOS_STATUS_E_FAULT;
864 }
865 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
866 {
867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
868 /* return a cached value */
869 *rssi_value = pAdapter->rssi;
870 return VOS_STATUS_SUCCESS;
871 }
872
873 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
874 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
875
mukul sharma8aec69b2015-06-10 22:28:43 +0530876 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
877 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
879 __func__, pAdapter->rssi_on_disconnect);
880 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +0530881 return VOS_STATUS_SUCCESS;
882 }
883
884 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
885 {
886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
887 "%s: Roaming in progress, hence return last cached RSSI", __func__);
888 *rssi_value = pAdapter->rssi;
889 return VOS_STATUS_SUCCESS;
890 }
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 init_completion(&context.completion);
893 context.pAdapter = pAdapter;
894 context.magic = RSSI_CONTEXT_MAGIC;
895
896 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
897 pHddStaCtx->conn_info.staId[ 0 ],
898 pHddStaCtx->conn_info.bssId,
899 &context, pHddCtx->pvosContext);
900 if (eHAL_STATUS_SUCCESS != hstatus)
901 {
902 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700903 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 /* we'll returned a cached value below */
905 }
906 else
907 {
908 /* request was sent -- wait for the response */
909 lrc = wait_for_completion_interruptible_timeout(&context.completion,
910 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 if (lrc <= 0)
912 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700914 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 /* we'll now returned a cached value below */
916 }
917 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800918
919 /* either we never sent a request, we sent a request and received a
920 response or we sent a request and timed out. if we never sent a
921 request or if we sent a request and got a response, we want to
922 clear the magic out of paranoia. if we timed out there is a
923 race condition such that the callback function could be
924 executing at the same time we are. of primary concern is if the
925 callback function had already verified the "magic" but had not
926 yet set the completion variable when a timeout occurred. we
927 serialize these activities by invalidating the magic while
928 holding a shared spinlock which will cause us to block if the
929 callback is currently executing */
930 spin_lock(&hdd_context_lock);
931 context.magic = 0;
932 spin_unlock(&hdd_context_lock);
933
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 *rssi_value = pAdapter->rssi;
935
936 return VOS_STATUS_SUCCESS;
937}
Siddharth Bhal64246172015-02-27 01:04:37 +0530938/**---------------------------------------------------------------------------
939
940 \brief wlan_hdd_get_frame_logs() -
941
942 This function use to get Frames log.
943
944 \param - pAdapter Pointer to the adapter.
945 flag - Specify type of request. Clear and Send request are
946 supported.
947
948 \return - none
949
950 --------------------------------------------------------------------------*/
951VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
952{
Siddharth Bhal64246172015-02-27 01:04:37 +0530953 hdd_context_t *pHddCtx;
954 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +0530955
956 if (NULL == pAdapter)
957 {
958 hddLog(VOS_TRACE_LEVEL_WARN,
959 "%s: Invalid context, pAdapter", __func__);
960 return VOS_STATUS_E_FAULT;
961 }
962
963 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
964 if (!pHddCtx->mgmt_frame_logging)
965 {
966 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
967 return VOS_STATUS_E_AGAIN;
968 }
969
Siddharth Bhal4507c262015-04-29 20:20:42 +0530970 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
971 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
972 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +0530973 {
974 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
975 return VOS_STATUS_E_INVAL;
976 }
977
Siddharth Bhal4507c262015-04-29 20:20:42 +0530978 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
979 (!pHddCtx->cfg_ini->enableBMUHWtracing))
980 {
981 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
982 return VOS_STATUS_E_INVAL;
983 }
984
Abhishek Singh611295e2015-07-09 11:11:54 +0530985 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +0530986 if (eHAL_STATUS_SUCCESS != hstatus)
987 {
988 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +0530989 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +0530990 }
Siddharth Bhal64246172015-02-27 01:04:37 +0530991
992 return VOS_STATUS_SUCCESS;
993}
994
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530995
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530996VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
997{
998 struct statsContext context;
999 hdd_context_t *pHddCtx;
1000 hdd_station_ctx_t *pHddStaCtx;
1001 eHalStatus hstatus;
1002 long lrc;
1003 int valid;
1004
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301005 ENTER();
1006
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301007 if (NULL == pAdapter)
1008 {
1009 hddLog(VOS_TRACE_LEVEL_ERROR,
1010 "%s: Invalid context, pAdapter", __func__);
1011 return VOS_STATUS_E_FAULT;
1012 }
1013
1014 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1015
1016 valid = wlan_hdd_validate_context(pHddCtx);
1017 if (0 != valid)
1018 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301019 return VOS_STATUS_E_FAULT;
1020 }
1021
1022 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1023 if (NULL == pHddStaCtx)
1024 {
1025 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1026 return VOS_STATUS_E_FAULT;
1027 }
1028
1029 init_completion(&context.completion);
1030 context.pAdapter = pAdapter;
1031 context.magic = SNR_CONTEXT_MAGIC;
1032
1033 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1034 pHddStaCtx->conn_info.staId[ 0 ],
1035 pHddStaCtx->conn_info.bssId,
1036 &context);
1037 if (eHAL_STATUS_SUCCESS != hstatus)
1038 {
1039 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1040 __func__);
1041 /* we'll returned a cached value below */
1042 }
1043 else
1044 {
1045 /* request was sent -- wait for the response */
1046 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1047 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301048 if (lrc <= 0)
1049 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001050 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301051 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301052 /* we'll now returned a cached value below */
1053 }
1054 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001055
1056 /* either we never sent a request, we sent a request and received a
1057 response or we sent a request and timed out. if we never sent a
1058 request or if we sent a request and got a response, we want to
1059 clear the magic out of paranoia. if we timed out there is a
1060 race condition such that the callback function could be
1061 executing at the same time we are. of primary concern is if the
1062 callback function had already verified the "magic" but had not
1063 yet set the completion variable when a timeout occurred. we
1064 serialize these activities by invalidating the magic while
1065 holding a shared spinlock which will cause us to block if the
1066 callback is currently executing */
1067 spin_lock(&hdd_context_lock);
1068 context.magic = 0;
1069 spin_unlock(&hdd_context_lock);
1070
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301071 *snr = pAdapter->snr;
1072
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301073 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301074 return VOS_STATUS_SUCCESS;
1075}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301076
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001077#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001078
1079static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1080{
1081 struct statsContext *pStatsContext;
1082 hdd_adapter_t *pAdapter;
1083 if (ioctl_debug)
1084 {
1085 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1086 __func__, (int)rssi, (int)staId, pContext);
1087 }
1088
1089 if (NULL == pContext)
1090 {
1091 hddLog(VOS_TRACE_LEVEL_ERROR,
1092 "%s: Bad param, pContext [%p]",
1093 __func__, pContext);
1094 return;
1095 }
1096
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001097 pStatsContext = pContext;
1098 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001099
1100 /* there is a race condition that exists between this callback
1101 function and the caller since the caller could time out either
1102 before or while this code is executing. we use a spinlock to
1103 serialize these actions */
1104 spin_lock(&hdd_context_lock);
1105
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001106 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1107 {
1108 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001109 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001110 hddLog(VOS_TRACE_LEVEL_WARN,
1111 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1112 __func__, pAdapter, pStatsContext->magic);
1113 if (ioctl_debug)
1114 {
1115 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1116 __func__, pAdapter, pStatsContext->magic);
1117 }
1118 return;
1119 }
1120
Jeff Johnson72a40512013-12-19 10:14:15 -08001121 /* context is valid so caller is still waiting */
1122
1123 /* paranoia: invalidate the magic */
1124 pStatsContext->magic = 0;
1125
Sachin Ahujaa082b672015-10-05 19:51:31 +05301126 /* copy over the rssi.FW will return RSSI as -100
1127 * if there are no samples to calculate the average
1128 * RSSI
1129 */
1130 if (rssi != -100)
1131 pAdapter->rssi = rssi;
1132
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301133 if (pAdapter->rssi > 0)
1134 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001135 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001136 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001137
1138 /* serialization is complete */
1139 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001140}
1141
1142
1143
1144VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1145{
1146 struct statsContext context;
1147 hdd_context_t *pHddCtx = NULL;
1148 hdd_station_ctx_t *pHddStaCtx = NULL;
1149 eHalStatus hstatus;
1150 long lrc;
1151
1152 if (NULL == pAdapter)
1153 {
1154 hddLog(VOS_TRACE_LEVEL_WARN,
1155 "%s: Invalid context, pAdapter", __func__);
1156 return VOS_STATUS_E_FAULT;
1157 }
1158 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1159 {
1160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1161 /* return a cached value */
1162 *rssi_value = pAdapter->rssi;
1163 return VOS_STATUS_SUCCESS;
1164 }
1165
1166 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1167 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1168
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301169 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001170 {
1171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1172 /* return a cached value */
1173 *rssi_value = 0;
1174 return VOS_STATUS_SUCCESS;
1175 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301176
1177 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1178 {
1179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1180 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1181 *rssi_value = pAdapter->rssi;
1182 return VOS_STATUS_SUCCESS;
1183 }
1184
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001185 init_completion(&context.completion);
1186 context.pAdapter = pAdapter;
1187 context.magic = RSSI_CONTEXT_MAGIC;
1188
1189 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1190 pHddStaCtx->conn_info.staId[ 0 ],
1191 pHddStaCtx->conn_info.bssId,
1192 &context, pHddCtx->pvosContext);
1193 if (eHAL_STATUS_SUCCESS != hstatus)
1194 {
1195 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1196 __func__);
1197 /* we'll returned a cached value below */
1198 }
1199 else
1200 {
1201 /* request was sent -- wait for the response */
1202 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1203 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001204 if (lrc <= 0)
1205 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001206 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001207 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001208 /* we'll now returned a cached value below */
1209 }
1210 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001211
1212 /* either we never sent a request, we sent a request and received a
1213 response or we sent a request and timed out. if we never sent a
1214 request or if we sent a request and got a response, we want to
1215 clear the magic out of paranoia. if we timed out there is a
1216 race condition such that the callback function could be
1217 executing at the same time we are. of primary concern is if the
1218 callback function had already verified the "magic" but had not
1219 yet set the completion variable when a timeout occurred. we
1220 serialize these activities by invalidating the magic while
1221 holding a shared spinlock which will cause us to block if the
1222 callback is currently executing */
1223 spin_lock(&hdd_context_lock);
1224 context.magic = 0;
1225 spin_unlock(&hdd_context_lock);
1226
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001227 *rssi_value = pAdapter->rssi;
1228
1229 return VOS_STATUS_SUCCESS;
1230}
1231#endif
1232
1233
Jeff Johnson295189b2012-06-20 16:38:30 -07001234void hdd_StatisticsCB( void *pStats, void *pContext )
1235{
1236 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1237 hdd_stats_t *pStatsCache = NULL;
1238 hdd_wext_state_t *pWextState;
1239 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1240
1241 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1242 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1243 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1244 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1245 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1246 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1247
1248 if (pAdapter!= NULL)
1249 pStatsCache = &pAdapter->hdd_stats;
1250
1251
1252 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1253 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1254 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1255 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1256 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1257 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1258
1259 if (pStatsCache!=NULL)
1260 {
1261 // and copy the stats into the cache we keep in the adapter instance structure
1262 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1263 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1264 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1265 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1266 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1267 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1268 }
1269
1270 if(pAdapter)
1271 {
1272 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1273 if(pWextState)
1274 {
1275 vos_status = vos_event_set(&pWextState->vosevent);
1276 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1277 {
1278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001279 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 return;
1281 }
1282 }
1283 }
1284}
1285
1286void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1287{
1288 v_CONTEXT_t pVosContext;
1289 hdd_context_t *pHddCtx;
1290 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1291#if 0
1292 hdd_wext_state_t *pWextState;
1293 v_U32_t roamId;
1294#endif
1295
1296 ENTER();
1297
1298 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1299
1300 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1301 if (NULL == pHddCtx)
1302 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001303 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 return;
1305 }
1306#if 0
1307 pWextState = pAdapter->pWextState;
1308#endif
1309
1310 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1311 {
1312 //TODO Verify is this is really used. If yes need to fix it.
1313 hdd_reconnect_all_adapters( pHddCtx );
1314#if 0
1315 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1316 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1317 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1318
1319 if(VOS_STATUS_SUCCESS == vosStatus)
1320 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1321 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1322
1323 sme_RoamConnect(halHandle,
1324 pAdapter->sessionId, &(pWextState->roamProfile),
1325 &roamId);
1326#endif
1327 }
1328
1329 EXIT();
1330
1331}
1332
1333void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1334{
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1336
1337 /* clear WPA/RSN/WSC IE information in the profile */
1338 pWextState->roamProfile.nWPAReqIELength = 0;
1339 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1340 pWextState->roamProfile.nRSNReqIELength = 0;
1341 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1342
Chet Lanctot186b5732013-03-18 10:26:30 -07001343#ifdef FEATURE_WLAN_WAPI
1344 pWextState->roamProfile.nWAPIReqIELength = 0;
1345 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1346#endif
1347
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001349 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001350 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301351 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1353 pWextState->roamProfile.nAddIEAssocLength = 0;
1354
1355 pWextState->roamProfile.EncryptionType.numEntries = 1;
1356 pWextState->roamProfile.EncryptionType.encryptionType[0]
1357 = eCSR_ENCRYPT_TYPE_NONE;
1358
1359 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1360 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1361 = eCSR_ENCRYPT_TYPE_NONE;
1362
1363 pWextState->roamProfile.AuthType.numEntries = 1;
1364 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1365
Chet Lanctot186b5732013-03-18 10:26:30 -07001366#ifdef WLAN_FEATURE_11W
1367 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1368 pWextState->roamProfile.MFPRequired = 0;
1369 pWextState->roamProfile.MFPCapable = 0;
1370#endif
1371
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 pWextState->authKeyMgmt = 0;
1373
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301374 vos_mem_zero(&pWextState->roamProfile.Keys,
1375 sizeof(pWextState->roamProfile.Keys));
1376
Jeff Johnson295189b2012-06-20 16:38:30 -07001377#ifdef FEATURE_WLAN_WAPI
1378 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1379 pAdapter->wapi_info.nWapiMode = 0;
1380#endif
1381
1382 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1383
1384}
1385
1386void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1387{
1388 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001389
Nirav Shahf6bd2672015-03-11 12:53:15 +05301390 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001391 {
1392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301393 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001394 }
1395 else
1396 {
1397 complete(&pAdapter->ula_complete);
1398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001399}
1400
1401VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1402{
1403 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001405 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001406
1407 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1408 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001409 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001410
1411 /*To avoid race condition between the set key and the last EAPOL
1412 packet, notify TL to finish upper layer authentication incase if the
1413 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001414 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001415
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001416 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 {
1418 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1419 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1420 __LINE__, vos_status );
1421 return vos_status;
1422
1423 }
1424
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001425 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301427 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001428 {
1429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301430 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001431 /* we'll still fall through and return success since the
1432 * connection may still get established but is just taking
1433 * too long for us to wait */
1434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 }
1436 return VOS_STATUS_SUCCESS;
1437}
1438
1439v_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)
1440{
1441
1442 int left = ie_len;
1443 v_U8_t *ptr = ie;
1444 v_U8_t elem_id,elem_len;
1445 v_U8_t eid = 0xDD;
1446
1447 if ( NULL == ie || 0 == ie_len )
1448 return NULL;
1449
1450 while(left >= 2)
1451 {
1452 elem_id = ptr[0];
1453 elem_len = ptr[1];
1454 left -= 2;
1455 if(elem_len > left)
1456 {
1457 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001458 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001459 eid,elem_len,left);
1460 return NULL;
1461 }
1462 if (elem_id == eid)
1463 {
1464 if(memcmp( &ptr[2], oui, oui_size)==0)
1465 return ptr;
1466 }
1467
1468 left -= elem_len;
1469 ptr += (elem_len + 2);
1470 }
1471 return NULL;
1472}
1473
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301474static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 union iwreq_data *wrqu, char *extra)
1476{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301477 hdd_adapter_t *pAdapter;
1478 hdd_context_t *pHddCtx;
1479 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301480
1481 ENTER();
1482
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301483 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1484 if (NULL == pAdapter)
1485 {
1486 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1487 "%s: pAdapter is NULL\n", __func__);
1488 return -EINVAL;
1489 }
1490 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1491 ret = wlan_hdd_validate_context(pHddCtx);
1492 if (0 != ret)
1493 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301494 return ret;
1495 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301496
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301498
1499 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301500 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001501}
1502
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301503static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1504 union iwreq_data *wrqu, char *extra)
1505{
1506 int ret;
1507
1508 vos_ssr_protect(__func__);
1509 ret = __iw_set_commit(dev, info, wrqu, extra);
1510 vos_ssr_unprotect(__func__);
1511
1512 return ret;
1513}
1514
1515static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 struct iw_request_info *info,
1517 char *wrqu, char *extra)
1518{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301519 hdd_adapter_t *pAdapter;
1520 hdd_context_t *pHddCtx;
1521 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301522
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301524 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1525 if (NULL == pAdapter)
1526 {
1527 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1528 "%s: pAdapter is NULL\n", __func__);
1529 return -EINVAL;
1530 }
1531 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1532 ret = wlan_hdd_validate_context(pHddCtx);
1533 if (0 != ret)
1534 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301535 return ret;
1536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1538 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301539 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001540}
1541
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301542static int iw_get_name(struct net_device *dev,
1543 struct iw_request_info *info,
1544 char *wrqu, char *extra)
1545{
1546 int ret;
1547
1548 vos_ssr_protect(__func__);
1549 ret = __iw_get_name(dev, info, wrqu, extra);
1550 vos_ssr_unprotect(__func__);
1551
1552 return ret;
1553}
1554
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301555static int __iw_set_mode(struct net_device *dev,
1556 struct iw_request_info *info,
1557 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001558{
1559 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301560 hdd_adapter_t *pAdapter;
1561 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 tCsrRoamProfile *pRoamProfile;
1563 eCsrRoamBssType LastBSSType;
1564 eMib_dot11DesiredBssType connectedBssType;
1565 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301567 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001568
1569 ENTER();
1570
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301571 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 if (NULL == pAdapter)
1573 {
1574 hddLog(VOS_TRACE_LEVEL_WARN,
1575 "%s: Invalid context, pAdapter", __func__);
1576 return 0;
1577 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301578 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1579 status = wlan_hdd_validate_context(pHddCtx);
1580 if (0 != status)
1581 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301582 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 }
1584
1585 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1586 if (pWextState == NULL)
1587 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301588 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 return -EINVAL;
1590 }
1591
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 pRoamProfile = &pWextState->roamProfile;
1594 LastBSSType = pRoamProfile->BSSType;
1595
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301596 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001597
1598 switch (wrqu->mode)
1599 {
1600 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301601 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1603 // Set the phymode correctly for IBSS.
1604 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1605 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001606 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 break;
1609 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301610 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 break;
1614 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301615 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1617 break;
1618 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301619 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 return -EOPNOTSUPP;
1621 }
1622
1623 if ( LastBSSType != pRoamProfile->BSSType )
1624 {
1625 //the BSS mode changed
1626 // We need to issue disconnect if connected or in IBSS disconnect state
1627 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1628 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1629 {
1630 VOS_STATUS vosStatus;
1631 // need to issue a disconnect to CSR.
1632 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1633 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1634 pAdapter->sessionId,
1635 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1636 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301637 {
1638 long ret;
1639 ret = wait_for_completion_interruptible_timeout(
1640 &pAdapter->disconnect_comp_var,
1641 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1642 if (ret <= 0)
1643 hddLog(VOS_TRACE_LEVEL_ERROR,
1644 FL("failed wait on disconnect_comp_var %ld"), ret);
1645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 }
1647 }
1648
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 EXIT();
1650 return 0;
1651}
1652
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301653static int iw_set_mode(struct net_device *dev,
1654 struct iw_request_info *info,
1655 union iwreq_data *wrqu, char *extra)
1656{
1657 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001658
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301659 vos_ssr_protect(__func__);
1660 ret = __iw_set_mode(dev, info, wrqu, extra);
1661 vos_ssr_unprotect(__func__);
1662
1663 return ret;
1664}
1665
1666static int __iw_get_mode(struct net_device *dev,
1667 struct iw_request_info *info,
1668 union iwreq_data *wrqu,
1669 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001670{
1671
1672 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301673 hdd_adapter_t *pAdapter;
1674 hdd_context_t *pHddCtx;
1675 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001676
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301677 ENTER();
1678
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301679 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 if (NULL == pAdapter)
1681 {
1682 hddLog(VOS_TRACE_LEVEL_WARN,
1683 "%s: Invalid context, pAdapter", __func__);
1684 return 0;
1685 }
1686
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301687 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1688 ret = wlan_hdd_validate_context(pHddCtx);
1689 if (0 != ret)
1690 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301691 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1694 if (pWextState == NULL)
1695 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301696 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 return -EINVAL;
1698 }
1699
1700 switch (pWextState->roamProfile.BSSType)
1701 {
1702 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001703 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301704 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 break;
1706 case eCSR_BSS_TYPE_IBSS:
1707 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001708 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301709 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 break;
1711 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001712 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301713 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 break;
1715 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001716 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 break;
1718 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301719
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301720 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 return 0;
1722}
1723
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301724static int iw_get_mode(struct net_device *dev,
1725 struct iw_request_info *info,
1726 union iwreq_data *wrqu,
1727 char *extra)
1728{
1729 int ret;
1730
1731 vos_ssr_protect(__func__);
1732 ret = __iw_get_mode(dev, info, wrqu, extra);
1733 vos_ssr_unprotect(__func__);
1734
1735 return ret;
1736}
1737
1738static int __iw_set_freq(struct net_device *dev,
1739 struct iw_request_info *info,
1740 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001741{
1742 v_U32_t numChans = 0;
1743 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1744 v_U32_t indx = 0;
1745 v_U32_t status = 0;
1746
1747 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301748 hdd_adapter_t *pAdapter;
1749 hdd_context_t *pHddCtx;
1750 tHalHandle hHal;
1751 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301753
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 ENTER();
1755
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301756 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1757 if (NULL == pAdapter)
1758 {
1759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1760 "%s:Invalid Adapter",__func__);
1761 return -EINVAL;
1762 }
1763
1764 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1765 status = wlan_hdd_validate_context(pHddCtx);
1766 if (0 != status)
1767 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 return status;
1769 }
1770
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301771 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1772 if (NULL == hHal)
1773 {
1774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1775 "%s: Hal Context is NULL",__func__);
1776 return -EINVAL;
1777 }
1778
1779 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1780 if (NULL == pHddStaCtx)
1781 {
1782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1783 "%s:STA context is NULL",__func__);
1784 return -EINVAL;
1785 }
1786
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301788 if (NULL == pWextState)
1789 {
1790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1791 "%s: pWextState is NULL",__func__);
1792 return -EINVAL;
1793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001794
1795 pRoamProfile = &pWextState->roamProfile;
1796
Arif Hussain6d2a3322013-11-17 19:50:10 -08001797 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001798
1799 /* Link is up then return cant set channel*/
1800 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1801 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1802 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001803 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 return -EOPNOTSUPP;
1805 }
1806
1807 /* Settings by Frequency as input */
1808 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1809 (wrqu->freq.m <= (tANI_U32)5.825e8))
1810 {
1811 tANI_U32 freq = wrqu->freq.m / 100000;
1812
1813 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1814 indx++;
1815 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1816 {
1817 return -EINVAL;
1818 }
1819 wrqu->freq.e = 0;
1820 wrqu->freq.m = freq_chan_map[indx].chan;
1821
1822 }
1823
1824 if (wrqu->freq.e == 0)
1825 {
1826 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1827 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1828 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001829 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001830 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1832 return -EINVAL;
1833 }
1834
1835 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1836
1837 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1838 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1840 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 return -EIO;
1842 }
1843
1844 for (indx = 0; indx < numChans; indx++) {
1845 if (wrqu->freq.m == validChan[indx]){
1846 break;
1847 }
1848 }
1849 }
1850 else{
1851
1852 return -EINVAL;
1853 }
1854
1855 if(indx >= numChans)
1856 {
1857 return -EINVAL;
1858 }
1859
1860 /* Set the Operational Channel */
1861 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1862 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1863 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1864
Arif Hussain6d2a3322013-11-17 19:50:10 -08001865 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001866
1867 EXIT();
1868
1869 return status;
1870}
1871
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301872static int iw_set_freq(struct net_device *dev,
1873 struct iw_request_info *info,
1874 union iwreq_data *wrqu, char *extra)
1875{
1876 int ret;
1877
1878 vos_ssr_protect(__func__);
1879 ret = __iw_set_freq(dev, info, wrqu, extra);
1880 vos_ssr_unprotect(__func__);
1881
1882 return ret;
1883}
1884
1885static int __iw_get_freq(struct net_device *dev,
1886 struct iw_request_info *info,
1887 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001888{
Jeff Johnsone7245742012-09-05 17:12:55 -07001889 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301890 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 tHalHandle hHal;
1892 hdd_wext_state_t *pWextState;
1893 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301894 hdd_station_ctx_t *pHddStaCtx;
1895 hdd_context_t *pHddCtx;
1896 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001897
1898 ENTER();
1899
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301900 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1901 if (NULL == pAdapter)
1902 {
1903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1904 "%s: Adapter is NULL", __func__);
1905 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301907 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1908 ret = wlan_hdd_validate_context(pHddCtx);
1909 if (0 != ret)
1910 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301911 return ret;
1912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301914 if (NULL == hHal)
1915 {
1916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1917 "%s: Hal Context is NULL",__func__);
1918 return -EINVAL;
1919 }
1920 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1921 if (NULL == pHddStaCtx)
1922 {
1923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1924 "%s: HddStaCtx is NULL", __func__);
1925 return -EINVAL;
1926 }
1927 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1928 if (NULL == pWextState)
1929 {
1930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1931 "%s: pWextState is NULL",__func__);
1932 return -EINVAL;
1933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 pRoamProfile = &pWextState->roamProfile;
1935
1936 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1937 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001938 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 {
c_hpothub8245442013-11-20 23:41:09 +05301940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1941 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 return -EIO;
1943 }
1944 else
1945 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001946 status = hdd_wlan_get_freq(channel, &freq);
1947 if( TRUE == status )
1948 {
1949 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1950 * iwlist & iwconfig command shows frequency into proper
1951 * format (2.412 GHz instead of 246.2 MHz)*/
1952 fwrq->m = freq;
1953 fwrq->e = MHZ;
1954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 }
1956 }
1957 else
1958 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001959 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1960 * iwlist & iwconfig command shows frequency into proper
1961 * format (2.412 GHz instead of 246.2 MHz)*/
1962 fwrq->m = 0;
1963 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301965
1966 EXIT();
1967 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001968}
1969
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301970static int iw_get_freq(struct net_device *dev,
1971 struct iw_request_info *info,
1972 struct iw_freq *fwrq, char *extra)
1973{
1974 int ret;
1975
1976 vos_ssr_protect(__func__);
1977 ret = __iw_get_freq(dev, info, fwrq, extra);
1978 vos_ssr_unprotect(__func__);
1979
1980 return ret;
1981}
1982
1983static int __iw_get_tx_power(struct net_device *dev,
1984 struct iw_request_info *info,
1985 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001986{
1987
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301988 hdd_adapter_t *pAdapter;
1989 hdd_context_t *pHddCtx;
1990 hdd_station_ctx_t *pHddStaCtx;
1991 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001992
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301993 ENTER();
1994
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301995 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1996 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1999 "%s: Adapter is NULL",__func__);
2000 return -EINVAL;
2001 }
2002 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2003 ret = wlan_hdd_validate_context(pHddCtx);
2004 if (0 != ret)
2005 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302006 return ret;
2007 }
2008
2009 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2010 if (NULL == pHddStaCtx)
2011 {
2012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2013 "%s: STA Context is NULL",__func__);
2014 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 }
2016
2017 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2018 {
2019 wrqu->txpower.value = 0;
2020 return 0;
2021 }
2022 wlan_hdd_get_classAstats(pAdapter);
2023 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2024
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302025 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 return 0;
2027}
2028
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302029static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 struct iw_request_info *info,
2031 union iwreq_data *wrqu, char *extra)
2032{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302033 int ret;
2034
2035 vos_ssr_protect(__func__);
2036 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2037 vos_ssr_unprotect(__func__);
2038
2039 return ret;
2040}
2041
2042static int __iw_set_tx_power(struct net_device *dev,
2043 struct iw_request_info *info,
2044 union iwreq_data *wrqu, char *extra)
2045{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302046 hdd_adapter_t *pAdapter;
2047 tHalHandle hHal;
2048 hdd_context_t *pHddCtx;
2049 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002050
2051 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302052 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2053 if (NULL == pAdapter)
2054 {
2055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2056 "%s: Adapter is NULL",__func__);
2057 return -EINVAL;
2058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002059
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302060 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2061 ret = wlan_hdd_validate_context(pHddCtx);
2062 if (0 != ret)
2063 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302064 return ret;
2065 }
2066
2067 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2068 if (NULL == hHal)
2069 {
2070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2071 "%s: Hal Context is NULL",__func__);
2072 return -EINVAL;
2073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2075 {
c_hpothub8245442013-11-20 23:41:09 +05302076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2077 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 return -EIO;
2079 }
2080
2081 EXIT();
2082
2083 return 0;
2084}
2085
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302086static int iw_set_tx_power(struct net_device *dev,
2087 struct iw_request_info *info,
2088 union iwreq_data *wrqu, char *extra)
2089{
2090 int ret;
2091
2092 vos_ssr_protect(__func__);
2093 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2094 vos_ssr_unprotect(__func__);
2095
2096 return ret;
2097}
2098
2099static int __iw_get_bitrate(struct net_device *dev,
2100 struct iw_request_info *info,
2101 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002102{
2103 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2104 eHalStatus status = eHAL_STATUS_SUCCESS;
2105 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302106 hdd_adapter_t *pAdapter;
2107 hdd_context_t *pHddCtx;
2108 hdd_station_ctx_t *pHddStaCtx;
2109 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002110
2111 ENTER();
2112
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302113 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2114 if (NULL == pAdapter)
2115 {
2116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2117 "%s: Adapter is NULL",__func__);
2118 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 }
2120
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302121 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2122 ret = wlan_hdd_validate_context(pHddCtx);
2123 if (0 != ret)
2124 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302125 return ret;
2126 }
2127
2128 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2129 if (NULL == pHddStaCtx)
2130 {
2131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2132 "%s: STA Context is NULL",__func__);
2133 return -EINVAL;
2134 }
2135
2136 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 wrqu->bitrate.value = 0;
2138 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302139 else
2140 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2142 SME_SUMMARY_STATS |
2143 SME_GLOBAL_CLASSA_STATS |
2144 SME_GLOBAL_CLASSB_STATS |
2145 SME_GLOBAL_CLASSC_STATS |
2146 SME_GLOBAL_CLASSD_STATS |
2147 SME_PER_STA_STATS,
2148 hdd_StatisticsCB, 0, FALSE,
2149 pHddStaCtx->conn_info.staId[0], pAdapter );
2150
2151 if(eHAL_STATUS_SUCCESS != status)
2152 {
2153 hddLog(VOS_TRACE_LEVEL_ERROR,
2154 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002155 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 return status;
2157 }
2158
2159 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302160 if (NULL == pWextState)
2161 {
2162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2163 "%s: pWextState is NULL",__func__);
2164 return -EINVAL;
2165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002166
2167 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2168
2169 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2170 {
2171 hddLog(VOS_TRACE_LEVEL_ERROR,
2172 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002173 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 return VOS_STATUS_E_FAILURE;
2175 }
2176
2177 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2178 }
2179
2180 EXIT();
2181
2182 return vos_status;
2183}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302184
2185static int iw_get_bitrate(struct net_device *dev,
2186 struct iw_request_info *info,
2187 union iwreq_data *wrqu, char *extra)
2188{
2189 int ret;
2190
2191 vos_ssr_protect(__func__);
2192 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2193 vos_ssr_unprotect(__func__);
2194
2195 return ret;
2196}
2197
2198
Jeff Johnson295189b2012-06-20 16:38:30 -07002199/* ccm call back function */
2200
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302201static int __iw_set_bitrate(struct net_device *dev,
2202 struct iw_request_info *info,
2203 union iwreq_data *wrqu,
2204 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002205{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302206 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302208 hdd_station_ctx_t *pHddStaCtx;
2209 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2211 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2212 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2213 v_U32_t i, rate;
2214 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302215 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002216
2217 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302218 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2219 if (NULL == pAdapter)
2220 {
2221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2222 "%s: Adapter is NULL",__func__);
2223 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 }
2225
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302226 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2227 ret = wlan_hdd_validate_context(pHddCtx);
2228 if (0 != ret)
2229 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302230 return ret;
2231 }
2232
2233 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2234 if (NULL == pHddStaCtx)
2235 {
2236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2237 "%s: STA Context is NULL",__func__);
2238 return -EINVAL;
2239 }
2240
2241
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302243 if (NULL == pWextState)
2244 {
2245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2246 "%s: pWextState is NULL",__func__);
2247 return -EINVAL;
2248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002249
2250 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2251 {
2252 return -ENXIO ;
2253 }
2254
2255 rate = wrqu->bitrate.value;
2256
2257 if (rate == -1)
2258 {
2259 rate = WNI_CFG_FIXED_RATE_AUTO;
2260 valid_rate = TRUE;
2261 }
2262 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2263 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2264 {
2265 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2266 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2267 {
2268 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2269 WNI_CFG_SUPPORTED_RATES_11A,
2270 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2271 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2272 WNI_CFG_SUPPORTED_RATES_11B,
2273 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2274 {
2275 for (i = 0; i < (b_len + a_len); ++i)
2276 {
2277 /* supported rates returned is double the actual rate so we divide it by 2 */
2278 if ((supp_rates[i]&0x7F)/2 == rate)
2279 {
2280 valid_rate = TRUE;
2281 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2282 break;
2283 }
2284 }
2285 }
2286 }
2287 }
2288 if (valid_rate != TRUE)
2289 {
2290 return -EINVAL;
2291 }
2292 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2293 WNI_CFG_FIXED_RATE, rate,
2294 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2295 {
c_hpothub8245442013-11-20 23:41:09 +05302296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2297 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 return -EIO;
2299 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302300
2301 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 return 0;
2303}
2304
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302305static int iw_set_bitrate(struct net_device *dev,
2306 struct iw_request_info *info,
2307 union iwreq_data *wrqu,
2308 char *extra)
2309{
2310 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002311
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302312 vos_ssr_protect(__func__);
2313 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2314 vos_ssr_unprotect(__func__);
2315
2316 return ret;
2317}
2318
2319static int __iw_set_genie(struct net_device *dev,
2320 struct iw_request_info *info,
2321 union iwreq_data *wrqu,
2322 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002323{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302324 hdd_adapter_t *pAdapter;
2325 hdd_context_t *pHddCtx;
2326 hdd_wext_state_t *pWextState;
2327 u_int8_t *genie = NULL;
2328 u_int8_t *base_genie = NULL;
2329 v_U16_t remLen;
2330 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002331
2332 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002333
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302334 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2335 if (NULL == pAdapter)
2336 {
2337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2338 "%s: Adapter is NULL",__func__);
2339 return -EINVAL;
2340 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002341
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302342 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2343 ret = wlan_hdd_validate_context(pHddCtx);
2344 if (0 != ret)
2345 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302346 return ret;
2347 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002348
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302349 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2350 if (NULL == pWextState)
2351 {
2352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2353 "%s: pWextState is NULL",__func__);
2354 return -EINVAL;
2355 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002356
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302357 if (!wrqu->data.length) {
2358 hdd_clearRoamProfileIe(pAdapter);
2359 EXIT();
2360 return 0;
2361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002362
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302363 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2364 wrqu->data.length);
2365 if (NULL == base_genie)
2366 {
2367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2368 "mem_alloc_copy_from_user_helper fail");
2369 return -ENOMEM;
2370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002371
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302372 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002373
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302374 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002375
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302376 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2377
2378 /* clear any previous genIE before this call */
2379 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2380
2381 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 {
2383 v_U16_t eLen = 0;
2384 v_U8_t elementId;
2385 elementId = *genie++;
2386 eLen = *genie++;
2387 remLen -= 2;
2388
Arif Hussain6d2a3322013-11-17 19:50:10 -08002389 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 __func__, elementId, eLen);
2391
2392 switch ( elementId )
2393 {
2394 case IE_EID_VENDOR:
2395 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002396 {
2397 kfree(base_genie);
2398 return -EINVAL;
2399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002400
2401 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2402 {
2403 v_U16_t curGenIELen = pWextState->genIE.length;
2404 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2405 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2406
2407 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2408 {
2409 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002410 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002412 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 return -ENOMEM;
2414 }
2415 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2416 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2417 pWextState->genIE.length += eLen + 2;
2418 }
2419 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2420 {
2421 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2422 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2423 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2424 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2425 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2426 }
2427 else /* any vendorId except WPA IE should be accumulated to genIE */
2428 {
2429 v_U16_t curGenIELen = pWextState->genIE.length;
2430 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2431 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2432
2433 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2434 {
2435 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002436 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002438 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 return -ENOMEM;
2440 }
2441 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2442 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2443 pWextState->genIE.length += eLen + 2;
2444 }
2445 break;
2446 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002447 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2449 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2450 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2451 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2452 break;
2453
2454 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002455 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002456 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 return 0;
2458 }
2459 genie += eLen;
2460 remLen -= eLen;
2461 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302462
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002464 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 return 0;
2466}
2467
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302468static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 struct iw_request_info *info,
2470 union iwreq_data *wrqu,
2471 char *extra)
2472{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302473 int ret;
2474
2475 vos_ssr_protect(__func__);
2476 ret = __iw_set_genie(dev, info, wrqu, extra);
2477 vos_ssr_unprotect(__func__);
2478
2479 return ret;
2480}
2481
2482static int __iw_get_genie(struct net_device *dev,
2483 struct iw_request_info *info,
2484 union iwreq_data *wrqu,
2485 char *extra)
2486{
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302488 hdd_context_t *pHddCtx;
2489 hdd_adapter_t *pAdapter;
2490 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 eHalStatus status;
2492 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2493 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2494
2495 ENTER();
2496
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302497 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2498 if (NULL == pAdapter)
2499 {
2500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2501 "%s: Adapter is NULL",__func__);
2502 return -EINVAL;
2503 }
2504 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2505 status = wlan_hdd_validate_context(pHddCtx);
2506 if (0 != status)
2507 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302508 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 }
2510
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302512 if (NULL == pWextState)
2513 {
2514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2515 "%s: pWextState is NULL",__func__);
2516 return -EINVAL;
2517 }
2518
2519 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2520 if (NULL == pHddStaCtx)
2521 {
2522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2523 "%s: STA Context is NULL",__func__);
2524 return -EINVAL;
2525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002526
2527 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2528 {
2529 return -ENXIO;
2530 }
2531
2532 // Return something ONLY if we are associated with an RSN or WPA network
2533 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2534 pWextState->roamProfile.negotiatedAuthType))
2535 {
2536 return -ENXIO;
2537 }
2538
2539 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2540 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2541 pAdapter->sessionId,
2542 &length,
2543 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002544 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2545 if (wrqu->data.length < length)
2546 {
2547 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2548 return -EFAULT;
2549 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002550 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002551 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002552
Arif Hussain6d2a3322013-11-17 19:50:10 -08002553 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002554
2555 EXIT();
2556
2557 return 0;
2558}
2559
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302560static int iw_get_genie(struct net_device *dev,
2561 struct iw_request_info *info,
2562 union iwreq_data *wrqu,
2563 char *extra)
2564{
2565 int ret;
2566
2567 vos_ssr_protect(__func__);
2568 ret = __iw_get_genie(dev, info, wrqu, extra);
2569 vos_ssr_unprotect(__func__);
2570
2571 return ret;
2572}
2573
2574
2575static int __iw_get_encode(struct net_device *dev,
2576 struct iw_request_info *info,
2577 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002578{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302579 hdd_adapter_t *pAdapter;
2580 hdd_context_t *pHddCtx;
2581 hdd_wext_state_t *pWextState;
2582 tCsrRoamProfile *pRoamProfile;
2583 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002585
2586 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302587 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2588 if (NULL == pAdapter)
2589 {
2590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2591 "%s: Adapter is NULL",__func__);
2592 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 }
2594
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302595 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2596 ret = wlan_hdd_validate_context(pHddCtx);
2597 if (0 != ret)
2598 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302599 return ret;
2600 }
2601 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2602 if (NULL == pWextState)
2603 {
2604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2605 "%s: pWextState is NULL",__func__);
2606 return -EINVAL;
2607 }
2608
2609 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 keyId = pRoamProfile->Keys.defaultIndex;
2611
2612 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2613 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002614 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 return -EINVAL;
2616 }
2617
2618 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2619 {
2620 dwrq->flags |= IW_ENCODE_ENABLED;
2621 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2622 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2623
2624 dwrq->flags |= (keyId + 1);
2625
2626 }
2627 else
2628 {
2629 dwrq->flags |= IW_ENCODE_DISABLED;
2630 }
2631
2632 for(i=0; i < MAX_WEP_KEYS; i++)
2633 {
2634 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2635 {
2636 continue;
2637 }
2638 else
2639 {
2640 break;
2641 }
2642 }
2643
2644 if(MAX_WEP_KEYS == i)
2645 {
2646 dwrq->flags |= IW_ENCODE_NOKEY;
2647 }
2648
2649 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2650
2651 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2652 {
2653 dwrq->flags |= IW_ENCODE_OPEN;
2654 }
2655 else
2656 {
2657 dwrq->flags |= IW_ENCODE_RESTRICTED;
2658 }
2659 EXIT();
2660 return 0;
2661}
2662
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302663static int iw_get_encode(struct net_device *dev,
2664 struct iw_request_info *info,
2665 struct iw_point *dwrq, char *extra)
2666{
2667 int ret;
2668
2669 vos_ssr_protect(__func__);
2670 ret = __iw_get_encode(dev, info, dwrq, extra);
2671 vos_ssr_unprotect(__func__);
2672
2673 return ret;
2674}
2675
Jeff Johnson295189b2012-06-20 16:38:30 -07002676#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2677#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2678
2679
2680/*
2681 * This function sends a single 'key' to LIM at all time.
2682 */
2683
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302684static int __iw_get_rts_threshold(struct net_device *dev,
2685 struct iw_request_info *info,
2686 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002687{
2688 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2689 v_U32_t status = 0;
2690
2691 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2692
2693 return status;
2694}
2695
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302696static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 struct iw_request_info *info,
2698 union iwreq_data *wrqu, char *extra)
2699{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302700 int ret;
2701
2702 vos_ssr_protect(__func__);
2703 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2704 vos_ssr_unprotect(__func__);
2705
2706 return ret;
2707}
2708
2709static int __iw_set_rts_threshold(struct net_device *dev,
2710 struct iw_request_info *info,
2711 union iwreq_data *wrqu, char *extra)
2712{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302713 hdd_adapter_t *pAdapter;
2714 hdd_context_t *pHddCtx;
2715 tHalHandle hHal;
2716 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002717
2718 ENTER();
2719
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302720 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2721 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002722 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2724 "%s: Adapter is NULL",__func__);
2725 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002726 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302727
2728 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2729 ret = wlan_hdd_validate_context(pHddCtx);
2730 if (0 != ret)
2731 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302732 return ret;
2733 }
2734
2735 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2736 if (NULL == hHal)
2737 {
2738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2739 "%s: Hal Context is NULL",__func__);
2740 return -EINVAL;
2741 }
2742
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2744 {
2745 return -EINVAL;
2746 }
2747
2748 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2749 {
c_hpothub8245442013-11-20 23:41:09 +05302750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2751 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002752 return -EIO;
2753 }
2754
2755 EXIT();
2756
2757 return 0;
2758}
2759
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302760static int iw_set_rts_threshold(struct net_device *dev,
2761 struct iw_request_info *info,
2762 union iwreq_data *wrqu, char *extra)
2763{
2764 int ret;
2765
2766 vos_ssr_protect(__func__);
2767 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2768 vos_ssr_unprotect(__func__);
2769
2770 return ret;
2771}
2772
2773static int __iw_get_frag_threshold(struct net_device *dev,
2774 struct iw_request_info *info,
2775 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002776{
2777 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2778 v_U32_t status = 0;
2779
2780 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2781
2782 return status;
2783}
2784
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302785static int iw_get_frag_threshold(struct net_device *dev,
2786 struct iw_request_info *info,
2787 union iwreq_data *wrqu, char *extra)
2788{
2789 int ret;
2790
2791 vos_ssr_protect(__func__);
2792 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2793 vos_ssr_unprotect(__func__);
2794
2795 return ret;
2796}
2797
2798static int __iw_set_frag_threshold(struct net_device *dev,
2799 struct iw_request_info *info,
2800 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002801{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302802 hdd_adapter_t *pAdapter;
2803 hdd_context_t *pHddCtx;
2804 tHalHandle hHal;
2805 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002806
2807 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302808 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2809 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002810 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2812 "%s: Adapter is NULL",__func__);
2813 return -EINVAL;
2814 }
2815
2816 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2817 ret = wlan_hdd_validate_context(pHddCtx);
2818 if (0 != ret)
2819 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302820 return ret;
2821 }
2822
2823 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2824 if (NULL == hHal)
2825 {
2826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2827 "%s: Hal Context is NULL",__func__);
2828 return -EINVAL;
2829 }
2830
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2832 {
2833 return -EINVAL;
2834 }
2835
2836 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2837 {
c_hpothub8245442013-11-20 23:41:09 +05302838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2839 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 return -EIO;
2841 }
2842
2843 EXIT();
2844
2845 return 0;
2846}
2847
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302848static int iw_set_frag_threshold(struct net_device *dev,
2849 struct iw_request_info *info,
2850 union iwreq_data *wrqu, char *extra)
2851{
2852 int ret;
2853
2854 vos_ssr_protect(__func__);
2855 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2856 vos_ssr_unprotect(__func__);
2857
2858 return ret;
2859}
2860
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302861static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 struct iw_request_info *info,
2863 union iwreq_data *wrqu, char *extra)
2864{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302865 hdd_adapter_t *pAdapter;
2866 hdd_context_t *pHddCtx;
2867 int ret = 0;
2868
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302870 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2871 if (NULL == pAdapter)
2872 {
2873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2874 "%s: Adapter is NULL",__func__);
2875 return -EINVAL;
2876 }
2877 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2878 ret = wlan_hdd_validate_context(pHddCtx);
2879 if (0 != ret)
2880 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302881 return ret;
2882 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302883
2884 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 return -EOPNOTSUPP;
2886}
2887
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302888static int iw_get_power_mode(struct net_device *dev,
2889 struct iw_request_info *info,
2890 union iwreq_data *wrqu, char *extra)
2891{
2892 int ret;
2893
2894 vos_ssr_protect(__func__);
2895 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2896 vos_ssr_unprotect(__func__);
2897
2898 return ret;
2899}
2900static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 struct iw_request_info *info,
2902 union iwreq_data *wrqu, char *extra)
2903{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302904 hdd_adapter_t *pAdapter;
2905 hdd_context_t *pHddCtx;
2906 int ret = 0;
2907
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302909 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2910 if (NULL == pAdapter)
2911 {
2912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2913 "%s: Adapter is NULL",__func__);
2914 return -EINVAL;
2915 }
2916 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2917 ret = wlan_hdd_validate_context(pHddCtx);
2918 if (0 != ret)
2919 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302920 return ret;
2921 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302922
2923 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 return -EOPNOTSUPP;
2925}
2926
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302927static int iw_set_power_mode(struct net_device *dev,
2928 struct iw_request_info *info,
2929 union iwreq_data *wrqu, char *extra)
2930{
2931 int ret;
2932
2933 vos_ssr_protect(__func__);
2934 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2935 vos_ssr_unprotect(__func__);
2936
2937 return ret;
2938}
2939
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302940static int __iw_get_range(struct net_device *dev,
2941 struct iw_request_info *info,
2942 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002943{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302944 hdd_adapter_t *pAdapter;
2945 tHalHandle hHal;
2946 hdd_context_t *pHddCtx;
2947 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 struct iw_range *range = (struct iw_range *) extra;
2949
2950 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2951
2952 v_U32_t num_channels = sizeof(channels);
2953 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2954 v_U32_t a_len;
2955 v_U32_t b_len;
2956 v_U32_t active_phy_mode = 0;
2957 v_U8_t index = 0, i;
2958
2959 ENTER();
2960
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302961 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2962 if (NULL == pAdapter)
2963 {
2964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2965 "%s: pAdapter is NULL", __func__);
2966 return -EINVAL;
2967 }
2968 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2969 ret = wlan_hdd_validate_context(pHddCtx);
2970 if (0 != ret)
2971 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302972 return ret;
2973 }
2974 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2975 if (NULL == hHal)
2976 {
2977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2978 "%s: pAdapter is NULL", __func__);
2979 return -EINVAL;
2980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 wrqu->data.length = sizeof(struct iw_range);
2982 memset(range, 0, sizeof(struct iw_range));
2983
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 /*Get the phy mode*/
2985 if (ccmCfgGetInt(hHal,
2986 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2987 {
2988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002989 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002990
2991 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2992 {
2993 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002994 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 if (ccmCfgGetStr(hHal,
2996 WNI_CFG_SUPPORTED_RATES_11A,
2997 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2998 {
2999 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3000 {
3001 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3002 }
3003 for (i = 0; i < a_len; i++)
3004 {
3005 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3006 }
3007 range->num_bitrates = a_len;
3008 }
3009 else
3010 {
3011 return -EIO;
3012 }
3013 }
3014 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3015 {
3016 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003017 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 if (ccmCfgGetStr(hHal,
3019 WNI_CFG_SUPPORTED_RATES_11B,
3020 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3021 {
3022 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3023 {
3024 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3025 }
3026 for (i = 0; i < b_len; i++)
3027 {
3028 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3029 }
3030 range->num_bitrates = b_len;
3031 }
3032 else
3033 {
3034 return -EIO;
3035 }
3036 }
3037 }
3038
3039 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3040 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3041 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3042
3043 range->encoding_size[0] = 5;
3044 range->encoding_size[1] = 13;
3045 range->num_encoding_sizes = 2;
3046 range->max_encoding_tokens = MAX_WEP_KEYS;
3047
3048 // we support through Wireless Extensions 22
3049 range->we_version_compiled = WIRELESS_EXT;
3050 range->we_version_source = 22;
3051
3052 /*Supported Channels and Frequencies*/
3053 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3054 {
c_hpothub8245442013-11-20 23:41:09 +05303055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3056 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 return -EIO;
3058 }
3059 if (num_channels > IW_MAX_FREQUENCIES)
3060 {
3061 num_channels = IW_MAX_FREQUENCIES;
3062 }
3063
3064 range->num_channels = num_channels;
3065 range->num_frequency = num_channels;
3066
3067 for (index=0; index < num_channels; index++)
3068 {
3069 v_U32_t frq_indx = 0;
3070
3071 range->freq[index].i = channels[index];
3072 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3073 {
3074 if(channels[index] == freq_chan_map[frq_indx].chan)
3075 {
3076 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3077 range->freq[index].e = 1;
3078 break;
3079 }
3080 frq_indx++;
3081 }
3082 }
3083
3084 /* Event capability (kernel + driver) */
3085 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3086 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3087 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3088 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3089
3090 /*Encryption capability*/
3091 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3092 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3093
3094 /* Txpower capability */
3095 range->txpower_capa = IW_TXPOW_MWATT;
3096
3097 /*Scanning capability*/
3098 #if WIRELESS_EXT >= 22
3099 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3100 #endif
3101
3102 EXIT();
3103 return 0;
3104}
3105
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303106static int iw_get_range(struct net_device *dev,
3107 struct iw_request_info *info,
3108 union iwreq_data *wrqu, char *extra)
3109{
3110 int ret;
3111
3112 vos_ssr_protect(__func__);
3113 ret = __iw_get_range(dev, info, wrqu, extra);
3114 vos_ssr_unprotect(__func__);
3115
3116 return ret;
3117}
3118
Jeff Johnson295189b2012-06-20 16:38:30 -07003119/* Callback function registered with PMC to know status of PMC request */
3120static void iw_power_callback_fn (void *pContext, eHalStatus status)
3121{
3122 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003123
3124 if (NULL == pContext)
3125 {
3126 hddLog(VOS_TRACE_LEVEL_ERROR,
3127 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003128 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 return;
3130 }
3131
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003133
Jeff Johnson72a40512013-12-19 10:14:15 -08003134 /* there is a race condition that exists between this callback
3135 function and the caller since the caller could time out either
3136 before or while this code is executing. we use a spinlock to
3137 serialize these actions */
3138 spin_lock(&hdd_context_lock);
3139
3140 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 {
3142 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003143 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003145 "%s: Invalid context, magic [%08x]",
3146 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003147
3148 if (ioctl_debug)
3149 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003150 pr_info("%s: Invalid context, magic [%08x]\n",
3151 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 }
3153 return;
3154 }
3155
Jeff Johnson72a40512013-12-19 10:14:15 -08003156 /* context is valid so caller is still waiting */
3157
3158 /* paranoia: invalidate the magic */
3159 pStatsContext->magic = 0;
3160
3161 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003163
3164 /* serialization is complete */
3165 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003166}
3167
3168/* Callback function for tx per hit */
3169void hdd_tx_per_hit_cb (void *pCallbackContext)
3170{
3171 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3172 unsigned char tx_fail[16];
3173 union iwreq_data wrqu;
3174
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303175 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003177 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 return;
3179 }
3180 memset(&wrqu, 0, sizeof(wrqu));
3181 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3182 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3183}
3184
3185void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3186{
3187 struct statsContext *pStatsContext;
3188 tCsrGlobalClassAStatsInfo *pClassAStats;
3189 hdd_adapter_t *pAdapter;
3190
3191 if (ioctl_debug)
3192 {
3193 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003194 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 }
3196
3197 if ((NULL == pStats) || (NULL == pContext))
3198 {
3199 hddLog(VOS_TRACE_LEVEL_ERROR,
3200 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003201 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 return;
3203 }
3204
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 pClassAStats = pStats;
3206 pStatsContext = pContext;
3207 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003208
3209 /* there is a race condition that exists between this callback
3210 function and the caller since the caller could time out either
3211 before or while this code is executing. we use a spinlock to
3212 serialize these actions */
3213 spin_lock(&hdd_context_lock);
3214
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3216 {
3217 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003218 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 hddLog(VOS_TRACE_LEVEL_WARN,
3220 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003221 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 if (ioctl_debug)
3223 {
3224 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003225 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 }
3227 return;
3228 }
3229
Jeff Johnson72a40512013-12-19 10:14:15 -08003230 /* context is valid so caller is still waiting */
3231
3232 /* paranoia: invalidate the magic */
3233 pStatsContext->magic = 0;
3234
3235 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003236 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3237
Jeff Johnson72a40512013-12-19 10:14:15 -08003238 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003240
3241 /* serialization is complete */
3242 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243}
3244
3245VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3246{
3247 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3248 eHalStatus hstatus;
3249 long lrc;
3250 struct statsContext context;
3251
3252 if (NULL == pAdapter)
3253 {
3254 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3255 return VOS_STATUS_E_FAULT;
3256 }
3257 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3258 {
3259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3260 return VOS_STATUS_SUCCESS;
3261 }
3262
3263 /* we are connected
3264 prepare our callback context */
3265 init_completion(&context.completion);
3266 context.pAdapter = pAdapter;
3267 context.magic = STATS_CONTEXT_MAGIC;
3268 /* query only for Class A statistics (which include link speed) */
3269 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3270 eCSR_HDD,
3271 SME_GLOBAL_CLASSA_STATS,
3272 hdd_GetClassA_statisticsCB,
3273 0, // not periodic
3274 FALSE, //non-cached results
3275 pHddStaCtx->conn_info.staId[0],
3276 &context);
3277 if (eHAL_STATUS_SUCCESS != hstatus)
3278 {
3279 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003280 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003281 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 /* we'll returned a cached value below */
3283 }
3284 else
3285 {
3286 /* request was sent -- wait for the response */
3287 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3288 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 if (lrc <= 0)
3290 {
3291 hddLog(VOS_TRACE_LEVEL_ERROR,
3292 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003293 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 }
3295 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003296
3297 /* either we never sent a request, we sent a request and received a
3298 response or we sent a request and timed out. if we never sent a
3299 request or if we sent a request and got a response, we want to
3300 clear the magic out of paranoia. if we timed out there is a
3301 race condition such that the callback function could be
3302 executing at the same time we are. of primary concern is if the
3303 callback function had already verified the "magic" but had not
3304 yet set the completion variable when a timeout occurred. we
3305 serialize these activities by invalidating the magic while
3306 holding a shared spinlock which will cause us to block if the
3307 callback is currently executing */
3308 spin_lock(&hdd_context_lock);
3309 context.magic = 0;
3310 spin_unlock(&hdd_context_lock);
3311
3312 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 return VOS_STATUS_SUCCESS;
3314}
3315
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003316static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3317{
3318 struct statsContext *pStatsContext;
3319 tCsrSummaryStatsInfo *pSummaryStats;
3320 tCsrGlobalClassAStatsInfo *pClassAStats;
3321 hdd_adapter_t *pAdapter;
3322
3323 if (ioctl_debug)
3324 {
3325 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003326 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003327 }
3328
3329 if ((NULL == pStats) || (NULL == pContext))
3330 {
3331 hddLog(VOS_TRACE_LEVEL_ERROR,
3332 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003333 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003334 return;
3335 }
3336
Jeff Johnson72a40512013-12-19 10:14:15 -08003337 /* there is a race condition that exists between this callback
3338 function and the caller since the caller could time out either
3339 before or while this code is executing. we use a spinlock to
3340 serialize these actions */
3341 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003342
3343 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3344 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3345 pStatsContext = pContext;
3346 pAdapter = pStatsContext->pAdapter;
3347 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3348 {
3349 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003350 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003351 hddLog(VOS_TRACE_LEVEL_WARN,
3352 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003353 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003354 if (ioctl_debug)
3355 {
3356 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003357 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003358 }
3359 return;
3360 }
3361
Jeff Johnson72a40512013-12-19 10:14:15 -08003362 /* context is valid so caller is still waiting */
3363
3364 /* paranoia: invalidate the magic */
3365 pStatsContext->magic = 0;
3366
3367 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003368 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3369 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3370
Jeff Johnson72a40512013-12-19 10:14:15 -08003371 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003372 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003373
3374 /* serialization is complete */
3375 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003376}
3377
3378VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3379{
3380 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3381 eHalStatus hstatus;
3382 long lrc;
3383 struct statsContext context;
3384
3385 if (NULL == pAdapter)
3386 {
3387 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3388 return VOS_STATUS_SUCCESS;
3389 }
3390
3391 /* we are connected
3392 prepare our callback context */
3393 init_completion(&context.completion);
3394 context.pAdapter = pAdapter;
3395 context.magic = STATS_CONTEXT_MAGIC;
3396
3397 /* query only for Summary & Class A statistics */
3398 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3399 eCSR_HDD,
3400 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303401 SME_GLOBAL_CLASSA_STATS |
3402 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003403 hdd_get_station_statisticsCB,
3404 0, // not periodic
3405 FALSE, //non-cached results
3406 pHddStaCtx->conn_info.staId[0],
3407 &context);
3408 if (eHAL_STATUS_SUCCESS != hstatus)
3409 {
3410 hddLog(VOS_TRACE_LEVEL_ERROR,
3411 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003412 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003413 /* we'll return with cached values */
3414 }
3415 else
3416 {
3417 /* request was sent -- wait for the response */
3418 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3419 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003420
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003421 if (lrc <= 0)
3422 {
3423 hddLog(VOS_TRACE_LEVEL_ERROR,
3424 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003425 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003426 }
3427 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003428
3429 /* either we never sent a request, we sent a request and received a
3430 response or we sent a request and timed out. if we never sent a
3431 request or if we sent a request and got a response, we want to
3432 clear the magic out of paranoia. if we timed out there is a
3433 race condition such that the callback function could be
3434 executing at the same time we are. of primary concern is if the
3435 callback function had already verified the "magic" but had not
3436 yet set the completion variable when a timeout occurred. we
3437 serialize these activities by invalidating the magic while
3438 holding a shared spinlock which will cause us to block if the
3439 callback is currently executing */
3440 spin_lock(&hdd_context_lock);
3441 context.magic = 0;
3442 spin_unlock(&hdd_context_lock);
3443
3444 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003445 return VOS_STATUS_SUCCESS;
3446}
3447
3448
Jeff Johnson295189b2012-06-20 16:38:30 -07003449/*
3450 * Support for the LINKSPEED private command
3451 * Per the WiFi framework the response must be of the form
3452 * "LinkSpeed xx"
3453 */
3454static int iw_get_linkspeed(struct net_device *dev,
3455 struct iw_request_info *info,
3456 union iwreq_data *wrqu, char *extra)
3457{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303458 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303459 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303461 int len = sizeof(v_U32_t) + 1;
3462 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303463 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303464 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303465 int rc, valid = 0;
3466
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303467 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303468 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3469 if (NULL == pAdapter)
3470 {
3471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3472 "%s: Adapter is NULL",__func__);
3473 return -EINVAL;
3474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003475
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303476 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303477 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303478 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003479 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303480 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003481 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303482 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3483 if (NULL == pHddStaCtx)
3484 {
3485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3486 "%s: STA Context is NULL",__func__);
3487 return -EINVAL;
3488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3490 {
3491 /* we are not connected so we don't have a classAstats */
3492 link_speed = 0;
3493 }
3494 else
3495 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303496 status = wlan_hdd_get_classAstats(pAdapter);
3497
3498 if (!VOS_IS_STATUS_SUCCESS(status ))
3499 {
3500 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3501 return -EINVAL;
3502 }
3503
3504 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3505 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3506 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3507 &link_speed);
3508
3509 link_speed = link_speed / 10;
3510
3511 if (0 == link_speed)
3512 {
3513 /* The linkspeed returned by HAL is in units of 500kbps.
3514 * converting it to mbps.
3515 * This is required to support legacy firmware which does
3516 * not return link capacity.
3517 */
3518 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3519 }
3520
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 }
3522
3523 wrqu->data.length = len;
3524 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003525 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 if ((rc < 0) || (rc >= len))
3527 {
3528 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303529 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 return -EIO;
3531 }
3532
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303533 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003535 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003536}
3537
Arif Hussain695279c2014-03-24 14:06:07 -07003538/*
3539 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3540 *
3541 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303542static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003543 struct iw_request_info *info,
3544 union iwreq_data *wrqu, char *extra)
3545{
3546 int rc;
3547
3548 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3549
3550 if (rc < 0)
3551 return rc;
3552
3553 /* a value is being successfully returned */
3554 return 0;
3555}
Jeff Johnson295189b2012-06-20 16:38:30 -07003556
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303557static int iw_get_linkspeed_priv(struct net_device *dev,
3558 struct iw_request_info *info,
3559 union iwreq_data *wrqu, char *extra)
3560{
3561 int ret;
3562
3563 vos_ssr_protect(__func__);
3564 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3565 vos_ssr_unprotect(__func__);
3566
3567 return ret;
3568}
3569
Jeff Johnson295189b2012-06-20 16:38:30 -07003570/*
3571 * Support for the RSSI & RSSI-APPROX private commands
3572 * Per the WiFi framework the response must be of the form
3573 * "<ssid> rssi <xx>"
3574 * unless we are not associated, in which case the response is
3575 * "OK"
3576 */
3577static int iw_get_rssi(struct net_device *dev,
3578 struct iw_request_info *info,
3579 union iwreq_data *wrqu, char *extra)
3580{
3581 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003582 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 int len = wrqu->data.length;
3584 v_S7_t s7Rssi = 0;
3585 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3586 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3587 VOS_STATUS vosStatus;
3588 int rc;
3589
3590 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3591 (0 == ssidlen) || (ssidlen >= len))
3592 {
3593 /* we are not connected or our SSID is too long
3594 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003595 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 }
3597 else
3598 {
3599 /* we are connected with a valid SSID
3600 so we can write the SSID into the return buffer
3601 (note that it is not NUL-terminated) */
3602 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3603
3604 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3605
3606 if (VOS_STATUS_SUCCESS == vosStatus)
3607 {
3608 /* append the rssi to the ssid in the format required by
3609 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003610 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303611 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 }
3613 else
3614 {
3615 rc = -1;
3616 }
3617 }
3618
3619 /* verify that we wrote a valid response */
3620 if ((rc < 0) || (rc >= len))
3621 {
3622 // encoding or length error?
3623 hddLog(VOS_TRACE_LEVEL_ERROR,
3624 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003625 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 return -EIO;
3627 }
3628
3629 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003630 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003631}
3632
3633/*
3634 * Support for SoftAP channel range private command
3635 */
3636static int iw_softap_set_channel_range( struct net_device *dev,
3637 int startChannel,
3638 int endChannel,
3639 int band)
3640{
Jeff Johnson43971f52012-07-17 12:26:56 -07003641 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 int ret = 0;
3643 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3644 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003645 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3646
Jeff Johnson295189b2012-06-20 16:38:30 -07003647
3648 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3649 if (VOS_STATUS_SUCCESS != status)
3650 {
3651 ret = -EINVAL;
3652 }
Yathish9f22e662012-12-10 14:21:35 -08003653 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 return ret;
3655}
3656
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303657static uint8 chartohex(char c)
3658{
3659 uint8 val = 0;
3660 if (c >= '0' && c <= '9')
3661 val = c - '0';
3662 else if (c >= 'a' && c <= 'f')
3663 val = c - 'a' + 10;
3664 else if (c >= 'A' && c <= 'F')
3665 val = c - 'A' + 10;
3666 else
3667 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3668
3669 return val;
3670}
3671
3672uint8 getByte(char **buf)
3673{
3674 uint8 byte = 0;
3675 char *temp = *buf;
3676 byte = chartohex(*temp) * 16;
3677 temp++;
3678 byte += chartohex(*temp);
3679 temp++;
3680 *buf = temp;
3681 return byte;
3682}
3683
3684static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3685{
3686 tSir80211Header *macHeader;
3687 int i = 0, j = 0, length = 0;
3688 uint8 byte = 0;
3689 char *temp = pBuffer;
3690 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303691 char *pHeader;
3692 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303693
3694 macHeader = &pkt->macHeader;
3695
3696 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3697
3698 temp++;
3699
3700 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3701 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3702 pkt->encParams.keyParams.key[0].keyId);
3703
3704 for (i = 0; i< 16; i++) {
3705 pkt->encParams.keyParams.key[0].key[i]
3706 = getByte(&temp);
3707 }
3708
3709 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3710 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3711
3712 for (i = 0; i< 6; i++) {
3713 pkt->encParams.pn[i]
3714 = getByte(&temp);
3715 }
3716
3717 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3718 &pkt->encParams.pn[0], 6, 0);
3719
3720 for (i = 0, j= 5; i< 3; i++, j--) {
3721 byte = pkt->encParams.pn[i];
3722 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3723 pkt->encParams.pn[j] = byte;
3724 }
3725
3726 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303727 if (length > sizeof(tSir80211Header))
3728 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303729
Srinivas Dasari2382de62015-01-22 15:00:04 +05303730 pHeader = temp;
3731 vos_mem_zero(&header, sizeof(tSir80211Header));
3732 for (i = 0; i < length; i++) {
3733 *((uint8 *)&header + i) = getByte(&pHeader);
3734 }
3735
3736 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3737 (char *)&header, length, 0);
3738
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303739 byte = getByte(&temp);
3740
3741 macHeader->frameCtrl.protVer = byte & 0x3;
3742 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3743 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3744
3745 byte = getByte(&temp);
3746 macHeader->frameCtrl.toDS = (byte) & 0x1;
3747 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3748 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3749 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3750 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3751 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3752 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3753 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3754
3755 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3756 "macHeader->frameCtrl.type : %x "
3757 "macHeader->frameCtrl.subType : %x "
3758 "macHeader->frameCtrl.toDS : %x "
3759 "macHeader->frameCtrl.fromDS : %x "
3760 "macHeader->frameCtrl.moreFrag : %x "
3761 "macHeader->frameCtrl.retry : %x "
3762 "macHeader->frameCtrl.powerMgmt : %x "
3763 "macHeader->frameCtrl.MoreData : %x "
3764 "macHeader->frameCtrl.wep : %x "
3765 "macHeader->frameCtrl.order : %x "
3766 , macHeader->frameCtrl.protVer
3767 , macHeader->frameCtrl.type
3768 , macHeader->frameCtrl.subType
3769 , macHeader->frameCtrl.toDS
3770 , macHeader->frameCtrl.fromDS
3771 , macHeader->frameCtrl.moreFrag
3772 , macHeader->frameCtrl.retry
3773 , macHeader->frameCtrl.powerMgmt
3774 , macHeader->frameCtrl.moreData
3775 , macHeader->frameCtrl.wep
3776 , macHeader->frameCtrl.order);
3777
3778
3779 macHeader->usDurationId = getByte(&temp);
3780 macHeader->usDurationId += getByte(&temp) << 8;
3781
3782 macHeader->vA1[0] = getByte(&temp);
3783 macHeader->vA1[1] = getByte(&temp);
3784 macHeader->vA1[2] = getByte(&temp);
3785 macHeader->vA1[3] = getByte(&temp);
3786 macHeader->vA1[4] = getByte(&temp);
3787 macHeader->vA1[5] = getByte(&temp);
3788
3789 macHeader->vA2[0] = getByte(&temp);
3790 macHeader->vA2[1] = getByte(&temp);
3791 macHeader->vA2[2] = getByte(&temp);
3792 macHeader->vA2[3] = getByte(&temp);
3793 macHeader->vA2[4] = getByte(&temp);
3794 macHeader->vA2[5] = getByte(&temp);
3795
3796 macHeader->vA3[0] = getByte(&temp);
3797 macHeader->vA3[1] = getByte(&temp);
3798 macHeader->vA3[2] = getByte(&temp);
3799 macHeader->vA3[3] = getByte(&temp);
3800 macHeader->vA3[4] = getByte(&temp);
3801 macHeader->vA3[5] = getByte(&temp);
3802
3803 macHeader->sSeqCtrl = getByte(&temp);
3804 fragNum = macHeader->sSeqCtrl & 0xF;
3805 macHeader->sSeqCtrl >>= 4;
3806
3807 macHeader->sSeqCtrl += getByte(&temp) << 4;
3808
3809 macHeader->sSeqCtrl |= fragNum << 12;
3810
3811 if (length == 30 || length == 32) {
3812 macHeader->optvA4[0] = getByte(&temp);
3813 macHeader->optvA4[1] = getByte(&temp);
3814 macHeader->optvA4[2] = getByte(&temp);
3815 macHeader->optvA4[3] = getByte(&temp);
3816 macHeader->optvA4[4] = getByte(&temp);
3817 macHeader->optvA4[5] = getByte(&temp);
3818 }
3819
3820 if (length == 26 || length == 32) {
3821 macHeader->usQosCtrl = getByte(&temp);
3822 macHeader->usQosCtrl += getByte(&temp) << 8;
3823 }
3824
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303825 //parse payload
3826 length = getByte(&temp);
3827 length += getByte(&temp) << 8;
3828 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3829
3830 pkt->data.length = length;
3831
3832 for (i = 0; i< length; i++) {
3833 pkt->data.data[i] = getByte(&temp);
3834 }
3835
3836 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3837 &pkt->data.data[0], pkt->data.length, 0);
3838}
3839
3840/**---------------------------------------------------------------------------
3841
3842 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3843 encrypt message request
3844 This is an asynchronous callback function from SME when the encrypted data
3845 is received
3846
3847 \pEncInfoRsp -> Encrypted data info
3848
3849 \return - 0 for success non-zero for failure
3850 --------------------------------------------------------------------------*/
3851static void
3852hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3853{
3854 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3855
3856 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3857
3858 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3859 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3860 pEncryptedDataRsp->encryptedPayload.length);
3861 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3862 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3863 pEncryptedDataRsp->encryptedPayload.data,
3864 pEncryptedDataRsp->encryptedPayload.length, 0);
3865}
3866
Jeff Johnson295189b2012-06-20 16:38:30 -07003867VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3868{
3869 struct statsContext context;
3870 eHalStatus status;
3871 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303872 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003873
3874 if (NULL == pAdapter)
3875 {
3876 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3877 return VOS_STATUS_E_FAULT;
3878 }
3879
3880 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3881 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303882 if (pHddCtx->isLogpInProgress) {
3883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3884 "%s:LOGP in Progress. Ignore!!!", __func__);
3885 return VOS_STATUS_E_FAILURE;
3886 }
3887
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 init_completion(&context.completion);
3889
3890 context.pAdapter = pAdapter;
3891 context.magic = POWER_CONTEXT_MAGIC;
3892
3893 if (DRIVER_POWER_MODE_ACTIVE == mode)
3894 {
3895 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3896 "Full Power", __func__);
3897 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3898 iw_power_callback_fn, &context,
3899 eSME_FULL_PWR_NEEDED_BY_HDD);
3900 // Enter Full power command received from GUI this means we are disconnected
3901 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3902 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3903 if (eHAL_STATUS_PMC_PENDING == status)
3904 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003905 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 int lrc = wait_for_completion_interruptible_timeout(
3907 &context.completion,
3908 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003909
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 if (lrc <= 0)
3911 {
3912 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003913 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 }
3915 }
3916 }
3917 else if (DRIVER_POWER_MODE_AUTO == mode)
3918 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303919 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
3920 * was already in BMPS state and thus either STA or P2P-CLI is in
3921 * associated state and authenticated, so even if STA connState is
3922 * not associated it can be assumed that P2P-CLI is associated and
3923 * authenticated. Thus driver can enter BMPS. And even if we try to enter
3924 * BMPS with no adaptor in associated state, pmcRequestBmps will check
3925 * if all condition are satisfied for entering BMPS.
3926 */
3927 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
3928 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303929 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303930 hddLog(LOGE,
3931 FL("Station is associated but, still not Authenticated ignore "
3932 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303933 return VOS_STATUS_E_AGAIN;
3934 }
3935
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3937 {
3938 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3939 __func__);
3940 // Enter BMPS command received from GUI this means DHCP is completed
3941 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3942 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3943 FALSE);
3944 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3945 iw_power_callback_fn, &context);
3946 if (eHAL_STATUS_PMC_PENDING == status)
3947 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003948 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 int lrc = wait_for_completion_interruptible_timeout(
3950 &context.completion,
3951 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 if (lrc <= 0)
3953 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003954 hddLog(VOS_TRACE_LEVEL_ERROR,
3955 "%s: SME %s while requesting BMPS",
3956 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 }
3958 }
3959 }
3960 else
3961 {
3962 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3963 "enabled in the cfg");
3964 }
3965 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003966
3967 /* either we never sent a request, we sent a request and received a
3968 response or we sent a request and timed out. if we never sent a
3969 request or if we sent a request and got a response, we want to
3970 clear the magic out of paranoia. if we timed out there is a
3971 race condition such that the callback function could be
3972 executing at the same time we are. of primary concern is if the
3973 callback function had already verified the "magic" but had not
3974 yet set the completion variable when a timeout occurred. we
3975 serialize these activities by invalidating the magic while
3976 holding a shared spinlock which will cause us to block if the
3977 callback is currently executing */
3978 spin_lock(&hdd_context_lock);
3979 context.magic = 0;
3980 spin_unlock(&hdd_context_lock);
3981
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 return VOS_STATUS_SUCCESS;
3983}
3984
3985VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3986 hdd_adapter_t *pAdapter)
3987{
3988 VOS_STATUS vos_Status;
3989
3990 if ((NULL == pAdapter) || (NULL == pHddCtx))
3991 {
3992 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3993 return VOS_STATUS_E_FAULT;
3994 }
3995
3996 /**Exit from Deep sleep or standby if we get the driver
3997 START cmd from android GUI
3998 */
3999 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4000 {
4001 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4002 "from Stand by",__func__);
4003 vos_Status = hdd_exit_standby(pHddCtx);
4004 }
4005 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4006 {
4007 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4008 "from deep sleep",__func__);
4009 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4010 }
4011 else
4012 {
4013 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4014 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4015 vos_Status = VOS_STATUS_SUCCESS;
4016 }
4017
4018 return vos_Status;
4019}
4020
4021VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4022{
4023 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4024
4025 if (NULL == pHddCtx)
4026 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304027 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 return VOS_STATUS_E_FAULT;
4029 }
4030
4031 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4032 {
4033 //Execute standby procedure.
4034 //Executing standby procedure will cause the STA to
4035 //disassociate first and then the chip will be put into standby.
4036 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4037 vos_Status = hdd_enter_standby(pHddCtx);
4038 }
4039 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4040 pHddCtx->cfg_ini->nEnableDriverStop)
4041 {
4042 //Execute deep sleep procedure
4043 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004044 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 //Deep sleep not supported
4046 vos_Status = hdd_enter_standby(pHddCtx);
4047 }
4048 else
4049 {
4050 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4051 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4052 vos_Status = VOS_STATUS_SUCCESS;
4053 }
4054
4055 return vos_Status;
4056}
4057
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004058
4059void* wlan_hdd_change_country_code_callback(void *pAdapter)
4060{
4061
4062 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004063 complete(&call_back_pAdapter->change_country_code);
4064
4065 return NULL;
4066}
4067
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304068static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 struct iw_request_info *info,
4070 union iwreq_data *wrqu, char *extra)
4071{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304072 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004073 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304075 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004076 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4077
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304078 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004079
4080 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304081
4082 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4083 if (NULL == pAdapter)
4084 {
4085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4086 "mem_alloc_copy_from_user_helper fail");
4087 return -EINVAL;
4088 }
4089 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4090 rc = wlan_hdd_validate_context(pHddCtx);
4091 if (0 != rc)
4092 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304093 return rc;
4094 }
4095
Arif Hussain24bfa702014-01-22 13:51:30 -08004096 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4097 wrqu->data.length);
4098 if (NULL == cmd)
4099 {
4100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4101 "mem_alloc_copy_from_user_helper fail");
4102 return -ENOMEM;
4103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004104
4105 if (ioctl_debug)
4106 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004107 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 }
4109
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004110 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4111 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004112
Arif Hussain24bfa702014-01-22 13:51:30 -08004113 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004115 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4117 "%s: Error in iw_set_scan!", __func__);
4118 rc = -EINVAL;
4119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 }
4121 else if( strcasecmp(cmd, "start") == 0 ) {
4122
Arif Hussain6d2a3322013-11-17 19:50:10 -08004123 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004125
Arif Hussain24bfa702014-01-22 13:51:30 -08004126 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4127 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 {
4129 union iwreq_data wrqu;
4130 char buf[10];
4131
4132 memset(&wrqu, 0, sizeof(wrqu));
4133 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4134 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4135 }
4136 else
4137 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004138 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4139 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 }
4141 goto done;
4142 }
4143 else if( strcasecmp(cmd, "stop") == 0 )
4144 {
4145 union iwreq_data wrqu;
4146 char buf[10];
4147
Arif Hussain6d2a3322013-11-17 19:50:10 -08004148 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004149
4150 wlan_hdd_enter_lowpower(pHddCtx);
4151 memset(&wrqu, 0, sizeof(wrqu));
4152 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4153 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 goto done;
4155 }
4156 else if (strcasecmp(cmd, "macaddr") == 0)
4157 {
4158 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4159 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4160 }
4161 else if (strcasecmp(cmd, "scan-active") == 0)
4162 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304163 hddLog(VOS_TRACE_LEVEL_ERROR,
4164 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004165 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 ret = snprintf(cmd, cmd_len, "OK");
4167 }
4168 else if (strcasecmp(cmd, "scan-passive") == 0)
4169 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304170 hddLog(VOS_TRACE_LEVEL_ERROR,
4171 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004172 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 ret = snprintf(cmd, cmd_len, "OK");
4174 }
4175 else if( strcasecmp(cmd, "scan-mode") == 0 )
4176 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004177 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 }
4179 else if( strcasecmp(cmd, "linkspeed") == 0 )
4180 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004181 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 }
4183 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4184 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004185 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004186 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004187
4188 country_code = cmd + 8;
4189
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004190 init_completion(&pAdapter->change_country_code);
4191
Arif Hussain24bfa702014-01-22 13:51:30 -08004192 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004193 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 country_code,
4195 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304196 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304197 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304198 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004199
4200 /* Wait for completion */
4201 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4202 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4203
4204 if (lrc <= 0)
4205 {
4206 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004207 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004208 }
4209
Arif Hussain24bfa702014-01-22 13:51:30 -08004210 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004211 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004212 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004213 "%s: SME Change Country code fail", __func__);
4214 kfree(cmd);
4215 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 }
4217 }
4218 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4219 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004220 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 }
4222 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4223 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004224 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004225
Wilson Yang1be3e652013-10-09 15:18:31 -07004226 if (9 < cmd_len)
4227 {
4228 ptr = (char*)(cmd + 9);
4229
4230 }else{
4231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4232 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004233 kfree(cmd);
4234 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004235 }
4236
4237 if (1 != sscanf(ptr,"%d",&mode))
4238 {
4239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4240 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004241 kfree(cmd);
4242 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004243 }
4244
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 wlan_hdd_enter_bmps(pAdapter, mode);
4246 /*TODO:Set the power mode*/
4247 }
4248 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4249 v_U32_t pmc_state;
4250 v_U16_t value;
4251
4252 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4253 if(pmc_state == BMPS) {
4254 value = DRIVER_POWER_MODE_AUTO;
4255 }
4256 else {
4257 value = DRIVER_POWER_MODE_ACTIVE;
4258 }
4259 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4260 }
4261 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004262 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 /*TODO: set the btcoexmode*/
4264 }
4265 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4266
Arif Hussain6d2a3322013-11-17 19:50:10 -08004267 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 /*TODO: Return the btcoex status*/
4269 }
4270 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4271
Arif Hussain6d2a3322013-11-17 19:50:10 -08004272 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004273
4274 /*TODO: Enable Rx data Filter*/
4275 }
4276 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4277
Arif Hussain6d2a3322013-11-17 19:50:10 -08004278 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004279
4280 /*TODO: Disable Rx data Filter*/
4281 }
4282 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4283
Arif Hussain6d2a3322013-11-17 19:50:10 -08004284 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 /*TODO: rxfilter-statistics*/
4286 }
4287 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4288
Arif Hussain6d2a3322013-11-17 19:50:10 -08004289 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 /*TODO: rxfilter-add*/
4291 }
4292 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4293
Arif Hussain6d2a3322013-11-17 19:50:10 -08004294 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 /*TODO: rxfilter-remove*/
4296 }
4297#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004298 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4299 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4300 /*TODO: support pnosetup*/
4301 }
4302 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4303 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4304 /*TODO: support pnoforce*/
4305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4307
Arif Hussain6d2a3322013-11-17 19:50:10 -08004308 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004309 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4310 kfree(cmd);
4311 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 }
4313 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004314 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004315 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4316 kfree(cmd);
4317 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 }
4319#endif /*FEATURE_WLAN_SCAN_PNO*/
4320 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004321 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004322 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4323 kfree(cmd);
4324 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 }
4326 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4327 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004328 char *ptr;
4329
4330 if (18 < cmd_len)
4331 {
4332 ptr = (char*)(cmd + 18);
4333 }else{
4334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4335 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004336 kfree(cmd);
4337 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004338 }
4339
Jeff Johnson02797792013-10-26 19:17:13 -07004340 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004341 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4342 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4343 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4344 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4345 {
4346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4347 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004348 kfree(cmd);
4349 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004351
4352 // parameters checking
4353 // period has to be larger than 0
4354 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4355 {
4356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004357 kfree(cmd);
4358 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 }
4360
4361 // use default value 5 is the input is not reasonable. in unit of 10%
4362 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4363 {
4364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4365 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4366 }
4367
4368 // default is 5
4369 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4370 {
4371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4372 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4373 }
4374
Arif Hussain24bfa702014-01-22 13:51:30 -08004375 if (eHAL_STATUS_SUCCESS !=
4376 sme_SetTxPerTracking(pHddCtx->hHal,
4377 hdd_tx_per_hit_cb,
4378 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004380 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 }
4382 }
4383 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004384 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4385 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 }
4387done:
4388 /* many of the commands write information back into the command
4389 string using snprintf(). check the return value here in one
4390 place */
4391 if ((ret < 0) || (ret >= cmd_len))
4392 {
4393 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004394 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004396 else if (ret > 0)
4397 {
4398 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4399 {
4400 hddLog(VOS_TRACE_LEVEL_ERROR,
4401 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004402 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004403 return -EFAULT;
4404 }
4405 wrqu->data.length = ret;
4406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004407
4408 if (ioctl_debug)
4409 {
4410 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004411 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004413 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304414 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004415 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004416}
4417
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304418static int iw_set_priv(struct net_device *dev,
4419 struct iw_request_info *info,
4420 union iwreq_data *wrqu, char *extra)
4421{
4422 int ret;
4423 vos_ssr_protect(__func__);
4424 ret = __iw_set_priv(dev, info, wrqu, extra);
4425 vos_ssr_unprotect(__func__);
4426
4427 return ret;
4428}
4429
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304430static int __iw_set_nick(struct net_device *dev,
4431 struct iw_request_info *info,
4432 union iwreq_data *wrqu, char *extra)
4433{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304434 hdd_adapter_t *pAdapter;
4435 hdd_context_t *pHddCtx;
4436 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304437
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304438 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304439
4440 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4441 if (NULL == pAdapter)
4442 {
4443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4444 "%s: Adapter is NULL",__func__);
4445 return -EINVAL;
4446 }
4447
4448 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4449 ret = wlan_hdd_validate_context(pHddCtx);
4450 if (0 != ret)
4451 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304452 return ret;
4453 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304454 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304455 return 0;
4456}
4457
Jeff Johnson295189b2012-06-20 16:38:30 -07004458static int iw_set_nick(struct net_device *dev,
4459 struct iw_request_info *info,
4460 union iwreq_data *wrqu, char *extra)
4461{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304462 int ret;
4463
4464 vos_ssr_protect(__func__);
4465 ret = __iw_set_nick(dev, info, wrqu, extra);
4466 vos_ssr_unprotect(__func__);
4467
4468 return ret;
4469}
4470
4471static int __iw_get_nick(struct net_device *dev,
4472 struct iw_request_info *info,
4473 union iwreq_data *wrqu, char *extra)
4474{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304475 hdd_adapter_t *pAdapter;
4476 hdd_context_t *pHddCtx;
4477 int ret = 0;
4478
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304480
4481 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4482 if (NULL == pAdapter)
4483 {
4484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4485 "%s: Adapter is NULL",__func__);
4486 return -EINVAL;
4487 }
4488
4489 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4490 ret = wlan_hdd_validate_context(pHddCtx);
4491 if (0 != ret)
4492 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304493 return ret;
4494 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304495 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 return 0;
4497}
4498
4499static int iw_get_nick(struct net_device *dev,
4500 struct iw_request_info *info,
4501 union iwreq_data *wrqu, char *extra)
4502{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304503 int ret;
4504
4505 vos_ssr_protect(__func__);
4506 ret = __iw_get_nick(dev, info, wrqu, extra);
4507 vos_ssr_unprotect(__func__);
4508
4509 return ret;
4510}
4511
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304512/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304513static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4514{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304515 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4516 hdd_context_t *pHddCtx;
4517 hdd_station_ctx_t *pHddStaCtx;
4518 v_S7_t snr = 0, rssi = 0;
4519 eHalStatus status = eHAL_STATUS_SUCCESS;
4520
4521 ENTER();
4522
4523 if (NULL == pAdapter)
4524 {
4525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4526 "%s: Adapter is NULL",__func__);
4527 return NULL;
4528 }
4529
4530 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4531 status = wlan_hdd_validate_context(pHddCtx);
4532 if (0 != status)
4533 {
4534 return NULL;
4535 }
4536
4537 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4538 if (NULL == pHddStaCtx)
4539 {
4540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4541 "%s: STA Context is NULL",__func__);
4542 return NULL;
4543 }
4544
4545 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4546 {
4547 wlan_hdd_get_station_stats(pAdapter);
4548 wlan_hdd_get_snr(pAdapter, &snr);
4549 wlan_hdd_get_rssi(pAdapter, &rssi);
4550
4551 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4552 pAdapter->iwStats.status = 0;
4553 pAdapter->iwStats.qual.qual = snr;
4554 pAdapter->iwStats.qual.level = rssi;
4555 pAdapter->iwStats.qual.noise = rssi - snr;
4556 pAdapter->iwStats.discard.code = 0;
4557 pAdapter->iwStats.discard.retries= 0;
4558 pAdapter->iwStats.miss.beacon = 0;
4559 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4560 }
4561 else
4562 {
4563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4564 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4565 return NULL;
4566 }
4567
4568 EXIT();
4569 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004570}
4571
4572static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4573{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304574
4575 struct iw_statistics *stats;
4576
4577 vos_ssr_protect(__func__);
4578 stats = __get_wireless_stats(dev);
4579 vos_ssr_unprotect(__func__);
4580
4581 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004582}
4583
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304584static int __iw_set_encode(struct net_device *dev,
4585 struct iw_request_info *info,
4586 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004587
4588{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304589 hdd_adapter_t *pAdapter;
4590 hdd_station_ctx_t *pHddStaCtx;
4591 hdd_wext_state_t *pWextState;
4592 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 struct iw_point *encoderq = &(wrqu->encoding);
4594 v_U32_t keyId;
4595 v_U8_t key_length;
4596 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4597 v_BOOL_t fKeyPresent = 0;
4598 int i;
4599 eHalStatus status = eHAL_STATUS_SUCCESS;
4600
4601
4602 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304603 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4604 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4607 "%s: Adapter is NULL",__func__);
4608 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 }
4610
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4612 status = wlan_hdd_validate_context(pHddCtx);
4613 if (0 != status)
4614 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304615 return status;
4616 }
4617 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4618 if (NULL == pWextState)
4619 {
4620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4621 "%s: pWextState is NULL ",__func__);
4622 return -EINVAL;
4623 }
4624 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4625 if (NULL == pHddStaCtx)
4626 {
4627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4628 "%s: STA Context is NULL",__func__);
4629 return -EINVAL;
4630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004631
4632 keyId = encoderq->flags & IW_ENCODE_INDEX;
4633
4634 if(keyId)
4635 {
4636 if(keyId > MAX_WEP_KEYS)
4637 {
4638 return -EINVAL;
4639 }
4640
4641 fKeyPresent = 1;
4642 keyId--;
4643 }
4644 else
4645 {
4646 fKeyPresent = 0;
4647 }
4648
4649
4650 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4651 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 if(!fKeyPresent) {
4654
4655 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4656
4657 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4658 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4659 }
4660 }
4661 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4662 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4663 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4664 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4665
4666 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4667 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4668
4669 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4670 {
4671 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4672 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004673 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304674 {
4675 long ret;
4676 ret = wait_for_completion_interruptible_timeout(
4677 &pAdapter->disconnect_comp_var,
4678 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4679 if (ret <= 0)
4680 hddLog(VOS_TRACE_LEVEL_ERROR,
4681 FL("failed wait on disconnect_comp_var %ld"), ret);
4682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 }
4684
4685 return status;
4686
4687 }
4688
4689 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4690 {
4691 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4692
4693 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4694
4695 }
4696
4697
4698 if(wrqu->data.length > 0)
4699 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004700 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004701
4702 key_length = wrqu->data.length;
4703
4704 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4705
4706 if(5 == key_length)
4707 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004708 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004709
4710 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4711 {
4712 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4713 }
4714 else
4715 {
4716 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4717 }
4718 }
4719 else if(13 == key_length)
4720 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004721 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004722
4723 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4724 {
4725 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4726 }
4727 else
4728 {
4729 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4730 }
4731 }
4732 else
4733 {
4734 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004735 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 return -EINVAL;
4737 }
4738
4739 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4740 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4741 pWextState->roamProfile.EncryptionType.numEntries = 1;
4742 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4743 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4744 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4745
4746 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4747 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4748 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4749 {
4750
4751 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4752
4753 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4754 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4755
4756 return status;
4757 }
4758 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304759 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 return 0;
4761}
4762
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304763static int iw_set_encode(struct net_device *dev,
4764 struct iw_request_info *info,
4765 union iwreq_data *wrqu,char *extra)
4766{
4767 int ret;
4768
4769 vos_ssr_protect(__func__);
4770 ret = __iw_set_encode(dev, info, wrqu, extra);
4771 vos_ssr_unprotect(__func__);
4772
4773 return ret;
4774}
4775
4776static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 struct iw_request_info *info,
4778 struct iw_point *dwrq,
4779 char *extra)
4780{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304781 hdd_adapter_t *pAdapter;
4782 hdd_wext_state_t *pWextState;
4783 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 int keyId;
4785 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4786 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304787 int i, ret = 0;
4788 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004789
4790 ENTER();
4791
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304792 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4793 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004794 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4796 "%s: Adapter is NULL",__func__);
4797 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004798 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304799 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4800 ret = wlan_hdd_validate_context(pHddCtx);
4801 if (0 != ret)
4802 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304803 return ret;
4804 }
4805 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4806 if (NULL == pWextState)
4807 {
4808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4809 "%s: pWextState is NULL",__func__);
4810 return -EINVAL;
4811 }
4812 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004813
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 keyId = pRoamProfile->Keys.defaultIndex;
4815
4816 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4817 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004818 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 return -EINVAL;
4820 }
4821
4822 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4823 {
4824 dwrq->flags |= IW_ENCODE_ENABLED;
4825 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304826 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4827 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 }
4829 else
4830 {
4831 dwrq->flags |= IW_ENCODE_DISABLED;
4832 }
4833
4834 for(i=0; i < MAX_WEP_KEYS; i++)
4835 {
4836 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4837 {
4838 continue;
4839 }
4840 else
4841 {
4842 break;
4843 }
4844 }
4845
4846 if(MAX_WEP_KEYS == i)
4847 {
4848 dwrq->flags |= IW_ENCODE_NOKEY;
4849 }
4850 else
4851 {
4852 dwrq->flags |= IW_ENCODE_ENABLED;
4853 }
4854
4855 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4856
4857 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4858 {
4859 dwrq->flags |= IW_ENCODE_DISABLED;
4860 }
4861
4862 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4863
4864 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4865 {
4866 dwrq->flags |= IW_ENCODE_OPEN;
4867 }
4868 else
4869 {
4870 dwrq->flags |= IW_ENCODE_RESTRICTED;
4871 }
4872 EXIT();
4873 return 0;
4874
4875}
4876
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304877static int iw_get_encodeext(struct net_device *dev,
4878 struct iw_request_info *info,
4879 struct iw_point *dwrq,
4880 char *extra)
4881{
4882 int ret;
4883 vos_ssr_protect(__func__);
4884 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4885 vos_ssr_unprotect(__func__);
4886
4887 return ret;
4888}
4889
4890static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 struct iw_request_info *info,
4892 union iwreq_data *wrqu, char *extra)
4893{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304894 hdd_adapter_t *pAdapter;
4895 hdd_station_ctx_t *pHddStaCtx;
4896 hdd_wext_state_t *pWextState;
4897 hdd_context_t *pHddCtx;
4898 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004899
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304900 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 v_U32_t status = 0;
4902
4903 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4904
4905 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4906
4907 int key_index;
4908 struct iw_point *encoding = &wrqu->encoding;
4909 tCsrRoamSetKey setKey;
4910 v_U32_t roamId= 0xFF;
4911 VOS_STATUS vos_status;
4912
4913 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304914 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4915 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4918 "%s: Adapter is NULL",__func__);
4919 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304921 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4922 status = wlan_hdd_validate_context(pHddCtx);
4923 if (0 != status)
4924 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304925 return status;
4926 }
4927 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4928 if (NULL == pHddStaCtx)
4929 {
4930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4931 "%s: STA Context is NULL",__func__);
4932 return -EINVAL;
4933 }
4934 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4935 if (NULL == pWextState)
4936 {
4937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4938 "%s: pWextState is NULL",__func__);
4939 return -EINVAL;
4940 }
4941 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 key_index = encoding->flags & IW_ENCODE_INDEX;
4943
4944 if(key_index > 0) {
4945
4946 /*Convert from 1-based to 0-based keying*/
4947 key_index--;
4948 }
4949 if(!ext->key_len) {
4950
4951 /*Set the encrytion type to NONE*/
4952 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4953 return status;
4954 }
4955
4956 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4957 (IW_ENCODE_ALG_WEP == ext->alg))
4958 {
4959 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4960
Agarwal Ashish971c2882013-10-30 20:11:12 +05304961 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4962 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 return -EINVAL;
4964 }
4965 else {
4966 /*Static wep, update the roam profile with the keys */
4967 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4968 key_index < CSR_MAX_NUM_KEY) {
4969 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4970 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4971
4972 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4973 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4974
4975 }
4976 }
4977 return status;
4978 }
4979
4980 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4981
4982 setKey.keyId = key_index;
4983 setKey.keyLength = ext->key_len;
4984
4985 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4986 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4987 }
4988
4989 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4990 /*Key direction for group is RX only*/
4991 setKey.keyDirection = eSIR_RX_ONLY;
4992 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4993 }
4994 else {
4995
4996 setKey.keyDirection = eSIR_TX_RX;
4997 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4998 }
4999
5000 /*For supplicant pae role is zero*/
5001 setKey.paeRole = 0;
5002
5003 switch(ext->alg)
5004 {
5005 case IW_ENCODE_ALG_NONE:
5006 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5007 break;
5008
5009 case IW_ENCODE_ALG_WEP:
5010 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5011 break;
5012
5013 case IW_ENCODE_ALG_TKIP:
5014 {
5015 v_U8_t *pKey = &setKey.Key[0];
5016
5017 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5018
5019 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5020
5021 /*Supplicant sends the 32bytes key in this order
5022
5023 |--------------|----------|----------|
5024 | Tk1 |TX-MIC | RX Mic |
5025 |--------------|----------|----------|
5026 <---16bytes---><--8bytes--><--8bytes-->
5027
5028 */
5029 /*Sme expects the 32 bytes key to be in the below order
5030
5031 |--------------|----------|----------|
5032 | Tk1 |RX-MIC | TX Mic |
5033 |--------------|----------|----------|
5034 <---16bytes---><--8bytes--><--8bytes-->
5035 */
5036 /* Copy the Temporal Key 1 (TK1) */
5037 vos_mem_copy(pKey,ext->key,16);
5038
5039 /*Copy the rx mic first*/
5040 vos_mem_copy(&pKey[16],&ext->key[24],8);
5041
5042 /*Copy the tx mic */
5043 vos_mem_copy(&pKey[24],&ext->key[16],8);
5044
5045 }
5046 break;
5047
5048 case IW_ENCODE_ALG_CCMP:
5049 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5050 break;
5051
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005052#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005053#define IW_ENCODE_ALG_KRK 6
5054 case IW_ENCODE_ALG_KRK:
5055 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5056 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005057#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005058
5059 default:
5060 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5061 break;
5062 }
5063
5064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005065 ("%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 -07005066
5067#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305068 /* The supplicant may attempt to set the PTK once pre-authentication
5069 is done. Save the key in the UMAC and include it in the ADD
5070 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305072 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305074 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5075 "%s: Update PreAuth Key success", __func__);
5076 return 0;
5077 }
5078 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5079 {
5080 hddLog(VOS_TRACE_LEVEL_ERROR,
5081 "%s: Update PreAuth Key failed", __func__);
5082 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 }
5084#endif /* WLAN_FEATURE_VOWIFI_11R */
5085
5086 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5087
5088 vos_status = wlan_hdd_check_ula_done(pAdapter);
5089 if ( vos_status != VOS_STATUS_SUCCESS )
5090 {
5091 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5092 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5093 __LINE__, vos_status );
5094
5095 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5096 }
5097
5098 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5099
5100 if ( halStatus != eHAL_STATUS_SUCCESS )
5101 {
5102 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5103 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5104 __LINE__, halStatus );
5105
5106 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5107 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305108 EXIT();
5109 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005110}
5111
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305112static int iw_set_encodeext(struct net_device *dev,
5113 struct iw_request_info *info,
5114 union iwreq_data *wrqu, char *extra)
5115{
5116 int ret;
5117
5118 vos_ssr_protect(__func__);
5119 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5120 vos_ssr_unprotect(__func__);
5121
5122 return ret;
5123}
5124
5125static int __iw_set_retry(struct net_device *dev,
5126 struct iw_request_info *info,
5127 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005128{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305129 hdd_adapter_t *pAdapter;
5130 tHalHandle hHal;
5131 hdd_context_t *pHddCtx;
5132 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005133
5134 ENTER();
5135
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305136 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5137 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005138 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5140 "%s: Adapter is NULL",__func__);
5141 return -EINVAL;
5142 }
5143
5144 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5145 ret = wlan_hdd_validate_context(pHddCtx);
5146 if (0 != ret)
5147 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305148 return ret;
5149 }
5150
5151 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5152 if (NULL == hHal)
5153 {
5154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5155 "%s: Hal Context is NULL",__func__);
5156 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005157 }
5158
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5160 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5161
Arif Hussain6d2a3322013-11-17 19:50:10 -08005162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005163
5164 return -EINVAL;
5165 }
5166
5167 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5168
5169 if((wrqu->retry.flags & IW_RETRY_LONG))
5170 {
5171 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5172 {
c_hpothub8245442013-11-20 23:41:09 +05305173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5174 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005175 return -EIO;
5176 }
5177 }
5178 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5179 {
5180 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5181 {
c_hpothub8245442013-11-20 23:41:09 +05305182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5183 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 return -EIO;
5185 }
5186 }
5187 }
5188 else
5189 {
5190 return -EOPNOTSUPP;
5191 }
5192
Arif Hussain6d2a3322013-11-17 19:50:10 -08005193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005194
5195 EXIT();
5196
5197 return 0;
5198
5199}
5200
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305201static int iw_set_retry(struct net_device *dev,
5202 struct iw_request_info *info,
5203 union iwreq_data *wrqu, char *extra)
5204{
5205 int ret;
5206
5207 vos_ssr_protect(__func__);
5208 ret = __iw_set_retry(dev, info, wrqu, extra);
5209 vos_ssr_unprotect(__func__);
5210
5211 return ret;
5212}
5213
5214static int __iw_get_retry(struct net_device *dev,
5215 struct iw_request_info *info,
5216 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005217{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305218 hdd_adapter_t *pAdapter;
5219 hdd_context_t *pHddCtx;
5220 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305222 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005223
5224 ENTER();
5225
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305226 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5227 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005228 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5230 "%s: Adapter is NULL",__func__);
5231 return -EINVAL;
5232 }
5233
5234 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5235 ret = wlan_hdd_validate_context(pHddCtx);
5236 if (0 != ret)
5237 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305238 return ret;
5239 }
5240
5241 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5242 if (NULL == hHal)
5243 {
5244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5245 "%s: Hal Context is NULL",__func__);
5246 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005247 }
5248
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 if((wrqu->retry.flags & IW_RETRY_LONG))
5250 {
5251 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5252
5253 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5254 {
c_hpothub8245442013-11-20 23:41:09 +05305255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5256 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 return -EIO;
5258 }
5259
5260 wrqu->retry.value = retry;
5261 }
5262 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5263 {
5264 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5265
5266 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5267 {
c_hpothub8245442013-11-20 23:41:09 +05305268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5269 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 return -EIO;
5271 }
5272
5273 wrqu->retry.value = retry;
5274 }
5275 else {
5276 return -EOPNOTSUPP;
5277 }
5278
Arif Hussain6d2a3322013-11-17 19:50:10 -08005279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005280
5281 EXIT();
5282
5283 return 0;
5284}
5285
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305286static int iw_get_retry(struct net_device *dev,
5287 struct iw_request_info *info,
5288 union iwreq_data *wrqu, char *extra)
5289{
5290 int ret;
5291
5292 vos_ssr_protect(__func__);
5293 ret = __iw_get_retry(dev, info, wrqu, extra);
5294 vos_ssr_unprotect(__func__);
5295
5296 return ret;
5297}
5298
5299static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 struct iw_request_info *info,
5301 union iwreq_data *wrqu,
5302 char *extra)
5303{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305304 hdd_adapter_t *pAdapter;
5305 hdd_context_t *pHddCtx;
5306 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5308 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305309 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005310
5311 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305312 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5313 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5316 "%s:Adapter is NULL",__func__);
5317 return -EINVAL;
5318 }
5319 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5320 ret = wlan_hdd_validate_context(pHddCtx);
5321 if (0 != ret)
5322 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305323 return ret;
5324 }
5325 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5326 if (NULL == pHddStaCtx)
5327 {
5328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5329 "%s:STA context is NULL",__func__);
5330 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 }
5332
5333 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5334 switch (mlme->cmd) {
5335 case IW_MLME_DISASSOC:
5336 case IW_MLME_DEAUTH:
5337
5338 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5339 {
5340 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5341
5342 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5343 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5344
5345 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5346 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5347
Jeff Johnson43971f52012-07-17 12:26:56 -07005348 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305349 {
5350 long ret;
5351 ret = wait_for_completion_interruptible_timeout(
5352 &pAdapter->disconnect_comp_var,
5353 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5354 if (ret <= 0)
5355 hddLog(VOS_TRACE_LEVEL_ERROR,
5356 FL("failed wait on disconnect_comp_var %ld"), ret);
5357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005359 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005360 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005361
5362 /* Resetting authKeyMgmt */
5363 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5364
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305365 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 netif_tx_disable(dev);
5367 netif_carrier_off(dev);
5368
5369 }
5370 else
5371 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005372 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 -07005373 }
5374 break;
5375 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005376 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 return -EINVAL;
5378 }//end of switch
5379
5380 EXIT();
5381
5382 return status;
5383
5384}
5385
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305386static int iw_set_mlme(struct net_device *dev,
5387 struct iw_request_info *info,
5388 union iwreq_data *wrqu,
5389 char *extra)
5390{
5391 int ret;
5392
5393 vos_ssr_protect(__func__);
5394 ret = __iw_set_mlme(dev, info, wrqu, extra);
5395 vos_ssr_unprotect(__func__);
5396
5397 return ret;
5398}
5399
Jeff Johnson295189b2012-06-20 16:38:30 -07005400/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305401static int __iw_setint_getnone(struct net_device *dev,
5402 struct iw_request_info *info,
5403 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005404{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305405 hdd_adapter_t *pAdapter;
5406 tHalHandle hHal;
5407 hdd_wext_state_t *pWextState;
5408 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305409 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 int *value = (int *)extra;
5411 int sub_cmd = value[0];
5412 int set_value = value[1];
5413 int ret = 0; /* success */
5414 int enable_pbm, enable_mp;
5415#ifdef CONFIG_HAS_EARLYSUSPEND
5416 v_U8_t nEnableSuspendOld;
5417#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005418
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305419 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305420 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5421 if (NULL == pAdapter)
5422 {
5423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5424 "%s: Adapter is NULL",__func__);
5425 return -EINVAL;
5426 }
5427 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5428 ret = wlan_hdd_validate_context(pHddCtx);
5429 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005430 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305431 return ret;
5432 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305433
5434 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5435 if (NULL == hHal)
5436 {
5437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5438 "%s: Hal Context is NULL",__func__);
5439 return -EINVAL;
5440 }
5441
Katya Nigameae74b62015-05-28 17:19:16 +05305442 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305443 {
Katya Nigameae74b62015-05-28 17:19:16 +05305444 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5445 if (NULL == pWextState)
5446 {
5447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5448 "%s: pWextState is NULL",__func__);
5449 return -EINVAL;
5450 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005451
Katya Nigameae74b62015-05-28 17:19:16 +05305452 INIT_COMPLETION(pWextState->completion_var);
5453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 switch(sub_cmd)
5455 {
5456 case WE_SET_11D_STATE:
5457 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005458 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005459 memset(&smeConfig, 0x00, sizeof(smeConfig));
5460
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5462
5463 sme_GetConfigParam(hHal,&smeConfig);
5464 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5465
Arif Hussain6d2a3322013-11-17 19:50:10 -08005466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005467
5468 sme_UpdateConfig(hHal,&smeConfig);
5469 }
5470 else {
5471 return -EINVAL;
5472 }
5473 break;
5474 }
5475
5476 case WE_WOWL:
5477 {
5478 switch (set_value)
5479 {
5480 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305481 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 break;
5483 case 0x01:
5484 case 0x02:
5485 case 0x03:
5486 enable_mp = (set_value & 0x01) ? 1 : 0;
5487 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005488 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5490 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5491 break;
5492 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005493 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 ret = -EINVAL;
5495 break;
5496 }
5497
5498 break;
5499 }
5500 case WE_SET_POWER:
5501 {
5502 switch (set_value)
5503 {
5504 case 0: //Full Power
5505 {
5506 struct statsContext context;
5507 eHalStatus status;
5508
5509 init_completion(&context.completion);
5510
5511 context.pAdapter = pAdapter;
5512 context.magic = POWER_CONTEXT_MAGIC;
5513
5514 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5515 iw_power_callback_fn, &context,
5516 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005517 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 {
5519 int lrc = wait_for_completion_interruptible_timeout(
5520 &context.completion,
5521 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005522
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 if (lrc <= 0)
5524 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005525 hddLog(VOS_TRACE_LEVEL_ERROR,
5526 "%s: SME %s while requesting fullpower",
5527 __func__, (0 == lrc) ?
5528 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 }
5530 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005531 /* either we have a response or we timed out. if we timed
5532 out there is a race condition such that the callback
5533 function could be executing at the same time we are. of
5534 primary concern is if the callback function had already
5535 verified the "magic" but had not yet set the completion
5536 variable when a timeout occurred. we serialize these
5537 activities by invalidating the magic while holding a
5538 shared spinlock which will cause us to block if the
5539 callback is currently executing */
5540 spin_lock(&hdd_context_lock);
5541 context.magic = 0;
5542 spin_unlock(&hdd_context_lock);
5543
Arif Hussain6d2a3322013-11-17 19:50:10 -08005544 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 break;
5546 }
5547 case 1: //Enable BMPS
5548 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5549 break;
5550 case 2: //Disable BMPS
5551 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5552 break;
5553 case 3: //Request Bmps
5554 {
5555 struct statsContext context;
5556 eHalStatus status;
5557
5558 init_completion(&context.completion);
5559
5560 context.pAdapter = pAdapter;
5561 context.magic = POWER_CONTEXT_MAGIC;
5562
5563 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5564 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005565 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 {
5567 int lrc = wait_for_completion_interruptible_timeout(
5568 &context.completion,
5569 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 if (lrc <= 0)
5571 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005572 hddLog(VOS_TRACE_LEVEL_ERROR,
5573 "%s: SME %s while requesting BMPS",
5574 __func__, (0 == lrc) ? "timeout" :
5575 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 }
5577 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005578 /* either we have a response or we timed out. if we
5579 timed out there is a race condition such that the
5580 callback function could be executing at the same
5581 time we are. of primary concern is if the callback
5582 function had already verified the "magic" but had
5583 not yet set the completion variable when a timeout
5584 occurred. we serialize these activities by
5585 invalidating the magic while holding a shared
5586 spinlock which will cause us to block if the
5587 callback is currently executing */
5588 spin_lock(&hdd_context_lock);
5589 context.magic = 0;
5590 spin_unlock(&hdd_context_lock);
5591
Arif Hussain6d2a3322013-11-17 19:50:10 -08005592 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 break;
5594 }
5595 case 4: //Enable IMPS
5596 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5597 break;
5598 case 5: //Disable IMPS
5599 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5600 break;
5601 case 6: //Enable Standby
5602 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5603 break;
5604 case 7: //Disable Standby
5605 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5606 break;
5607 case 8: //Request Standby
5608#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005609#endif
5610 break;
5611 case 9: //Start Auto Bmps Timer
5612 sme_StartAutoBmpsTimer(hHal);
5613 break;
5614 case 10://Stop Auto BMPS Timer
5615 sme_StopAutoBmpsTimer(hHal);
5616 break;
5617#ifdef CONFIG_HAS_EARLYSUSPEND
5618 case 11://suspend to standby
5619#ifdef CONFIG_HAS_EARLYSUSPEND
5620 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5621 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5623#endif
5624 break;
5625 case 12://suspend to deep sleep
5626#ifdef CONFIG_HAS_EARLYSUSPEND
5627 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5628 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005629 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5630#endif
5631 break;
5632 case 13://resume from suspend
5633#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005634#endif
5635 break;
5636#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005638 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 ret = -EINVAL;
5640 break;
5641 }
5642 break;
5643 }
5644
5645 case WE_SET_MAX_ASSOC:
5646 {
5647 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5648 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5649 {
5650 ret = -EINVAL;
5651 }
5652 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5653 set_value, NULL, eANI_BOOLEAN_FALSE)
5654 != eHAL_STATUS_SUCCESS )
5655 {
c_hpothub8245442013-11-20 23:41:09 +05305656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5657 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 ret = -EIO;
5659 }
5660 break;
5661 }
5662
5663 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5664 {
5665 if( 0 == set_value )
5666 {
5667 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5668 }
5669 else if ( 1 == set_value )
5670 {
5671 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5672 }
5673 else
5674 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005675 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 ret = -EINVAL;
5677 }
5678 break;
5679 }
5680
5681 case WE_SET_DATA_INACTIVITY_TO:
5682 {
5683 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5684 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5685 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5686 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5687 set_value,
5688 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5689 {
5690 hddLog(LOGE,"Failure: Could not pass on "
5691 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005692 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 ret = -EINVAL;
5694 }
5695 break;
5696 }
5697 case WE_SET_MAX_TX_POWER:
5698 {
5699 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5700 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5701
5702 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5703 __func__, set_value);
5704 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5705 eHAL_STATUS_SUCCESS )
5706 {
5707 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5708 __func__);
5709 return -EIO;
5710 }
5711
5712 break;
5713 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005714 case WE_SET_MAX_TX_POWER_2_4:
5715 {
5716 hddLog(VOS_TRACE_LEVEL_INFO,
5717 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5718 __func__, set_value);
5719 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5720 eHAL_STATUS_SUCCESS)
5721 {
5722 hddLog(VOS_TRACE_LEVEL_ERROR,
5723 "%s: Setting maximum tx power failed for 2.4 GHz band",
5724 __func__);
5725 return -EIO;
5726 }
5727
5728 break;
5729 }
5730 case WE_SET_MAX_TX_POWER_5_0:
5731 {
5732 hddLog(VOS_TRACE_LEVEL_INFO,
5733 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5734 __func__, set_value);
5735 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5736 eHAL_STATUS_SUCCESS)
5737 {
5738 hddLog(VOS_TRACE_LEVEL_ERROR,
5739 "%s: Setting maximum tx power failed for 5.0 GHz band",
5740 __func__);
5741 return -EIO;
5742 }
5743
5744 break;
5745 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 case WE_SET_HIGHER_DTIM_TRANSITION:
5747 {
5748 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5749 (set_value == eANI_BOOLEAN_TRUE)))
5750 {
5751 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5752 ret = -EINVAL;
5753 }
5754 else
5755 {
5756 if(pAdapter->higherDtimTransition != set_value)
5757 {
5758 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005759 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 }
5761 }
5762
5763 break;
5764 }
5765
5766 case WE_SET_TM_LEVEL:
5767 {
5768 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005769 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5771
5772 break;
5773 }
5774
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305775 case WE_ENABLE_STRICT_FCC_REG:
5776 {
5777 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5778 struct wiphy *wiphy = NULL;
5779 long lrc;
5780 int status;
5781
5782 wiphy = hddCtxt->wiphy;
5783 if(wiphy == NULL)
5784 {
5785 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5786 break;
5787 }
5788 init_completion(&hddCtxt->wiphy_channel_update_event);
5789
5790 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5791
5792 status = regulatory_hint(wiphy, "00");
5793 if(status < 0)
5794 {
5795 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5796 break;
5797 }
5798
5799 /* Wait for completion */
5800 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5801 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5802 if (lrc <= 0)
5803 {
5804 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5805 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5806 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5807 }
5808 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5809
5810 break;
5811 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005812 case WE_SET_DEBUG_LOG:
5813 {
5814 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5815 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5816 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5817 break;
5818 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305819#ifdef FEATURE_WLAN_TDLS
5820 case WE_SET_TDLS_OFF_CHAN:
5821 {
5822 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5824 __func__, set_value);
5825 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5826 break;
5827 }
5828 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5829 {
5830 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5832 __func__, set_value);
5833 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5834 break;
5835 }
5836 case WE_SET_TDLS_OFF_CHAN_MODE:
5837 {
5838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5839 __func__, set_value);
5840 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5841 break;
5842 }
5843#endif
Peng Xu2446a892014-09-05 17:21:18 +05305844 case WE_SET_SCAN_BAND_PREFERENCE:
5845 {
5846 tSmeConfigParams smeConfig;
5847 memset(&smeConfig, 0x00, sizeof(smeConfig));
5848 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5849 ret = -EINVAL;
5850 break;
5851 }
5852 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5853
5854 if (eCSR_BAND_ALL == set_value ||
5855 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5856 sme_GetConfigParam(hHal, &smeConfig);
5857 smeConfig.csrConfig.scanBandPreference = set_value;
5858
5859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5860 "set band scan preference = %d\n",
5861 smeConfig.csrConfig.scanBandPreference);
5862
5863 sme_UpdateConfig(hHal, &smeConfig);
5864 }
5865 else {
5866 ret = -EINVAL;
5867 }
5868 break;
5869 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305870 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5871 * connection happens so that the params can take effect during
5872 * association. Also this should not be used in STA+p2p concurrency
5873 * as the param will also effect the STA mode.
5874 */
5875 case WE_SET_MIRACAST_VENDOR_CONFIG:
5876 {
5877 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305878
Abhishek Singh01c73d12015-03-12 15:13:44 +05305879 hddLog(LOG1, FL(
5880 "Set Miracast vendor tuning %d"), set_value);
5881
5882 if (1 == set_value || 0 == set_value)
5883 {
5884 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5885 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5886 {
5887 hddLog( LOGE, FL("set vendor miracast config failed"));
5888 ret = -EIO;
5889 }
5890 }
5891 else
5892 {
5893 hddLog(LOGE,
5894 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5895 ret = -EINVAL;
5896 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305897 break;
5898 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305899
5900 case WE_GET_FRAME_LOG:
5901 {
5902 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5903 != VOS_STATUS_SUCCESS)
5904 {
5905 ret = -EINVAL;
5906 }
5907 break;
5908 }
5909
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305910 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5911 {
5912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5913 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5914 if (set_value == 0 || set_value == 1)
5915 {
5916 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5917 set_value);
5918 }
5919 else
5920 ret = -EINVAL;
5921
5922 break;
5923 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05305924 /* Bit mask value to enable RTS/CTS for different modes
5925 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
5926 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
5927 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
5928 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
5929 * for 5 GHz, VHT80 - 0x1000
5930 */
5931 case WE_SET_RTS_CTS_HTVHT:
5932 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305933
Abhishek Singh41988ba2015-05-25 19:42:29 +05305934 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
5935
5936 if (eHAL_STATUS_SUCCESS !=
5937 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
5938 {
5939 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
5940 ret = -EINVAL;
5941 }
5942 break;
5943 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305944 case WE_SET_MONITOR_STATE:
5945 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305946 v_U32_t magic = 0;
5947 struct completion cmpVar;
5948 long waitRet = 0;
5949 tVOS_CON_MODE mode = hdd_get_conparam();
5950
5951 if( VOS_MONITOR_MODE != mode)
5952 {
5953 hddLog(LOGE, "invalid mode %d", mode);
5954 ret = -EIO;
5955 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305956
5957 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
5958 if( pMonCtx == NULL )
5959 {
5960 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305961 ret = -EIO;
5962 }
5963 if (pMonCtx->state == set_value)
5964 {
5965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5966 FL("already in same mode curr_mode:%d req_mode: %d"),
5967 pMonCtx->state, set_value);
5968 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305969 }
5970 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305971 magic = MON_MODE_MSG_MAGIC;
5972 init_completion(&cmpVar);
5973 if (VOS_STATUS_SUCCESS !=
5974 wlan_hdd_mon_postMsg(&magic, &cmpVar,
5975 pMonCtx, hdd_monPostMsgCb)) {
5976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5977 FL("failed to post MON MODE REQ"));
5978 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
5979 MON_MODE_STOP : MON_MODE_START;
5980 magic = 0;
5981 ret = -EIO;
5982 break;
5983 }
5984 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
5985 magic = 0;
5986 if (waitRet <= 0 ){
5987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5988 FL("failed to wait on monitor mode completion %ld"),
5989 waitRet);
5990 }
5991 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305992 }
Sushant Kaushik33200572015-08-05 16:46:20 +05305993 case WE_SET_PKT_STATS_ENABLE_DISABLE:
5994 {
5995 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5996 tAniWifiStartLog start_log;
5997 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
5998 !vos_isPktStatsEnabled())
5999 {
6000 hddLog(LOGE, FL("per pkt stats not enabled"));
6001 return -EINVAL;
6002 }
6003 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6004
6005 if (1 == set_value || 0 == set_value)
6006 {
6007 start_log.ringId = RING_ID_PER_PACKET_STATS;
6008 start_log.flag = 0;
6009 if (set_value)
6010 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6011 else
6012 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6013
6014 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6015 }
6016 else
6017 {
6018 hddLog(LOGE,
6019 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6020 set_value);
6021 ret = -EINVAL;
6022 }
6023 break;
6024 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306025
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 default:
6027 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006028 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 sub_cmd, set_value);
6030 break;
6031 }
6032 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306033 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 return ret;
6035}
6036
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306037static int iw_setint_getnone(struct net_device *dev,
6038 struct iw_request_info *info,
6039 union iwreq_data *wrqu, char *extra)
6040{
6041 int ret;
6042
6043 vos_ssr_protect(__func__);
6044 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6045 vos_ssr_unprotect(__func__);
6046
6047 return 0;
6048}
Jeff Johnson295189b2012-06-20 16:38:30 -07006049/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306050static int __iw_setchar_getnone(struct net_device *dev,
6051 struct iw_request_info *info,
6052 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006053{
6054 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306055 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006057 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306058 hdd_adapter_t *pAdapter;
6059 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006060#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306061 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006062#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306063 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306064 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006065
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306066 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306067 pAdapter = (netdev_priv(dev));
6068 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006069 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6071 "%s: Adapter is NULL",__func__);
6072 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006073 }
6074
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306075 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6076 ret = wlan_hdd_validate_context(pHddCtx);
6077 if (0 != ret)
6078 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306079 return ret;
6080 }
6081#ifdef WLAN_FEATURE_VOWIFI
6082 pConfig = pHddCtx->cfg_ini;
6083#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306084 /* helper function to get iwreq_data with compat handling. */
6085 if (hdd_priv_get_data(&s_priv_data, wrqu))
6086 {
6087 return -EINVAL;
6088 }
6089
6090 /* make sure all params are correctly passed to function */
6091 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6092 {
6093 return -EINVAL;
6094 }
6095
6096 sub_cmd = s_priv_data.flags;
6097
Arif Hussain0273cba2014-01-07 20:58:29 -08006098 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306099 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6100 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006101 if (NULL == pBuffer)
6102 {
6103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6104 "mem_alloc_copy_from_user_helper fail");
6105 return -ENOMEM;
6106 }
6107
6108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306109 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6111 "%s: Received data %s", __func__, pBuffer);
6112
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 switch(sub_cmd)
6114 {
6115 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006117 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 break;
6119 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006121 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 break;
6123#if defined WLAN_FEATURE_VOWIFI
6124 case WE_NEIGHBOR_REPORT_REQUEST:
6125 {
6126 tRrmNeighborReq neighborReq;
6127 tRrmNeighborRspCallbackInfo callbackInfo;
6128
6129 if (pConfig->fRrmEnable)
6130 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306132 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 if( !neighborReq.no_ssid )
6134 {
Girish Gowli552fc072014-06-14 18:26:16 +05306135 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006136 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 }
6138
6139 callbackInfo.neighborRspCallback = NULL;
6140 callbackInfo.neighborRspCallbackContext = NULL;
6141 callbackInfo.timeout = 5000; //5 seconds
6142 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6143 }
6144 else
6145 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006146 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 ret = -EINVAL;
6148 }
6149 }
6150 break;
6151#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 case WE_SET_AP_WPS_IE:
6153 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306154 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006157 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006158 if (VOS_STATUS_SUCCESS != vstatus)
6159 {
6160 ret = -EINVAL;
6161 }
6162 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306163 case WE_SET_ENCRYPT_MSG:
6164 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6165 if (NULL == pkt)
6166 {
6167 hddLog(VOS_TRACE_LEVEL_ERROR,
6168 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306169 ret = -ENOMEM;
6170 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306171 }
6172
6173 memset(pkt, 0, sizeof(tSirpkt80211));
6174
6175 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6176 hddLog(VOS_TRACE_LEVEL_ERROR,
6177 FL("Firmware is not DISA capable"));
6178 ret = -EINVAL;
6179 vos_mem_free(pkt);
6180 break;
6181 }
6182
6183 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6184
6185 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6186 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6187 if (eHAL_STATUS_SUCCESS != ret) {
6188 hddLog(VOS_TRACE_LEVEL_ERROR,
6189 FL("SENDEncryptMSG: fail to post WDA cmd"));
6190 ret = -EINVAL;
6191 }
6192 vos_mem_free(pkt);
6193
6194 break;
6195
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 default:
6197 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006198 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 ret = -EINVAL;
6200 break;
6201 }
6202 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006203 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306204
6205 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 return ret;
6207}
6208
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306209static int iw_setchar_getnone(struct net_device *dev,
6210 struct iw_request_info *info,
6211 union iwreq_data *wrqu, char *extra)
6212{
6213 int ret;
6214
6215 vos_ssr_protect(__func__);
6216 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6217 vos_ssr_unprotect(__func__);
6218
6219 return ret;
6220}
6221
Jeff Johnson295189b2012-06-20 16:38:30 -07006222/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306223static int __iw_setnone_getint(struct net_device *dev,
6224 struct iw_request_info *info,
6225 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006226{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306227 hdd_adapter_t *pAdapter;
6228 tHalHandle hHal;
6229 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 int *value = (int *)extra;
6231 int ret = 0; /* success */
6232
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306233 ENTER();
6234
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306235 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6236 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006237 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6239 "%s: Adapter is NULL",__func__);
6240 return -EINVAL;
6241 }
6242 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6243 ret = wlan_hdd_validate_context(pHddCtx);
6244 if (0 != ret)
6245 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306246 return ret;
6247 }
6248 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6249 if (NULL == hHal)
6250 {
6251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6252 "%s: Hal Context is NULL",__func__);
6253 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006255
6256 switch (value[0])
6257 {
6258 case WE_GET_11D_STATE:
6259 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006260 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306262
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6264
Arif Hussain6d2a3322013-11-17 19:50:10 -08006265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006266
6267 break;
6268 }
6269
6270 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 break;
6273
6274 case WE_PMC_STATE:
6275 {
6276 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 break;
6279 }
6280 case WE_GET_WLAN_DBG:
6281 {
6282 vos_trace_display();
6283 *value = 0;
6284 break;
6285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 case WE_GET_MAX_ASSOC:
6287 {
6288 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6289 {
c_hpothub8245442013-11-20 23:41:09 +05306290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6291 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 ret = -EIO;
6293 }
Girish Gowli385be612014-09-18 11:17:20 +05306294#ifdef WLAN_SOFTAP_VSTA_FEATURE
6295 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6296 {
6297 if (*value > VSTA_NUM_ASSOC_STA)
6298 {
6299 *value = VSTA_NUM_ASSOC_STA;
6300 }
6301 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6302 (*value > (VSTA_NUM_ASSOC_STA -
6303 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6304 {
6305 *value = (VSTA_NUM_ASSOC_STA -
6306 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6307 }
6308 }
6309 else
6310#endif
6311 {
6312 if (*value > NUM_ASSOC_STA)
6313 {
6314 *value = NUM_ASSOC_STA;
6315 }
6316 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6317 (*value > (NUM_ASSOC_STA -
6318 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6319 {
6320 *value = (NUM_ASSOC_STA -
6321 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6322 }
6323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 break;
6325 }
6326
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 case WE_GET_WDI_DBG:
6328 {
6329 wpalTraceDisplay();
6330 *value = 0;
6331 break;
6332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006333
6334 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6335 {
6336 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6337 break;
6338 }
6339 case WE_GET_CONCURRENCY_MODE:
6340 {
6341 *value = hdd_get_concurrency_mode ( );
6342
Arif Hussain6d2a3322013-11-17 19:50:10 -08006343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006344 break;
6345 }
6346
Peng Xu2446a892014-09-05 17:21:18 +05306347 case WE_GET_SCAN_BAND_PREFERENCE:
6348 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306349 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306350 sme_GetConfigParam(hHal, &smeConfig);
6351 *value = smeConfig.csrConfig.scanBandPreference;
6352
6353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6354 "scanBandPreference = %d\n", *value);
6355 break;
6356 }
6357
Jeff Johnson295189b2012-06-20 16:38:30 -07006358 default:
6359 {
6360 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6361 break;
6362 }
6363 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306364 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 return ret;
6366}
6367
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306368static int iw_setnone_getint(struct net_device *dev,
6369 struct iw_request_info *info,
6370 union iwreq_data *wrqu, char *extra)
6371{
6372 int ret;
6373
6374 vos_ssr_protect(__func__);
6375 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6376 vos_ssr_unprotect(__func__);
6377
6378 return ret;
6379
6380}
Jeff Johnson295189b2012-06-20 16:38:30 -07006381/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306382int __iw_set_three_ints_getnone(struct net_device *dev,
6383 struct iw_request_info *info,
6384 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006385{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306386 hdd_adapter_t *pAdapter;
6387 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 int *value = (int *)extra;
6389 int sub_cmd = value[0];
6390 int ret = 0;
6391
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306392 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306393 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6394 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006395 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6397 "%s: Adapter is NULL",__func__);
6398 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006399 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306400 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6401 ret = wlan_hdd_validate_context(pHddCtx);
6402 if (0 != ret)
6403 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306404 return ret;
6405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 switch(sub_cmd)
6407 {
6408 case WE_SET_WLAN_DBG:
6409 {
6410 vos_trace_setValue( value[1], value[2], value[3]);
6411 break;
6412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 case WE_SET_WDI_DBG:
6414 {
6415 wpalTraceSetLevel( value[1], value[2], value[3]);
6416 break;
6417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 case WE_SET_SAP_CHANNELS:
6419 {
6420 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6421 break;
6422 }
6423
6424 default:
6425 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006426 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 break;
6428 }
6429 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306430 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 return ret;
6432}
6433
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306434int iw_set_three_ints_getnone(struct net_device *dev,
6435 struct iw_request_info *info,
6436 union iwreq_data *wrqu, char *extra)
6437{
6438 int ret;
6439
6440 vos_ssr_protect(__func__);
6441 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6442 vos_ssr_unprotect(__func__);
6443
6444 return ret;
6445}
6446
6447static int __iw_get_char_setnone(struct net_device *dev,
6448 struct iw_request_info *info,
6449 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006450{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306451 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006452 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306453 hdd_context_t *pHddCtx;
6454 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006455#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006456 hdd_wext_state_t *pWextState;
6457#endif
6458
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306459 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306460 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006461 if (pAdapter == NULL)
6462 {
6463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6464 "%s: pAdapter is NULL!", __func__);
6465 return -EINVAL;
6466 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306467 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6468 ret = wlan_hdd_validate_context(pHddCtx);
6469 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006470 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306471 return ret;
6472 }
6473#ifdef WLAN_FEATURE_11W
6474 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6475 if (NULL == pWextState)
6476 {
6477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6478 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006479 return -EINVAL;
6480 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306481#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006482
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 switch(sub_cmd)
6484 {
6485 case WE_WLAN_VERSION:
6486 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006487 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 break;
6489 }
6490
6491 case WE_GET_STATS:
6492 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306493 tHalHandle hHal = NULL;
6494 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6496 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6497 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6498
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306499
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 snprintf(extra, WE_MAX_STR_LEN,
6501 "\nTransmit"
6502 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6503 "\n dropped BK %u, BE %u, VI %u, VO %u"
6504 "\n classified BK %u, BE %u, VI %u, VO %u"
6505 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6506 "\n queued BK %u, BE %u, VI %u, VO %u"
6507 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006508 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 "\n fetched BK %u, BE %u, VI %u, VO %u"
6510 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6511 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006512 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 "\n flushed BK %u, BE %u, VI %u, VO %u"
6514 "\n\nReceive"
6515 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6516 "\n\nResetsStats"
6517 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6518 "\n",
6519 pStats->txXmitCalled,
6520 pStats->txXmitDropped,
6521 pStats->txXmitBackPressured,
6522 pStats->txXmitQueued,
6523
6524 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6525 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6526 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6527 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6528
6529 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6530 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6531 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6532 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6533
6534 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6535 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6536 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6537 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6538
6539 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6540 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6541 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6542 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6543
6544 pStats->txFetched,
6545 pStats->txFetchEmpty,
6546 pStats->txFetchLowResources,
6547 pStats->txFetchDequeueError,
6548
6549 pStats->txFetchDequeued,
6550 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006551 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006552 pStats->txCompleted,
6553 pStats->txFlushed,
6554
6555 pStats->txFetchedAC[WLANTL_AC_BK],
6556 pStats->txFetchedAC[WLANTL_AC_BE],
6557 pStats->txFetchedAC[WLANTL_AC_VI],
6558 pStats->txFetchedAC[WLANTL_AC_VO],
6559
6560 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6561 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6562 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6563 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6564
6565 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6566 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6567 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6568 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6569
Ravi Joshi41914632013-10-21 23:02:21 -07006570 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6571 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6572 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6573 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6574
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 pStats->txFlushedAC[WLANTL_AC_BK],
6576 pStats->txFlushedAC[WLANTL_AC_BE],
6577 pStats->txFlushedAC[WLANTL_AC_VI],
6578 pStats->txFlushedAC[WLANTL_AC_VO],
6579
6580 pStats->rxChains,
6581 pStats->rxPackets,
6582 pStats->rxDropped,
6583 pStats->rxDelivered,
6584 pStats->rxRefused,
6585
6586 pResetStats->totalLogpResets,
6587 pResetStats->totalCMD53Failures,
6588 pResetStats->totalMutexReadFailures,
6589 pResetStats->totalMIFErrorFailures,
6590 pResetStats->totalFWHearbeatFailures,
6591 pResetStats->totalUnknownExceptions
6592 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306593 wrqu->data.length = strlen(extra);
6594
6595 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6596
6597 if (hHal)
6598 pMac = PMAC_STRUCT( hHal );
6599
6600 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6601 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6602 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306603 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6604 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6605 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6606 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306607 "\n",
6608 pMac->pmm.BmpscntSleep,
6609 pMac->pmm.BmpscntAwake,
6610 pMac->pmm.BmpsSleeReqFailCnt,
6611 pMac->pmm.BmpsWakeupReqFailCnt,
6612 pMac->pmm.ImpsCntSleep,
6613 pMac->pmm.ImpsCntAwake,
6614 pMac->pmm.ImpsSleepErrCnt,
6615 pMac->pmm.ImpsWakeupErrCnt,
6616 pMac->pmm.ImpsLastErr
6617 );
6618 }
6619
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 wrqu->data.length = strlen(extra)+1;
6621 break;
6622 }
6623
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306624/* The case prints the current state of the HDD, SME, CSR, PE, TL
6625 *it can be extended for WDI Global State as well.
6626 *And currently it only checks P2P_CLIENT adapter.
6627 *P2P_DEVICE and P2P_GO have not been added as of now.
6628*/
6629 case WE_GET_STATES:
6630 {
6631 int buf = 0, len = 0;
6632 int adapter_num = 0;
6633 int count = 0, check = 1;
6634
6635 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006636 tHalHandle hHal = NULL;
6637 tpAniSirGlobal pMac = NULL;
6638 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306639
6640 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6641 hdd_adapter_t *useAdapter = NULL;
6642
6643 /* Print wlan0 or p2p0 states based on the adapter_num
6644 *by using the correct adapter
6645 */
6646 while ( adapter_num < 2 )
6647 {
6648 if ( WLAN_ADAPTER == adapter_num )
6649 {
6650 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006651 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306652 "\n\n wlan0 States:-");
6653 len += buf;
6654 }
6655 else if ( P2P_ADAPTER == adapter_num )
6656 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006657 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306658 "\n\n p2p0 States:-");
6659 len += buf;
6660
6661 if( !pHddCtx )
6662 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006663 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306664 "\n pHddCtx is NULL");
6665 len += buf;
6666 break;
6667 }
6668
6669 /*Printing p2p0 states only in the case when the device is
6670 configured as a p2p_client*/
6671 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6672 if ( !useAdapter )
6673 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006674 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306675 "\n Device not configured as P2P_CLIENT.");
6676 len += buf;
6677 break;
6678 }
6679 }
6680
6681 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006682 if (!hHal) {
6683 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6684 "\n pMac is NULL");
6685 len += buf;
6686 break;
6687 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306688 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006689 if (!pMac) {
6690 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6691 "\n pMac is NULL");
6692 len += buf;
6693 break;
6694 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306695 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6696 if( !pHddStaCtx )
6697 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006698 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306699 "\n pHddStaCtx is NULL");
6700 len += buf;
6701 break;
6702 }
6703
6704 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6705
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006706 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306707 "\n HDD Conn State - %s "
6708 "\n \n SME State:"
6709 "\n Neighbour Roam State - %s"
6710 "\n CSR State - %s"
6711 "\n CSR Substate - %s"
6712 "\n \n TL STA %d State: %s",
6713 macTraceGetHDDWlanConnState(
6714 pHddStaCtx->conn_info.connState),
6715 macTraceGetNeighbourRoamState(
6716 pMac->roam.neighborRoamInfo.neighborRoamState),
6717 macTraceGetcsrRoamState(
6718 pMac->roam.curState[useAdapter->sessionId]),
6719 macTraceGetcsrRoamSubState(
6720 pMac->roam.curSubState[useAdapter->sessionId]),
6721 pHddStaCtx->conn_info.staId[0],
6722 macTraceGetTLState(tlState)
6723 );
6724 len += buf;
6725 adapter_num++;
6726 }
6727
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006728 if (pMac) {
6729 /* Printing Lim State starting with global lim states */
6730 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6731 "\n \n LIM STATES:-"
6732 "\n Global Sme State - %s "\
6733 "\n Global mlm State - %s "\
6734 "\n",
6735 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6736 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6737 );
6738 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306739
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006740 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05306741 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306742 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006743 if ( pMac->lim.gpSession[count].valid )
6744 {
6745 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6746 "\n Lim Valid Session %d:-"
6747 "\n PE Sme State - %s "
6748 "\n PE Mlm State - %s "
6749 "\n",
6750 check,
6751 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6752 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6753 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306754
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006755 len += buf;
6756 check++;
6757 }
6758 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306759 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306760 }
6761
6762 wrqu->data.length = strlen(extra)+1;
6763 break;
6764 }
6765
Jeff Johnson295189b2012-06-20 16:38:30 -07006766 case WE_GET_CFG:
6767 {
6768 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6769 wrqu->data.length = strlen(extra)+1;
6770 break;
6771 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006772#ifdef WLAN_FEATURE_11AC
6773 case WE_GET_RSSI:
6774 {
6775 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05306776 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07006777 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6778 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6779 wrqu->data.length = strlen(extra)+1;
6780 break;
6781 }
6782#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306783
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006784#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006785 case WE_GET_ROAM_RSSI:
6786 {
6787 v_S7_t s7Rssi = 0;
6788 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6789 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6790 wrqu->data.length = strlen(extra)+1;
6791 break;
6792 }
6793#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 case WE_GET_WMM_STATUS:
6795 {
6796 snprintf(extra, WE_MAX_STR_LEN,
6797 "\nDir: 0=up, 1=down, 3=both\n"
6798 "|------------------------|\n"
6799 "|AC | ACM |Admitted| Dir |\n"
6800 "|------------------------|\n"
6801 "|VO | %d | %3s | %d |\n"
6802 "|VI | %d | %3s | %d |\n"
6803 "|BE | %d | %3s | %d |\n"
6804 "|BK | %d | %3s | %d |\n"
6805 "|------------------------|\n",
6806 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6807 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6808 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6809 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6810 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6811 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6812 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6813 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6814 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6815 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6816 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6817 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6818
Jeff Johnsone7245742012-09-05 17:12:55 -07006819
Jeff Johnson295189b2012-06-20 16:38:30 -07006820 wrqu->data.length = strlen(extra)+1;
6821 break;
6822 }
6823 case WE_GET_CHANNEL_LIST:
6824 {
6825 VOS_STATUS status;
6826 v_U8_t i, len;
6827 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306828 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6829 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6830 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 tChannelListInfo channel_list;
6832
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006833 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006834 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006835 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006837 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 return -EINVAL;
6839 }
6840 buf = extra;
6841
6842 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006843 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6844 * needed = 5 * number of channels. Check ifsufficient
6845 * buffer is available and then proceed to fill the buffer.
6846 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6848 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006849 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006850 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006851 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 return -EINVAL;
6853 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006854 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6855 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306856 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6857 {
6858 //Printing Country code in getChannelList
6859 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6860 {
6861 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6862 "%c ", pBuf[i]);
6863 }
6864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 for(i = 0 ; i < channel_list.num_channels; i++)
6866 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006867 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006869 }
6870 wrqu->data.length = strlen(extra)+1;
6871
6872 break;
6873 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006874#ifdef FEATURE_WLAN_TDLS
6875 case WE_GET_TDLS_PEERS:
6876 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006877 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006878 break;
6879 }
6880#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006881#ifdef WLAN_FEATURE_11W
6882 case WE_GET_11W_INFO:
6883 {
6884 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6885
6886 snprintf(extra, WE_MAX_STR_LEN,
6887 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6888 "\n Number of Unprotected Disassocs %d"
6889 "\n Number of Unprotected Deauths %d",
6890 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6891 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6892 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6893 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6894 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6895
6896 wrqu->data.length = strlen(extra)+1;
6897 break;
6898 }
6899#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306900 case WE_GET_SNR:
6901 {
6902 v_S7_t s7snr = 0;
6903 int status = 0;
6904 hdd_context_t *pHddCtx;
6905 hdd_station_ctx_t *pHddStaCtx;
6906
6907 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6908 status = wlan_hdd_validate_context(pHddCtx);
6909 if (0 != status)
6910 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306911 return status;
6912 }
6913
6914 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6915
6916 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6917 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6918 {
6919 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6920 " ConnectionState-%d", __func__,
6921 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6922 pHddStaCtx->conn_info.connState);
6923 return -ENONET;
6924 }
6925
6926 /*update the stats in TL*/
6927 wlan_hdd_get_station_stats(pAdapter);
6928 wlan_hdd_get_snr(pAdapter, &s7snr);
6929 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6930 wrqu->data.length = strlen(extra) + 1;
6931 break;
6932 }
6933
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306934 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006936 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 break;
6938 }
6939 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306940 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006941 return 0;
6942}
6943
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306944static int iw_get_char_setnone(struct net_device *dev,
6945 struct iw_request_info *info,
6946 union iwreq_data *wrqu, char *extra)
6947{
6948 int ret;
6949
6950 vos_ssr_protect(__func__);
6951 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6952 vos_ssr_unprotect(__func__);
6953
6954 return ret;
6955}
6956
Jeff Johnson295189b2012-06-20 16:38:30 -07006957/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306958static int __iw_setnone_getnone(struct net_device *dev,
6959 struct iw_request_info *info,
6960 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006961{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306962 hdd_adapter_t *pAdapter;
6963 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306964 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006965 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306966 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006967
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306968 ENTER();
6969
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306970 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6971 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006972 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6974 "%s: Adapter is NULL",__func__);
6975 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006976 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306977 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6978 ret = wlan_hdd_validate_context(pHddCtx);
6979 if (0 != ret)
6980 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306981 return ret;
6982 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306983 /* helper function to get iwreq_data with compat handling. */
6984 if (hdd_priv_get_data(&s_priv_data, wrqu))
6985 {
6986 return -EINVAL;
6987 }
6988
6989 sub_cmd = s_priv_data.flags;
6990
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 switch (sub_cmd)
6992 {
6993 case WE_CLEAR_STATS:
6994 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006996 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6997 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6998 break;
6999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007000 case WE_INIT_AP:
7001 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307002 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7003
7004 /* As Soft AP mode might been changed to STA already with
7005 * killing of Hostapd, need to find the adpater by name
7006 * rather than mode */
7007 hdd_adapter_t* pAdapter_to_stop =
7008 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7009 if( pAdapter_to_stop )
7010 {
7011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7012 "Adapter with name softap.0 already "
7013 "exist, ignoring the request.\nRemove the "
7014 "adapter and try again\n");
7015 break;
7016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007017 pr_info("Init AP trigger\n");
7018 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7019 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7020 break;
7021 }
7022 case WE_STOP_AP:
7023 {
7024 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7025 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7026 * this is a dead code and need to find the adpater by name rather than mode */
7027 hdd_adapter_t* pAdapter_to_stop =
7028 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7029 if( pAdapter_to_stop )
7030 {
7031 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7032
7033 pr_info("Stopping AP mode\n");
7034
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307035 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7036 {
7037 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7038 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7039 }
7040
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307042 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307043 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7045
7046 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7047 pAdapter_to_stop->macAddressCurrent.bytes);
7048 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7049 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307050
7051 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7052 {
7053 /* put the device back into BMPS */
7054 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007056 }
7057 else
7058 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007059 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 }
7061
7062 break;
7063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007064#ifdef WLAN_BTAMP_FEATURE
7065 case WE_ENABLE_AMP:
7066 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007068 WLANBAP_RegisterWithHCI(pAdapter);
7069 break;
7070 }
7071 case WE_DISABLE_AMP:
7072 {
7073 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7074 VOS_STATUS status;
7075
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007077
7078 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7079 status = WLANBAP_StopAmp();
7080 if(VOS_STATUS_SUCCESS != status )
7081 {
7082 pHddCtx->isAmpAllowed = VOS_TRUE;
7083 hddLog(VOS_TRACE_LEVEL_FATAL,
7084 "%s: Failed to stop AMP", __func__);
7085 }
7086 else
7087 {
7088 //a state m/c implementation in PAL is TBD to avoid this delay
7089 msleep(500);
7090 pHddCtx->isAmpAllowed = VOS_FALSE;
7091 WLANBAP_DeregisterFromHCI();
7092 }
7093
7094 break;
7095 }
7096#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007097 case WE_ENABLE_DXE_STALL_DETECT:
7098 {
schang6295e542013-03-12 15:31:23 -07007099 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7100 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007101 break;
7102 }
7103 case WE_DISPLAY_DXE_SNAP_SHOT:
7104 {
schang6295e542013-03-12 15:31:23 -07007105 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7106 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007107 break;
7108 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307109 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7110 {
7111 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7112 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307113 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307114 break;
7115 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307116
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307117 case WE_SET_REASSOC_TRIGGER:
7118 {
7119 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7120 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7121 v_U32_t roamId = 0;
7122 tCsrRoamModifyProfileFields modProfileFields;
Abhishek Singh5333d472015-10-15 15:49:24 +05307123 hdd_station_ctx_t *pHddStaCtx =
7124 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7125 /* Reassoc to same AP, only supported for Open Security*/
7126 if ((pHddStaCtx->conn_info.ucEncryptionType ||
7127 pHddStaCtx->conn_info.mcEncryptionType))
7128 {
7129 hddLog(LOGE,
7130 FL("Reassoc to same AP, only supported for Open Security"));
7131 return -ENOTSUPP;
7132 }
7133 sme_GetModifyProfileFields(pMac,
7134 pAdapter->sessionId, &modProfileFields);
7135 sme_RoamReassoc(pMac, pAdapter->sessionId,
7136 NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307137 return 0;
7138 }
7139
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307140 case WE_STOP_OBSS_SCAN:
7141 {
7142 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7143 2.OBSS scan is stopped by Firmware during the disassociation
7144 3.OBSS stop comamnd is added for debugging purpose*/
7145 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7146 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007147
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307148 if (pAdapter == NULL)
7149 {
7150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7151 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307152 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307153 }
7154 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7155 if (pMac == NULL)
7156 {
7157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7158 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307159 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307160 }
7161 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7162 }
7163 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307164 case WE_DUMP_ROAM_TIMER_LOG:
7165 {
7166 vos_dump_roam_time_log_service();
7167 break;
7168 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307169
Mukul Sharma84f27252014-07-14 18:11:42 +05307170 case WE_RESET_ROAM_TIMER_LOG:
7171 {
7172 vos_reset_roam_timer_log();
7173 break;
7174 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307175 case WE_GET_FW_LOGS:
7176 {
7177 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7178 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307179 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307180 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307181 break;
7182 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307183 case WE_GET_FW_MEMDUMP:
7184 {
7185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7186 "FW_MEM_DUMP requested ");
7187 get_fwr_memdump(dev,info,wrqu,extra);
7188 break;
7189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 default:
7191 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007192 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007193 break;
7194 }
7195 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307196 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 return ret;
7198}
7199
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307200static int iw_setnone_getnone(struct net_device *dev,
7201 struct iw_request_info *info,
7202 union iwreq_data *wrqu, char *extra)
7203{
7204 int ret;
7205
7206 vos_ssr_protect(__func__);
7207 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7208 vos_ssr_unprotect(__func__);
7209
7210 return ret;
7211}
7212
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307213void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7214{
7215 /*
7216 * Function to display HDD WMM information
7217 * for Tx Queues.
7218 * Prints globala as well as per client depending
7219 * whether the clients are registered or not.
7220 */
7221 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307222 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7223 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7225 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307226 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307227
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307228 for ( i=0; i< NUM_TX_QUEUES; i++)
7229 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307230 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307231 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307232 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307233 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307234
7235 for ( i=0; i< NUM_TX_QUEUES; i++) {
7236 if (tx_queue_count[i]) {
7237 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7238 i, tx_queue_count[i]);
7239 }
7240 }
7241
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307242 if(pSapCtx == NULL){
7243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7244 FL("psapCtx is NULL"));
7245 return;
7246 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307247
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307248 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307249 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7250 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307251 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307252 {
7253 hddLog(LOGE, "******STAIndex: %d*********", i);
7254 for ( j=0; j< NUM_TX_QUEUES; j++)
7255 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307256 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7257 {
7258 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307259 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7260 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307261 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7262 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307263 }
7264 }
7265 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307266 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307267
Katya Nigam1fd24402015-02-16 14:52:19 +05307268 if(pHddStaCtx == NULL){
7269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7270 FL("pHddStaCtx is NULL"));
7271 return;
7272 }
7273
7274 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7275 if(pPeerInfo == NULL){
7276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7277 FL("ppeerinfo is NULL"));
7278 return;
7279 }
7280
7281 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7282 {
7283 if(pPeerInfo->ibssStaInfo[i].isUsed)
7284 {
7285 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7286 for ( j=0; j< NUM_TX_QUEUES; j++)
7287 {
7288 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7289 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7290 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7291 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7292 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7293 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7294 }
7295 }
7296 }
7297
7298
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307299}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307300static int __iw_set_var_ints_getnone(struct net_device *dev,
7301 struct iw_request_info *info,
7302 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007303{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307304 hdd_adapter_t *pAdapter;
7305 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307306 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307307 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007308 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307309 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307310 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007311 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307312 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007313 int cmd = 0;
7314 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307315 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007316
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307317 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307318 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307319 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7321 "%s: NULL extra buffer pointer", __func__);
7322 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307323 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307324 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7325 if (NULL == pAdapter)
7326 {
7327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7328 "%s: Adapter is NULL",__func__);
7329 return -EINVAL;
7330 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307331 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307332 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7333 ret = wlan_hdd_validate_context(pHddCtx);
7334 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007335 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307336 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007337 }
Katya Nigameae74b62015-05-28 17:19:16 +05307338 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307339 {
Katya Nigameae74b62015-05-28 17:19:16 +05307340 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7341 if (NULL == hHal)
7342 {
7343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7344 "%s: Hal Context is NULL",__func__);
7345 return -EINVAL;
7346 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307347 }
7348 sub_cmd = wrqu->data.flags;
7349
7350 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7351
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007352
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007353 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7354 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7355 {
7356 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7357 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7358 {
7359 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7360 staId = pStaCtx->conn_info.staId[0];
7361 }
7362 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7363 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7364 {
7365 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7366 staId = pAPCtx->uBCStaId;
7367 }
7368 else
7369 {
7370 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7371 return 0;
7372 }
7373 }
7374
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 switch (sub_cmd)
7376 {
7377 case WE_LOG_DUMP_CMD:
7378 {
7379 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007380 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007381 apps_args[3], apps_args[4]);
7382
7383 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7384 apps_args[3], apps_args[4]);
7385
7386 }
7387 break;
7388
Jeff Johnson295189b2012-06-20 16:38:30 -07007389 case WE_P2P_NOA_CMD:
7390 {
7391 p2p_app_setP2pPs_t p2pNoA;
7392
7393 p2pNoA.opp_ps = apps_args[0];
7394 p2pNoA.ctWindow = apps_args[1];
7395 p2pNoA.duration = apps_args[2];
7396 p2pNoA.interval = apps_args[3];
7397 p2pNoA.count = apps_args[4];
7398 p2pNoA.single_noa_duration = apps_args[5];
7399 p2pNoA.psSelection = apps_args[6];
7400
7401 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7402 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007403 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7405
7406 hdd_setP2pPs(dev, &p2pNoA);
7407
7408 }
7409 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007410
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307411 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7412 {
7413 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7414 __func__, apps_args[0], apps_args[1]);
7415 vosTraceEnable(apps_args[0], apps_args[1]);
7416 }
7417 break;
7418
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007419 case WE_MTRACE_DUMP_CMD:
7420 {
7421 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7422 "bitmask_of_module %d ",
7423 __func__, apps_args[0], apps_args[1], apps_args[2],
7424 apps_args[3]);
7425 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7426 apps_args[2], apps_args[3]);
7427
7428 }
7429 break;
7430
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007431 case WE_MCC_CONFIG_CREDENTIAL :
7432 {
7433 cmd = 287; //Command should be updated if there is any change
7434 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007435 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007436 {
7437 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7438 }
7439 else
7440 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007441 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007442 return 0;
7443 }
7444 }
7445 break;
7446
7447 case WE_MCC_CONFIG_PARAMS :
7448 {
7449 cmd = 288; //command Should be updated if there is any change
7450 // in the Riva dump command
7451 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7452 }
7453 break;
7454
Chilam NG571c65a2013-01-19 12:27:36 +05307455#ifdef FEATURE_WLAN_TDLS
7456 case WE_TDLS_CONFIG_PARAMS :
7457 {
7458 tdls_config_params_t tdlsParams;
7459
Chilam Ng01120412013-02-19 18:32:21 -08007460 tdlsParams.tdls = apps_args[0];
7461 tdlsParams.tx_period_t = apps_args[1];
7462 tdlsParams.tx_packet_n = apps_args[2];
7463 tdlsParams.discovery_period_t = apps_args[3];
7464 tdlsParams.discovery_tries_n = apps_args[4];
7465 tdlsParams.idle_timeout_t = apps_args[5];
7466 tdlsParams.idle_packet_n = apps_args[6];
7467 tdlsParams.rssi_hysteresis = apps_args[7];
7468 tdlsParams.rssi_trigger_threshold = apps_args[8];
7469 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307470
Chilam Ng01120412013-02-19 18:32:21 -08007471 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307472 }
7473 break;
7474#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307475 case WE_CONFIGURE_MONITOR_MODE:
7476 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307477 v_U32_t magic = 0;
7478 struct completion cmpVar;
7479 long waitRet = 0;
7480
Katya Nigamf0511f62015-05-05 16:40:57 +05307481 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7482 if( pMonCtx == NULL )
7483 {
7484 hddLog(LOGE, "Monitor Context NULL");
7485 break;
7486 }
7487 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7488 __func__, apps_args[0], apps_args[1], apps_args[2],
7489 apps_args[3], apps_args[4]);
7490 /* Input Validation part of FW */
7491 pMonCtx->ChannelNo = apps_args[0];
7492 pMonCtx->ChannelBW = apps_args[1];
7493 pMonCtx->crcCheckEnabled = apps_args[2];
7494 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7495 pMonCtx->is80211to803ConReq = apps_args[4];
7496 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7497 if( pMonCtx->is80211to803ConReq )
7498 pAdapter->dev->type = ARPHRD_ETHER;
7499 else
7500 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7501 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7502 {
7503 hddLog(LOGE, "%s: Filtering data packets as management and control"
7504 " cannot be converted to 802.3 ",__func__);
7505 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7506 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307507 if (MON_MODE_START == pMonCtx->state) {
7508 magic = MON_MODE_MSG_MAGIC;
7509 init_completion(&cmpVar);
7510 if (VOS_STATUS_SUCCESS !=
7511 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7512 pMonCtx, hdd_monPostMsgCb)) {
7513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7514 FL("failed to post MON MODE REQ"));
7515 magic = 0;
7516 ret = -EIO;
7517 break;
7518 }
7519 waitRet = wait_for_completion_timeout(&cmpVar,
7520 MON_MODE_MSG_TIMEOUT);
7521 magic = 0;
7522 if (waitRet <= 0 ) {
7523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7524 FL("failed to wait on monitor mode completion %ld"),
7525 waitRet);
7526 }
7527 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307528 }
7529 break;
7530
7531 case WE_SET_MONITOR_MODE_FILTER:
7532 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307533 v_U32_t magic = 0;
7534 struct completion cmpVar;
7535 long waitRet = 0;
7536
Katya Nigamf0511f62015-05-05 16:40:57 +05307537 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7538 if( pMonCtx == NULL )
7539 {
7540 hddLog(LOGE, "Monitor Context NULL");
7541 break;
7542 }
7543 /* Input Validation Part of FW */
7544 pMonCtx->numOfMacFilters=1;
7545 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7546 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7547 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7548 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7549 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7550 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7551 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7552 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7553 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7554 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7555 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7556 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307557 if (MON_MODE_START == pMonCtx->state) {
7558 magic = MON_MODE_MSG_MAGIC;
7559 init_completion(&cmpVar);
7560 if (VOS_STATUS_SUCCESS !=
7561 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7562 pMonCtx, hdd_monPostMsgCb)) {
7563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7564 FL("failed to post MON MODE REQ"));
7565 magic = 0;
7566 ret = -EIO;
7567 break;
7568 }
7569 waitRet = wait_for_completion_timeout(&cmpVar,
7570 MON_MODE_MSG_TIMEOUT);
7571 magic = 0;
7572 if (waitRet <= 0 ) {
7573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7574 FL("failed to wait on monitor mode completion %ld"),
7575 waitRet);
7576 }
7577 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307578 }
7579 break;
7580
Jeff Johnson295189b2012-06-20 16:38:30 -07007581 default:
7582 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007583 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7584 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007585 }
7586 break;
7587 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307588 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007589 return 0;
7590}
7591
Girish Gowlifb9758e2014-11-19 15:19:17 +05307592static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7593 struct iw_request_info *info,
7594 union iwreq_data *wrqu, char *extra)
7595{
7596 int ret;
7597 union iwreq_data u_priv_wrqu;
7598 int apps_args[MAX_VAR_ARGS] = {0};
7599 int num_args;
7600
7601 /* helper function to get iwreq_data with compat handling. */
7602 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7603 {
7604 return -EINVAL;
7605 }
7606
7607 if (NULL == u_priv_wrqu.data.pointer)
7608 {
7609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7610 "%s: NULL data pointer", __func__);
7611 return -EINVAL;
7612 }
7613
7614 num_args = u_priv_wrqu.data.length;
7615 if (num_args > MAX_VAR_ARGS)
7616 {
7617 num_args = MAX_VAR_ARGS;
7618 }
7619
7620 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7621 (sizeof(int)) * num_args))
7622 {
7623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7624 "%s: failed to copy data from user buffer", __func__);
7625 return -EFAULT;
7626 }
7627
7628 vos_ssr_protect(__func__);
7629 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7630 (char *)&apps_args);
7631 vos_ssr_unprotect(__func__);
7632
7633 return ret;
7634}
7635
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307636int iw_set_var_ints_getnone(struct net_device *dev,
7637 struct iw_request_info *info,
7638 union iwreq_data *wrqu, char *extra)
7639{
7640 int ret;
7641 vos_ssr_protect(__func__);
7642 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7643 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007644
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307645 return ret;
7646}
7647
7648static int __iw_add_tspec(struct net_device *dev,
7649 struct iw_request_info *info,
7650 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007651{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307652 hdd_adapter_t *pAdapter;
7653 hdd_station_ctx_t *pHddStaCtx;
7654 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7656 int params[HDD_WLAN_WMM_PARAM_COUNT];
7657 sme_QosWmmTspecInfo tSpec;
7658 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307659 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307660 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007661
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307662 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307663 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7664 if (NULL == pAdapter)
7665 {
7666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7667 "%s: Adapter is NULL",__func__);
7668 return -EINVAL;
7669 }
7670 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7671 ret = wlan_hdd_validate_context(pHddCtx);
7672 if (0 != ret)
7673 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307674 return ret;
7675 }
7676 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7677 if (NULL == pHddStaCtx)
7678 {
7679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7680 "%s: STA Context is NULL",__func__);
7681 return -EINVAL;
7682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 // make sure the application is sufficiently priviledged
7684 // note that the kernel will do this for "set" ioctls, but since
7685 // this ioctl wants to return status to user space it must be
7686 // defined as a "get" ioctl
7687 if (!capable(CAP_NET_ADMIN))
7688 {
7689 return -EPERM;
7690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007691 // we must be associated in order to add a tspec
7692 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7693 {
7694 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7695 return 0;
7696 }
7697
7698 // since we are defined to be a "get" ioctl, and since the number
7699 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307700 // will pass down in the iwreq_data, we must copy the "set" params.
7701 // We must handle the compat for iwreq_data in 32U/64K environment.
7702
7703 // helper fucntion to get iwreq_data with compat handling.
7704 if (hdd_priv_get_data(&s_priv_data, wrqu))
7705 {
7706 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7707 return 0;
7708 }
7709
7710 // make sure all params are correctly passed to function
7711 if ((NULL == s_priv_data.pointer) ||
7712 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7713 {
7714 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7715 return 0;
7716 }
7717
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307719 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007720 {
7721 // hmmm, can't get them
7722 return -EIO;
7723 }
7724
7725 // clear the tspec
7726 memset(&tSpec, 0, sizeof(tSpec));
7727
7728 // validate the handle
7729 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7730 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7731 {
7732 // that one is reserved
7733 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7734 return 0;
7735 }
7736
7737 // validate the TID
7738 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7739 {
7740 // out of range
7741 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7742 return 0;
7743 }
7744 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7745
7746 // validate the direction
7747 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7748 {
7749 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7750 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7751 break;
7752
7753 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7754 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7755 break;
7756
7757 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7758 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7759 break;
7760
7761 default:
7762 // unknown
7763 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7764 return 0;
7765 }
7766
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307767 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7768
Jeff Johnson295189b2012-06-20 16:38:30 -07007769 // validate the user priority
7770 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7771 {
7772 // out of range
7773 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7774 return 0;
7775 }
7776 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307777 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7778 {
7779 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7780 return 0;
7781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007782
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7784 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7785 tSpec.ts_info.psb, tSpec.ts_info.up);
7786
Jeff Johnson295189b2012-06-20 16:38:30 -07007787 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7788 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7789 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7790 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7791 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7792 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7793 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7794 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7795 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7796 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7797 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7798 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7799
7800 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7801
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307802 // Save the expected UAPSD settings by application, this will be needed
7803 // when re-negotiating UAPSD settings during BT Coex cases.
7804 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7805
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 // validate the ts info ack policy
7807 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7808 {
7809 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7810 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7811 break;
7812
7813 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7814 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7815 break;
7816
7817 default:
7818 // unknown
7819 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7820 return 0;
7821 }
7822
7823 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307824
7825 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 return 0;
7827}
7828
7829
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307830static int iw_add_tspec(struct net_device *dev,
7831 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007832 union iwreq_data *wrqu, char *extra)
7833{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307834 int ret;
7835
7836 vos_ssr_protect(__func__);
7837 ret = __iw_add_tspec(dev, info, wrqu, extra);
7838 vos_ssr_unprotect(__func__);
7839
7840 return ret;
7841}
7842
7843static int __iw_del_tspec(struct net_device *dev,
7844 struct iw_request_info *info,
7845 union iwreq_data *wrqu, char *extra)
7846{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307847 hdd_adapter_t *pAdapter;
7848 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 int *params = (int *)extra;
7850 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7851 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307852 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007853
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307854 ENTER();
7855
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307856 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7857 if (NULL == pAdapter)
7858 {
7859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7860 "%s: Adapter is NULL",__func__);
7861 return -EINVAL;
7862 }
7863
7864 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7865 ret = wlan_hdd_validate_context(pHddCtx);
7866 if (0 != ret)
7867 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307868 return ret;
7869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 // make sure the application is sufficiently priviledged
7871 // note that the kernel will do this for "set" ioctls, but since
7872 // this ioctl wants to return status to user space it must be
7873 // defined as a "get" ioctl
7874 if (!capable(CAP_NET_ADMIN))
7875 {
7876 return -EPERM;
7877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 // although we are defined to be a "get" ioctl, the params we require
7879 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7880 // is no need to copy the params from user space
7881
7882 // validate the handle
7883 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7884 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7885 {
7886 // that one is reserved
7887 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7888 return 0;
7889 }
7890
7891 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307892
7893 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 return 0;
7895}
7896
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307897static int iw_del_tspec(struct net_device *dev,
7898 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 union iwreq_data *wrqu, char *extra)
7900{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307901 int ret;
7902
7903 vos_ssr_protect(__func__);
7904 ret = __iw_del_tspec(dev, info, wrqu, extra);
7905 vos_ssr_unprotect(__func__);
7906
7907 return ret;
7908}
7909
7910
7911static int __iw_get_tspec(struct net_device *dev,
7912 struct iw_request_info *info,
7913 union iwreq_data *wrqu, char *extra)
7914{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307915 hdd_adapter_t *pAdapter;
7916 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007917 int *params = (int *)extra;
7918 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7919 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307920 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007921
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307922 ENTER();
7923
Jeff Johnson295189b2012-06-20 16:38:30 -07007924 // although we are defined to be a "get" ioctl, the params we require
7925 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7926 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307927 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7928 if (NULL == pAdapter)
7929 {
7930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7931 "%s: Adapter is NULL",__func__);
7932 return -EINVAL;
7933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007934
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307935 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7936 ret = wlan_hdd_validate_context(pHddCtx);
7937 if (0 != ret)
7938 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307939 return ret;
7940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007941 // validate the handle
7942 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7943 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7944 {
7945 // that one is reserved
7946 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7947 return 0;
7948 }
7949
7950 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307951 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 return 0;
7953}
7954
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307955static int iw_get_tspec(struct net_device *dev,
7956 struct iw_request_info *info,
7957 union iwreq_data *wrqu, char *extra)
7958{
7959 int ret;
7960
7961 vos_ssr_protect(__func__);
7962 ret = __iw_get_tspec(dev, info, wrqu, extra);
7963 vos_ssr_unprotect(__func__);
7964
7965 return ret;
7966}
7967
Jeff Johnson295189b2012-06-20 16:38:30 -07007968#ifdef WLAN_FEATURE_VOWIFI_11R
7969//
7970//
7971// Each time the supplicant has the auth_request or reassoc request
7972// IEs ready. This is pushed to the driver. The driver will inturn use
7973// it to send out the auth req and reassoc req for 11r FT Assoc.
7974//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307975static int __iw_set_fties(struct net_device *dev,
7976 struct iw_request_info *info,
7977 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007978{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307979 hdd_adapter_t *pAdapter;
7980 hdd_station_ctx_t *pHddStaCtx;
7981 hdd_context_t *pHddCtx;
7982 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007983 //v_CONTEXT_t pVosContext;
7984
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307985 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307986 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7987 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007988 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7990 "%s: Adapter is NULL",__func__);
7991 return -EINVAL;
7992 }
7993 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7994 ret = wlan_hdd_validate_context(pHddCtx);
7995 if (0 != ret)
7996 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307997 return ret;
7998 }
7999 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8000 if (NULL == pHddStaCtx)
8001 {
8002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8003 "%s: STA Context is NULL",__func__);
8004 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 if (!wrqu->data.length)
8007 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008008 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008009 return -EINVAL;
8010 }
8011 if (wrqu->data.pointer == NULL)
8012 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008013 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008014 return -EINVAL;
8015 }
8016
8017 // Added for debug on reception of Re-assoc Req.
8018 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8019 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008020 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008021 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008022 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008023 }
8024
8025#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008026 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008027#endif
8028
8029 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008030 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008031 wrqu->data.length);
8032
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308033 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008034 return 0;
8035}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308036
8037static int iw_set_fties(struct net_device *dev,
8038 struct iw_request_info *info,
8039 union iwreq_data *wrqu, char *extra)
8040{
8041 int ret;
8042
8043 vos_ssr_protect(__func__);
8044 ret = __iw_set_fties(dev, info, wrqu, extra);
8045 vos_ssr_unprotect(__func__);
8046
8047 return ret;
8048}
Jeff Johnson295189b2012-06-20 16:38:30 -07008049#endif
8050
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308051static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008052 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008054{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308055 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008056 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308057 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008058 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308059 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008060 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8061 int idx;
8062 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008063
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308064 ENTER();
8065
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308066 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8067 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008068 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8070 "%s: Adapter is NULL",__func__);
8071 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008072 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308073 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8074 ret_val = wlan_hdd_validate_context(pHddCtx);
8075 if (0 != ret_val)
8076 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308077 return ret_val;
8078 }
8079 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8080 if (NULL == hHal)
8081 {
8082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8083 "%s: Hal Context is NULL",__func__);
8084 return -EINVAL;
8085 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308086 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8087 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308088#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008089
Amar Singhalf3a6e762013-02-19 15:06:50 -08008090 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8091 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008092 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008093 hddLog(VOS_TRACE_LEVEL_ERROR,
8094 "%s: vos_mem_alloc failed", __func__);
8095 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008096 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008097
8098 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8099
8100 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8101 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8102
8103 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8104 mc_addr_list_ptr->ulMulticastAddrCnt);
8105
8106 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008107 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008108 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8109 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8110
8111 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8112 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008113 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008114
Amar Singhalf3a6e762013-02-19 15:06:50 -08008115 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8116 vos_mem_free(mc_addr_list_ptr);
8117 if (eHAL_STATUS_SUCCESS != ret_val)
8118 {
8119 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8120 __func__);
8121 return -EINVAL;
8122 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308123#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308124 }
8125 else
8126 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008127
Amar Singhalf3a6e762013-02-19 15:06:50 -08008128 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8129 "%s: Set MC BC Filter Config request: %d suspend %d",
8130 __func__, pRequest->mcastBcastFilterSetting,
8131 pHddCtx->hdd_wlan_suspended);
8132
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308133 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008134
8135 if (pHddCtx->hdd_wlan_suspended)
8136 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008137 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8138 if (NULL == wlanRxpFilterParam)
8139 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308140 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008141 "%s: vos_mem_alloc failed", __func__);
8142 return -EINVAL;
8143 }
8144
Amar Singhalf3a6e762013-02-19 15:06:50 -08008145 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8146 pRequest->mcastBcastFilterSetting;
8147 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8148
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308149 hdd_conf_hostoffload(pAdapter, TRUE);
8150 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8151 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008152
8153 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8154 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308155 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008156 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8157 wlanRxpFilterParam->setMcstBcstFilter);
8158
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308159 if (eHAL_STATUS_SUCCESS !=
8160 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8161 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008162 {
8163 hddLog(VOS_TRACE_LEVEL_ERROR,
8164 "%s: Failure to execute set HW MC/BC Filter request",
8165 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008166 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008167 return -EINVAL;
8168 }
8169
c_hpothud3ce76d2014-10-28 10:34:13 +05308170 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8171 {
8172 pHddCtx->sus_res_mcastbcast_filter =
8173 pRequest->mcastBcastFilterSetting;
8174 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008175 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008177
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308178 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 return 0;
8180}
8181
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308182static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8183 struct iw_request_info *info,
8184 union iwreq_data *wrqu, char *extra)
8185{
8186 int ret;
8187
8188 vos_ssr_protect(__func__);
8189 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8190 vos_ssr_unprotect(__func__);
8191
8192 return ret;
8193}
8194
8195static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8196 struct iw_request_info *info,
8197 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008198{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308199 hdd_adapter_t *pAdapter;
8200 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308201 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308202 int ret = 0;
8203
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308204 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008205
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308206 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8207 if (NULL == pAdapter)
8208 {
8209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8210 "%s: Adapter is NULL",__func__);
8211 return -EINVAL;
8212 }
8213
8214 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8215 ret = wlan_hdd_validate_context(pHddCtx);
8216 if (0 != ret)
8217 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308218 return ret;
8219 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308220 //Reset the filter to INI value as we have to clear the dynamic filter
8221 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008222
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308223 //Configure FW with new setting
8224 if (pHddCtx->hdd_wlan_suspended)
8225 {
8226 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8227 if (NULL == wlanRxpFilterParam)
8228 {
8229 hddLog(VOS_TRACE_LEVEL_ERROR,
8230 "%s: vos_mem_alloc failed", __func__);
8231 return -EINVAL;
8232 }
8233
8234 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8235 pHddCtx->configuredMcastBcastFilter;
8236 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8237
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308238 hdd_conf_hostoffload(pAdapter, TRUE);
8239 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8240 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308241
8242 if (eHAL_STATUS_SUCCESS !=
8243 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8244 wlanRxpFilterParam))
8245 {
8246 hddLog(VOS_TRACE_LEVEL_ERROR,
8247 "%s: Failure to execute set HW MC/BC Filter request",
8248 __func__);
8249 vos_mem_free(wlanRxpFilterParam);
8250 return -EINVAL;
8251 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308252
8253 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8254 {
8255 pHddCtx->sus_res_mcastbcast_filter =
8256 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8257 }
8258
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308259 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308260 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008261 return 0;
8262}
8263
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308264
8265static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8266 struct iw_request_info *info,
8267 union iwreq_data *wrqu, char *extra)
8268{
8269 int ret;
8270
8271 vos_ssr_protect(__func__);
8272 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8273 vos_ssr_unprotect(__func__);
8274
8275 return ret;
8276}
8277
8278static int __iw_set_host_offload(struct net_device *dev,
8279 struct iw_request_info *info,
8280 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008281{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308282 hdd_adapter_t *pAdapter;
8283 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008284 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008285 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308286 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008287
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308288 ENTER();
8289
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308290 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8291 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008292 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8294 "%s: Adapter is NULL",__func__);
8295 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008296 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308297 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8298 ret = wlan_hdd_validate_context(pHddCtx);
8299 if (0 != ret)
8300 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308301 return ret;
8302 }
8303
Jeff Johnson295189b2012-06-20 16:38:30 -07008304 /* Debug display of request components. */
8305 switch (pRequest->offloadType)
8306 {
8307 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008308 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 switch (pRequest->enableOrDisable)
8310 {
8311 case WLAN_OFFLOAD_DISABLE:
8312 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8313 break;
8314 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8315 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8316 case WLAN_OFFLOAD_ENABLE:
8317 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8318 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8319 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8320 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8321 }
8322 break;
8323
8324 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008325 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008326 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008327 switch (pRequest->enableOrDisable)
8328 {
8329 case WLAN_OFFLOAD_DISABLE:
8330 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8331 break;
8332 case WLAN_OFFLOAD_ENABLE:
8333 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8334 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8335 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8336 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8337 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8338 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8339 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8340 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8341 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8342 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8343 }
8344 }
8345
8346 /* Execute offload request. The reason that we can copy the request information
8347 from the ioctl structure to the SME structure is that they are laid out
8348 exactly the same. Otherwise, each piece of information would have to be
8349 copied individually. */
8350 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008351 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8352 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008353 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008354 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 __func__);
8356 return -EINVAL;
8357 }
8358
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308359 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 return 0;
8361}
8362
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308363static int iw_set_host_offload(struct net_device *dev,
8364 struct iw_request_info *info,
8365 union iwreq_data *wrqu, char *extra)
8366{
8367 int ret;
8368
8369 vos_ssr_protect(__func__);
8370 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8371 vos_ssr_unprotect(__func__);
8372
8373 return ret;
8374}
8375
8376static int __iw_set_keepalive_params(struct net_device *dev,
8377 struct iw_request_info *info,
8378 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008379{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308380 hdd_adapter_t *pAdapter;
8381 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008382 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008383 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308384 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008385
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308386 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308387 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8388 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008389 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8391 "%s: Adapter is NULL",__func__);
8392 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008393 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308394 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8395 ret = wlan_hdd_validate_context(pHddCtx);
8396 if (0 != ret)
8397 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308398 return ret;
8399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008401 hddLog(VOS_TRACE_LEVEL_INFO,
8402 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8403 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008404
8405 switch (pRequest->packetType)
8406 {
8407 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008408 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 break;
8410
8411 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8412
Arif Hussain6d2a3322013-11-17 19:50:10 -08008413 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008414 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008415
8416 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8417 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8418 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8419
8420 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8421 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8422 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8423
8424 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8425 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8426 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8427 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8428 break;
8429
8430 }
8431
8432 /* Execute keep alive request. The reason that we can copy the request information
8433 from the ioctl structure to the SME structure is that they are laid out
8434 exactly the same. Otherwise, each piece of information would have to be
8435 copied individually. */
8436 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8437
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308438 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8439 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008440
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008441 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008442 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008444 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 __func__);
8446 return -EINVAL;
8447 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308448 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 return 0;
8450}
8451
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308452static int iw_set_keepalive_params(struct net_device *dev,
8453 struct iw_request_info *info,
8454 union iwreq_data *wrqu, char *extra)
8455{
8456 int ret;
8457 vos_ssr_protect(__func__);
8458 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8459 vos_ssr_unprotect(__func__);
8460
8461 return ret;
8462}
8463
Jeff Johnson295189b2012-06-20 16:38:30 -07008464#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008465int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008466 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008467{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008468 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8469 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 int i=0;
8471
8472 if (pHddCtx->cfg_ini->disablePacketFilter)
8473 {
8474 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008475 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 return 0;
8477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 /* Debug display of request components. */
8479 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008480 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008481
8482 switch (pRequest->filterAction)
8483 {
8484 case HDD_RCV_FILTER_SET:
8485 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008486 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008487
8488 packetFilterSetReq.filterId = pRequest->filterId;
8489 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8490 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008491 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008492 __func__, pRequest->numParams);
8493 return -EINVAL;
8494 }
8495 packetFilterSetReq.numFieldParams = pRequest->numParams;
8496 packetFilterSetReq.coalesceTime = 0;
8497 packetFilterSetReq.filterType = 1;
8498 for (i=0; i < pRequest->numParams; i++)
8499 {
8500 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8501 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8502 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8503 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8504 packetFilterSetReq.paramsData[i].reserved = 0;
8505
Arif Hussain6d2a3322013-11-17 19:50:10 -08008506 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8508 packetFilterSetReq.filterType);
8509
Arif Hussain6d2a3322013-11-17 19:50:10 -08008510 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05308512 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
8513 (pRequest->paramsData[i].dataLength))
8514 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008515
8516 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8517 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8518 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8519 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8520
Arif Hussain6d2a3322013-11-17 19:50:10 -08008521 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008522 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8523 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8524 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8525
Arif Hussain6d2a3322013-11-17 19:50:10 -08008526 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008527 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8528 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8529 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8530 }
8531
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008532 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008534 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 __func__);
8536 return -EINVAL;
8537 }
8538
8539 break;
8540
8541 case HDD_RCV_FILTER_CLEAR:
8542
Arif Hussain6d2a3322013-11-17 19:50:10 -08008543 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008544 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008546 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008548 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 __func__);
8550 return -EINVAL;
8551 }
8552 break;
8553
8554 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008555 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008556 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008557 return -EINVAL;
8558 }
8559 return 0;
8560}
8561
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308562int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8563 tANI_U8 sessionId)
8564{
8565 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8566 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8567
8568 if (NULL == pHddCtx)
8569 {
8570 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8571 return -EINVAL;
8572 }
8573
8574 if (pHddCtx->isLogpInProgress)
8575 {
8576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8577 "%s:LOGP in Progress. Ignore!!!", __func__);
8578 return -EBUSY;
8579 }
8580
8581 if (pHddCtx->cfg_ini->disablePacketFilter)
8582 {
8583 hddLog(VOS_TRACE_LEVEL_ERROR,
8584 "%s: Packet Filtering Disabled. Returning ",
8585 __func__ );
8586 return -EINVAL;
8587 }
8588
8589 switch (filterType)
8590 {
8591 /* For setting IPV6 MC and UC Filter we need to configure
8592 * 2 filters, one for MC and one for UC.
8593 * The Filter ID shouldn't be swapped, which results in making
8594 * UC Filter ineffective.
8595 * We have Hardcode all the values
8596 *
8597 * Reason for a seperate UC filter is because, driver need to
8598 * specify the FW that the specific filter is for unicast
8599 * otherwise FW will not pass the unicast frames by default
8600 * through the filter. This is required to avoid any performance
8601 * hits when no unicast filter is set and only MC/BC are set.
8602 * The way driver informs host is by using the MAC protocol
8603 * layer, CMP flag set to MAX, CMP Data set to 1.
8604 */
8605
8606 case HDD_FILTER_IPV6_MC_UC:
8607 /* Setting IPV6 MC Filter below
8608 */
8609 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8610 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8611 packetFilterSetReq.numFieldParams = 2;
8612 packetFilterSetReq.paramsData[0].protocolLayer =
8613 HDD_FILTER_PROTO_TYPE_MAC;
8614 packetFilterSetReq.paramsData[0].cmpFlag =
8615 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8616 packetFilterSetReq.paramsData[0].dataOffset =
8617 WLAN_HDD_80211_FRM_DA_OFFSET;
8618 packetFilterSetReq.paramsData[0].dataLength = 1;
8619 packetFilterSetReq.paramsData[0].compareData[0] =
8620 HDD_IPV6_MC_CMP_DATA;
8621
8622 packetFilterSetReq.paramsData[1].protocolLayer =
8623 HDD_FILTER_PROTO_TYPE_ARP;
8624 packetFilterSetReq.paramsData[1].cmpFlag =
8625 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8626 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8627 packetFilterSetReq.paramsData[1].dataLength = 2;
8628 packetFilterSetReq.paramsData[1].compareData[0] =
8629 HDD_IPV6_CMP_DATA_0;
8630 packetFilterSetReq.paramsData[1].compareData[1] =
8631 HDD_IPV6_CMP_DATA_1;
8632
8633
8634 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8635 &packetFilterSetReq, sessionId))
8636 {
8637 hddLog(VOS_TRACE_LEVEL_ERROR,
8638 "%s: Failure to execute Set IPv6 Mulicast Filter",
8639 __func__);
8640 return -EINVAL;
8641 }
8642
8643 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8644
8645 /*
8646 * Setting IPV6 UC Filter below
8647 */
8648 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8649 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8650 packetFilterSetReq.numFieldParams = 2;
8651 packetFilterSetReq.paramsData[0].protocolLayer =
8652 HDD_FILTER_PROTO_TYPE_MAC;
8653 packetFilterSetReq.paramsData[0].cmpFlag =
8654 HDD_FILTER_CMP_TYPE_MAX;
8655 packetFilterSetReq.paramsData[0].dataOffset = 0;
8656 packetFilterSetReq.paramsData[0].dataLength = 1;
8657 packetFilterSetReq.paramsData[0].compareData[0] =
8658 HDD_IPV6_UC_CMP_DATA;
8659
8660 packetFilterSetReq.paramsData[1].protocolLayer =
8661 HDD_FILTER_PROTO_TYPE_ARP;
8662 packetFilterSetReq.paramsData[1].cmpFlag =
8663 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8664 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8665 packetFilterSetReq.paramsData[1].dataLength = 2;
8666 packetFilterSetReq.paramsData[1].compareData[0] =
8667 HDD_IPV6_CMP_DATA_0;
8668 packetFilterSetReq.paramsData[1].compareData[1] =
8669 HDD_IPV6_CMP_DATA_1;
8670
8671 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8672 &packetFilterSetReq, sessionId))
8673 {
8674 hddLog(VOS_TRACE_LEVEL_ERROR,
8675 "%s: Failure to execute Set IPv6 Unicast Filter",
8676 __func__);
8677 return -EINVAL;
8678 }
8679
8680 break;
8681
8682 case HDD_FILTER_IPV6_MC:
8683 /*
8684 * IPV6 UC Filter might be already set,
8685 * clear the UC Filter. As the Filter
8686 * IDs are static, we can directly clear it.
8687 */
8688 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8689 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8690 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8691 &packetFilterClrReq, sessionId))
8692 {
8693 hddLog(VOS_TRACE_LEVEL_ERROR,
8694 "%s: Failure to execute Clear IPv6 Unicast Filter",
8695 __func__);
8696 return -EINVAL;
8697 }
8698
8699 /*
8700 * Setting IPV6 MC Filter below
8701 */
8702 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8703 packetFilterSetReq.numFieldParams = 2;
8704 packetFilterSetReq.paramsData[0].protocolLayer =
8705 HDD_FILTER_PROTO_TYPE_MAC;
8706 packetFilterSetReq.paramsData[0].cmpFlag =
8707 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8708 packetFilterSetReq.paramsData[0].dataOffset =
8709 WLAN_HDD_80211_FRM_DA_OFFSET;
8710 packetFilterSetReq.paramsData[0].dataLength = 1;
8711 packetFilterSetReq.paramsData[0].compareData[0] =
8712 HDD_IPV6_MC_CMP_DATA;
8713
8714 packetFilterSetReq.paramsData[1].protocolLayer =
8715 HDD_FILTER_PROTO_TYPE_ARP;
8716 packetFilterSetReq.paramsData[1].cmpFlag =
8717 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8718 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8719 packetFilterSetReq.paramsData[1].dataLength = 2;
8720 packetFilterSetReq.paramsData[1].compareData[0] =
8721 HDD_IPV6_CMP_DATA_0;
8722 packetFilterSetReq.paramsData[1].compareData[1] =
8723 HDD_IPV6_CMP_DATA_1;
8724
8725
8726 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8727 &packetFilterSetReq, sessionId))
8728 {
8729 hddLog(VOS_TRACE_LEVEL_ERROR,
8730 "%s: Failure to execute Set IPv6 Multicast Filter",
8731 __func__);
8732 return -EINVAL;
8733 }
8734 break;
8735
8736 default :
8737 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8738 "%s: Packet Filter Request: Invalid",
8739 __func__);
8740 return -EINVAL;
8741 }
8742 return 0;
8743}
8744
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308745void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008746{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308747 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308748 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008749 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308750 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008751
Yue Ma3ede6052013-08-29 00:33:26 -07008752 if (NULL == pHddCtx)
8753 {
8754 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8755 return;
8756 }
8757
8758 hHal = pHddCtx->hHal;
8759
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308760 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308762 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8763 return;
8764 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308765
8766 /* Check if INI is enabled or not, other wise just return
8767 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308768 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308769 {
8770 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8771 if (NULL == pMulticastAddrs)
8772 {
8773 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8774 return;
8775 }
8776
Jeff Johnson295189b2012-06-20 16:38:30 -07008777 if (set)
8778 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308779 /* Following pre-conditions should be satisfied before wei
8780 * configure the MC address list.
8781 */
8782 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8783 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8784 && pAdapter->mc_addr_list.mc_cnt
8785 && (eConnectionState_Associated ==
8786 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8787 {
8788 pMulticastAddrs->ulMulticastAddrCnt =
8789 pAdapter->mc_addr_list.mc_cnt;
8790 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8791 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008792 memcpy(pMulticastAddrs->multicastAddr[i],
8793 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308794 sizeof(pAdapter->mc_addr_list.addr[i]));
8795 hddLog(VOS_TRACE_LEVEL_INFO,
8796 "%s: %s multicast filter: addr ="
8797 MAC_ADDRESS_STR,
8798 __func__, set ? "setting" : "clearing",
8799 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8800 }
8801 /* Set multicast filter */
8802 sme_8023MulticastList(hHal, pAdapter->sessionId,
8803 pMulticastAddrs);
8804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008805 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308806 else
8807 {
8808 /* Need to clear only if it was previously configured
8809 */
8810 if (pAdapter->mc_addr_list.isFilterApplied)
8811 {
8812 pMulticastAddrs->ulMulticastAddrCnt = 0;
8813 sme_8023MulticastList(hHal, pAdapter->sessionId,
8814 pMulticastAddrs);
8815 }
8816
8817 }
8818 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008819 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308821 else
8822 {
8823 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308824 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308825 }
8826 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008827}
8828
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308829static int __iw_set_packet_filter_params(struct net_device *dev,
8830 struct iw_request_info *info,
8831 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308832{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308833 hdd_adapter_t *pAdapter;
8834 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008835 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308836 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308837 struct iw_point s_priv_data;
8838
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308839 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308840 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8841 if (NULL == pAdapter)
8842 {
8843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8844 "%s: Adapter is NULL",__func__);
8845 return -EINVAL;
8846 }
8847 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8848 ret = wlan_hdd_validate_context(pHddCtx);
8849 if (0 != ret)
8850 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308851 return ret;
8852 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308853 if (hdd_priv_get_data(&s_priv_data, wrqu))
8854 {
8855 return -EINVAL;
8856 }
8857
8858 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8859 {
8860 return -EINVAL;
8861 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008862
Arif Hussain0273cba2014-01-07 20:58:29 -08008863 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308864 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8865 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008866 if (NULL == pRequest)
8867 {
8868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8869 "mem_alloc_copy_from_user_helper fail");
8870 return -ENOMEM;
8871 }
8872
8873 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8874 kfree(pRequest);
8875
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308876 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008877 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008878}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308879
8880static int iw_set_packet_filter_params(struct net_device *dev,
8881 struct iw_request_info *info,
8882 union iwreq_data *wrqu, char *extra)
8883{
8884 int ret;
8885
8886 vos_ssr_protect(__func__);
8887 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8888 vos_ssr_unprotect(__func__);
8889
8890 return ret;
8891}
Jeff Johnson295189b2012-06-20 16:38:30 -07008892#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308893static int __iw_get_statistics(struct net_device *dev,
8894 struct iw_request_info *info,
8895 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008896{
8897
8898 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8899 eHalStatus status = eHAL_STATUS_SUCCESS;
8900 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308901 hdd_adapter_t *pAdapter;
8902 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008903 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308904 int tlen = 0, ret = 0;
8905 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008906
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308907 tCsrGlobalClassAStatsInfo *aStats;
8908 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008909
8910 ENTER();
8911
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308912 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8913 if (NULL == pAdapter)
8914 {
8915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8916 "%s: Adapter is NULL",__func__);
8917 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008918 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308919 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8920 ret = wlan_hdd_validate_context(pHddCtx);
8921 if (0 != ret)
8922 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308923 return ret;
8924 }
8925 pStats = &(pAdapter->hdd_stats.summary_stat);
8926 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8927 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8929
8930 wrqu->txpower.value = 0;
8931 }
8932 else {
8933 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8934 SME_SUMMARY_STATS |
8935 SME_GLOBAL_CLASSA_STATS |
8936 SME_GLOBAL_CLASSB_STATS |
8937 SME_GLOBAL_CLASSC_STATS |
8938 SME_GLOBAL_CLASSD_STATS |
8939 SME_PER_STA_STATS,
8940 hdd_StatisticsCB, 0, FALSE,
8941 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8942
8943 if (eHAL_STATUS_SUCCESS != status)
8944 {
8945 hddLog(VOS_TRACE_LEVEL_ERROR,
8946 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008947 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008948 return -EINVAL;
8949 }
8950
8951 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308952 if (NULL == pWextState)
8953 {
8954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8955 "%s: pWextState is NULL",__func__);
8956 return -EINVAL;
8957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008958
8959 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8960 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8961 {
8962 hddLog(VOS_TRACE_LEVEL_ERROR,
8963 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008964 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008965 /*Remove the SME statistics list by passing NULL in callback argument*/
8966 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8967 SME_SUMMARY_STATS |
8968 SME_GLOBAL_CLASSA_STATS |
8969 SME_GLOBAL_CLASSB_STATS |
8970 SME_GLOBAL_CLASSC_STATS |
8971 SME_GLOBAL_CLASSD_STATS |
8972 SME_PER_STA_STATS,
8973 NULL, 0, FALSE,
8974 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8975
8976 return -EINVAL;
8977 }
8978 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8979 (tANI_U8) sizeof (pStats->retry_cnt),
8980 (char*) &(pStats->retry_cnt[0]),
8981 tlen);
8982
8983 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8984 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8985 (char*) &(pStats->multiple_retry_cnt[0]),
8986 tlen);
8987
8988 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8989 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8990 (char*) &(pStats->tx_frm_cnt[0]),
8991 tlen);
8992
8993 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8994 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8995 (char*) &(pStats->rx_frm_cnt),
8996 tlen);
8997
8998 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8999 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9000 (char*) &(pStats->frm_dup_cnt),
9001 tlen);
9002
9003 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9004 (tANI_U8) sizeof (pStats->fail_cnt),
9005 (char*) &(pStats->fail_cnt[0]),
9006 tlen);
9007
9008 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9009 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9010 (char*) &(pStats->rts_fail_cnt),
9011 tlen);
9012
9013 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9014 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9015 (char*) &(pStats->ack_fail_cnt),
9016 tlen);
9017
9018 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9019 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9020 (char*) &(pStats->rts_succ_cnt),
9021 tlen);
9022
9023 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9024 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9025 (char*) &(pStats->rx_discard_cnt),
9026 tlen);
9027
9028 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9029 (tANI_U8) sizeof (pStats->rx_error_cnt),
9030 (char*) &(pStats->rx_error_cnt),
9031 tlen);
9032
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009033 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009034 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009035 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009036 tlen);
9037
9038 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9039 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9040 (char*) &(dStats->rx_byte_cnt),
9041 tlen);
9042
9043 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9044 (tANI_U8) sizeof (dStats->rx_rate),
9045 (char*) &(dStats->rx_rate),
9046 tlen);
9047
9048 /* Transmit rate, in units of 500 kbit/sec */
9049 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9050 (tANI_U8) sizeof (aStats->tx_rate),
9051 (char*) &(aStats->tx_rate),
9052 tlen);
9053
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009054 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9055 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9056 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009057 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009058 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9059 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9060 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009061 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009062 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9063 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9064 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009065 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009066 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9067 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9068 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009069 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009070 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9071 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9072 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009073 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009074 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9075 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9076 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009077 tlen);
9078
Jeff Johnson295189b2012-06-20 16:38:30 -07009079 wrqu->data.length = tlen;
9080
9081 }
9082
9083 EXIT();
9084
9085 return 0;
9086}
9087
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309088static int iw_get_statistics(struct net_device *dev,
9089 struct iw_request_info *info,
9090 union iwreq_data *wrqu, char *extra)
9091{
9092 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009093
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309094 vos_ssr_protect(__func__);
9095 ret = __iw_get_statistics(dev, info, wrqu, extra);
9096 vos_ssr_unprotect(__func__);
9097
9098 return ret;
9099}
Jeff Johnson295189b2012-06-20 16:38:30 -07009100#ifdef FEATURE_WLAN_SCAN_PNO
9101
9102/*Max Len for PNO notification*/
9103#define MAX_PNO_NOTIFY_LEN 100
9104void found_pref_network_cb (void *callbackContext,
9105 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9106{
9107 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9108 union iwreq_data wrqu;
9109 char buf[MAX_PNO_NOTIFY_LEN+1];
9110
9111 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9112 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9113
9114 // create the event
9115 memset(&wrqu, 0, sizeof(wrqu));
9116 memset(buf, 0, sizeof(buf));
9117
9118 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9119 pPrefNetworkFoundInd->ssId.ssId,
9120 (unsigned int)pPrefNetworkFoundInd->rssi);
9121
9122 wrqu.data.pointer = buf;
9123 wrqu.data.length = strlen(buf);
9124
9125 // send the event
9126
9127 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9128
9129}
9130
9131
9132/*string based input*/
9133VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9134 union iwreq_data *wrqu, char *extra, int nOffset)
9135{
9136 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309137 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009138 /* pnoRequest is a large struct, so we make it static to avoid stack
9139 overflow. This API is only invoked via ioctl, so it is
9140 serialized by the kernel rtnl_lock and hence does not need to be
9141 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309142 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 char *ptr;
9144 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309145 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9147
9148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9149 "PNO data len %d data %s",
9150 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009151 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009152
9153 if (wrqu->data.length <= nOffset )
9154 {
9155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9156 return VOS_STATUS_E_FAILURE;
9157 }
9158
9159 pnoRequest.enable = 0;
9160 pnoRequest.ucNetworksCount = 0;
9161 /*-----------------------------------------------------------------------
9162 Input is string based and expected to be like this:
9163
9164 <enabled> <netw_count>
9165 for each network:
9166 <ssid_len> <ssid> <authentication> <encryption>
9167 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9168 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9169
9170 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009171 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 -07009172
9173 this translates into:
9174 -----------------------------
9175 enable PNO
9176 look for 2 networks:
9177 test - with authentication type 0 and encryption type 0,
9178 that can be found on 3 channels: 1 6 and 11 ,
9179 SSID bcast type is unknown (directed probe will be sent if AP not found)
9180 and must meet -40dBm RSSI
9181
9182 test2 - with auth and enrytption type 4/4
9183 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9184 bcast type is non-bcast (directed probe will be sent)
9185 and must not meet any RSSI threshold
9186
Jeff Johnson8301aa12013-03-28 14:27:29 -07009187 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009188 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009189 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009190
Wilson Yang623f6592013-10-08 16:33:37 -07009191 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9192 {
9193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9194 "PNO enable input is not valid %s",ptr);
9195 return VOS_STATUS_E_FAILURE;
9196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009197
9198 if ( 0 == pnoRequest.enable )
9199 {
9200 /*Disable PNO*/
9201 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309202 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9203 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009204 pAdapter->sessionId,
9205 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309206 if (eHAL_STATUS_SUCCESS != status)
9207 {
9208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9209 "%s: failed to disable PNO", __func__);
9210 return VOS_STATUS_E_FAILURE;
9211 }
9212 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 return VOS_STATUS_SUCCESS;
9214 }
9215
c_hpothu37f21312014-04-09 21:49:54 +05309216 if (TRUE == pHddCtx->isPnoEnable)
9217 {
9218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9219 FL("already PNO is enabled"));
9220 return -EBUSY;
9221 }
9222 pHddCtx->isPnoEnable = TRUE;
9223
Jeff Johnson295189b2012-06-20 16:38:30 -07009224 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009225
9226 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9227 {
9228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9229 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309230 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009232
9233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9234 "PNO enable %d networks count %d offset %d",
9235 pnoRequest.enable,
9236 pnoRequest.ucNetworksCount,
9237 nOffset);
9238
9239 /* Parameters checking:
9240 ucNetworksCount has to be larger than 0*/
9241 if (( 0 == pnoRequest.ucNetworksCount ) ||
9242 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9243 {
9244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309245 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 }
9247
9248 ptr += nOffset;
9249
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309250 pnoRequest.aNetworks =
9251 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9252 if (pnoRequest.aNetworks == NULL)
9253 {
9254 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9255 FL("failed to allocate memory aNetworks %u"),
9256 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9257 goto error;
9258 }
9259 vos_mem_zero(pnoRequest.aNetworks,
9260 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9261
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9263 {
9264
9265 pnoRequest.aNetworks[i].ssId.length = 0;
9266
Wilson Yang623f6592013-10-08 16:33:37 -07009267 ucParams = sscanf(ptr,"%hhu %n",
9268 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9269
9270 if (1 != ucParams)
9271 {
9272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9273 "PNO ssid length input is not valid %s",ptr);
9274 return VOS_STATUS_E_FAILURE;
9275 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009276
9277 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9278 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9279 {
9280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9281 "SSID Len %d is not correct for network %d",
9282 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309283 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 }
9285
9286 /*Advance to SSID*/
9287 ptr += nOffset;
9288
Jeff Johnson8301aa12013-03-28 14:27:29 -07009289 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009290 pnoRequest.aNetworks[i].ssId.length);
9291 ptr += pnoRequest.aNetworks[i].ssId.length;
9292
Jeff Johnson02797792013-10-26 19:17:13 -07009293 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009294 &(pnoRequest.aNetworks[i].authentication),
9295 &(pnoRequest.aNetworks[i].encryption),
9296 &(pnoRequest.aNetworks[i].ucChannelCount),
9297 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009298
Wilson Yang623f6592013-10-08 16:33:37 -07009299 if ( 3 != ucParams )
9300 {
9301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9302 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309303 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009304 }
9305
Jeff Johnson295189b2012-06-20 16:38:30 -07009306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009307 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009308 "auth %d encry %d channel count %d offset %d",
9309 pnoRequest.aNetworks[i].ssId.length,
9310 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9311 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9312 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9313 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9314 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9315 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9316 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9317 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9318 pnoRequest.aNetworks[i].authentication,
9319 pnoRequest.aNetworks[i].encryption,
9320 pnoRequest.aNetworks[i].ucChannelCount,
9321 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009322
Jeff Johnson295189b2012-06-20 16:38:30 -07009323 /*Advance to channel list*/
9324 ptr += nOffset;
9325
Wilson Yang623f6592013-10-08 16:33:37 -07009326 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 {
9328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9329 "Incorrect number of channels");
9330 return VOS_STATUS_E_FAILURE;
9331 }
9332
9333 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9334 {
9335 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9336 {
Wilson Yang623f6592013-10-08 16:33:37 -07009337 if (1 != sscanf(ptr,"%hhu %n",
9338 &(pnoRequest.aNetworks[i].aChannels[j]),
9339 &nOffset))
9340 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9341 "PNO network channel input is not valid %s",ptr);
9342 return VOS_STATUS_E_FAILURE;
9343 }
9344 /*Advance to next channel number*/
9345 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009346 }
9347 }
9348
Jeff Johnson02797792013-10-26 19:17:13 -07009349 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009350 &(pnoRequest.aNetworks[i].bcastNetwType),
9351 &nOffset))
9352 {
9353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9354 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309355 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009356 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009357
9358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9359 "PNO bcastNetwType %d offset %d",
9360 pnoRequest.aNetworks[i].bcastNetwType,
9361 nOffset );
9362
9363 /*Advance to rssi Threshold*/
9364 ptr += nOffset;
9365
Wilson Yang623f6592013-10-08 16:33:37 -07009366 if (1 != sscanf(ptr,"%hhu %n",
9367 &(pnoRequest.aNetworks[i].rssiThreshold),
9368 &nOffset))
9369 {
9370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9371 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309372 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009374
9375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9376 "PNO rssi %d offset %d",
9377 pnoRequest.aNetworks[i].rssiThreshold,
9378 nOffset );
9379 /*Advance to next network*/
9380 ptr += nOffset;
9381 }/*For ucNetworkCount*/
9382
9383 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009384 &(pnoRequest.scanTimers.ucScanTimersCount),
9385 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009386
9387 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009388 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 {
9390 ptr += nOffset;
9391
Jeff Johnson8301aa12013-03-28 14:27:29 -07009392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9393 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 pnoRequest.scanTimers.ucScanTimersCount,
9395 nOffset );
9396
9397 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9398 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309401 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 }
9403
9404 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9405 {
Jeff Johnson02797792013-10-26 19:17:13 -07009406 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009407 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9408 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9409 &nOffset);
9410
Wilson Yang623f6592013-10-08 16:33:37 -07009411 if (2 != ucParams)
9412 {
9413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9414 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309415 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009416 }
9417
Jeff Johnson8301aa12013-03-28 14:27:29 -07009418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9419 "PNO Timer value %d Timer repeat %d offset %d",
9420 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009421 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9422 nOffset );
9423
Jeff Johnson295189b2012-06-20 16:38:30 -07009424 ptr += nOffset;
9425 }
9426
9427 }
9428 else
9429 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9431 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9433
9434 /*Scan timers defaults to 5 minutes*/
9435 pnoRequest.scanTimers.ucScanTimersCount = 1;
9436 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9437 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9438 }
9439
Wilson Yang623f6592013-10-08 16:33:37 -07009440 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009441
9442 pnoRequest.modePNO = ucMode;
9443 /*for LA we just expose suspend option*/
9444 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9445 {
9446 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9447 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309448 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9449 if (pnoRequest.p24GProbeTemplate == NULL){
9450 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9451 FL("failed to allocate memory p24GProbeTemplate %u"),
9452 SIR_PNO_MAX_PB_REQ_SIZE);
9453 goto error;
9454 }
9455
9456 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9457 if (pnoRequest.p5GProbeTemplate == NULL){
9458 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9459 FL("failed to allocate memory p5GProbeTemplate %u"),
9460 SIR_PNO_MAX_PB_REQ_SIZE);
9461 goto error;
9462 }
9463
9464 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9465 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009466
c_hpothu37f21312014-04-09 21:49:54 +05309467 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009468 pAdapter->sessionId,
9469 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309470 if (eHAL_STATUS_SUCCESS == status)
9471 {
9472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9473 "%s: PNO enabled", __func__);
9474 return VOS_STATUS_SUCCESS;
9475 }
9476error:
9477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9478 "%s: Failed to enable PNO", __func__);
9479 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309480 if (pnoRequest.aNetworks)
9481 vos_mem_free(pnoRequest.aNetworks);
9482 if (pnoRequest.p24GProbeTemplate)
9483 vos_mem_free(pnoRequest.p24GProbeTemplate);
9484 if (pnoRequest.p5GProbeTemplate)
9485 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309486 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009487}/*iw_set_pno*/
9488
9489VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9490 union iwreq_data *wrqu, char *extra, int nOffset)
9491{
9492 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9493 v_U8_t rssiThreshold = 0;
9494 v_U8_t nRead;
9495
Arif Hussain7adce1b2013-11-11 22:59:34 -08009496 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 &rssiThreshold);
9498
9499 if ( 1 != nRead )
9500 {
9501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9502 "Incorrect format");
9503 return VOS_STATUS_E_FAILURE;
9504 }
9505
9506 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9507 return VOS_STATUS_SUCCESS;
9508}
9509
9510
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309511static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 struct iw_request_info *info,
9513 union iwreq_data *wrqu, char *extra)
9514{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309515 hdd_adapter_t *pAdapter;
9516 hdd_context_t *pHddCtx;
9517 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309518 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309519
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309520 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309521 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9522 if (NULL == pAdapter)
9523 {
9524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9525 "%s: Adapter is NULL",__func__);
9526 return -EINVAL;
9527 }
9528
9529 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9530 ret = wlan_hdd_validate_context(pHddCtx);
9531 if (0 != ret)
9532 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309533 return ret;
9534 }
9535
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009536
9537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009539
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309540 status = iw_set_pno(dev,info,wrqu,extra,0);
9541
9542 EXIT();
9543 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009544}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309545
9546static int iw_set_pno_priv(struct net_device *dev,
9547 struct iw_request_info *info,
9548 union iwreq_data *wrqu, char *extra)
9549{
9550 int ret;
9551
9552 vos_ssr_protect(__func__);
9553 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9554 vos_ssr_unprotect(__func__);
9555
9556 return ret;
9557}
Jeff Johnson295189b2012-06-20 16:38:30 -07009558#endif /*FEATURE_WLAN_SCAN_PNO*/
9559
9560//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309561int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009562{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309563 hdd_adapter_t *pAdapter;
9564 tHalHandle hHal;
9565 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309566 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309567 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309568 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309570 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309571 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309572 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309573
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309574 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309575 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9576 if (NULL == pAdapter)
9577 {
9578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9579 "%s: Adapter is NULL",__func__);
9580 return -EINVAL;
9581 }
9582 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9583 retval = wlan_hdd_validate_context(pHddCtx);
9584 if (0 != retval)
9585 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309586 return retval;
9587 }
9588 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9589 if (NULL == hHal)
9590 {
9591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9592 "%s: Hal Context is NULL",__func__);
9593 return -EINVAL;
9594 }
9595 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009596
Atul Mittal54378cb2014-04-02 16:51:50 +05309597 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 {
9599 case WLAN_HDD_UI_BAND_AUTO:
9600 band = eCSR_BAND_ALL;
9601 break;
9602 case WLAN_HDD_UI_BAND_5_GHZ:
9603 band = eCSR_BAND_5G;
9604 break;
9605 case WLAN_HDD_UI_BAND_2_4_GHZ:
9606 band = eCSR_BAND_24;
9607 break;
9608 default:
9609 band = eCSR_BAND_MAX;
9610 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309611 connectedBand =
9612 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009613
Atul Mittal54378cb2014-04-02 16:51:50 +05309614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009615 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009616
9617 if (band == eCSR_BAND_MAX)
9618 {
9619 /* Received change band request with invalid band value */
9620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309621 "%s: Invalid band value %u", __func__, ui_band);
9622 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 }
9624
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309625 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309626 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309627 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009629 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009630 band, pHddCtx->cfg_ini->nBandCapability);
9631 return -EIO;
9632 }
9633
Sushant Kaushik1165f872015-03-30 20:25:27 +05309634 if (band == eCSR_BAND_ALL)
9635 {
9636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9637 "received. Setting band same as ini value %d"),
9638 pHddCtx->cfg_ini->nBandCapability);
9639 band = pHddCtx->cfg_ini->nBandCapability;
9640 }
9641
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9643 {
9644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9645 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009646 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009647 return -EIO;
9648 }
9649
9650 if (currBand != band)
9651 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309652 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309653 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309654 /* Return failure if current country code is world regulatory domain*/
9655 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9656 pMac->scan.countryCodeCurrent[1] == '0') )
9657 {
9658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9659 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309660 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309661 return -EAGAIN;
9662 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309663 }
9664
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 /* Change band request received.
9666 * Abort pending scan requests, flush the existing scan results,
9667 * and change the band capability
9668 */
9669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9670 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009671 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009672
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309673 /* We need to change the band and flush the scan results here itself
9674 * as we may get timeout for disconnection in which we will return
9675 * with out doing any of these
9676 */
9677 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9678 {
9679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9680 "%s: failed to set the band value to %u ",
9681 __func__, band);
9682 return -EINVAL;
9683 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309684 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9685 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309686 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309687 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9688 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309689 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309690 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9691 * information available in NV so to get the channel information from kernel
9692 * we need to send regulatory hint for the currunt country
9693 * And to set the same country again we need to set the dummy country
9694 * first and then the actual country.
9695 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309696#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9697 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9698#else
9699 regulatory_hint_user("00");
9700#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309701 wait_result = wait_for_completion_interruptible_timeout(
9702 &pHddCtx->linux_reg_req,
9703 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9704
9705 /* if the country information does not exist with the kernel,
9706 then the driver callback would not be called */
9707
9708 if (wait_result >= 0)
9709 {
9710 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9711 "runtime country code is found in kernel db");
9712 }
9713 else
9714 {
9715 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9716 "runtime country code is not found"
9717 " in kernel db");
9718 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309719
9720 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309721
9722 /*
9723 * Update 11dcountry and current country here as the hint
9724 * with 00 results in 11d and current country with 00
9725 */
9726 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9727 WNI_CFG_COUNTRY_CODE_LEN);
9728 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9729 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309730#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9731 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9732#else
9733 regulatory_hint_user(curr_country);
9734#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309735 wait_result = wait_for_completion_interruptible_timeout(
9736 &pHddCtx->linux_reg_req,
9737 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9738
9739 /* if the country information does not exist with the kernel,
9740 then the driver callback would not be called */
9741 if (wait_result >= 0)
9742 {
9743 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9744 "runtime country code is found in kernel db");
9745 }
9746 else
9747 {
9748 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9749 "runtime country code is not found"
9750 " in kernel db");
9751 }
9752
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309753 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309754 }
9755 else
9756 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309757#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309758 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9759 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309760#else
9761 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9762#endif
9763
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309764 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309765 pScanInfo = &pHddCtx->scan_info;
9766 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9767 {
9768 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9769 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9770 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309771 sme_FilterScanResults(hHal, pAdapter->sessionId);
9772
9773 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309774 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9775 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009777 eHalStatus status = eHAL_STATUS_SUCCESS;
9778 long lrc;
9779
9780 /* STA already connected on current band, So issue disconnect first,
9781 * then change the band*/
9782
9783 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309784 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309785 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009786
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9788
9789 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9790 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9791
Jeff Johnson43971f52012-07-17 12:26:56 -07009792 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 {
9794 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009795 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 __func__, (int)status );
9797 return -EINVAL;
9798 }
9799
9800 lrc = wait_for_completion_interruptible_timeout(
9801 &pAdapter->disconnect_comp_var,
9802 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9803
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309804 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009805
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009806 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009807 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009808
9809 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9810 }
9811 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009812 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309813 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309814 if (TRUE == pHddCtx->isSetBandByNL)
9815 return 0;
9816 else
9817 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07009818}
9819
Atul Mittal54378cb2014-04-02 16:51:50 +05309820int hdd_setBand_helper(struct net_device *dev, const char *command)
9821{
9822 u8 band;
9823
9824 /*convert the band value from ascii to integer*/
9825 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9826
9827 return hdd_setBand(dev, band);
9828
9829}
9830
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309831static int __iw_set_band_config(struct net_device *dev,
9832 struct iw_request_info *info,
9833 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009834{
Atul Mittal54378cb2014-04-02 16:51:50 +05309835 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009836
Arif Hussain0273cba2014-01-07 20:58:29 -08009837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009838
Atul Mittal54378cb2014-04-02 16:51:50 +05309839 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009840}
9841
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309842static int iw_set_band_config(struct net_device *dev,
9843 struct iw_request_info *info,
9844 union iwreq_data *wrqu, char *extra)
9845{
9846 int ret;
9847
9848 vos_ssr_protect(__func__);
9849 ret = __iw_set_band_config(dev, info, wrqu, extra);
9850 vos_ssr_unprotect(__func__);
9851
9852 return ret;
9853}
9854
c_manjeecfd1efb2015-09-25 19:32:34 +05309855static int get_fwr_memdump(struct net_device *dev,
9856 struct iw_request_info *info,
9857 union iwreq_data *wrqu, char *extra)
9858{
9859 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9860 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9861 int ret;
9862 ENTER();
9863 // HddCtx sanity
9864 ret = wlan_hdd_validate_context(pHddCtx);
9865 if (0 != ret)
9866 {
9867 return ret;
9868 }
9869 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
9870 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
9871 {
9872 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
9873 return -EINVAL;
9874 }
9875 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
9876
9877 EXIT();
9878 return ret;
9879}
9880
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309881static int __iw_set_power_params_priv(struct net_device *dev,
9882 struct iw_request_info *info,
9883 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009884{
Arif Hussain0273cba2014-01-07 20:58:29 -08009885 int ret;
9886 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9888 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009889 /* ODD number is used for set, copy data using copy_from_user */
9890 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9891 wrqu->data.length);
9892 if (NULL == ptr)
9893 {
9894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9895 "mem_alloc_copy_from_user_helper fail");
9896 return -ENOMEM;
9897 }
9898
9899 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9900 kfree(ptr);
9901 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009902}
9903
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309904static int iw_set_power_params_priv(struct net_device *dev,
9905 struct iw_request_info *info,
9906 union iwreq_data *wrqu, char *extra)
9907{
9908 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009909
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309910 vos_ssr_protect(__func__);
9911 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9912 vos_ssr_unprotect(__func__);
9913
9914 return ret;
9915}
Jeff Johnson295189b2012-06-20 16:38:30 -07009916
9917/*string based input*/
9918VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9919 union iwreq_data *wrqu, char *extra, int nOffset)
9920{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309921 hdd_adapter_t *pAdapter;
9922 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 tSirSetPowerParamsReq powerRequest;
9924 char *ptr;
9925 v_U8_t ucType;
9926 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309927 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009928
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309929 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309930 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9931 if (NULL == pAdapter)
9932 {
9933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9934 "%s: Adapter is NULL",__func__);
9935 return -EINVAL;
9936 }
9937
9938 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9939 ret = wlan_hdd_validate_context(pHddCtx);
9940 if (0 != ret)
9941 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309942 return ret;
9943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9945 "Power Params data len %d data %s",
9946 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009947 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009948
9949 if (wrqu->data.length <= nOffset )
9950 {
9951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9952 return VOS_STATUS_E_FAILURE;
9953 }
9954
9955 uTotalSize = wrqu->data.length - nOffset;
9956
9957 /*-----------------------------------------------------------------------
9958 Input is string based and expected to be like this:
9959
9960 <param_type> <param_value> <param_type> <param_value> ...
9961
9962 e.g:
9963 1 2 2 3 3 0 4 1 5 1
9964
9965 e.g. setting just a few:
9966 1 2 4 1
9967
9968 parameter types:
9969 -----------------------------
9970 1 - Ignore DTIM
9971 2 - Listen Interval
9972 3 - Broadcast Multicas Filter
9973 4 - Beacon Early Termination
9974 5 - Beacon Early Termination Interval
9975 -----------------------------------------------------------------------*/
9976 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9977 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9978 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9979 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9980 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9981
Arif Hussain7adce1b2013-11-11 22:59:34 -08009982 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009983
9984 while ( uTotalSize )
9985 {
Wilson Yang6f971452013-10-08 15:00:00 -07009986 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9987 {
9988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9989 "Invalid input parameter type %s",ptr);
9990 return VOS_STATUS_E_FAILURE;
9991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009992
9993 uTotalSize -= nOffset;
9994
9995 if (!uTotalSize)
9996 {
9997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009998 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009999 ucType, nOffset);
10000 return VOS_STATUS_E_FAILURE;
10001 }
10002
10003 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010004
Jeff Johnson02797792013-10-26 19:17:13 -070010005 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010006 {
10007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10008 "Invalid input parameter value %s",ptr);
10009 return VOS_STATUS_E_FAILURE;
10010 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010011
10012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10013 "Power request parameter %d value %d offset %d",
10014 ucType, uValue, nOffset);
10015
10016 switch (ucType)
10017 {
10018 case eSIR_IGNORE_DTIM:
10019 powerRequest.uIgnoreDTIM = uValue;
10020 break;
10021 case eSIR_LISTEN_INTERVAL:
10022 powerRequest.uListenInterval = uValue;
10023 break;
10024 case eSIR_MCAST_BCAST_FILTER:
10025 powerRequest.uBcastMcastFilter = uValue;
10026 break;
10027 case eSIR_ENABLE_BET:
10028 powerRequest.uEnableBET = uValue;
10029 break;
10030 case eSIR_BET_INTERVAL:
10031 powerRequest.uBETInterval = uValue;
10032 break;
10033 default:
10034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010035 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010036 ucType, uValue, nOffset);
10037 return VOS_STATUS_E_FAILURE;
10038 }
10039
10040 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10042 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010043 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010044 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010045 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010046 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010047 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10048 {
10049 uTotalSize = 0;
10050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010051
10052 }/*Go for as long as we have a valid string*/
10053
10054 /* put the device into full power*/
10055 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10056
10057 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010058 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010059
10060 /* put the device back to power save*/
10061 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10062
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010063 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 return VOS_STATUS_SUCCESS;
10065}/*iw_set_power_params*/
10066
Atul Mittalc0f739f2014-07-31 13:47:47 +053010067// tdlsoffchan
10068#ifdef FEATURE_WLAN_TDLS
10069
Atul Mittal87ec2422014-09-24 13:12:50 +053010070int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010071{
10072 if (offchannel < 0 || offchannel > 165)
10073 {
10074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10075 __func__, offchannel);
10076 return -1;
10077
10078 }
10079
10080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10081 __func__, tdlsOffCh, offchannel);
10082
10083 tdlsOffCh = offchannel;
10084 return 0;
10085}
10086
Atul Mittal87ec2422014-09-24 13:12:50 +053010087int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010088{
10089 if (offchanoffset == 0)
10090 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010091 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10093 __func__, tdlsOffChBwOffset);
10094
10095 return 0;
10096
10097 }
10098
10099 if ( offchanoffset == 40 )
10100 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010101 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10103 __func__, tdlsOffChBwOffset);
10104
10105 return 0;
10106
10107 }
10108 if (offchanoffset == -40)
10109 {
10110 tdlsOffChBwOffset = 3;
10111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10112 __func__, tdlsOffChBwOffset);
10113
10114 return 0;
10115
10116 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010117
10118 if ((offchanoffset == 80) &&
10119 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10120 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10121 {
10122 tdlsOffChBwOffset = 4;
10123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10124 "%s: change tdls secondary off channel offset to %u",
10125 __func__, tdlsOffChBwOffset);
10126
10127 return 0;
10128 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10130 __func__, offchanoffset);
10131 return -1;
10132}
10133
Atul Mittal87ec2422014-09-24 13:12:50 +053010134int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010135{
10136 hddTdlsPeer_t *connPeer = NULL;
10137 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10138 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10139
10140 if (offchanmode < 0 || offchanmode > 4)
10141 {
10142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10143 "%s: Invalid tdls off channel mode %d",
10144 __func__, offchanmode);
10145 return -1;
10146 }
10147
10148 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10149 {
10150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10151 "%s: tdls off channel mode req in not associated state %d",
10152 __func__, offchanmode);
10153 return -1;
10154 }
10155
10156 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10157 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10158 {
10159 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010160 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010161 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010162 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010163 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10165 "%s: No TDLS Connected Peer", __func__);
10166 return -1;
10167 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010168 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010169 }
10170 else
10171 {
10172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10173 "%s: TDLS Connection not supported", __func__);
10174 return -1;
10175 }
10176
10177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10178 ("%s: TDLS Channel Switch in swmode=%d"),
10179 __func__, offchanmode);
10180
10181 switch (offchanmode)
10182 {
10183 case 1:/*Enable*/
10184 case 2:/*Disable*/
10185 {
10186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10187 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10188 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10189 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10190 {
10191
10192 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
10193 pAdapter->sessionId, connPeer->peerMac,
10194 tdlsOffCh, tdlsOffChBwOffset,
10195 offchanmode);
10196 }
10197 else
10198 {
10199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10200 "%s: TDLS Off Channel not supported", __func__);
10201 return -1;
10202 }
10203 break;
10204 }
10205 case 3:
10206 {
10207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10208 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10209 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10210
10211 break;
10212 }
10213 case 4:
10214 {
10215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10216 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10217 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10218 break;
10219 }
10220 default:
10221 {
10222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10223 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10224 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10225 break;
10226 }
10227
10228 }
10229
10230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10231 __func__, offchanmode);
10232 return 0;
10233}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010234#endif
10235
Jeff Johnson295189b2012-06-20 16:38:30 -070010236
10237// Define the Wireless Extensions to the Linux Network Device structure
10238// A number of these routines are NULL (meaning they are not implemented.)
10239
10240static const iw_handler we_handler[] =
10241{
10242 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10243 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10244 (iw_handler) NULL, /* SIOCSIWNWID */
10245 (iw_handler) NULL, /* SIOCGIWNWID */
10246 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10247 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10248 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10249 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10250 (iw_handler) NULL, /* SIOCSIWSENS */
10251 (iw_handler) NULL, /* SIOCGIWSENS */
10252 (iw_handler) NULL, /* SIOCSIWRANGE */
10253 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10254 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
10255 (iw_handler) NULL, /* SIOCGIWPRIV */
10256 (iw_handler) NULL, /* SIOCSIWSTATS */
10257 (iw_handler) NULL, /* SIOCGIWSTATS */
10258 iw_handler_set_spy, /* SIOCSIWSPY */
10259 iw_handler_get_spy, /* SIOCGIWSPY */
10260 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10261 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10262 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10263 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10264 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10265 (iw_handler) NULL, /* SIOCGIWAPLIST */
10266 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10267 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10268 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10269 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10270 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10271 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10272 (iw_handler) NULL, /* -- hole -- */
10273 (iw_handler) NULL, /* -- hole -- */
10274 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10275 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10276 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10277 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10278 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10279 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10280 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10281 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10282 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10283 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10284 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10285 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10286 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10287 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10288 (iw_handler) NULL, /* -- hole -- */
10289 (iw_handler) NULL, /* -- hole -- */
10290 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10291 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10292 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10293 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10294 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10295 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10296 (iw_handler) NULL, /* SIOCSIWPMKSA */
10297};
10298
10299static const iw_handler we_private[] = {
10300
10301 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10302 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10303 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10304 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10305 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10306 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010307 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010308 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10309 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10310 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010311#ifdef FEATURE_OEM_DATA_SUPPORT
10312 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10313 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10314#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010315
Jeff Johnson295189b2012-06-20 16:38:30 -070010316#ifdef WLAN_FEATURE_VOWIFI_11R
10317 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10318#endif
10319 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10320 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10321 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10322#ifdef WLAN_FEATURE_PACKET_FILTERING
10323 ,
10324 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10325#endif
10326#ifdef FEATURE_WLAN_SCAN_PNO
10327 ,
10328 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10329#endif
10330 ,
10331 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10332 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10333 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10334 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010335 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010336};
10337
10338/*Maximum command length can be only 15 */
10339static const struct iw_priv_args we_private_args[] = {
10340
Katya Nigamf0511f62015-05-05 16:40:57 +053010341 { WE_SET_MONITOR_STATE,
10342 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10343 0, "monitor" },
10344
Jeff Johnson295189b2012-06-20 16:38:30 -070010345 /* handlers for main ioctl */
10346 { WLAN_PRIV_SET_INT_GET_NONE,
10347 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10348 0,
10349 "" },
10350
10351 /* handlers for sub-ioctl */
10352 { WE_SET_11D_STATE,
10353 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10354 0,
10355 "set11Dstate" },
10356
10357 { WE_WOWL,
10358 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10359 0,
10360 "wowl" },
10361
10362 { WE_SET_POWER,
10363 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10364 0,
10365 "setPower" },
10366
10367 { WE_SET_MAX_ASSOC,
10368 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10369 0,
10370 "setMaxAssoc" },
10371
10372 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10373 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10374 0,
10375 "setAutoChannel" },
10376
10377 { WE_SET_DATA_INACTIVITY_TO,
10378 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10379 0,
10380 "inactivityTO" },
10381
10382 { WE_SET_MAX_TX_POWER,
10383 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10384 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010385 "setMaxTxPower" },
10386
10387 { WE_SET_MAX_TX_POWER_2_4,
10388 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10389 0,
10390 "setTxMaxPower2G" },
10391
10392 { WE_SET_MAX_TX_POWER_5_0,
10393 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10394 0,
10395 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010396
10397 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10398 * as well to keep same syntax as in SAP. Now onwards, STA
10399 * will support both */
10400 { WE_SET_MAX_TX_POWER,
10401 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10402 0,
10403 "setTxMaxPower" },
10404
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10406 * 1 = enable and 0 = disable */
10407 {
10408 WE_SET_HIGHER_DTIM_TRANSITION,
10409 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10410 0,
10411 "setHDtimTransn" },
10412
10413 { WE_SET_TM_LEVEL,
10414 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010415 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 "setTmLevel" },
10417
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010418 { WE_ENABLE_STRICT_FCC_REG,
10419 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10420 0,
10421 "setStrictFCCreg" },
10422
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010423 { WE_SET_DEBUG_LOG,
10424 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10425 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010426#ifdef FEATURE_WLAN_TDLS
10427 {
10428 WE_SET_TDLS_OFF_CHAN,
10429 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10430 0,
10431 "tdlsoffchan" },
10432 {
10433 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10434 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10435 0,
10436 "tdlsecchnoffst" },
10437 {
10438 WE_SET_TDLS_OFF_CHAN_MODE,
10439 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10440 0,
10441 "tdlsoffchnmode" },
10442#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010443
Peng Xu2446a892014-09-05 17:21:18 +053010444 { WE_SET_SCAN_BAND_PREFERENCE,
10445 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10446 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010447 {
10448 WE_GET_FRAME_LOG,
10449 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10450 0,
10451 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010452
Abhishek Singh01c73d12015-03-12 15:13:44 +053010453 { WE_SET_MIRACAST_VENDOR_CONFIG,
10454 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10455 0, "setMiracstConf" },
10456
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010457#ifdef FEATURE_WLAN_TDLS
10458 {
10459 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10460 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10461 0,
10462 "tdls_2040bsscox" },
10463#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010464 { WE_SET_RTS_CTS_HTVHT,
10465 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10466 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010467 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10468 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10469 0, "setPktStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010470 /* handlers for main ioctl */
10471 { WLAN_PRIV_SET_NONE_GET_INT,
10472 0,
10473 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10474 "" },
10475
10476 /* handlers for sub-ioctl */
10477 { WE_GET_11D_STATE,
10478 0,
10479 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10480 "get11Dstate" },
10481
10482 { WE_IBSS_STATUS,
10483 0,
10484 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10485 "getAdhocStatus" },
10486
10487 { WE_PMC_STATE,
10488 0,
10489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10490 "pmcState" },
10491
10492 { WE_GET_WLAN_DBG,
10493 0,
10494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10495 "getwlandbg" },
10496
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 { WE_GET_MAX_ASSOC,
10498 0,
10499 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10500 "getMaxAssoc" },
10501
Jeff Johnson295189b2012-06-20 16:38:30 -070010502 { WE_GET_WDI_DBG,
10503 0,
10504 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10505 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010506
10507 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10508 0,
10509 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10510 "getAutoChannel" },
10511
10512 { WE_GET_CONCURRENCY_MODE,
10513 0,
10514 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10515 "getconcurrency" },
10516
Peng Xu2446a892014-09-05 17:21:18 +053010517 { WE_GET_SCAN_BAND_PREFERENCE,
10518 0,
10519 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10520 "get_scan_pref"},
10521
Jeff Johnson295189b2012-06-20 16:38:30 -070010522 /* handlers for main ioctl */
10523 { WLAN_PRIV_SET_CHAR_GET_NONE,
10524 IW_PRIV_TYPE_CHAR| 512,
10525 0,
10526 "" },
10527
10528 /* handlers for sub-ioctl */
10529 { WE_WOWL_ADD_PTRN,
10530 IW_PRIV_TYPE_CHAR| 512,
10531 0,
10532 "wowlAddPtrn" },
10533
10534 { WE_WOWL_DEL_PTRN,
10535 IW_PRIV_TYPE_CHAR| 512,
10536 0,
10537 "wowlDelPtrn" },
10538
10539#if defined WLAN_FEATURE_VOWIFI
10540 /* handlers for sub-ioctl */
10541 { WE_NEIGHBOR_REPORT_REQUEST,
10542 IW_PRIV_TYPE_CHAR | 512,
10543 0,
10544 "neighbor" },
10545#endif
10546 { WE_SET_AP_WPS_IE,
10547 IW_PRIV_TYPE_CHAR| 512,
10548 0,
10549 "set_ap_wps_ie" },
10550
10551 { WE_SET_CONFIG,
10552 IW_PRIV_TYPE_CHAR| 512,
10553 0,
10554 "setConfig" },
10555
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010556 { WE_SET_ENCRYPT_MSG,
10557 IW_PRIV_TYPE_CHAR| 512,
10558 0,
10559 "encryptMsg" },
10560
10561
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 /* handlers for main ioctl */
10563 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10565 0,
10566 "" },
10567
10568 /* handlers for sub-ioctl */
10569 { WE_SET_WLAN_DBG,
10570 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10571 0,
10572 "setwlandbg" },
10573
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 { WE_SET_WDI_DBG,
10575 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10576 0,
10577 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010578
10579 { WE_SET_SAP_CHANNELS,
10580 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10581 0,
10582 "setsapchannels" },
10583
10584 /* handlers for main ioctl */
10585 { WLAN_PRIV_GET_CHAR_SET_NONE,
10586 0,
10587 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10588 "" },
10589
10590 /* handlers for sub-ioctl */
10591 { WE_WLAN_VERSION,
10592 0,
10593 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10594 "version" },
10595 { WE_GET_STATS,
10596 0,
10597 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10598 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010599 { WE_GET_STATES,
10600 0,
10601 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10602 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010603 { WE_GET_CFG,
10604 0,
10605 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10606 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010607#ifdef WLAN_FEATURE_11AC
10608 { WE_GET_RSSI,
10609 0,
10610 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10611 "getRSSI" },
10612#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010613#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010614 { WE_GET_ROAM_RSSI,
10615 0,
10616 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10617 "getRoamRSSI" },
10618#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010619 { WE_GET_WMM_STATUS,
10620 0,
10621 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10622 "getWmmStatus" },
10623 {
10624 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010625 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010626 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10627 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010628#ifdef FEATURE_WLAN_TDLS
10629 {
10630 WE_GET_TDLS_PEERS,
10631 0,
10632 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10633 "getTdlsPeers" },
10634#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010635#ifdef WLAN_FEATURE_11W
10636 {
10637 WE_GET_11W_INFO,
10638 0,
10639 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10640 "getPMFInfo" },
10641#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010642 { WE_GET_SNR,
10643 0,
10644 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10645 "getSNR" },
10646
Jeff Johnson295189b2012-06-20 16:38:30 -070010647 /* handlers for main ioctl */
10648 { WLAN_PRIV_SET_NONE_GET_NONE,
10649 0,
10650 0,
10651 "" },
10652
10653 /* handlers for sub-ioctl */
10654 { WE_CLEAR_STATS,
10655 0,
10656 0,
10657 "clearStats" },
10658 { WE_INIT_AP,
10659 0,
10660 0,
10661 "initAP" },
10662 { WE_STOP_AP,
10663 0,
10664 0,
10665 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010666#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010667 { WE_ENABLE_AMP,
10668 0,
10669 0,
10670 "enableAMP" },
10671 { WE_DISABLE_AMP,
10672 0,
10673 0,
10674 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010675#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010676 { WE_ENABLE_DXE_STALL_DETECT,
10677 0,
10678 0,
10679 "dxeStallDetect" },
10680 { WE_DISPLAY_DXE_SNAP_SHOT,
10681 0,
10682 0,
10683 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010684 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10685 0,
10686 0,
10687 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010688 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010689 WE_SET_REASSOC_TRIGGER,
10690 0,
10691 0,
10692 "reassoc" },
10693 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010694 WE_STOP_OBSS_SCAN,
10695 0,
10696 0,
10697 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010698 {
10699 WE_DUMP_ROAM_TIMER_LOG,
10700 0,
10701 0,
10702 "dumpRoamDelay" },
10703 {
10704 WE_RESET_ROAM_TIMER_LOG,
10705 0,
10706 0,
10707 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010708 {
10709 WE_GET_FW_LOGS,
10710 0,
10711 0,
10712 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053010713 {
10714 WE_GET_FW_MEMDUMP,
10715 0,
10716 0,
10717 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010718 /* handlers for main ioctl */
10719 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10720 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10721 0,
10722 "" },
10723
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010724
10725
Jeff Johnson295189b2012-06-20 16:38:30 -070010726 /* handlers for sub-ioctl */
10727 { WE_LOG_DUMP_CMD,
10728 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10729 0,
10730 "dump" },
10731
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010732 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010733 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10734 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10735 0,
10736 "setdumplog" },
10737
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010738 { WE_MTRACE_DUMP_CMD,
10739 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10740 0,
10741 "dumplog" },
10742
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010743 /* handlers for sub ioctl */
10744 {
10745 WE_MCC_CONFIG_CREDENTIAL,
10746 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10747 0,
10748 "setMccCrdnl" },
10749
10750 /* handlers for sub ioctl */
10751 {
10752 WE_MCC_CONFIG_PARAMS,
10753 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10754 0,
10755 "setMccConfig" },
10756
Chilam NG571c65a2013-01-19 12:27:36 +053010757#ifdef FEATURE_WLAN_TDLS
10758 /* handlers for sub ioctl */
10759 {
10760 WE_TDLS_CONFIG_PARAMS,
10761 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10762 0,
10763 "setTdlsConfig" },
10764#endif
10765
Katya Nigamf0511f62015-05-05 16:40:57 +053010766 {
10767 WE_CONFIGURE_MONITOR_MODE,
10768 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10769 0,
10770 "MonitorModeConf" },
10771
10772 {
10773 WE_SET_MONITOR_MODE_FILTER,
10774 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10775 0,
10776 "MonitorFilter" },
10777
Jeff Johnson295189b2012-06-20 16:38:30 -070010778 /* handlers for main ioctl */
10779 { WLAN_PRIV_ADD_TSPEC,
10780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10781 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10782 "addTspec" },
10783
10784 /* handlers for main ioctl */
10785 { WLAN_PRIV_DEL_TSPEC,
10786 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10787 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10788 "delTspec" },
10789
10790 /* handlers for main ioctl */
10791 { WLAN_PRIV_GET_TSPEC,
10792 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10793 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10794 "getTspec" },
10795
Jeff Johnsone7245742012-09-05 17:12:55 -070010796#ifdef FEATURE_OEM_DATA_SUPPORT
10797 /* handlers for main ioctl - OEM DATA */
10798 {
10799 WLAN_PRIV_SET_OEM_DATA_REQ,
10800 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10801 0,
10802 "set_oem_data_req" },
10803
10804 /* handlers for main ioctl - OEM DATA */
10805 {
10806 WLAN_PRIV_GET_OEM_DATA_RSP,
10807 0,
10808 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10809 "get_oem_data_rsp" },
10810#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010811
Jeff Johnson295189b2012-06-20 16:38:30 -070010812 /* handlers for main ioctl - host offload */
10813 {
10814 WLAN_PRIV_SET_HOST_OFFLOAD,
10815 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10816 0,
10817 "setHostOffload" },
10818
10819 {
10820 WLAN_GET_WLAN_STATISTICS,
10821 0,
10822 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10823 "getWlanStats" },
10824
10825 {
10826 WLAN_SET_KEEPALIVE_PARAMS,
10827 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10828 0,
10829 "setKeepAlive" },
10830#ifdef WLAN_FEATURE_PACKET_FILTERING
10831 {
10832 WLAN_SET_PACKET_FILTER_PARAMS,
10833 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10834 0,
10835 "setPktFilter" },
10836#endif
10837#ifdef FEATURE_WLAN_SCAN_PNO
10838 {
10839 WLAN_SET_PNO,
10840 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10841 0,
10842 "setpno" },
10843#endif
10844 {
10845 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010846 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 0,
10848 "SETBAND" },
10849 /* handlers for dynamic MC BC ioctl */
10850 {
10851 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010852 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010853 0,
10854 "setMCBCFilter" },
10855 {
10856 WLAN_PRIV_CLEAR_MCBC_FILTER,
10857 0,
10858 0,
10859 "clearMCBCFilter" },
10860 {
10861 WLAN_SET_POWER_PARAMS,
10862 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10863 0,
10864 "setpowerparams" },
10865 {
10866 WLAN_GET_LINK_SPEED,
10867 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010868 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010869};
10870
10871
10872
10873const struct iw_handler_def we_handler_def = {
10874 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10875 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10876 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10877
10878 .standard = (iw_handler *)we_handler,
10879 .private = (iw_handler *)we_private,
10880 .private_args = we_private_args,
10881 .get_wireless_stats = get_wireless_stats,
10882};
10883
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010884int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10885{
10886 v_U32_t cmd = 288; //Command to RIVA
10887 hdd_context_t *pHddCtx = NULL;
10888 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10889 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10890 /*
10891 *configMccParam : specify the bit which needs to be modified
10892 *allowed to update based on wlan_qcom_cfg.ini
10893 * configuration
10894 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10895 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10896 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10897 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10898 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10899 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10900 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10901 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10902 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10903 * Bit 9 : Reserved
10904 */
10905 switch (arg1)
10906 {
10907 //Update MCC SCHEDULE_TIME_SLICE parameter
10908 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10909 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10910 {
10911 if((arg2 >= 5) && (arg2 <= 20))
10912 {
10913 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10914 }
10915 else
10916 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010917 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010918 return 0;
10919 }
10920 }
10921 break;
10922
10923 //Update MCC MAX_NULL_SEND_TIME parameter
10924 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10925 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10926 {
10927 if((arg2 >= 1) && (arg2 <= 10))
10928 {
10929 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10930 }
10931 else
10932 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010933 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010934 return 0;
10935 }
10936 }
10937 break;
10938
10939 //Update MCC TX_EARLY_STOP_TIME parameter
10940 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10941 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10942 {
10943 if((arg2 >= 1) && (arg2 <= 10))
10944 {
10945 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10946 }
10947 else
10948 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010949 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010950 return 0;
10951 }
10952 }
10953 break;
10954
10955 //Update MCC RX_DRAIN_TIME parameter
10956 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10957 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10958 {
10959 if((arg2 >= 1) && (arg2 <= 10))
10960 {
10961 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10962 }
10963 else
10964 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010965 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010966 return 0;
10967 }
10968 }
10969 break;
10970
10971 //Update MCC CHANNEL_SWITCH_TIME parameter
10972 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10973 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10974 {
10975 if((arg2 >= 1) && (arg2 <= 20))
10976 {
10977 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10978 }
10979 else
10980 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010981 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010982 return 0;
10983 }
10984 }
10985 break;
10986
10987 //Update MCC MIN_CHANNEL_TIME parameter
10988 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10989 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10990 {
10991 if((arg2 >= 5) && (arg2 <= 20))
10992 {
10993 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10994 }
10995 else
10996 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010997 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010998 return 0;
10999 }
11000 }
11001 break;
11002
11003 //Update MCC PARK_BEFORE_TBTT parameter
11004 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11005 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11006 {
11007 if((arg2 >= 1) && (arg2 <= 5))
11008 {
11009 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11010 }
11011 else
11012 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011013 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011014 return 0;
11015 }
11016 }
11017 break;
11018
11019 //Update MCC MIN_AFTER_DTIM parameter
11020 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11021 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11022 {
11023 if((arg2 >= 5) && (arg2 <= 15))
11024 {
11025 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11026 }
11027 else
11028 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011029 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011030 return 0;
11031 }
11032 }
11033 break;
11034
11035 //Update MCC TOO_CLOSE_MARGIN parameter
11036 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11037 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11038 {
11039 if((arg2 >= 1) && (arg2 <= 3))
11040 {
11041 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11042 }
11043 else
11044 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011045 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011046 return 0;
11047 }
11048 }
11049 break;
11050
11051 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011052 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011053 __FUNCTION__,arg1);
11054 break;
11055 }
11056 return 0;
11057}
11058
Jeff Johnson295189b2012-06-20 16:38:30 -070011059int hdd_set_wext(hdd_adapter_t *pAdapter)
11060{
11061 hdd_wext_state_t *pwextBuf;
11062 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011063 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011064
11065 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11066
11067 // Now configure the roaming profile links. To SSID and bssid.
11068 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11069 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11070
11071 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11072 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11073
11074 /*Set the numOfChannels to zero to scan all the channels*/
11075 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11076 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11077
11078 /* Default is no encryption */
11079 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11080 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11081
11082 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11083 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11084
11085 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11086
11087 /* Default is no authentication */
11088 pwextBuf->roamProfile.AuthType.numEntries = 1;
11089 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11090
11091 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11092 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11093
11094 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011095 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011096
11097 hdd_clearRoamProfileIe(pAdapter);
11098
11099 return VOS_STATUS_SUCCESS;
11100
11101 }
11102
11103int hdd_register_wext(struct net_device *dev)
11104 {
11105 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11106 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11107 VOS_STATUS status;
11108
11109 ENTER();
11110
11111 // Zero the memory. This zeros the profile structure.
11112 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11113
11114 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11115
11116
11117 status = hdd_set_wext(pAdapter);
11118
11119 if(!VOS_IS_STATUS_SUCCESS(status)) {
11120
Arif Hussain6d2a3322013-11-17 19:50:10 -080011121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011122 return eHAL_STATUS_FAILURE;
11123 }
11124
11125 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11126 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011128 return eHAL_STATUS_FAILURE;
11129 }
11130
11131 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11132 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011134 return eHAL_STATUS_FAILURE;
11135 }
11136
11137 // Register as a wireless device
11138 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11139
11140 EXIT();
11141 return 0;
11142}
11143
11144int hdd_UnregisterWext(struct net_device *dev)
11145{
c_hpothu2a13bc32015-01-21 12:48:54 +053011146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11147 if (dev != NULL)
11148 {
11149 rtnl_lock();
11150 dev->wireless_handlers = NULL;
11151 rtnl_unlock();
11152 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011153
Jeff Johnson295189b2012-06-20 16:38:30 -070011154 return 0;
11155}
11156
11157