blob: 43704d2789c8e1563f8197768dffb74bac8ebdc5 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
c_hpothu002231a2015-02-05 14:58:51 +05302 * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Anand N Sunkad0a3436f2015-05-01 14:22:19 +053053#include <linux/wcnss_wlan.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053054#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include <wlan_hdd_includes.h>
56#include <wlan_btc_svc.h>
57#include <wlan_nlink_common.h>
58#ifdef WLAN_BTAMP_FEATURE
59#include <bap_hdd_main.h>
60#endif
61#include <vos_api.h>
62#include <net/arp.h>
63#include "ccmApi.h"
64#include "sirParams.h"
65#include "csrApi.h"
66#include "csrInsideApi.h"
67#if defined WLAN_FEATURE_VOWIFI
68#include "smeRrmInternal.h"
69#endif
70#include <aniGlobal.h>
71#include "dot11f.h"
72#include <wlan_hdd_wowl.h>
73#include <wlan_hdd_cfg.h>
74#include <wlan_hdd_wmm.h>
75#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#ifdef CONFIG_HAS_EARLYSUSPEND
82#include <linux/earlysuspend.h>
83#endif
84#include "wlan_hdd_power.h"
85#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070086#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530107#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530108
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#ifdef CONFIG_HAS_EARLYSUSPEND
110extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
111extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
112#endif
113
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800115#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530119#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700120
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
Atul Mittalc0f739f2014-07-31 13:47:47 +0530122// tdlsoffchan
123#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530124static int tdlsOffCh = 1;
125static int tdlsOffChBwOffset = 0;
126#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530127
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700128static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/* To Validate Channel against the Frequency and Vice-Versa */
132static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
133 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
134 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
135 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
136 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
137 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
138 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
139 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800140 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
141 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700142
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800143#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700144
145/* Private ioctls and their sub-ioctls */
146#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
147#define WE_SET_11D_STATE 1
148#define WE_WOWL 2
149#define WE_SET_POWER 3
150#define WE_SET_MAX_ASSOC 4
151#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
152#define WE_SET_DATA_INACTIVITY_TO 6
153#define WE_SET_MAX_TX_POWER 7
154#define WE_SET_HIGHER_DTIM_TRANSITION 8
155#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530156#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700157#define WE_SET_MAX_TX_POWER_2_4 11
158#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800159/* Private IOCTL for debug connection issues */
160#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530161// tdlsoffchan
162#ifdef FEATURE_WLAN_TDLS
163#define WE_SET_TDLS_OFF_CHAN 14
164#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
165#define WE_SET_TDLS_OFF_CHAN_MODE 16
166#endif
Peng Xu2446a892014-09-05 17:21:18 +0530167#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530168#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530169#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530170#ifdef FEATURE_WLAN_TDLS
171#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
172#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +0530173#define WE_SET_RTS_CTS_HTVHT 21
Katya Nigamf0511f62015-05-05 16:40:57 +0530174#define WE_SET_MONITOR_STATE 22
Sushant Kaushik33200572015-08-05 16:46:20 +0530175#define WE_SET_PKT_STATS_ENABLE_DISABLE 23
Jeff Johnson295189b2012-06-20 16:38:30 -0700176
177/* Private ioctls and their sub-ioctls */
178#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
179#define WE_GET_11D_STATE 1
180#define WE_IBSS_STATUS 2
181#define WE_PMC_STATE 3
182#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700183#define WE_GET_MAX_ASSOC 6
184#define WE_GET_WDI_DBG 7
185#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
186#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530187#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700188/* Private ioctls and their sub-ioctls */
189#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
190
191/* Private ioctls and their sub-ioctls */
192#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
193#define WE_WOWL_ADD_PTRN 1
194#define WE_WOWL_DEL_PTRN 2
195#if defined WLAN_FEATURE_VOWIFI
196#define WE_NEIGHBOR_REPORT_REQUEST 3
197#endif
198#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
199#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530200#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700201
202/* Private ioctls and their sub-ioctls */
203#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
204#define WE_SET_WLAN_DBG 1
205#define WE_SET_WDI_DBG 2
206#define WE_SET_SAP_CHANNELS 3
207
208/* Private ioctls and their sub-ioctls */
209#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
210#define WE_WLAN_VERSION 1
211#define WE_GET_STATS 2
212#define WE_GET_CFG 3
213#define WE_GET_WMM_STATUS 4
214#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700215#ifdef WLAN_FEATURE_11AC
216#define WE_GET_RSSI 6
217#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800218#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800219#ifdef FEATURE_WLAN_TDLS
220#define WE_GET_TDLS_PEERS 8
221#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700222#ifdef WLAN_FEATURE_11W
223#define WE_GET_11W_INFO 9
224#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530225#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530226#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700227
228/* Private ioctls and their sub-ioctls */
229#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
230#define WE_CLEAR_STATS 1
231#define WE_INIT_AP 2
232#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530233#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700234#define WE_ENABLE_AMP 4
235#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530236#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700237#define WE_ENABLE_DXE_STALL_DETECT 6
238#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700239#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530240#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530241#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530242#define WE_DUMP_ROAM_TIMER_LOG 12
243#define WE_RESET_ROAM_TIMER_LOG 13
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530244#define WE_GET_FW_LOGS 14
c_manjeecfd1efb2015-09-25 19:32:34 +0530245#define WE_GET_FW_MEMDUMP 15
Mukul Sharma84f27252014-07-14 18:11:42 +0530246
Jeff Johnson295189b2012-06-20 16:38:30 -0700247/* Private ioctls and their sub-ioctls */
248#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
249#define WE_LOG_DUMP_CMD 1
250
Jeff Johnson295189b2012-06-20 16:38:30 -0700251#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800252//IOCTL to configure MCC params
253#define WE_MCC_CONFIG_CREDENTIAL 3
254#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700255
Chilam NG571c65a2013-01-19 12:27:36 +0530256#ifdef FEATURE_WLAN_TDLS
257#define WE_TDLS_CONFIG_PARAMS 5
258#endif
259
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700260#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530261#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530262#define WE_CONFIGURE_MONITOR_MODE 10
263#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700264
Chilam Ng01120412013-02-19 18:32:21 -0800265#ifdef FEATURE_WLAN_TDLS
266#undef MAX_VAR_ARGS
267#define MAX_VAR_ARGS 10
268#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700269#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800270#endif
271
Jeff Johnson295189b2012-06-20 16:38:30 -0700272/* Private ioctls (with no sub-ioctls) */
273/* note that they must be odd so that they have "get" semantics */
274#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
275#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
276#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
277
Girish Gowli464c9c82014-06-09 19:47:53 +0530278/* (SIOCIWFIRSTPRIV + 8) is currently unused */
279/* (SIOCIWFIRSTPRIV + 16) is currently unused */
280/* (SIOCIWFIRSTPRIV + 10) is currently unused */
281/* (SIOCIWFIRSTPRIV + 12) is currently unused */
282/* (SIOCIWFIRSTPRIV + 14) is currently unused */
283/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
Jeff Johnsone7245742012-09-05 17:12:55 -0700285#ifdef FEATURE_OEM_DATA_SUPPORT
286/* Private ioctls for setting the measurement configuration */
287#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
288#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700290
291#ifdef WLAN_FEATURE_VOWIFI_11R
292#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
293#endif
294
295/* Private ioctl for setting the host offload feature */
296#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
297
298/* Private ioctl to get the statistics */
299#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
300
301/* Private ioctl to set the Keep Alive Params */
302#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
303#ifdef WLAN_FEATURE_PACKET_FILTERING
304/* Private ioctl to set the Packet Filtering Params */
305#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
306#endif
307
308#ifdef FEATURE_WLAN_SCAN_PNO
309/* Private ioctl to get the statistics */
310#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
311#endif
312
313#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
314
315#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
316#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700317/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700318
Jeff Johnson295189b2012-06-20 16:38:30 -0700319#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
320#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
321
322#define WLAN_STATS_INVALID 0
323#define WLAN_STATS_RETRY_CNT 1
324#define WLAN_STATS_MUL_RETRY_CNT 2
325#define WLAN_STATS_TX_FRM_CNT 3
326#define WLAN_STATS_RX_FRM_CNT 4
327#define WLAN_STATS_FRM_DUP_CNT 5
328#define WLAN_STATS_FAIL_CNT 6
329#define WLAN_STATS_RTS_FAIL_CNT 7
330#define WLAN_STATS_ACK_FAIL_CNT 8
331#define WLAN_STATS_RTS_SUC_CNT 9
332#define WLAN_STATS_RX_DISCARD_CNT 10
333#define WLAN_STATS_RX_ERROR_CNT 11
334#define WLAN_STATS_TX_BYTE_CNT 12
335
336#define WLAN_STATS_RX_BYTE_CNT 13
337#define WLAN_STATS_RX_RATE 14
338#define WLAN_STATS_TX_RATE 15
339
Jeff Johnsone7245742012-09-05 17:12:55 -0700340#define WLAN_STATS_RX_UC_BYTE_CNT 16
341#define WLAN_STATS_RX_MC_BYTE_CNT 17
342#define WLAN_STATS_RX_BC_BYTE_CNT 18
343#define WLAN_STATS_TX_UC_BYTE_CNT 19
344#define WLAN_STATS_TX_MC_BYTE_CNT 20
345#define WLAN_STATS_TX_BC_BYTE_CNT 21
346
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800347#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
348 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
349 { \
350 *__p++ = __type; \
351 *__p++ = __size; \
352 memcpy(__p, __val, __size); \
353 __p += __size; \
354 __tlen += __size + 2; \
355 } \
356 else \
357 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800358 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800359 } \
360 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700361
362#define VERSION_VALUE_MAX_LEN 32
363
364#define TX_PER_TRACKING_DEFAULT_RATIO 5
365#define TX_PER_TRACKING_MAX_RATIO 10
366#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
367
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530368#define WLAN_ADAPTER 0
369#define P2P_ADAPTER 1
370
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +0530371/*
372 * When supplicant sends SETBAND ioctl it queries for channels from
373 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
374 * This is not required if the return type from ioctl is
375 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
376 * event as part of regulatory_hint.
377 */
378enum {
379 SEND_CHANNEL_CHANGE_EVENT = 0,
380 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
381};
382
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800383/*MCC Configuration parameters */
384enum {
385 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
386 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
387 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
388 MCC_RX_DRAIN_TIME_CFG_PARAM,
389 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
390 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
391 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
392 MCC_MIN_AFTER_DTIM_CFG_PARAM,
393 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
394};
395
396int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
397 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
398
Jeff Johnson295189b2012-06-20 16:38:30 -0700399#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800400int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700401 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700402#endif
c_manjeecfd1efb2015-09-25 19:32:34 +0530403static int get_fwr_memdump(struct net_device *,
404 struct iw_request_info *,
405 union iwreq_data *, char *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700406/**---------------------------------------------------------------------------
407
Arif Hussain0273cba2014-01-07 20:58:29 -0800408 \brief mem_alloc_copy_from_user_helper -
409
410 Helper function to allocate buffer and copy user data.
411
412 \param - wrqu - Pointer to IOCTL Data.
413 len - size
414
415 \return - On Success pointer to buffer, On failure NULL
416
417 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530418void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800419{
420 u8 *ptr = NULL;
421
422 /* in order to protect the code, an extra byte is post appended to the buffer
423 * and the null termination is added. However, when allocating (len+1) byte
424 * of memory, we need to make sure that there is no uint overflow when doing
425 * addition. In theory check len < UINT_MAX protects the uint overflow. For
426 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
427 * guess, now, it is assumed that the private command buffer size is no
428 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
429 */
430 if (len > MAX_USER_COMMAND_SIZE)
431 {
432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
433 "Invalid length");
434 return NULL;
435 }
436
437 ptr = kmalloc(len + 1, GFP_KERNEL);
438 if (NULL == ptr)
439 {
440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
441 "unable to allocate memory");
442 return NULL;
443 }
444
445 if (copy_from_user(ptr, wrqu_data, len))
446 {
447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
448 "%s: failed to copy data to user buffer", __func__);
449 kfree(ptr);
450 return NULL;
451 }
452 ptr[len] = '\0';
453 return ptr;
454}
455
Girish Gowli488ef492014-06-12 18:44:33 +0530456// Function to handle and get compatible struct iw_point passed to ioctl.
457int hdd_priv_get_data(struct iw_point *p_priv_data,
458 union iwreq_data *wrqu)
459{
460 if ((NULL == p_priv_data) || (NULL == wrqu))
461 {
462 return -EINVAL;
463 }
464
465#ifdef CONFIG_COMPAT
466 if (is_compat_task())
467 {
468 struct compat_iw_point *p_compat_priv_data;
469
470 // Compat task: typecast to campat structure and copy the members.
471 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
472
473 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
474 p_priv_data->length = p_compat_priv_data->length;
475 p_priv_data->flags = p_compat_priv_data->flags;
476 }//if(is_compat_task())
477 else
478 {
479#endif //#ifdef CONFIG_COMPAT
480
481 // Non compat task: directly copy the structure.
482 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
483
484#ifdef CONFIG_COMPAT
485 }//else of - if(is_compat_task())
486#endif //#ifdef CONFIG_COMPAT
487
488 return 0;
489}
490
Arif Hussain0273cba2014-01-07 20:58:29 -0800491/**---------------------------------------------------------------------------
492
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 \brief hdd_wlan_get_version() -
494
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800495 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700496
497 \param - pAdapter Pointer to the adapter.
498 wrqu - Pointer to IOCTL REQUEST Data.
499 extra - Pointer to char
500
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800501 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700502
503 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800504void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
505 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700506{
507 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800508 tSirVersionString wcnss_SW_version;
509 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530510 tSirVersionString iris_name;
511 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800512 char *pSWversion;
513 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800516 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
517 sizeof(wcnss_SW_version));
518 if (VOS_IS_STATUS_SUCCESS(status))
519 {
520 pSWversion = wcnss_SW_version;
521 }
522 else
523 {
524 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 }
526
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800527 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
528 sizeof(wcnss_HW_version));
529 if (VOS_IS_STATUS_SUCCESS(status))
530 {
531 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800533 else
534 {
535 pHWversion = "Unknown";
536 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700537
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530538 status = wcnss_get_iris_name(iris_name);
539
540 if (!status) {
541 pIRISversion = iris_name;
542 } else {
543 pIRISversion = "Unknown";
544 }
545
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700546 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530547 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800548 QWLAN_VERSIONSTR,
549 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530550 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800551
552 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700553}
554
Jeff Johnson295189b2012-06-20 16:38:30 -0700555int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
556{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530557 tHalHandle hHal;
558 hdd_context_t *pHddCtx;
559 v_U32_t threshold = 0;
560 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700561
562 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530563 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530564 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
566 "%s: Adapter is NULL",__func__);
567 return -EINVAL;
568 }
569
570 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
571 ret = wlan_hdd_validate_context(pHddCtx);
572 if (0 != ret)
573 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530574 return ret;
575 }
576
577 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
578 if (NULL == hHal)
579 {
580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
581 "%s: Hal Context is NULL",__func__);
582 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 }
584
585 if ( eHAL_STATUS_SUCCESS !=
586 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
587 {
c_hpothub8245442013-11-20 23:41:09 +0530588 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
589 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700590 return -EIO;
591 }
592 wrqu->rts.value = threshold;
593
594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800595 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700596
597 EXIT();
598
599 return 0;
600}
601
602int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
603{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530604 tHalHandle hHal;
605 hdd_context_t *pHddCtx;
606 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700607
608 ENTER();
609
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530610 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530611 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
613 "%s: Adapter is NULL",__func__);
614 return -EINVAL;
615 }
616
617 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
618 status = wlan_hdd_validate_context(pHddCtx);
619 if (0 != status)
620 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530621 return status;
622 }
623
624 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
625 if (NULL == hHal)
626 {
627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
628 "%s: Hal Context is NULL",__func__);
629 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 }
631
632 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
633 != eHAL_STATUS_SUCCESS )
634 {
c_hpothub8245442013-11-20 23:41:09 +0530635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
636 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 return -EIO;
638 }
639 wrqu->frag.value = threshold;
640
641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800642 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700643
644 EXIT();
645
646 return 0;
647}
648
649int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
650{
Jeff Johnsone7245742012-09-05 17:12:55 -0700651 int i;
652 if (channel > 0)
653 {
654 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
655 {
656 if (channel == freq_chan_map[i].chan)
657 {
658 *pfreq = freq_chan_map[i].freq;
659 return 1;
660 }
661 }
662 }
663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800664 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700665 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700666}
667
668static v_BOOL_t
669hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
670{
671 v_BOOL_t rsnType = VOS_FALSE;
672 // is the authType supported?
673 switch (authType)
674 {
675 case eCSR_AUTH_TYPE_NONE: //never used
676 rsnType = eANI_BOOLEAN_FALSE;
677 break;
678 // MAC layer authentication types
679 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
680 rsnType = eANI_BOOLEAN_FALSE;
681 break;
682 case eCSR_AUTH_TYPE_SHARED_KEY:
683 rsnType = eANI_BOOLEAN_FALSE;
684 break;
685 case eCSR_AUTH_TYPE_AUTOSWITCH:
686 rsnType = eANI_BOOLEAN_FALSE;
687 break;
688
689 // Upper layer authentication types
690 case eCSR_AUTH_TYPE_WPA:
691 rsnType = eANI_BOOLEAN_TRUE;
692 break;
693 case eCSR_AUTH_TYPE_WPA_PSK:
694 rsnType = eANI_BOOLEAN_TRUE;
695 break;
696 case eCSR_AUTH_TYPE_WPA_NONE:
697 rsnType = eANI_BOOLEAN_TRUE;
698 break;
699#ifdef WLAN_FEATURE_VOWIFI_11R
700 case eCSR_AUTH_TYPE_FT_RSN:
701#endif
702 case eCSR_AUTH_TYPE_RSN:
703 rsnType = eANI_BOOLEAN_TRUE;
704 break;
705#ifdef WLAN_FEATURE_VOWIFI_11R
706 case eCSR_AUTH_TYPE_FT_RSN_PSK:
707#endif
708 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700709#ifdef WLAN_FEATURE_11W
710 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530711 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700712#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 rsnType = eANI_BOOLEAN_TRUE;
714 break;
715 //case eCSR_AUTH_TYPE_FAILED:
716 case eCSR_AUTH_TYPE_UNKNOWN:
717 rsnType = eANI_BOOLEAN_FALSE;
718 break;
719 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800720 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
721 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 rsnType = eANI_BOOLEAN_FALSE;
723 break;
724 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800725 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700726 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 return rsnType;
728}
729
730static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
731{
732 struct statsContext *pStatsContext;
733 hdd_adapter_t *pAdapter;
734
735 if (ioctl_debug)
736 {
737 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700738 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 }
740
741 if (NULL == pContext)
742 {
743 hddLog(VOS_TRACE_LEVEL_ERROR,
744 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700745 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 return;
747 }
748
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 pStatsContext = pContext;
750 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800751
752 /* there is a race condition that exists between this callback
753 function and the caller since the caller could time out either
754 before or while this code is executing. we use a spinlock to
755 serialize these actions */
756 spin_lock(&hdd_context_lock);
757
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
759 {
760 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800761 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 hddLog(VOS_TRACE_LEVEL_WARN,
763 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700764 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 if (ioctl_debug)
766 {
767 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700768 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 }
770 return;
771 }
772
Jeff Johnson72a40512013-12-19 10:14:15 -0800773 /* context is valid so caller is still waiting */
774
775 /* paranoia: invalidate the magic */
776 pStatsContext->magic = 0;
777
Sachin Ahujaa082b672015-10-05 19:51:31 +0530778 /* copy over the rssi.FW will return RSSI as -100
779 * if there are no samples to calculate the average
780 * RSSI
781 */
782 if (rssi != -100)
783 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530784 if (pAdapter->rssi > 0)
785 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800786 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800788
789 /* serialization is complete */
790 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700791}
792
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530793static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
794{
795 struct statsContext *pStatsContext;
796 hdd_adapter_t *pAdapter;
797
798 if (ioctl_debug)
799 {
800 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
801 __func__, (int)snr, (int)staId, pContext);
802 }
803
804 if (NULL == pContext)
805 {
806 hddLog(VOS_TRACE_LEVEL_ERROR,
807 "%s: Bad param, pContext [%p]",
808 __func__, pContext);
809 return;
810 }
811
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530812 pStatsContext = pContext;
813 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800814
815 /* there is a race condition that exists between this callback
816 function and the caller since the caller could time out either
817 before or while this code is executing. we use a spinlock to
818 serialize these actions */
819 spin_lock(&hdd_context_lock);
820
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530821 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
822 {
823 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800824 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530825 hddLog(VOS_TRACE_LEVEL_WARN,
826 "%s: Invalid context, pAdapter [%p] magic [%08x]",
827 __func__, pAdapter, pStatsContext->magic);
828 if (ioctl_debug)
829 {
830 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
831 __func__, pAdapter, pStatsContext->magic);
832 }
833 return;
834 }
835
Jeff Johnson72a40512013-12-19 10:14:15 -0800836 /* context is valid so caller is still waiting */
837
838 /* paranoia: invalidate the magic */
839 pStatsContext->magic = 0;
840
841 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530842 pAdapter->snr = snr;
843
Jeff Johnson72a40512013-12-19 10:14:15 -0800844 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530845 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800846
847 /* serialization is complete */
848 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530849}
850
Jeff Johnson295189b2012-06-20 16:38:30 -0700851VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
852{
853 struct statsContext context;
854 hdd_context_t *pHddCtx;
855 hdd_station_ctx_t *pHddStaCtx;
856 eHalStatus hstatus;
857 long lrc;
858
859 if (NULL == pAdapter)
860 {
861 hddLog(VOS_TRACE_LEVEL_WARN,
862 "%s: Invalid context, pAdapter", __func__);
863 return VOS_STATUS_E_FAULT;
864 }
865 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
866 {
867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
868 /* return a cached value */
869 *rssi_value = pAdapter->rssi;
870 return VOS_STATUS_SUCCESS;
871 }
872
873 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
874 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
875
mukul sharma8aec69b2015-06-10 22:28:43 +0530876 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
877 {
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +0530878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated, rssi on Disconnect : %d",
879 __func__, pAdapter->rssi_on_disconnect);
880 *rssi_value = pAdapter->rssi_on_disconnect;
mukul sharma8aec69b2015-06-10 22:28:43 +0530881 return VOS_STATUS_SUCCESS;
882 }
883
884 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
885 {
886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
887 "%s: Roaming in progress, hence return last cached RSSI", __func__);
888 *rssi_value = pAdapter->rssi;
889 return VOS_STATUS_SUCCESS;
890 }
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 init_completion(&context.completion);
893 context.pAdapter = pAdapter;
894 context.magic = RSSI_CONTEXT_MAGIC;
895
896 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
897 pHddStaCtx->conn_info.staId[ 0 ],
898 pHddStaCtx->conn_info.bssId,
899 &context, pHddCtx->pvosContext);
900 if (eHAL_STATUS_SUCCESS != hstatus)
901 {
902 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700903 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 /* we'll returned a cached value below */
905 }
906 else
907 {
908 /* request was sent -- wait for the response */
909 lrc = wait_for_completion_interruptible_timeout(&context.completion,
910 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 if (lrc <= 0)
912 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700914 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 /* we'll now returned a cached value below */
916 }
917 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800918
919 /* either we never sent a request, we sent a request and received a
920 response or we sent a request and timed out. if we never sent a
921 request or if we sent a request and got a response, we want to
922 clear the magic out of paranoia. if we timed out there is a
923 race condition such that the callback function could be
924 executing at the same time we are. of primary concern is if the
925 callback function had already verified the "magic" but had not
926 yet set the completion variable when a timeout occurred. we
927 serialize these activities by invalidating the magic while
928 holding a shared spinlock which will cause us to block if the
929 callback is currently executing */
930 spin_lock(&hdd_context_lock);
931 context.magic = 0;
932 spin_unlock(&hdd_context_lock);
933
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 *rssi_value = pAdapter->rssi;
935
936 return VOS_STATUS_SUCCESS;
937}
Siddharth Bhal64246172015-02-27 01:04:37 +0530938/**---------------------------------------------------------------------------
939
940 \brief wlan_hdd_get_frame_logs() -
941
942 This function use to get Frames log.
943
944 \param - pAdapter Pointer to the adapter.
945 flag - Specify type of request. Clear and Send request are
946 supported.
947
948 \return - none
949
950 --------------------------------------------------------------------------*/
951VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
952{
Siddharth Bhal64246172015-02-27 01:04:37 +0530953 hdd_context_t *pHddCtx;
954 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +0530955
956 if (NULL == pAdapter)
957 {
958 hddLog(VOS_TRACE_LEVEL_WARN,
959 "%s: Invalid context, pAdapter", __func__);
960 return VOS_STATUS_E_FAULT;
961 }
962
963 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
964 if (!pHddCtx->mgmt_frame_logging)
965 {
966 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
967 return VOS_STATUS_E_AGAIN;
968 }
969
Siddharth Bhal4507c262015-04-29 20:20:42 +0530970 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
971 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
972 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +0530973 {
974 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
975 return VOS_STATUS_E_INVAL;
976 }
977
Siddharth Bhal4507c262015-04-29 20:20:42 +0530978 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
979 (!pHddCtx->cfg_ini->enableBMUHWtracing))
980 {
981 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
982 return VOS_STATUS_E_INVAL;
983 }
984
Abhishek Singh611295e2015-07-09 11:11:54 +0530985 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +0530986 if (eHAL_STATUS_SUCCESS != hstatus)
987 {
988 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +0530989 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +0530990 }
Siddharth Bhal64246172015-02-27 01:04:37 +0530991
992 return VOS_STATUS_SUCCESS;
993}
994
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530995
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530996VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
997{
998 struct statsContext context;
999 hdd_context_t *pHddCtx;
1000 hdd_station_ctx_t *pHddStaCtx;
1001 eHalStatus hstatus;
1002 long lrc;
1003 int valid;
1004
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301005 ENTER();
1006
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301007 if (NULL == pAdapter)
1008 {
1009 hddLog(VOS_TRACE_LEVEL_ERROR,
1010 "%s: Invalid context, pAdapter", __func__);
1011 return VOS_STATUS_E_FAULT;
1012 }
1013
1014 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1015
1016 valid = wlan_hdd_validate_context(pHddCtx);
1017 if (0 != valid)
1018 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301019 return VOS_STATUS_E_FAULT;
1020 }
1021
1022 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1023 if (NULL == pHddStaCtx)
1024 {
1025 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1026 return VOS_STATUS_E_FAULT;
1027 }
1028
1029 init_completion(&context.completion);
1030 context.pAdapter = pAdapter;
1031 context.magic = SNR_CONTEXT_MAGIC;
1032
1033 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1034 pHddStaCtx->conn_info.staId[ 0 ],
1035 pHddStaCtx->conn_info.bssId,
1036 &context);
1037 if (eHAL_STATUS_SUCCESS != hstatus)
1038 {
1039 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1040 __func__);
1041 /* we'll returned a cached value below */
1042 }
1043 else
1044 {
1045 /* request was sent -- wait for the response */
1046 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1047 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301048 if (lrc <= 0)
1049 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001050 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301051 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301052 /* we'll now returned a cached value below */
1053 }
1054 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001055
1056 /* either we never sent a request, we sent a request and received a
1057 response or we sent a request and timed out. if we never sent a
1058 request or if we sent a request and got a response, we want to
1059 clear the magic out of paranoia. if we timed out there is a
1060 race condition such that the callback function could be
1061 executing at the same time we are. of primary concern is if the
1062 callback function had already verified the "magic" but had not
1063 yet set the completion variable when a timeout occurred. we
1064 serialize these activities by invalidating the magic while
1065 holding a shared spinlock which will cause us to block if the
1066 callback is currently executing */
1067 spin_lock(&hdd_context_lock);
1068 context.magic = 0;
1069 spin_unlock(&hdd_context_lock);
1070
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301071 *snr = pAdapter->snr;
1072
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301073 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301074 return VOS_STATUS_SUCCESS;
1075}
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301076
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001077#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001078
1079static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1080{
1081 struct statsContext *pStatsContext;
1082 hdd_adapter_t *pAdapter;
1083 if (ioctl_debug)
1084 {
1085 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1086 __func__, (int)rssi, (int)staId, pContext);
1087 }
1088
1089 if (NULL == pContext)
1090 {
1091 hddLog(VOS_TRACE_LEVEL_ERROR,
1092 "%s: Bad param, pContext [%p]",
1093 __func__, pContext);
1094 return;
1095 }
1096
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001097 pStatsContext = pContext;
1098 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001099
1100 /* there is a race condition that exists between this callback
1101 function and the caller since the caller could time out either
1102 before or while this code is executing. we use a spinlock to
1103 serialize these actions */
1104 spin_lock(&hdd_context_lock);
1105
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001106 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1107 {
1108 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001109 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001110 hddLog(VOS_TRACE_LEVEL_WARN,
1111 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1112 __func__, pAdapter, pStatsContext->magic);
1113 if (ioctl_debug)
1114 {
1115 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1116 __func__, pAdapter, pStatsContext->magic);
1117 }
1118 return;
1119 }
1120
Jeff Johnson72a40512013-12-19 10:14:15 -08001121 /* context is valid so caller is still waiting */
1122
1123 /* paranoia: invalidate the magic */
1124 pStatsContext->magic = 0;
1125
Sachin Ahujaa082b672015-10-05 19:51:31 +05301126 /* copy over the rssi.FW will return RSSI as -100
1127 * if there are no samples to calculate the average
1128 * RSSI
1129 */
1130 if (rssi != -100)
1131 pAdapter->rssi = rssi;
1132
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301133 if (pAdapter->rssi > 0)
1134 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001135 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001136 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001137
1138 /* serialization is complete */
1139 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001140}
1141
1142
1143
1144VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1145{
1146 struct statsContext context;
1147 hdd_context_t *pHddCtx = NULL;
1148 hdd_station_ctx_t *pHddStaCtx = NULL;
1149 eHalStatus hstatus;
1150 long lrc;
1151
1152 if (NULL == pAdapter)
1153 {
1154 hddLog(VOS_TRACE_LEVEL_WARN,
1155 "%s: Invalid context, pAdapter", __func__);
1156 return VOS_STATUS_E_FAULT;
1157 }
1158 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1159 {
1160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1161 /* return a cached value */
1162 *rssi_value = pAdapter->rssi;
1163 return VOS_STATUS_SUCCESS;
1164 }
1165
1166 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1167 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1168
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301169 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001170 {
1171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1172 /* return a cached value */
1173 *rssi_value = 0;
1174 return VOS_STATUS_SUCCESS;
1175 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301176
1177 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1178 {
1179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1180 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1181 *rssi_value = pAdapter->rssi;
1182 return VOS_STATUS_SUCCESS;
1183 }
1184
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001185 init_completion(&context.completion);
1186 context.pAdapter = pAdapter;
1187 context.magic = RSSI_CONTEXT_MAGIC;
1188
1189 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1190 pHddStaCtx->conn_info.staId[ 0 ],
1191 pHddStaCtx->conn_info.bssId,
1192 &context, pHddCtx->pvosContext);
1193 if (eHAL_STATUS_SUCCESS != hstatus)
1194 {
1195 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1196 __func__);
1197 /* we'll returned a cached value below */
1198 }
1199 else
1200 {
1201 /* request was sent -- wait for the response */
1202 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1203 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001204 if (lrc <= 0)
1205 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001206 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001207 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001208 /* we'll now returned a cached value below */
1209 }
1210 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001211
1212 /* either we never sent a request, we sent a request and received a
1213 response or we sent a request and timed out. if we never sent a
1214 request or if we sent a request and got a response, we want to
1215 clear the magic out of paranoia. if we timed out there is a
1216 race condition such that the callback function could be
1217 executing at the same time we are. of primary concern is if the
1218 callback function had already verified the "magic" but had not
1219 yet set the completion variable when a timeout occurred. we
1220 serialize these activities by invalidating the magic while
1221 holding a shared spinlock which will cause us to block if the
1222 callback is currently executing */
1223 spin_lock(&hdd_context_lock);
1224 context.magic = 0;
1225 spin_unlock(&hdd_context_lock);
1226
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001227 *rssi_value = pAdapter->rssi;
1228
1229 return VOS_STATUS_SUCCESS;
1230}
1231#endif
1232
1233
Jeff Johnson295189b2012-06-20 16:38:30 -07001234void hdd_StatisticsCB( void *pStats, void *pContext )
1235{
1236 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1237 hdd_stats_t *pStatsCache = NULL;
1238 hdd_wext_state_t *pWextState;
1239 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1240
1241 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1242 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1243 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1244 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1245 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1246 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1247
1248 if (pAdapter!= NULL)
1249 pStatsCache = &pAdapter->hdd_stats;
1250
1251
1252 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1253 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1254 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1255 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1256 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1257 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1258
1259 if (pStatsCache!=NULL)
1260 {
1261 // and copy the stats into the cache we keep in the adapter instance structure
1262 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1263 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1264 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1265 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1266 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1267 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1268 }
1269
1270 if(pAdapter)
1271 {
1272 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1273 if(pWextState)
1274 {
1275 vos_status = vos_event_set(&pWextState->vosevent);
1276 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1277 {
1278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001279 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 return;
1281 }
1282 }
1283 }
1284}
1285
1286void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1287{
1288 v_CONTEXT_t pVosContext;
1289 hdd_context_t *pHddCtx;
1290 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1291#if 0
1292 hdd_wext_state_t *pWextState;
1293 v_U32_t roamId;
1294#endif
1295
1296 ENTER();
1297
1298 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1299
1300 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1301 if (NULL == pHddCtx)
1302 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001303 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 return;
1305 }
1306#if 0
1307 pWextState = pAdapter->pWextState;
1308#endif
1309
1310 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1311 {
1312 //TODO Verify is this is really used. If yes need to fix it.
1313 hdd_reconnect_all_adapters( pHddCtx );
1314#if 0
1315 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1316 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1317 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1318
1319 if(VOS_STATUS_SUCCESS == vosStatus)
1320 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1321 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1322
1323 sme_RoamConnect(halHandle,
1324 pAdapter->sessionId, &(pWextState->roamProfile),
1325 &roamId);
1326#endif
1327 }
1328
1329 EXIT();
1330
1331}
1332
1333void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1334{
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1336
1337 /* clear WPA/RSN/WSC IE information in the profile */
1338 pWextState->roamProfile.nWPAReqIELength = 0;
1339 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1340 pWextState->roamProfile.nRSNReqIELength = 0;
1341 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1342
Chet Lanctot186b5732013-03-18 10:26:30 -07001343#ifdef FEATURE_WLAN_WAPI
1344 pWextState->roamProfile.nWAPIReqIELength = 0;
1345 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1346#endif
1347
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001349 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001350 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301351 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1353 pWextState->roamProfile.nAddIEAssocLength = 0;
1354
1355 pWextState->roamProfile.EncryptionType.numEntries = 1;
1356 pWextState->roamProfile.EncryptionType.encryptionType[0]
1357 = eCSR_ENCRYPT_TYPE_NONE;
1358
1359 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1360 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1361 = eCSR_ENCRYPT_TYPE_NONE;
1362
1363 pWextState->roamProfile.AuthType.numEntries = 1;
1364 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1365
Chet Lanctot186b5732013-03-18 10:26:30 -07001366#ifdef WLAN_FEATURE_11W
1367 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1368 pWextState->roamProfile.MFPRequired = 0;
1369 pWextState->roamProfile.MFPCapable = 0;
1370#endif
1371
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 pWextState->authKeyMgmt = 0;
1373
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301374 vos_mem_zero(&pWextState->roamProfile.Keys,
1375 sizeof(pWextState->roamProfile.Keys));
1376
Jeff Johnson295189b2012-06-20 16:38:30 -07001377#ifdef FEATURE_WLAN_WAPI
1378 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1379 pAdapter->wapi_info.nWapiMode = 0;
1380#endif
1381
1382 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1383
1384}
1385
1386void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1387{
1388 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001389
Nirav Shahf6bd2672015-03-11 12:53:15 +05301390 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001391 {
1392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301393 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001394 }
1395 else
1396 {
1397 complete(&pAdapter->ula_complete);
1398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001399}
1400
1401VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1402{
1403 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001405 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001406
1407 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1408 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001409 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001410
1411 /*To avoid race condition between the set key and the last EAPOL
1412 packet, notify TL to finish upper layer authentication incase if the
1413 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001414 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001415
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001416 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 {
1418 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1419 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1420 __LINE__, vos_status );
1421 return vos_status;
1422
1423 }
1424
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001425 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301427 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001428 {
1429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301430 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001431 /* we'll still fall through and return success since the
1432 * connection may still get established but is just taking
1433 * too long for us to wait */
1434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 }
1436 return VOS_STATUS_SUCCESS;
1437}
1438
1439v_U8_t* wlan_hdd_get_vendor_oui_ie_ptr(v_U8_t *oui, v_U8_t oui_size, v_U8_t *ie, int ie_len)
1440{
1441
1442 int left = ie_len;
1443 v_U8_t *ptr = ie;
1444 v_U8_t elem_id,elem_len;
1445 v_U8_t eid = 0xDD;
1446
1447 if ( NULL == ie || 0 == ie_len )
1448 return NULL;
1449
1450 while(left >= 2)
1451 {
1452 elem_id = ptr[0];
1453 elem_len = ptr[1];
1454 left -= 2;
1455 if(elem_len > left)
1456 {
1457 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001458 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001459 eid,elem_len,left);
1460 return NULL;
1461 }
1462 if (elem_id == eid)
1463 {
1464 if(memcmp( &ptr[2], oui, oui_size)==0)
1465 return ptr;
1466 }
1467
1468 left -= elem_len;
1469 ptr += (elem_len + 2);
1470 }
1471 return NULL;
1472}
1473
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301474static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 union iwreq_data *wrqu, char *extra)
1476{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301477 hdd_adapter_t *pAdapter;
1478 hdd_context_t *pHddCtx;
1479 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301480
1481 ENTER();
1482
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301483 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1484 if (NULL == pAdapter)
1485 {
1486 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1487 "%s: pAdapter is NULL\n", __func__);
1488 return -EINVAL;
1489 }
1490 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1491 ret = wlan_hdd_validate_context(pHddCtx);
1492 if (0 != ret)
1493 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301494 return ret;
1495 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301496
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301498
1499 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301500 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001501}
1502
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301503static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1504 union iwreq_data *wrqu, char *extra)
1505{
1506 int ret;
1507
1508 vos_ssr_protect(__func__);
1509 ret = __iw_set_commit(dev, info, wrqu, extra);
1510 vos_ssr_unprotect(__func__);
1511
1512 return ret;
1513}
1514
1515static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 struct iw_request_info *info,
1517 char *wrqu, char *extra)
1518{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301519 hdd_adapter_t *pAdapter;
1520 hdd_context_t *pHddCtx;
1521 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301522
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301524 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1525 if (NULL == pAdapter)
1526 {
1527 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1528 "%s: pAdapter is NULL\n", __func__);
1529 return -EINVAL;
1530 }
1531 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1532 ret = wlan_hdd_validate_context(pHddCtx);
1533 if (0 != ret)
1534 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301535 return ret;
1536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1538 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301539 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001540}
1541
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301542static int iw_get_name(struct net_device *dev,
1543 struct iw_request_info *info,
1544 char *wrqu, char *extra)
1545{
1546 int ret;
1547
1548 vos_ssr_protect(__func__);
1549 ret = __iw_get_name(dev, info, wrqu, extra);
1550 vos_ssr_unprotect(__func__);
1551
1552 return ret;
1553}
1554
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301555static int __iw_set_mode(struct net_device *dev,
1556 struct iw_request_info *info,
1557 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001558{
1559 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301560 hdd_adapter_t *pAdapter;
1561 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 tCsrRoamProfile *pRoamProfile;
1563 eCsrRoamBssType LastBSSType;
1564 eMib_dot11DesiredBssType connectedBssType;
1565 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301567 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001568
1569 ENTER();
1570
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301571 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 if (NULL == pAdapter)
1573 {
1574 hddLog(VOS_TRACE_LEVEL_WARN,
1575 "%s: Invalid context, pAdapter", __func__);
1576 return 0;
1577 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301578 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1579 status = wlan_hdd_validate_context(pHddCtx);
1580 if (0 != status)
1581 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301582 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 }
1584
1585 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1586 if (pWextState == NULL)
1587 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301588 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 return -EINVAL;
1590 }
1591
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 pRoamProfile = &pWextState->roamProfile;
1594 LastBSSType = pRoamProfile->BSSType;
1595
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301596 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001597
1598 switch (wrqu->mode)
1599 {
1600 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301601 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1603 // Set the phymode correctly for IBSS.
1604 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1605 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001606 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 break;
1609 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301610 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 break;
1614 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301615 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1617 break;
1618 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301619 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 return -EOPNOTSUPP;
1621 }
1622
1623 if ( LastBSSType != pRoamProfile->BSSType )
1624 {
1625 //the BSS mode changed
1626 // We need to issue disconnect if connected or in IBSS disconnect state
1627 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1628 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1629 {
1630 VOS_STATUS vosStatus;
1631 // need to issue a disconnect to CSR.
1632 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1633 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1634 pAdapter->sessionId,
1635 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1636 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301637 {
1638 long ret;
1639 ret = wait_for_completion_interruptible_timeout(
1640 &pAdapter->disconnect_comp_var,
1641 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1642 if (ret <= 0)
1643 hddLog(VOS_TRACE_LEVEL_ERROR,
1644 FL("failed wait on disconnect_comp_var %ld"), ret);
1645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 }
1647 }
1648
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 EXIT();
1650 return 0;
1651}
1652
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301653static int iw_set_mode(struct net_device *dev,
1654 struct iw_request_info *info,
1655 union iwreq_data *wrqu, char *extra)
1656{
1657 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001658
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301659 vos_ssr_protect(__func__);
1660 ret = __iw_set_mode(dev, info, wrqu, extra);
1661 vos_ssr_unprotect(__func__);
1662
1663 return ret;
1664}
1665
1666static int __iw_get_mode(struct net_device *dev,
1667 struct iw_request_info *info,
1668 union iwreq_data *wrqu,
1669 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001670{
1671
1672 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301673 hdd_adapter_t *pAdapter;
1674 hdd_context_t *pHddCtx;
1675 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001676
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301677 ENTER();
1678
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301679 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 if (NULL == pAdapter)
1681 {
1682 hddLog(VOS_TRACE_LEVEL_WARN,
1683 "%s: Invalid context, pAdapter", __func__);
1684 return 0;
1685 }
1686
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301687 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1688 ret = wlan_hdd_validate_context(pHddCtx);
1689 if (0 != ret)
1690 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301691 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1694 if (pWextState == NULL)
1695 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301696 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 return -EINVAL;
1698 }
1699
1700 switch (pWextState->roamProfile.BSSType)
1701 {
1702 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001703 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301704 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 break;
1706 case eCSR_BSS_TYPE_IBSS:
1707 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001708 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301709 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 break;
1711 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001712 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301713 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 break;
1715 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001716 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 break;
1718 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301719
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301720 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 return 0;
1722}
1723
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301724static int iw_get_mode(struct net_device *dev,
1725 struct iw_request_info *info,
1726 union iwreq_data *wrqu,
1727 char *extra)
1728{
1729 int ret;
1730
1731 vos_ssr_protect(__func__);
1732 ret = __iw_get_mode(dev, info, wrqu, extra);
1733 vos_ssr_unprotect(__func__);
1734
1735 return ret;
1736}
1737
1738static int __iw_set_freq(struct net_device *dev,
1739 struct iw_request_info *info,
1740 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001741{
1742 v_U32_t numChans = 0;
1743 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1744 v_U32_t indx = 0;
1745 v_U32_t status = 0;
1746
1747 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301748 hdd_adapter_t *pAdapter;
1749 hdd_context_t *pHddCtx;
1750 tHalHandle hHal;
1751 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301753
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 ENTER();
1755
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301756 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1757 if (NULL == pAdapter)
1758 {
1759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1760 "%s:Invalid Adapter",__func__);
1761 return -EINVAL;
1762 }
1763
1764 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1765 status = wlan_hdd_validate_context(pHddCtx);
1766 if (0 != status)
1767 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 return status;
1769 }
1770
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301771 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1772 if (NULL == hHal)
1773 {
1774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1775 "%s: Hal Context is NULL",__func__);
1776 return -EINVAL;
1777 }
1778
1779 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1780 if (NULL == pHddStaCtx)
1781 {
1782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1783 "%s:STA context is NULL",__func__);
1784 return -EINVAL;
1785 }
1786
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301788 if (NULL == pWextState)
1789 {
1790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1791 "%s: pWextState is NULL",__func__);
1792 return -EINVAL;
1793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001794
1795 pRoamProfile = &pWextState->roamProfile;
1796
Arif Hussain6d2a3322013-11-17 19:50:10 -08001797 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001798
1799 /* Link is up then return cant set channel*/
1800 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1801 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1802 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001803 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 return -EOPNOTSUPP;
1805 }
1806
1807 /* Settings by Frequency as input */
1808 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1809 (wrqu->freq.m <= (tANI_U32)5.825e8))
1810 {
1811 tANI_U32 freq = wrqu->freq.m / 100000;
1812
1813 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1814 indx++;
1815 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1816 {
1817 return -EINVAL;
1818 }
1819 wrqu->freq.e = 0;
1820 wrqu->freq.m = freq_chan_map[indx].chan;
1821
1822 }
1823
1824 if (wrqu->freq.e == 0)
1825 {
1826 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1827 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1828 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001829 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001830 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1832 return -EINVAL;
1833 }
1834
1835 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1836
1837 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1838 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1840 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 return -EIO;
1842 }
1843
1844 for (indx = 0; indx < numChans; indx++) {
1845 if (wrqu->freq.m == validChan[indx]){
1846 break;
1847 }
1848 }
1849 }
1850 else{
1851
1852 return -EINVAL;
1853 }
1854
1855 if(indx >= numChans)
1856 {
1857 return -EINVAL;
1858 }
1859
1860 /* Set the Operational Channel */
1861 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1862 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1863 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1864
Arif Hussain6d2a3322013-11-17 19:50:10 -08001865 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001866
1867 EXIT();
1868
1869 return status;
1870}
1871
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301872static int iw_set_freq(struct net_device *dev,
1873 struct iw_request_info *info,
1874 union iwreq_data *wrqu, char *extra)
1875{
1876 int ret;
1877
1878 vos_ssr_protect(__func__);
1879 ret = __iw_set_freq(dev, info, wrqu, extra);
1880 vos_ssr_unprotect(__func__);
1881
1882 return ret;
1883}
1884
1885static int __iw_get_freq(struct net_device *dev,
1886 struct iw_request_info *info,
1887 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001888{
Jeff Johnsone7245742012-09-05 17:12:55 -07001889 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301890 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 tHalHandle hHal;
1892 hdd_wext_state_t *pWextState;
1893 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301894 hdd_station_ctx_t *pHddStaCtx;
1895 hdd_context_t *pHddCtx;
1896 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001897
1898 ENTER();
1899
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301900 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1901 if (NULL == pAdapter)
1902 {
1903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1904 "%s: Adapter is NULL", __func__);
1905 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301907 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1908 ret = wlan_hdd_validate_context(pHddCtx);
1909 if (0 != ret)
1910 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301911 return ret;
1912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301914 if (NULL == hHal)
1915 {
1916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1917 "%s: Hal Context is NULL",__func__);
1918 return -EINVAL;
1919 }
1920 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1921 if (NULL == pHddStaCtx)
1922 {
1923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1924 "%s: HddStaCtx is NULL", __func__);
1925 return -EINVAL;
1926 }
1927 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1928 if (NULL == pWextState)
1929 {
1930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1931 "%s: pWextState is NULL",__func__);
1932 return -EINVAL;
1933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 pRoamProfile = &pWextState->roamProfile;
1935
1936 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1937 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001938 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 {
c_hpothub8245442013-11-20 23:41:09 +05301940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1941 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 return -EIO;
1943 }
1944 else
1945 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001946 status = hdd_wlan_get_freq(channel, &freq);
1947 if( TRUE == status )
1948 {
1949 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1950 * iwlist & iwconfig command shows frequency into proper
1951 * format (2.412 GHz instead of 246.2 MHz)*/
1952 fwrq->m = freq;
1953 fwrq->e = MHZ;
1954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 }
1956 }
1957 else
1958 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001959 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1960 * iwlist & iwconfig command shows frequency into proper
1961 * format (2.412 GHz instead of 246.2 MHz)*/
1962 fwrq->m = 0;
1963 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301965
1966 EXIT();
1967 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001968}
1969
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301970static int iw_get_freq(struct net_device *dev,
1971 struct iw_request_info *info,
1972 struct iw_freq *fwrq, char *extra)
1973{
1974 int ret;
1975
1976 vos_ssr_protect(__func__);
1977 ret = __iw_get_freq(dev, info, fwrq, extra);
1978 vos_ssr_unprotect(__func__);
1979
1980 return ret;
1981}
1982
1983static int __iw_get_tx_power(struct net_device *dev,
1984 struct iw_request_info *info,
1985 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001986{
1987
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301988 hdd_adapter_t *pAdapter;
1989 hdd_context_t *pHddCtx;
1990 hdd_station_ctx_t *pHddStaCtx;
1991 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001992
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301993 ENTER();
1994
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301995 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1996 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1999 "%s: Adapter is NULL",__func__);
2000 return -EINVAL;
2001 }
2002 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2003 ret = wlan_hdd_validate_context(pHddCtx);
2004 if (0 != ret)
2005 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302006 return ret;
2007 }
2008
2009 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2010 if (NULL == pHddStaCtx)
2011 {
2012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2013 "%s: STA Context is NULL",__func__);
2014 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 }
2016
2017 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2018 {
2019 wrqu->txpower.value = 0;
2020 return 0;
2021 }
2022 wlan_hdd_get_classAstats(pAdapter);
2023 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2024
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302025 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 return 0;
2027}
2028
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302029static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 struct iw_request_info *info,
2031 union iwreq_data *wrqu, char *extra)
2032{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302033 int ret;
2034
2035 vos_ssr_protect(__func__);
2036 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2037 vos_ssr_unprotect(__func__);
2038
2039 return ret;
2040}
2041
2042static int __iw_set_tx_power(struct net_device *dev,
2043 struct iw_request_info *info,
2044 union iwreq_data *wrqu, char *extra)
2045{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302046 hdd_adapter_t *pAdapter;
2047 tHalHandle hHal;
2048 hdd_context_t *pHddCtx;
2049 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002050
2051 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302052 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2053 if (NULL == pAdapter)
2054 {
2055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2056 "%s: Adapter is NULL",__func__);
2057 return -EINVAL;
2058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002059
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302060 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2061 ret = wlan_hdd_validate_context(pHddCtx);
2062 if (0 != ret)
2063 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302064 return ret;
2065 }
2066
2067 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2068 if (NULL == hHal)
2069 {
2070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2071 "%s: Hal Context is NULL",__func__);
2072 return -EINVAL;
2073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2075 {
c_hpothub8245442013-11-20 23:41:09 +05302076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2077 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 return -EIO;
2079 }
2080
2081 EXIT();
2082
2083 return 0;
2084}
2085
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302086static int iw_set_tx_power(struct net_device *dev,
2087 struct iw_request_info *info,
2088 union iwreq_data *wrqu, char *extra)
2089{
2090 int ret;
2091
2092 vos_ssr_protect(__func__);
2093 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2094 vos_ssr_unprotect(__func__);
2095
2096 return ret;
2097}
2098
2099static int __iw_get_bitrate(struct net_device *dev,
2100 struct iw_request_info *info,
2101 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002102{
2103 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2104 eHalStatus status = eHAL_STATUS_SUCCESS;
2105 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302106 hdd_adapter_t *pAdapter;
2107 hdd_context_t *pHddCtx;
2108 hdd_station_ctx_t *pHddStaCtx;
2109 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002110
2111 ENTER();
2112
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302113 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2114 if (NULL == pAdapter)
2115 {
2116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2117 "%s: Adapter is NULL",__func__);
2118 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 }
2120
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302121 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2122 ret = wlan_hdd_validate_context(pHddCtx);
2123 if (0 != ret)
2124 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302125 return ret;
2126 }
2127
2128 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2129 if (NULL == pHddStaCtx)
2130 {
2131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2132 "%s: STA Context is NULL",__func__);
2133 return -EINVAL;
2134 }
2135
2136 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 wrqu->bitrate.value = 0;
2138 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302139 else
2140 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2142 SME_SUMMARY_STATS |
2143 SME_GLOBAL_CLASSA_STATS |
2144 SME_GLOBAL_CLASSB_STATS |
2145 SME_GLOBAL_CLASSC_STATS |
2146 SME_GLOBAL_CLASSD_STATS |
2147 SME_PER_STA_STATS,
2148 hdd_StatisticsCB, 0, FALSE,
2149 pHddStaCtx->conn_info.staId[0], pAdapter );
2150
2151 if(eHAL_STATUS_SUCCESS != status)
2152 {
2153 hddLog(VOS_TRACE_LEVEL_ERROR,
2154 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002155 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 return status;
2157 }
2158
2159 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302160 if (NULL == pWextState)
2161 {
2162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2163 "%s: pWextState is NULL",__func__);
2164 return -EINVAL;
2165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002166
2167 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2168
2169 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2170 {
2171 hddLog(VOS_TRACE_LEVEL_ERROR,
2172 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002173 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 return VOS_STATUS_E_FAILURE;
2175 }
2176
2177 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2178 }
2179
2180 EXIT();
2181
2182 return vos_status;
2183}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302184
2185static int iw_get_bitrate(struct net_device *dev,
2186 struct iw_request_info *info,
2187 union iwreq_data *wrqu, char *extra)
2188{
2189 int ret;
2190
2191 vos_ssr_protect(__func__);
2192 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2193 vos_ssr_unprotect(__func__);
2194
2195 return ret;
2196}
2197
2198
Jeff Johnson295189b2012-06-20 16:38:30 -07002199/* ccm call back function */
2200
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302201static int __iw_set_bitrate(struct net_device *dev,
2202 struct iw_request_info *info,
2203 union iwreq_data *wrqu,
2204 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002205{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302206 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302208 hdd_station_ctx_t *pHddStaCtx;
2209 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2211 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2212 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2213 v_U32_t i, rate;
2214 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302215 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002216
2217 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302218 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2219 if (NULL == pAdapter)
2220 {
2221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2222 "%s: Adapter is NULL",__func__);
2223 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 }
2225
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302226 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2227 ret = wlan_hdd_validate_context(pHddCtx);
2228 if (0 != ret)
2229 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302230 return ret;
2231 }
2232
2233 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2234 if (NULL == pHddStaCtx)
2235 {
2236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2237 "%s: STA Context is NULL",__func__);
2238 return -EINVAL;
2239 }
2240
2241
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302243 if (NULL == pWextState)
2244 {
2245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2246 "%s: pWextState is NULL",__func__);
2247 return -EINVAL;
2248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002249
2250 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2251 {
2252 return -ENXIO ;
2253 }
2254
2255 rate = wrqu->bitrate.value;
2256
2257 if (rate == -1)
2258 {
2259 rate = WNI_CFG_FIXED_RATE_AUTO;
2260 valid_rate = TRUE;
2261 }
2262 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2263 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2264 {
2265 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2266 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2267 {
2268 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2269 WNI_CFG_SUPPORTED_RATES_11A,
2270 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2271 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2272 WNI_CFG_SUPPORTED_RATES_11B,
2273 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2274 {
2275 for (i = 0; i < (b_len + a_len); ++i)
2276 {
2277 /* supported rates returned is double the actual rate so we divide it by 2 */
2278 if ((supp_rates[i]&0x7F)/2 == rate)
2279 {
2280 valid_rate = TRUE;
2281 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2282 break;
2283 }
2284 }
2285 }
2286 }
2287 }
2288 if (valid_rate != TRUE)
2289 {
2290 return -EINVAL;
2291 }
2292 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2293 WNI_CFG_FIXED_RATE, rate,
2294 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2295 {
c_hpothub8245442013-11-20 23:41:09 +05302296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2297 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 return -EIO;
2299 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302300
2301 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 return 0;
2303}
2304
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302305static int iw_set_bitrate(struct net_device *dev,
2306 struct iw_request_info *info,
2307 union iwreq_data *wrqu,
2308 char *extra)
2309{
2310 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002311
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302312 vos_ssr_protect(__func__);
2313 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2314 vos_ssr_unprotect(__func__);
2315
2316 return ret;
2317}
2318
2319static int __iw_set_genie(struct net_device *dev,
2320 struct iw_request_info *info,
2321 union iwreq_data *wrqu,
2322 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002323{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302324 hdd_adapter_t *pAdapter;
2325 hdd_context_t *pHddCtx;
2326 hdd_wext_state_t *pWextState;
2327 u_int8_t *genie = NULL;
2328 u_int8_t *base_genie = NULL;
2329 v_U16_t remLen;
2330 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002331
2332 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002333
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302334 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2335 if (NULL == pAdapter)
2336 {
2337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2338 "%s: Adapter is NULL",__func__);
2339 return -EINVAL;
2340 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002341
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302342 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2343 ret = wlan_hdd_validate_context(pHddCtx);
2344 if (0 != ret)
2345 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302346 return ret;
2347 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002348
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302349 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2350 if (NULL == pWextState)
2351 {
2352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2353 "%s: pWextState is NULL",__func__);
2354 return -EINVAL;
2355 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002356
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302357 if (!wrqu->data.length) {
2358 hdd_clearRoamProfileIe(pAdapter);
2359 EXIT();
2360 return 0;
2361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002362
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302363 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2364 wrqu->data.length);
2365 if (NULL == base_genie)
2366 {
2367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2368 "mem_alloc_copy_from_user_helper fail");
2369 return -ENOMEM;
2370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002371
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302372 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002373
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302374 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002375
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302376 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2377
2378 /* clear any previous genIE before this call */
2379 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2380
2381 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 {
2383 v_U16_t eLen = 0;
2384 v_U8_t elementId;
2385 elementId = *genie++;
2386 eLen = *genie++;
2387 remLen -= 2;
2388
Arif Hussain6d2a3322013-11-17 19:50:10 -08002389 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 __func__, elementId, eLen);
2391
2392 switch ( elementId )
2393 {
2394 case IE_EID_VENDOR:
2395 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002396 {
2397 kfree(base_genie);
2398 return -EINVAL;
2399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002400
2401 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2402 {
2403 v_U16_t curGenIELen = pWextState->genIE.length;
2404 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2405 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2406
2407 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2408 {
2409 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002410 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002412 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 return -ENOMEM;
2414 }
2415 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2416 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2417 pWextState->genIE.length += eLen + 2;
2418 }
2419 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2420 {
2421 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2422 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2423 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2424 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2425 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2426 }
2427 else /* any vendorId except WPA IE should be accumulated to genIE */
2428 {
2429 v_U16_t curGenIELen = pWextState->genIE.length;
2430 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2431 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2432
2433 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2434 {
2435 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002436 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002438 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 return -ENOMEM;
2440 }
2441 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2442 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2443 pWextState->genIE.length += eLen + 2;
2444 }
2445 break;
2446 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002447 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2449 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2450 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2451 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2452 break;
2453
2454 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002455 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002456 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 return 0;
2458 }
2459 genie += eLen;
2460 remLen -= eLen;
2461 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302462
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002464 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 return 0;
2466}
2467
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302468static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 struct iw_request_info *info,
2470 union iwreq_data *wrqu,
2471 char *extra)
2472{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302473 int ret;
2474
2475 vos_ssr_protect(__func__);
2476 ret = __iw_set_genie(dev, info, wrqu, extra);
2477 vos_ssr_unprotect(__func__);
2478
2479 return ret;
2480}
2481
2482static int __iw_get_genie(struct net_device *dev,
2483 struct iw_request_info *info,
2484 union iwreq_data *wrqu,
2485 char *extra)
2486{
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302488 hdd_context_t *pHddCtx;
2489 hdd_adapter_t *pAdapter;
2490 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 eHalStatus status;
2492 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2493 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2494
2495 ENTER();
2496
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302497 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2498 if (NULL == pAdapter)
2499 {
2500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2501 "%s: Adapter is NULL",__func__);
2502 return -EINVAL;
2503 }
2504 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2505 status = wlan_hdd_validate_context(pHddCtx);
2506 if (0 != status)
2507 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302508 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 }
2510
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302512 if (NULL == pWextState)
2513 {
2514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2515 "%s: pWextState is NULL",__func__);
2516 return -EINVAL;
2517 }
2518
2519 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2520 if (NULL == pHddStaCtx)
2521 {
2522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2523 "%s: STA Context is NULL",__func__);
2524 return -EINVAL;
2525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002526
2527 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2528 {
2529 return -ENXIO;
2530 }
2531
2532 // Return something ONLY if we are associated with an RSN or WPA network
2533 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2534 pWextState->roamProfile.negotiatedAuthType))
2535 {
2536 return -ENXIO;
2537 }
2538
2539 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2540 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2541 pAdapter->sessionId,
2542 &length,
2543 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002544 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2545 if (wrqu->data.length < length)
2546 {
2547 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2548 return -EFAULT;
2549 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002550 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002551 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002552
Arif Hussain6d2a3322013-11-17 19:50:10 -08002553 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002554
2555 EXIT();
2556
2557 return 0;
2558}
2559
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302560static int iw_get_genie(struct net_device *dev,
2561 struct iw_request_info *info,
2562 union iwreq_data *wrqu,
2563 char *extra)
2564{
2565 int ret;
2566
2567 vos_ssr_protect(__func__);
2568 ret = __iw_get_genie(dev, info, wrqu, extra);
2569 vos_ssr_unprotect(__func__);
2570
2571 return ret;
2572}
2573
2574
2575static int __iw_get_encode(struct net_device *dev,
2576 struct iw_request_info *info,
2577 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002578{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302579 hdd_adapter_t *pAdapter;
2580 hdd_context_t *pHddCtx;
2581 hdd_wext_state_t *pWextState;
2582 tCsrRoamProfile *pRoamProfile;
2583 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002585
2586 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302587 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2588 if (NULL == pAdapter)
2589 {
2590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2591 "%s: Adapter is NULL",__func__);
2592 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 }
2594
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302595 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2596 ret = wlan_hdd_validate_context(pHddCtx);
2597 if (0 != ret)
2598 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302599 return ret;
2600 }
2601 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2602 if (NULL == pWextState)
2603 {
2604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2605 "%s: pWextState is NULL",__func__);
2606 return -EINVAL;
2607 }
2608
2609 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 keyId = pRoamProfile->Keys.defaultIndex;
2611
2612 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2613 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002614 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 return -EINVAL;
2616 }
2617
2618 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2619 {
2620 dwrq->flags |= IW_ENCODE_ENABLED;
2621 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2622 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2623
2624 dwrq->flags |= (keyId + 1);
2625
2626 }
2627 else
2628 {
2629 dwrq->flags |= IW_ENCODE_DISABLED;
2630 }
2631
2632 for(i=0; i < MAX_WEP_KEYS; i++)
2633 {
2634 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2635 {
2636 continue;
2637 }
2638 else
2639 {
2640 break;
2641 }
2642 }
2643
2644 if(MAX_WEP_KEYS == i)
2645 {
2646 dwrq->flags |= IW_ENCODE_NOKEY;
2647 }
2648
2649 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2650
2651 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2652 {
2653 dwrq->flags |= IW_ENCODE_OPEN;
2654 }
2655 else
2656 {
2657 dwrq->flags |= IW_ENCODE_RESTRICTED;
2658 }
2659 EXIT();
2660 return 0;
2661}
2662
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302663static int iw_get_encode(struct net_device *dev,
2664 struct iw_request_info *info,
2665 struct iw_point *dwrq, char *extra)
2666{
2667 int ret;
2668
2669 vos_ssr_protect(__func__);
2670 ret = __iw_get_encode(dev, info, dwrq, extra);
2671 vos_ssr_unprotect(__func__);
2672
2673 return ret;
2674}
2675
Jeff Johnson295189b2012-06-20 16:38:30 -07002676#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2677#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2678
2679
2680/*
2681 * This function sends a single 'key' to LIM at all time.
2682 */
2683
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302684static int __iw_get_rts_threshold(struct net_device *dev,
2685 struct iw_request_info *info,
2686 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002687{
2688 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2689 v_U32_t status = 0;
2690
2691 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2692
2693 return status;
2694}
2695
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302696static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 struct iw_request_info *info,
2698 union iwreq_data *wrqu, char *extra)
2699{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302700 int ret;
2701
2702 vos_ssr_protect(__func__);
2703 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2704 vos_ssr_unprotect(__func__);
2705
2706 return ret;
2707}
2708
2709static int __iw_set_rts_threshold(struct net_device *dev,
2710 struct iw_request_info *info,
2711 union iwreq_data *wrqu, char *extra)
2712{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302713 hdd_adapter_t *pAdapter;
2714 hdd_context_t *pHddCtx;
2715 tHalHandle hHal;
2716 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002717
2718 ENTER();
2719
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302720 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2721 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002722 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2724 "%s: Adapter is NULL",__func__);
2725 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002726 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302727
2728 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2729 ret = wlan_hdd_validate_context(pHddCtx);
2730 if (0 != ret)
2731 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302732 return ret;
2733 }
2734
2735 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2736 if (NULL == hHal)
2737 {
2738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2739 "%s: Hal Context is NULL",__func__);
2740 return -EINVAL;
2741 }
2742
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2744 {
2745 return -EINVAL;
2746 }
2747
2748 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2749 {
c_hpothub8245442013-11-20 23:41:09 +05302750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2751 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002752 return -EIO;
2753 }
2754
2755 EXIT();
2756
2757 return 0;
2758}
2759
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302760static int iw_set_rts_threshold(struct net_device *dev,
2761 struct iw_request_info *info,
2762 union iwreq_data *wrqu, char *extra)
2763{
2764 int ret;
2765
2766 vos_ssr_protect(__func__);
2767 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2768 vos_ssr_unprotect(__func__);
2769
2770 return ret;
2771}
2772
2773static int __iw_get_frag_threshold(struct net_device *dev,
2774 struct iw_request_info *info,
2775 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002776{
2777 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2778 v_U32_t status = 0;
2779
2780 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2781
2782 return status;
2783}
2784
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302785static int iw_get_frag_threshold(struct net_device *dev,
2786 struct iw_request_info *info,
2787 union iwreq_data *wrqu, char *extra)
2788{
2789 int ret;
2790
2791 vos_ssr_protect(__func__);
2792 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2793 vos_ssr_unprotect(__func__);
2794
2795 return ret;
2796}
2797
2798static int __iw_set_frag_threshold(struct net_device *dev,
2799 struct iw_request_info *info,
2800 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002801{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302802 hdd_adapter_t *pAdapter;
2803 hdd_context_t *pHddCtx;
2804 tHalHandle hHal;
2805 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002806
2807 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302808 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2809 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002810 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2812 "%s: Adapter is NULL",__func__);
2813 return -EINVAL;
2814 }
2815
2816 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2817 ret = wlan_hdd_validate_context(pHddCtx);
2818 if (0 != ret)
2819 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302820 return ret;
2821 }
2822
2823 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2824 if (NULL == hHal)
2825 {
2826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2827 "%s: Hal Context is NULL",__func__);
2828 return -EINVAL;
2829 }
2830
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2832 {
2833 return -EINVAL;
2834 }
2835
2836 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2837 {
c_hpothub8245442013-11-20 23:41:09 +05302838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2839 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 return -EIO;
2841 }
2842
2843 EXIT();
2844
2845 return 0;
2846}
2847
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302848static int iw_set_frag_threshold(struct net_device *dev,
2849 struct iw_request_info *info,
2850 union iwreq_data *wrqu, char *extra)
2851{
2852 int ret;
2853
2854 vos_ssr_protect(__func__);
2855 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2856 vos_ssr_unprotect(__func__);
2857
2858 return ret;
2859}
2860
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302861static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 struct iw_request_info *info,
2863 union iwreq_data *wrqu, char *extra)
2864{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302865 hdd_adapter_t *pAdapter;
2866 hdd_context_t *pHddCtx;
2867 int ret = 0;
2868
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302870 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2871 if (NULL == pAdapter)
2872 {
2873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2874 "%s: Adapter is NULL",__func__);
2875 return -EINVAL;
2876 }
2877 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2878 ret = wlan_hdd_validate_context(pHddCtx);
2879 if (0 != ret)
2880 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302881 return ret;
2882 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302883
2884 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 return -EOPNOTSUPP;
2886}
2887
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302888static int iw_get_power_mode(struct net_device *dev,
2889 struct iw_request_info *info,
2890 union iwreq_data *wrqu, char *extra)
2891{
2892 int ret;
2893
2894 vos_ssr_protect(__func__);
2895 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2896 vos_ssr_unprotect(__func__);
2897
2898 return ret;
2899}
2900static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 struct iw_request_info *info,
2902 union iwreq_data *wrqu, char *extra)
2903{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302904 hdd_adapter_t *pAdapter;
2905 hdd_context_t *pHddCtx;
2906 int ret = 0;
2907
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302909 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2910 if (NULL == pAdapter)
2911 {
2912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2913 "%s: Adapter is NULL",__func__);
2914 return -EINVAL;
2915 }
2916 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2917 ret = wlan_hdd_validate_context(pHddCtx);
2918 if (0 != ret)
2919 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302920 return ret;
2921 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302922
2923 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 return -EOPNOTSUPP;
2925}
2926
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302927static int iw_set_power_mode(struct net_device *dev,
2928 struct iw_request_info *info,
2929 union iwreq_data *wrqu, char *extra)
2930{
2931 int ret;
2932
2933 vos_ssr_protect(__func__);
2934 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2935 vos_ssr_unprotect(__func__);
2936
2937 return ret;
2938}
2939
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302940static int __iw_get_range(struct net_device *dev,
2941 struct iw_request_info *info,
2942 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002943{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302944 hdd_adapter_t *pAdapter;
2945 tHalHandle hHal;
2946 hdd_context_t *pHddCtx;
2947 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 struct iw_range *range = (struct iw_range *) extra;
2949
2950 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2951
2952 v_U32_t num_channels = sizeof(channels);
2953 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2954 v_U32_t a_len;
2955 v_U32_t b_len;
2956 v_U32_t active_phy_mode = 0;
2957 v_U8_t index = 0, i;
2958
2959 ENTER();
2960
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302961 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2962 if (NULL == pAdapter)
2963 {
2964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2965 "%s: pAdapter is NULL", __func__);
2966 return -EINVAL;
2967 }
2968 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2969 ret = wlan_hdd_validate_context(pHddCtx);
2970 if (0 != ret)
2971 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302972 return ret;
2973 }
2974 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2975 if (NULL == hHal)
2976 {
2977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2978 "%s: pAdapter is NULL", __func__);
2979 return -EINVAL;
2980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 wrqu->data.length = sizeof(struct iw_range);
2982 memset(range, 0, sizeof(struct iw_range));
2983
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 /*Get the phy mode*/
2985 if (ccmCfgGetInt(hHal,
2986 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2987 {
2988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002989 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002990
2991 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2992 {
2993 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002994 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 if (ccmCfgGetStr(hHal,
2996 WNI_CFG_SUPPORTED_RATES_11A,
2997 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2998 {
2999 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3000 {
3001 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3002 }
3003 for (i = 0; i < a_len; i++)
3004 {
3005 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3006 }
3007 range->num_bitrates = a_len;
3008 }
3009 else
3010 {
3011 return -EIO;
3012 }
3013 }
3014 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3015 {
3016 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003017 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 if (ccmCfgGetStr(hHal,
3019 WNI_CFG_SUPPORTED_RATES_11B,
3020 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3021 {
3022 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3023 {
3024 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3025 }
3026 for (i = 0; i < b_len; i++)
3027 {
3028 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3029 }
3030 range->num_bitrates = b_len;
3031 }
3032 else
3033 {
3034 return -EIO;
3035 }
3036 }
3037 }
3038
3039 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3040 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3041 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3042
3043 range->encoding_size[0] = 5;
3044 range->encoding_size[1] = 13;
3045 range->num_encoding_sizes = 2;
3046 range->max_encoding_tokens = MAX_WEP_KEYS;
3047
3048 // we support through Wireless Extensions 22
3049 range->we_version_compiled = WIRELESS_EXT;
3050 range->we_version_source = 22;
3051
3052 /*Supported Channels and Frequencies*/
3053 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3054 {
c_hpothub8245442013-11-20 23:41:09 +05303055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3056 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 return -EIO;
3058 }
3059 if (num_channels > IW_MAX_FREQUENCIES)
3060 {
3061 num_channels = IW_MAX_FREQUENCIES;
3062 }
3063
3064 range->num_channels = num_channels;
3065 range->num_frequency = num_channels;
3066
3067 for (index=0; index < num_channels; index++)
3068 {
3069 v_U32_t frq_indx = 0;
3070
3071 range->freq[index].i = channels[index];
3072 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3073 {
3074 if(channels[index] == freq_chan_map[frq_indx].chan)
3075 {
3076 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3077 range->freq[index].e = 1;
3078 break;
3079 }
3080 frq_indx++;
3081 }
3082 }
3083
3084 /* Event capability (kernel + driver) */
3085 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3086 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3087 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3088 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3089
3090 /*Encryption capability*/
3091 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3092 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3093
3094 /* Txpower capability */
3095 range->txpower_capa = IW_TXPOW_MWATT;
3096
3097 /*Scanning capability*/
3098 #if WIRELESS_EXT >= 22
3099 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3100 #endif
3101
3102 EXIT();
3103 return 0;
3104}
3105
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303106static int iw_get_range(struct net_device *dev,
3107 struct iw_request_info *info,
3108 union iwreq_data *wrqu, char *extra)
3109{
3110 int ret;
3111
3112 vos_ssr_protect(__func__);
3113 ret = __iw_get_range(dev, info, wrqu, extra);
3114 vos_ssr_unprotect(__func__);
3115
3116 return ret;
3117}
3118
Jeff Johnson295189b2012-06-20 16:38:30 -07003119/* Callback function registered with PMC to know status of PMC request */
3120static void iw_power_callback_fn (void *pContext, eHalStatus status)
3121{
3122 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003123
3124 if (NULL == pContext)
3125 {
3126 hddLog(VOS_TRACE_LEVEL_ERROR,
3127 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003128 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 return;
3130 }
3131
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003133
Jeff Johnson72a40512013-12-19 10:14:15 -08003134 /* there is a race condition that exists between this callback
3135 function and the caller since the caller could time out either
3136 before or while this code is executing. we use a spinlock to
3137 serialize these actions */
3138 spin_lock(&hdd_context_lock);
3139
3140 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 {
3142 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003143 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003145 "%s: Invalid context, magic [%08x]",
3146 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003147
3148 if (ioctl_debug)
3149 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003150 pr_info("%s: Invalid context, magic [%08x]\n",
3151 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 }
3153 return;
3154 }
3155
Jeff Johnson72a40512013-12-19 10:14:15 -08003156 /* context is valid so caller is still waiting */
3157
3158 /* paranoia: invalidate the magic */
3159 pStatsContext->magic = 0;
3160
3161 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003163
3164 /* serialization is complete */
3165 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003166}
3167
3168/* Callback function for tx per hit */
3169void hdd_tx_per_hit_cb (void *pCallbackContext)
3170{
3171 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3172 unsigned char tx_fail[16];
3173 union iwreq_data wrqu;
3174
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303175 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003177 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 return;
3179 }
3180 memset(&wrqu, 0, sizeof(wrqu));
3181 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3182 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3183}
3184
3185void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3186{
3187 struct statsContext *pStatsContext;
3188 tCsrGlobalClassAStatsInfo *pClassAStats;
3189 hdd_adapter_t *pAdapter;
3190
3191 if (ioctl_debug)
3192 {
3193 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003194 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 }
3196
3197 if ((NULL == pStats) || (NULL == pContext))
3198 {
3199 hddLog(VOS_TRACE_LEVEL_ERROR,
3200 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003201 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 return;
3203 }
3204
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 pClassAStats = pStats;
3206 pStatsContext = pContext;
3207 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003208
3209 /* there is a race condition that exists between this callback
3210 function and the caller since the caller could time out either
3211 before or while this code is executing. we use a spinlock to
3212 serialize these actions */
3213 spin_lock(&hdd_context_lock);
3214
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3216 {
3217 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003218 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 hddLog(VOS_TRACE_LEVEL_WARN,
3220 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003221 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 if (ioctl_debug)
3223 {
3224 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003225 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 }
3227 return;
3228 }
3229
Jeff Johnson72a40512013-12-19 10:14:15 -08003230 /* context is valid so caller is still waiting */
3231
3232 /* paranoia: invalidate the magic */
3233 pStatsContext->magic = 0;
3234
3235 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003236 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3237
Jeff Johnson72a40512013-12-19 10:14:15 -08003238 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003240
3241 /* serialization is complete */
3242 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243}
3244
3245VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3246{
3247 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3248 eHalStatus hstatus;
3249 long lrc;
3250 struct statsContext context;
3251
3252 if (NULL == pAdapter)
3253 {
3254 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3255 return VOS_STATUS_E_FAULT;
3256 }
3257 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3258 {
3259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3260 return VOS_STATUS_SUCCESS;
3261 }
3262
3263 /* we are connected
3264 prepare our callback context */
3265 init_completion(&context.completion);
3266 context.pAdapter = pAdapter;
3267 context.magic = STATS_CONTEXT_MAGIC;
3268 /* query only for Class A statistics (which include link speed) */
3269 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3270 eCSR_HDD,
3271 SME_GLOBAL_CLASSA_STATS,
3272 hdd_GetClassA_statisticsCB,
3273 0, // not periodic
3274 FALSE, //non-cached results
3275 pHddStaCtx->conn_info.staId[0],
3276 &context);
3277 if (eHAL_STATUS_SUCCESS != hstatus)
3278 {
3279 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003280 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003281 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 /* we'll returned a cached value below */
3283 }
3284 else
3285 {
3286 /* request was sent -- wait for the response */
3287 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3288 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 if (lrc <= 0)
3290 {
3291 hddLog(VOS_TRACE_LEVEL_ERROR,
3292 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003293 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 }
3295 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003296
3297 /* either we never sent a request, we sent a request and received a
3298 response or we sent a request and timed out. if we never sent a
3299 request or if we sent a request and got a response, we want to
3300 clear the magic out of paranoia. if we timed out there is a
3301 race condition such that the callback function could be
3302 executing at the same time we are. of primary concern is if the
3303 callback function had already verified the "magic" but had not
3304 yet set the completion variable when a timeout occurred. we
3305 serialize these activities by invalidating the magic while
3306 holding a shared spinlock which will cause us to block if the
3307 callback is currently executing */
3308 spin_lock(&hdd_context_lock);
3309 context.magic = 0;
3310 spin_unlock(&hdd_context_lock);
3311
3312 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 return VOS_STATUS_SUCCESS;
3314}
3315
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003316static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3317{
3318 struct statsContext *pStatsContext;
3319 tCsrSummaryStatsInfo *pSummaryStats;
3320 tCsrGlobalClassAStatsInfo *pClassAStats;
3321 hdd_adapter_t *pAdapter;
3322
3323 if (ioctl_debug)
3324 {
3325 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003326 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003327 }
3328
3329 if ((NULL == pStats) || (NULL == pContext))
3330 {
3331 hddLog(VOS_TRACE_LEVEL_ERROR,
3332 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003333 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003334 return;
3335 }
3336
Jeff Johnson72a40512013-12-19 10:14:15 -08003337 /* there is a race condition that exists between this callback
3338 function and the caller since the caller could time out either
3339 before or while this code is executing. we use a spinlock to
3340 serialize these actions */
3341 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003342
3343 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3344 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3345 pStatsContext = pContext;
3346 pAdapter = pStatsContext->pAdapter;
3347 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3348 {
3349 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003350 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003351 hddLog(VOS_TRACE_LEVEL_WARN,
3352 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003353 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003354 if (ioctl_debug)
3355 {
3356 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003357 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003358 }
3359 return;
3360 }
3361
Jeff Johnson72a40512013-12-19 10:14:15 -08003362 /* context is valid so caller is still waiting */
3363
3364 /* paranoia: invalidate the magic */
3365 pStatsContext->magic = 0;
3366
3367 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003368 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3369 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3370
Jeff Johnson72a40512013-12-19 10:14:15 -08003371 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003372 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003373
3374 /* serialization is complete */
3375 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003376}
3377
3378VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3379{
3380 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3381 eHalStatus hstatus;
3382 long lrc;
3383 struct statsContext context;
3384
3385 if (NULL == pAdapter)
3386 {
3387 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3388 return VOS_STATUS_SUCCESS;
3389 }
3390
3391 /* we are connected
3392 prepare our callback context */
3393 init_completion(&context.completion);
3394 context.pAdapter = pAdapter;
3395 context.magic = STATS_CONTEXT_MAGIC;
3396
3397 /* query only for Summary & Class A statistics */
3398 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3399 eCSR_HDD,
3400 SME_SUMMARY_STATS |
Sushant Kaushik33200572015-08-05 16:46:20 +05303401 SME_GLOBAL_CLASSA_STATS |
3402 SME_PER_PKT_STATS,
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003403 hdd_get_station_statisticsCB,
3404 0, // not periodic
3405 FALSE, //non-cached results
3406 pHddStaCtx->conn_info.staId[0],
3407 &context);
3408 if (eHAL_STATUS_SUCCESS != hstatus)
3409 {
3410 hddLog(VOS_TRACE_LEVEL_ERROR,
3411 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003412 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003413 /* we'll return with cached values */
3414 }
3415 else
3416 {
3417 /* request was sent -- wait for the response */
3418 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3419 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003420
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003421 if (lrc <= 0)
3422 {
3423 hddLog(VOS_TRACE_LEVEL_ERROR,
3424 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003425 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003426 }
3427 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003428
3429 /* either we never sent a request, we sent a request and received a
3430 response or we sent a request and timed out. if we never sent a
3431 request or if we sent a request and got a response, we want to
3432 clear the magic out of paranoia. if we timed out there is a
3433 race condition such that the callback function could be
3434 executing at the same time we are. of primary concern is if the
3435 callback function had already verified the "magic" but had not
3436 yet set the completion variable when a timeout occurred. we
3437 serialize these activities by invalidating the magic while
3438 holding a shared spinlock which will cause us to block if the
3439 callback is currently executing */
3440 spin_lock(&hdd_context_lock);
3441 context.magic = 0;
3442 spin_unlock(&hdd_context_lock);
3443
3444 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003445 return VOS_STATUS_SUCCESS;
3446}
3447
3448
Jeff Johnson295189b2012-06-20 16:38:30 -07003449/*
3450 * Support for the LINKSPEED private command
3451 * Per the WiFi framework the response must be of the form
3452 * "LinkSpeed xx"
3453 */
3454static int iw_get_linkspeed(struct net_device *dev,
3455 struct iw_request_info *info,
3456 union iwreq_data *wrqu, char *extra)
3457{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303458 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303459 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303461 int len = sizeof(v_U32_t) + 1;
3462 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303463 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303464 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303465 int rc, valid = 0;
3466
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303467 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303468 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3469 if (NULL == pAdapter)
3470 {
3471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3472 "%s: Adapter is NULL",__func__);
3473 return -EINVAL;
3474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003475
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303476 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303477 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303478 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003479 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303480 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003481 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303482 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3483 if (NULL == pHddStaCtx)
3484 {
3485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3486 "%s: STA Context is NULL",__func__);
3487 return -EINVAL;
3488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3490 {
3491 /* we are not connected so we don't have a classAstats */
3492 link_speed = 0;
3493 }
3494 else
3495 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303496 status = wlan_hdd_get_classAstats(pAdapter);
3497
3498 if (!VOS_IS_STATUS_SUCCESS(status ))
3499 {
3500 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3501 return -EINVAL;
3502 }
3503
3504 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3505 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3506 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3507 &link_speed);
3508
3509 link_speed = link_speed / 10;
3510
3511 if (0 == link_speed)
3512 {
3513 /* The linkspeed returned by HAL is in units of 500kbps.
3514 * converting it to mbps.
3515 * This is required to support legacy firmware which does
3516 * not return link capacity.
3517 */
3518 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3519 }
3520
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 }
3522
3523 wrqu->data.length = len;
3524 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003525 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 if ((rc < 0) || (rc >= len))
3527 {
3528 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303529 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 return -EIO;
3531 }
3532
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303533 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003535 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003536}
3537
Arif Hussain695279c2014-03-24 14:06:07 -07003538/*
3539 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3540 *
3541 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303542static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003543 struct iw_request_info *info,
3544 union iwreq_data *wrqu, char *extra)
3545{
3546 int rc;
3547
3548 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3549
3550 if (rc < 0)
3551 return rc;
3552
3553 /* a value is being successfully returned */
3554 return 0;
3555}
Jeff Johnson295189b2012-06-20 16:38:30 -07003556
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303557static int iw_get_linkspeed_priv(struct net_device *dev,
3558 struct iw_request_info *info,
3559 union iwreq_data *wrqu, char *extra)
3560{
3561 int ret;
3562
3563 vos_ssr_protect(__func__);
3564 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3565 vos_ssr_unprotect(__func__);
3566
3567 return ret;
3568}
3569
Jeff Johnson295189b2012-06-20 16:38:30 -07003570/*
3571 * Support for the RSSI & RSSI-APPROX private commands
3572 * Per the WiFi framework the response must be of the form
3573 * "<ssid> rssi <xx>"
3574 * unless we are not associated, in which case the response is
3575 * "OK"
3576 */
3577static int iw_get_rssi(struct net_device *dev,
3578 struct iw_request_info *info,
3579 union iwreq_data *wrqu, char *extra)
3580{
3581 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003582 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 int len = wrqu->data.length;
3584 v_S7_t s7Rssi = 0;
3585 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3586 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3587 VOS_STATUS vosStatus;
3588 int rc;
3589
3590 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3591 (0 == ssidlen) || (ssidlen >= len))
3592 {
3593 /* we are not connected or our SSID is too long
3594 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003595 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 }
3597 else
3598 {
3599 /* we are connected with a valid SSID
3600 so we can write the SSID into the return buffer
3601 (note that it is not NUL-terminated) */
3602 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3603
3604 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3605
3606 if (VOS_STATUS_SUCCESS == vosStatus)
3607 {
3608 /* append the rssi to the ssid in the format required by
3609 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003610 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303611 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 }
3613 else
3614 {
3615 rc = -1;
3616 }
3617 }
3618
3619 /* verify that we wrote a valid response */
3620 if ((rc < 0) || (rc >= len))
3621 {
3622 // encoding or length error?
3623 hddLog(VOS_TRACE_LEVEL_ERROR,
3624 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003625 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 return -EIO;
3627 }
3628
3629 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003630 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003631}
3632
3633/*
3634 * Support for SoftAP channel range private command
3635 */
3636static int iw_softap_set_channel_range( struct net_device *dev,
3637 int startChannel,
3638 int endChannel,
3639 int band)
3640{
Jeff Johnson43971f52012-07-17 12:26:56 -07003641 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 int ret = 0;
3643 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3644 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003645 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3646
Jeff Johnson295189b2012-06-20 16:38:30 -07003647
3648 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3649 if (VOS_STATUS_SUCCESS != status)
3650 {
3651 ret = -EINVAL;
3652 }
Yathish9f22e662012-12-10 14:21:35 -08003653 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 return ret;
3655}
3656
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303657static uint8 chartohex(char c)
3658{
3659 uint8 val = 0;
3660 if (c >= '0' && c <= '9')
3661 val = c - '0';
3662 else if (c >= 'a' && c <= 'f')
3663 val = c - 'a' + 10;
3664 else if (c >= 'A' && c <= 'F')
3665 val = c - 'A' + 10;
3666 else
3667 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3668
3669 return val;
3670}
3671
3672uint8 getByte(char **buf)
3673{
3674 uint8 byte = 0;
3675 char *temp = *buf;
3676 byte = chartohex(*temp) * 16;
3677 temp++;
3678 byte += chartohex(*temp);
3679 temp++;
3680 *buf = temp;
3681 return byte;
3682}
3683
3684static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3685{
3686 tSir80211Header *macHeader;
3687 int i = 0, j = 0, length = 0;
3688 uint8 byte = 0;
3689 char *temp = pBuffer;
3690 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303691 char *pHeader;
3692 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303693
3694 macHeader = &pkt->macHeader;
3695
3696 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3697
3698 temp++;
3699
3700 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3701 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3702 pkt->encParams.keyParams.key[0].keyId);
3703
3704 for (i = 0; i< 16; i++) {
3705 pkt->encParams.keyParams.key[0].key[i]
3706 = getByte(&temp);
3707 }
3708
3709 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3710 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3711
3712 for (i = 0; i< 6; i++) {
3713 pkt->encParams.pn[i]
3714 = getByte(&temp);
3715 }
3716
3717 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3718 &pkt->encParams.pn[0], 6, 0);
3719
3720 for (i = 0, j= 5; i< 3; i++, j--) {
3721 byte = pkt->encParams.pn[i];
3722 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3723 pkt->encParams.pn[j] = byte;
3724 }
3725
3726 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303727 if (length > sizeof(tSir80211Header))
3728 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303729
Srinivas Dasari2382de62015-01-22 15:00:04 +05303730 pHeader = temp;
3731 vos_mem_zero(&header, sizeof(tSir80211Header));
3732 for (i = 0; i < length; i++) {
3733 *((uint8 *)&header + i) = getByte(&pHeader);
3734 }
3735
3736 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3737 (char *)&header, length, 0);
3738
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303739 byte = getByte(&temp);
3740
3741 macHeader->frameCtrl.protVer = byte & 0x3;
3742 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3743 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3744
3745 byte = getByte(&temp);
3746 macHeader->frameCtrl.toDS = (byte) & 0x1;
3747 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3748 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3749 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3750 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3751 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3752 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3753 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3754
3755 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3756 "macHeader->frameCtrl.type : %x "
3757 "macHeader->frameCtrl.subType : %x "
3758 "macHeader->frameCtrl.toDS : %x "
3759 "macHeader->frameCtrl.fromDS : %x "
3760 "macHeader->frameCtrl.moreFrag : %x "
3761 "macHeader->frameCtrl.retry : %x "
3762 "macHeader->frameCtrl.powerMgmt : %x "
3763 "macHeader->frameCtrl.MoreData : %x "
3764 "macHeader->frameCtrl.wep : %x "
3765 "macHeader->frameCtrl.order : %x "
3766 , macHeader->frameCtrl.protVer
3767 , macHeader->frameCtrl.type
3768 , macHeader->frameCtrl.subType
3769 , macHeader->frameCtrl.toDS
3770 , macHeader->frameCtrl.fromDS
3771 , macHeader->frameCtrl.moreFrag
3772 , macHeader->frameCtrl.retry
3773 , macHeader->frameCtrl.powerMgmt
3774 , macHeader->frameCtrl.moreData
3775 , macHeader->frameCtrl.wep
3776 , macHeader->frameCtrl.order);
3777
3778
3779 macHeader->usDurationId = getByte(&temp);
3780 macHeader->usDurationId += getByte(&temp) << 8;
3781
3782 macHeader->vA1[0] = getByte(&temp);
3783 macHeader->vA1[1] = getByte(&temp);
3784 macHeader->vA1[2] = getByte(&temp);
3785 macHeader->vA1[3] = getByte(&temp);
3786 macHeader->vA1[4] = getByte(&temp);
3787 macHeader->vA1[5] = getByte(&temp);
3788
3789 macHeader->vA2[0] = getByte(&temp);
3790 macHeader->vA2[1] = getByte(&temp);
3791 macHeader->vA2[2] = getByte(&temp);
3792 macHeader->vA2[3] = getByte(&temp);
3793 macHeader->vA2[4] = getByte(&temp);
3794 macHeader->vA2[5] = getByte(&temp);
3795
3796 macHeader->vA3[0] = getByte(&temp);
3797 macHeader->vA3[1] = getByte(&temp);
3798 macHeader->vA3[2] = getByte(&temp);
3799 macHeader->vA3[3] = getByte(&temp);
3800 macHeader->vA3[4] = getByte(&temp);
3801 macHeader->vA3[5] = getByte(&temp);
3802
3803 macHeader->sSeqCtrl = getByte(&temp);
3804 fragNum = macHeader->sSeqCtrl & 0xF;
3805 macHeader->sSeqCtrl >>= 4;
3806
3807 macHeader->sSeqCtrl += getByte(&temp) << 4;
3808
3809 macHeader->sSeqCtrl |= fragNum << 12;
3810
3811 if (length == 30 || length == 32) {
3812 macHeader->optvA4[0] = getByte(&temp);
3813 macHeader->optvA4[1] = getByte(&temp);
3814 macHeader->optvA4[2] = getByte(&temp);
3815 macHeader->optvA4[3] = getByte(&temp);
3816 macHeader->optvA4[4] = getByte(&temp);
3817 macHeader->optvA4[5] = getByte(&temp);
3818 }
3819
3820 if (length == 26 || length == 32) {
3821 macHeader->usQosCtrl = getByte(&temp);
3822 macHeader->usQosCtrl += getByte(&temp) << 8;
3823 }
3824
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303825 //parse payload
3826 length = getByte(&temp);
3827 length += getByte(&temp) << 8;
3828 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3829
3830 pkt->data.length = length;
3831
3832 for (i = 0; i< length; i++) {
3833 pkt->data.data[i] = getByte(&temp);
3834 }
3835
3836 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3837 &pkt->data.data[0], pkt->data.length, 0);
3838}
3839
3840/**---------------------------------------------------------------------------
3841
3842 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3843 encrypt message request
3844 This is an asynchronous callback function from SME when the encrypted data
3845 is received
3846
3847 \pEncInfoRsp -> Encrypted data info
3848
3849 \return - 0 for success non-zero for failure
3850 --------------------------------------------------------------------------*/
3851static void
3852hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3853{
3854 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3855
3856 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3857
3858 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3859 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3860 pEncryptedDataRsp->encryptedPayload.length);
3861 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3862 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3863 pEncryptedDataRsp->encryptedPayload.data,
3864 pEncryptedDataRsp->encryptedPayload.length, 0);
3865}
3866
Jeff Johnson295189b2012-06-20 16:38:30 -07003867VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3868{
3869 struct statsContext context;
3870 eHalStatus status;
3871 hdd_context_t *pHddCtx;
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303872 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003873
3874 if (NULL == pAdapter)
3875 {
3876 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3877 return VOS_STATUS_E_FAULT;
3878 }
3879
3880 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3881 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303882 if (pHddCtx->isLogpInProgress) {
3883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3884 "%s:LOGP in Progress. Ignore!!!", __func__);
3885 return VOS_STATUS_E_FAILURE;
3886 }
3887
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 init_completion(&context.completion);
3889
3890 context.pAdapter = pAdapter;
3891 context.magic = POWER_CONTEXT_MAGIC;
3892
3893 if (DRIVER_POWER_MODE_ACTIVE == mode)
3894 {
3895 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3896 "Full Power", __func__);
3897 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3898 iw_power_callback_fn, &context,
3899 eSME_FULL_PWR_NEEDED_BY_HDD);
3900 // Enter Full power command received from GUI this means we are disconnected
3901 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3902 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3903 if (eHAL_STATUS_PMC_PENDING == status)
3904 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003905 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 int lrc = wait_for_completion_interruptible_timeout(
3907 &context.completion,
3908 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003909
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 if (lrc <= 0)
3911 {
3912 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003913 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 }
3915 }
3916 }
3917 else if (DRIVER_POWER_MODE_AUTO == mode)
3918 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303919 /* If this is called by hdd_suspend_wlan or hdd_resume_wlan, driver
3920 * was already in BMPS state and thus either STA or P2P-CLI is in
3921 * associated state and authenticated, so even if STA connState is
3922 * not associated it can be assumed that P2P-CLI is associated and
3923 * authenticated. Thus driver can enter BMPS. And even if we try to enter
3924 * BMPS with no adaptor in associated state, pmcRequestBmps will check
3925 * if all condition are satisfied for entering BMPS.
3926 */
3927 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
3928 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303929 {
Abhishek Singh69c97a22015-10-23 15:42:45 +05303930 hddLog(LOGE,
3931 FL("Station is associated but, still not Authenticated ignore "
3932 "power save mode"));
Ganesh Kondabattiniea075782015-09-23 19:13:56 +05303933 return VOS_STATUS_E_AGAIN;
3934 }
3935
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3937 {
3938 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3939 __func__);
3940 // Enter BMPS command received from GUI this means DHCP is completed
3941 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3942 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3943 FALSE);
3944 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3945 iw_power_callback_fn, &context);
3946 if (eHAL_STATUS_PMC_PENDING == status)
3947 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003948 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 int lrc = wait_for_completion_interruptible_timeout(
3950 &context.completion,
3951 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 if (lrc <= 0)
3953 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003954 hddLog(VOS_TRACE_LEVEL_ERROR,
3955 "%s: SME %s while requesting BMPS",
3956 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 }
3958 }
3959 }
3960 else
3961 {
3962 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3963 "enabled in the cfg");
3964 }
3965 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003966
3967 /* either we never sent a request, we sent a request and received a
3968 response or we sent a request and timed out. if we never sent a
3969 request or if we sent a request and got a response, we want to
3970 clear the magic out of paranoia. if we timed out there is a
3971 race condition such that the callback function could be
3972 executing at the same time we are. of primary concern is if the
3973 callback function had already verified the "magic" but had not
3974 yet set the completion variable when a timeout occurred. we
3975 serialize these activities by invalidating the magic while
3976 holding a shared spinlock which will cause us to block if the
3977 callback is currently executing */
3978 spin_lock(&hdd_context_lock);
3979 context.magic = 0;
3980 spin_unlock(&hdd_context_lock);
3981
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 return VOS_STATUS_SUCCESS;
3983}
3984
3985VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3986 hdd_adapter_t *pAdapter)
3987{
3988 VOS_STATUS vos_Status;
3989
3990 if ((NULL == pAdapter) || (NULL == pHddCtx))
3991 {
3992 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3993 return VOS_STATUS_E_FAULT;
3994 }
3995
3996 /**Exit from Deep sleep or standby if we get the driver
3997 START cmd from android GUI
3998 */
3999 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4000 {
4001 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4002 "from Stand by",__func__);
4003 vos_Status = hdd_exit_standby(pHddCtx);
4004 }
4005 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4006 {
4007 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4008 "from deep sleep",__func__);
4009 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4010 }
4011 else
4012 {
4013 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4014 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4015 vos_Status = VOS_STATUS_SUCCESS;
4016 }
4017
4018 return vos_Status;
4019}
4020
4021VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4022{
4023 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4024
4025 if (NULL == pHddCtx)
4026 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304027 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 return VOS_STATUS_E_FAULT;
4029 }
4030
4031 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4032 {
4033 //Execute standby procedure.
4034 //Executing standby procedure will cause the STA to
4035 //disassociate first and then the chip will be put into standby.
4036 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4037 vos_Status = hdd_enter_standby(pHddCtx);
4038 }
4039 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4040 pHddCtx->cfg_ini->nEnableDriverStop)
4041 {
4042 //Execute deep sleep procedure
4043 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004044 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 //Deep sleep not supported
4046 vos_Status = hdd_enter_standby(pHddCtx);
4047 }
4048 else
4049 {
4050 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4051 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4052 vos_Status = VOS_STATUS_SUCCESS;
4053 }
4054
4055 return vos_Status;
4056}
4057
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004058
4059void* wlan_hdd_change_country_code_callback(void *pAdapter)
4060{
4061
4062 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004063 complete(&call_back_pAdapter->change_country_code);
4064
4065 return NULL;
4066}
4067
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304068static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 struct iw_request_info *info,
4070 union iwreq_data *wrqu, char *extra)
4071{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304072 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004073 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304075 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004076 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4077
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304078 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004079
4080 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304081
4082 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4083 if (NULL == pAdapter)
4084 {
4085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4086 "mem_alloc_copy_from_user_helper fail");
4087 return -EINVAL;
4088 }
4089 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4090 rc = wlan_hdd_validate_context(pHddCtx);
4091 if (0 != rc)
4092 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304093 return rc;
4094 }
4095
Arif Hussain24bfa702014-01-22 13:51:30 -08004096 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4097 wrqu->data.length);
4098 if (NULL == cmd)
4099 {
4100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4101 "mem_alloc_copy_from_user_helper fail");
4102 return -ENOMEM;
4103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004104
4105 if (ioctl_debug)
4106 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004107 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 }
4109
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004110 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4111 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004112
Arif Hussain24bfa702014-01-22 13:51:30 -08004113 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004115 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4117 "%s: Error in iw_set_scan!", __func__);
4118 rc = -EINVAL;
4119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 }
4121 else if( strcasecmp(cmd, "start") == 0 ) {
4122
Arif Hussain6d2a3322013-11-17 19:50:10 -08004123 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004125
Arif Hussain24bfa702014-01-22 13:51:30 -08004126 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4127 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 {
4129 union iwreq_data wrqu;
4130 char buf[10];
4131
4132 memset(&wrqu, 0, sizeof(wrqu));
4133 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4134 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4135 }
4136 else
4137 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004138 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4139 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 }
4141 goto done;
4142 }
4143 else if( strcasecmp(cmd, "stop") == 0 )
4144 {
4145 union iwreq_data wrqu;
4146 char buf[10];
4147
Arif Hussain6d2a3322013-11-17 19:50:10 -08004148 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004149
4150 wlan_hdd_enter_lowpower(pHddCtx);
4151 memset(&wrqu, 0, sizeof(wrqu));
4152 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4153 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 goto done;
4155 }
4156 else if (strcasecmp(cmd, "macaddr") == 0)
4157 {
4158 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4159 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4160 }
4161 else if (strcasecmp(cmd, "scan-active") == 0)
4162 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304163 hddLog(VOS_TRACE_LEVEL_ERROR,
4164 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004165 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 ret = snprintf(cmd, cmd_len, "OK");
4167 }
4168 else if (strcasecmp(cmd, "scan-passive") == 0)
4169 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304170 hddLog(VOS_TRACE_LEVEL_ERROR,
4171 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004172 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 ret = snprintf(cmd, cmd_len, "OK");
4174 }
4175 else if( strcasecmp(cmd, "scan-mode") == 0 )
4176 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004177 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 }
4179 else if( strcasecmp(cmd, "linkspeed") == 0 )
4180 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004181 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 }
4183 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4184 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004185 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004186 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004187
4188 country_code = cmd + 8;
4189
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004190 init_completion(&pAdapter->change_country_code);
4191
Arif Hussain24bfa702014-01-22 13:51:30 -08004192 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004193 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 country_code,
4195 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304196 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304197 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304198 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004199
4200 /* Wait for completion */
4201 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4202 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4203
4204 if (lrc <= 0)
4205 {
4206 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004207 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004208 }
4209
Arif Hussain24bfa702014-01-22 13:51:30 -08004210 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004211 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004212 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004213 "%s: SME Change Country code fail", __func__);
4214 kfree(cmd);
4215 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 }
4217 }
4218 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4219 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004220 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 }
4222 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4223 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004224 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004225
Wilson Yang1be3e652013-10-09 15:18:31 -07004226 if (9 < cmd_len)
4227 {
4228 ptr = (char*)(cmd + 9);
4229
4230 }else{
4231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4232 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004233 kfree(cmd);
4234 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004235 }
4236
4237 if (1 != sscanf(ptr,"%d",&mode))
4238 {
4239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4240 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004241 kfree(cmd);
4242 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004243 }
4244
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 wlan_hdd_enter_bmps(pAdapter, mode);
4246 /*TODO:Set the power mode*/
4247 }
4248 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4249 v_U32_t pmc_state;
4250 v_U16_t value;
4251
4252 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4253 if(pmc_state == BMPS) {
4254 value = DRIVER_POWER_MODE_AUTO;
4255 }
4256 else {
4257 value = DRIVER_POWER_MODE_ACTIVE;
4258 }
4259 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4260 }
4261 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004262 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 /*TODO: set the btcoexmode*/
4264 }
4265 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4266
Arif Hussain6d2a3322013-11-17 19:50:10 -08004267 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 /*TODO: Return the btcoex status*/
4269 }
4270 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4271
Arif Hussain6d2a3322013-11-17 19:50:10 -08004272 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004273
4274 /*TODO: Enable Rx data Filter*/
4275 }
4276 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4277
Arif Hussain6d2a3322013-11-17 19:50:10 -08004278 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004279
4280 /*TODO: Disable Rx data Filter*/
4281 }
4282 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4283
Arif Hussain6d2a3322013-11-17 19:50:10 -08004284 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 /*TODO: rxfilter-statistics*/
4286 }
4287 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4288
Arif Hussain6d2a3322013-11-17 19:50:10 -08004289 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 /*TODO: rxfilter-add*/
4291 }
4292 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4293
Arif Hussain6d2a3322013-11-17 19:50:10 -08004294 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 /*TODO: rxfilter-remove*/
4296 }
4297#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004298 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4299 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4300 /*TODO: support pnosetup*/
4301 }
4302 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4303 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4304 /*TODO: support pnoforce*/
4305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4307
Arif Hussain6d2a3322013-11-17 19:50:10 -08004308 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004309 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4310 kfree(cmd);
4311 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 }
4313 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004314 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004315 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4316 kfree(cmd);
4317 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 }
4319#endif /*FEATURE_WLAN_SCAN_PNO*/
4320 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004321 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004322 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4323 kfree(cmd);
4324 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 }
4326 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4327 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004328 char *ptr;
4329
4330 if (18 < cmd_len)
4331 {
4332 ptr = (char*)(cmd + 18);
4333 }else{
4334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4335 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004336 kfree(cmd);
4337 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004338 }
4339
Jeff Johnson02797792013-10-26 19:17:13 -07004340 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004341 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4342 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4343 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4344 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4345 {
4346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4347 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004348 kfree(cmd);
4349 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004351
4352 // parameters checking
4353 // period has to be larger than 0
4354 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4355 {
4356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004357 kfree(cmd);
4358 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 }
4360
4361 // use default value 5 is the input is not reasonable. in unit of 10%
4362 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4363 {
4364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4365 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4366 }
4367
4368 // default is 5
4369 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4370 {
4371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4372 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4373 }
4374
Arif Hussain24bfa702014-01-22 13:51:30 -08004375 if (eHAL_STATUS_SUCCESS !=
4376 sme_SetTxPerTracking(pHddCtx->hHal,
4377 hdd_tx_per_hit_cb,
4378 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004380 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 }
4382 }
4383 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004384 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4385 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 }
4387done:
4388 /* many of the commands write information back into the command
4389 string using snprintf(). check the return value here in one
4390 place */
4391 if ((ret < 0) || (ret >= cmd_len))
4392 {
4393 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004394 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004396 else if (ret > 0)
4397 {
4398 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4399 {
4400 hddLog(VOS_TRACE_LEVEL_ERROR,
4401 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004402 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004403 return -EFAULT;
4404 }
4405 wrqu->data.length = ret;
4406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004407
4408 if (ioctl_debug)
4409 {
4410 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004411 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004413 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304414 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004415 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004416}
4417
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304418static int iw_set_priv(struct net_device *dev,
4419 struct iw_request_info *info,
4420 union iwreq_data *wrqu, char *extra)
4421{
4422 int ret;
4423 vos_ssr_protect(__func__);
4424 ret = __iw_set_priv(dev, info, wrqu, extra);
4425 vos_ssr_unprotect(__func__);
4426
4427 return ret;
4428}
4429
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304430static int __iw_set_nick(struct net_device *dev,
4431 struct iw_request_info *info,
4432 union iwreq_data *wrqu, char *extra)
4433{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304434 hdd_adapter_t *pAdapter;
4435 hdd_context_t *pHddCtx;
4436 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304437
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304438 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304439
4440 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4441 if (NULL == pAdapter)
4442 {
4443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4444 "%s: Adapter is NULL",__func__);
4445 return -EINVAL;
4446 }
4447
4448 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4449 ret = wlan_hdd_validate_context(pHddCtx);
4450 if (0 != ret)
4451 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304452 return ret;
4453 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304454 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304455 return 0;
4456}
4457
Jeff Johnson295189b2012-06-20 16:38:30 -07004458static int iw_set_nick(struct net_device *dev,
4459 struct iw_request_info *info,
4460 union iwreq_data *wrqu, char *extra)
4461{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304462 int ret;
4463
4464 vos_ssr_protect(__func__);
4465 ret = __iw_set_nick(dev, info, wrqu, extra);
4466 vos_ssr_unprotect(__func__);
4467
4468 return ret;
4469}
4470
4471static int __iw_get_nick(struct net_device *dev,
4472 struct iw_request_info *info,
4473 union iwreq_data *wrqu, char *extra)
4474{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304475 hdd_adapter_t *pAdapter;
4476 hdd_context_t *pHddCtx;
4477 int ret = 0;
4478
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304480
4481 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4482 if (NULL == pAdapter)
4483 {
4484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4485 "%s: Adapter is NULL",__func__);
4486 return -EINVAL;
4487 }
4488
4489 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4490 ret = wlan_hdd_validate_context(pHddCtx);
4491 if (0 != ret)
4492 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304493 return ret;
4494 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304495 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 return 0;
4497}
4498
4499static int iw_get_nick(struct net_device *dev,
4500 struct iw_request_info *info,
4501 union iwreq_data *wrqu, char *extra)
4502{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304503 int ret;
4504
4505 vos_ssr_protect(__func__);
4506 ret = __iw_get_nick(dev, info, wrqu, extra);
4507 vos_ssr_unprotect(__func__);
4508
4509 return ret;
4510}
4511
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304512/* cat /proc/net/wireless invokes this function to get wireless stats */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304513static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4514{
Hanumantha Reddy Pothula55de0ea2015-10-19 16:50:53 +05304515 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4516 hdd_context_t *pHddCtx;
4517 hdd_station_ctx_t *pHddStaCtx;
4518 v_S7_t snr = 0, rssi = 0;
4519 eHalStatus status = eHAL_STATUS_SUCCESS;
4520
4521 ENTER();
4522
4523 if (NULL == pAdapter)
4524 {
4525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4526 "%s: Adapter is NULL",__func__);
4527 return NULL;
4528 }
4529
4530 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4531 status = wlan_hdd_validate_context(pHddCtx);
4532 if (0 != status)
4533 {
4534 return NULL;
4535 }
4536
4537 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4538 if (NULL == pHddStaCtx)
4539 {
4540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4541 "%s: STA Context is NULL",__func__);
4542 return NULL;
4543 }
4544
4545 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4546 {
4547 wlan_hdd_get_station_stats(pAdapter);
4548 wlan_hdd_get_snr(pAdapter, &snr);
4549 wlan_hdd_get_rssi(pAdapter, &rssi);
4550
4551 vos_mem_zero(&pAdapter->iwStats, sizeof(pAdapter->iwStats));
4552 pAdapter->iwStats.status = 0;
4553 pAdapter->iwStats.qual.qual = snr;
4554 pAdapter->iwStats.qual.level = rssi;
4555 pAdapter->iwStats.qual.noise = rssi - snr;
4556 pAdapter->iwStats.discard.code = 0;
4557 pAdapter->iwStats.discard.retries= 0;
4558 pAdapter->iwStats.miss.beacon = 0;
4559 pAdapter->iwStats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
4560 }
4561 else
4562 {
4563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4564 FL("not in associated state: %d"), pHddStaCtx->conn_info.connState);
4565 return NULL;
4566 }
4567
4568 EXIT();
4569 return &(pAdapter->iwStats);
Jeff Johnson295189b2012-06-20 16:38:30 -07004570}
4571
4572static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4573{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304574
4575 struct iw_statistics *stats;
4576
4577 vos_ssr_protect(__func__);
4578 stats = __get_wireless_stats(dev);
4579 vos_ssr_unprotect(__func__);
4580
4581 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004582}
4583
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304584static int __iw_set_encode(struct net_device *dev,
4585 struct iw_request_info *info,
4586 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004587
4588{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304589 hdd_adapter_t *pAdapter;
4590 hdd_station_ctx_t *pHddStaCtx;
4591 hdd_wext_state_t *pWextState;
4592 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 struct iw_point *encoderq = &(wrqu->encoding);
4594 v_U32_t keyId;
4595 v_U8_t key_length;
4596 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4597 v_BOOL_t fKeyPresent = 0;
4598 int i;
4599 eHalStatus status = eHAL_STATUS_SUCCESS;
4600
4601
4602 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304603 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4604 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4607 "%s: Adapter is NULL",__func__);
4608 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 }
4610
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4612 status = wlan_hdd_validate_context(pHddCtx);
4613 if (0 != status)
4614 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304615 return status;
4616 }
4617 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4618 if (NULL == pWextState)
4619 {
4620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4621 "%s: pWextState is NULL ",__func__);
4622 return -EINVAL;
4623 }
4624 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4625 if (NULL == pHddStaCtx)
4626 {
4627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4628 "%s: STA Context is NULL",__func__);
4629 return -EINVAL;
4630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004631
4632 keyId = encoderq->flags & IW_ENCODE_INDEX;
4633
4634 if(keyId)
4635 {
4636 if(keyId > MAX_WEP_KEYS)
4637 {
4638 return -EINVAL;
4639 }
4640
4641 fKeyPresent = 1;
4642 keyId--;
4643 }
4644 else
4645 {
4646 fKeyPresent = 0;
4647 }
4648
4649
4650 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4651 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 if(!fKeyPresent) {
4654
4655 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4656
4657 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4658 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4659 }
4660 }
4661 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4662 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4663 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4664 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4665
4666 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4667 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4668
4669 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4670 {
4671 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4672 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004673 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304674 {
4675 long ret;
4676 ret = wait_for_completion_interruptible_timeout(
4677 &pAdapter->disconnect_comp_var,
4678 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4679 if (ret <= 0)
4680 hddLog(VOS_TRACE_LEVEL_ERROR,
4681 FL("failed wait on disconnect_comp_var %ld"), ret);
4682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 }
4684
4685 return status;
4686
4687 }
4688
4689 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4690 {
4691 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4692
4693 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4694
4695 }
4696
4697
4698 if(wrqu->data.length > 0)
4699 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004700 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004701
4702 key_length = wrqu->data.length;
4703
4704 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4705
4706 if(5 == key_length)
4707 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004708 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004709
4710 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4711 {
4712 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4713 }
4714 else
4715 {
4716 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4717 }
4718 }
4719 else if(13 == key_length)
4720 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004721 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004722
4723 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4724 {
4725 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4726 }
4727 else
4728 {
4729 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4730 }
4731 }
4732 else
4733 {
4734 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004735 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 return -EINVAL;
4737 }
4738
4739 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4740 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4741 pWextState->roamProfile.EncryptionType.numEntries = 1;
4742 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4743 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4744 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4745
4746 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4747 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4748 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4749 {
4750
4751 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4752
4753 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4754 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4755
4756 return status;
4757 }
4758 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304759 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 return 0;
4761}
4762
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304763static int iw_set_encode(struct net_device *dev,
4764 struct iw_request_info *info,
4765 union iwreq_data *wrqu,char *extra)
4766{
4767 int ret;
4768
4769 vos_ssr_protect(__func__);
4770 ret = __iw_set_encode(dev, info, wrqu, extra);
4771 vos_ssr_unprotect(__func__);
4772
4773 return ret;
4774}
4775
4776static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 struct iw_request_info *info,
4778 struct iw_point *dwrq,
4779 char *extra)
4780{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304781 hdd_adapter_t *pAdapter;
4782 hdd_wext_state_t *pWextState;
4783 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 int keyId;
4785 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4786 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304787 int i, ret = 0;
4788 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004789
4790 ENTER();
4791
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304792 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4793 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004794 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4796 "%s: Adapter is NULL",__func__);
4797 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004798 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304799 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4800 ret = wlan_hdd_validate_context(pHddCtx);
4801 if (0 != ret)
4802 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304803 return ret;
4804 }
4805 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4806 if (NULL == pWextState)
4807 {
4808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4809 "%s: pWextState is NULL",__func__);
4810 return -EINVAL;
4811 }
4812 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004813
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 keyId = pRoamProfile->Keys.defaultIndex;
4815
4816 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4817 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004818 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 return -EINVAL;
4820 }
4821
4822 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4823 {
4824 dwrq->flags |= IW_ENCODE_ENABLED;
4825 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304826 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4827 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 }
4829 else
4830 {
4831 dwrq->flags |= IW_ENCODE_DISABLED;
4832 }
4833
4834 for(i=0; i < MAX_WEP_KEYS; i++)
4835 {
4836 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4837 {
4838 continue;
4839 }
4840 else
4841 {
4842 break;
4843 }
4844 }
4845
4846 if(MAX_WEP_KEYS == i)
4847 {
4848 dwrq->flags |= IW_ENCODE_NOKEY;
4849 }
4850 else
4851 {
4852 dwrq->flags |= IW_ENCODE_ENABLED;
4853 }
4854
4855 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4856
4857 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4858 {
4859 dwrq->flags |= IW_ENCODE_DISABLED;
4860 }
4861
4862 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4863
4864 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4865 {
4866 dwrq->flags |= IW_ENCODE_OPEN;
4867 }
4868 else
4869 {
4870 dwrq->flags |= IW_ENCODE_RESTRICTED;
4871 }
4872 EXIT();
4873 return 0;
4874
4875}
4876
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304877static int iw_get_encodeext(struct net_device *dev,
4878 struct iw_request_info *info,
4879 struct iw_point *dwrq,
4880 char *extra)
4881{
4882 int ret;
4883 vos_ssr_protect(__func__);
4884 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4885 vos_ssr_unprotect(__func__);
4886
4887 return ret;
4888}
4889
4890static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 struct iw_request_info *info,
4892 union iwreq_data *wrqu, char *extra)
4893{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304894 hdd_adapter_t *pAdapter;
4895 hdd_station_ctx_t *pHddStaCtx;
4896 hdd_wext_state_t *pWextState;
4897 hdd_context_t *pHddCtx;
4898 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004899
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304900 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 v_U32_t status = 0;
4902
4903 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4904
4905 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4906
4907 int key_index;
4908 struct iw_point *encoding = &wrqu->encoding;
4909 tCsrRoamSetKey setKey;
4910 v_U32_t roamId= 0xFF;
4911 VOS_STATUS vos_status;
4912
4913 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304914 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4915 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4918 "%s: Adapter is NULL",__func__);
4919 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304921 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4922 status = wlan_hdd_validate_context(pHddCtx);
4923 if (0 != status)
4924 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304925 return status;
4926 }
4927 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4928 if (NULL == pHddStaCtx)
4929 {
4930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4931 "%s: STA Context is NULL",__func__);
4932 return -EINVAL;
4933 }
4934 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4935 if (NULL == pWextState)
4936 {
4937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4938 "%s: pWextState is NULL",__func__);
4939 return -EINVAL;
4940 }
4941 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 key_index = encoding->flags & IW_ENCODE_INDEX;
4943
4944 if(key_index > 0) {
4945
4946 /*Convert from 1-based to 0-based keying*/
4947 key_index--;
4948 }
4949 if(!ext->key_len) {
4950
4951 /*Set the encrytion type to NONE*/
4952 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4953 return status;
4954 }
4955
4956 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4957 (IW_ENCODE_ALG_WEP == ext->alg))
4958 {
4959 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4960
Agarwal Ashish971c2882013-10-30 20:11:12 +05304961 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4962 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 return -EINVAL;
4964 }
4965 else {
4966 /*Static wep, update the roam profile with the keys */
4967 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4968 key_index < CSR_MAX_NUM_KEY) {
4969 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4970 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4971
4972 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4973 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4974
4975 }
4976 }
4977 return status;
4978 }
4979
4980 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4981
4982 setKey.keyId = key_index;
4983 setKey.keyLength = ext->key_len;
4984
4985 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4986 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4987 }
4988
4989 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4990 /*Key direction for group is RX only*/
4991 setKey.keyDirection = eSIR_RX_ONLY;
4992 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4993 }
4994 else {
4995
4996 setKey.keyDirection = eSIR_TX_RX;
4997 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4998 }
4999
5000 /*For supplicant pae role is zero*/
5001 setKey.paeRole = 0;
5002
5003 switch(ext->alg)
5004 {
5005 case IW_ENCODE_ALG_NONE:
5006 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5007 break;
5008
5009 case IW_ENCODE_ALG_WEP:
5010 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
5011 break;
5012
5013 case IW_ENCODE_ALG_TKIP:
5014 {
5015 v_U8_t *pKey = &setKey.Key[0];
5016
5017 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5018
5019 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5020
5021 /*Supplicant sends the 32bytes key in this order
5022
5023 |--------------|----------|----------|
5024 | Tk1 |TX-MIC | RX Mic |
5025 |--------------|----------|----------|
5026 <---16bytes---><--8bytes--><--8bytes-->
5027
5028 */
5029 /*Sme expects the 32 bytes key to be in the below order
5030
5031 |--------------|----------|----------|
5032 | Tk1 |RX-MIC | TX Mic |
5033 |--------------|----------|----------|
5034 <---16bytes---><--8bytes--><--8bytes-->
5035 */
5036 /* Copy the Temporal Key 1 (TK1) */
5037 vos_mem_copy(pKey,ext->key,16);
5038
5039 /*Copy the rx mic first*/
5040 vos_mem_copy(&pKey[16],&ext->key[24],8);
5041
5042 /*Copy the tx mic */
5043 vos_mem_copy(&pKey[24],&ext->key[16],8);
5044
5045 }
5046 break;
5047
5048 case IW_ENCODE_ALG_CCMP:
5049 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5050 break;
5051
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005052#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005053#define IW_ENCODE_ALG_KRK 6
5054 case IW_ENCODE_ALG_KRK:
5055 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5056 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005057#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005058
5059 default:
5060 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5061 break;
5062 }
5063
5064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005065 ("%s:cipher_alg:%d key_len[%d] *pEncryptionType :%d"),__func__,(int)ext->alg,(int)ext->key_len,setKey.encType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005066
5067#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305068 /* The supplicant may attempt to set the PTK once pre-authentication
5069 is done. Save the key in the UMAC and include it in the ADD
5070 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305072 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305074 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5075 "%s: Update PreAuth Key success", __func__);
5076 return 0;
5077 }
5078 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5079 {
5080 hddLog(VOS_TRACE_LEVEL_ERROR,
5081 "%s: Update PreAuth Key failed", __func__);
5082 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 }
5084#endif /* WLAN_FEATURE_VOWIFI_11R */
5085
5086 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5087
5088 vos_status = wlan_hdd_check_ula_done(pAdapter);
5089 if ( vos_status != VOS_STATUS_SUCCESS )
5090 {
5091 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5092 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5093 __LINE__, vos_status );
5094
5095 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5096 }
5097
5098 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5099
5100 if ( halStatus != eHAL_STATUS_SUCCESS )
5101 {
5102 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5103 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5104 __LINE__, halStatus );
5105
5106 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5107 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305108 EXIT();
5109 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005110}
5111
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305112static int iw_set_encodeext(struct net_device *dev,
5113 struct iw_request_info *info,
5114 union iwreq_data *wrqu, char *extra)
5115{
5116 int ret;
5117
5118 vos_ssr_protect(__func__);
5119 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5120 vos_ssr_unprotect(__func__);
5121
5122 return ret;
5123}
5124
5125static int __iw_set_retry(struct net_device *dev,
5126 struct iw_request_info *info,
5127 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005128{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305129 hdd_adapter_t *pAdapter;
5130 tHalHandle hHal;
5131 hdd_context_t *pHddCtx;
5132 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005133
5134 ENTER();
5135
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305136 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5137 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005138 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5140 "%s: Adapter is NULL",__func__);
5141 return -EINVAL;
5142 }
5143
5144 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5145 ret = wlan_hdd_validate_context(pHddCtx);
5146 if (0 != ret)
5147 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305148 return ret;
5149 }
5150
5151 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5152 if (NULL == hHal)
5153 {
5154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5155 "%s: Hal Context is NULL",__func__);
5156 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005157 }
5158
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5160 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5161
Arif Hussain6d2a3322013-11-17 19:50:10 -08005162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005163
5164 return -EINVAL;
5165 }
5166
5167 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5168
5169 if((wrqu->retry.flags & IW_RETRY_LONG))
5170 {
5171 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5172 {
c_hpothub8245442013-11-20 23:41:09 +05305173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5174 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005175 return -EIO;
5176 }
5177 }
5178 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5179 {
5180 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5181 {
c_hpothub8245442013-11-20 23:41:09 +05305182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5183 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 return -EIO;
5185 }
5186 }
5187 }
5188 else
5189 {
5190 return -EOPNOTSUPP;
5191 }
5192
Arif Hussain6d2a3322013-11-17 19:50:10 -08005193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005194
5195 EXIT();
5196
5197 return 0;
5198
5199}
5200
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305201static int iw_set_retry(struct net_device *dev,
5202 struct iw_request_info *info,
5203 union iwreq_data *wrqu, char *extra)
5204{
5205 int ret;
5206
5207 vos_ssr_protect(__func__);
5208 ret = __iw_set_retry(dev, info, wrqu, extra);
5209 vos_ssr_unprotect(__func__);
5210
5211 return ret;
5212}
5213
5214static int __iw_get_retry(struct net_device *dev,
5215 struct iw_request_info *info,
5216 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005217{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305218 hdd_adapter_t *pAdapter;
5219 hdd_context_t *pHddCtx;
5220 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305222 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005223
5224 ENTER();
5225
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305226 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5227 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005228 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5230 "%s: Adapter is NULL",__func__);
5231 return -EINVAL;
5232 }
5233
5234 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5235 ret = wlan_hdd_validate_context(pHddCtx);
5236 if (0 != ret)
5237 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305238 return ret;
5239 }
5240
5241 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5242 if (NULL == hHal)
5243 {
5244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5245 "%s: Hal Context is NULL",__func__);
5246 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005247 }
5248
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 if((wrqu->retry.flags & IW_RETRY_LONG))
5250 {
5251 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5252
5253 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5254 {
c_hpothub8245442013-11-20 23:41:09 +05305255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5256 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 return -EIO;
5258 }
5259
5260 wrqu->retry.value = retry;
5261 }
5262 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5263 {
5264 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5265
5266 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5267 {
c_hpothub8245442013-11-20 23:41:09 +05305268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5269 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 return -EIO;
5271 }
5272
5273 wrqu->retry.value = retry;
5274 }
5275 else {
5276 return -EOPNOTSUPP;
5277 }
5278
Arif Hussain6d2a3322013-11-17 19:50:10 -08005279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005280
5281 EXIT();
5282
5283 return 0;
5284}
5285
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305286static int iw_get_retry(struct net_device *dev,
5287 struct iw_request_info *info,
5288 union iwreq_data *wrqu, char *extra)
5289{
5290 int ret;
5291
5292 vos_ssr_protect(__func__);
5293 ret = __iw_get_retry(dev, info, wrqu, extra);
5294 vos_ssr_unprotect(__func__);
5295
5296 return ret;
5297}
5298
5299static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 struct iw_request_info *info,
5301 union iwreq_data *wrqu,
5302 char *extra)
5303{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305304 hdd_adapter_t *pAdapter;
5305 hdd_context_t *pHddCtx;
5306 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5308 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305309 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005310
5311 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305312 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5313 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5316 "%s:Adapter is NULL",__func__);
5317 return -EINVAL;
5318 }
5319 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5320 ret = wlan_hdd_validate_context(pHddCtx);
5321 if (0 != ret)
5322 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305323 return ret;
5324 }
5325 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5326 if (NULL == pHddStaCtx)
5327 {
5328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5329 "%s:STA context is NULL",__func__);
5330 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 }
5332
5333 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5334 switch (mlme->cmd) {
5335 case IW_MLME_DISASSOC:
5336 case IW_MLME_DEAUTH:
5337
5338 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5339 {
5340 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5341
5342 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5343 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5344
5345 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5346 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5347
Jeff Johnson43971f52012-07-17 12:26:56 -07005348 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305349 {
5350 long ret;
5351 ret = wait_for_completion_interruptible_timeout(
5352 &pAdapter->disconnect_comp_var,
5353 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5354 if (ret <= 0)
5355 hddLog(VOS_TRACE_LEVEL_ERROR,
5356 FL("failed wait on disconnect_comp_var %ld"), ret);
5357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005359 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005360 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005361
5362 /* Resetting authKeyMgmt */
5363 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5364
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305365 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 netif_tx_disable(dev);
5367 netif_carrier_off(dev);
5368
5369 }
5370 else
5371 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005372 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate called but station is not in associated state", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 }
5374 break;
5375 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005376 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 return -EINVAL;
5378 }//end of switch
5379
5380 EXIT();
5381
5382 return status;
5383
5384}
5385
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305386static int iw_set_mlme(struct net_device *dev,
5387 struct iw_request_info *info,
5388 union iwreq_data *wrqu,
5389 char *extra)
5390{
5391 int ret;
5392
5393 vos_ssr_protect(__func__);
5394 ret = __iw_set_mlme(dev, info, wrqu, extra);
5395 vos_ssr_unprotect(__func__);
5396
5397 return ret;
5398}
5399
Jeff Johnson295189b2012-06-20 16:38:30 -07005400/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305401static int __iw_setint_getnone(struct net_device *dev,
5402 struct iw_request_info *info,
5403 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005404{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305405 hdd_adapter_t *pAdapter;
5406 tHalHandle hHal;
5407 hdd_wext_state_t *pWextState;
5408 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305409 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 int *value = (int *)extra;
5411 int sub_cmd = value[0];
5412 int set_value = value[1];
5413 int ret = 0; /* success */
5414 int enable_pbm, enable_mp;
5415#ifdef CONFIG_HAS_EARLYSUSPEND
5416 v_U8_t nEnableSuspendOld;
5417#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005418
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305419 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305420 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5421 if (NULL == pAdapter)
5422 {
5423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5424 "%s: Adapter is NULL",__func__);
5425 return -EINVAL;
5426 }
5427 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5428 ret = wlan_hdd_validate_context(pHddCtx);
5429 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005430 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305431 return ret;
5432 }
Abhishek Singh2b055852015-10-07 14:14:13 +05305433
5434 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5435 if (NULL == hHal)
5436 {
5437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5438 "%s: Hal Context is NULL",__func__);
5439 return -EINVAL;
5440 }
5441
Katya Nigameae74b62015-05-28 17:19:16 +05305442 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305443 {
Katya Nigameae74b62015-05-28 17:19:16 +05305444 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5445 if (NULL == pWextState)
5446 {
5447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5448 "%s: pWextState is NULL",__func__);
5449 return -EINVAL;
5450 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005451
Katya Nigameae74b62015-05-28 17:19:16 +05305452 INIT_COMPLETION(pWextState->completion_var);
5453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 switch(sub_cmd)
5455 {
5456 case WE_SET_11D_STATE:
5457 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005458 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005459 memset(&smeConfig, 0x00, sizeof(smeConfig));
5460
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5462
5463 sme_GetConfigParam(hHal,&smeConfig);
5464 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5465
Arif Hussain6d2a3322013-11-17 19:50:10 -08005466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005467
5468 sme_UpdateConfig(hHal,&smeConfig);
5469 }
5470 else {
5471 return -EINVAL;
5472 }
5473 break;
5474 }
5475
5476 case WE_WOWL:
5477 {
5478 switch (set_value)
5479 {
5480 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305481 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 break;
5483 case 0x01:
5484 case 0x02:
5485 case 0x03:
5486 enable_mp = (set_value & 0x01) ? 1 : 0;
5487 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005488 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5490 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5491 break;
5492 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005493 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 ret = -EINVAL;
5495 break;
5496 }
5497
5498 break;
5499 }
5500 case WE_SET_POWER:
5501 {
5502 switch (set_value)
5503 {
5504 case 0: //Full Power
5505 {
5506 struct statsContext context;
5507 eHalStatus status;
5508
5509 init_completion(&context.completion);
5510
5511 context.pAdapter = pAdapter;
5512 context.magic = POWER_CONTEXT_MAGIC;
5513
5514 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5515 iw_power_callback_fn, &context,
5516 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005517 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 {
5519 int lrc = wait_for_completion_interruptible_timeout(
5520 &context.completion,
5521 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005522
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 if (lrc <= 0)
5524 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005525 hddLog(VOS_TRACE_LEVEL_ERROR,
5526 "%s: SME %s while requesting fullpower",
5527 __func__, (0 == lrc) ?
5528 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 }
5530 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005531 /* either we have a response or we timed out. if we timed
5532 out there is a race condition such that the callback
5533 function could be executing at the same time we are. of
5534 primary concern is if the callback function had already
5535 verified the "magic" but had not yet set the completion
5536 variable when a timeout occurred. we serialize these
5537 activities by invalidating the magic while holding a
5538 shared spinlock which will cause us to block if the
5539 callback is currently executing */
5540 spin_lock(&hdd_context_lock);
5541 context.magic = 0;
5542 spin_unlock(&hdd_context_lock);
5543
Arif Hussain6d2a3322013-11-17 19:50:10 -08005544 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 break;
5546 }
5547 case 1: //Enable BMPS
5548 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5549 break;
5550 case 2: //Disable BMPS
5551 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5552 break;
5553 case 3: //Request Bmps
5554 {
5555 struct statsContext context;
5556 eHalStatus status;
5557
5558 init_completion(&context.completion);
5559
5560 context.pAdapter = pAdapter;
5561 context.magic = POWER_CONTEXT_MAGIC;
5562
5563 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5564 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005565 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 {
5567 int lrc = wait_for_completion_interruptible_timeout(
5568 &context.completion,
5569 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 if (lrc <= 0)
5571 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005572 hddLog(VOS_TRACE_LEVEL_ERROR,
5573 "%s: SME %s while requesting BMPS",
5574 __func__, (0 == lrc) ? "timeout" :
5575 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 }
5577 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005578 /* either we have a response or we timed out. if we
5579 timed out there is a race condition such that the
5580 callback function could be executing at the same
5581 time we are. of primary concern is if the callback
5582 function had already verified the "magic" but had
5583 not yet set the completion variable when a timeout
5584 occurred. we serialize these activities by
5585 invalidating the magic while holding a shared
5586 spinlock which will cause us to block if the
5587 callback is currently executing */
5588 spin_lock(&hdd_context_lock);
5589 context.magic = 0;
5590 spin_unlock(&hdd_context_lock);
5591
Arif Hussain6d2a3322013-11-17 19:50:10 -08005592 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 break;
5594 }
5595 case 4: //Enable IMPS
5596 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5597 break;
5598 case 5: //Disable IMPS
5599 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5600 break;
5601 case 6: //Enable Standby
5602 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5603 break;
5604 case 7: //Disable Standby
5605 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5606 break;
5607 case 8: //Request Standby
5608#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005609#endif
5610 break;
5611 case 9: //Start Auto Bmps Timer
5612 sme_StartAutoBmpsTimer(hHal);
5613 break;
5614 case 10://Stop Auto BMPS Timer
5615 sme_StopAutoBmpsTimer(hHal);
5616 break;
5617#ifdef CONFIG_HAS_EARLYSUSPEND
5618 case 11://suspend to standby
5619#ifdef CONFIG_HAS_EARLYSUSPEND
5620 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5621 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5623#endif
5624 break;
5625 case 12://suspend to deep sleep
5626#ifdef CONFIG_HAS_EARLYSUSPEND
5627 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5628 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005629 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5630#endif
5631 break;
5632 case 13://resume from suspend
5633#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005634#endif
5635 break;
5636#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005638 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 ret = -EINVAL;
5640 break;
5641 }
5642 break;
5643 }
5644
5645 case WE_SET_MAX_ASSOC:
5646 {
5647 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5648 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5649 {
5650 ret = -EINVAL;
5651 }
5652 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5653 set_value, NULL, eANI_BOOLEAN_FALSE)
5654 != eHAL_STATUS_SUCCESS )
5655 {
c_hpothub8245442013-11-20 23:41:09 +05305656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5657 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 ret = -EIO;
5659 }
5660 break;
5661 }
5662
5663 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5664 {
5665 if( 0 == set_value )
5666 {
5667 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5668 }
5669 else if ( 1 == set_value )
5670 {
5671 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5672 }
5673 else
5674 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005675 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 ret = -EINVAL;
5677 }
5678 break;
5679 }
5680
5681 case WE_SET_DATA_INACTIVITY_TO:
5682 {
5683 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5684 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5685 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5686 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5687 set_value,
5688 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5689 {
5690 hddLog(LOGE,"Failure: Could not pass on "
5691 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005692 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 ret = -EINVAL;
5694 }
5695 break;
5696 }
5697 case WE_SET_MAX_TX_POWER:
5698 {
5699 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5700 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5701
5702 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5703 __func__, set_value);
5704 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5705 eHAL_STATUS_SUCCESS )
5706 {
5707 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5708 __func__);
5709 return -EIO;
5710 }
5711
5712 break;
5713 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005714 case WE_SET_MAX_TX_POWER_2_4:
5715 {
5716 hddLog(VOS_TRACE_LEVEL_INFO,
5717 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5718 __func__, set_value);
5719 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5720 eHAL_STATUS_SUCCESS)
5721 {
5722 hddLog(VOS_TRACE_LEVEL_ERROR,
5723 "%s: Setting maximum tx power failed for 2.4 GHz band",
5724 __func__);
5725 return -EIO;
5726 }
5727
5728 break;
5729 }
5730 case WE_SET_MAX_TX_POWER_5_0:
5731 {
5732 hddLog(VOS_TRACE_LEVEL_INFO,
5733 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5734 __func__, set_value);
5735 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5736 eHAL_STATUS_SUCCESS)
5737 {
5738 hddLog(VOS_TRACE_LEVEL_ERROR,
5739 "%s: Setting maximum tx power failed for 5.0 GHz band",
5740 __func__);
5741 return -EIO;
5742 }
5743
5744 break;
5745 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 case WE_SET_HIGHER_DTIM_TRANSITION:
5747 {
5748 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5749 (set_value == eANI_BOOLEAN_TRUE)))
5750 {
5751 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5752 ret = -EINVAL;
5753 }
5754 else
5755 {
5756 if(pAdapter->higherDtimTransition != set_value)
5757 {
5758 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005759 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 }
5761 }
5762
5763 break;
5764 }
5765
5766 case WE_SET_TM_LEVEL:
5767 {
5768 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005769 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5771
5772 break;
5773 }
5774
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305775 case WE_ENABLE_STRICT_FCC_REG:
5776 {
5777 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5778 struct wiphy *wiphy = NULL;
5779 long lrc;
5780 int status;
5781
5782 wiphy = hddCtxt->wiphy;
5783 if(wiphy == NULL)
5784 {
5785 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5786 break;
5787 }
5788 init_completion(&hddCtxt->wiphy_channel_update_event);
5789
5790 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5791
5792 status = regulatory_hint(wiphy, "00");
5793 if(status < 0)
5794 {
5795 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5796 break;
5797 }
5798
5799 /* Wait for completion */
5800 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5801 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5802 if (lrc <= 0)
5803 {
5804 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5805 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5806 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5807 }
5808 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5809
5810 break;
5811 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005812 case WE_SET_DEBUG_LOG:
5813 {
5814 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5815 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5816 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5817 break;
5818 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305819#ifdef FEATURE_WLAN_TDLS
5820 case WE_SET_TDLS_OFF_CHAN:
5821 {
5822 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5824 __func__, set_value);
5825 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5826 break;
5827 }
5828 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5829 {
5830 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5832 __func__, set_value);
5833 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5834 break;
5835 }
5836 case WE_SET_TDLS_OFF_CHAN_MODE:
5837 {
5838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5839 __func__, set_value);
5840 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5841 break;
5842 }
5843#endif
Peng Xu2446a892014-09-05 17:21:18 +05305844 case WE_SET_SCAN_BAND_PREFERENCE:
5845 {
5846 tSmeConfigParams smeConfig;
5847 memset(&smeConfig, 0x00, sizeof(smeConfig));
5848 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5849 ret = -EINVAL;
5850 break;
5851 }
5852 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5853
5854 if (eCSR_BAND_ALL == set_value ||
5855 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5856 sme_GetConfigParam(hHal, &smeConfig);
5857 smeConfig.csrConfig.scanBandPreference = set_value;
5858
5859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5860 "set band scan preference = %d\n",
5861 smeConfig.csrConfig.scanBandPreference);
5862
5863 sme_UpdateConfig(hHal, &smeConfig);
5864 }
5865 else {
5866 ret = -EINVAL;
5867 }
5868 break;
5869 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305870 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5871 * connection happens so that the params can take effect during
5872 * association. Also this should not be used in STA+p2p concurrency
5873 * as the param will also effect the STA mode.
5874 */
5875 case WE_SET_MIRACAST_VENDOR_CONFIG:
5876 {
5877 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305878
Abhishek Singh01c73d12015-03-12 15:13:44 +05305879 hddLog(LOG1, FL(
5880 "Set Miracast vendor tuning %d"), set_value);
5881
5882 if (1 == set_value || 0 == set_value)
5883 {
5884 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5885 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5886 {
5887 hddLog( LOGE, FL("set vendor miracast config failed"));
5888 ret = -EIO;
5889 }
5890 }
5891 else
5892 {
5893 hddLog(LOGE,
5894 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5895 ret = -EINVAL;
5896 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305897 break;
5898 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305899
5900 case WE_GET_FRAME_LOG:
5901 {
5902 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5903 != VOS_STATUS_SUCCESS)
5904 {
5905 ret = -EINVAL;
5906 }
5907 break;
5908 }
5909
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305910 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5911 {
5912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5913 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5914 if (set_value == 0 || set_value == 1)
5915 {
5916 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5917 set_value);
5918 }
5919 else
5920 ret = -EINVAL;
5921
5922 break;
5923 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05305924 /* Bit mask value to enable RTS/CTS for different modes
5925 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
5926 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
5927 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
5928 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
5929 * for 5 GHz, VHT80 - 0x1000
5930 */
5931 case WE_SET_RTS_CTS_HTVHT:
5932 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305933
Abhishek Singh41988ba2015-05-25 19:42:29 +05305934 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
5935
5936 if (eHAL_STATUS_SUCCESS !=
5937 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
5938 {
5939 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
5940 ret = -EINVAL;
5941 }
5942 break;
5943 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305944 case WE_SET_MONITOR_STATE:
5945 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305946 v_U32_t magic = 0;
5947 struct completion cmpVar;
5948 long waitRet = 0;
5949 tVOS_CON_MODE mode = hdd_get_conparam();
5950
5951 if( VOS_MONITOR_MODE != mode)
5952 {
5953 hddLog(LOGE, "invalid mode %d", mode);
5954 ret = -EIO;
5955 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305956
5957 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
5958 if( pMonCtx == NULL )
5959 {
5960 hddLog(LOGE, "Monitor Context NULL");
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305961 ret = -EIO;
5962 }
5963 if (pMonCtx->state == set_value)
5964 {
5965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5966 FL("already in same mode curr_mode:%d req_mode: %d"),
5967 pMonCtx->state, set_value);
5968 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305969 }
5970 pMonCtx->state = set_value;
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05305971 magic = MON_MODE_MSG_MAGIC;
5972 init_completion(&cmpVar);
5973 if (VOS_STATUS_SUCCESS !=
5974 wlan_hdd_mon_postMsg(&magic, &cmpVar,
5975 pMonCtx, hdd_monPostMsgCb)) {
5976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5977 FL("failed to post MON MODE REQ"));
5978 pMonCtx->state = (pMonCtx->state==MON_MODE_START)?
5979 MON_MODE_STOP : MON_MODE_START;
5980 magic = 0;
5981 ret = -EIO;
5982 break;
5983 }
5984 waitRet = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT);
5985 magic = 0;
5986 if (waitRet <= 0 ){
5987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5988 FL("failed to wait on monitor mode completion %ld"),
5989 waitRet);
5990 }
5991 break;
Katya Nigamf0511f62015-05-05 16:40:57 +05305992 }
Sushant Kaushik33200572015-08-05 16:46:20 +05305993 case WE_SET_PKT_STATS_ENABLE_DISABLE:
5994 {
5995 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5996 tAniWifiStartLog start_log;
5997 if (!pHddCtx->cfg_ini->wlanPerPktStatsLogEnable ||
5998 !vos_isPktStatsEnabled())
5999 {
6000 hddLog(LOGE, FL("per pkt stats not enabled"));
6001 return -EINVAL;
6002 }
6003 hddLog(LOG1, FL("Set Pkt Stats %d"), set_value);
6004
6005 if (1 == set_value || 0 == set_value)
6006 {
6007 start_log.ringId = RING_ID_PER_PACKET_STATS;
6008 start_log.flag = 0;
6009 if (set_value)
6010 start_log.verboseLevel = WLAN_LOG_LEVEL_ACTIVE;
6011 else
6012 start_log.verboseLevel = WLAN_LOG_LEVEL_OFF;
6013
6014 vos_set_ring_log_level(start_log.ringId, start_log.verboseLevel);
6015 }
6016 else
6017 {
6018 hddLog(LOGE,
6019 FL("Invalid value %d in WE_SET_PKT_STATS_ENABLE_DISABLE IOCTL"),
6020 set_value);
6021 ret = -EINVAL;
6022 }
6023 break;
6024 }
Katya Nigamf0511f62015-05-05 16:40:57 +05306025
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 default:
6027 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006028 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 sub_cmd, set_value);
6030 break;
6031 }
6032 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306033 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 return ret;
6035}
6036
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306037static int iw_setint_getnone(struct net_device *dev,
6038 struct iw_request_info *info,
6039 union iwreq_data *wrqu, char *extra)
6040{
6041 int ret;
6042
6043 vos_ssr_protect(__func__);
6044 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6045 vos_ssr_unprotect(__func__);
6046
6047 return 0;
6048}
Jeff Johnson295189b2012-06-20 16:38:30 -07006049/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306050static int __iw_setchar_getnone(struct net_device *dev,
6051 struct iw_request_info *info,
6052 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006053{
6054 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05306055 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08006057 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306058 hdd_adapter_t *pAdapter;
6059 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006060#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306061 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006062#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05306063 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306064 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07006065
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306066 ENTER();
Hanumantha Reddy Pothulae60df522015-10-27 21:41:43 +05306067
6068 if (!capable(CAP_NET_ADMIN))
6069 {
6070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6071 FL("permission check failed"));
6072 return -EPERM;
6073 }
6074
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306075 pAdapter = (netdev_priv(dev));
6076 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006077 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6079 "%s: Adapter is NULL",__func__);
6080 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006081 }
6082
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306083 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6084 ret = wlan_hdd_validate_context(pHddCtx);
6085 if (0 != ret)
6086 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306087 return ret;
6088 }
6089#ifdef WLAN_FEATURE_VOWIFI
6090 pConfig = pHddCtx->cfg_ini;
6091#endif
Girish Gowli552fc072014-06-14 18:26:16 +05306092 /* helper function to get iwreq_data with compat handling. */
6093 if (hdd_priv_get_data(&s_priv_data, wrqu))
6094 {
6095 return -EINVAL;
6096 }
6097
6098 /* make sure all params are correctly passed to function */
6099 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6100 {
6101 return -EINVAL;
6102 }
6103
6104 sub_cmd = s_priv_data.flags;
6105
Arif Hussain0273cba2014-01-07 20:58:29 -08006106 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306107 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6108 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006109 if (NULL == pBuffer)
6110 {
6111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6112 "mem_alloc_copy_from_user_helper fail");
6113 return -ENOMEM;
6114 }
6115
6116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306117 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6119 "%s: Received data %s", __func__, pBuffer);
6120
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 switch(sub_cmd)
6122 {
6123 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006125 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 break;
6127 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006129 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 break;
6131#if defined WLAN_FEATURE_VOWIFI
6132 case WE_NEIGHBOR_REPORT_REQUEST:
6133 {
6134 tRrmNeighborReq neighborReq;
6135 tRrmNeighborRspCallbackInfo callbackInfo;
6136
6137 if (pConfig->fRrmEnable)
6138 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306140 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 if( !neighborReq.no_ssid )
6142 {
Girish Gowli552fc072014-06-14 18:26:16 +05306143 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006144 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 }
6146
6147 callbackInfo.neighborRspCallback = NULL;
6148 callbackInfo.neighborRspCallbackContext = NULL;
6149 callbackInfo.timeout = 5000; //5 seconds
6150 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6151 }
6152 else
6153 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006154 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 ret = -EINVAL;
6156 }
6157 }
6158 break;
6159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 case WE_SET_AP_WPS_IE:
6161 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306162 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006165 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 if (VOS_STATUS_SUCCESS != vstatus)
6167 {
6168 ret = -EINVAL;
6169 }
6170 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306171 case WE_SET_ENCRYPT_MSG:
6172 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6173 if (NULL == pkt)
6174 {
6175 hddLog(VOS_TRACE_LEVEL_ERROR,
6176 "%s: vos_mem_alloc failed", __func__);
Abhishek Singh2b055852015-10-07 14:14:13 +05306177 ret = -ENOMEM;
6178 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306179 }
6180
6181 memset(pkt, 0, sizeof(tSirpkt80211));
6182
6183 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6184 hddLog(VOS_TRACE_LEVEL_ERROR,
6185 FL("Firmware is not DISA capable"));
6186 ret = -EINVAL;
6187 vos_mem_free(pkt);
6188 break;
6189 }
6190
6191 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6192
6193 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6194 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6195 if (eHAL_STATUS_SUCCESS != ret) {
6196 hddLog(VOS_TRACE_LEVEL_ERROR,
6197 FL("SENDEncryptMSG: fail to post WDA cmd"));
6198 ret = -EINVAL;
6199 }
6200 vos_mem_free(pkt);
6201
6202 break;
6203
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 default:
6205 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006206 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 ret = -EINVAL;
6208 break;
6209 }
6210 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006211 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306212
6213 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 return ret;
6215}
6216
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306217static int iw_setchar_getnone(struct net_device *dev,
6218 struct iw_request_info *info,
6219 union iwreq_data *wrqu, char *extra)
6220{
6221 int ret;
6222
6223 vos_ssr_protect(__func__);
6224 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6225 vos_ssr_unprotect(__func__);
6226
6227 return ret;
6228}
6229
Jeff Johnson295189b2012-06-20 16:38:30 -07006230/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306231static int __iw_setnone_getint(struct net_device *dev,
6232 struct iw_request_info *info,
6233 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006234{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306235 hdd_adapter_t *pAdapter;
6236 tHalHandle hHal;
6237 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 int *value = (int *)extra;
6239 int ret = 0; /* success */
6240
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306241 ENTER();
6242
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306243 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6244 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006245 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6247 "%s: Adapter is NULL",__func__);
6248 return -EINVAL;
6249 }
6250 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6251 ret = wlan_hdd_validate_context(pHddCtx);
6252 if (0 != ret)
6253 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306254 return ret;
6255 }
6256 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6257 if (NULL == hHal)
6258 {
6259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6260 "%s: Hal Context is NULL",__func__);
6261 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006263
6264 switch (value[0])
6265 {
6266 case WE_GET_11D_STATE:
6267 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006268 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306270
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6272
Arif Hussain6d2a3322013-11-17 19:50:10 -08006273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006274
6275 break;
6276 }
6277
6278 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 break;
6281
6282 case WE_PMC_STATE:
6283 {
6284 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 break;
6287 }
6288 case WE_GET_WLAN_DBG:
6289 {
6290 vos_trace_display();
6291 *value = 0;
6292 break;
6293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 case WE_GET_MAX_ASSOC:
6295 {
6296 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6297 {
c_hpothub8245442013-11-20 23:41:09 +05306298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6299 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 ret = -EIO;
6301 }
Girish Gowli385be612014-09-18 11:17:20 +05306302#ifdef WLAN_SOFTAP_VSTA_FEATURE
6303 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6304 {
6305 if (*value > VSTA_NUM_ASSOC_STA)
6306 {
6307 *value = VSTA_NUM_ASSOC_STA;
6308 }
6309 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6310 (*value > (VSTA_NUM_ASSOC_STA -
6311 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6312 {
6313 *value = (VSTA_NUM_ASSOC_STA -
6314 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6315 }
6316 }
6317 else
6318#endif
6319 {
6320 if (*value > NUM_ASSOC_STA)
6321 {
6322 *value = NUM_ASSOC_STA;
6323 }
6324 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6325 (*value > (NUM_ASSOC_STA -
6326 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6327 {
6328 *value = (NUM_ASSOC_STA -
6329 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6330 }
6331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006332 break;
6333 }
6334
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 case WE_GET_WDI_DBG:
6336 {
6337 wpalTraceDisplay();
6338 *value = 0;
6339 break;
6340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006341
6342 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6343 {
6344 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6345 break;
6346 }
6347 case WE_GET_CONCURRENCY_MODE:
6348 {
6349 *value = hdd_get_concurrency_mode ( );
6350
Arif Hussain6d2a3322013-11-17 19:50:10 -08006351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 break;
6353 }
6354
Peng Xu2446a892014-09-05 17:21:18 +05306355 case WE_GET_SCAN_BAND_PREFERENCE:
6356 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05306357 tSmeConfigParams smeConfig;
Peng Xu2446a892014-09-05 17:21:18 +05306358 sme_GetConfigParam(hHal, &smeConfig);
6359 *value = smeConfig.csrConfig.scanBandPreference;
6360
6361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6362 "scanBandPreference = %d\n", *value);
6363 break;
6364 }
6365
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 default:
6367 {
6368 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6369 break;
6370 }
6371 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306372 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 return ret;
6374}
6375
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306376static int iw_setnone_getint(struct net_device *dev,
6377 struct iw_request_info *info,
6378 union iwreq_data *wrqu, char *extra)
6379{
6380 int ret;
6381
6382 vos_ssr_protect(__func__);
6383 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6384 vos_ssr_unprotect(__func__);
6385
6386 return ret;
6387
6388}
Jeff Johnson295189b2012-06-20 16:38:30 -07006389/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306390int __iw_set_three_ints_getnone(struct net_device *dev,
6391 struct iw_request_info *info,
6392 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006393{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306394 hdd_adapter_t *pAdapter;
6395 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 int *value = (int *)extra;
6397 int sub_cmd = value[0];
6398 int ret = 0;
6399
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306400 ENTER();
Hanumantha Reddy Pothulad41fa692015-10-28 00:12:23 +05306401
6402 if (!capable(CAP_NET_ADMIN))
6403 {
6404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6405 FL("permission check failed"));
6406 return -EPERM;
6407 }
6408
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306409 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6410 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006411 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6413 "%s: Adapter is NULL",__func__);
6414 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006415 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306416 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6417 ret = wlan_hdd_validate_context(pHddCtx);
6418 if (0 != ret)
6419 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306420 return ret;
6421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 switch(sub_cmd)
6423 {
6424 case WE_SET_WLAN_DBG:
6425 {
6426 vos_trace_setValue( value[1], value[2], value[3]);
6427 break;
6428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 case WE_SET_WDI_DBG:
6430 {
6431 wpalTraceSetLevel( value[1], value[2], value[3]);
6432 break;
6433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 case WE_SET_SAP_CHANNELS:
6435 {
6436 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6437 break;
6438 }
6439
6440 default:
6441 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006442 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 break;
6444 }
6445 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306446 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006447 return ret;
6448}
6449
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306450int iw_set_three_ints_getnone(struct net_device *dev,
6451 struct iw_request_info *info,
6452 union iwreq_data *wrqu, char *extra)
6453{
6454 int ret;
6455
6456 vos_ssr_protect(__func__);
6457 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6458 vos_ssr_unprotect(__func__);
6459
6460 return ret;
6461}
6462
6463static int __iw_get_char_setnone(struct net_device *dev,
6464 struct iw_request_info *info,
6465 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006466{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306467 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306469 hdd_context_t *pHddCtx;
6470 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006471#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006472 hdd_wext_state_t *pWextState;
6473#endif
6474
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306475 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306476 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006477 if (pAdapter == NULL)
6478 {
6479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6480 "%s: pAdapter is NULL!", __func__);
6481 return -EINVAL;
6482 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306483 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6484 ret = wlan_hdd_validate_context(pHddCtx);
6485 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006486 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306487 return ret;
6488 }
6489#ifdef WLAN_FEATURE_11W
6490 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6491 if (NULL == pWextState)
6492 {
6493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6494 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006495 return -EINVAL;
6496 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306497#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006498
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 switch(sub_cmd)
6500 {
6501 case WE_WLAN_VERSION:
6502 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006503 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 break;
6505 }
6506
6507 case WE_GET_STATS:
6508 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306509 tHalHandle hHal = NULL;
6510 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6512 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6513 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6514
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306515
Jeff Johnson295189b2012-06-20 16:38:30 -07006516 snprintf(extra, WE_MAX_STR_LEN,
6517 "\nTransmit"
6518 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6519 "\n dropped BK %u, BE %u, VI %u, VO %u"
6520 "\n classified BK %u, BE %u, VI %u, VO %u"
6521 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6522 "\n queued BK %u, BE %u, VI %u, VO %u"
6523 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006524 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006525 "\n fetched BK %u, BE %u, VI %u, VO %u"
6526 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6527 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006528 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 "\n flushed BK %u, BE %u, VI %u, VO %u"
6530 "\n\nReceive"
6531 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6532 "\n\nResetsStats"
6533 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6534 "\n",
6535 pStats->txXmitCalled,
6536 pStats->txXmitDropped,
6537 pStats->txXmitBackPressured,
6538 pStats->txXmitQueued,
6539
6540 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6541 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6542 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6543 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6544
6545 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6546 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6547 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6548 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6549
6550 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6551 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6552 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6553 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6554
6555 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6556 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6557 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6558 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6559
6560 pStats->txFetched,
6561 pStats->txFetchEmpty,
6562 pStats->txFetchLowResources,
6563 pStats->txFetchDequeueError,
6564
6565 pStats->txFetchDequeued,
6566 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006567 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 pStats->txCompleted,
6569 pStats->txFlushed,
6570
6571 pStats->txFetchedAC[WLANTL_AC_BK],
6572 pStats->txFetchedAC[WLANTL_AC_BE],
6573 pStats->txFetchedAC[WLANTL_AC_VI],
6574 pStats->txFetchedAC[WLANTL_AC_VO],
6575
6576 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6577 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6578 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6579 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6580
6581 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6582 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6583 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6584 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6585
Ravi Joshi41914632013-10-21 23:02:21 -07006586 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6587 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6588 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6589 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6590
Jeff Johnson295189b2012-06-20 16:38:30 -07006591 pStats->txFlushedAC[WLANTL_AC_BK],
6592 pStats->txFlushedAC[WLANTL_AC_BE],
6593 pStats->txFlushedAC[WLANTL_AC_VI],
6594 pStats->txFlushedAC[WLANTL_AC_VO],
6595
6596 pStats->rxChains,
6597 pStats->rxPackets,
6598 pStats->rxDropped,
6599 pStats->rxDelivered,
6600 pStats->rxRefused,
6601
6602 pResetStats->totalLogpResets,
6603 pResetStats->totalCMD53Failures,
6604 pResetStats->totalMutexReadFailures,
6605 pResetStats->totalMIFErrorFailures,
6606 pResetStats->totalFWHearbeatFailures,
6607 pResetStats->totalUnknownExceptions
6608 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306609 wrqu->data.length = strlen(extra);
6610
6611 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6612
6613 if (hHal)
6614 pMac = PMAC_STRUCT( hHal );
6615
6616 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6617 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6618 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306619 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6620 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6621 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6622 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306623 "\n",
6624 pMac->pmm.BmpscntSleep,
6625 pMac->pmm.BmpscntAwake,
6626 pMac->pmm.BmpsSleeReqFailCnt,
6627 pMac->pmm.BmpsWakeupReqFailCnt,
6628 pMac->pmm.ImpsCntSleep,
6629 pMac->pmm.ImpsCntAwake,
6630 pMac->pmm.ImpsSleepErrCnt,
6631 pMac->pmm.ImpsWakeupErrCnt,
6632 pMac->pmm.ImpsLastErr
6633 );
6634 }
6635
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 wrqu->data.length = strlen(extra)+1;
6637 break;
6638 }
6639
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306640/* The case prints the current state of the HDD, SME, CSR, PE, TL
6641 *it can be extended for WDI Global State as well.
6642 *And currently it only checks P2P_CLIENT adapter.
6643 *P2P_DEVICE and P2P_GO have not been added as of now.
6644*/
6645 case WE_GET_STATES:
6646 {
6647 int buf = 0, len = 0;
6648 int adapter_num = 0;
6649 int count = 0, check = 1;
6650
6651 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006652 tHalHandle hHal = NULL;
6653 tpAniSirGlobal pMac = NULL;
6654 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306655
6656 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6657 hdd_adapter_t *useAdapter = NULL;
6658
6659 /* Print wlan0 or p2p0 states based on the adapter_num
6660 *by using the correct adapter
6661 */
6662 while ( adapter_num < 2 )
6663 {
6664 if ( WLAN_ADAPTER == adapter_num )
6665 {
6666 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006667 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306668 "\n\n wlan0 States:-");
6669 len += buf;
6670 }
6671 else if ( P2P_ADAPTER == adapter_num )
6672 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006673 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306674 "\n\n p2p0 States:-");
6675 len += buf;
6676
6677 if( !pHddCtx )
6678 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006679 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306680 "\n pHddCtx is NULL");
6681 len += buf;
6682 break;
6683 }
6684
6685 /*Printing p2p0 states only in the case when the device is
6686 configured as a p2p_client*/
6687 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6688 if ( !useAdapter )
6689 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006690 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306691 "\n Device not configured as P2P_CLIENT.");
6692 len += buf;
6693 break;
6694 }
6695 }
6696
6697 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006698 if (!hHal) {
6699 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6700 "\n pMac is NULL");
6701 len += buf;
6702 break;
6703 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306704 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006705 if (!pMac) {
6706 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6707 "\n pMac is NULL");
6708 len += buf;
6709 break;
6710 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306711 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6712 if( !pHddStaCtx )
6713 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006714 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306715 "\n pHddStaCtx is NULL");
6716 len += buf;
6717 break;
6718 }
6719
6720 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6721
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006722 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306723 "\n HDD Conn State - %s "
6724 "\n \n SME State:"
6725 "\n Neighbour Roam State - %s"
6726 "\n CSR State - %s"
6727 "\n CSR Substate - %s"
6728 "\n \n TL STA %d State: %s",
6729 macTraceGetHDDWlanConnState(
6730 pHddStaCtx->conn_info.connState),
6731 macTraceGetNeighbourRoamState(
6732 pMac->roam.neighborRoamInfo.neighborRoamState),
6733 macTraceGetcsrRoamState(
6734 pMac->roam.curState[useAdapter->sessionId]),
6735 macTraceGetcsrRoamSubState(
6736 pMac->roam.curSubState[useAdapter->sessionId]),
6737 pHddStaCtx->conn_info.staId[0],
6738 macTraceGetTLState(tlState)
6739 );
6740 len += buf;
6741 adapter_num++;
6742 }
6743
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006744 if (pMac) {
6745 /* Printing Lim State starting with global lim states */
6746 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6747 "\n \n LIM STATES:-"
6748 "\n Global Sme State - %s "\
6749 "\n Global mlm State - %s "\
6750 "\n",
6751 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6752 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6753 );
6754 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306755
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006756 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05306757 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306758 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006759 if ( pMac->lim.gpSession[count].valid )
6760 {
6761 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6762 "\n Lim Valid Session %d:-"
6763 "\n PE Sme State - %s "
6764 "\n PE Mlm State - %s "
6765 "\n",
6766 check,
6767 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6768 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6769 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306770
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006771 len += buf;
6772 check++;
6773 }
6774 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306775 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306776 }
6777
6778 wrqu->data.length = strlen(extra)+1;
6779 break;
6780 }
6781
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 case WE_GET_CFG:
6783 {
6784 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6785 wrqu->data.length = strlen(extra)+1;
6786 break;
6787 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006788#ifdef WLAN_FEATURE_11AC
6789 case WE_GET_RSSI:
6790 {
6791 v_S7_t s7Rssi = 0;
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +05306792 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnsone7245742012-09-05 17:12:55 -07006793 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6794 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6795 wrqu->data.length = strlen(extra)+1;
6796 break;
6797 }
6798#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306799
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006800#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006801 case WE_GET_ROAM_RSSI:
6802 {
6803 v_S7_t s7Rssi = 0;
6804 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6805 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6806 wrqu->data.length = strlen(extra)+1;
6807 break;
6808 }
6809#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 case WE_GET_WMM_STATUS:
6811 {
6812 snprintf(extra, WE_MAX_STR_LEN,
6813 "\nDir: 0=up, 1=down, 3=both\n"
6814 "|------------------------|\n"
6815 "|AC | ACM |Admitted| Dir |\n"
6816 "|------------------------|\n"
6817 "|VO | %d | %3s | %d |\n"
6818 "|VI | %d | %3s | %d |\n"
6819 "|BE | %d | %3s | %d |\n"
6820 "|BK | %d | %3s | %d |\n"
6821 "|------------------------|\n",
6822 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6823 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6824 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6825 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6826 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6827 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6828 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6829 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6830 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6831 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6832 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6833 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6834
Jeff Johnsone7245742012-09-05 17:12:55 -07006835
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 wrqu->data.length = strlen(extra)+1;
6837 break;
6838 }
6839 case WE_GET_CHANNEL_LIST:
6840 {
6841 VOS_STATUS status;
6842 v_U8_t i, len;
6843 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306844 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6845 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6846 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 tChannelListInfo channel_list;
6848
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006849 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006851 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006853 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006854 return -EINVAL;
6855 }
6856 buf = extra;
6857
6858 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006859 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6860 * needed = 5 * number of channels. Check ifsufficient
6861 * buffer is available and then proceed to fill the buffer.
6862 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6864 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006865 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006866 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006867 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 return -EINVAL;
6869 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006870 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6871 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306872 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6873 {
6874 //Printing Country code in getChannelList
6875 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6876 {
6877 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6878 "%c ", pBuf[i]);
6879 }
6880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006881 for(i = 0 ; i < channel_list.num_channels; i++)
6882 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006883 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006884 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 }
6886 wrqu->data.length = strlen(extra)+1;
6887
6888 break;
6889 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006890#ifdef FEATURE_WLAN_TDLS
6891 case WE_GET_TDLS_PEERS:
6892 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006893 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006894 break;
6895 }
6896#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006897#ifdef WLAN_FEATURE_11W
6898 case WE_GET_11W_INFO:
6899 {
6900 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6901
6902 snprintf(extra, WE_MAX_STR_LEN,
6903 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6904 "\n Number of Unprotected Disassocs %d"
6905 "\n Number of Unprotected Deauths %d",
6906 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6907 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6908 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6909 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6910 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6911
6912 wrqu->data.length = strlen(extra)+1;
6913 break;
6914 }
6915#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306916 case WE_GET_SNR:
6917 {
6918 v_S7_t s7snr = 0;
6919 int status = 0;
6920 hdd_context_t *pHddCtx;
6921 hdd_station_ctx_t *pHddStaCtx;
6922
6923 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6924 status = wlan_hdd_validate_context(pHddCtx);
6925 if (0 != status)
6926 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306927 return status;
6928 }
6929
6930 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6931
6932 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6933 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6934 {
6935 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6936 " ConnectionState-%d", __func__,
6937 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6938 pHddStaCtx->conn_info.connState);
6939 return -ENONET;
6940 }
6941
6942 /*update the stats in TL*/
6943 wlan_hdd_get_station_stats(pAdapter);
6944 wlan_hdd_get_snr(pAdapter, &s7snr);
6945 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6946 wrqu->data.length = strlen(extra) + 1;
6947 break;
6948 }
6949
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306950 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006952 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 break;
6954 }
6955 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306956 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 return 0;
6958}
6959
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306960static int iw_get_char_setnone(struct net_device *dev,
6961 struct iw_request_info *info,
6962 union iwreq_data *wrqu, char *extra)
6963{
6964 int ret;
6965
6966 vos_ssr_protect(__func__);
6967 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6968 vos_ssr_unprotect(__func__);
6969
6970 return ret;
6971}
6972
Jeff Johnson295189b2012-06-20 16:38:30 -07006973/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306974static int __iw_setnone_getnone(struct net_device *dev,
6975 struct iw_request_info *info,
6976 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006977{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306978 hdd_adapter_t *pAdapter;
6979 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306980 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006981 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306982 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006983
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306984 ENTER();
6985
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306986 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6987 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006988 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6990 "%s: Adapter is NULL",__func__);
6991 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006992 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306993 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6994 ret = wlan_hdd_validate_context(pHddCtx);
6995 if (0 != ret)
6996 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306997 return ret;
6998 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306999 /* helper function to get iwreq_data with compat handling. */
7000 if (hdd_priv_get_data(&s_priv_data, wrqu))
7001 {
7002 return -EINVAL;
7003 }
7004
7005 sub_cmd = s_priv_data.flags;
7006
Jeff Johnson295189b2012-06-20 16:38:30 -07007007 switch (sub_cmd)
7008 {
7009 case WE_CLEAR_STATS:
7010 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
7013 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
7014 break;
7015 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 case WE_INIT_AP:
7017 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05307018 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7019
7020 /* As Soft AP mode might been changed to STA already with
7021 * killing of Hostapd, need to find the adpater by name
7022 * rather than mode */
7023 hdd_adapter_t* pAdapter_to_stop =
7024 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7025 if( pAdapter_to_stop )
7026 {
7027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7028 "Adapter with name softap.0 already "
7029 "exist, ignoring the request.\nRemove the "
7030 "adapter and try again\n");
7031 break;
7032 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 pr_info("Init AP trigger\n");
7034 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
7035 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
7036 break;
7037 }
7038 case WE_STOP_AP:
7039 {
7040 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
7041 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
7042 * this is a dead code and need to find the adpater by name rather than mode */
7043 hdd_adapter_t* pAdapter_to_stop =
7044 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
7045 if( pAdapter_to_stop )
7046 {
7047 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7048
7049 pr_info("Stopping AP mode\n");
7050
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307051 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7052 {
7053 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
7054 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7055 }
7056
Jeff Johnson295189b2012-06-20 16:38:30 -07007057 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05307058 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05307059 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
7061
7062 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
7063 pAdapter_to_stop->macAddressCurrent.bytes);
7064 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
7065 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05307066
7067 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7068 {
7069 /* put the device back into BMPS */
7070 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 }
7073 else
7074 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007075 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 }
7077
7078 break;
7079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007080#ifdef WLAN_BTAMP_FEATURE
7081 case WE_ENABLE_AMP:
7082 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 WLANBAP_RegisterWithHCI(pAdapter);
7085 break;
7086 }
7087 case WE_DISABLE_AMP:
7088 {
7089 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7090 VOS_STATUS status;
7091
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007093
7094 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
7095 status = WLANBAP_StopAmp();
7096 if(VOS_STATUS_SUCCESS != status )
7097 {
7098 pHddCtx->isAmpAllowed = VOS_TRUE;
7099 hddLog(VOS_TRACE_LEVEL_FATAL,
7100 "%s: Failed to stop AMP", __func__);
7101 }
7102 else
7103 {
7104 //a state m/c implementation in PAL is TBD to avoid this delay
7105 msleep(500);
7106 pHddCtx->isAmpAllowed = VOS_FALSE;
7107 WLANBAP_DeregisterFromHCI();
7108 }
7109
7110 break;
7111 }
7112#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007113 case WE_ENABLE_DXE_STALL_DETECT:
7114 {
schang6295e542013-03-12 15:31:23 -07007115 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7116 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007117 break;
7118 }
7119 case WE_DISPLAY_DXE_SNAP_SHOT:
7120 {
schang6295e542013-03-12 15:31:23 -07007121 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7122 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007123 break;
7124 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307125 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7126 {
7127 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7128 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307129 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307130 break;
7131 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307132
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307133 case WE_SET_REASSOC_TRIGGER:
7134 {
7135 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7136 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7137 v_U32_t roamId = 0;
7138 tCsrRoamModifyProfileFields modProfileFields;
Abhishek Singh5333d472015-10-15 15:49:24 +05307139 hdd_station_ctx_t *pHddStaCtx =
7140 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7141 /* Reassoc to same AP, only supported for Open Security*/
7142 if ((pHddStaCtx->conn_info.ucEncryptionType ||
7143 pHddStaCtx->conn_info.mcEncryptionType))
7144 {
7145 hddLog(LOGE,
7146 FL("Reassoc to same AP, only supported for Open Security"));
7147 return -ENOTSUPP;
7148 }
7149 sme_GetModifyProfileFields(pMac,
7150 pAdapter->sessionId, &modProfileFields);
7151 sme_RoamReassoc(pMac, pAdapter->sessionId,
7152 NULL, modProfileFields, &roamId, 1);
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307153 return 0;
7154 }
7155
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307156 case WE_STOP_OBSS_SCAN:
7157 {
7158 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7159 2.OBSS scan is stopped by Firmware during the disassociation
7160 3.OBSS stop comamnd is added for debugging purpose*/
7161 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7162 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007163
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307164 if (pAdapter == NULL)
7165 {
7166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7167 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307168 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307169 }
7170 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7171 if (pMac == NULL)
7172 {
7173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7174 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307175 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307176 }
7177 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7178 }
7179 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307180 case WE_DUMP_ROAM_TIMER_LOG:
7181 {
7182 vos_dump_roam_time_log_service();
7183 break;
7184 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307185
Mukul Sharma84f27252014-07-14 18:11:42 +05307186 case WE_RESET_ROAM_TIMER_LOG:
7187 {
7188 vos_reset_roam_timer_log();
7189 break;
7190 }
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307191 case WE_GET_FW_LOGS:
7192 {
7193 vos_fatal_event_logs_req(WLAN_LOG_TYPE_NON_FATAL,
7194 WLAN_LOG_INDICATOR_IOCTL,
Sachin Ahujac08f72a2015-09-22 15:25:47 +05307195 WLAN_LOG_REASON_IOCTL,
Abhishek Singh837adf22015-10-01 17:37:37 +05307196 TRUE, TRUE);
Sachin Ahuja715aafc2015-07-21 23:35:10 +05307197 break;
7198 }
c_manjeecfd1efb2015-09-25 19:32:34 +05307199 case WE_GET_FW_MEMDUMP:
7200 {
7201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7202 "FW_MEM_DUMP requested ");
7203 get_fwr_memdump(dev,info,wrqu,extra);
7204 break;
7205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 default:
7207 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007208 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 break;
7210 }
7211 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307212 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 return ret;
7214}
7215
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307216static int iw_setnone_getnone(struct net_device *dev,
7217 struct iw_request_info *info,
7218 union iwreq_data *wrqu, char *extra)
7219{
7220 int ret;
7221
7222 vos_ssr_protect(__func__);
7223 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7224 vos_ssr_unprotect(__func__);
7225
7226 return ret;
7227}
7228
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307229void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7230{
7231 /*
7232 * Function to display HDD WMM information
7233 * for Tx Queues.
7234 * Prints globala as well as per client depending
7235 * whether the clients are registered or not.
7236 */
7237 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307238 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7239 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307240 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7241 hdd_ibss_peer_info_t *pPeerInfo;
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307242 v_SIZE_t tx_queue_count[NUM_TX_QUEUES];
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307243
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307244 for ( i=0; i< NUM_TX_QUEUES; i++)
7245 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307246 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307247 tx_queue_count[i] = pAdapter->wmm_tx_queue[i].count;
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307248 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307249 }
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307250
7251 for ( i=0; i< NUM_TX_QUEUES; i++) {
7252 if (tx_queue_count[i]) {
7253 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d",
7254 i, tx_queue_count[i]);
7255 }
7256 }
7257
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307258 if(pSapCtx == NULL){
7259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7260 FL("psapCtx is NULL"));
7261 return;
7262 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307263
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307264 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307265 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7266 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307267 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307268 {
7269 hddLog(LOGE, "******STAIndex: %d*********", i);
7270 for ( j=0; j< NUM_TX_QUEUES; j++)
7271 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307272 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7273 {
7274 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
mukul sharma2cdb8ea2015-10-01 14:53:38 +05307275 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d",
7276 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count);
Katya Nigamd5c24212015-06-19 15:40:58 +05307277 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7278 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307279 }
7280 }
7281 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307282 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307283
Katya Nigam1fd24402015-02-16 14:52:19 +05307284 if(pHddStaCtx == NULL){
7285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7286 FL("pHddStaCtx is NULL"));
7287 return;
7288 }
7289
7290 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7291 if(pPeerInfo == NULL){
7292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7293 FL("ppeerinfo is NULL"));
7294 return;
7295 }
7296
7297 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7298 {
7299 if(pPeerInfo->ibssStaInfo[i].isUsed)
7300 {
7301 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7302 for ( j=0; j< NUM_TX_QUEUES; j++)
7303 {
7304 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7305 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7306 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7307 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7308 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7309 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7310 }
7311 }
7312 }
7313
7314
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307315}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307316static int __iw_set_var_ints_getnone(struct net_device *dev,
7317 struct iw_request_info *info,
7318 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007319{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307320 hdd_adapter_t *pAdapter;
7321 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307322 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307323 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007324 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307325 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307326 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007327 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307328 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007329 int cmd = 0;
7330 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307331 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007332
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307333 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307334 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307335 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7337 "%s: NULL extra buffer pointer", __func__);
7338 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307339 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307340 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7341 if (NULL == pAdapter)
7342 {
7343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7344 "%s: Adapter is NULL",__func__);
7345 return -EINVAL;
7346 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307347 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307348 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7349 ret = wlan_hdd_validate_context(pHddCtx);
7350 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007351 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307352 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007353 }
Katya Nigameae74b62015-05-28 17:19:16 +05307354 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307355 {
Katya Nigameae74b62015-05-28 17:19:16 +05307356 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7357 if (NULL == hHal)
7358 {
7359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7360 "%s: Hal Context is NULL",__func__);
7361 return -EINVAL;
7362 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307363 }
7364 sub_cmd = wrqu->data.flags;
7365
7366 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7367
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007368
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007369 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7370 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7371 {
7372 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7373 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7374 {
7375 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7376 staId = pStaCtx->conn_info.staId[0];
7377 }
7378 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7379 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7380 {
7381 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7382 staId = pAPCtx->uBCStaId;
7383 }
7384 else
7385 {
7386 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7387 return 0;
7388 }
7389 }
7390
Jeff Johnson295189b2012-06-20 16:38:30 -07007391 switch (sub_cmd)
7392 {
7393 case WE_LOG_DUMP_CMD:
7394 {
7395 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007396 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 apps_args[3], apps_args[4]);
7398
7399 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7400 apps_args[3], apps_args[4]);
7401
7402 }
7403 break;
7404
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 case WE_P2P_NOA_CMD:
7406 {
7407 p2p_app_setP2pPs_t p2pNoA;
7408
7409 p2pNoA.opp_ps = apps_args[0];
7410 p2pNoA.ctWindow = apps_args[1];
7411 p2pNoA.duration = apps_args[2];
7412 p2pNoA.interval = apps_args[3];
7413 p2pNoA.count = apps_args[4];
7414 p2pNoA.single_noa_duration = apps_args[5];
7415 p2pNoA.psSelection = apps_args[6];
7416
7417 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7418 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007419 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007420 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7421
7422 hdd_setP2pPs(dev, &p2pNoA);
7423
7424 }
7425 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007426
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307427 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7428 {
7429 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7430 __func__, apps_args[0], apps_args[1]);
7431 vosTraceEnable(apps_args[0], apps_args[1]);
7432 }
7433 break;
7434
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007435 case WE_MTRACE_DUMP_CMD:
7436 {
7437 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7438 "bitmask_of_module %d ",
7439 __func__, apps_args[0], apps_args[1], apps_args[2],
7440 apps_args[3]);
7441 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7442 apps_args[2], apps_args[3]);
7443
7444 }
7445 break;
7446
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007447 case WE_MCC_CONFIG_CREDENTIAL :
7448 {
7449 cmd = 287; //Command should be updated if there is any change
7450 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007451 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007452 {
7453 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7454 }
7455 else
7456 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007457 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007458 return 0;
7459 }
7460 }
7461 break;
7462
7463 case WE_MCC_CONFIG_PARAMS :
7464 {
7465 cmd = 288; //command Should be updated if there is any change
7466 // in the Riva dump command
7467 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7468 }
7469 break;
7470
Chilam NG571c65a2013-01-19 12:27:36 +05307471#ifdef FEATURE_WLAN_TDLS
7472 case WE_TDLS_CONFIG_PARAMS :
7473 {
7474 tdls_config_params_t tdlsParams;
7475
Chilam Ng01120412013-02-19 18:32:21 -08007476 tdlsParams.tdls = apps_args[0];
7477 tdlsParams.tx_period_t = apps_args[1];
7478 tdlsParams.tx_packet_n = apps_args[2];
7479 tdlsParams.discovery_period_t = apps_args[3];
7480 tdlsParams.discovery_tries_n = apps_args[4];
7481 tdlsParams.idle_timeout_t = apps_args[5];
7482 tdlsParams.idle_packet_n = apps_args[6];
7483 tdlsParams.rssi_hysteresis = apps_args[7];
7484 tdlsParams.rssi_trigger_threshold = apps_args[8];
7485 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307486
Chilam Ng01120412013-02-19 18:32:21 -08007487 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307488 }
7489 break;
7490#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307491 case WE_CONFIGURE_MONITOR_MODE:
7492 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307493 v_U32_t magic = 0;
7494 struct completion cmpVar;
7495 long waitRet = 0;
7496
Katya Nigamf0511f62015-05-05 16:40:57 +05307497 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7498 if( pMonCtx == NULL )
7499 {
7500 hddLog(LOGE, "Monitor Context NULL");
7501 break;
7502 }
7503 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7504 __func__, apps_args[0], apps_args[1], apps_args[2],
7505 apps_args[3], apps_args[4]);
7506 /* Input Validation part of FW */
7507 pMonCtx->ChannelNo = apps_args[0];
7508 pMonCtx->ChannelBW = apps_args[1];
7509 pMonCtx->crcCheckEnabled = apps_args[2];
7510 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7511 pMonCtx->is80211to803ConReq = apps_args[4];
7512 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7513 if( pMonCtx->is80211to803ConReq )
7514 pAdapter->dev->type = ARPHRD_ETHER;
7515 else
7516 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7517 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7518 {
7519 hddLog(LOGE, "%s: Filtering data packets as management and control"
7520 " cannot be converted to 802.3 ",__func__);
7521 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7522 }
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307523 if (MON_MODE_START == pMonCtx->state) {
7524 magic = MON_MODE_MSG_MAGIC;
7525 init_completion(&cmpVar);
7526 if (VOS_STATUS_SUCCESS !=
7527 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7528 pMonCtx, hdd_monPostMsgCb)) {
7529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7530 FL("failed to post MON MODE REQ"));
7531 magic = 0;
7532 ret = -EIO;
7533 break;
7534 }
7535 waitRet = wait_for_completion_timeout(&cmpVar,
7536 MON_MODE_MSG_TIMEOUT);
7537 magic = 0;
7538 if (waitRet <= 0 ) {
7539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7540 FL("failed to wait on monitor mode completion %ld"),
7541 waitRet);
7542 }
7543 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307544 }
7545 break;
7546
7547 case WE_SET_MONITOR_MODE_FILTER:
7548 {
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307549 v_U32_t magic = 0;
7550 struct completion cmpVar;
7551 long waitRet = 0;
7552
Katya Nigamf0511f62015-05-05 16:40:57 +05307553 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7554 if( pMonCtx == NULL )
7555 {
7556 hddLog(LOGE, "Monitor Context NULL");
7557 break;
7558 }
7559 /* Input Validation Part of FW */
7560 pMonCtx->numOfMacFilters=1;
7561 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7562 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7563 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7564 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7565 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7566 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7567 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7568 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7569 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7570 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7571 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7572 apps_args[6], apps_args[7], apps_args[8]);
Hanumantha Reddy Pothula91cdd7f2015-09-03 21:25:16 +05307573 if (MON_MODE_START == pMonCtx->state) {
7574 magic = MON_MODE_MSG_MAGIC;
7575 init_completion(&cmpVar);
7576 if (VOS_STATUS_SUCCESS !=
7577 wlan_hdd_mon_postMsg(&magic, &cmpVar,
7578 pMonCtx, hdd_monPostMsgCb)) {
7579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7580 FL("failed to post MON MODE REQ"));
7581 magic = 0;
7582 ret = -EIO;
7583 break;
7584 }
7585 waitRet = wait_for_completion_timeout(&cmpVar,
7586 MON_MODE_MSG_TIMEOUT);
7587 magic = 0;
7588 if (waitRet <= 0 ) {
7589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7590 FL("failed to wait on monitor mode completion %ld"),
7591 waitRet);
7592 }
7593 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307594 }
7595 break;
7596
Jeff Johnson295189b2012-06-20 16:38:30 -07007597 default:
7598 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007599 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7600 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 }
7602 break;
7603 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307604 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007605 return 0;
7606}
7607
Girish Gowlifb9758e2014-11-19 15:19:17 +05307608static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7609 struct iw_request_info *info,
7610 union iwreq_data *wrqu, char *extra)
7611{
7612 int ret;
7613 union iwreq_data u_priv_wrqu;
7614 int apps_args[MAX_VAR_ARGS] = {0};
7615 int num_args;
7616
Hanumantha Reddy Pothula54df19e2015-10-27 21:48:29 +05307617 if (!capable(CAP_NET_ADMIN))
7618 {
7619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7620 FL("permission check failed"));
7621 return -EPERM;
7622 }
7623
Girish Gowlifb9758e2014-11-19 15:19:17 +05307624 /* helper function to get iwreq_data with compat handling. */
7625 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7626 {
7627 return -EINVAL;
7628 }
7629
7630 if (NULL == u_priv_wrqu.data.pointer)
7631 {
7632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7633 "%s: NULL data pointer", __func__);
7634 return -EINVAL;
7635 }
7636
7637 num_args = u_priv_wrqu.data.length;
7638 if (num_args > MAX_VAR_ARGS)
7639 {
7640 num_args = MAX_VAR_ARGS;
7641 }
7642
7643 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7644 (sizeof(int)) * num_args))
7645 {
7646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7647 "%s: failed to copy data from user buffer", __func__);
7648 return -EFAULT;
7649 }
7650
7651 vos_ssr_protect(__func__);
7652 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7653 (char *)&apps_args);
7654 vos_ssr_unprotect(__func__);
7655
7656 return ret;
7657}
7658
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307659int iw_set_var_ints_getnone(struct net_device *dev,
7660 struct iw_request_info *info,
7661 union iwreq_data *wrqu, char *extra)
7662{
7663 int ret;
7664 vos_ssr_protect(__func__);
7665 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7666 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007667
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307668 return ret;
7669}
7670
7671static int __iw_add_tspec(struct net_device *dev,
7672 struct iw_request_info *info,
7673 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007674{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307675 hdd_adapter_t *pAdapter;
7676 hdd_station_ctx_t *pHddStaCtx;
7677 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007678 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7679 int params[HDD_WLAN_WMM_PARAM_COUNT];
7680 sme_QosWmmTspecInfo tSpec;
7681 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307682 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307683 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007684
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307685 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307686 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7687 if (NULL == pAdapter)
7688 {
7689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7690 "%s: Adapter is NULL",__func__);
7691 return -EINVAL;
7692 }
7693 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7694 ret = wlan_hdd_validate_context(pHddCtx);
7695 if (0 != ret)
7696 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307697 return ret;
7698 }
7699 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7700 if (NULL == pHddStaCtx)
7701 {
7702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7703 "%s: STA Context is NULL",__func__);
7704 return -EINVAL;
7705 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 // make sure the application is sufficiently priviledged
7707 // note that the kernel will do this for "set" ioctls, but since
7708 // this ioctl wants to return status to user space it must be
7709 // defined as a "get" ioctl
7710 if (!capable(CAP_NET_ADMIN))
7711 {
7712 return -EPERM;
7713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007714 // we must be associated in order to add a tspec
7715 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7716 {
7717 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7718 return 0;
7719 }
7720
7721 // since we are defined to be a "get" ioctl, and since the number
7722 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307723 // will pass down in the iwreq_data, we must copy the "set" params.
7724 // We must handle the compat for iwreq_data in 32U/64K environment.
7725
7726 // helper fucntion to get iwreq_data with compat handling.
7727 if (hdd_priv_get_data(&s_priv_data, wrqu))
7728 {
7729 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7730 return 0;
7731 }
7732
7733 // make sure all params are correctly passed to function
7734 if ((NULL == s_priv_data.pointer) ||
7735 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7736 {
7737 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7738 return 0;
7739 }
7740
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307742 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 {
7744 // hmmm, can't get them
7745 return -EIO;
7746 }
7747
7748 // clear the tspec
7749 memset(&tSpec, 0, sizeof(tSpec));
7750
7751 // validate the handle
7752 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7753 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7754 {
7755 // that one is reserved
7756 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7757 return 0;
7758 }
7759
7760 // validate the TID
7761 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7762 {
7763 // out of range
7764 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7765 return 0;
7766 }
7767 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7768
7769 // validate the direction
7770 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7771 {
7772 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7773 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7774 break;
7775
7776 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7777 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7778 break;
7779
7780 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7781 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7782 break;
7783
7784 default:
7785 // unknown
7786 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7787 return 0;
7788 }
7789
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307790 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7791
Jeff Johnson295189b2012-06-20 16:38:30 -07007792 // validate the user priority
7793 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7794 {
7795 // out of range
7796 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7797 return 0;
7798 }
7799 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307800 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7801 {
7802 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7803 return 0;
7804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007805
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7807 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7808 tSpec.ts_info.psb, tSpec.ts_info.up);
7809
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7811 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7812 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7813 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7814 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7815 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7816 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7817 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7818 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7819 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7820 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7821 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7822
7823 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7824
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307825 // Save the expected UAPSD settings by application, this will be needed
7826 // when re-negotiating UAPSD settings during BT Coex cases.
7827 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7828
Jeff Johnson295189b2012-06-20 16:38:30 -07007829 // validate the ts info ack policy
7830 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7831 {
7832 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7833 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7834 break;
7835
7836 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7837 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7838 break;
7839
7840 default:
7841 // unknown
7842 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7843 return 0;
7844 }
7845
7846 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307847
7848 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 return 0;
7850}
7851
7852
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307853static int iw_add_tspec(struct net_device *dev,
7854 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007855 union iwreq_data *wrqu, char *extra)
7856{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307857 int ret;
7858
7859 vos_ssr_protect(__func__);
7860 ret = __iw_add_tspec(dev, info, wrqu, extra);
7861 vos_ssr_unprotect(__func__);
7862
7863 return ret;
7864}
7865
7866static int __iw_del_tspec(struct net_device *dev,
7867 struct iw_request_info *info,
7868 union iwreq_data *wrqu, char *extra)
7869{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307870 hdd_adapter_t *pAdapter;
7871 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 int *params = (int *)extra;
7873 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7874 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307875 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007876
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307877 ENTER();
7878
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307879 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7880 if (NULL == pAdapter)
7881 {
7882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7883 "%s: Adapter is NULL",__func__);
7884 return -EINVAL;
7885 }
7886
7887 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7888 ret = wlan_hdd_validate_context(pHddCtx);
7889 if (0 != ret)
7890 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307891 return ret;
7892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007893 // make sure the application is sufficiently priviledged
7894 // note that the kernel will do this for "set" ioctls, but since
7895 // this ioctl wants to return status to user space it must be
7896 // defined as a "get" ioctl
7897 if (!capable(CAP_NET_ADMIN))
7898 {
7899 return -EPERM;
7900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 // although we are defined to be a "get" ioctl, the params we require
7902 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7903 // is no need to copy the params from user space
7904
7905 // validate the handle
7906 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7907 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7908 {
7909 // that one is reserved
7910 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7911 return 0;
7912 }
7913
7914 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307915
7916 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007917 return 0;
7918}
7919
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307920static int iw_del_tspec(struct net_device *dev,
7921 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 union iwreq_data *wrqu, char *extra)
7923{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307924 int ret;
7925
7926 vos_ssr_protect(__func__);
7927 ret = __iw_del_tspec(dev, info, wrqu, extra);
7928 vos_ssr_unprotect(__func__);
7929
7930 return ret;
7931}
7932
7933
7934static int __iw_get_tspec(struct net_device *dev,
7935 struct iw_request_info *info,
7936 union iwreq_data *wrqu, char *extra)
7937{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307938 hdd_adapter_t *pAdapter;
7939 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007940 int *params = (int *)extra;
7941 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7942 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307943 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007944
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307945 ENTER();
7946
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 // although we are defined to be a "get" ioctl, the params we require
7948 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7949 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307950 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7951 if (NULL == pAdapter)
7952 {
7953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7954 "%s: Adapter is NULL",__func__);
7955 return -EINVAL;
7956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007957
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307958 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7959 ret = wlan_hdd_validate_context(pHddCtx);
7960 if (0 != ret)
7961 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307962 return ret;
7963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007964 // validate the handle
7965 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7966 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7967 {
7968 // that one is reserved
7969 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7970 return 0;
7971 }
7972
7973 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307974 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007975 return 0;
7976}
7977
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307978static int iw_get_tspec(struct net_device *dev,
7979 struct iw_request_info *info,
7980 union iwreq_data *wrqu, char *extra)
7981{
7982 int ret;
7983
7984 vos_ssr_protect(__func__);
7985 ret = __iw_get_tspec(dev, info, wrqu, extra);
7986 vos_ssr_unprotect(__func__);
7987
7988 return ret;
7989}
7990
Jeff Johnson295189b2012-06-20 16:38:30 -07007991#ifdef WLAN_FEATURE_VOWIFI_11R
7992//
7993//
7994// Each time the supplicant has the auth_request or reassoc request
7995// IEs ready. This is pushed to the driver. The driver will inturn use
7996// it to send out the auth req and reassoc req for 11r FT Assoc.
7997//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307998static int __iw_set_fties(struct net_device *dev,
7999 struct iw_request_info *info,
8000 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008001{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308002 hdd_adapter_t *pAdapter;
8003 hdd_station_ctx_t *pHddStaCtx;
8004 hdd_context_t *pHddCtx;
8005 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 //v_CONTEXT_t pVosContext;
8007
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308008 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308009 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8010 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008011 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8013 "%s: Adapter is NULL",__func__);
8014 return -EINVAL;
8015 }
8016 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8017 ret = wlan_hdd_validate_context(pHddCtx);
8018 if (0 != ret)
8019 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308020 return ret;
8021 }
8022 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8023 if (NULL == pHddStaCtx)
8024 {
8025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8026 "%s: STA Context is NULL",__func__);
8027 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008029 if (!wrqu->data.length)
8030 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008031 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008032 return -EINVAL;
8033 }
8034 if (wrqu->data.pointer == NULL)
8035 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008036 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008037 return -EINVAL;
8038 }
8039
8040 // Added for debug on reception of Re-assoc Req.
8041 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8042 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008043 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08008045 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008046 }
8047
8048#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08008049 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07008050#endif
8051
8052 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08008053 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07008054 wrqu->data.length);
8055
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308056 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008057 return 0;
8058}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308059
8060static int iw_set_fties(struct net_device *dev,
8061 struct iw_request_info *info,
8062 union iwreq_data *wrqu, char *extra)
8063{
8064 int ret;
8065
8066 vos_ssr_protect(__func__);
8067 ret = __iw_set_fties(dev, info, wrqu, extra);
8068 vos_ssr_unprotect(__func__);
8069
8070 return ret;
8071}
Jeff Johnson295189b2012-06-20 16:38:30 -07008072#endif
8073
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308074static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008075 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08008077{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308078 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008079 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308080 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008081 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308082 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008083 tpSirRcvFltMcAddrList mc_addr_list_ptr;
8084 int idx;
8085 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07008086
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308087 ENTER();
8088
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308089 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8090 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008091 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8093 "%s: Adapter is NULL",__func__);
8094 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008095 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308096 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8097 ret_val = wlan_hdd_validate_context(pHddCtx);
8098 if (0 != ret_val)
8099 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308100 return ret_val;
8101 }
8102 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8103 if (NULL == hHal)
8104 {
8105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8106 "%s: Hal Context is NULL",__func__);
8107 return -EINVAL;
8108 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308109 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
8110 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308111#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07008112
Amar Singhalf3a6e762013-02-19 15:06:50 -08008113 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8114 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008115 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008116 hddLog(VOS_TRACE_LEVEL_ERROR,
8117 "%s: vos_mem_alloc failed", __func__);
8118 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008119 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008120
8121 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
8122
8123 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
8124 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
8125
8126 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
8127 mc_addr_list_ptr->ulMulticastAddrCnt);
8128
8129 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008130 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08008131 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
8132 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
8133
8134 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
8135 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008136 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008137
Amar Singhalf3a6e762013-02-19 15:06:50 -08008138 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
8139 vos_mem_free(mc_addr_list_ptr);
8140 if (eHAL_STATUS_SUCCESS != ret_val)
8141 {
8142 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
8143 __func__);
8144 return -EINVAL;
8145 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308146#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308147 }
8148 else
8149 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008150
Amar Singhalf3a6e762013-02-19 15:06:50 -08008151 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8152 "%s: Set MC BC Filter Config request: %d suspend %d",
8153 __func__, pRequest->mcastBcastFilterSetting,
8154 pHddCtx->hdd_wlan_suspended);
8155
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308156 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008157
8158 if (pHddCtx->hdd_wlan_suspended)
8159 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008160 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8161 if (NULL == wlanRxpFilterParam)
8162 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308163 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07008164 "%s: vos_mem_alloc failed", __func__);
8165 return -EINVAL;
8166 }
8167
Amar Singhalf3a6e762013-02-19 15:06:50 -08008168 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8169 pRequest->mcastBcastFilterSetting;
8170 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8171
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308172 hdd_conf_hostoffload(pAdapter, TRUE);
8173 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8174 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08008175
8176 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
8177 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308178 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008179 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
8180 wlanRxpFilterParam->setMcstBcstFilter);
8181
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308182 if (eHAL_STATUS_SUCCESS !=
8183 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8184 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08008185 {
8186 hddLog(VOS_TRACE_LEVEL_ERROR,
8187 "%s: Failure to execute set HW MC/BC Filter request",
8188 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008189 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08008190 return -EINVAL;
8191 }
8192
c_hpothud3ce76d2014-10-28 10:34:13 +05308193 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8194 {
8195 pHddCtx->sus_res_mcastbcast_filter =
8196 pRequest->mcastBcastFilterSetting;
8197 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008198 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008200
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308201 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008202 return 0;
8203}
8204
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308205static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8206 struct iw_request_info *info,
8207 union iwreq_data *wrqu, char *extra)
8208{
8209 int ret;
8210
8211 vos_ssr_protect(__func__);
8212 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8213 vos_ssr_unprotect(__func__);
8214
8215 return ret;
8216}
8217
8218static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8219 struct iw_request_info *info,
8220 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008221{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308222 hdd_adapter_t *pAdapter;
8223 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308224 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308225 int ret = 0;
8226
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308227 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008228
Hanumantha Reddy Pothulad025fbd2015-10-27 22:01:39 +05308229 if (!capable(CAP_NET_ADMIN))
8230 {
8231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8232 FL("permission check failed"));
8233 return -EPERM;
8234 }
8235
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308236 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8237 if (NULL == pAdapter)
8238 {
8239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8240 "%s: Adapter is NULL",__func__);
8241 return -EINVAL;
8242 }
8243
8244 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8245 ret = wlan_hdd_validate_context(pHddCtx);
8246 if (0 != ret)
8247 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308248 return ret;
8249 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308250 //Reset the filter to INI value as we have to clear the dynamic filter
8251 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008252
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308253 //Configure FW with new setting
8254 if (pHddCtx->hdd_wlan_suspended)
8255 {
8256 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8257 if (NULL == wlanRxpFilterParam)
8258 {
8259 hddLog(VOS_TRACE_LEVEL_ERROR,
8260 "%s: vos_mem_alloc failed", __func__);
8261 return -EINVAL;
8262 }
8263
8264 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8265 pHddCtx->configuredMcastBcastFilter;
8266 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8267
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308268 hdd_conf_hostoffload(pAdapter, TRUE);
8269 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8270 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308271
8272 if (eHAL_STATUS_SUCCESS !=
8273 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8274 wlanRxpFilterParam))
8275 {
8276 hddLog(VOS_TRACE_LEVEL_ERROR,
8277 "%s: Failure to execute set HW MC/BC Filter request",
8278 __func__);
8279 vos_mem_free(wlanRxpFilterParam);
8280 return -EINVAL;
8281 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308282
8283 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8284 {
8285 pHddCtx->sus_res_mcastbcast_filter =
8286 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8287 }
8288
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308289 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308290 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 return 0;
8292}
8293
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308294
8295static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8296 struct iw_request_info *info,
8297 union iwreq_data *wrqu, char *extra)
8298{
8299 int ret;
8300
8301 vos_ssr_protect(__func__);
8302 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8303 vos_ssr_unprotect(__func__);
8304
8305 return ret;
8306}
8307
8308static int __iw_set_host_offload(struct net_device *dev,
8309 struct iw_request_info *info,
8310 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008311{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308312 hdd_adapter_t *pAdapter;
8313 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008314 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008315 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308316 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008317
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308318 ENTER();
8319
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308320 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8321 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008322 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8324 "%s: Adapter is NULL",__func__);
8325 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008326 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308327 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8328 ret = wlan_hdd_validate_context(pHddCtx);
8329 if (0 != ret)
8330 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308331 return ret;
8332 }
8333
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 /* Debug display of request components. */
8335 switch (pRequest->offloadType)
8336 {
8337 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008338 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008339 switch (pRequest->enableOrDisable)
8340 {
8341 case WLAN_OFFLOAD_DISABLE:
8342 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8343 break;
8344 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8345 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8346 case WLAN_OFFLOAD_ENABLE:
8347 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8348 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8349 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8350 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8351 }
8352 break;
8353
8354 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008355 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008356 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 switch (pRequest->enableOrDisable)
8358 {
8359 case WLAN_OFFLOAD_DISABLE:
8360 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8361 break;
8362 case WLAN_OFFLOAD_ENABLE:
8363 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8364 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8365 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8366 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8367 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8368 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8369 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8370 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8371 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8372 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8373 }
8374 }
8375
8376 /* Execute offload request. The reason that we can copy the request information
8377 from the ioctl structure to the SME structure is that they are laid out
8378 exactly the same. Otherwise, each piece of information would have to be
8379 copied individually. */
8380 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008381 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8382 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008383 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008384 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 __func__);
8386 return -EINVAL;
8387 }
8388
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308389 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 return 0;
8391}
8392
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308393static int iw_set_host_offload(struct net_device *dev,
8394 struct iw_request_info *info,
8395 union iwreq_data *wrqu, char *extra)
8396{
8397 int ret;
8398
8399 vos_ssr_protect(__func__);
8400 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8401 vos_ssr_unprotect(__func__);
8402
8403 return ret;
8404}
8405
8406static int __iw_set_keepalive_params(struct net_device *dev,
8407 struct iw_request_info *info,
8408 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008409{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308410 hdd_adapter_t *pAdapter;
8411 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008412 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008413 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308414 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008415
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308416 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308417 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8418 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8421 "%s: Adapter is NULL",__func__);
8422 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008423 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308424 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8425 ret = wlan_hdd_validate_context(pHddCtx);
8426 if (0 != ret)
8427 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308428 return ret;
8429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008431 hddLog(VOS_TRACE_LEVEL_INFO,
8432 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8433 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008434
8435 switch (pRequest->packetType)
8436 {
8437 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008438 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 break;
8440
8441 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8442
Arif Hussain6d2a3322013-11-17 19:50:10 -08008443 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008444 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008445
8446 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8447 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8448 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8449
8450 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8451 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8452 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8453
8454 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8455 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8456 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8457 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8458 break;
8459
8460 }
8461
8462 /* Execute keep alive request. The reason that we can copy the request information
8463 from the ioctl structure to the SME structure is that they are laid out
8464 exactly the same. Otherwise, each piece of information would have to be
8465 copied individually. */
8466 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8467
Sushant Kaushikdc3184b2015-10-09 12:00:21 +05308468 hddLog(VOS_TRACE_LEVEL_INFO, "set Keep: TP before SME %d",
8469 keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008470
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008471 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008472 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008474 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 __func__);
8476 return -EINVAL;
8477 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308478 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 return 0;
8480}
8481
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308482static int iw_set_keepalive_params(struct net_device *dev,
8483 struct iw_request_info *info,
8484 union iwreq_data *wrqu, char *extra)
8485{
8486 int ret;
8487 vos_ssr_protect(__func__);
8488 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8489 vos_ssr_unprotect(__func__);
8490
8491 return ret;
8492}
8493
Jeff Johnson295189b2012-06-20 16:38:30 -07008494#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008495int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008496 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008497{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008498 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8499 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008500 int i=0;
8501
8502 if (pHddCtx->cfg_ini->disablePacketFilter)
8503 {
8504 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008505 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008506 return 0;
8507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 /* Debug display of request components. */
8509 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008510 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008511
8512 switch (pRequest->filterAction)
8513 {
8514 case HDD_RCV_FILTER_SET:
8515 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008516 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008517
8518 packetFilterSetReq.filterId = pRequest->filterId;
8519 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8520 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008521 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008522 __func__, pRequest->numParams);
8523 return -EINVAL;
8524 }
8525 packetFilterSetReq.numFieldParams = pRequest->numParams;
8526 packetFilterSetReq.coalesceTime = 0;
8527 packetFilterSetReq.filterType = 1;
8528 for (i=0; i < pRequest->numParams; i++)
8529 {
8530 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8531 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8532 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8533 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8534 packetFilterSetReq.paramsData[i].reserved = 0;
8535
Arif Hussain6d2a3322013-11-17 19:50:10 -08008536 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8538 packetFilterSetReq.filterType);
8539
Arif Hussain6d2a3322013-11-17 19:50:10 -08008540 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
Mahesh A Saptasagarc1ad3092015-10-27 15:40:18 +05308542 if ((sizeof(packetFilterSetReq.paramsData[i].compareData)) <
8543 (pRequest->paramsData[i].dataLength))
8544 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008545
8546 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8547 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8548 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8549 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8550
Arif Hussain6d2a3322013-11-17 19:50:10 -08008551 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008552 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8553 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8554 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8555
Arif Hussain6d2a3322013-11-17 19:50:10 -08008556 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008557 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8558 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8559 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8560 }
8561
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008562 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008563 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008564 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 __func__);
8566 return -EINVAL;
8567 }
8568
8569 break;
8570
8571 case HDD_RCV_FILTER_CLEAR:
8572
Arif Hussain6d2a3322013-11-17 19:50:10 -08008573 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008574 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008575 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008576 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008578 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008579 __func__);
8580 return -EINVAL;
8581 }
8582 break;
8583
8584 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008585 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008586 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008587 return -EINVAL;
8588 }
8589 return 0;
8590}
8591
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308592int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8593 tANI_U8 sessionId)
8594{
8595 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8596 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8597
8598 if (NULL == pHddCtx)
8599 {
8600 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8601 return -EINVAL;
8602 }
8603
8604 if (pHddCtx->isLogpInProgress)
8605 {
8606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8607 "%s:LOGP in Progress. Ignore!!!", __func__);
8608 return -EBUSY;
8609 }
8610
8611 if (pHddCtx->cfg_ini->disablePacketFilter)
8612 {
8613 hddLog(VOS_TRACE_LEVEL_ERROR,
8614 "%s: Packet Filtering Disabled. Returning ",
8615 __func__ );
8616 return -EINVAL;
8617 }
8618
8619 switch (filterType)
8620 {
8621 /* For setting IPV6 MC and UC Filter we need to configure
8622 * 2 filters, one for MC and one for UC.
8623 * The Filter ID shouldn't be swapped, which results in making
8624 * UC Filter ineffective.
8625 * We have Hardcode all the values
8626 *
8627 * Reason for a seperate UC filter is because, driver need to
8628 * specify the FW that the specific filter is for unicast
8629 * otherwise FW will not pass the unicast frames by default
8630 * through the filter. This is required to avoid any performance
8631 * hits when no unicast filter is set and only MC/BC are set.
8632 * The way driver informs host is by using the MAC protocol
8633 * layer, CMP flag set to MAX, CMP Data set to 1.
8634 */
8635
8636 case HDD_FILTER_IPV6_MC_UC:
8637 /* Setting IPV6 MC Filter below
8638 */
8639 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8640 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8641 packetFilterSetReq.numFieldParams = 2;
8642 packetFilterSetReq.paramsData[0].protocolLayer =
8643 HDD_FILTER_PROTO_TYPE_MAC;
8644 packetFilterSetReq.paramsData[0].cmpFlag =
8645 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8646 packetFilterSetReq.paramsData[0].dataOffset =
8647 WLAN_HDD_80211_FRM_DA_OFFSET;
8648 packetFilterSetReq.paramsData[0].dataLength = 1;
8649 packetFilterSetReq.paramsData[0].compareData[0] =
8650 HDD_IPV6_MC_CMP_DATA;
8651
8652 packetFilterSetReq.paramsData[1].protocolLayer =
8653 HDD_FILTER_PROTO_TYPE_ARP;
8654 packetFilterSetReq.paramsData[1].cmpFlag =
8655 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8656 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8657 packetFilterSetReq.paramsData[1].dataLength = 2;
8658 packetFilterSetReq.paramsData[1].compareData[0] =
8659 HDD_IPV6_CMP_DATA_0;
8660 packetFilterSetReq.paramsData[1].compareData[1] =
8661 HDD_IPV6_CMP_DATA_1;
8662
8663
8664 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8665 &packetFilterSetReq, sessionId))
8666 {
8667 hddLog(VOS_TRACE_LEVEL_ERROR,
8668 "%s: Failure to execute Set IPv6 Mulicast Filter",
8669 __func__);
8670 return -EINVAL;
8671 }
8672
8673 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8674
8675 /*
8676 * Setting IPV6 UC Filter below
8677 */
8678 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8679 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8680 packetFilterSetReq.numFieldParams = 2;
8681 packetFilterSetReq.paramsData[0].protocolLayer =
8682 HDD_FILTER_PROTO_TYPE_MAC;
8683 packetFilterSetReq.paramsData[0].cmpFlag =
8684 HDD_FILTER_CMP_TYPE_MAX;
8685 packetFilterSetReq.paramsData[0].dataOffset = 0;
8686 packetFilterSetReq.paramsData[0].dataLength = 1;
8687 packetFilterSetReq.paramsData[0].compareData[0] =
8688 HDD_IPV6_UC_CMP_DATA;
8689
8690 packetFilterSetReq.paramsData[1].protocolLayer =
8691 HDD_FILTER_PROTO_TYPE_ARP;
8692 packetFilterSetReq.paramsData[1].cmpFlag =
8693 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8694 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8695 packetFilterSetReq.paramsData[1].dataLength = 2;
8696 packetFilterSetReq.paramsData[1].compareData[0] =
8697 HDD_IPV6_CMP_DATA_0;
8698 packetFilterSetReq.paramsData[1].compareData[1] =
8699 HDD_IPV6_CMP_DATA_1;
8700
8701 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8702 &packetFilterSetReq, sessionId))
8703 {
8704 hddLog(VOS_TRACE_LEVEL_ERROR,
8705 "%s: Failure to execute Set IPv6 Unicast Filter",
8706 __func__);
8707 return -EINVAL;
8708 }
8709
8710 break;
8711
8712 case HDD_FILTER_IPV6_MC:
8713 /*
8714 * IPV6 UC Filter might be already set,
8715 * clear the UC Filter. As the Filter
8716 * IDs are static, we can directly clear it.
8717 */
8718 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8719 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8720 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8721 &packetFilterClrReq, sessionId))
8722 {
8723 hddLog(VOS_TRACE_LEVEL_ERROR,
8724 "%s: Failure to execute Clear IPv6 Unicast Filter",
8725 __func__);
8726 return -EINVAL;
8727 }
8728
8729 /*
8730 * Setting IPV6 MC Filter below
8731 */
8732 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8733 packetFilterSetReq.numFieldParams = 2;
8734 packetFilterSetReq.paramsData[0].protocolLayer =
8735 HDD_FILTER_PROTO_TYPE_MAC;
8736 packetFilterSetReq.paramsData[0].cmpFlag =
8737 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8738 packetFilterSetReq.paramsData[0].dataOffset =
8739 WLAN_HDD_80211_FRM_DA_OFFSET;
8740 packetFilterSetReq.paramsData[0].dataLength = 1;
8741 packetFilterSetReq.paramsData[0].compareData[0] =
8742 HDD_IPV6_MC_CMP_DATA;
8743
8744 packetFilterSetReq.paramsData[1].protocolLayer =
8745 HDD_FILTER_PROTO_TYPE_ARP;
8746 packetFilterSetReq.paramsData[1].cmpFlag =
8747 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8748 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8749 packetFilterSetReq.paramsData[1].dataLength = 2;
8750 packetFilterSetReq.paramsData[1].compareData[0] =
8751 HDD_IPV6_CMP_DATA_0;
8752 packetFilterSetReq.paramsData[1].compareData[1] =
8753 HDD_IPV6_CMP_DATA_1;
8754
8755
8756 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8757 &packetFilterSetReq, sessionId))
8758 {
8759 hddLog(VOS_TRACE_LEVEL_ERROR,
8760 "%s: Failure to execute Set IPv6 Multicast Filter",
8761 __func__);
8762 return -EINVAL;
8763 }
8764 break;
8765
8766 default :
8767 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8768 "%s: Packet Filter Request: Invalid",
8769 __func__);
8770 return -EINVAL;
8771 }
8772 return 0;
8773}
8774
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308775void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008776{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308777 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308778 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008779 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308780 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008781
Yue Ma3ede6052013-08-29 00:33:26 -07008782 if (NULL == pHddCtx)
8783 {
8784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8785 return;
8786 }
8787
8788 hHal = pHddCtx->hHal;
8789
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308790 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008791 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308792 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8793 return;
8794 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308795
8796 /* Check if INI is enabled or not, other wise just return
8797 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308798 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308799 {
8800 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8801 if (NULL == pMulticastAddrs)
8802 {
8803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8804 return;
8805 }
8806
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 if (set)
8808 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308809 /* Following pre-conditions should be satisfied before wei
8810 * configure the MC address list.
8811 */
8812 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8813 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8814 && pAdapter->mc_addr_list.mc_cnt
8815 && (eConnectionState_Associated ==
8816 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8817 {
8818 pMulticastAddrs->ulMulticastAddrCnt =
8819 pAdapter->mc_addr_list.mc_cnt;
8820 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8821 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008822 memcpy(pMulticastAddrs->multicastAddr[i],
8823 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308824 sizeof(pAdapter->mc_addr_list.addr[i]));
8825 hddLog(VOS_TRACE_LEVEL_INFO,
8826 "%s: %s multicast filter: addr ="
8827 MAC_ADDRESS_STR,
8828 __func__, set ? "setting" : "clearing",
8829 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8830 }
8831 /* Set multicast filter */
8832 sme_8023MulticastList(hHal, pAdapter->sessionId,
8833 pMulticastAddrs);
8834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008835 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308836 else
8837 {
8838 /* Need to clear only if it was previously configured
8839 */
8840 if (pAdapter->mc_addr_list.isFilterApplied)
8841 {
8842 pMulticastAddrs->ulMulticastAddrCnt = 0;
8843 sme_8023MulticastList(hHal, pAdapter->sessionId,
8844 pMulticastAddrs);
8845 }
8846
8847 }
8848 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008849 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008850 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308851 else
8852 {
8853 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308854 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308855 }
8856 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008857}
8858
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308859static int __iw_set_packet_filter_params(struct net_device *dev,
8860 struct iw_request_info *info,
8861 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308862{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308863 hdd_adapter_t *pAdapter;
8864 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008865 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308866 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308867 struct iw_point s_priv_data;
8868
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308869 ENTER();
Hanumantha Reddy Pothulad75a8d82015-10-27 21:55:28 +05308870
8871 if (!capable(CAP_NET_ADMIN))
8872 {
8873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8874 FL("permission check failed"));
8875 return -EPERM;
8876 }
8877
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308878 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8879 if (NULL == pAdapter)
8880 {
8881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8882 "%s: Adapter is NULL",__func__);
8883 return -EINVAL;
8884 }
8885 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8886 ret = wlan_hdd_validate_context(pHddCtx);
8887 if (0 != ret)
8888 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308889 return ret;
8890 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308891 if (hdd_priv_get_data(&s_priv_data, wrqu))
8892 {
8893 return -EINVAL;
8894 }
8895
8896 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8897 {
8898 return -EINVAL;
8899 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008900
Arif Hussain0273cba2014-01-07 20:58:29 -08008901 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308902 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8903 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008904 if (NULL == pRequest)
8905 {
8906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8907 "mem_alloc_copy_from_user_helper fail");
8908 return -ENOMEM;
8909 }
8910
8911 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8912 kfree(pRequest);
8913
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308914 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008915 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008916}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308917
8918static int iw_set_packet_filter_params(struct net_device *dev,
8919 struct iw_request_info *info,
8920 union iwreq_data *wrqu, char *extra)
8921{
8922 int ret;
8923
8924 vos_ssr_protect(__func__);
8925 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8926 vos_ssr_unprotect(__func__);
8927
8928 return ret;
8929}
Jeff Johnson295189b2012-06-20 16:38:30 -07008930#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308931static int __iw_get_statistics(struct net_device *dev,
8932 struct iw_request_info *info,
8933 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008934{
8935
8936 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8937 eHalStatus status = eHAL_STATUS_SUCCESS;
8938 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308939 hdd_adapter_t *pAdapter;
8940 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308942 int tlen = 0, ret = 0;
8943 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008944
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308945 tCsrGlobalClassAStatsInfo *aStats;
8946 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008947
8948 ENTER();
8949
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308950 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8951 if (NULL == pAdapter)
8952 {
8953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8954 "%s: Adapter is NULL",__func__);
8955 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008956 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308957 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8958 ret = wlan_hdd_validate_context(pHddCtx);
8959 if (0 != ret)
8960 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308961 return ret;
8962 }
8963 pStats = &(pAdapter->hdd_stats.summary_stat);
8964 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8965 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8967
8968 wrqu->txpower.value = 0;
8969 }
8970 else {
8971 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8972 SME_SUMMARY_STATS |
8973 SME_GLOBAL_CLASSA_STATS |
8974 SME_GLOBAL_CLASSB_STATS |
8975 SME_GLOBAL_CLASSC_STATS |
8976 SME_GLOBAL_CLASSD_STATS |
8977 SME_PER_STA_STATS,
8978 hdd_StatisticsCB, 0, FALSE,
8979 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8980
8981 if (eHAL_STATUS_SUCCESS != status)
8982 {
8983 hddLog(VOS_TRACE_LEVEL_ERROR,
8984 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008985 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 return -EINVAL;
8987 }
8988
8989 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308990 if (NULL == pWextState)
8991 {
8992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8993 "%s: pWextState is NULL",__func__);
8994 return -EINVAL;
8995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008996
8997 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8998 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8999 {
9000 hddLog(VOS_TRACE_LEVEL_ERROR,
9001 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009002 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009003 /*Remove the SME statistics list by passing NULL in callback argument*/
9004 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
9005 SME_SUMMARY_STATS |
9006 SME_GLOBAL_CLASSA_STATS |
9007 SME_GLOBAL_CLASSB_STATS |
9008 SME_GLOBAL_CLASSC_STATS |
9009 SME_GLOBAL_CLASSD_STATS |
9010 SME_PER_STA_STATS,
9011 NULL, 0, FALSE,
9012 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
9013
9014 return -EINVAL;
9015 }
9016 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
9017 (tANI_U8) sizeof (pStats->retry_cnt),
9018 (char*) &(pStats->retry_cnt[0]),
9019 tlen);
9020
9021 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
9022 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
9023 (char*) &(pStats->multiple_retry_cnt[0]),
9024 tlen);
9025
9026 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
9027 (tANI_U8) sizeof (pStats->tx_frm_cnt),
9028 (char*) &(pStats->tx_frm_cnt[0]),
9029 tlen);
9030
9031 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
9032 (tANI_U8) sizeof (pStats->rx_frm_cnt),
9033 (char*) &(pStats->rx_frm_cnt),
9034 tlen);
9035
9036 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
9037 (tANI_U8) sizeof (pStats->frm_dup_cnt),
9038 (char*) &(pStats->frm_dup_cnt),
9039 tlen);
9040
9041 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
9042 (tANI_U8) sizeof (pStats->fail_cnt),
9043 (char*) &(pStats->fail_cnt[0]),
9044 tlen);
9045
9046 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
9047 (tANI_U8) sizeof (pStats->rts_fail_cnt),
9048 (char*) &(pStats->rts_fail_cnt),
9049 tlen);
9050
9051 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
9052 (tANI_U8) sizeof (pStats->ack_fail_cnt),
9053 (char*) &(pStats->ack_fail_cnt),
9054 tlen);
9055
9056 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
9057 (tANI_U8) sizeof (pStats->rts_succ_cnt),
9058 (char*) &(pStats->rts_succ_cnt),
9059 tlen);
9060
9061 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
9062 (tANI_U8) sizeof (pStats->rx_discard_cnt),
9063 (char*) &(pStats->rx_discard_cnt),
9064 tlen);
9065
9066 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
9067 (tANI_U8) sizeof (pStats->rx_error_cnt),
9068 (char*) &(pStats->rx_error_cnt),
9069 tlen);
9070
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009071 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07009072 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009073 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 tlen);
9075
9076 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
9077 (tANI_U8) sizeof (dStats->rx_byte_cnt),
9078 (char*) &(dStats->rx_byte_cnt),
9079 tlen);
9080
9081 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
9082 (tANI_U8) sizeof (dStats->rx_rate),
9083 (char*) &(dStats->rx_rate),
9084 tlen);
9085
9086 /* Transmit rate, in units of 500 kbit/sec */
9087 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
9088 (tANI_U8) sizeof (aStats->tx_rate),
9089 (char*) &(aStats->tx_rate),
9090 tlen);
9091
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009092 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
9093 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
9094 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009095 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009096 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
9097 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
9098 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009099 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009100 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
9101 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
9102 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009103 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009104 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
9105 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
9106 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07009107 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009108 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
9109 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
9110 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009111 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009112 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
9113 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
9114 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07009115 tlen);
9116
Jeff Johnson295189b2012-06-20 16:38:30 -07009117 wrqu->data.length = tlen;
9118
9119 }
9120
9121 EXIT();
9122
9123 return 0;
9124}
9125
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309126static int iw_get_statistics(struct net_device *dev,
9127 struct iw_request_info *info,
9128 union iwreq_data *wrqu, char *extra)
9129{
9130 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009131
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309132 vos_ssr_protect(__func__);
9133 ret = __iw_get_statistics(dev, info, wrqu, extra);
9134 vos_ssr_unprotect(__func__);
9135
9136 return ret;
9137}
Jeff Johnson295189b2012-06-20 16:38:30 -07009138#ifdef FEATURE_WLAN_SCAN_PNO
9139
9140/*Max Len for PNO notification*/
9141#define MAX_PNO_NOTIFY_LEN 100
9142void found_pref_network_cb (void *callbackContext,
9143 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9144{
9145 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9146 union iwreq_data wrqu;
9147 char buf[MAX_PNO_NOTIFY_LEN+1];
9148
9149 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
9150 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9151
9152 // create the event
9153 memset(&wrqu, 0, sizeof(wrqu));
9154 memset(buf, 0, sizeof(buf));
9155
9156 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
9157 pPrefNetworkFoundInd->ssId.ssId,
9158 (unsigned int)pPrefNetworkFoundInd->rssi);
9159
9160 wrqu.data.pointer = buf;
9161 wrqu.data.length = strlen(buf);
9162
9163 // send the event
9164
9165 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9166
9167}
9168
9169
9170/*string based input*/
9171VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
9172 union iwreq_data *wrqu, char *extra, int nOffset)
9173{
9174 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05309175 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07009176 /* pnoRequest is a large struct, so we make it static to avoid stack
9177 overflow. This API is only invoked via ioctl, so it is
9178 serialized by the kernel rtnl_lock and hence does not need to be
9179 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309180 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07009181 char *ptr;
9182 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05309183 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9185
9186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9187 "PNO data len %d data %s",
9188 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009189 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009190
9191 if (wrqu->data.length <= nOffset )
9192 {
9193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
9194 return VOS_STATUS_E_FAILURE;
9195 }
9196
9197 pnoRequest.enable = 0;
9198 pnoRequest.ucNetworksCount = 0;
9199 /*-----------------------------------------------------------------------
9200 Input is string based and expected to be like this:
9201
9202 <enabled> <netw_count>
9203 for each network:
9204 <ssid_len> <ssid> <authentication> <encryption>
9205 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9206 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
9207
9208 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07009209 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 -07009210
9211 this translates into:
9212 -----------------------------
9213 enable PNO
9214 look for 2 networks:
9215 test - with authentication type 0 and encryption type 0,
9216 that can be found on 3 channels: 1 6 and 11 ,
9217 SSID bcast type is unknown (directed probe will be sent if AP not found)
9218 and must meet -40dBm RSSI
9219
9220 test2 - with auth and enrytption type 4/4
9221 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9222 bcast type is non-bcast (directed probe will be sent)
9223 and must not meet any RSSI threshold
9224
Jeff Johnson8301aa12013-03-28 14:27:29 -07009225 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009227 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009228
Wilson Yang623f6592013-10-08 16:33:37 -07009229 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9230 {
9231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9232 "PNO enable input is not valid %s",ptr);
9233 return VOS_STATUS_E_FAILURE;
9234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009235
9236 if ( 0 == pnoRequest.enable )
9237 {
9238 /*Disable PNO*/
9239 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309240 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9241 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009242 pAdapter->sessionId,
9243 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309244 if (eHAL_STATUS_SUCCESS != status)
9245 {
9246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9247 "%s: failed to disable PNO", __func__);
9248 return VOS_STATUS_E_FAILURE;
9249 }
9250 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 return VOS_STATUS_SUCCESS;
9252 }
9253
c_hpothu37f21312014-04-09 21:49:54 +05309254 if (TRUE == pHddCtx->isPnoEnable)
9255 {
9256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9257 FL("already PNO is enabled"));
9258 return -EBUSY;
9259 }
9260 pHddCtx->isPnoEnable = TRUE;
9261
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009263
9264 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9265 {
9266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9267 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309268 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009270
9271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9272 "PNO enable %d networks count %d offset %d",
9273 pnoRequest.enable,
9274 pnoRequest.ucNetworksCount,
9275 nOffset);
9276
9277 /* Parameters checking:
9278 ucNetworksCount has to be larger than 0*/
9279 if (( 0 == pnoRequest.ucNetworksCount ) ||
9280 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9281 {
9282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309283 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 }
9285
9286 ptr += nOffset;
9287
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309288 pnoRequest.aNetworks =
9289 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9290 if (pnoRequest.aNetworks == NULL)
9291 {
9292 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9293 FL("failed to allocate memory aNetworks %u"),
9294 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9295 goto error;
9296 }
9297 vos_mem_zero(pnoRequest.aNetworks,
9298 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9299
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9301 {
9302
9303 pnoRequest.aNetworks[i].ssId.length = 0;
9304
Wilson Yang623f6592013-10-08 16:33:37 -07009305 ucParams = sscanf(ptr,"%hhu %n",
9306 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9307
9308 if (1 != ucParams)
9309 {
9310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9311 "PNO ssid length input is not valid %s",ptr);
9312 return VOS_STATUS_E_FAILURE;
9313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009314
9315 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9316 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9317 {
9318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9319 "SSID Len %d is not correct for network %d",
9320 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309321 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009322 }
9323
9324 /*Advance to SSID*/
9325 ptr += nOffset;
9326
Jeff Johnson8301aa12013-03-28 14:27:29 -07009327 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009328 pnoRequest.aNetworks[i].ssId.length);
9329 ptr += pnoRequest.aNetworks[i].ssId.length;
9330
Jeff Johnson02797792013-10-26 19:17:13 -07009331 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009332 &(pnoRequest.aNetworks[i].authentication),
9333 &(pnoRequest.aNetworks[i].encryption),
9334 &(pnoRequest.aNetworks[i].ucChannelCount),
9335 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009336
Wilson Yang623f6592013-10-08 16:33:37 -07009337 if ( 3 != ucParams )
9338 {
9339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9340 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309341 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009342 }
9343
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009345 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009346 "auth %d encry %d channel count %d offset %d",
9347 pnoRequest.aNetworks[i].ssId.length,
9348 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9349 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9350 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9351 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9352 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9353 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9354 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9355 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9356 pnoRequest.aNetworks[i].authentication,
9357 pnoRequest.aNetworks[i].encryption,
9358 pnoRequest.aNetworks[i].ucChannelCount,
9359 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009360
Jeff Johnson295189b2012-06-20 16:38:30 -07009361 /*Advance to channel list*/
9362 ptr += nOffset;
9363
Wilson Yang623f6592013-10-08 16:33:37 -07009364 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009365 {
9366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9367 "Incorrect number of channels");
9368 return VOS_STATUS_E_FAILURE;
9369 }
9370
9371 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9372 {
9373 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9374 {
Wilson Yang623f6592013-10-08 16:33:37 -07009375 if (1 != sscanf(ptr,"%hhu %n",
9376 &(pnoRequest.aNetworks[i].aChannels[j]),
9377 &nOffset))
9378 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9379 "PNO network channel input is not valid %s",ptr);
9380 return VOS_STATUS_E_FAILURE;
9381 }
9382 /*Advance to next channel number*/
9383 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009384 }
9385 }
9386
Jeff Johnson02797792013-10-26 19:17:13 -07009387 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009388 &(pnoRequest.aNetworks[i].bcastNetwType),
9389 &nOffset))
9390 {
9391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9392 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309393 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009395
9396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9397 "PNO bcastNetwType %d offset %d",
9398 pnoRequest.aNetworks[i].bcastNetwType,
9399 nOffset );
9400
9401 /*Advance to rssi Threshold*/
9402 ptr += nOffset;
9403
Wilson Yang623f6592013-10-08 16:33:37 -07009404 if (1 != sscanf(ptr,"%hhu %n",
9405 &(pnoRequest.aNetworks[i].rssiThreshold),
9406 &nOffset))
9407 {
9408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9409 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309410 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009412
9413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9414 "PNO rssi %d offset %d",
9415 pnoRequest.aNetworks[i].rssiThreshold,
9416 nOffset );
9417 /*Advance to next network*/
9418 ptr += nOffset;
9419 }/*For ucNetworkCount*/
9420
9421 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009422 &(pnoRequest.scanTimers.ucScanTimersCount),
9423 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009424
9425 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009426 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 {
9428 ptr += nOffset;
9429
Jeff Johnson8301aa12013-03-28 14:27:29 -07009430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9431 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 pnoRequest.scanTimers.ucScanTimersCount,
9433 nOffset );
9434
9435 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9436 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309439 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 }
9441
9442 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9443 {
Jeff Johnson02797792013-10-26 19:17:13 -07009444 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9446 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9447 &nOffset);
9448
Wilson Yang623f6592013-10-08 16:33:37 -07009449 if (2 != ucParams)
9450 {
9451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9452 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309453 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009454 }
9455
Jeff Johnson8301aa12013-03-28 14:27:29 -07009456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9457 "PNO Timer value %d Timer repeat %d offset %d",
9458 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9460 nOffset );
9461
Jeff Johnson295189b2012-06-20 16:38:30 -07009462 ptr += nOffset;
9463 }
9464
9465 }
9466 else
9467 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9469 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009470 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9471
9472 /*Scan timers defaults to 5 minutes*/
9473 pnoRequest.scanTimers.ucScanTimersCount = 1;
9474 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9475 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9476 }
9477
Wilson Yang623f6592013-10-08 16:33:37 -07009478 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009479
9480 pnoRequest.modePNO = ucMode;
9481 /*for LA we just expose suspend option*/
9482 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9483 {
9484 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9485 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309486 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9487 if (pnoRequest.p24GProbeTemplate == NULL){
9488 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9489 FL("failed to allocate memory p24GProbeTemplate %u"),
9490 SIR_PNO_MAX_PB_REQ_SIZE);
9491 goto error;
9492 }
9493
9494 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9495 if (pnoRequest.p5GProbeTemplate == NULL){
9496 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9497 FL("failed to allocate memory p5GProbeTemplate %u"),
9498 SIR_PNO_MAX_PB_REQ_SIZE);
9499 goto error;
9500 }
9501
9502 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9503 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009504
c_hpothu37f21312014-04-09 21:49:54 +05309505 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 pAdapter->sessionId,
9507 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309508 if (eHAL_STATUS_SUCCESS == status)
9509 {
9510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9511 "%s: PNO enabled", __func__);
9512 return VOS_STATUS_SUCCESS;
9513 }
9514error:
9515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9516 "%s: Failed to enable PNO", __func__);
9517 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309518 if (pnoRequest.aNetworks)
9519 vos_mem_free(pnoRequest.aNetworks);
9520 if (pnoRequest.p24GProbeTemplate)
9521 vos_mem_free(pnoRequest.p24GProbeTemplate);
9522 if (pnoRequest.p5GProbeTemplate)
9523 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309524 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009525}/*iw_set_pno*/
9526
9527VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9528 union iwreq_data *wrqu, char *extra, int nOffset)
9529{
9530 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9531 v_U8_t rssiThreshold = 0;
9532 v_U8_t nRead;
9533
Arif Hussain7adce1b2013-11-11 22:59:34 -08009534 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009535 &rssiThreshold);
9536
9537 if ( 1 != nRead )
9538 {
9539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9540 "Incorrect format");
9541 return VOS_STATUS_E_FAILURE;
9542 }
9543
9544 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9545 return VOS_STATUS_SUCCESS;
9546}
9547
9548
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309549static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 struct iw_request_info *info,
9551 union iwreq_data *wrqu, char *extra)
9552{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309553 hdd_adapter_t *pAdapter;
9554 hdd_context_t *pHddCtx;
9555 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309556 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309557
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309558 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309559 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9560 if (NULL == pAdapter)
9561 {
9562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9563 "%s: Adapter is NULL",__func__);
9564 return -EINVAL;
9565 }
9566
9567 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9568 ret = wlan_hdd_validate_context(pHddCtx);
9569 if (0 != ret)
9570 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309571 return ret;
9572 }
9573
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009574
9575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009576 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009577
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309578 status = iw_set_pno(dev,info,wrqu,extra,0);
9579
9580 EXIT();
9581 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009582}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309583
9584static int iw_set_pno_priv(struct net_device *dev,
9585 struct iw_request_info *info,
9586 union iwreq_data *wrqu, char *extra)
9587{
9588 int ret;
9589
9590 vos_ssr_protect(__func__);
9591 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9592 vos_ssr_unprotect(__func__);
9593
9594 return ret;
9595}
Jeff Johnson295189b2012-06-20 16:38:30 -07009596#endif /*FEATURE_WLAN_SCAN_PNO*/
9597
9598//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309599int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009600{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309601 hdd_adapter_t *pAdapter;
9602 tHalHandle hHal;
9603 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309604 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309605 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309606 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309608 eCsrBand connectedBand;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309609 tpAniSirGlobal pMac;
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309610 int retval = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309611
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309612 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309613 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9614 if (NULL == pAdapter)
9615 {
9616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9617 "%s: Adapter is NULL",__func__);
9618 return -EINVAL;
9619 }
9620 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9621 retval = wlan_hdd_validate_context(pHddCtx);
9622 if (0 != retval)
9623 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309624 return retval;
9625 }
9626 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9627 if (NULL == hHal)
9628 {
9629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9630 "%s: Hal Context is NULL",__func__);
9631 return -EINVAL;
9632 }
9633 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009634
Atul Mittal54378cb2014-04-02 16:51:50 +05309635 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 {
9637 case WLAN_HDD_UI_BAND_AUTO:
9638 band = eCSR_BAND_ALL;
9639 break;
9640 case WLAN_HDD_UI_BAND_5_GHZ:
9641 band = eCSR_BAND_5G;
9642 break;
9643 case WLAN_HDD_UI_BAND_2_4_GHZ:
9644 band = eCSR_BAND_24;
9645 break;
9646 default:
9647 band = eCSR_BAND_MAX;
9648 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309649 connectedBand =
9650 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009651
Atul Mittal54378cb2014-04-02 16:51:50 +05309652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009653 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009654
9655 if (band == eCSR_BAND_MAX)
9656 {
9657 /* Received change band request with invalid band value */
9658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309659 "%s: Invalid band value %u", __func__, ui_band);
9660 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009661 }
9662
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309663 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309664 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309665 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009667 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009668 band, pHddCtx->cfg_ini->nBandCapability);
9669 return -EIO;
9670 }
9671
Sushant Kaushik1165f872015-03-30 20:25:27 +05309672 if (band == eCSR_BAND_ALL)
9673 {
9674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9675 "received. Setting band same as ini value %d"),
9676 pHddCtx->cfg_ini->nBandCapability);
9677 band = pHddCtx->cfg_ini->nBandCapability;
9678 }
9679
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9681 {
9682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9683 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009684 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 return -EIO;
9686 }
9687
9688 if (currBand != band)
9689 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309690 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309691 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309692 /* Return failure if current country code is world regulatory domain*/
9693 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9694 pMac->scan.countryCodeCurrent[1] == '0') )
9695 {
9696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9697 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309698 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309699 return -EAGAIN;
9700 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309701 }
9702
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 /* Change band request received.
9704 * Abort pending scan requests, flush the existing scan results,
9705 * and change the band capability
9706 */
9707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9708 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009709 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009710
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309711 /* We need to change the band and flush the scan results here itself
9712 * as we may get timeout for disconnection in which we will return
9713 * with out doing any of these
9714 */
9715 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9716 {
9717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9718 "%s: failed to set the band value to %u ",
9719 __func__, band);
9720 return -EINVAL;
9721 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309722 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9723 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309724 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309725 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9726 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309727 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309728 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9729 * information available in NV so to get the channel information from kernel
9730 * we need to send regulatory hint for the currunt country
9731 * And to set the same country again we need to set the dummy country
9732 * first and then the actual country.
9733 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309734#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9735 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9736#else
9737 regulatory_hint_user("00");
9738#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309739 wait_result = wait_for_completion_interruptible_timeout(
9740 &pHddCtx->linux_reg_req,
9741 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9742
9743 /* if the country information does not exist with the kernel,
9744 then the driver callback would not be called */
9745
9746 if (wait_result >= 0)
9747 {
9748 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9749 "runtime country code is found in kernel db");
9750 }
9751 else
9752 {
9753 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9754 "runtime country code is not found"
9755 " in kernel db");
9756 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309757
9758 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309759
9760 /*
9761 * Update 11dcountry and current country here as the hint
9762 * with 00 results in 11d and current country with 00
9763 */
9764 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9765 WNI_CFG_COUNTRY_CODE_LEN);
9766 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9767 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309768#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9769 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9770#else
9771 regulatory_hint_user(curr_country);
9772#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309773 wait_result = wait_for_completion_interruptible_timeout(
9774 &pHddCtx->linux_reg_req,
9775 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9776
9777 /* if the country information does not exist with the kernel,
9778 then the driver callback would not be called */
9779 if (wait_result >= 0)
9780 {
9781 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9782 "runtime country code is found in kernel db");
9783 }
9784 else
9785 {
9786 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9787 "runtime country code is not found"
9788 " in kernel db");
9789 }
9790
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309791 retval = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309792 }
9793 else
9794 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309795#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309796 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9797 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309798#else
9799 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9800#endif
9801
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309802 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309803 pScanInfo = &pHddCtx->scan_info;
9804 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9805 {
9806 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9807 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9808 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309809 sme_FilterScanResults(hHal, pAdapter->sessionId);
9810
9811 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309812 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9813 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009814 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009815 eHalStatus status = eHAL_STATUS_SUCCESS;
9816 long lrc;
9817
9818 /* STA already connected on current band, So issue disconnect first,
9819 * then change the band*/
9820
9821 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309822 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309823 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009824
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9826
9827 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9828 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9829
Jeff Johnson43971f52012-07-17 12:26:56 -07009830 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 {
9832 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009833 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009834 __func__, (int)status );
9835 return -EINVAL;
9836 }
9837
9838 lrc = wait_for_completion_interruptible_timeout(
9839 &pAdapter->disconnect_comp_var,
9840 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9841
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309842 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009843
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009844 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009845 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009846
9847 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9848 }
9849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009850 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309851 EXIT();
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05309852 if (TRUE == pHddCtx->isSetBandByNL)
9853 return 0;
9854 else
9855 return retval;
Jeff Johnson295189b2012-06-20 16:38:30 -07009856}
9857
Atul Mittal54378cb2014-04-02 16:51:50 +05309858int hdd_setBand_helper(struct net_device *dev, const char *command)
9859{
9860 u8 band;
9861
9862 /*convert the band value from ascii to integer*/
9863 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9864
9865 return hdd_setBand(dev, band);
9866
9867}
9868
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309869static int __iw_set_band_config(struct net_device *dev,
9870 struct iw_request_info *info,
9871 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009872{
Atul Mittal54378cb2014-04-02 16:51:50 +05309873 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009874
Arif Hussain0273cba2014-01-07 20:58:29 -08009875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009876
Hanumantha Reddy Pothulaf473d662015-10-27 21:58:39 +05309877 if (!capable(CAP_NET_ADMIN))
9878 {
9879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9880 FL("permission check failed"));
9881 return -EPERM;
9882 }
9883
Atul Mittal54378cb2014-04-02 16:51:50 +05309884 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009885}
9886
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309887static int iw_set_band_config(struct net_device *dev,
9888 struct iw_request_info *info,
9889 union iwreq_data *wrqu, char *extra)
9890{
9891 int ret;
9892
9893 vos_ssr_protect(__func__);
9894 ret = __iw_set_band_config(dev, info, wrqu, extra);
9895 vos_ssr_unprotect(__func__);
9896
9897 return ret;
9898}
9899
c_manjeecfd1efb2015-09-25 19:32:34 +05309900static int get_fwr_memdump(struct net_device *dev,
9901 struct iw_request_info *info,
9902 union iwreq_data *wrqu, char *extra)
9903{
9904 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9905 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9906 int ret;
9907 ENTER();
9908 // HddCtx sanity
9909 ret = wlan_hdd_validate_context(pHddCtx);
9910 if (0 != ret)
9911 {
9912 return ret;
9913 }
9914 if( !pHddCtx->cfg_ini->enableFwrMemDump ||
9915 (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)))
9916 {
9917 hddLog(VOS_TRACE_LEVEL_INFO, FL("FW dump Logging not supported"));
9918 return -EINVAL;
9919 }
9920 ret = wlan_hdd_fw_mem_dump_req(pHddCtx);
9921
9922 EXIT();
9923 return ret;
9924}
9925
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309926static int __iw_set_power_params_priv(struct net_device *dev,
9927 struct iw_request_info *info,
9928 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009929{
Arif Hussain0273cba2014-01-07 20:58:29 -08009930 int ret;
9931 char *ptr;
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +05309932
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9934 "Set power params Private");
Hanumantha Reddy Pothula27244162015-10-27 22:10:50 +05309935
9936 if (!capable(CAP_NET_ADMIN))
9937 {
9938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9939 FL("permission check failed"));
9940 return -EPERM;
9941 }
9942
Arif Hussain0273cba2014-01-07 20:58:29 -08009943 /* ODD number is used for set, copy data using copy_from_user */
9944 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9945 wrqu->data.length);
9946 if (NULL == ptr)
9947 {
9948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9949 "mem_alloc_copy_from_user_helper fail");
9950 return -ENOMEM;
9951 }
9952
9953 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9954 kfree(ptr);
9955 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009956}
9957
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309958static int iw_set_power_params_priv(struct net_device *dev,
9959 struct iw_request_info *info,
9960 union iwreq_data *wrqu, char *extra)
9961{
9962 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009963
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309964 vos_ssr_protect(__func__);
9965 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9966 vos_ssr_unprotect(__func__);
9967
9968 return ret;
9969}
Jeff Johnson295189b2012-06-20 16:38:30 -07009970
9971/*string based input*/
9972VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9973 union iwreq_data *wrqu, char *extra, int nOffset)
9974{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309975 hdd_adapter_t *pAdapter;
9976 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009977 tSirSetPowerParamsReq powerRequest;
9978 char *ptr;
9979 v_U8_t ucType;
9980 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309981 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009982
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309983 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309984 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9985 if (NULL == pAdapter)
9986 {
9987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9988 "%s: Adapter is NULL",__func__);
9989 return -EINVAL;
9990 }
9991
9992 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9993 ret = wlan_hdd_validate_context(pHddCtx);
9994 if (0 != ret)
9995 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309996 return ret;
9997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9999 "Power Params data len %d data %s",
10000 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -080010001 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -070010002
10003 if (wrqu->data.length <= nOffset )
10004 {
10005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
10006 return VOS_STATUS_E_FAILURE;
10007 }
10008
10009 uTotalSize = wrqu->data.length - nOffset;
10010
10011 /*-----------------------------------------------------------------------
10012 Input is string based and expected to be like this:
10013
10014 <param_type> <param_value> <param_type> <param_value> ...
10015
10016 e.g:
10017 1 2 2 3 3 0 4 1 5 1
10018
10019 e.g. setting just a few:
10020 1 2 4 1
10021
10022 parameter types:
10023 -----------------------------
10024 1 - Ignore DTIM
10025 2 - Listen Interval
10026 3 - Broadcast Multicas Filter
10027 4 - Beacon Early Termination
10028 5 - Beacon Early Termination Interval
10029 -----------------------------------------------------------------------*/
10030 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
10031 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
10032 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
10033 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
10034 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
10035
Arif Hussain7adce1b2013-11-11 22:59:34 -080010036 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010037
10038 while ( uTotalSize )
10039 {
Wilson Yang6f971452013-10-08 15:00:00 -070010040 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
10041 {
10042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10043 "Invalid input parameter type %s",ptr);
10044 return VOS_STATUS_E_FAILURE;
10045 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010046
10047 uTotalSize -= nOffset;
10048
10049 if (!uTotalSize)
10050 {
10051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010052 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010053 ucType, nOffset);
10054 return VOS_STATUS_E_FAILURE;
10055 }
10056
10057 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -070010058
Jeff Johnson02797792013-10-26 19:17:13 -070010059 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -070010060 {
10061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10062 "Invalid input parameter value %s",ptr);
10063 return VOS_STATUS_E_FAILURE;
10064 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010065
10066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10067 "Power request parameter %d value %d offset %d",
10068 ucType, uValue, nOffset);
10069
10070 switch (ucType)
10071 {
10072 case eSIR_IGNORE_DTIM:
10073 powerRequest.uIgnoreDTIM = uValue;
10074 break;
10075 case eSIR_LISTEN_INTERVAL:
10076 powerRequest.uListenInterval = uValue;
10077 break;
10078 case eSIR_MCAST_BCAST_FILTER:
10079 powerRequest.uBcastMcastFilter = uValue;
10080 break;
10081 case eSIR_ENABLE_BET:
10082 powerRequest.uEnableBET = uValue;
10083 break;
10084 case eSIR_BET_INTERVAL:
10085 powerRequest.uBETInterval = uValue;
10086 break;
10087 default:
10088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -080010089 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 ucType, uValue, nOffset);
10091 return VOS_STATUS_E_FAILURE;
10092 }
10093
10094 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10096 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -070010097 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -070010099 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010100 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -070010101 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
10102 {
10103 uTotalSize = 0;
10104 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010105
10106 }/*Go for as long as we have a valid string*/
10107
10108 /* put the device into full power*/
10109 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
10110
10111 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -080010112 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070010113
10114 /* put the device back to power save*/
10115 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
10116
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010117 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010118 return VOS_STATUS_SUCCESS;
10119}/*iw_set_power_params*/
10120
Atul Mittalc0f739f2014-07-31 13:47:47 +053010121// tdlsoffchan
10122#ifdef FEATURE_WLAN_TDLS
10123
Atul Mittal87ec2422014-09-24 13:12:50 +053010124int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010125{
10126 if (offchannel < 0 || offchannel > 165)
10127 {
10128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
10129 __func__, offchannel);
10130 return -1;
10131
10132 }
10133
10134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
10135 __func__, tdlsOffCh, offchannel);
10136
10137 tdlsOffCh = offchannel;
10138 return 0;
10139}
10140
Atul Mittal87ec2422014-09-24 13:12:50 +053010141int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010142{
10143 if (offchanoffset == 0)
10144 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010145 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10147 __func__, tdlsOffChBwOffset);
10148
10149 return 0;
10150
10151 }
10152
10153 if ( offchanoffset == 40 )
10154 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010155 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +053010156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10157 __func__, tdlsOffChBwOffset);
10158
10159 return 0;
10160
10161 }
10162 if (offchanoffset == -40)
10163 {
10164 tdlsOffChBwOffset = 3;
10165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
10166 __func__, tdlsOffChBwOffset);
10167
10168 return 0;
10169
10170 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +053010171
10172 if ((offchanoffset == 80) &&
10173 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
10174 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
10175 {
10176 tdlsOffChBwOffset = 4;
10177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10178 "%s: change tdls secondary off channel offset to %u",
10179 __func__, tdlsOffChBwOffset);
10180
10181 return 0;
10182 }
Atul Mittalc0f739f2014-07-31 13:47:47 +053010183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
10184 __func__, offchanoffset);
10185 return -1;
10186}
10187
Atul Mittal87ec2422014-09-24 13:12:50 +053010188int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +053010189{
10190 hddTdlsPeer_t *connPeer = NULL;
10191 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10192 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10193
10194 if (offchanmode < 0 || offchanmode > 4)
10195 {
10196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10197 "%s: Invalid tdls off channel mode %d",
10198 __func__, offchanmode);
10199 return -1;
10200 }
10201
10202 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
10203 {
10204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10205 "%s: tdls off channel mode req in not associated state %d",
10206 __func__, offchanmode);
10207 return -1;
10208 }
10209
10210 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
10211 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
10212 {
10213 /* Send TDLS Channel Switch Request to connected peer */
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010214 mutex_lock(&pHddCtx->tdls_lock);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053010215 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010216 if (NULL == connPeer) {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010217 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10219 "%s: No TDLS Connected Peer", __func__);
10220 return -1;
10221 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +053010222 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittalc0f739f2014-07-31 13:47:47 +053010223 }
10224 else
10225 {
10226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10227 "%s: TDLS Connection not supported", __func__);
10228 return -1;
10229 }
10230
10231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10232 ("%s: TDLS Channel Switch in swmode=%d"),
10233 __func__, offchanmode);
10234
10235 switch (offchanmode)
10236 {
10237 case 1:/*Enable*/
10238 case 2:/*Disable*/
10239 {
10240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10241 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
10242 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10243 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
10244 {
10245
10246 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
10247 pAdapter->sessionId, connPeer->peerMac,
10248 tdlsOffCh, tdlsOffChBwOffset,
10249 offchanmode);
10250 }
10251 else
10252 {
10253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10254 "%s: TDLS Off Channel not supported", __func__);
10255 return -1;
10256 }
10257 break;
10258 }
10259 case 3:
10260 {
10261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10262 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10263 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10264
10265 break;
10266 }
10267 case 4:
10268 {
10269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10270 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10271 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10272 break;
10273 }
10274 default:
10275 {
10276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10277 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10278 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10279 break;
10280 }
10281
10282 }
10283
10284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10285 __func__, offchanmode);
10286 return 0;
10287}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010288#endif
10289
Jeff Johnson295189b2012-06-20 16:38:30 -070010290
10291// Define the Wireless Extensions to the Linux Network Device structure
10292// A number of these routines are NULL (meaning they are not implemented.)
10293
10294static const iw_handler we_handler[] =
10295{
10296 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10297 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10298 (iw_handler) NULL, /* SIOCSIWNWID */
10299 (iw_handler) NULL, /* SIOCGIWNWID */
10300 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10301 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10302 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10303 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10304 (iw_handler) NULL, /* SIOCSIWSENS */
10305 (iw_handler) NULL, /* SIOCGIWSENS */
10306 (iw_handler) NULL, /* SIOCSIWRANGE */
10307 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10308 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
10309 (iw_handler) NULL, /* SIOCGIWPRIV */
10310 (iw_handler) NULL, /* SIOCSIWSTATS */
10311 (iw_handler) NULL, /* SIOCGIWSTATS */
10312 iw_handler_set_spy, /* SIOCSIWSPY */
10313 iw_handler_get_spy, /* SIOCGIWSPY */
10314 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10315 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10316 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10317 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10318 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10319 (iw_handler) NULL, /* SIOCGIWAPLIST */
10320 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10321 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10322 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10323 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10324 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10325 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10326 (iw_handler) NULL, /* -- hole -- */
10327 (iw_handler) NULL, /* -- hole -- */
10328 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10329 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10330 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10331 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10332 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10333 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10334 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10335 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10336 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10337 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10338 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10339 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10340 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10341 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10342 (iw_handler) NULL, /* -- hole -- */
10343 (iw_handler) NULL, /* -- hole -- */
10344 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10345 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10346 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10347 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10348 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10349 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10350 (iw_handler) NULL, /* SIOCSIWPMKSA */
10351};
10352
10353static const iw_handler we_private[] = {
10354
10355 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10356 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10357 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10358 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10359 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10360 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010361 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010362 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10363 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10364 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010365#ifdef FEATURE_OEM_DATA_SUPPORT
10366 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10367 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10368#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010369
Jeff Johnson295189b2012-06-20 16:38:30 -070010370#ifdef WLAN_FEATURE_VOWIFI_11R
10371 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10372#endif
10373 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10374 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10375 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10376#ifdef WLAN_FEATURE_PACKET_FILTERING
10377 ,
10378 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10379#endif
10380#ifdef FEATURE_WLAN_SCAN_PNO
10381 ,
10382 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10383#endif
10384 ,
10385 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10386 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10387 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10388 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010389 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010390};
10391
10392/*Maximum command length can be only 15 */
10393static const struct iw_priv_args we_private_args[] = {
10394
Katya Nigamf0511f62015-05-05 16:40:57 +053010395 { WE_SET_MONITOR_STATE,
10396 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10397 0, "monitor" },
10398
Jeff Johnson295189b2012-06-20 16:38:30 -070010399 /* handlers for main ioctl */
10400 { WLAN_PRIV_SET_INT_GET_NONE,
10401 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10402 0,
10403 "" },
10404
10405 /* handlers for sub-ioctl */
10406 { WE_SET_11D_STATE,
10407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10408 0,
10409 "set11Dstate" },
10410
10411 { WE_WOWL,
10412 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10413 0,
10414 "wowl" },
10415
10416 { WE_SET_POWER,
10417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10418 0,
10419 "setPower" },
10420
10421 { WE_SET_MAX_ASSOC,
10422 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10423 0,
10424 "setMaxAssoc" },
10425
10426 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10428 0,
10429 "setAutoChannel" },
10430
10431 { WE_SET_DATA_INACTIVITY_TO,
10432 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10433 0,
10434 "inactivityTO" },
10435
10436 { WE_SET_MAX_TX_POWER,
10437 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10438 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010439 "setMaxTxPower" },
10440
10441 { WE_SET_MAX_TX_POWER_2_4,
10442 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10443 0,
10444 "setTxMaxPower2G" },
10445
10446 { WE_SET_MAX_TX_POWER_5_0,
10447 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10448 0,
10449 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010450
10451 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10452 * as well to keep same syntax as in SAP. Now onwards, STA
10453 * will support both */
10454 { WE_SET_MAX_TX_POWER,
10455 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10456 0,
10457 "setTxMaxPower" },
10458
Jeff Johnson295189b2012-06-20 16:38:30 -070010459 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10460 * 1 = enable and 0 = disable */
10461 {
10462 WE_SET_HIGHER_DTIM_TRANSITION,
10463 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10464 0,
10465 "setHDtimTransn" },
10466
10467 { WE_SET_TM_LEVEL,
10468 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010469 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010470 "setTmLevel" },
10471
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010472 { WE_ENABLE_STRICT_FCC_REG,
10473 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10474 0,
10475 "setStrictFCCreg" },
10476
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010477 { WE_SET_DEBUG_LOG,
10478 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10479 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010480#ifdef FEATURE_WLAN_TDLS
10481 {
10482 WE_SET_TDLS_OFF_CHAN,
10483 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10484 0,
10485 "tdlsoffchan" },
10486 {
10487 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10488 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10489 0,
10490 "tdlsecchnoffst" },
10491 {
10492 WE_SET_TDLS_OFF_CHAN_MODE,
10493 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10494 0,
10495 "tdlsoffchnmode" },
10496#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010497
Peng Xu2446a892014-09-05 17:21:18 +053010498 { WE_SET_SCAN_BAND_PREFERENCE,
10499 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10500 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010501 {
10502 WE_GET_FRAME_LOG,
10503 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10504 0,
10505 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010506
Abhishek Singh01c73d12015-03-12 15:13:44 +053010507 { WE_SET_MIRACAST_VENDOR_CONFIG,
10508 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10509 0, "setMiracstConf" },
10510
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010511#ifdef FEATURE_WLAN_TDLS
10512 {
10513 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10514 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10515 0,
10516 "tdls_2040bsscox" },
10517#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010518 { WE_SET_RTS_CTS_HTVHT,
10519 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10520 0, "setRtsCtsHtVht" },
Sushant Kaushik33200572015-08-05 16:46:20 +053010521 { WE_SET_PKT_STATS_ENABLE_DISABLE,
10522 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10523 0, "setPktStats" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010524 /* handlers for main ioctl */
10525 { WLAN_PRIV_SET_NONE_GET_INT,
10526 0,
10527 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10528 "" },
10529
10530 /* handlers for sub-ioctl */
10531 { WE_GET_11D_STATE,
10532 0,
10533 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10534 "get11Dstate" },
10535
10536 { WE_IBSS_STATUS,
10537 0,
10538 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10539 "getAdhocStatus" },
10540
10541 { WE_PMC_STATE,
10542 0,
10543 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10544 "pmcState" },
10545
10546 { WE_GET_WLAN_DBG,
10547 0,
10548 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10549 "getwlandbg" },
10550
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 { WE_GET_MAX_ASSOC,
10552 0,
10553 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10554 "getMaxAssoc" },
10555
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 { WE_GET_WDI_DBG,
10557 0,
10558 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10559 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010560
10561 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10562 0,
10563 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10564 "getAutoChannel" },
10565
10566 { WE_GET_CONCURRENCY_MODE,
10567 0,
10568 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10569 "getconcurrency" },
10570
Peng Xu2446a892014-09-05 17:21:18 +053010571 { WE_GET_SCAN_BAND_PREFERENCE,
10572 0,
10573 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10574 "get_scan_pref"},
10575
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 /* handlers for main ioctl */
10577 { WLAN_PRIV_SET_CHAR_GET_NONE,
10578 IW_PRIV_TYPE_CHAR| 512,
10579 0,
10580 "" },
10581
10582 /* handlers for sub-ioctl */
10583 { WE_WOWL_ADD_PTRN,
10584 IW_PRIV_TYPE_CHAR| 512,
10585 0,
10586 "wowlAddPtrn" },
10587
10588 { WE_WOWL_DEL_PTRN,
10589 IW_PRIV_TYPE_CHAR| 512,
10590 0,
10591 "wowlDelPtrn" },
10592
10593#if defined WLAN_FEATURE_VOWIFI
10594 /* handlers for sub-ioctl */
10595 { WE_NEIGHBOR_REPORT_REQUEST,
10596 IW_PRIV_TYPE_CHAR | 512,
10597 0,
10598 "neighbor" },
10599#endif
10600 { WE_SET_AP_WPS_IE,
10601 IW_PRIV_TYPE_CHAR| 512,
10602 0,
10603 "set_ap_wps_ie" },
10604
10605 { WE_SET_CONFIG,
10606 IW_PRIV_TYPE_CHAR| 512,
10607 0,
10608 "setConfig" },
10609
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010610 { WE_SET_ENCRYPT_MSG,
10611 IW_PRIV_TYPE_CHAR| 512,
10612 0,
10613 "encryptMsg" },
10614
10615
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 /* handlers for main ioctl */
10617 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10619 0,
10620 "" },
10621
10622 /* handlers for sub-ioctl */
10623 { WE_SET_WLAN_DBG,
10624 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10625 0,
10626 "setwlandbg" },
10627
Jeff Johnson295189b2012-06-20 16:38:30 -070010628 { WE_SET_WDI_DBG,
10629 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10630 0,
10631 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010632
10633 { WE_SET_SAP_CHANNELS,
10634 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10635 0,
10636 "setsapchannels" },
10637
10638 /* handlers for main ioctl */
10639 { WLAN_PRIV_GET_CHAR_SET_NONE,
10640 0,
10641 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10642 "" },
10643
10644 /* handlers for sub-ioctl */
10645 { WE_WLAN_VERSION,
10646 0,
10647 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10648 "version" },
10649 { WE_GET_STATS,
10650 0,
10651 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10652 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010653 { WE_GET_STATES,
10654 0,
10655 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10656 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010657 { WE_GET_CFG,
10658 0,
10659 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10660 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010661#ifdef WLAN_FEATURE_11AC
10662 { WE_GET_RSSI,
10663 0,
10664 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10665 "getRSSI" },
10666#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010667#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010668 { WE_GET_ROAM_RSSI,
10669 0,
10670 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10671 "getRoamRSSI" },
10672#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010673 { WE_GET_WMM_STATUS,
10674 0,
10675 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10676 "getWmmStatus" },
10677 {
10678 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010679 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010680 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10681 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010682#ifdef FEATURE_WLAN_TDLS
10683 {
10684 WE_GET_TDLS_PEERS,
10685 0,
10686 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10687 "getTdlsPeers" },
10688#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010689#ifdef WLAN_FEATURE_11W
10690 {
10691 WE_GET_11W_INFO,
10692 0,
10693 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10694 "getPMFInfo" },
10695#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010696 { WE_GET_SNR,
10697 0,
10698 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10699 "getSNR" },
10700
Jeff Johnson295189b2012-06-20 16:38:30 -070010701 /* handlers for main ioctl */
10702 { WLAN_PRIV_SET_NONE_GET_NONE,
10703 0,
10704 0,
10705 "" },
10706
10707 /* handlers for sub-ioctl */
10708 { WE_CLEAR_STATS,
10709 0,
10710 0,
10711 "clearStats" },
10712 { WE_INIT_AP,
10713 0,
10714 0,
10715 "initAP" },
10716 { WE_STOP_AP,
10717 0,
10718 0,
10719 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010720#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 { WE_ENABLE_AMP,
10722 0,
10723 0,
10724 "enableAMP" },
10725 { WE_DISABLE_AMP,
10726 0,
10727 0,
10728 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010729#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010730 { WE_ENABLE_DXE_STALL_DETECT,
10731 0,
10732 0,
10733 "dxeStallDetect" },
10734 { WE_DISPLAY_DXE_SNAP_SHOT,
10735 0,
10736 0,
10737 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010738 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10739 0,
10740 0,
10741 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010742 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010743 WE_SET_REASSOC_TRIGGER,
10744 0,
10745 0,
10746 "reassoc" },
10747 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010748 WE_STOP_OBSS_SCAN,
10749 0,
10750 0,
10751 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010752 {
10753 WE_DUMP_ROAM_TIMER_LOG,
10754 0,
10755 0,
10756 "dumpRoamDelay" },
10757 {
10758 WE_RESET_ROAM_TIMER_LOG,
10759 0,
10760 0,
10761 "resetRoamDelay" },
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010762 {
10763 WE_GET_FW_LOGS,
10764 0,
10765 0,
10766 "getFwLogs" },
c_manjeecfd1efb2015-09-25 19:32:34 +053010767 {
10768 WE_GET_FW_MEMDUMP,
10769 0,
10770 0,
10771 "getFwMemDump" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010772 /* handlers for main ioctl */
10773 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10774 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10775 0,
10776 "" },
10777
Sachin Ahuja715aafc2015-07-21 23:35:10 +053010778
10779
Jeff Johnson295189b2012-06-20 16:38:30 -070010780 /* handlers for sub-ioctl */
10781 { WE_LOG_DUMP_CMD,
10782 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10783 0,
10784 "dump" },
10785
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010786 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010787 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10788 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10789 0,
10790 "setdumplog" },
10791
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010792 { WE_MTRACE_DUMP_CMD,
10793 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10794 0,
10795 "dumplog" },
10796
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010797 /* handlers for sub ioctl */
10798 {
10799 WE_MCC_CONFIG_CREDENTIAL,
10800 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10801 0,
10802 "setMccCrdnl" },
10803
10804 /* handlers for sub ioctl */
10805 {
10806 WE_MCC_CONFIG_PARAMS,
10807 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10808 0,
10809 "setMccConfig" },
10810
Chilam NG571c65a2013-01-19 12:27:36 +053010811#ifdef FEATURE_WLAN_TDLS
10812 /* handlers for sub ioctl */
10813 {
10814 WE_TDLS_CONFIG_PARAMS,
10815 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10816 0,
10817 "setTdlsConfig" },
10818#endif
10819
Katya Nigamf0511f62015-05-05 16:40:57 +053010820 {
10821 WE_CONFIGURE_MONITOR_MODE,
10822 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10823 0,
10824 "MonitorModeConf" },
10825
10826 {
10827 WE_SET_MONITOR_MODE_FILTER,
10828 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10829 0,
10830 "MonitorFilter" },
10831
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 /* handlers for main ioctl */
10833 { WLAN_PRIV_ADD_TSPEC,
10834 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10835 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10836 "addTspec" },
10837
10838 /* handlers for main ioctl */
10839 { WLAN_PRIV_DEL_TSPEC,
10840 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10841 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10842 "delTspec" },
10843
10844 /* handlers for main ioctl */
10845 { WLAN_PRIV_GET_TSPEC,
10846 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10847 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10848 "getTspec" },
10849
Jeff Johnsone7245742012-09-05 17:12:55 -070010850#ifdef FEATURE_OEM_DATA_SUPPORT
10851 /* handlers for main ioctl - OEM DATA */
10852 {
10853 WLAN_PRIV_SET_OEM_DATA_REQ,
10854 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10855 0,
10856 "set_oem_data_req" },
10857
10858 /* handlers for main ioctl - OEM DATA */
10859 {
10860 WLAN_PRIV_GET_OEM_DATA_RSP,
10861 0,
10862 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10863 "get_oem_data_rsp" },
10864#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010865
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 /* handlers for main ioctl - host offload */
10867 {
10868 WLAN_PRIV_SET_HOST_OFFLOAD,
10869 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10870 0,
10871 "setHostOffload" },
10872
10873 {
10874 WLAN_GET_WLAN_STATISTICS,
10875 0,
10876 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10877 "getWlanStats" },
10878
10879 {
10880 WLAN_SET_KEEPALIVE_PARAMS,
10881 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10882 0,
10883 "setKeepAlive" },
10884#ifdef WLAN_FEATURE_PACKET_FILTERING
10885 {
10886 WLAN_SET_PACKET_FILTER_PARAMS,
10887 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10888 0,
10889 "setPktFilter" },
10890#endif
10891#ifdef FEATURE_WLAN_SCAN_PNO
10892 {
10893 WLAN_SET_PNO,
10894 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10895 0,
10896 "setpno" },
10897#endif
10898 {
10899 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010900 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010901 0,
10902 "SETBAND" },
10903 /* handlers for dynamic MC BC ioctl */
10904 {
10905 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010906 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010907 0,
10908 "setMCBCFilter" },
10909 {
10910 WLAN_PRIV_CLEAR_MCBC_FILTER,
10911 0,
10912 0,
10913 "clearMCBCFilter" },
10914 {
10915 WLAN_SET_POWER_PARAMS,
10916 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10917 0,
10918 "setpowerparams" },
10919 {
10920 WLAN_GET_LINK_SPEED,
10921 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010922 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010923};
10924
10925
10926
10927const struct iw_handler_def we_handler_def = {
10928 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10929 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10930 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10931
10932 .standard = (iw_handler *)we_handler,
10933 .private = (iw_handler *)we_private,
10934 .private_args = we_private_args,
10935 .get_wireless_stats = get_wireless_stats,
10936};
10937
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010938int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10939{
10940 v_U32_t cmd = 288; //Command to RIVA
10941 hdd_context_t *pHddCtx = NULL;
10942 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10943 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10944 /*
10945 *configMccParam : specify the bit which needs to be modified
10946 *allowed to update based on wlan_qcom_cfg.ini
10947 * configuration
10948 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10949 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10950 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10951 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10952 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10953 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10954 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10955 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10956 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10957 * Bit 9 : Reserved
10958 */
10959 switch (arg1)
10960 {
10961 //Update MCC SCHEDULE_TIME_SLICE parameter
10962 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10963 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10964 {
10965 if((arg2 >= 5) && (arg2 <= 20))
10966 {
10967 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10968 }
10969 else
10970 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010971 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010972 return 0;
10973 }
10974 }
10975 break;
10976
10977 //Update MCC MAX_NULL_SEND_TIME parameter
10978 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10979 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10980 {
10981 if((arg2 >= 1) && (arg2 <= 10))
10982 {
10983 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10984 }
10985 else
10986 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010987 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010988 return 0;
10989 }
10990 }
10991 break;
10992
10993 //Update MCC TX_EARLY_STOP_TIME parameter
10994 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10995 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10996 {
10997 if((arg2 >= 1) && (arg2 <= 10))
10998 {
10999 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11000 }
11001 else
11002 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011003 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011004 return 0;
11005 }
11006 }
11007 break;
11008
11009 //Update MCC RX_DRAIN_TIME parameter
11010 case MCC_RX_DRAIN_TIME_CFG_PARAM :
11011 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
11012 {
11013 if((arg2 >= 1) && (arg2 <= 10))
11014 {
11015 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11016 }
11017 else
11018 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011019 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011020 return 0;
11021 }
11022 }
11023 break;
11024
11025 //Update MCC CHANNEL_SWITCH_TIME parameter
11026 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
11027 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
11028 {
11029 if((arg2 >= 1) && (arg2 <= 20))
11030 {
11031 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11032 }
11033 else
11034 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011035 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011036 return 0;
11037 }
11038 }
11039 break;
11040
11041 //Update MCC MIN_CHANNEL_TIME parameter
11042 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
11043 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
11044 {
11045 if((arg2 >= 5) && (arg2 <= 20))
11046 {
11047 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11048 }
11049 else
11050 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011051 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011052 return 0;
11053 }
11054 }
11055 break;
11056
11057 //Update MCC PARK_BEFORE_TBTT parameter
11058 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
11059 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
11060 {
11061 if((arg2 >= 1) && (arg2 <= 5))
11062 {
11063 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11064 }
11065 else
11066 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011067 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011068 return 0;
11069 }
11070 }
11071 break;
11072
11073 //Update MCC MIN_AFTER_DTIM parameter
11074 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
11075 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
11076 {
11077 if((arg2 >= 5) && (arg2 <= 15))
11078 {
11079 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11080 }
11081 else
11082 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011083 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011084 return 0;
11085 }
11086 }
11087 break;
11088
11089 //Update MCC TOO_CLOSE_MARGIN parameter
11090 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
11091 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
11092 {
11093 if((arg2 >= 1) && (arg2 <= 3))
11094 {
11095 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
11096 }
11097 else
11098 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011099 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011100 return 0;
11101 }
11102 }
11103 break;
11104
11105 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080011106 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080011107 __FUNCTION__,arg1);
11108 break;
11109 }
11110 return 0;
11111}
11112
Jeff Johnson295189b2012-06-20 16:38:30 -070011113int hdd_set_wext(hdd_adapter_t *pAdapter)
11114{
11115 hdd_wext_state_t *pwextBuf;
11116 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011117 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011118
11119 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11120
11121 // Now configure the roaming profile links. To SSID and bssid.
11122 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
11123 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
11124
11125 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
11126 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
11127
11128 /*Set the numOfChannels to zero to scan all the channels*/
11129 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11130 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11131
11132 /* Default is no encryption */
11133 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11134 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11135
11136 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11137 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
11138
11139 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11140
11141 /* Default is no authentication */
11142 pwextBuf->roamProfile.AuthType.numEntries = 1;
11143 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11144
11145 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
11146 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11147
11148 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070011149 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011150
11151 hdd_clearRoamProfileIe(pAdapter);
11152
11153 return VOS_STATUS_SUCCESS;
11154
11155 }
11156
11157int hdd_register_wext(struct net_device *dev)
11158 {
11159 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11160 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11161 VOS_STATUS status;
11162
11163 ENTER();
11164
11165 // Zero the memory. This zeros the profile structure.
11166 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
11167
11168 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
11169
11170
11171 status = hdd_set_wext(pAdapter);
11172
11173 if(!VOS_IS_STATUS_SUCCESS(status)) {
11174
Arif Hussain6d2a3322013-11-17 19:50:10 -080011175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011176 return eHAL_STATUS_FAILURE;
11177 }
11178
11179 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
11180 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011182 return eHAL_STATUS_FAILURE;
11183 }
11184
11185 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
11186 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011188 return eHAL_STATUS_FAILURE;
11189 }
11190
11191 // Register as a wireless device
11192 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11193
11194 EXIT();
11195 return 0;
11196}
11197
11198int hdd_UnregisterWext(struct net_device *dev)
11199{
c_hpothu2a13bc32015-01-21 12:48:54 +053011200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
11201 if (dev != NULL)
11202 {
11203 rtnl_lock();
11204 dev->wireless_handlers = NULL;
11205 rtnl_unlock();
11206 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053011207
Jeff Johnson295189b2012-06-20 16:38:30 -070011208 return 0;
11209}
11210
11211