blob: 31a402bc7420d94ddab4c21627a995eff6721f82 [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 {
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303919 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
3920 {
3921 hddLog(VOS_TRACE_LEVEL_ERROR,
3922 "%s:station is in still not Authenticated ignore the "
3923 "power save mode", __func__);
3924 return VOS_STATUS_E_AGAIN;
3925 }
3926
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3928 {
3929 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3930 __func__);
3931 // Enter BMPS command received from GUI this means DHCP is completed
3932 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3933 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3934 FALSE);
3935 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3936 iw_power_callback_fn, &context);
3937 if (eHAL_STATUS_PMC_PENDING == status)
3938 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003939 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003940 int lrc = wait_for_completion_interruptible_timeout(
3941 &context.completion,
3942 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 if (lrc <= 0)
3944 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003945 hddLog(VOS_TRACE_LEVEL_ERROR,
3946 "%s: SME %s while requesting BMPS",
3947 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 }
3949 }
3950 }
3951 else
3952 {
3953 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3954 "enabled in the cfg");
3955 }
3956 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003957
3958 /* either we never sent a request, we sent a request and received a
3959 response or we sent a request and timed out. if we never sent a
3960 request or if we sent a request and got a response, we want to
3961 clear the magic out of paranoia. if we timed out there is a
3962 race condition such that the callback function could be
3963 executing at the same time we are. of primary concern is if the
3964 callback function had already verified the "magic" but had not
3965 yet set the completion variable when a timeout occurred. we
3966 serialize these activities by invalidating the magic while
3967 holding a shared spinlock which will cause us to block if the
3968 callback is currently executing */
3969 spin_lock(&hdd_context_lock);
3970 context.magic = 0;
3971 spin_unlock(&hdd_context_lock);
3972
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 return VOS_STATUS_SUCCESS;
3974}
3975
3976VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3977 hdd_adapter_t *pAdapter)
3978{
3979 VOS_STATUS vos_Status;
3980
3981 if ((NULL == pAdapter) || (NULL == pHddCtx))
3982 {
3983 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3984 return VOS_STATUS_E_FAULT;
3985 }
3986
3987 /**Exit from Deep sleep or standby if we get the driver
3988 START cmd from android GUI
3989 */
3990 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3991 {
3992 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3993 "from Stand by",__func__);
3994 vos_Status = hdd_exit_standby(pHddCtx);
3995 }
3996 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3997 {
3998 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3999 "from deep sleep",__func__);
4000 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4001 }
4002 else
4003 {
4004 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4005 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4006 vos_Status = VOS_STATUS_SUCCESS;
4007 }
4008
4009 return vos_Status;
4010}
4011
4012VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4013{
4014 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4015
4016 if (NULL == pHddCtx)
4017 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304018 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 return VOS_STATUS_E_FAULT;
4020 }
4021
4022 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4023 {
4024 //Execute standby procedure.
4025 //Executing standby procedure will cause the STA to
4026 //disassociate first and then the chip will be put into standby.
4027 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4028 vos_Status = hdd_enter_standby(pHddCtx);
4029 }
4030 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4031 pHddCtx->cfg_ini->nEnableDriverStop)
4032 {
4033 //Execute deep sleep procedure
4034 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004035 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 //Deep sleep not supported
4037 vos_Status = hdd_enter_standby(pHddCtx);
4038 }
4039 else
4040 {
4041 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4042 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4043 vos_Status = VOS_STATUS_SUCCESS;
4044 }
4045
4046 return vos_Status;
4047}
4048
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004049
4050void* wlan_hdd_change_country_code_callback(void *pAdapter)
4051{
4052
4053 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004054 complete(&call_back_pAdapter->change_country_code);
4055
4056 return NULL;
4057}
4058
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304059static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 struct iw_request_info *info,
4061 union iwreq_data *wrqu, char *extra)
4062{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304063 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004064 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304066 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004067 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4068
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304069 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004070
4071 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304072
4073 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4074 if (NULL == pAdapter)
4075 {
4076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4077 "mem_alloc_copy_from_user_helper fail");
4078 return -EINVAL;
4079 }
4080 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4081 rc = wlan_hdd_validate_context(pHddCtx);
4082 if (0 != rc)
4083 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304084 return rc;
4085 }
4086
Arif Hussain24bfa702014-01-22 13:51:30 -08004087 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4088 wrqu->data.length);
4089 if (NULL == cmd)
4090 {
4091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4092 "mem_alloc_copy_from_user_helper fail");
4093 return -ENOMEM;
4094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004095
4096 if (ioctl_debug)
4097 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004098 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 }
4100
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004101 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4102 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004103
Arif Hussain24bfa702014-01-22 13:51:30 -08004104 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004106 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4108 "%s: Error in iw_set_scan!", __func__);
4109 rc = -EINVAL;
4110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 }
4112 else if( strcasecmp(cmd, "start") == 0 ) {
4113
Arif Hussain6d2a3322013-11-17 19:50:10 -08004114 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004116
Arif Hussain24bfa702014-01-22 13:51:30 -08004117 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4118 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 {
4120 union iwreq_data wrqu;
4121 char buf[10];
4122
4123 memset(&wrqu, 0, sizeof(wrqu));
4124 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4125 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4126 }
4127 else
4128 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004129 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4130 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 }
4132 goto done;
4133 }
4134 else if( strcasecmp(cmd, "stop") == 0 )
4135 {
4136 union iwreq_data wrqu;
4137 char buf[10];
4138
Arif Hussain6d2a3322013-11-17 19:50:10 -08004139 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004140
4141 wlan_hdd_enter_lowpower(pHddCtx);
4142 memset(&wrqu, 0, sizeof(wrqu));
4143 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4144 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 goto done;
4146 }
4147 else if (strcasecmp(cmd, "macaddr") == 0)
4148 {
4149 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4150 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4151 }
4152 else if (strcasecmp(cmd, "scan-active") == 0)
4153 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304154 hddLog(VOS_TRACE_LEVEL_ERROR,
4155 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004156 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 ret = snprintf(cmd, cmd_len, "OK");
4158 }
4159 else if (strcasecmp(cmd, "scan-passive") == 0)
4160 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304161 hddLog(VOS_TRACE_LEVEL_ERROR,
4162 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004163 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 ret = snprintf(cmd, cmd_len, "OK");
4165 }
4166 else if( strcasecmp(cmd, "scan-mode") == 0 )
4167 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004168 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 }
4170 else if( strcasecmp(cmd, "linkspeed") == 0 )
4171 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004172 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 }
4174 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4175 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004176 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004177 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004178
4179 country_code = cmd + 8;
4180
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004181 init_completion(&pAdapter->change_country_code);
4182
Arif Hussain24bfa702014-01-22 13:51:30 -08004183 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004184 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 country_code,
4186 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304187 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304188 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304189 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004190
4191 /* Wait for completion */
4192 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4193 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4194
4195 if (lrc <= 0)
4196 {
4197 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004198 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004199 }
4200
Arif Hussain24bfa702014-01-22 13:51:30 -08004201 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004203 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004204 "%s: SME Change Country code fail", __func__);
4205 kfree(cmd);
4206 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 }
4208 }
4209 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4210 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004211 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 }
4213 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4214 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004215 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004216
Wilson Yang1be3e652013-10-09 15:18:31 -07004217 if (9 < cmd_len)
4218 {
4219 ptr = (char*)(cmd + 9);
4220
4221 }else{
4222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4223 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004224 kfree(cmd);
4225 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004226 }
4227
4228 if (1 != sscanf(ptr,"%d",&mode))
4229 {
4230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4231 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004232 kfree(cmd);
4233 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004234 }
4235
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 wlan_hdd_enter_bmps(pAdapter, mode);
4237 /*TODO:Set the power mode*/
4238 }
4239 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4240 v_U32_t pmc_state;
4241 v_U16_t value;
4242
4243 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4244 if(pmc_state == BMPS) {
4245 value = DRIVER_POWER_MODE_AUTO;
4246 }
4247 else {
4248 value = DRIVER_POWER_MODE_ACTIVE;
4249 }
4250 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4251 }
4252 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004253 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 /*TODO: set the btcoexmode*/
4255 }
4256 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4257
Arif Hussain6d2a3322013-11-17 19:50:10 -08004258 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 /*TODO: Return the btcoex status*/
4260 }
4261 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4262
Arif Hussain6d2a3322013-11-17 19:50:10 -08004263 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004264
4265 /*TODO: Enable Rx data Filter*/
4266 }
4267 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4268
Arif Hussain6d2a3322013-11-17 19:50:10 -08004269 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004270
4271 /*TODO: Disable Rx data Filter*/
4272 }
4273 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4274
Arif Hussain6d2a3322013-11-17 19:50:10 -08004275 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 /*TODO: rxfilter-statistics*/
4277 }
4278 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4279
Arif Hussain6d2a3322013-11-17 19:50:10 -08004280 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 /*TODO: rxfilter-add*/
4282 }
4283 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4284
Arif Hussain6d2a3322013-11-17 19:50:10 -08004285 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 /*TODO: rxfilter-remove*/
4287 }
4288#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004289 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4290 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4291 /*TODO: support pnosetup*/
4292 }
4293 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4294 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4295 /*TODO: support pnoforce*/
4296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4298
Arif Hussain6d2a3322013-11-17 19:50:10 -08004299 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004300 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4301 kfree(cmd);
4302 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 }
4304 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004305 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004306 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4307 kfree(cmd);
4308 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 }
4310#endif /*FEATURE_WLAN_SCAN_PNO*/
4311 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004312 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004313 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4314 kfree(cmd);
4315 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 }
4317 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4318 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004319 char *ptr;
4320
4321 if (18 < cmd_len)
4322 {
4323 ptr = (char*)(cmd + 18);
4324 }else{
4325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4326 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004327 kfree(cmd);
4328 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004329 }
4330
Jeff Johnson02797792013-10-26 19:17:13 -07004331 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004332 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4333 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4334 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4335 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4336 {
4337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4338 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004339 kfree(cmd);
4340 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004342
4343 // parameters checking
4344 // period has to be larger than 0
4345 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4346 {
4347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004348 kfree(cmd);
4349 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 }
4351
4352 // use default value 5 is the input is not reasonable. in unit of 10%
4353 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4354 {
4355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4356 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4357 }
4358
4359 // default is 5
4360 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4361 {
4362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4363 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4364 }
4365
Arif Hussain24bfa702014-01-22 13:51:30 -08004366 if (eHAL_STATUS_SUCCESS !=
4367 sme_SetTxPerTracking(pHddCtx->hHal,
4368 hdd_tx_per_hit_cb,
4369 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004371 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 }
4373 }
4374 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004375 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4376 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 }
4378done:
4379 /* many of the commands write information back into the command
4380 string using snprintf(). check the return value here in one
4381 place */
4382 if ((ret < 0) || (ret >= cmd_len))
4383 {
4384 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004385 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004387 else if (ret > 0)
4388 {
4389 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4390 {
4391 hddLog(VOS_TRACE_LEVEL_ERROR,
4392 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004393 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004394 return -EFAULT;
4395 }
4396 wrqu->data.length = ret;
4397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004398
4399 if (ioctl_debug)
4400 {
4401 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004402 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004404 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304405 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004406 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004407}
4408
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304409static int iw_set_priv(struct net_device *dev,
4410 struct iw_request_info *info,
4411 union iwreq_data *wrqu, char *extra)
4412{
4413 int ret;
4414 vos_ssr_protect(__func__);
4415 ret = __iw_set_priv(dev, info, wrqu, extra);
4416 vos_ssr_unprotect(__func__);
4417
4418 return ret;
4419}
4420
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304421static int __iw_set_nick(struct net_device *dev,
4422 struct iw_request_info *info,
4423 union iwreq_data *wrqu, char *extra)
4424{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304425 hdd_adapter_t *pAdapter;
4426 hdd_context_t *pHddCtx;
4427 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304428
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304429 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304430
4431 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4432 if (NULL == pAdapter)
4433 {
4434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4435 "%s: Adapter is NULL",__func__);
4436 return -EINVAL;
4437 }
4438
4439 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4440 ret = wlan_hdd_validate_context(pHddCtx);
4441 if (0 != ret)
4442 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304443 return ret;
4444 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304445 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304446 return 0;
4447}
4448
Jeff Johnson295189b2012-06-20 16:38:30 -07004449static int iw_set_nick(struct net_device *dev,
4450 struct iw_request_info *info,
4451 union iwreq_data *wrqu, char *extra)
4452{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304453 int ret;
4454
4455 vos_ssr_protect(__func__);
4456 ret = __iw_set_nick(dev, info, wrqu, extra);
4457 vos_ssr_unprotect(__func__);
4458
4459 return ret;
4460}
4461
4462static int __iw_get_nick(struct net_device *dev,
4463 struct iw_request_info *info,
4464 union iwreq_data *wrqu, char *extra)
4465{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304466 hdd_adapter_t *pAdapter;
4467 hdd_context_t *pHddCtx;
4468 int ret = 0;
4469
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304471
4472 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4473 if (NULL == pAdapter)
4474 {
4475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4476 "%s: Adapter is NULL",__func__);
4477 return -EINVAL;
4478 }
4479
4480 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4481 ret = wlan_hdd_validate_context(pHddCtx);
4482 if (0 != ret)
4483 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304484 return ret;
4485 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304486 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 return 0;
4488}
4489
4490static int iw_get_nick(struct net_device *dev,
4491 struct iw_request_info *info,
4492 union iwreq_data *wrqu, char *extra)
4493{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304494 int ret;
4495
4496 vos_ssr_protect(__func__);
4497 ret = __iw_get_nick(dev, info, wrqu, extra);
4498 vos_ssr_unprotect(__func__);
4499
4500 return ret;
4501}
4502
4503static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4504{
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304506 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004507}
4508
4509static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4510{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304511
4512 struct iw_statistics *stats;
4513
4514 vos_ssr_protect(__func__);
4515 stats = __get_wireless_stats(dev);
4516 vos_ssr_unprotect(__func__);
4517
4518 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004519}
4520
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304521static int __iw_set_encode(struct net_device *dev,
4522 struct iw_request_info *info,
4523 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004524
4525{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304526 hdd_adapter_t *pAdapter;
4527 hdd_station_ctx_t *pHddStaCtx;
4528 hdd_wext_state_t *pWextState;
4529 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 struct iw_point *encoderq = &(wrqu->encoding);
4531 v_U32_t keyId;
4532 v_U8_t key_length;
4533 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4534 v_BOOL_t fKeyPresent = 0;
4535 int i;
4536 eHalStatus status = eHAL_STATUS_SUCCESS;
4537
4538
4539 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304540 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4541 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4544 "%s: Adapter is NULL",__func__);
4545 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 }
4547
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304548 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4549 status = wlan_hdd_validate_context(pHddCtx);
4550 if (0 != status)
4551 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304552 return status;
4553 }
4554 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4555 if (NULL == pWextState)
4556 {
4557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4558 "%s: pWextState is NULL ",__func__);
4559 return -EINVAL;
4560 }
4561 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4562 if (NULL == pHddStaCtx)
4563 {
4564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4565 "%s: STA Context is NULL",__func__);
4566 return -EINVAL;
4567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004568
4569 keyId = encoderq->flags & IW_ENCODE_INDEX;
4570
4571 if(keyId)
4572 {
4573 if(keyId > MAX_WEP_KEYS)
4574 {
4575 return -EINVAL;
4576 }
4577
4578 fKeyPresent = 1;
4579 keyId--;
4580 }
4581 else
4582 {
4583 fKeyPresent = 0;
4584 }
4585
4586
4587 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4588 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 if(!fKeyPresent) {
4591
4592 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4593
4594 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4595 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4596 }
4597 }
4598 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4599 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4600 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4601 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4602
4603 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4604 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4605
4606 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4607 {
4608 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4609 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004610 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304611 {
4612 long ret;
4613 ret = wait_for_completion_interruptible_timeout(
4614 &pAdapter->disconnect_comp_var,
4615 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4616 if (ret <= 0)
4617 hddLog(VOS_TRACE_LEVEL_ERROR,
4618 FL("failed wait on disconnect_comp_var %ld"), ret);
4619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 }
4621
4622 return status;
4623
4624 }
4625
4626 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4627 {
4628 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4629
4630 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4631
4632 }
4633
4634
4635 if(wrqu->data.length > 0)
4636 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004637 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004638
4639 key_length = wrqu->data.length;
4640
4641 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4642
4643 if(5 == key_length)
4644 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004645 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004646
4647 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4648 {
4649 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4650 }
4651 else
4652 {
4653 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4654 }
4655 }
4656 else if(13 == key_length)
4657 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004658 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004659
4660 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4661 {
4662 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4663 }
4664 else
4665 {
4666 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4667 }
4668 }
4669 else
4670 {
4671 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004672 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 return -EINVAL;
4674 }
4675
4676 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4677 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4678 pWextState->roamProfile.EncryptionType.numEntries = 1;
4679 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4680 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4681 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4682
4683 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4684 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4685 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4686 {
4687
4688 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4689
4690 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4691 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4692
4693 return status;
4694 }
4695 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304696 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 return 0;
4698}
4699
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304700static int iw_set_encode(struct net_device *dev,
4701 struct iw_request_info *info,
4702 union iwreq_data *wrqu,char *extra)
4703{
4704 int ret;
4705
4706 vos_ssr_protect(__func__);
4707 ret = __iw_set_encode(dev, info, wrqu, extra);
4708 vos_ssr_unprotect(__func__);
4709
4710 return ret;
4711}
4712
4713static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 struct iw_request_info *info,
4715 struct iw_point *dwrq,
4716 char *extra)
4717{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304718 hdd_adapter_t *pAdapter;
4719 hdd_wext_state_t *pWextState;
4720 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 int keyId;
4722 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4723 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304724 int i, ret = 0;
4725 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004726
4727 ENTER();
4728
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304729 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4730 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004731 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4733 "%s: Adapter is NULL",__func__);
4734 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004735 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304736 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4737 ret = wlan_hdd_validate_context(pHddCtx);
4738 if (0 != ret)
4739 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304740 return ret;
4741 }
4742 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4743 if (NULL == pWextState)
4744 {
4745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4746 "%s: pWextState is NULL",__func__);
4747 return -EINVAL;
4748 }
4749 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004750
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 keyId = pRoamProfile->Keys.defaultIndex;
4752
4753 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4754 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004755 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 return -EINVAL;
4757 }
4758
4759 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4760 {
4761 dwrq->flags |= IW_ENCODE_ENABLED;
4762 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304763 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4764 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 }
4766 else
4767 {
4768 dwrq->flags |= IW_ENCODE_DISABLED;
4769 }
4770
4771 for(i=0; i < MAX_WEP_KEYS; i++)
4772 {
4773 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4774 {
4775 continue;
4776 }
4777 else
4778 {
4779 break;
4780 }
4781 }
4782
4783 if(MAX_WEP_KEYS == i)
4784 {
4785 dwrq->flags |= IW_ENCODE_NOKEY;
4786 }
4787 else
4788 {
4789 dwrq->flags |= IW_ENCODE_ENABLED;
4790 }
4791
4792 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4793
4794 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4795 {
4796 dwrq->flags |= IW_ENCODE_DISABLED;
4797 }
4798
4799 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4800
4801 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4802 {
4803 dwrq->flags |= IW_ENCODE_OPEN;
4804 }
4805 else
4806 {
4807 dwrq->flags |= IW_ENCODE_RESTRICTED;
4808 }
4809 EXIT();
4810 return 0;
4811
4812}
4813
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304814static int iw_get_encodeext(struct net_device *dev,
4815 struct iw_request_info *info,
4816 struct iw_point *dwrq,
4817 char *extra)
4818{
4819 int ret;
4820 vos_ssr_protect(__func__);
4821 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4822 vos_ssr_unprotect(__func__);
4823
4824 return ret;
4825}
4826
4827static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 struct iw_request_info *info,
4829 union iwreq_data *wrqu, char *extra)
4830{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304831 hdd_adapter_t *pAdapter;
4832 hdd_station_ctx_t *pHddStaCtx;
4833 hdd_wext_state_t *pWextState;
4834 hdd_context_t *pHddCtx;
4835 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004836
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304837 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 v_U32_t status = 0;
4839
4840 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4841
4842 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4843
4844 int key_index;
4845 struct iw_point *encoding = &wrqu->encoding;
4846 tCsrRoamSetKey setKey;
4847 v_U32_t roamId= 0xFF;
4848 VOS_STATUS vos_status;
4849
4850 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304851 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4852 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4855 "%s: Adapter is NULL",__func__);
4856 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304858 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4859 status = wlan_hdd_validate_context(pHddCtx);
4860 if (0 != status)
4861 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304862 return status;
4863 }
4864 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4865 if (NULL == pHddStaCtx)
4866 {
4867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4868 "%s: STA Context is NULL",__func__);
4869 return -EINVAL;
4870 }
4871 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4872 if (NULL == pWextState)
4873 {
4874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4875 "%s: pWextState is NULL",__func__);
4876 return -EINVAL;
4877 }
4878 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 key_index = encoding->flags & IW_ENCODE_INDEX;
4880
4881 if(key_index > 0) {
4882
4883 /*Convert from 1-based to 0-based keying*/
4884 key_index--;
4885 }
4886 if(!ext->key_len) {
4887
4888 /*Set the encrytion type to NONE*/
4889 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4890 return status;
4891 }
4892
4893 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4894 (IW_ENCODE_ALG_WEP == ext->alg))
4895 {
4896 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4897
Agarwal Ashish971c2882013-10-30 20:11:12 +05304898 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4899 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 return -EINVAL;
4901 }
4902 else {
4903 /*Static wep, update the roam profile with the keys */
4904 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4905 key_index < CSR_MAX_NUM_KEY) {
4906 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4907 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4908
4909 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4910 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4911
4912 }
4913 }
4914 return status;
4915 }
4916
4917 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4918
4919 setKey.keyId = key_index;
4920 setKey.keyLength = ext->key_len;
4921
4922 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4923 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4924 }
4925
4926 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4927 /*Key direction for group is RX only*/
4928 setKey.keyDirection = eSIR_RX_ONLY;
4929 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4930 }
4931 else {
4932
4933 setKey.keyDirection = eSIR_TX_RX;
4934 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4935 }
4936
4937 /*For supplicant pae role is zero*/
4938 setKey.paeRole = 0;
4939
4940 switch(ext->alg)
4941 {
4942 case IW_ENCODE_ALG_NONE:
4943 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4944 break;
4945
4946 case IW_ENCODE_ALG_WEP:
4947 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4948 break;
4949
4950 case IW_ENCODE_ALG_TKIP:
4951 {
4952 v_U8_t *pKey = &setKey.Key[0];
4953
4954 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4955
4956 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4957
4958 /*Supplicant sends the 32bytes key in this order
4959
4960 |--------------|----------|----------|
4961 | Tk1 |TX-MIC | RX Mic |
4962 |--------------|----------|----------|
4963 <---16bytes---><--8bytes--><--8bytes-->
4964
4965 */
4966 /*Sme expects the 32 bytes key to be in the below order
4967
4968 |--------------|----------|----------|
4969 | Tk1 |RX-MIC | TX Mic |
4970 |--------------|----------|----------|
4971 <---16bytes---><--8bytes--><--8bytes-->
4972 */
4973 /* Copy the Temporal Key 1 (TK1) */
4974 vos_mem_copy(pKey,ext->key,16);
4975
4976 /*Copy the rx mic first*/
4977 vos_mem_copy(&pKey[16],&ext->key[24],8);
4978
4979 /*Copy the tx mic */
4980 vos_mem_copy(&pKey[24],&ext->key[16],8);
4981
4982 }
4983 break;
4984
4985 case IW_ENCODE_ALG_CCMP:
4986 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4987 break;
4988
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004989#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004990#define IW_ENCODE_ALG_KRK 6
4991 case IW_ENCODE_ALG_KRK:
4992 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4993 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004994#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004995
4996 default:
4997 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4998 break;
4999 }
5000
5001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005002 ("%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 -07005003
5004#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305005 /* The supplicant may attempt to set the PTK once pre-authentication
5006 is done. Save the key in the UMAC and include it in the ADD
5007 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305009 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305011 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5012 "%s: Update PreAuth Key success", __func__);
5013 return 0;
5014 }
5015 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5016 {
5017 hddLog(VOS_TRACE_LEVEL_ERROR,
5018 "%s: Update PreAuth Key failed", __func__);
5019 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 }
5021#endif /* WLAN_FEATURE_VOWIFI_11R */
5022
5023 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5024
5025 vos_status = wlan_hdd_check_ula_done(pAdapter);
5026 if ( vos_status != VOS_STATUS_SUCCESS )
5027 {
5028 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5029 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5030 __LINE__, vos_status );
5031
5032 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5033 }
5034
5035 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5036
5037 if ( halStatus != eHAL_STATUS_SUCCESS )
5038 {
5039 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5040 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5041 __LINE__, halStatus );
5042
5043 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5044 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305045 EXIT();
5046 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005047}
5048
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305049static int iw_set_encodeext(struct net_device *dev,
5050 struct iw_request_info *info,
5051 union iwreq_data *wrqu, char *extra)
5052{
5053 int ret;
5054
5055 vos_ssr_protect(__func__);
5056 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5057 vos_ssr_unprotect(__func__);
5058
5059 return ret;
5060}
5061
5062static int __iw_set_retry(struct net_device *dev,
5063 struct iw_request_info *info,
5064 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005065{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305066 hdd_adapter_t *pAdapter;
5067 tHalHandle hHal;
5068 hdd_context_t *pHddCtx;
5069 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005070
5071 ENTER();
5072
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305073 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5074 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005075 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5077 "%s: Adapter is NULL",__func__);
5078 return -EINVAL;
5079 }
5080
5081 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5082 ret = wlan_hdd_validate_context(pHddCtx);
5083 if (0 != ret)
5084 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305085 return ret;
5086 }
5087
5088 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5089 if (NULL == hHal)
5090 {
5091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5092 "%s: Hal Context is NULL",__func__);
5093 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005094 }
5095
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5097 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5098
Arif Hussain6d2a3322013-11-17 19:50:10 -08005099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005100
5101 return -EINVAL;
5102 }
5103
5104 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5105
5106 if((wrqu->retry.flags & IW_RETRY_LONG))
5107 {
5108 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5109 {
c_hpothub8245442013-11-20 23:41:09 +05305110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5111 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 return -EIO;
5113 }
5114 }
5115 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5116 {
5117 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5118 {
c_hpothub8245442013-11-20 23:41:09 +05305119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5120 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 return -EIO;
5122 }
5123 }
5124 }
5125 else
5126 {
5127 return -EOPNOTSUPP;
5128 }
5129
Arif Hussain6d2a3322013-11-17 19:50:10 -08005130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005131
5132 EXIT();
5133
5134 return 0;
5135
5136}
5137
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305138static int iw_set_retry(struct net_device *dev,
5139 struct iw_request_info *info,
5140 union iwreq_data *wrqu, char *extra)
5141{
5142 int ret;
5143
5144 vos_ssr_protect(__func__);
5145 ret = __iw_set_retry(dev, info, wrqu, extra);
5146 vos_ssr_unprotect(__func__);
5147
5148 return ret;
5149}
5150
5151static int __iw_get_retry(struct net_device *dev,
5152 struct iw_request_info *info,
5153 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005154{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305155 hdd_adapter_t *pAdapter;
5156 hdd_context_t *pHddCtx;
5157 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305159 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005160
5161 ENTER();
5162
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305163 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5164 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005165 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5167 "%s: Adapter is NULL",__func__);
5168 return -EINVAL;
5169 }
5170
5171 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5172 ret = wlan_hdd_validate_context(pHddCtx);
5173 if (0 != ret)
5174 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305175 return ret;
5176 }
5177
5178 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5179 if (NULL == hHal)
5180 {
5181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5182 "%s: Hal Context is NULL",__func__);
5183 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005184 }
5185
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 if((wrqu->retry.flags & IW_RETRY_LONG))
5187 {
5188 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5189
5190 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5191 {
c_hpothub8245442013-11-20 23:41:09 +05305192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5193 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005194 return -EIO;
5195 }
5196
5197 wrqu->retry.value = retry;
5198 }
5199 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5200 {
5201 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5202
5203 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5204 {
c_hpothub8245442013-11-20 23:41:09 +05305205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5206 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 return -EIO;
5208 }
5209
5210 wrqu->retry.value = retry;
5211 }
5212 else {
5213 return -EOPNOTSUPP;
5214 }
5215
Arif Hussain6d2a3322013-11-17 19:50:10 -08005216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005217
5218 EXIT();
5219
5220 return 0;
5221}
5222
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305223static int iw_get_retry(struct net_device *dev,
5224 struct iw_request_info *info,
5225 union iwreq_data *wrqu, char *extra)
5226{
5227 int ret;
5228
5229 vos_ssr_protect(__func__);
5230 ret = __iw_get_retry(dev, info, wrqu, extra);
5231 vos_ssr_unprotect(__func__);
5232
5233 return ret;
5234}
5235
5236static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 struct iw_request_info *info,
5238 union iwreq_data *wrqu,
5239 char *extra)
5240{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305241 hdd_adapter_t *pAdapter;
5242 hdd_context_t *pHddCtx;
5243 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5245 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305246 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005247
5248 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305249 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5250 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005251 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5253 "%s:Adapter is NULL",__func__);
5254 return -EINVAL;
5255 }
5256 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5257 ret = wlan_hdd_validate_context(pHddCtx);
5258 if (0 != ret)
5259 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305260 return ret;
5261 }
5262 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5263 if (NULL == pHddStaCtx)
5264 {
5265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5266 "%s:STA context is NULL",__func__);
5267 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 }
5269
5270 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5271 switch (mlme->cmd) {
5272 case IW_MLME_DISASSOC:
5273 case IW_MLME_DEAUTH:
5274
5275 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5276 {
5277 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5278
5279 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5280 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5281
5282 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5283 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5284
Jeff Johnson43971f52012-07-17 12:26:56 -07005285 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305286 {
5287 long ret;
5288 ret = wait_for_completion_interruptible_timeout(
5289 &pAdapter->disconnect_comp_var,
5290 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5291 if (ret <= 0)
5292 hddLog(VOS_TRACE_LEVEL_ERROR,
5293 FL("failed wait on disconnect_comp_var %ld"), ret);
5294 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005295 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005296 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005297 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005298
5299 /* Resetting authKeyMgmt */
5300 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5301
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305302 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005303 netif_tx_disable(dev);
5304 netif_carrier_off(dev);
5305
5306 }
5307 else
5308 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005309 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 -07005310 }
5311 break;
5312 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005313 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 return -EINVAL;
5315 }//end of switch
5316
5317 EXIT();
5318
5319 return status;
5320
5321}
5322
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305323static int iw_set_mlme(struct net_device *dev,
5324 struct iw_request_info *info,
5325 union iwreq_data *wrqu,
5326 char *extra)
5327{
5328 int ret;
5329
5330 vos_ssr_protect(__func__);
5331 ret = __iw_set_mlme(dev, info, wrqu, extra);
5332 vos_ssr_unprotect(__func__);
5333
5334 return ret;
5335}
5336
Jeff Johnson295189b2012-06-20 16:38:30 -07005337/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305338static int __iw_setint_getnone(struct net_device *dev,
5339 struct iw_request_info *info,
5340 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005341{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305342 hdd_adapter_t *pAdapter;
5343 tHalHandle hHal;
5344 hdd_wext_state_t *pWextState;
5345 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305346 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 int *value = (int *)extra;
5348 int sub_cmd = value[0];
5349 int set_value = value[1];
5350 int ret = 0; /* success */
5351 int enable_pbm, enable_mp;
5352#ifdef CONFIG_HAS_EARLYSUSPEND
5353 v_U8_t nEnableSuspendOld;
5354#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005355
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305356 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305357 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5358 if (NULL == pAdapter)
5359 {
5360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5361 "%s: Adapter is NULL",__func__);
5362 return -EINVAL;
5363 }
5364 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5365 ret = wlan_hdd_validate_context(pHddCtx);
5366 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005367 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305368 return ret;
5369 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305370
5371 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5372 if (NULL == hHal)
5373 {
5374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5375 "%s: Hal Context is NULL",__func__);
5376 return -EINVAL;
5377 }
5378
Katya Nigameae74b62015-05-28 17:19:16 +05305379 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305380 {
Katya Nigameae74b62015-05-28 17:19:16 +05305381 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5382 if (NULL == pWextState)
5383 {
5384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5385 "%s: pWextState is NULL",__func__);
5386 return -EINVAL;
5387 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005388
Katya Nigameae74b62015-05-28 17:19:16 +05305389 INIT_COMPLETION(pWextState->completion_var);
5390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 switch(sub_cmd)
5392 {
5393 case WE_SET_11D_STATE:
5394 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005395 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005396 memset(&smeConfig, 0x00, sizeof(smeConfig));
5397
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5399
5400 sme_GetConfigParam(hHal,&smeConfig);
5401 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5402
Arif Hussain6d2a3322013-11-17 19:50:10 -08005403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005404
5405 sme_UpdateConfig(hHal,&smeConfig);
5406 }
5407 else {
5408 return -EINVAL;
5409 }
5410 break;
5411 }
5412
5413 case WE_WOWL:
5414 {
5415 switch (set_value)
5416 {
5417 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305418 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 break;
5420 case 0x01:
5421 case 0x02:
5422 case 0x03:
5423 enable_mp = (set_value & 0x01) ? 1 : 0;
5424 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005425 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5427 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5428 break;
5429 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005430 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 ret = -EINVAL;
5432 break;
5433 }
5434
5435 break;
5436 }
5437 case WE_SET_POWER:
5438 {
5439 switch (set_value)
5440 {
5441 case 0: //Full Power
5442 {
5443 struct statsContext context;
5444 eHalStatus status;
5445
5446 init_completion(&context.completion);
5447
5448 context.pAdapter = pAdapter;
5449 context.magic = POWER_CONTEXT_MAGIC;
5450
5451 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5452 iw_power_callback_fn, &context,
5453 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005454 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 {
5456 int lrc = wait_for_completion_interruptible_timeout(
5457 &context.completion,
5458 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005459
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 if (lrc <= 0)
5461 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005462 hddLog(VOS_TRACE_LEVEL_ERROR,
5463 "%s: SME %s while requesting fullpower",
5464 __func__, (0 == lrc) ?
5465 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 }
5467 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005468 /* either we have a response or we timed out. if we timed
5469 out there is a race condition such that the callback
5470 function could be executing at the same time we are. of
5471 primary concern is if the callback function had already
5472 verified the "magic" but had not yet set the completion
5473 variable when a timeout occurred. we serialize these
5474 activities by invalidating the magic while holding a
5475 shared spinlock which will cause us to block if the
5476 callback is currently executing */
5477 spin_lock(&hdd_context_lock);
5478 context.magic = 0;
5479 spin_unlock(&hdd_context_lock);
5480
Arif Hussain6d2a3322013-11-17 19:50:10 -08005481 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 break;
5483 }
5484 case 1: //Enable BMPS
5485 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5486 break;
5487 case 2: //Disable BMPS
5488 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5489 break;
5490 case 3: //Request Bmps
5491 {
5492 struct statsContext context;
5493 eHalStatus status;
5494
5495 init_completion(&context.completion);
5496
5497 context.pAdapter = pAdapter;
5498 context.magic = POWER_CONTEXT_MAGIC;
5499
5500 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5501 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005502 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 {
5504 int lrc = wait_for_completion_interruptible_timeout(
5505 &context.completion,
5506 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 if (lrc <= 0)
5508 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005509 hddLog(VOS_TRACE_LEVEL_ERROR,
5510 "%s: SME %s while requesting BMPS",
5511 __func__, (0 == lrc) ? "timeout" :
5512 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 }
5514 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005515 /* either we have a response or we timed out. if we
5516 timed out there is a race condition such that the
5517 callback function could be executing at the same
5518 time we are. of primary concern is if the callback
5519 function had already verified the "magic" but had
5520 not yet set the completion variable when a timeout
5521 occurred. we serialize these activities by
5522 invalidating the magic while holding a shared
5523 spinlock which will cause us to block if the
5524 callback is currently executing */
5525 spin_lock(&hdd_context_lock);
5526 context.magic = 0;
5527 spin_unlock(&hdd_context_lock);
5528
Arif Hussain6d2a3322013-11-17 19:50:10 -08005529 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 break;
5531 }
5532 case 4: //Enable IMPS
5533 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5534 break;
5535 case 5: //Disable IMPS
5536 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5537 break;
5538 case 6: //Enable Standby
5539 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5540 break;
5541 case 7: //Disable Standby
5542 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5543 break;
5544 case 8: //Request Standby
5545#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005546#endif
5547 break;
5548 case 9: //Start Auto Bmps Timer
5549 sme_StartAutoBmpsTimer(hHal);
5550 break;
5551 case 10://Stop Auto BMPS Timer
5552 sme_StopAutoBmpsTimer(hHal);
5553 break;
5554#ifdef CONFIG_HAS_EARLYSUSPEND
5555 case 11://suspend to standby
5556#ifdef CONFIG_HAS_EARLYSUSPEND
5557 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5558 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5560#endif
5561 break;
5562 case 12://suspend to deep sleep
5563#ifdef CONFIG_HAS_EARLYSUSPEND
5564 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5565 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5567#endif
5568 break;
5569 case 13://resume from suspend
5570#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005571#endif
5572 break;
5573#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005574 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005575 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 ret = -EINVAL;
5577 break;
5578 }
5579 break;
5580 }
5581
5582 case WE_SET_MAX_ASSOC:
5583 {
5584 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5585 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5586 {
5587 ret = -EINVAL;
5588 }
5589 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5590 set_value, NULL, eANI_BOOLEAN_FALSE)
5591 != eHAL_STATUS_SUCCESS )
5592 {
c_hpothub8245442013-11-20 23:41:09 +05305593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5594 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 ret = -EIO;
5596 }
5597 break;
5598 }
5599
5600 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5601 {
5602 if( 0 == set_value )
5603 {
5604 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5605 }
5606 else if ( 1 == set_value )
5607 {
5608 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5609 }
5610 else
5611 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005612 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 ret = -EINVAL;
5614 }
5615 break;
5616 }
5617
5618 case WE_SET_DATA_INACTIVITY_TO:
5619 {
5620 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5621 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5622 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5623 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5624 set_value,
5625 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5626 {
5627 hddLog(LOGE,"Failure: Could not pass on "
5628 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005629 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 ret = -EINVAL;
5631 }
5632 break;
5633 }
5634 case WE_SET_MAX_TX_POWER:
5635 {
5636 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5637 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5638
5639 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5640 __func__, set_value);
5641 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5642 eHAL_STATUS_SUCCESS )
5643 {
5644 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5645 __func__);
5646 return -EIO;
5647 }
5648
5649 break;
5650 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005651 case WE_SET_MAX_TX_POWER_2_4:
5652 {
5653 hddLog(VOS_TRACE_LEVEL_INFO,
5654 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5655 __func__, set_value);
5656 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5657 eHAL_STATUS_SUCCESS)
5658 {
5659 hddLog(VOS_TRACE_LEVEL_ERROR,
5660 "%s: Setting maximum tx power failed for 2.4 GHz band",
5661 __func__);
5662 return -EIO;
5663 }
5664
5665 break;
5666 }
5667 case WE_SET_MAX_TX_POWER_5_0:
5668 {
5669 hddLog(VOS_TRACE_LEVEL_INFO,
5670 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5671 __func__, set_value);
5672 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5673 eHAL_STATUS_SUCCESS)
5674 {
5675 hddLog(VOS_TRACE_LEVEL_ERROR,
5676 "%s: Setting maximum tx power failed for 5.0 GHz band",
5677 __func__);
5678 return -EIO;
5679 }
5680
5681 break;
5682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 case WE_SET_HIGHER_DTIM_TRANSITION:
5684 {
5685 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5686 (set_value == eANI_BOOLEAN_TRUE)))
5687 {
5688 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5689 ret = -EINVAL;
5690 }
5691 else
5692 {
5693 if(pAdapter->higherDtimTransition != set_value)
5694 {
5695 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005696 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005697 }
5698 }
5699
5700 break;
5701 }
5702
5703 case WE_SET_TM_LEVEL:
5704 {
5705 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005706 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5708
5709 break;
5710 }
5711
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305712 case WE_ENABLE_STRICT_FCC_REG:
5713 {
5714 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5715 struct wiphy *wiphy = NULL;
5716 long lrc;
5717 int status;
5718
5719 wiphy = hddCtxt->wiphy;
5720 if(wiphy == NULL)
5721 {
5722 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5723 break;
5724 }
5725 init_completion(&hddCtxt->wiphy_channel_update_event);
5726
5727 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5728
5729 status = regulatory_hint(wiphy, "00");
5730 if(status < 0)
5731 {
5732 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5733 break;
5734 }
5735
5736 /* Wait for completion */
5737 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5738 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5739 if (lrc <= 0)
5740 {
5741 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5742 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5743 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5744 }
5745 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5746
5747 break;
5748 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005749 case WE_SET_DEBUG_LOG:
5750 {
5751 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5752 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5753 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5754 break;
5755 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305756#ifdef FEATURE_WLAN_TDLS
5757 case WE_SET_TDLS_OFF_CHAN:
5758 {
5759 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5761 __func__, set_value);
5762 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5763 break;
5764 }
5765 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5766 {
5767 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5769 __func__, set_value);
5770 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5771 break;
5772 }
5773 case WE_SET_TDLS_OFF_CHAN_MODE:
5774 {
5775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5776 __func__, set_value);
5777 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5778 break;
5779 }
5780#endif
Peng Xu2446a892014-09-05 17:21:18 +05305781 case WE_SET_SCAN_BAND_PREFERENCE:
5782 {
5783 tSmeConfigParams smeConfig;
5784 memset(&smeConfig, 0x00, sizeof(smeConfig));
5785 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5786 ret = -EINVAL;
5787 break;
5788 }
5789 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5790
5791 if (eCSR_BAND_ALL == set_value ||
5792 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5793 sme_GetConfigParam(hHal, &smeConfig);
5794 smeConfig.csrConfig.scanBandPreference = set_value;
5795
5796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5797 "set band scan preference = %d\n",
5798 smeConfig.csrConfig.scanBandPreference);
5799
5800 sme_UpdateConfig(hHal, &smeConfig);
5801 }
5802 else {
5803 ret = -EINVAL;
5804 }
5805 break;
5806 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305807 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5808 * connection happens so that the params can take effect during
5809 * association. Also this should not be used in STA+p2p concurrency
5810 * as the param will also effect the STA mode.
5811 */
5812 case WE_SET_MIRACAST_VENDOR_CONFIG:
5813 {
5814 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305815
Abhishek Singh01c73d12015-03-12 15:13:44 +05305816 hddLog(LOG1, FL(
5817 "Set Miracast vendor tuning %d"), set_value);
5818
5819 if (1 == set_value || 0 == set_value)
5820 {
5821 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5822 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5823 {
5824 hddLog( LOGE, FL("set vendor miracast config failed"));
5825 ret = -EIO;
5826 }
5827 }
5828 else
5829 {
5830 hddLog(LOGE,
5831 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5832 ret = -EINVAL;
5833 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305834 break;
5835 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305836
5837 case WE_GET_FRAME_LOG:
5838 {
5839 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5840 != VOS_STATUS_SUCCESS)
5841 {
5842 ret = -EINVAL;
5843 }
5844 break;
5845 }
5846
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305847 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5848 {
5849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5850 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5851 if (set_value == 0 || set_value == 1)
5852 {
5853 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5854 set_value);
5855 }
5856 else
5857 ret = -EINVAL;
5858
5859 break;
5860 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05305861 /* Bit mask value to enable RTS/CTS for different modes
5862 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
5863 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
5864 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
5865 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
5866 * for 5 GHz, VHT80 - 0x1000
5867 */
5868 case WE_SET_RTS_CTS_HTVHT:
5869 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305870
Abhishek Singh41988ba2015-05-25 19:42:29 +05305871 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
5872
5873 if (eHAL_STATUS_SUCCESS !=
5874 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
5875 {
5876 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
5877 ret = -EINVAL;
5878 }
5879 break;
5880 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305881 case WE_SET_MONITOR_STATE:
5882 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305883 v_U32_t magic = 0;
5884 struct completion cmpVar;
5885 long waitRet = 0;
5886 tVOS_CON_MODE mode = hdd_get_conparam();
5887
5888 if( VOS_MONITOR_MODE != mode)
5889 {
5890 hddLog(LOGE, "invalid mode %d", mode);
5891 ret = -EIO;
5892 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305893
5894 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
5895 if( pMonCtx == NULL )
5896 {
5897 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305898 ret = -EIO;
5899 }
5900 if (pMonCtx->state == set_value)
5901 {
5902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5903 FL("already in same mode curr_mode:%d req_mode: %d"),
5904 pMonCtx->state, set_value);
5905 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305906 }
5907 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305908 magic = MON_MODE_MSG_MAGIC;
5909 init_completion(&cmpVar);
5910 if (VOS_STATUS_SUCCESS !=
5911 wlan_hdd_mon_postMsg(&magic, &cmpVar,
5912 pMonCtx, hdd_monPostMsgCb)) {
5913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5914 FL("failed to post MON MODE REQ"));
5915 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
5916 MON_MODE_STOP : MON_MODE_START;
5917 magic = 0;
5918 ret = -EIO;
5919 break;
5920 }
5921 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
5922 magic = 0;
5923 if (waitRet <= 0 ){
5924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5925 FL("failed to wait on monitor mode completion %ld"),
5926 waitRet);
5927 }
5928 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305929 }
Sushant Kaushik33200572015-08-05 16:46:20 +05305930 case WE_SET_PKT_STATS_ENABLE_DISABLE:
5931 {
5932 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5933 tAniWifiStartLog start_log;
5934 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
5935 !vos_isPktStatsEnabled())
5936 {
5937 hddLog(LOGE, FL("per pkt stats not enabled"));
5938 return -EINVAL;
5939 }
5940 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
5941
5942 if (1 == set_value || 0 == set_value)
5943 {
5944 start_log.ringId = RING_ID_PER_PACKET_STATS;
5945 start_log.flag = 0;
5946 if (set_value)
5947 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
5948 else
5949 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
5950
5951 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
5952 }
5953 else
5954 {
5955 hddLog(LOGE,
5956 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
5957 set_value);
5958 ret = -EINVAL;
5959 }
5960 break;
5961 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305962
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 default:
5964 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005965 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 sub_cmd, set_value);
5967 break;
5968 }
5969 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305970 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 return ret;
5972}
5973
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305974static int iw_setint_getnone(struct net_device *dev,
5975 struct iw_request_info *info,
5976 union iwreq_data *wrqu, char *extra)
5977{
5978 int ret;
5979
5980 vos_ssr_protect(__func__);
5981 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5982 vos_ssr_unprotect(__func__);
5983
5984 return 0;
5985}
Jeff Johnson295189b2012-06-20 16:38:30 -07005986/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305987static int __iw_setchar_getnone(struct net_device *dev,
5988 struct iw_request_info *info,
5989 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005990{
5991 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305992 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005994 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305995 hdd_adapter_t *pAdapter;
5996 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005997#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305998 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005999#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306000 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306001 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006002
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306003 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306004 pAdapter = (netdev_priv(dev));
6005 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006006 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6008 "%s: Adapter is NULL",__func__);
6009 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006010 }
6011
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306012 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6013 ret = wlan_hdd_validate_context(pHddCtx);
6014 if (0 != ret)
6015 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306016 return ret;
6017 }
6018#ifdef WLAN_FEATURE_VOWIFI
6019 pConfig = pHddCtx->cfg_ini;
6020#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306021 /* helper function to get iwreq_data with compat handling. */
6022 if (hdd_priv_get_data(&s_priv_data, wrqu))
6023 {
6024 return -EINVAL;
6025 }
6026
6027 /* make sure all params are correctly passed to function */
6028 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6029 {
6030 return -EINVAL;
6031 }
6032
6033 sub_cmd = s_priv_data.flags;
6034
Arif Hussain0273cba2014-01-07 20:58:29 -08006035 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306036 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6037 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006038 if (NULL == pBuffer)
6039 {
6040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6041 "mem_alloc_copy_from_user_helper fail");
6042 return -ENOMEM;
6043 }
6044
6045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306046 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6048 "%s: Received data %s", __func__, pBuffer);
6049
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 switch(sub_cmd)
6051 {
6052 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006054 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 break;
6056 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006058 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 break;
6060#if defined WLAN_FEATURE_VOWIFI
6061 case WE_NEIGHBOR_REPORT_REQUEST:
6062 {
6063 tRrmNeighborReq neighborReq;
6064 tRrmNeighborRspCallbackInfo callbackInfo;
6065
6066 if (pConfig->fRrmEnable)
6067 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306069 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 if( !neighborReq.no_ssid )
6071 {
Girish Gowli552fc072014-06-14 18:26:16 +05306072 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006073 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 }
6075
6076 callbackInfo.neighborRspCallback = NULL;
6077 callbackInfo.neighborRspCallbackContext = NULL;
6078 callbackInfo.timeout = 5000; //5 seconds
6079 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6080 }
6081 else
6082 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006083 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 ret = -EINVAL;
6085 }
6086 }
6087 break;
6088#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 case WE_SET_AP_WPS_IE:
6090 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306091 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006094 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 if (VOS_STATUS_SUCCESS != vstatus)
6096 {
6097 ret = -EINVAL;
6098 }
6099 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306100 case WE_SET_ENCRYPT_MSG:
6101 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6102 if (NULL == pkt)
6103 {
6104 hddLog(VOS_TRACE_LEVEL_ERROR,
6105 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306106 ret = -ENOMEM;
6107 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306108 }
6109
6110 memset(pkt, 0, sizeof(tSirpkt80211));
6111
6112 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6113 hddLog(VOS_TRACE_LEVEL_ERROR,
6114 FL("Firmware is not DISA capable"));
6115 ret = -EINVAL;
6116 vos_mem_free(pkt);
6117 break;
6118 }
6119
6120 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6121
6122 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6123 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6124 if (eHAL_STATUS_SUCCESS != ret) {
6125 hddLog(VOS_TRACE_LEVEL_ERROR,
6126 FL("SENDEncryptMSG: fail to post WDA cmd"));
6127 ret = -EINVAL;
6128 }
6129 vos_mem_free(pkt);
6130
6131 break;
6132
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 default:
6134 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006135 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 ret = -EINVAL;
6137 break;
6138 }
6139 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006140 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306141
6142 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 return ret;
6144}
6145
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306146static int iw_setchar_getnone(struct net_device *dev,
6147 struct iw_request_info *info,
6148 union iwreq_data *wrqu, char *extra)
6149{
6150 int ret;
6151
6152 vos_ssr_protect(__func__);
6153 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6154 vos_ssr_unprotect(__func__);
6155
6156 return ret;
6157}
6158
Jeff Johnson295189b2012-06-20 16:38:30 -07006159/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306160static int __iw_setnone_getint(struct net_device *dev,
6161 struct iw_request_info *info,
6162 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006163{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306164 hdd_adapter_t *pAdapter;
6165 tHalHandle hHal;
6166 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 int *value = (int *)extra;
6168 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05306169 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006170
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306171 ENTER();
6172
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306173 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6174 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006175 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6177 "%s: Adapter is NULL",__func__);
6178 return -EINVAL;
6179 }
6180 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6181 ret = wlan_hdd_validate_context(pHddCtx);
6182 if (0 != ret)
6183 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306184 return ret;
6185 }
6186 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6187 if (NULL == hHal)
6188 {
6189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6190 "%s: Hal Context is NULL",__func__);
6191 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006193
6194 switch (value[0])
6195 {
6196 case WE_GET_11D_STATE:
6197 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006198 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306200
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6202
Arif Hussain6d2a3322013-11-17 19:50:10 -08006203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006204
6205 break;
6206 }
6207
6208 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 break;
6211
6212 case WE_PMC_STATE:
6213 {
6214 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 break;
6217 }
6218 case WE_GET_WLAN_DBG:
6219 {
6220 vos_trace_display();
6221 *value = 0;
6222 break;
6223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 case WE_GET_MAX_ASSOC:
6225 {
6226 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6227 {
c_hpothub8245442013-11-20 23:41:09 +05306228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6229 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 ret = -EIO;
6231 }
Girish Gowli385be612014-09-18 11:17:20 +05306232#ifdef WLAN_SOFTAP_VSTA_FEATURE
6233 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6234 {
6235 if (*value > VSTA_NUM_ASSOC_STA)
6236 {
6237 *value = VSTA_NUM_ASSOC_STA;
6238 }
6239 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6240 (*value > (VSTA_NUM_ASSOC_STA -
6241 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6242 {
6243 *value = (VSTA_NUM_ASSOC_STA -
6244 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6245 }
6246 }
6247 else
6248#endif
6249 {
6250 if (*value > NUM_ASSOC_STA)
6251 {
6252 *value = NUM_ASSOC_STA;
6253 }
6254 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6255 (*value > (NUM_ASSOC_STA -
6256 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6257 {
6258 *value = (NUM_ASSOC_STA -
6259 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6260 }
6261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 break;
6263 }
6264
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 case WE_GET_WDI_DBG:
6266 {
6267 wpalTraceDisplay();
6268 *value = 0;
6269 break;
6270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006271
6272 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6273 {
6274 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6275 break;
6276 }
6277 case WE_GET_CONCURRENCY_MODE:
6278 {
6279 *value = hdd_get_concurrency_mode ( );
6280
Arif Hussain6d2a3322013-11-17 19:50:10 -08006281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 break;
6283 }
6284
Peng Xu2446a892014-09-05 17:21:18 +05306285 case WE_GET_SCAN_BAND_PREFERENCE:
6286 {
6287 sme_GetConfigParam(hHal, &smeConfig);
6288 *value = smeConfig.csrConfig.scanBandPreference;
6289
6290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6291 "scanBandPreference = %d\n", *value);
6292 break;
6293 }
6294
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 default:
6296 {
6297 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6298 break;
6299 }
6300 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306301 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 return ret;
6303}
6304
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306305static int iw_setnone_getint(struct net_device *dev,
6306 struct iw_request_info *info,
6307 union iwreq_data *wrqu, char *extra)
6308{
6309 int ret;
6310
6311 vos_ssr_protect(__func__);
6312 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6313 vos_ssr_unprotect(__func__);
6314
6315 return ret;
6316
6317}
Jeff Johnson295189b2012-06-20 16:38:30 -07006318/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306319int __iw_set_three_ints_getnone(struct net_device *dev,
6320 struct iw_request_info *info,
6321 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006322{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306323 hdd_adapter_t *pAdapter;
6324 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 int *value = (int *)extra;
6326 int sub_cmd = value[0];
6327 int ret = 0;
6328
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306329 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306330 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6331 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006332 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6334 "%s: Adapter is NULL",__func__);
6335 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006336 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306337 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6338 ret = wlan_hdd_validate_context(pHddCtx);
6339 if (0 != ret)
6340 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306341 return ret;
6342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 switch(sub_cmd)
6344 {
6345 case WE_SET_WLAN_DBG:
6346 {
6347 vos_trace_setValue( value[1], value[2], value[3]);
6348 break;
6349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 case WE_SET_WDI_DBG:
6351 {
6352 wpalTraceSetLevel( value[1], value[2], value[3]);
6353 break;
6354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 case WE_SET_SAP_CHANNELS:
6356 {
6357 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6358 break;
6359 }
6360
6361 default:
6362 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006363 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 break;
6365 }
6366 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306367 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 return ret;
6369}
6370
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306371int iw_set_three_ints_getnone(struct net_device *dev,
6372 struct iw_request_info *info,
6373 union iwreq_data *wrqu, char *extra)
6374{
6375 int ret;
6376
6377 vos_ssr_protect(__func__);
6378 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6379 vos_ssr_unprotect(__func__);
6380
6381 return ret;
6382}
6383
6384static int __iw_get_char_setnone(struct net_device *dev,
6385 struct iw_request_info *info,
6386 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006387{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306388 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306390 hdd_context_t *pHddCtx;
6391 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006392#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006393 hdd_wext_state_t *pWextState;
6394#endif
6395
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306396 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306397 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006398 if (pAdapter == NULL)
6399 {
6400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6401 "%s: pAdapter is NULL!", __func__);
6402 return -EINVAL;
6403 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306404 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6405 ret = wlan_hdd_validate_context(pHddCtx);
6406 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006407 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306408 return ret;
6409 }
6410#ifdef WLAN_FEATURE_11W
6411 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6412 if (NULL == pWextState)
6413 {
6414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6415 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006416 return -EINVAL;
6417 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306418#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006419
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 switch(sub_cmd)
6421 {
6422 case WE_WLAN_VERSION:
6423 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006424 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 break;
6426 }
6427
6428 case WE_GET_STATS:
6429 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306430 tHalHandle hHal = NULL;
6431 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6433 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6434 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6435
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306436
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 snprintf(extra, WE_MAX_STR_LEN,
6438 "\nTransmit"
6439 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6440 "\n dropped BK %u, BE %u, VI %u, VO %u"
6441 "\n classified BK %u, BE %u, VI %u, VO %u"
6442 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6443 "\n queued BK %u, BE %u, VI %u, VO %u"
6444 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006445 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 "\n fetched BK %u, BE %u, VI %u, VO %u"
6447 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6448 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006449 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 "\n flushed BK %u, BE %u, VI %u, VO %u"
6451 "\n\nReceive"
6452 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6453 "\n\nResetsStats"
6454 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6455 "\n",
6456 pStats->txXmitCalled,
6457 pStats->txXmitDropped,
6458 pStats->txXmitBackPressured,
6459 pStats->txXmitQueued,
6460
6461 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6462 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6463 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6464 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6465
6466 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6467 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6468 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6469 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6470
6471 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6472 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6473 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6474 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6475
6476 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6477 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6478 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6479 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6480
6481 pStats->txFetched,
6482 pStats->txFetchEmpty,
6483 pStats->txFetchLowResources,
6484 pStats->txFetchDequeueError,
6485
6486 pStats->txFetchDequeued,
6487 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006488 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 pStats->txCompleted,
6490 pStats->txFlushed,
6491
6492 pStats->txFetchedAC[WLANTL_AC_BK],
6493 pStats->txFetchedAC[WLANTL_AC_BE],
6494 pStats->txFetchedAC[WLANTL_AC_VI],
6495 pStats->txFetchedAC[WLANTL_AC_VO],
6496
6497 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6498 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6499 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6500 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6501
6502 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6503 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6504 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6505 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6506
Ravi Joshi41914632013-10-21 23:02:21 -07006507 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6508 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6509 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6510 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6511
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 pStats->txFlushedAC[WLANTL_AC_BK],
6513 pStats->txFlushedAC[WLANTL_AC_BE],
6514 pStats->txFlushedAC[WLANTL_AC_VI],
6515 pStats->txFlushedAC[WLANTL_AC_VO],
6516
6517 pStats->rxChains,
6518 pStats->rxPackets,
6519 pStats->rxDropped,
6520 pStats->rxDelivered,
6521 pStats->rxRefused,
6522
6523 pResetStats->totalLogpResets,
6524 pResetStats->totalCMD53Failures,
6525 pResetStats->totalMutexReadFailures,
6526 pResetStats->totalMIFErrorFailures,
6527 pResetStats->totalFWHearbeatFailures,
6528 pResetStats->totalUnknownExceptions
6529 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306530 wrqu->data.length = strlen(extra);
6531
6532 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6533
6534 if (hHal)
6535 pMac = PMAC_STRUCT( hHal );
6536
6537 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6538 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6539 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306540 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6541 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6542 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6543 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306544 "\n",
6545 pMac->pmm.BmpscntSleep,
6546 pMac->pmm.BmpscntAwake,
6547 pMac->pmm.BmpsSleeReqFailCnt,
6548 pMac->pmm.BmpsWakeupReqFailCnt,
6549 pMac->pmm.ImpsCntSleep,
6550 pMac->pmm.ImpsCntAwake,
6551 pMac->pmm.ImpsSleepErrCnt,
6552 pMac->pmm.ImpsWakeupErrCnt,
6553 pMac->pmm.ImpsLastErr
6554 );
6555 }
6556
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 wrqu->data.length = strlen(extra)+1;
6558 break;
6559 }
6560
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306561/* The case prints the current state of the HDD, SME, CSR, PE, TL
6562 *it can be extended for WDI Global State as well.
6563 *And currently it only checks P2P_CLIENT adapter.
6564 *P2P_DEVICE and P2P_GO have not been added as of now.
6565*/
6566 case WE_GET_STATES:
6567 {
6568 int buf = 0, len = 0;
6569 int adapter_num = 0;
6570 int count = 0, check = 1;
6571
6572 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006573 tHalHandle hHal = NULL;
6574 tpAniSirGlobal pMac = NULL;
6575 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306576
6577 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6578 hdd_adapter_t *useAdapter = NULL;
6579
6580 /* Print wlan0 or p2p0 states based on the adapter_num
6581 *by using the correct adapter
6582 */
6583 while ( adapter_num < 2 )
6584 {
6585 if ( WLAN_ADAPTER == adapter_num )
6586 {
6587 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006588 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306589 "\n\n wlan0 States:-");
6590 len += buf;
6591 }
6592 else if ( P2P_ADAPTER == adapter_num )
6593 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006594 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306595 "\n\n p2p0 States:-");
6596 len += buf;
6597
6598 if( !pHddCtx )
6599 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006600 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306601 "\n pHddCtx is NULL");
6602 len += buf;
6603 break;
6604 }
6605
6606 /*Printing p2p0 states only in the case when the device is
6607 configured as a p2p_client*/
6608 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6609 if ( !useAdapter )
6610 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006611 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306612 "\n Device not configured as P2P_CLIENT.");
6613 len += buf;
6614 break;
6615 }
6616 }
6617
6618 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006619 if (!hHal) {
6620 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6621 "\n pMac is NULL");
6622 len += buf;
6623 break;
6624 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306625 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006626 if (!pMac) {
6627 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6628 "\n pMac is NULL");
6629 len += buf;
6630 break;
6631 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306632 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6633 if( !pHddStaCtx )
6634 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006635 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306636 "\n pHddStaCtx is NULL");
6637 len += buf;
6638 break;
6639 }
6640
6641 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6642
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006643 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306644 "\n HDD Conn State - %s "
6645 "\n \n SME State:"
6646 "\n Neighbour Roam State - %s"
6647 "\n CSR State - %s"
6648 "\n CSR Substate - %s"
6649 "\n \n TL STA %d State: %s",
6650 macTraceGetHDDWlanConnState(
6651 pHddStaCtx->conn_info.connState),
6652 macTraceGetNeighbourRoamState(
6653 pMac->roam.neighborRoamInfo.neighborRoamState),
6654 macTraceGetcsrRoamState(
6655 pMac->roam.curState[useAdapter->sessionId]),
6656 macTraceGetcsrRoamSubState(
6657 pMac->roam.curSubState[useAdapter->sessionId]),
6658 pHddStaCtx->conn_info.staId[0],
6659 macTraceGetTLState(tlState)
6660 );
6661 len += buf;
6662 adapter_num++;
6663 }
6664
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006665 if (pMac) {
6666 /* Printing Lim State starting with global lim states */
6667 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6668 "\n \n LIM STATES:-"
6669 "\n Global Sme State - %s "\
6670 "\n Global mlm State - %s "\
6671 "\n",
6672 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6673 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6674 );
6675 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306676
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006677 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05306678 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306679 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006680 if ( pMac->lim.gpSession[count].valid )
6681 {
6682 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6683 "\n Lim Valid Session %d:-"
6684 "\n PE Sme State - %s "
6685 "\n PE Mlm State - %s "
6686 "\n",
6687 check,
6688 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6689 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6690 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306691
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006692 len += buf;
6693 check++;
6694 }
6695 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306696 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306697 }
6698
6699 wrqu->data.length = strlen(extra)+1;
6700 break;
6701 }
6702
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 case WE_GET_CFG:
6704 {
6705 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6706 wrqu->data.length = strlen(extra)+1;
6707 break;
6708 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006709#ifdef WLAN_FEATURE_11AC
6710 case WE_GET_RSSI:
6711 {
6712 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05306713 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07006714 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6715 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6716 wrqu->data.length = strlen(extra)+1;
6717 break;
6718 }
6719#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306720
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006721#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006722 case WE_GET_ROAM_RSSI:
6723 {
6724 v_S7_t s7Rssi = 0;
6725 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6726 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6727 wrqu->data.length = strlen(extra)+1;
6728 break;
6729 }
6730#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006731 case WE_GET_WMM_STATUS:
6732 {
6733 snprintf(extra, WE_MAX_STR_LEN,
6734 "\nDir: 0=up, 1=down, 3=both\n"
6735 "|------------------------|\n"
6736 "|AC | ACM |Admitted| Dir |\n"
6737 "|------------------------|\n"
6738 "|VO | %d | %3s | %d |\n"
6739 "|VI | %d | %3s | %d |\n"
6740 "|BE | %d | %3s | %d |\n"
6741 "|BK | %d | %3s | %d |\n"
6742 "|------------------------|\n",
6743 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6744 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6745 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6746 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6747 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6748 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6749 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6750 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6751 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6752 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6753 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6754 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6755
Jeff Johnsone7245742012-09-05 17:12:55 -07006756
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 wrqu->data.length = strlen(extra)+1;
6758 break;
6759 }
6760 case WE_GET_CHANNEL_LIST:
6761 {
6762 VOS_STATUS status;
6763 v_U8_t i, len;
6764 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306765 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6766 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6767 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 tChannelListInfo channel_list;
6769
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006770 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006772 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006774 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 return -EINVAL;
6776 }
6777 buf = extra;
6778
6779 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006780 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6781 * needed = 5 * number of channels. Check ifsufficient
6782 * buffer is available and then proceed to fill the buffer.
6783 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6785 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006786 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006787 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006788 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006789 return -EINVAL;
6790 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006791 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6792 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306793 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6794 {
6795 //Printing Country code in getChannelList
6796 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6797 {
6798 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6799 "%c ", pBuf[i]);
6800 }
6801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 for(i = 0 ; i < channel_list.num_channels; i++)
6803 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006804 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006805 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 }
6807 wrqu->data.length = strlen(extra)+1;
6808
6809 break;
6810 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006811#ifdef FEATURE_WLAN_TDLS
6812 case WE_GET_TDLS_PEERS:
6813 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006814 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006815 break;
6816 }
6817#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006818#ifdef WLAN_FEATURE_11W
6819 case WE_GET_11W_INFO:
6820 {
6821 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6822
6823 snprintf(extra, WE_MAX_STR_LEN,
6824 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6825 "\n Number of Unprotected Disassocs %d"
6826 "\n Number of Unprotected Deauths %d",
6827 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6828 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6829 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6830 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6831 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6832
6833 wrqu->data.length = strlen(extra)+1;
6834 break;
6835 }
6836#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306837 case WE_GET_SNR:
6838 {
6839 v_S7_t s7snr = 0;
6840 int status = 0;
6841 hdd_context_t *pHddCtx;
6842 hdd_station_ctx_t *pHddStaCtx;
6843
6844 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6845 status = wlan_hdd_validate_context(pHddCtx);
6846 if (0 != status)
6847 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306848 return status;
6849 }
6850
6851 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6852
6853 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6854 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6855 {
6856 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6857 " ConnectionState-%d", __func__,
6858 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6859 pHddStaCtx->conn_info.connState);
6860 return -ENONET;
6861 }
6862
6863 /*update the stats in TL*/
6864 wlan_hdd_get_station_stats(pAdapter);
6865 wlan_hdd_get_snr(pAdapter, &s7snr);
6866 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6867 wrqu->data.length = strlen(extra) + 1;
6868 break;
6869 }
6870
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306871 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006873 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006874 break;
6875 }
6876 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306877 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 return 0;
6879}
6880
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306881static int iw_get_char_setnone(struct net_device *dev,
6882 struct iw_request_info *info,
6883 union iwreq_data *wrqu, char *extra)
6884{
6885 int ret;
6886
6887 vos_ssr_protect(__func__);
6888 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6889 vos_ssr_unprotect(__func__);
6890
6891 return ret;
6892}
6893
Jeff Johnson295189b2012-06-20 16:38:30 -07006894/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306895static int __iw_setnone_getnone(struct net_device *dev,
6896 struct iw_request_info *info,
6897 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006898{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306899 hdd_adapter_t *pAdapter;
6900 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306901 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006902 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306903 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006904
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306905 ENTER();
6906
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306907 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6908 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006909 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6911 "%s: Adapter is NULL",__func__);
6912 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006913 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306914 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6915 ret = wlan_hdd_validate_context(pHddCtx);
6916 if (0 != ret)
6917 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306918 return ret;
6919 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306920 /* helper function to get iwreq_data with compat handling. */
6921 if (hdd_priv_get_data(&s_priv_data, wrqu))
6922 {
6923 return -EINVAL;
6924 }
6925
6926 sub_cmd = s_priv_data.flags;
6927
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 switch (sub_cmd)
6929 {
6930 case WE_CLEAR_STATS:
6931 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6934 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6935 break;
6936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 case WE_INIT_AP:
6938 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306939 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6940
6941 /* As Soft AP mode might been changed to STA already with
6942 * killing of Hostapd, need to find the adpater by name
6943 * rather than mode */
6944 hdd_adapter_t* pAdapter_to_stop =
6945 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6946 if( pAdapter_to_stop )
6947 {
6948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6949 "Adapter with name softap.0 already "
6950 "exist, ignoring the request.\nRemove the "
6951 "adapter and try again\n");
6952 break;
6953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 pr_info("Init AP trigger\n");
6955 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6956 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6957 break;
6958 }
6959 case WE_STOP_AP:
6960 {
6961 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6962 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6963 * this is a dead code and need to find the adpater by name rather than mode */
6964 hdd_adapter_t* pAdapter_to_stop =
6965 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6966 if( pAdapter_to_stop )
6967 {
6968 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6969
6970 pr_info("Stopping AP mode\n");
6971
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306972 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6973 {
6974 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6975 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6976 }
6977
Jeff Johnson295189b2012-06-20 16:38:30 -07006978 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306979 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306980 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6982
6983 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6984 pAdapter_to_stop->macAddressCurrent.bytes);
6985 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6986 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306987
6988 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6989 {
6990 /* put the device back into BMPS */
6991 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 }
6994 else
6995 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006996 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 }
6998
6999 break;
7000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007001#ifdef WLAN_BTAMP_FEATURE
7002 case WE_ENABLE_AMP:
7003 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 WLANBAP_RegisterWithHCI(pAdapter);
7006 break;
7007 }
7008 case WE_DISABLE_AMP:
7009 {
7010 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7011 VOS_STATUS status;
7012
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007014
7015 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7016 status = WLANBAP_StopAmp();
7017 if(VOS_STATUS_SUCCESS != status )
7018 {
7019 pHddCtx->isAmpAllowed = VOS_TRUE;
7020 hddLog(VOS_TRACE_LEVEL_FATAL,
7021 "%s: Failed to stop AMP", __func__);
7022 }
7023 else
7024 {
7025 //a state m/c implementation in PAL is TBD to avoid this delay
7026 msleep(500);
7027 pHddCtx->isAmpAllowed = VOS_FALSE;
7028 WLANBAP_DeregisterFromHCI();
7029 }
7030
7031 break;
7032 }
7033#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007034 case WE_ENABLE_DXE_STALL_DETECT:
7035 {
schang6295e542013-03-12 15:31:23 -07007036 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7037 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007038 break;
7039 }
7040 case WE_DISPLAY_DXE_SNAP_SHOT:
7041 {
schang6295e542013-03-12 15:31:23 -07007042 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7043 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007044 break;
7045 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307046 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7047 {
7048 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7049 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307050 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307051 break;
7052 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307053
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307054 case WE_SET_REASSOC_TRIGGER:
7055 {
7056 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7057 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7058 v_U32_t roamId = 0;
7059 tCsrRoamModifyProfileFields modProfileFields;
7060 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7061 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
7062 return 0;
7063 }
7064
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307065 case WE_STOP_OBSS_SCAN:
7066 {
7067 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7068 2.OBSS scan is stopped by Firmware during the disassociation
7069 3.OBSS stop comamnd is added for debugging purpose*/
7070 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7071 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007072
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307073 if (pAdapter == NULL)
7074 {
7075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7076 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307077 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307078 }
7079 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7080 if (pMac == NULL)
7081 {
7082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7083 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307084 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307085 }
7086 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7087 }
7088 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307089 case WE_DUMP_ROAM_TIMER_LOG:
7090 {
7091 vos_dump_roam_time_log_service();
7092 break;
7093 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307094
Mukul Sharma84f27252014-07-14 18:11:42 +05307095 case WE_RESET_ROAM_TIMER_LOG:
7096 {
7097 vos_reset_roam_timer_log();
7098 break;
7099 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307100 case WE_GET_FW_LOGS:
7101 {
7102 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7103 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307104 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307105 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307106 break;
7107 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307108 case WE_GET_FW_MEMDUMP:
7109 {
7110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7111 "FW_MEM_DUMP requested ");
7112 get_fwr_memdump(dev,info,wrqu,extra);
7113 break;
7114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 default:
7116 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007117 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007118 break;
7119 }
7120 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307121 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007122 return ret;
7123}
7124
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307125static int iw_setnone_getnone(struct net_device *dev,
7126 struct iw_request_info *info,
7127 union iwreq_data *wrqu, char *extra)
7128{
7129 int ret;
7130
7131 vos_ssr_protect(__func__);
7132 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7133 vos_ssr_unprotect(__func__);
7134
7135 return ret;
7136}
7137
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307138void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7139{
7140 /*
7141 * Function to display HDD WMM information
7142 * for Tx Queues.
7143 * Prints globala as well as per client depending
7144 * whether the clients are registered or not.
7145 */
7146 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307147 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7148 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307149 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7150 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307151 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307152
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307153 for ( i=0; i< NUM_TX_QUEUES; i++)
7154 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307155 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307156 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307157 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307158 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307159
7160 for ( i=0; i< NUM_TX_QUEUES; i++) {
7161 if (tx_queue_count[i]) {
7162 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7163 i, tx_queue_count[i]);
7164 }
7165 }
7166
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307167 if(pSapCtx == NULL){
7168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7169 FL("psapCtx is NULL"));
7170 return;
7171 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307172
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307173 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307174 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7175 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307176 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307177 {
7178 hddLog(LOGE, "******STAIndex: %d*********", i);
7179 for ( j=0; j< NUM_TX_QUEUES; j++)
7180 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307181 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7182 {
7183 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307184 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7185 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307186 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7187 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307188 }
7189 }
7190 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307191 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307192
Katya Nigam1fd24402015-02-16 14:52:19 +05307193 if(pHddStaCtx == NULL){
7194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7195 FL("pHddStaCtx is NULL"));
7196 return;
7197 }
7198
7199 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7200 if(pPeerInfo == NULL){
7201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7202 FL("ppeerinfo is NULL"));
7203 return;
7204 }
7205
7206 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7207 {
7208 if(pPeerInfo->ibssStaInfo[i].isUsed)
7209 {
7210 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7211 for ( j=0; j< NUM_TX_QUEUES; j++)
7212 {
7213 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7214 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7215 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7216 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7217 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7218 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7219 }
7220 }
7221 }
7222
7223
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307224}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307225static int __iw_set_var_ints_getnone(struct net_device *dev,
7226 struct iw_request_info *info,
7227 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007228{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307229 hdd_adapter_t *pAdapter;
7230 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307231 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307232 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007233 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307234 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307235 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007236 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307237 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007238 int cmd = 0;
7239 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307240 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007241
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307242 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307243 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307244 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7246 "%s: NULL extra buffer pointer", __func__);
7247 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307248 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307249 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7250 if (NULL == pAdapter)
7251 {
7252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7253 "%s: Adapter is NULL",__func__);
7254 return -EINVAL;
7255 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307256 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307257 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7258 ret = wlan_hdd_validate_context(pHddCtx);
7259 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007260 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307261 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007262 }
Katya Nigameae74b62015-05-28 17:19:16 +05307263 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307264 {
Katya Nigameae74b62015-05-28 17:19:16 +05307265 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7266 if (NULL == hHal)
7267 {
7268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7269 "%s: Hal Context is NULL",__func__);
7270 return -EINVAL;
7271 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307272 }
7273 sub_cmd = wrqu->data.flags;
7274
7275 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7276
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007277
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007278 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7279 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7280 {
7281 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7282 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7283 {
7284 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7285 staId = pStaCtx->conn_info.staId[0];
7286 }
7287 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7288 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7289 {
7290 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7291 staId = pAPCtx->uBCStaId;
7292 }
7293 else
7294 {
7295 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7296 return 0;
7297 }
7298 }
7299
Jeff Johnson295189b2012-06-20 16:38:30 -07007300 switch (sub_cmd)
7301 {
7302 case WE_LOG_DUMP_CMD:
7303 {
7304 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007305 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007306 apps_args[3], apps_args[4]);
7307
7308 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7309 apps_args[3], apps_args[4]);
7310
7311 }
7312 break;
7313
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 case WE_P2P_NOA_CMD:
7315 {
7316 p2p_app_setP2pPs_t p2pNoA;
7317
7318 p2pNoA.opp_ps = apps_args[0];
7319 p2pNoA.ctWindow = apps_args[1];
7320 p2pNoA.duration = apps_args[2];
7321 p2pNoA.interval = apps_args[3];
7322 p2pNoA.count = apps_args[4];
7323 p2pNoA.single_noa_duration = apps_args[5];
7324 p2pNoA.psSelection = apps_args[6];
7325
7326 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7327 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007328 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007329 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7330
7331 hdd_setP2pPs(dev, &p2pNoA);
7332
7333 }
7334 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007335
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307336 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7337 {
7338 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7339 __func__, apps_args[0], apps_args[1]);
7340 vosTraceEnable(apps_args[0], apps_args[1]);
7341 }
7342 break;
7343
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007344 case WE_MTRACE_DUMP_CMD:
7345 {
7346 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7347 "bitmask_of_module %d ",
7348 __func__, apps_args[0], apps_args[1], apps_args[2],
7349 apps_args[3]);
7350 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7351 apps_args[2], apps_args[3]);
7352
7353 }
7354 break;
7355
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007356 case WE_MCC_CONFIG_CREDENTIAL :
7357 {
7358 cmd = 287; //Command should be updated if there is any change
7359 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007360 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007361 {
7362 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7363 }
7364 else
7365 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007366 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007367 return 0;
7368 }
7369 }
7370 break;
7371
7372 case WE_MCC_CONFIG_PARAMS :
7373 {
7374 cmd = 288; //command Should be updated if there is any change
7375 // in the Riva dump command
7376 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7377 }
7378 break;
7379
Chilam NG571c65a2013-01-19 12:27:36 +05307380#ifdef FEATURE_WLAN_TDLS
7381 case WE_TDLS_CONFIG_PARAMS :
7382 {
7383 tdls_config_params_t tdlsParams;
7384
Chilam Ng01120412013-02-19 18:32:21 -08007385 tdlsParams.tdls = apps_args[0];
7386 tdlsParams.tx_period_t = apps_args[1];
7387 tdlsParams.tx_packet_n = apps_args[2];
7388 tdlsParams.discovery_period_t = apps_args[3];
7389 tdlsParams.discovery_tries_n = apps_args[4];
7390 tdlsParams.idle_timeout_t = apps_args[5];
7391 tdlsParams.idle_packet_n = apps_args[6];
7392 tdlsParams.rssi_hysteresis = apps_args[7];
7393 tdlsParams.rssi_trigger_threshold = apps_args[8];
7394 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307395
Chilam Ng01120412013-02-19 18:32:21 -08007396 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307397 }
7398 break;
7399#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307400 case WE_CONFIGURE_MONITOR_MODE:
7401 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307402 v_U32_t magic = 0;
7403 struct completion cmpVar;
7404 long waitRet = 0;
7405
Katya Nigamf0511f62015-05-05 16:40:57 +05307406 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7407 if( pMonCtx == NULL )
7408 {
7409 hddLog(LOGE, "Monitor Context NULL");
7410 break;
7411 }
7412 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7413 __func__, apps_args[0], apps_args[1], apps_args[2],
7414 apps_args[3], apps_args[4]);
7415 /* Input Validation part of FW */
7416 pMonCtx->ChannelNo = apps_args[0];
7417 pMonCtx->ChannelBW = apps_args[1];
7418 pMonCtx->crcCheckEnabled = apps_args[2];
7419 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7420 pMonCtx->is80211to803ConReq = apps_args[4];
7421 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7422 if( pMonCtx->is80211to803ConReq )
7423 pAdapter->dev->type = ARPHRD_ETHER;
7424 else
7425 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7426 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7427 {
7428 hddLog(LOGE, "%s: Filtering data packets as management and control"
7429 " cannot be converted to 802.3 ",__func__);
7430 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7431 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307432 if (MON_MODE_START == pMonCtx->state) {
7433 magic = MON_MODE_MSG_MAGIC;
7434 init_completion(&cmpVar);
7435 if (VOS_STATUS_SUCCESS !=
7436 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7437 pMonCtx, hdd_monPostMsgCb)) {
7438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7439 FL("failed to post MON MODE REQ"));
7440 magic = 0;
7441 ret = -EIO;
7442 break;
7443 }
7444 waitRet = wait_for_completion_timeout(&cmpVar,
7445 MON_MODE_MSG_TIMEOUT);
7446 magic = 0;
7447 if (waitRet <= 0 ) {
7448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7449 FL("failed to wait on monitor mode completion %ld"),
7450 waitRet);
7451 }
7452 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307453 }
7454 break;
7455
7456 case WE_SET_MONITOR_MODE_FILTER:
7457 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307458 v_U32_t magic = 0;
7459 struct completion cmpVar;
7460 long waitRet = 0;
7461
Katya Nigamf0511f62015-05-05 16:40:57 +05307462 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7463 if( pMonCtx == NULL )
7464 {
7465 hddLog(LOGE, "Monitor Context NULL");
7466 break;
7467 }
7468 /* Input Validation Part of FW */
7469 pMonCtx->numOfMacFilters=1;
7470 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7471 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7472 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7473 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7474 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7475 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7476 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7477 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7478 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7479 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7480 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7481 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307482 if (MON_MODE_START == pMonCtx->state) {
7483 magic = MON_MODE_MSG_MAGIC;
7484 init_completion(&cmpVar);
7485 if (VOS_STATUS_SUCCESS !=
7486 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7487 pMonCtx, hdd_monPostMsgCb)) {
7488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7489 FL("failed to post MON MODE REQ"));
7490 magic = 0;
7491 ret = -EIO;
7492 break;
7493 }
7494 waitRet = wait_for_completion_timeout(&cmpVar,
7495 MON_MODE_MSG_TIMEOUT);
7496 magic = 0;
7497 if (waitRet <= 0 ) {
7498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7499 FL("failed to wait on monitor mode completion %ld"),
7500 waitRet);
7501 }
7502 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307503 }
7504 break;
7505
Jeff Johnson295189b2012-06-20 16:38:30 -07007506 default:
7507 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007508 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7509 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 }
7511 break;
7512 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307513 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007514 return 0;
7515}
7516
Girish Gowlifb9758e2014-11-19 15:19:17 +05307517static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7518 struct iw_request_info *info,
7519 union iwreq_data *wrqu, char *extra)
7520{
7521 int ret;
7522 union iwreq_data u_priv_wrqu;
7523 int apps_args[MAX_VAR_ARGS] = {0};
7524 int num_args;
7525
7526 /* helper function to get iwreq_data with compat handling. */
7527 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7528 {
7529 return -EINVAL;
7530 }
7531
7532 if (NULL == u_priv_wrqu.data.pointer)
7533 {
7534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7535 "%s: NULL data pointer", __func__);
7536 return -EINVAL;
7537 }
7538
7539 num_args = u_priv_wrqu.data.length;
7540 if (num_args > MAX_VAR_ARGS)
7541 {
7542 num_args = MAX_VAR_ARGS;
7543 }
7544
7545 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7546 (sizeof(int)) * num_args))
7547 {
7548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7549 "%s: failed to copy data from user buffer", __func__);
7550 return -EFAULT;
7551 }
7552
7553 vos_ssr_protect(__func__);
7554 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7555 (char *)&apps_args);
7556 vos_ssr_unprotect(__func__);
7557
7558 return ret;
7559}
7560
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307561int iw_set_var_ints_getnone(struct net_device *dev,
7562 struct iw_request_info *info,
7563 union iwreq_data *wrqu, char *extra)
7564{
7565 int ret;
7566 vos_ssr_protect(__func__);
7567 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7568 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007569
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307570 return ret;
7571}
7572
7573static int __iw_add_tspec(struct net_device *dev,
7574 struct iw_request_info *info,
7575 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007576{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307577 hdd_adapter_t *pAdapter;
7578 hdd_station_ctx_t *pHddStaCtx;
7579 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7581 int params[HDD_WLAN_WMM_PARAM_COUNT];
7582 sme_QosWmmTspecInfo tSpec;
7583 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307584 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307585 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007586
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307587 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307588 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7589 if (NULL == pAdapter)
7590 {
7591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7592 "%s: Adapter is NULL",__func__);
7593 return -EINVAL;
7594 }
7595 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7596 ret = wlan_hdd_validate_context(pHddCtx);
7597 if (0 != ret)
7598 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307599 return ret;
7600 }
7601 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7602 if (NULL == pHddStaCtx)
7603 {
7604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7605 "%s: STA Context is NULL",__func__);
7606 return -EINVAL;
7607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007608 // make sure the application is sufficiently priviledged
7609 // note that the kernel will do this for "set" ioctls, but since
7610 // this ioctl wants to return status to user space it must be
7611 // defined as a "get" ioctl
7612 if (!capable(CAP_NET_ADMIN))
7613 {
7614 return -EPERM;
7615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 // we must be associated in order to add a tspec
7617 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7618 {
7619 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7620 return 0;
7621 }
7622
7623 // since we are defined to be a "get" ioctl, and since the number
7624 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307625 // will pass down in the iwreq_data, we must copy the "set" params.
7626 // We must handle the compat for iwreq_data in 32U/64K environment.
7627
7628 // helper fucntion to get iwreq_data with compat handling.
7629 if (hdd_priv_get_data(&s_priv_data, wrqu))
7630 {
7631 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7632 return 0;
7633 }
7634
7635 // make sure all params are correctly passed to function
7636 if ((NULL == s_priv_data.pointer) ||
7637 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7638 {
7639 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7640 return 0;
7641 }
7642
Jeff Johnson295189b2012-06-20 16:38:30 -07007643 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307644 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 {
7646 // hmmm, can't get them
7647 return -EIO;
7648 }
7649
7650 // clear the tspec
7651 memset(&tSpec, 0, sizeof(tSpec));
7652
7653 // validate the handle
7654 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7655 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7656 {
7657 // that one is reserved
7658 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7659 return 0;
7660 }
7661
7662 // validate the TID
7663 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7664 {
7665 // out of range
7666 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7667 return 0;
7668 }
7669 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7670
7671 // validate the direction
7672 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7673 {
7674 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7675 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7676 break;
7677
7678 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7679 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7680 break;
7681
7682 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7683 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7684 break;
7685
7686 default:
7687 // unknown
7688 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7689 return 0;
7690 }
7691
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307692 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7693
Jeff Johnson295189b2012-06-20 16:38:30 -07007694 // validate the user priority
7695 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7696 {
7697 // out of range
7698 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7699 return 0;
7700 }
7701 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307702 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7703 {
7704 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7705 return 0;
7706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007707
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7709 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7710 tSpec.ts_info.psb, tSpec.ts_info.up);
7711
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7713 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7714 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7715 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7716 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7717 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7718 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7719 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7720 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7721 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7722 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7723 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7724
7725 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7726
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307727 // Save the expected UAPSD settings by application, this will be needed
7728 // when re-negotiating UAPSD settings during BT Coex cases.
7729 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7730
Jeff Johnson295189b2012-06-20 16:38:30 -07007731 // validate the ts info ack policy
7732 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7733 {
7734 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7735 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7736 break;
7737
7738 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7739 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7740 break;
7741
7742 default:
7743 // unknown
7744 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7745 return 0;
7746 }
7747
7748 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307749
7750 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 return 0;
7752}
7753
7754
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307755static int iw_add_tspec(struct net_device *dev,
7756 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007757 union iwreq_data *wrqu, char *extra)
7758{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307759 int ret;
7760
7761 vos_ssr_protect(__func__);
7762 ret = __iw_add_tspec(dev, info, wrqu, extra);
7763 vos_ssr_unprotect(__func__);
7764
7765 return ret;
7766}
7767
7768static int __iw_del_tspec(struct net_device *dev,
7769 struct iw_request_info *info,
7770 union iwreq_data *wrqu, char *extra)
7771{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307772 hdd_adapter_t *pAdapter;
7773 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 int *params = (int *)extra;
7775 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7776 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307777 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007778
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307779 ENTER();
7780
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307781 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7782 if (NULL == pAdapter)
7783 {
7784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7785 "%s: Adapter is NULL",__func__);
7786 return -EINVAL;
7787 }
7788
7789 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7790 ret = wlan_hdd_validate_context(pHddCtx);
7791 if (0 != ret)
7792 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307793 return ret;
7794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007795 // make sure the application is sufficiently priviledged
7796 // note that the kernel will do this for "set" ioctls, but since
7797 // this ioctl wants to return status to user space it must be
7798 // defined as a "get" ioctl
7799 if (!capable(CAP_NET_ADMIN))
7800 {
7801 return -EPERM;
7802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007803 // although we are defined to be a "get" ioctl, the params we require
7804 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7805 // is no need to copy the params from user space
7806
7807 // validate the handle
7808 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7809 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7810 {
7811 // that one is reserved
7812 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7813 return 0;
7814 }
7815
7816 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307817
7818 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007819 return 0;
7820}
7821
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307822static int iw_del_tspec(struct net_device *dev,
7823 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007824 union iwreq_data *wrqu, char *extra)
7825{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307826 int ret;
7827
7828 vos_ssr_protect(__func__);
7829 ret = __iw_del_tspec(dev, info, wrqu, extra);
7830 vos_ssr_unprotect(__func__);
7831
7832 return ret;
7833}
7834
7835
7836static int __iw_get_tspec(struct net_device *dev,
7837 struct iw_request_info *info,
7838 union iwreq_data *wrqu, char *extra)
7839{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307840 hdd_adapter_t *pAdapter;
7841 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007842 int *params = (int *)extra;
7843 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7844 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307845 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007846
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307847 ENTER();
7848
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 // although we are defined to be a "get" ioctl, the params we require
7850 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7851 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307852 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7853 if (NULL == pAdapter)
7854 {
7855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7856 "%s: Adapter is NULL",__func__);
7857 return -EINVAL;
7858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007859
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307860 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7861 ret = wlan_hdd_validate_context(pHddCtx);
7862 if (0 != ret)
7863 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307864 return ret;
7865 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 // validate the handle
7867 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7868 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7869 {
7870 // that one is reserved
7871 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7872 return 0;
7873 }
7874
7875 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307876 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 return 0;
7878}
7879
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307880static int iw_get_tspec(struct net_device *dev,
7881 struct iw_request_info *info,
7882 union iwreq_data *wrqu, char *extra)
7883{
7884 int ret;
7885
7886 vos_ssr_protect(__func__);
7887 ret = __iw_get_tspec(dev, info, wrqu, extra);
7888 vos_ssr_unprotect(__func__);
7889
7890 return ret;
7891}
7892
Jeff Johnson295189b2012-06-20 16:38:30 -07007893#ifdef WLAN_FEATURE_VOWIFI_11R
7894//
7895//
7896// Each time the supplicant has the auth_request or reassoc request
7897// IEs ready. This is pushed to the driver. The driver will inturn use
7898// it to send out the auth req and reassoc req for 11r FT Assoc.
7899//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307900static int __iw_set_fties(struct net_device *dev,
7901 struct iw_request_info *info,
7902 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007903{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307904 hdd_adapter_t *pAdapter;
7905 hdd_station_ctx_t *pHddStaCtx;
7906 hdd_context_t *pHddCtx;
7907 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 //v_CONTEXT_t pVosContext;
7909
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307910 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307911 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7912 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007913 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7915 "%s: Adapter is NULL",__func__);
7916 return -EINVAL;
7917 }
7918 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7919 ret = wlan_hdd_validate_context(pHddCtx);
7920 if (0 != ret)
7921 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307922 return ret;
7923 }
7924 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7925 if (NULL == pHddStaCtx)
7926 {
7927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7928 "%s: STA Context is NULL",__func__);
7929 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 if (!wrqu->data.length)
7932 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007933 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007934 return -EINVAL;
7935 }
7936 if (wrqu->data.pointer == NULL)
7937 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007938 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007939 return -EINVAL;
7940 }
7941
7942 // Added for debug on reception of Re-assoc Req.
7943 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7944 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007945 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007946 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007947 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 }
7949
7950#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007951 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007952#endif
7953
7954 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007955 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 wrqu->data.length);
7957
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307958 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 return 0;
7960}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307961
7962static int iw_set_fties(struct net_device *dev,
7963 struct iw_request_info *info,
7964 union iwreq_data *wrqu, char *extra)
7965{
7966 int ret;
7967
7968 vos_ssr_protect(__func__);
7969 ret = __iw_set_fties(dev, info, wrqu, extra);
7970 vos_ssr_unprotect(__func__);
7971
7972 return ret;
7973}
Jeff Johnson295189b2012-06-20 16:38:30 -07007974#endif
7975
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307976static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007977 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007978 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007979{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307980 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007981 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307982 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007983 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307984 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007985 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7986 int idx;
7987 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007988
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307989 ENTER();
7990
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307991 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7992 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007993 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7995 "%s: Adapter is NULL",__func__);
7996 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007997 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307998 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7999 ret_val = wlan_hdd_validate_context(pHddCtx);
8000 if (0 != ret_val)
8001 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308002 return ret_val;
8003 }
8004 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8005 if (NULL == hHal)
8006 {
8007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8008 "%s: Hal Context is NULL",__func__);
8009 return -EINVAL;
8010 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308011 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8012 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308013#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008014
Amar Singhalf3a6e762013-02-19 15:06:50 -08008015 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8016 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008017 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008018 hddLog(VOS_TRACE_LEVEL_ERROR,
8019 "%s: vos_mem_alloc failed", __func__);
8020 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008021 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008022
8023 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8024
8025 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8026 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8027
8028 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8029 mc_addr_list_ptr->ulMulticastAddrCnt);
8030
8031 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008032 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008033 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8034 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8035
8036 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8037 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008038 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008039
Amar Singhalf3a6e762013-02-19 15:06:50 -08008040 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8041 vos_mem_free(mc_addr_list_ptr);
8042 if (eHAL_STATUS_SUCCESS != ret_val)
8043 {
8044 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8045 __func__);
8046 return -EINVAL;
8047 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308048#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308049 }
8050 else
8051 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008052
Amar Singhalf3a6e762013-02-19 15:06:50 -08008053 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8054 "%s: Set MC BC Filter Config request: %d suspend %d",
8055 __func__, pRequest->mcastBcastFilterSetting,
8056 pHddCtx->hdd_wlan_suspended);
8057
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308058 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008059
8060 if (pHddCtx->hdd_wlan_suspended)
8061 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008062 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8063 if (NULL == wlanRxpFilterParam)
8064 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308065 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008066 "%s: vos_mem_alloc failed", __func__);
8067 return -EINVAL;
8068 }
8069
Amar Singhalf3a6e762013-02-19 15:06:50 -08008070 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8071 pRequest->mcastBcastFilterSetting;
8072 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8073
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308074 hdd_conf_hostoffload(pAdapter, TRUE);
8075 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8076 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008077
8078 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8079 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308080 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008081 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8082 wlanRxpFilterParam->setMcstBcstFilter);
8083
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308084 if (eHAL_STATUS_SUCCESS !=
8085 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8086 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008087 {
8088 hddLog(VOS_TRACE_LEVEL_ERROR,
8089 "%s: Failure to execute set HW MC/BC Filter request",
8090 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008091 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008092 return -EINVAL;
8093 }
8094
c_hpothud3ce76d2014-10-28 10:34:13 +05308095 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8096 {
8097 pHddCtx->sus_res_mcastbcast_filter =
8098 pRequest->mcastBcastFilterSetting;
8099 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008100 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008102
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308103 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 return 0;
8105}
8106
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308107static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8108 struct iw_request_info *info,
8109 union iwreq_data *wrqu, char *extra)
8110{
8111 int ret;
8112
8113 vos_ssr_protect(__func__);
8114 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8115 vos_ssr_unprotect(__func__);
8116
8117 return ret;
8118}
8119
8120static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8121 struct iw_request_info *info,
8122 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008123{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308124 hdd_adapter_t *pAdapter;
8125 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308126 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308127 int ret = 0;
8128
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308129 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008130
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308131 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8132 if (NULL == pAdapter)
8133 {
8134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8135 "%s: Adapter is NULL",__func__);
8136 return -EINVAL;
8137 }
8138
8139 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8140 ret = wlan_hdd_validate_context(pHddCtx);
8141 if (0 != ret)
8142 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308143 return ret;
8144 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308145 //Reset the filter to INI value as we have to clear the dynamic filter
8146 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008147
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308148 //Configure FW with new setting
8149 if (pHddCtx->hdd_wlan_suspended)
8150 {
8151 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8152 if (NULL == wlanRxpFilterParam)
8153 {
8154 hddLog(VOS_TRACE_LEVEL_ERROR,
8155 "%s: vos_mem_alloc failed", __func__);
8156 return -EINVAL;
8157 }
8158
8159 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8160 pHddCtx->configuredMcastBcastFilter;
8161 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8162
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308163 hdd_conf_hostoffload(pAdapter, TRUE);
8164 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8165 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308166
8167 if (eHAL_STATUS_SUCCESS !=
8168 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8169 wlanRxpFilterParam))
8170 {
8171 hddLog(VOS_TRACE_LEVEL_ERROR,
8172 "%s: Failure to execute set HW MC/BC Filter request",
8173 __func__);
8174 vos_mem_free(wlanRxpFilterParam);
8175 return -EINVAL;
8176 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308177
8178 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8179 {
8180 pHddCtx->sus_res_mcastbcast_filter =
8181 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8182 }
8183
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308184 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308185 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 return 0;
8187}
8188
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308189
8190static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8191 struct iw_request_info *info,
8192 union iwreq_data *wrqu, char *extra)
8193{
8194 int ret;
8195
8196 vos_ssr_protect(__func__);
8197 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8198 vos_ssr_unprotect(__func__);
8199
8200 return ret;
8201}
8202
8203static int __iw_set_host_offload(struct net_device *dev,
8204 struct iw_request_info *info,
8205 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008206{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308207 hdd_adapter_t *pAdapter;
8208 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008209 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008210 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308211 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008212
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308213 ENTER();
8214
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308215 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8216 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008217 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8219 "%s: Adapter is NULL",__func__);
8220 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008221 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308222 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8223 ret = wlan_hdd_validate_context(pHddCtx);
8224 if (0 != ret)
8225 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308226 return ret;
8227 }
8228
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 /* Debug display of request components. */
8230 switch (pRequest->offloadType)
8231 {
8232 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008233 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 switch (pRequest->enableOrDisable)
8235 {
8236 case WLAN_OFFLOAD_DISABLE:
8237 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8238 break;
8239 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8240 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8241 case WLAN_OFFLOAD_ENABLE:
8242 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8243 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8244 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8245 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8246 }
8247 break;
8248
8249 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008250 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008251 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 switch (pRequest->enableOrDisable)
8253 {
8254 case WLAN_OFFLOAD_DISABLE:
8255 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8256 break;
8257 case WLAN_OFFLOAD_ENABLE:
8258 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8259 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8260 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8261 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8262 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8263 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8264 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8265 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8266 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8267 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8268 }
8269 }
8270
8271 /* Execute offload request. The reason that we can copy the request information
8272 from the ioctl structure to the SME structure is that they are laid out
8273 exactly the same. Otherwise, each piece of information would have to be
8274 copied individually. */
8275 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008276 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8277 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008279 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 __func__);
8281 return -EINVAL;
8282 }
8283
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308284 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008285 return 0;
8286}
8287
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308288static int iw_set_host_offload(struct net_device *dev,
8289 struct iw_request_info *info,
8290 union iwreq_data *wrqu, char *extra)
8291{
8292 int ret;
8293
8294 vos_ssr_protect(__func__);
8295 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8296 vos_ssr_unprotect(__func__);
8297
8298 return ret;
8299}
8300
8301static int __iw_set_keepalive_params(struct net_device *dev,
8302 struct iw_request_info *info,
8303 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008304{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308305 hdd_adapter_t *pAdapter;
8306 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008307 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308309 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008310
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308311 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308312 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8313 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8316 "%s: Adapter is NULL",__func__);
8317 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008318 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308319 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8320 ret = wlan_hdd_validate_context(pHddCtx);
8321 if (0 != ret)
8322 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308323 return ret;
8324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008326 hddLog(VOS_TRACE_LEVEL_INFO,
8327 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8328 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008329
8330 switch (pRequest->packetType)
8331 {
8332 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008333 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 break;
8335
8336 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8337
Arif Hussain6d2a3322013-11-17 19:50:10 -08008338 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008339 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008340
8341 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8342 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8343 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8344
8345 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8346 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8347 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8348
8349 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8350 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8351 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8352 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8353 break;
8354
8355 }
8356
8357 /* Execute keep alive request. The reason that we can copy the request information
8358 from the ioctl structure to the SME structure is that they are laid out
8359 exactly the same. Otherwise, each piece of information would have to be
8360 copied individually. */
8361 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8362
Arif Hussain6d2a3322013-11-17 19:50:10 -08008363 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008364
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008365 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008366 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008368 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 __func__);
8370 return -EINVAL;
8371 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308372 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 return 0;
8374}
8375
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308376static int iw_set_keepalive_params(struct net_device *dev,
8377 struct iw_request_info *info,
8378 union iwreq_data *wrqu, char *extra)
8379{
8380 int ret;
8381 vos_ssr_protect(__func__);
8382 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8383 vos_ssr_unprotect(__func__);
8384
8385 return ret;
8386}
8387
Jeff Johnson295189b2012-06-20 16:38:30 -07008388#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008389int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008390 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008391{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008392 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8393 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008394 int i=0;
8395
8396 if (pHddCtx->cfg_ini->disablePacketFilter)
8397 {
8398 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008399 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 return 0;
8401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008402 /* Debug display of request components. */
8403 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008404 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008405
8406 switch (pRequest->filterAction)
8407 {
8408 case HDD_RCV_FILTER_SET:
8409 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008410 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008411
8412 packetFilterSetReq.filterId = pRequest->filterId;
8413 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8414 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008415 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 __func__, pRequest->numParams);
8417 return -EINVAL;
8418 }
8419 packetFilterSetReq.numFieldParams = pRequest->numParams;
8420 packetFilterSetReq.coalesceTime = 0;
8421 packetFilterSetReq.filterType = 1;
8422 for (i=0; i < pRequest->numParams; i++)
8423 {
8424 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8425 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8426 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8427 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8428 packetFilterSetReq.paramsData[i].reserved = 0;
8429
Arif Hussain6d2a3322013-11-17 19:50:10 -08008430 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008431 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8432 packetFilterSetReq.filterType);
8433
Arif Hussain6d2a3322013-11-17 19:50:10 -08008434 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008435 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8436
8437 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8438 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8439 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8440 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8441
Arif Hussain6d2a3322013-11-17 19:50:10 -08008442 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8444 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8445 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8446
Arif Hussain6d2a3322013-11-17 19:50:10 -08008447 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8449 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8450 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8451 }
8452
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008453 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008455 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008456 __func__);
8457 return -EINVAL;
8458 }
8459
8460 break;
8461
8462 case HDD_RCV_FILTER_CLEAR:
8463
Arif Hussain6d2a3322013-11-17 19:50:10 -08008464 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008465 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008467 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008468 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008469 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 __func__);
8471 return -EINVAL;
8472 }
8473 break;
8474
8475 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008476 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008477 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 return -EINVAL;
8479 }
8480 return 0;
8481}
8482
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308483int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8484 tANI_U8 sessionId)
8485{
8486 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8487 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8488
8489 if (NULL == pHddCtx)
8490 {
8491 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8492 return -EINVAL;
8493 }
8494
8495 if (pHddCtx->isLogpInProgress)
8496 {
8497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8498 "%s:LOGP in Progress. Ignore!!!", __func__);
8499 return -EBUSY;
8500 }
8501
8502 if (pHddCtx->cfg_ini->disablePacketFilter)
8503 {
8504 hddLog(VOS_TRACE_LEVEL_ERROR,
8505 "%s: Packet Filtering Disabled. Returning ",
8506 __func__ );
8507 return -EINVAL;
8508 }
8509
8510 switch (filterType)
8511 {
8512 /* For setting IPV6 MC and UC Filter we need to configure
8513 * 2 filters, one for MC and one for UC.
8514 * The Filter ID shouldn't be swapped, which results in making
8515 * UC Filter ineffective.
8516 * We have Hardcode all the values
8517 *
8518 * Reason for a seperate UC filter is because, driver need to
8519 * specify the FW that the specific filter is for unicast
8520 * otherwise FW will not pass the unicast frames by default
8521 * through the filter. This is required to avoid any performance
8522 * hits when no unicast filter is set and only MC/BC are set.
8523 * The way driver informs host is by using the MAC protocol
8524 * layer, CMP flag set to MAX, CMP Data set to 1.
8525 */
8526
8527 case HDD_FILTER_IPV6_MC_UC:
8528 /* Setting IPV6 MC Filter below
8529 */
8530 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8531 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8532 packetFilterSetReq.numFieldParams = 2;
8533 packetFilterSetReq.paramsData[0].protocolLayer =
8534 HDD_FILTER_PROTO_TYPE_MAC;
8535 packetFilterSetReq.paramsData[0].cmpFlag =
8536 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8537 packetFilterSetReq.paramsData[0].dataOffset =
8538 WLAN_HDD_80211_FRM_DA_OFFSET;
8539 packetFilterSetReq.paramsData[0].dataLength = 1;
8540 packetFilterSetReq.paramsData[0].compareData[0] =
8541 HDD_IPV6_MC_CMP_DATA;
8542
8543 packetFilterSetReq.paramsData[1].protocolLayer =
8544 HDD_FILTER_PROTO_TYPE_ARP;
8545 packetFilterSetReq.paramsData[1].cmpFlag =
8546 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8547 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8548 packetFilterSetReq.paramsData[1].dataLength = 2;
8549 packetFilterSetReq.paramsData[1].compareData[0] =
8550 HDD_IPV6_CMP_DATA_0;
8551 packetFilterSetReq.paramsData[1].compareData[1] =
8552 HDD_IPV6_CMP_DATA_1;
8553
8554
8555 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8556 &packetFilterSetReq, sessionId))
8557 {
8558 hddLog(VOS_TRACE_LEVEL_ERROR,
8559 "%s: Failure to execute Set IPv6 Mulicast Filter",
8560 __func__);
8561 return -EINVAL;
8562 }
8563
8564 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8565
8566 /*
8567 * Setting IPV6 UC Filter below
8568 */
8569 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8570 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8571 packetFilterSetReq.numFieldParams = 2;
8572 packetFilterSetReq.paramsData[0].protocolLayer =
8573 HDD_FILTER_PROTO_TYPE_MAC;
8574 packetFilterSetReq.paramsData[0].cmpFlag =
8575 HDD_FILTER_CMP_TYPE_MAX;
8576 packetFilterSetReq.paramsData[0].dataOffset = 0;
8577 packetFilterSetReq.paramsData[0].dataLength = 1;
8578 packetFilterSetReq.paramsData[0].compareData[0] =
8579 HDD_IPV6_UC_CMP_DATA;
8580
8581 packetFilterSetReq.paramsData[1].protocolLayer =
8582 HDD_FILTER_PROTO_TYPE_ARP;
8583 packetFilterSetReq.paramsData[1].cmpFlag =
8584 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8585 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8586 packetFilterSetReq.paramsData[1].dataLength = 2;
8587 packetFilterSetReq.paramsData[1].compareData[0] =
8588 HDD_IPV6_CMP_DATA_0;
8589 packetFilterSetReq.paramsData[1].compareData[1] =
8590 HDD_IPV6_CMP_DATA_1;
8591
8592 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8593 &packetFilterSetReq, sessionId))
8594 {
8595 hddLog(VOS_TRACE_LEVEL_ERROR,
8596 "%s: Failure to execute Set IPv6 Unicast Filter",
8597 __func__);
8598 return -EINVAL;
8599 }
8600
8601 break;
8602
8603 case HDD_FILTER_IPV6_MC:
8604 /*
8605 * IPV6 UC Filter might be already set,
8606 * clear the UC Filter. As the Filter
8607 * IDs are static, we can directly clear it.
8608 */
8609 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8610 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8611 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8612 &packetFilterClrReq, sessionId))
8613 {
8614 hddLog(VOS_TRACE_LEVEL_ERROR,
8615 "%s: Failure to execute Clear IPv6 Unicast Filter",
8616 __func__);
8617 return -EINVAL;
8618 }
8619
8620 /*
8621 * Setting IPV6 MC Filter below
8622 */
8623 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8624 packetFilterSetReq.numFieldParams = 2;
8625 packetFilterSetReq.paramsData[0].protocolLayer =
8626 HDD_FILTER_PROTO_TYPE_MAC;
8627 packetFilterSetReq.paramsData[0].cmpFlag =
8628 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8629 packetFilterSetReq.paramsData[0].dataOffset =
8630 WLAN_HDD_80211_FRM_DA_OFFSET;
8631 packetFilterSetReq.paramsData[0].dataLength = 1;
8632 packetFilterSetReq.paramsData[0].compareData[0] =
8633 HDD_IPV6_MC_CMP_DATA;
8634
8635 packetFilterSetReq.paramsData[1].protocolLayer =
8636 HDD_FILTER_PROTO_TYPE_ARP;
8637 packetFilterSetReq.paramsData[1].cmpFlag =
8638 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8639 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8640 packetFilterSetReq.paramsData[1].dataLength = 2;
8641 packetFilterSetReq.paramsData[1].compareData[0] =
8642 HDD_IPV6_CMP_DATA_0;
8643 packetFilterSetReq.paramsData[1].compareData[1] =
8644 HDD_IPV6_CMP_DATA_1;
8645
8646
8647 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8648 &packetFilterSetReq, sessionId))
8649 {
8650 hddLog(VOS_TRACE_LEVEL_ERROR,
8651 "%s: Failure to execute Set IPv6 Multicast Filter",
8652 __func__);
8653 return -EINVAL;
8654 }
8655 break;
8656
8657 default :
8658 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8659 "%s: Packet Filter Request: Invalid",
8660 __func__);
8661 return -EINVAL;
8662 }
8663 return 0;
8664}
8665
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308666void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008667{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308668 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308669 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008670 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308671 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008672
Yue Ma3ede6052013-08-29 00:33:26 -07008673 if (NULL == pHddCtx)
8674 {
8675 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8676 return;
8677 }
8678
8679 hHal = pHddCtx->hHal;
8680
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308681 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308683 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8684 return;
8685 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308686
8687 /* Check if INI is enabled or not, other wise just return
8688 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308689 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308690 {
8691 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8692 if (NULL == pMulticastAddrs)
8693 {
8694 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8695 return;
8696 }
8697
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 if (set)
8699 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308700 /* Following pre-conditions should be satisfied before wei
8701 * configure the MC address list.
8702 */
8703 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8704 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8705 && pAdapter->mc_addr_list.mc_cnt
8706 && (eConnectionState_Associated ==
8707 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8708 {
8709 pMulticastAddrs->ulMulticastAddrCnt =
8710 pAdapter->mc_addr_list.mc_cnt;
8711 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8712 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008713 memcpy(pMulticastAddrs->multicastAddr[i],
8714 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308715 sizeof(pAdapter->mc_addr_list.addr[i]));
8716 hddLog(VOS_TRACE_LEVEL_INFO,
8717 "%s: %s multicast filter: addr ="
8718 MAC_ADDRESS_STR,
8719 __func__, set ? "setting" : "clearing",
8720 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8721 }
8722 /* Set multicast filter */
8723 sme_8023MulticastList(hHal, pAdapter->sessionId,
8724 pMulticastAddrs);
8725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308727 else
8728 {
8729 /* Need to clear only if it was previously configured
8730 */
8731 if (pAdapter->mc_addr_list.isFilterApplied)
8732 {
8733 pMulticastAddrs->ulMulticastAddrCnt = 0;
8734 sme_8023MulticastList(hHal, pAdapter->sessionId,
8735 pMulticastAddrs);
8736 }
8737
8738 }
8739 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008740 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308742 else
8743 {
8744 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308745 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308746 }
8747 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008748}
8749
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308750static int __iw_set_packet_filter_params(struct net_device *dev,
8751 struct iw_request_info *info,
8752 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308753{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308754 hdd_adapter_t *pAdapter;
8755 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008756 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308757 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308758 struct iw_point s_priv_data;
8759
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308760 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308761 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8762 if (NULL == pAdapter)
8763 {
8764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8765 "%s: Adapter is NULL",__func__);
8766 return -EINVAL;
8767 }
8768 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8769 ret = wlan_hdd_validate_context(pHddCtx);
8770 if (0 != ret)
8771 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308772 return ret;
8773 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308774 if (hdd_priv_get_data(&s_priv_data, wrqu))
8775 {
8776 return -EINVAL;
8777 }
8778
8779 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8780 {
8781 return -EINVAL;
8782 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008783
Arif Hussain0273cba2014-01-07 20:58:29 -08008784 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308785 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8786 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008787 if (NULL == pRequest)
8788 {
8789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8790 "mem_alloc_copy_from_user_helper fail");
8791 return -ENOMEM;
8792 }
8793
8794 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8795 kfree(pRequest);
8796
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308797 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008798 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008799}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308800
8801static int iw_set_packet_filter_params(struct net_device *dev,
8802 struct iw_request_info *info,
8803 union iwreq_data *wrqu, char *extra)
8804{
8805 int ret;
8806
8807 vos_ssr_protect(__func__);
8808 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8809 vos_ssr_unprotect(__func__);
8810
8811 return ret;
8812}
Jeff Johnson295189b2012-06-20 16:38:30 -07008813#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308814static int __iw_get_statistics(struct net_device *dev,
8815 struct iw_request_info *info,
8816 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008817{
8818
8819 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8820 eHalStatus status = eHAL_STATUS_SUCCESS;
8821 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308822 hdd_adapter_t *pAdapter;
8823 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308825 int tlen = 0, ret = 0;
8826 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008827
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308828 tCsrGlobalClassAStatsInfo *aStats;
8829 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008830
8831 ENTER();
8832
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308833 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8834 if (NULL == pAdapter)
8835 {
8836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8837 "%s: Adapter is NULL",__func__);
8838 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008839 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308840 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8841 ret = wlan_hdd_validate_context(pHddCtx);
8842 if (0 != ret)
8843 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308844 return ret;
8845 }
8846 pStats = &(pAdapter->hdd_stats.summary_stat);
8847 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8848 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8850
8851 wrqu->txpower.value = 0;
8852 }
8853 else {
8854 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8855 SME_SUMMARY_STATS |
8856 SME_GLOBAL_CLASSA_STATS |
8857 SME_GLOBAL_CLASSB_STATS |
8858 SME_GLOBAL_CLASSC_STATS |
8859 SME_GLOBAL_CLASSD_STATS |
8860 SME_PER_STA_STATS,
8861 hdd_StatisticsCB, 0, FALSE,
8862 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8863
8864 if (eHAL_STATUS_SUCCESS != status)
8865 {
8866 hddLog(VOS_TRACE_LEVEL_ERROR,
8867 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008868 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 return -EINVAL;
8870 }
8871
8872 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308873 if (NULL == pWextState)
8874 {
8875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8876 "%s: pWextState is NULL",__func__);
8877 return -EINVAL;
8878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008879
8880 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8881 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8882 {
8883 hddLog(VOS_TRACE_LEVEL_ERROR,
8884 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008885 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008886 /*Remove the SME statistics list by passing NULL in callback argument*/
8887 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8888 SME_SUMMARY_STATS |
8889 SME_GLOBAL_CLASSA_STATS |
8890 SME_GLOBAL_CLASSB_STATS |
8891 SME_GLOBAL_CLASSC_STATS |
8892 SME_GLOBAL_CLASSD_STATS |
8893 SME_PER_STA_STATS,
8894 NULL, 0, FALSE,
8895 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8896
8897 return -EINVAL;
8898 }
8899 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8900 (tANI_U8) sizeof (pStats->retry_cnt),
8901 (char*) &(pStats->retry_cnt[0]),
8902 tlen);
8903
8904 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8905 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8906 (char*) &(pStats->multiple_retry_cnt[0]),
8907 tlen);
8908
8909 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8910 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8911 (char*) &(pStats->tx_frm_cnt[0]),
8912 tlen);
8913
8914 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8915 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8916 (char*) &(pStats->rx_frm_cnt),
8917 tlen);
8918
8919 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8920 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8921 (char*) &(pStats->frm_dup_cnt),
8922 tlen);
8923
8924 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8925 (tANI_U8) sizeof (pStats->fail_cnt),
8926 (char*) &(pStats->fail_cnt[0]),
8927 tlen);
8928
8929 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8930 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8931 (char*) &(pStats->rts_fail_cnt),
8932 tlen);
8933
8934 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8935 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8936 (char*) &(pStats->ack_fail_cnt),
8937 tlen);
8938
8939 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8940 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8941 (char*) &(pStats->rts_succ_cnt),
8942 tlen);
8943
8944 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8945 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8946 (char*) &(pStats->rx_discard_cnt),
8947 tlen);
8948
8949 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8950 (tANI_U8) sizeof (pStats->rx_error_cnt),
8951 (char*) &(pStats->rx_error_cnt),
8952 tlen);
8953
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008954 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008955 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008956 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008957 tlen);
8958
8959 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8960 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8961 (char*) &(dStats->rx_byte_cnt),
8962 tlen);
8963
8964 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8965 (tANI_U8) sizeof (dStats->rx_rate),
8966 (char*) &(dStats->rx_rate),
8967 tlen);
8968
8969 /* Transmit rate, in units of 500 kbit/sec */
8970 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8971 (tANI_U8) sizeof (aStats->tx_rate),
8972 (char*) &(aStats->tx_rate),
8973 tlen);
8974
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008975 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8976 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8977 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008978 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008979 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8980 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8981 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008982 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008983 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8984 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8985 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008986 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008987 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8988 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8989 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008990 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008991 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8992 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8993 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008994 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008995 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8996 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8997 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008998 tlen);
8999
Jeff Johnson295189b2012-06-20 16:38:30 -07009000 wrqu->data.length = tlen;
9001
9002 }
9003
9004 EXIT();
9005
9006 return 0;
9007}
9008
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309009static int iw_get_statistics(struct net_device *dev,
9010 struct iw_request_info *info,
9011 union iwreq_data *wrqu, char *extra)
9012{
9013 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009014
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309015 vos_ssr_protect(__func__);
9016 ret = __iw_get_statistics(dev, info, wrqu, extra);
9017 vos_ssr_unprotect(__func__);
9018
9019 return ret;
9020}
Jeff Johnson295189b2012-06-20 16:38:30 -07009021#ifdef FEATURE_WLAN_SCAN_PNO
9022
9023/*Max Len for PNO notification*/
9024#define MAX_PNO_NOTIFY_LEN 100
9025void found_pref_network_cb (void *callbackContext,
9026 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9027{
9028 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9029 union iwreq_data wrqu;
9030 char buf[MAX_PNO_NOTIFY_LEN+1];
9031
9032 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9033 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9034
9035 // create the event
9036 memset(&wrqu, 0, sizeof(wrqu));
9037 memset(buf, 0, sizeof(buf));
9038
9039 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9040 pPrefNetworkFoundInd->ssId.ssId,
9041 (unsigned int)pPrefNetworkFoundInd->rssi);
9042
9043 wrqu.data.pointer = buf;
9044 wrqu.data.length = strlen(buf);
9045
9046 // send the event
9047
9048 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9049
9050}
9051
9052
9053/*string based input*/
9054VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9055 union iwreq_data *wrqu, char *extra, int nOffset)
9056{
9057 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309058 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009059 /* pnoRequest is a large struct, so we make it static to avoid stack
9060 overflow. This API is only invoked via ioctl, so it is
9061 serialized by the kernel rtnl_lock and hence does not need to be
9062 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309063 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009064 char *ptr;
9065 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309066 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009067 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9068
9069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9070 "PNO data len %d data %s",
9071 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009072 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009073
9074 if (wrqu->data.length <= nOffset )
9075 {
9076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9077 return VOS_STATUS_E_FAILURE;
9078 }
9079
9080 pnoRequest.enable = 0;
9081 pnoRequest.ucNetworksCount = 0;
9082 /*-----------------------------------------------------------------------
9083 Input is string based and expected to be like this:
9084
9085 <enabled> <netw_count>
9086 for each network:
9087 <ssid_len> <ssid> <authentication> <encryption>
9088 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9089 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9090
9091 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009092 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 -07009093
9094 this translates into:
9095 -----------------------------
9096 enable PNO
9097 look for 2 networks:
9098 test - with authentication type 0 and encryption type 0,
9099 that can be found on 3 channels: 1 6 and 11 ,
9100 SSID bcast type is unknown (directed probe will be sent if AP not found)
9101 and must meet -40dBm RSSI
9102
9103 test2 - with auth and enrytption type 4/4
9104 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9105 bcast type is non-bcast (directed probe will be sent)
9106 and must not meet any RSSI threshold
9107
Jeff Johnson8301aa12013-03-28 14:27:29 -07009108 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009109 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009110 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009111
Wilson Yang623f6592013-10-08 16:33:37 -07009112 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9113 {
9114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9115 "PNO enable input is not valid %s",ptr);
9116 return VOS_STATUS_E_FAILURE;
9117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009118
9119 if ( 0 == pnoRequest.enable )
9120 {
9121 /*Disable PNO*/
9122 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309123 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9124 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009125 pAdapter->sessionId,
9126 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309127 if (eHAL_STATUS_SUCCESS != status)
9128 {
9129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9130 "%s: failed to disable PNO", __func__);
9131 return VOS_STATUS_E_FAILURE;
9132 }
9133 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009134 return VOS_STATUS_SUCCESS;
9135 }
9136
c_hpothu37f21312014-04-09 21:49:54 +05309137 if (TRUE == pHddCtx->isPnoEnable)
9138 {
9139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9140 FL("already PNO is enabled"));
9141 return -EBUSY;
9142 }
9143 pHddCtx->isPnoEnable = TRUE;
9144
Jeff Johnson295189b2012-06-20 16:38:30 -07009145 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009146
9147 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9148 {
9149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9150 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309151 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009153
9154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9155 "PNO enable %d networks count %d offset %d",
9156 pnoRequest.enable,
9157 pnoRequest.ucNetworksCount,
9158 nOffset);
9159
9160 /* Parameters checking:
9161 ucNetworksCount has to be larger than 0*/
9162 if (( 0 == pnoRequest.ucNetworksCount ) ||
9163 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9164 {
9165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309166 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 }
9168
9169 ptr += nOffset;
9170
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309171 pnoRequest.aNetworks =
9172 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9173 if (pnoRequest.aNetworks == NULL)
9174 {
9175 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9176 FL("failed to allocate memory aNetworks %u"),
9177 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9178 goto error;
9179 }
9180 vos_mem_zero(pnoRequest.aNetworks,
9181 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9182
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9184 {
9185
9186 pnoRequest.aNetworks[i].ssId.length = 0;
9187
Wilson Yang623f6592013-10-08 16:33:37 -07009188 ucParams = sscanf(ptr,"%hhu %n",
9189 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9190
9191 if (1 != ucParams)
9192 {
9193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9194 "PNO ssid length 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.aNetworks[i].ssId.length ) ||
9199 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9200 {
9201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9202 "SSID Len %d is not correct for network %d",
9203 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309204 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009205 }
9206
9207 /*Advance to SSID*/
9208 ptr += nOffset;
9209
Jeff Johnson8301aa12013-03-28 14:27:29 -07009210 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009211 pnoRequest.aNetworks[i].ssId.length);
9212 ptr += pnoRequest.aNetworks[i].ssId.length;
9213
Jeff Johnson02797792013-10-26 19:17:13 -07009214 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009215 &(pnoRequest.aNetworks[i].authentication),
9216 &(pnoRequest.aNetworks[i].encryption),
9217 &(pnoRequest.aNetworks[i].ucChannelCount),
9218 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009219
Wilson Yang623f6592013-10-08 16:33:37 -07009220 if ( 3 != ucParams )
9221 {
9222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9223 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309224 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009225 }
9226
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009228 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009229 "auth %d encry %d channel count %d offset %d",
9230 pnoRequest.aNetworks[i].ssId.length,
9231 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9232 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9233 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9234 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9235 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9236 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9237 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9238 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9239 pnoRequest.aNetworks[i].authentication,
9240 pnoRequest.aNetworks[i].encryption,
9241 pnoRequest.aNetworks[i].ucChannelCount,
9242 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009243
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 /*Advance to channel list*/
9245 ptr += nOffset;
9246
Wilson Yang623f6592013-10-08 16:33:37 -07009247 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009248 {
9249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9250 "Incorrect number of channels");
9251 return VOS_STATUS_E_FAILURE;
9252 }
9253
9254 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9255 {
9256 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9257 {
Wilson Yang623f6592013-10-08 16:33:37 -07009258 if (1 != sscanf(ptr,"%hhu %n",
9259 &(pnoRequest.aNetworks[i].aChannels[j]),
9260 &nOffset))
9261 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9262 "PNO network channel input is not valid %s",ptr);
9263 return VOS_STATUS_E_FAILURE;
9264 }
9265 /*Advance to next channel number*/
9266 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009267 }
9268 }
9269
Jeff Johnson02797792013-10-26 19:17:13 -07009270 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009271 &(pnoRequest.aNetworks[i].bcastNetwType),
9272 &nOffset))
9273 {
9274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9275 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309276 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009278
9279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9280 "PNO bcastNetwType %d offset %d",
9281 pnoRequest.aNetworks[i].bcastNetwType,
9282 nOffset );
9283
9284 /*Advance to rssi Threshold*/
9285 ptr += nOffset;
9286
Wilson Yang623f6592013-10-08 16:33:37 -07009287 if (1 != sscanf(ptr,"%hhu %n",
9288 &(pnoRequest.aNetworks[i].rssiThreshold),
9289 &nOffset))
9290 {
9291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9292 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309293 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009294 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009295
9296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9297 "PNO rssi %d offset %d",
9298 pnoRequest.aNetworks[i].rssiThreshold,
9299 nOffset );
9300 /*Advance to next network*/
9301 ptr += nOffset;
9302 }/*For ucNetworkCount*/
9303
9304 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009305 &(pnoRequest.scanTimers.ucScanTimersCount),
9306 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009307
9308 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009309 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009310 {
9311 ptr += nOffset;
9312
Jeff Johnson8301aa12013-03-28 14:27:29 -07009313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9314 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009315 pnoRequest.scanTimers.ucScanTimersCount,
9316 nOffset );
9317
9318 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9319 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009321 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309322 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009323 }
9324
9325 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9326 {
Jeff Johnson02797792013-10-26 19:17:13 -07009327 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9329 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9330 &nOffset);
9331
Wilson Yang623f6592013-10-08 16:33:37 -07009332 if (2 != ucParams)
9333 {
9334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9335 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309336 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009337 }
9338
Jeff Johnson8301aa12013-03-28 14:27:29 -07009339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9340 "PNO Timer value %d Timer repeat %d offset %d",
9341 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9343 nOffset );
9344
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 ptr += nOffset;
9346 }
9347
9348 }
9349 else
9350 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9352 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009353 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9354
9355 /*Scan timers defaults to 5 minutes*/
9356 pnoRequest.scanTimers.ucScanTimersCount = 1;
9357 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9358 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9359 }
9360
Wilson Yang623f6592013-10-08 16:33:37 -07009361 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009362
9363 pnoRequest.modePNO = ucMode;
9364 /*for LA we just expose suspend option*/
9365 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9366 {
9367 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9368 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309369 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9370 if (pnoRequest.p24GProbeTemplate == NULL){
9371 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9372 FL("failed to allocate memory p24GProbeTemplate %u"),
9373 SIR_PNO_MAX_PB_REQ_SIZE);
9374 goto error;
9375 }
9376
9377 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9378 if (pnoRequest.p5GProbeTemplate == NULL){
9379 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9380 FL("failed to allocate memory p5GProbeTemplate %u"),
9381 SIR_PNO_MAX_PB_REQ_SIZE);
9382 goto error;
9383 }
9384
9385 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9386 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009387
c_hpothu37f21312014-04-09 21:49:54 +05309388 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 pAdapter->sessionId,
9390 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309391 if (eHAL_STATUS_SUCCESS == status)
9392 {
9393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9394 "%s: PNO enabled", __func__);
9395 return VOS_STATUS_SUCCESS;
9396 }
9397error:
9398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9399 "%s: Failed to enable PNO", __func__);
9400 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309401 if (pnoRequest.aNetworks)
9402 vos_mem_free(pnoRequest.aNetworks);
9403 if (pnoRequest.p24GProbeTemplate)
9404 vos_mem_free(pnoRequest.p24GProbeTemplate);
9405 if (pnoRequest.p5GProbeTemplate)
9406 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309407 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009408}/*iw_set_pno*/
9409
9410VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9411 union iwreq_data *wrqu, char *extra, int nOffset)
9412{
9413 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9414 v_U8_t rssiThreshold = 0;
9415 v_U8_t nRead;
9416
Arif Hussain7adce1b2013-11-11 22:59:34 -08009417 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 &rssiThreshold);
9419
9420 if ( 1 != nRead )
9421 {
9422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9423 "Incorrect format");
9424 return VOS_STATUS_E_FAILURE;
9425 }
9426
9427 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9428 return VOS_STATUS_SUCCESS;
9429}
9430
9431
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309432static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 struct iw_request_info *info,
9434 union iwreq_data *wrqu, char *extra)
9435{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309436 hdd_adapter_t *pAdapter;
9437 hdd_context_t *pHddCtx;
9438 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309439 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309440
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309441 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309442 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9443 if (NULL == pAdapter)
9444 {
9445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9446 "%s: Adapter is NULL",__func__);
9447 return -EINVAL;
9448 }
9449
9450 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9451 ret = wlan_hdd_validate_context(pHddCtx);
9452 if (0 != ret)
9453 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309454 return ret;
9455 }
9456
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009457
9458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009460
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309461 status = iw_set_pno(dev,info,wrqu,extra,0);
9462
9463 EXIT();
9464 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009465}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309466
9467static int iw_set_pno_priv(struct net_device *dev,
9468 struct iw_request_info *info,
9469 union iwreq_data *wrqu, char *extra)
9470{
9471 int ret;
9472
9473 vos_ssr_protect(__func__);
9474 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9475 vos_ssr_unprotect(__func__);
9476
9477 return ret;
9478}
Jeff Johnson295189b2012-06-20 16:38:30 -07009479#endif /*FEATURE_WLAN_SCAN_PNO*/
9480
9481//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309482int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009483{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309484 hdd_adapter_t *pAdapter;
9485 tHalHandle hHal;
9486 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309487 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309488 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309489 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309491 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309492 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309493 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309494
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309495 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309496 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9497 if (NULL == pAdapter)
9498 {
9499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9500 "%s: Adapter is NULL",__func__);
9501 return -EINVAL;
9502 }
9503 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9504 retval = wlan_hdd_validate_context(pHddCtx);
9505 if (0 != retval)
9506 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309507 return retval;
9508 }
9509 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9510 if (NULL == hHal)
9511 {
9512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9513 "%s: Hal Context is NULL",__func__);
9514 return -EINVAL;
9515 }
9516 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009517
Atul Mittal54378cb2014-04-02 16:51:50 +05309518 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009519 {
9520 case WLAN_HDD_UI_BAND_AUTO:
9521 band = eCSR_BAND_ALL;
9522 break;
9523 case WLAN_HDD_UI_BAND_5_GHZ:
9524 band = eCSR_BAND_5G;
9525 break;
9526 case WLAN_HDD_UI_BAND_2_4_GHZ:
9527 band = eCSR_BAND_24;
9528 break;
9529 default:
9530 band = eCSR_BAND_MAX;
9531 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309532 connectedBand =
9533 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009534
Atul Mittal54378cb2014-04-02 16:51:50 +05309535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009536 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009537
9538 if (band == eCSR_BAND_MAX)
9539 {
9540 /* Received change band request with invalid band value */
9541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309542 "%s: Invalid band value %u", __func__, ui_band);
9543 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 }
9545
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309546 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309547 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309548 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009550 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009551 band, pHddCtx->cfg_ini->nBandCapability);
9552 return -EIO;
9553 }
9554
Sushant Kaushik1165f872015-03-30 20:25:27 +05309555 if (band == eCSR_BAND_ALL)
9556 {
9557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9558 "received. Setting band same as ini value %d"),
9559 pHddCtx->cfg_ini->nBandCapability);
9560 band = pHddCtx->cfg_ini->nBandCapability;
9561 }
9562
Jeff Johnson295189b2012-06-20 16:38:30 -07009563 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9564 {
9565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9566 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009567 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 return -EIO;
9569 }
9570
9571 if (currBand != band)
9572 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309573 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309574 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309575 /* Return failure if current country code is world regulatory domain*/
9576 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9577 pMac->scan.countryCodeCurrent[1] == '0') )
9578 {
9579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9580 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309581 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309582 return -EAGAIN;
9583 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309584 }
9585
Jeff Johnson295189b2012-06-20 16:38:30 -07009586 /* Change band request received.
9587 * Abort pending scan requests, flush the existing scan results,
9588 * and change the band capability
9589 */
9590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9591 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009592 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009593
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309594 /* We need to change the band and flush the scan results here itself
9595 * as we may get timeout for disconnection in which we will return
9596 * with out doing any of these
9597 */
9598 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9599 {
9600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9601 "%s: failed to set the band value to %u ",
9602 __func__, band);
9603 return -EINVAL;
9604 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309605 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9606 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309607 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309608 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9609 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309610 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309611 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9612 * information available in NV so to get the channel information from kernel
9613 * we need to send regulatory hint for the currunt country
9614 * And to set the same country again we need to set the dummy country
9615 * first and then the actual country.
9616 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309617#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9618 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9619#else
9620 regulatory_hint_user("00");
9621#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309622 wait_result = wait_for_completion_interruptible_timeout(
9623 &pHddCtx->linux_reg_req,
9624 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9625
9626 /* if the country information does not exist with the kernel,
9627 then the driver callback would not be called */
9628
9629 if (wait_result >= 0)
9630 {
9631 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9632 "runtime country code is found in kernel db");
9633 }
9634 else
9635 {
9636 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9637 "runtime country code is not found"
9638 " in kernel db");
9639 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309640
9641 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309642
9643 /*
9644 * Update 11dcountry and current country here as the hint
9645 * with 00 results in 11d and current country with 00
9646 */
9647 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9648 WNI_CFG_COUNTRY_CODE_LEN);
9649 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9650 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309651#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9652 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9653#else
9654 regulatory_hint_user(curr_country);
9655#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309656 wait_result = wait_for_completion_interruptible_timeout(
9657 &pHddCtx->linux_reg_req,
9658 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9659
9660 /* if the country information does not exist with the kernel,
9661 then the driver callback would not be called */
9662 if (wait_result >= 0)
9663 {
9664 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9665 "runtime country code is found in kernel db");
9666 }
9667 else
9668 {
9669 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9670 "runtime country code is not found"
9671 " in kernel db");
9672 }
9673
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309674 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309675 }
9676 else
9677 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309678#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309679 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9680 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309681#else
9682 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9683#endif
9684
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309685 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309686 pScanInfo = &pHddCtx->scan_info;
9687 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9688 {
9689 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9690 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9691 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309692 sme_FilterScanResults(hHal, pAdapter->sessionId);
9693
9694 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309695 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9696 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009697 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009698 eHalStatus status = eHAL_STATUS_SUCCESS;
9699 long lrc;
9700
9701 /* STA already connected on current band, So issue disconnect first,
9702 * then change the band*/
9703
9704 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309705 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309706 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009707
Jeff Johnson295189b2012-06-20 16:38:30 -07009708 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9709
9710 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9711 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9712
Jeff Johnson43971f52012-07-17 12:26:56 -07009713 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009714 {
9715 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009716 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009717 __func__, (int)status );
9718 return -EINVAL;
9719 }
9720
9721 lrc = wait_for_completion_interruptible_timeout(
9722 &pAdapter->disconnect_comp_var,
9723 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9724
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309725 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009726
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009727 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009728 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009729
9730 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9731 }
9732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309734 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309735 if (TRUE == pHddCtx->isSetBandByNL)
9736 return 0;
9737 else
9738 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07009739}
9740
Atul Mittal54378cb2014-04-02 16:51:50 +05309741int hdd_setBand_helper(struct net_device *dev, const char *command)
9742{
9743 u8 band;
9744
9745 /*convert the band value from ascii to integer*/
9746 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9747
9748 return hdd_setBand(dev, band);
9749
9750}
9751
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309752static int __iw_set_band_config(struct net_device *dev,
9753 struct iw_request_info *info,
9754 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009755{
Atul Mittal54378cb2014-04-02 16:51:50 +05309756 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009757
Arif Hussain0273cba2014-01-07 20:58:29 -08009758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009759
Atul Mittal54378cb2014-04-02 16:51:50 +05309760 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009761}
9762
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309763static int iw_set_band_config(struct net_device *dev,
9764 struct iw_request_info *info,
9765 union iwreq_data *wrqu, char *extra)
9766{
9767 int ret;
9768
9769 vos_ssr_protect(__func__);
9770 ret = __iw_set_band_config(dev, info, wrqu, extra);
9771 vos_ssr_unprotect(__func__);
9772
9773 return ret;
9774}
9775
c_manjeecfd1efb2015-09-25 19:32:34 +05309776static int get_fwr_memdump(struct net_device *dev,
9777 struct iw_request_info *info,
9778 union iwreq_data *wrqu, char *extra)
9779{
9780 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9781 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9782 int ret;
9783 ENTER();
9784 // HddCtx sanity
9785 ret = wlan_hdd_validate_context(pHddCtx);
9786 if (0 != ret)
9787 {
9788 return ret;
9789 }
9790 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
9791 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
9792 {
9793 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
9794 return -EINVAL;
9795 }
9796 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
9797
9798 EXIT();
9799 return ret;
9800}
9801
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309802static int __iw_set_power_params_priv(struct net_device *dev,
9803 struct iw_request_info *info,
9804 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009805{
Arif Hussain0273cba2014-01-07 20:58:29 -08009806 int ret;
9807 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9809 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009810 /* ODD number is used for set, copy data using copy_from_user */
9811 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9812 wrqu->data.length);
9813 if (NULL == ptr)
9814 {
9815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9816 "mem_alloc_copy_from_user_helper fail");
9817 return -ENOMEM;
9818 }
9819
9820 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9821 kfree(ptr);
9822 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009823}
9824
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309825static int iw_set_power_params_priv(struct net_device *dev,
9826 struct iw_request_info *info,
9827 union iwreq_data *wrqu, char *extra)
9828{
9829 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009830
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309831 vos_ssr_protect(__func__);
9832 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9833 vos_ssr_unprotect(__func__);
9834
9835 return ret;
9836}
Jeff Johnson295189b2012-06-20 16:38:30 -07009837
9838/*string based input*/
9839VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9840 union iwreq_data *wrqu, char *extra, int nOffset)
9841{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309842 hdd_adapter_t *pAdapter;
9843 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009844 tSirSetPowerParamsReq powerRequest;
9845 char *ptr;
9846 v_U8_t ucType;
9847 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309848 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009849
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309850 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309851 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9852 if (NULL == pAdapter)
9853 {
9854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9855 "%s: Adapter is NULL",__func__);
9856 return -EINVAL;
9857 }
9858
9859 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9860 ret = wlan_hdd_validate_context(pHddCtx);
9861 if (0 != ret)
9862 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309863 return ret;
9864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9866 "Power Params data len %d data %s",
9867 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009868 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009869
9870 if (wrqu->data.length <= nOffset )
9871 {
9872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9873 return VOS_STATUS_E_FAILURE;
9874 }
9875
9876 uTotalSize = wrqu->data.length - nOffset;
9877
9878 /*-----------------------------------------------------------------------
9879 Input is string based and expected to be like this:
9880
9881 <param_type> <param_value> <param_type> <param_value> ...
9882
9883 e.g:
9884 1 2 2 3 3 0 4 1 5 1
9885
9886 e.g. setting just a few:
9887 1 2 4 1
9888
9889 parameter types:
9890 -----------------------------
9891 1 - Ignore DTIM
9892 2 - Listen Interval
9893 3 - Broadcast Multicas Filter
9894 4 - Beacon Early Termination
9895 5 - Beacon Early Termination Interval
9896 -----------------------------------------------------------------------*/
9897 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9898 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9899 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9900 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9901 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9902
Arif Hussain7adce1b2013-11-11 22:59:34 -08009903 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009904
9905 while ( uTotalSize )
9906 {
Wilson Yang6f971452013-10-08 15:00:00 -07009907 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9908 {
9909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9910 "Invalid input parameter type %s",ptr);
9911 return VOS_STATUS_E_FAILURE;
9912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009913
9914 uTotalSize -= nOffset;
9915
9916 if (!uTotalSize)
9917 {
9918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009919 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009920 ucType, nOffset);
9921 return VOS_STATUS_E_FAILURE;
9922 }
9923
9924 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009925
Jeff Johnson02797792013-10-26 19:17:13 -07009926 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009927 {
9928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9929 "Invalid input parameter value %s",ptr);
9930 return VOS_STATUS_E_FAILURE;
9931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009932
9933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9934 "Power request parameter %d value %d offset %d",
9935 ucType, uValue, nOffset);
9936
9937 switch (ucType)
9938 {
9939 case eSIR_IGNORE_DTIM:
9940 powerRequest.uIgnoreDTIM = uValue;
9941 break;
9942 case eSIR_LISTEN_INTERVAL:
9943 powerRequest.uListenInterval = uValue;
9944 break;
9945 case eSIR_MCAST_BCAST_FILTER:
9946 powerRequest.uBcastMcastFilter = uValue;
9947 break;
9948 case eSIR_ENABLE_BET:
9949 powerRequest.uEnableBET = uValue;
9950 break;
9951 case eSIR_BET_INTERVAL:
9952 powerRequest.uBETInterval = uValue;
9953 break;
9954 default:
9955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009956 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009957 ucType, uValue, nOffset);
9958 return VOS_STATUS_E_FAILURE;
9959 }
9960
9961 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9963 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009964 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009965 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009966 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009967 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009968 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9969 {
9970 uTotalSize = 0;
9971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009972
9973 }/*Go for as long as we have a valid string*/
9974
9975 /* put the device into full power*/
9976 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9977
9978 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009979 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009980
9981 /* put the device back to power save*/
9982 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9983
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309984 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009985 return VOS_STATUS_SUCCESS;
9986}/*iw_set_power_params*/
9987
Atul Mittalc0f739f2014-07-31 13:47:47 +05309988// tdlsoffchan
9989#ifdef FEATURE_WLAN_TDLS
9990
Atul Mittal87ec2422014-09-24 13:12:50 +05309991int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309992{
9993 if (offchannel < 0 || offchannel > 165)
9994 {
9995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9996 __func__, offchannel);
9997 return -1;
9998
9999 }
10000
10001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10002 __func__, tdlsOffCh, offchannel);
10003
10004 tdlsOffCh = offchannel;
10005 return 0;
10006}
10007
Atul Mittal87ec2422014-09-24 13:12:50 +053010008int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010009{
10010 if (offchanoffset == 0)
10011 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010012 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10014 __func__, tdlsOffChBwOffset);
10015
10016 return 0;
10017
10018 }
10019
10020 if ( offchanoffset == 40 )
10021 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010022 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10024 __func__, tdlsOffChBwOffset);
10025
10026 return 0;
10027
10028 }
10029 if (offchanoffset == -40)
10030 {
10031 tdlsOffChBwOffset = 3;
10032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10033 __func__, tdlsOffChBwOffset);
10034
10035 return 0;
10036
10037 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010038
10039 if ((offchanoffset == 80) &&
10040 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10041 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10042 {
10043 tdlsOffChBwOffset = 4;
10044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10045 "%s: change tdls secondary off channel offset to %u",
10046 __func__, tdlsOffChBwOffset);
10047
10048 return 0;
10049 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10051 __func__, offchanoffset);
10052 return -1;
10053}
10054
Atul Mittal87ec2422014-09-24 13:12:50 +053010055int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010056{
10057 hddTdlsPeer_t *connPeer = NULL;
10058 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10059 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10060
10061 if (offchanmode < 0 || offchanmode > 4)
10062 {
10063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10064 "%s: Invalid tdls off channel mode %d",
10065 __func__, offchanmode);
10066 return -1;
10067 }
10068
10069 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10070 {
10071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10072 "%s: tdls off channel mode req in not associated state %d",
10073 __func__, offchanmode);
10074 return -1;
10075 }
10076
10077 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10078 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10079 {
10080 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010081 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010082 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010083 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010084 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10086 "%s: No TDLS Connected Peer", __func__);
10087 return -1;
10088 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010089 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010090 }
10091 else
10092 {
10093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10094 "%s: TDLS Connection not supported", __func__);
10095 return -1;
10096 }
10097
10098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10099 ("%s: TDLS Channel Switch in swmode=%d"),
10100 __func__, offchanmode);
10101
10102 switch (offchanmode)
10103 {
10104 case 1:/*Enable*/
10105 case 2:/*Disable*/
10106 {
10107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10108 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10109 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10110 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10111 {
10112
10113 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
10114 pAdapter->sessionId, connPeer->peerMac,
10115 tdlsOffCh, tdlsOffChBwOffset,
10116 offchanmode);
10117 }
10118 else
10119 {
10120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10121 "%s: TDLS Off Channel not supported", __func__);
10122 return -1;
10123 }
10124 break;
10125 }
10126 case 3:
10127 {
10128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10129 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10130 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10131
10132 break;
10133 }
10134 case 4:
10135 {
10136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10137 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10138 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10139 break;
10140 }
10141 default:
10142 {
10143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10144 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10145 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10146 break;
10147 }
10148
10149 }
10150
10151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10152 __func__, offchanmode);
10153 return 0;
10154}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010155#endif
10156
Jeff Johnson295189b2012-06-20 16:38:30 -070010157
10158// Define the Wireless Extensions to the Linux Network Device structure
10159// A number of these routines are NULL (meaning they are not implemented.)
10160
10161static const iw_handler we_handler[] =
10162{
10163 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10164 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10165 (iw_handler) NULL, /* SIOCSIWNWID */
10166 (iw_handler) NULL, /* SIOCGIWNWID */
10167 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10168 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10169 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10170 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10171 (iw_handler) NULL, /* SIOCSIWSENS */
10172 (iw_handler) NULL, /* SIOCGIWSENS */
10173 (iw_handler) NULL, /* SIOCSIWRANGE */
10174 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10175 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
10176 (iw_handler) NULL, /* SIOCGIWPRIV */
10177 (iw_handler) NULL, /* SIOCSIWSTATS */
10178 (iw_handler) NULL, /* SIOCGIWSTATS */
10179 iw_handler_set_spy, /* SIOCSIWSPY */
10180 iw_handler_get_spy, /* SIOCGIWSPY */
10181 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10182 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10183 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10184 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10185 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10186 (iw_handler) NULL, /* SIOCGIWAPLIST */
10187 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10188 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10189 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10190 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10191 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10192 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10193 (iw_handler) NULL, /* -- hole -- */
10194 (iw_handler) NULL, /* -- hole -- */
10195 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10196 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10197 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10198 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10199 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10200 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10201 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10202 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10203 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10204 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10205 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10206 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10207 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10208 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10209 (iw_handler) NULL, /* -- hole -- */
10210 (iw_handler) NULL, /* -- hole -- */
10211 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10212 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10213 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10214 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10215 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10216 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10217 (iw_handler) NULL, /* SIOCSIWPMKSA */
10218};
10219
10220static const iw_handler we_private[] = {
10221
10222 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10223 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10224 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10225 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10226 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10227 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010228 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010229 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10230 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10231 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010232#ifdef FEATURE_OEM_DATA_SUPPORT
10233 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10234 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10235#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010236
Jeff Johnson295189b2012-06-20 16:38:30 -070010237#ifdef WLAN_FEATURE_VOWIFI_11R
10238 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10239#endif
10240 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10241 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10242 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10243#ifdef WLAN_FEATURE_PACKET_FILTERING
10244 ,
10245 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10246#endif
10247#ifdef FEATURE_WLAN_SCAN_PNO
10248 ,
10249 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10250#endif
10251 ,
10252 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10253 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10254 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10255 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010256 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010257};
10258
10259/*Maximum command length can be only 15 */
10260static const struct iw_priv_args we_private_args[] = {
10261
Katya Nigamf0511f62015-05-05 16:40:57 +053010262 { WE_SET_MONITOR_STATE,
10263 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10264 0, "monitor" },
10265
Jeff Johnson295189b2012-06-20 16:38:30 -070010266 /* handlers for main ioctl */
10267 { WLAN_PRIV_SET_INT_GET_NONE,
10268 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10269 0,
10270 "" },
10271
10272 /* handlers for sub-ioctl */
10273 { WE_SET_11D_STATE,
10274 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10275 0,
10276 "set11Dstate" },
10277
10278 { WE_WOWL,
10279 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10280 0,
10281 "wowl" },
10282
10283 { WE_SET_POWER,
10284 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10285 0,
10286 "setPower" },
10287
10288 { WE_SET_MAX_ASSOC,
10289 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10290 0,
10291 "setMaxAssoc" },
10292
10293 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10294 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10295 0,
10296 "setAutoChannel" },
10297
10298 { WE_SET_DATA_INACTIVITY_TO,
10299 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10300 0,
10301 "inactivityTO" },
10302
10303 { WE_SET_MAX_TX_POWER,
10304 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10305 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010306 "setMaxTxPower" },
10307
10308 { WE_SET_MAX_TX_POWER_2_4,
10309 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10310 0,
10311 "setTxMaxPower2G" },
10312
10313 { WE_SET_MAX_TX_POWER_5_0,
10314 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10315 0,
10316 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010317
10318 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10319 * as well to keep same syntax as in SAP. Now onwards, STA
10320 * will support both */
10321 { WE_SET_MAX_TX_POWER,
10322 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10323 0,
10324 "setTxMaxPower" },
10325
Jeff Johnson295189b2012-06-20 16:38:30 -070010326 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10327 * 1 = enable and 0 = disable */
10328 {
10329 WE_SET_HIGHER_DTIM_TRANSITION,
10330 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10331 0,
10332 "setHDtimTransn" },
10333
10334 { WE_SET_TM_LEVEL,
10335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010336 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010337 "setTmLevel" },
10338
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010339 { WE_ENABLE_STRICT_FCC_REG,
10340 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10341 0,
10342 "setStrictFCCreg" },
10343
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010344 { WE_SET_DEBUG_LOG,
10345 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10346 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010347#ifdef FEATURE_WLAN_TDLS
10348 {
10349 WE_SET_TDLS_OFF_CHAN,
10350 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10351 0,
10352 "tdlsoffchan" },
10353 {
10354 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10355 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10356 0,
10357 "tdlsecchnoffst" },
10358 {
10359 WE_SET_TDLS_OFF_CHAN_MODE,
10360 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10361 0,
10362 "tdlsoffchnmode" },
10363#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010364
Peng Xu2446a892014-09-05 17:21:18 +053010365 { WE_SET_SCAN_BAND_PREFERENCE,
10366 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10367 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010368 {
10369 WE_GET_FRAME_LOG,
10370 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10371 0,
10372 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010373
Abhishek Singh01c73d12015-03-12 15:13:44 +053010374 { WE_SET_MIRACAST_VENDOR_CONFIG,
10375 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10376 0, "setMiracstConf" },
10377
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010378#ifdef FEATURE_WLAN_TDLS
10379 {
10380 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10381 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10382 0,
10383 "tdls_2040bsscox" },
10384#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010385 { WE_SET_RTS_CTS_HTVHT,
10386 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10387 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010388 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10389 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10390 0, "setPktStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010391 /* handlers for main ioctl */
10392 { WLAN_PRIV_SET_NONE_GET_INT,
10393 0,
10394 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10395 "" },
10396
10397 /* handlers for sub-ioctl */
10398 { WE_GET_11D_STATE,
10399 0,
10400 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10401 "get11Dstate" },
10402
10403 { WE_IBSS_STATUS,
10404 0,
10405 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10406 "getAdhocStatus" },
10407
10408 { WE_PMC_STATE,
10409 0,
10410 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10411 "pmcState" },
10412
10413 { WE_GET_WLAN_DBG,
10414 0,
10415 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10416 "getwlandbg" },
10417
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 { WE_GET_MAX_ASSOC,
10419 0,
10420 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10421 "getMaxAssoc" },
10422
Jeff Johnson295189b2012-06-20 16:38:30 -070010423 { WE_GET_WDI_DBG,
10424 0,
10425 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10426 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010427
10428 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10429 0,
10430 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10431 "getAutoChannel" },
10432
10433 { WE_GET_CONCURRENCY_MODE,
10434 0,
10435 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10436 "getconcurrency" },
10437
Peng Xu2446a892014-09-05 17:21:18 +053010438 { WE_GET_SCAN_BAND_PREFERENCE,
10439 0,
10440 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10441 "get_scan_pref"},
10442
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 /* handlers for main ioctl */
10444 { WLAN_PRIV_SET_CHAR_GET_NONE,
10445 IW_PRIV_TYPE_CHAR| 512,
10446 0,
10447 "" },
10448
10449 /* handlers for sub-ioctl */
10450 { WE_WOWL_ADD_PTRN,
10451 IW_PRIV_TYPE_CHAR| 512,
10452 0,
10453 "wowlAddPtrn" },
10454
10455 { WE_WOWL_DEL_PTRN,
10456 IW_PRIV_TYPE_CHAR| 512,
10457 0,
10458 "wowlDelPtrn" },
10459
10460#if defined WLAN_FEATURE_VOWIFI
10461 /* handlers for sub-ioctl */
10462 { WE_NEIGHBOR_REPORT_REQUEST,
10463 IW_PRIV_TYPE_CHAR | 512,
10464 0,
10465 "neighbor" },
10466#endif
10467 { WE_SET_AP_WPS_IE,
10468 IW_PRIV_TYPE_CHAR| 512,
10469 0,
10470 "set_ap_wps_ie" },
10471
10472 { WE_SET_CONFIG,
10473 IW_PRIV_TYPE_CHAR| 512,
10474 0,
10475 "setConfig" },
10476
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010477 { WE_SET_ENCRYPT_MSG,
10478 IW_PRIV_TYPE_CHAR| 512,
10479 0,
10480 "encryptMsg" },
10481
10482
Jeff Johnson295189b2012-06-20 16:38:30 -070010483 /* handlers for main ioctl */
10484 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10485 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10486 0,
10487 "" },
10488
10489 /* handlers for sub-ioctl */
10490 { WE_SET_WLAN_DBG,
10491 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10492 0,
10493 "setwlandbg" },
10494
Jeff Johnson295189b2012-06-20 16:38:30 -070010495 { WE_SET_WDI_DBG,
10496 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10497 0,
10498 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010499
10500 { WE_SET_SAP_CHANNELS,
10501 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10502 0,
10503 "setsapchannels" },
10504
10505 /* handlers for main ioctl */
10506 { WLAN_PRIV_GET_CHAR_SET_NONE,
10507 0,
10508 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10509 "" },
10510
10511 /* handlers for sub-ioctl */
10512 { WE_WLAN_VERSION,
10513 0,
10514 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10515 "version" },
10516 { WE_GET_STATS,
10517 0,
10518 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10519 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010520 { WE_GET_STATES,
10521 0,
10522 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10523 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010524 { WE_GET_CFG,
10525 0,
10526 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10527 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010528#ifdef WLAN_FEATURE_11AC
10529 { WE_GET_RSSI,
10530 0,
10531 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10532 "getRSSI" },
10533#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010534#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010535 { WE_GET_ROAM_RSSI,
10536 0,
10537 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10538 "getRoamRSSI" },
10539#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 { WE_GET_WMM_STATUS,
10541 0,
10542 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10543 "getWmmStatus" },
10544 {
10545 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010546 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10548 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010549#ifdef FEATURE_WLAN_TDLS
10550 {
10551 WE_GET_TDLS_PEERS,
10552 0,
10553 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10554 "getTdlsPeers" },
10555#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010556#ifdef WLAN_FEATURE_11W
10557 {
10558 WE_GET_11W_INFO,
10559 0,
10560 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10561 "getPMFInfo" },
10562#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010563 { WE_GET_SNR,
10564 0,
10565 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10566 "getSNR" },
10567
Jeff Johnson295189b2012-06-20 16:38:30 -070010568 /* handlers for main ioctl */
10569 { WLAN_PRIV_SET_NONE_GET_NONE,
10570 0,
10571 0,
10572 "" },
10573
10574 /* handlers for sub-ioctl */
10575 { WE_CLEAR_STATS,
10576 0,
10577 0,
10578 "clearStats" },
10579 { WE_INIT_AP,
10580 0,
10581 0,
10582 "initAP" },
10583 { WE_STOP_AP,
10584 0,
10585 0,
10586 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010587#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010588 { WE_ENABLE_AMP,
10589 0,
10590 0,
10591 "enableAMP" },
10592 { WE_DISABLE_AMP,
10593 0,
10594 0,
10595 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010596#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010597 { WE_ENABLE_DXE_STALL_DETECT,
10598 0,
10599 0,
10600 "dxeStallDetect" },
10601 { WE_DISPLAY_DXE_SNAP_SHOT,
10602 0,
10603 0,
10604 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010605 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10606 0,
10607 0,
10608 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010609 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010610 WE_SET_REASSOC_TRIGGER,
10611 0,
10612 0,
10613 "reassoc" },
10614 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010615 WE_STOP_OBSS_SCAN,
10616 0,
10617 0,
10618 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010619 {
10620 WE_DUMP_ROAM_TIMER_LOG,
10621 0,
10622 0,
10623 "dumpRoamDelay" },
10624 {
10625 WE_RESET_ROAM_TIMER_LOG,
10626 0,
10627 0,
10628 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010629 {
10630 WE_GET_FW_LOGS,
10631 0,
10632 0,
10633 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053010634 {
10635 WE_GET_FW_MEMDUMP,
10636 0,
10637 0,
10638 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010639 /* handlers for main ioctl */
10640 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10641 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10642 0,
10643 "" },
10644
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010645
10646
Jeff Johnson295189b2012-06-20 16:38:30 -070010647 /* handlers for sub-ioctl */
10648 { WE_LOG_DUMP_CMD,
10649 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10650 0,
10651 "dump" },
10652
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010653 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010654 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10655 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10656 0,
10657 "setdumplog" },
10658
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010659 { WE_MTRACE_DUMP_CMD,
10660 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10661 0,
10662 "dumplog" },
10663
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010664 /* handlers for sub ioctl */
10665 {
10666 WE_MCC_CONFIG_CREDENTIAL,
10667 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10668 0,
10669 "setMccCrdnl" },
10670
10671 /* handlers for sub ioctl */
10672 {
10673 WE_MCC_CONFIG_PARAMS,
10674 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10675 0,
10676 "setMccConfig" },
10677
Chilam NG571c65a2013-01-19 12:27:36 +053010678#ifdef FEATURE_WLAN_TDLS
10679 /* handlers for sub ioctl */
10680 {
10681 WE_TDLS_CONFIG_PARAMS,
10682 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10683 0,
10684 "setTdlsConfig" },
10685#endif
10686
Katya Nigamf0511f62015-05-05 16:40:57 +053010687 {
10688 WE_CONFIGURE_MONITOR_MODE,
10689 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10690 0,
10691 "MonitorModeConf" },
10692
10693 {
10694 WE_SET_MONITOR_MODE_FILTER,
10695 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10696 0,
10697 "MonitorFilter" },
10698
Jeff Johnson295189b2012-06-20 16:38:30 -070010699 /* handlers for main ioctl */
10700 { WLAN_PRIV_ADD_TSPEC,
10701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10702 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10703 "addTspec" },
10704
10705 /* handlers for main ioctl */
10706 { WLAN_PRIV_DEL_TSPEC,
10707 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10708 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10709 "delTspec" },
10710
10711 /* handlers for main ioctl */
10712 { WLAN_PRIV_GET_TSPEC,
10713 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10714 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10715 "getTspec" },
10716
Jeff Johnsone7245742012-09-05 17:12:55 -070010717#ifdef FEATURE_OEM_DATA_SUPPORT
10718 /* handlers for main ioctl - OEM DATA */
10719 {
10720 WLAN_PRIV_SET_OEM_DATA_REQ,
10721 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10722 0,
10723 "set_oem_data_req" },
10724
10725 /* handlers for main ioctl - OEM DATA */
10726 {
10727 WLAN_PRIV_GET_OEM_DATA_RSP,
10728 0,
10729 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10730 "get_oem_data_rsp" },
10731#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010732
Jeff Johnson295189b2012-06-20 16:38:30 -070010733 /* handlers for main ioctl - host offload */
10734 {
10735 WLAN_PRIV_SET_HOST_OFFLOAD,
10736 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10737 0,
10738 "setHostOffload" },
10739
10740 {
10741 WLAN_GET_WLAN_STATISTICS,
10742 0,
10743 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10744 "getWlanStats" },
10745
10746 {
10747 WLAN_SET_KEEPALIVE_PARAMS,
10748 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10749 0,
10750 "setKeepAlive" },
10751#ifdef WLAN_FEATURE_PACKET_FILTERING
10752 {
10753 WLAN_SET_PACKET_FILTER_PARAMS,
10754 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10755 0,
10756 "setPktFilter" },
10757#endif
10758#ifdef FEATURE_WLAN_SCAN_PNO
10759 {
10760 WLAN_SET_PNO,
10761 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10762 0,
10763 "setpno" },
10764#endif
10765 {
10766 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010767 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010768 0,
10769 "SETBAND" },
10770 /* handlers for dynamic MC BC ioctl */
10771 {
10772 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010773 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010774 0,
10775 "setMCBCFilter" },
10776 {
10777 WLAN_PRIV_CLEAR_MCBC_FILTER,
10778 0,
10779 0,
10780 "clearMCBCFilter" },
10781 {
10782 WLAN_SET_POWER_PARAMS,
10783 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10784 0,
10785 "setpowerparams" },
10786 {
10787 WLAN_GET_LINK_SPEED,
10788 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010789 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010790};
10791
10792
10793
10794const struct iw_handler_def we_handler_def = {
10795 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10796 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10797 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10798
10799 .standard = (iw_handler *)we_handler,
10800 .private = (iw_handler *)we_private,
10801 .private_args = we_private_args,
10802 .get_wireless_stats = get_wireless_stats,
10803};
10804
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010805int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10806{
10807 v_U32_t cmd = 288; //Command to RIVA
10808 hdd_context_t *pHddCtx = NULL;
10809 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10810 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10811 /*
10812 *configMccParam : specify the bit which needs to be modified
10813 *allowed to update based on wlan_qcom_cfg.ini
10814 * configuration
10815 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10816 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10817 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10818 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10819 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10820 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10821 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10822 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10823 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10824 * Bit 9 : Reserved
10825 */
10826 switch (arg1)
10827 {
10828 //Update MCC SCHEDULE_TIME_SLICE parameter
10829 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10830 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10831 {
10832 if((arg2 >= 5) && (arg2 <= 20))
10833 {
10834 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10835 }
10836 else
10837 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010838 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010839 return 0;
10840 }
10841 }
10842 break;
10843
10844 //Update MCC MAX_NULL_SEND_TIME parameter
10845 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10846 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10847 {
10848 if((arg2 >= 1) && (arg2 <= 10))
10849 {
10850 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10851 }
10852 else
10853 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010854 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010855 return 0;
10856 }
10857 }
10858 break;
10859
10860 //Update MCC TX_EARLY_STOP_TIME parameter
10861 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10862 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10863 {
10864 if((arg2 >= 1) && (arg2 <= 10))
10865 {
10866 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10867 }
10868 else
10869 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010870 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010871 return 0;
10872 }
10873 }
10874 break;
10875
10876 //Update MCC RX_DRAIN_TIME parameter
10877 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10878 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10879 {
10880 if((arg2 >= 1) && (arg2 <= 10))
10881 {
10882 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10883 }
10884 else
10885 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010886 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010887 return 0;
10888 }
10889 }
10890 break;
10891
10892 //Update MCC CHANNEL_SWITCH_TIME parameter
10893 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10894 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10895 {
10896 if((arg2 >= 1) && (arg2 <= 20))
10897 {
10898 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10899 }
10900 else
10901 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010902 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010903 return 0;
10904 }
10905 }
10906 break;
10907
10908 //Update MCC MIN_CHANNEL_TIME parameter
10909 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10910 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10911 {
10912 if((arg2 >= 5) && (arg2 <= 20))
10913 {
10914 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10915 }
10916 else
10917 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010918 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010919 return 0;
10920 }
10921 }
10922 break;
10923
10924 //Update MCC PARK_BEFORE_TBTT parameter
10925 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10926 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10927 {
10928 if((arg2 >= 1) && (arg2 <= 5))
10929 {
10930 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10931 }
10932 else
10933 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010934 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010935 return 0;
10936 }
10937 }
10938 break;
10939
10940 //Update MCC MIN_AFTER_DTIM parameter
10941 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10942 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10943 {
10944 if((arg2 >= 5) && (arg2 <= 15))
10945 {
10946 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10947 }
10948 else
10949 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010950 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010951 return 0;
10952 }
10953 }
10954 break;
10955
10956 //Update MCC TOO_CLOSE_MARGIN parameter
10957 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10958 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10959 {
10960 if((arg2 >= 1) && (arg2 <= 3))
10961 {
10962 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10963 }
10964 else
10965 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010966 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010967 return 0;
10968 }
10969 }
10970 break;
10971
10972 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010973 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010974 __FUNCTION__,arg1);
10975 break;
10976 }
10977 return 0;
10978}
10979
Jeff Johnson295189b2012-06-20 16:38:30 -070010980int hdd_set_wext(hdd_adapter_t *pAdapter)
10981{
10982 hdd_wext_state_t *pwextBuf;
10983 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010984 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010985
10986 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10987
10988 // Now configure the roaming profile links. To SSID and bssid.
10989 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10990 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10991
10992 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10993 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10994
10995 /*Set the numOfChannels to zero to scan all the channels*/
10996 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10997 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10998
10999 /* Default is no encryption */
11000 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11001 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11002
11003 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11004 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11005
11006 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11007
11008 /* Default is no authentication */
11009 pwextBuf->roamProfile.AuthType.numEntries = 1;
11010 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11011
11012 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11013 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11014
11015 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011016 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011017
11018 hdd_clearRoamProfileIe(pAdapter);
11019
11020 return VOS_STATUS_SUCCESS;
11021
11022 }
11023
11024int hdd_register_wext(struct net_device *dev)
11025 {
11026 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11027 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11028 VOS_STATUS status;
11029
11030 ENTER();
11031
11032 // Zero the memory. This zeros the profile structure.
11033 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11034
11035 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11036
11037
11038 status = hdd_set_wext(pAdapter);
11039
11040 if(!VOS_IS_STATUS_SUCCESS(status)) {
11041
Arif Hussain6d2a3322013-11-17 19:50:10 -080011042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011043 return eHAL_STATUS_FAILURE;
11044 }
11045
11046 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11047 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011049 return eHAL_STATUS_FAILURE;
11050 }
11051
11052 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11053 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 return eHAL_STATUS_FAILURE;
11056 }
11057
11058 // Register as a wireless device
11059 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11060
11061 EXIT();
11062 return 0;
11063}
11064
11065int hdd_UnregisterWext(struct net_device *dev)
11066{
c_hpothu2a13bc32015-01-21 12:48:54 +053011067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11068 if (dev != NULL)
11069 {
11070 rtnl_lock();
11071 dev->wireless_handlers = NULL;
11072 rtnl_unlock();
11073 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011074
Jeff Johnson295189b2012-06-20 16:38:30 -070011075 return 0;
11076}
11077
11078