blob: adcdae0d6878da21a2782080b44ec45639675399 [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
Jeff Johnson295189b2012-06-20 16:38:30 -0700175
176/* Private ioctls and their sub-ioctls */
177#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
178#define WE_GET_11D_STATE 1
179#define WE_IBSS_STATUS 2
180#define WE_PMC_STATE 3
181#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700182#define WE_GET_MAX_ASSOC 6
183#define WE_GET_WDI_DBG 7
184#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
185#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530186#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700187/* Private ioctls and their sub-ioctls */
188#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
189
190/* Private ioctls and their sub-ioctls */
191#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
192#define WE_WOWL_ADD_PTRN 1
193#define WE_WOWL_DEL_PTRN 2
194#if defined WLAN_FEATURE_VOWIFI
195#define WE_NEIGHBOR_REPORT_REQUEST 3
196#endif
197#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
198#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530199#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700200
201/* Private ioctls and their sub-ioctls */
202#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
203#define WE_SET_WLAN_DBG 1
204#define WE_SET_WDI_DBG 2
205#define WE_SET_SAP_CHANNELS 3
206
207/* Private ioctls and their sub-ioctls */
208#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
209#define WE_WLAN_VERSION 1
210#define WE_GET_STATS 2
211#define WE_GET_CFG 3
212#define WE_GET_WMM_STATUS 4
213#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700214#ifdef WLAN_FEATURE_11AC
215#define WE_GET_RSSI 6
216#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800217#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800218#ifdef FEATURE_WLAN_TDLS
219#define WE_GET_TDLS_PEERS 8
220#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700221#ifdef WLAN_FEATURE_11W
222#define WE_GET_11W_INFO 9
223#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530224#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530225#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700226
227/* Private ioctls and their sub-ioctls */
228#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
229#define WE_CLEAR_STATS 1
230#define WE_INIT_AP 2
231#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530232#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700233#define WE_ENABLE_AMP 4
234#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530235#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700236#define WE_ENABLE_DXE_STALL_DETECT 6
237#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700238#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530239#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530240#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530241#define WE_DUMP_ROAM_TIMER_LOG 12
242#define WE_RESET_ROAM_TIMER_LOG 13
Mukul Sharma84f27252014-07-14 18:11:42 +0530243
Jeff Johnson295189b2012-06-20 16:38:30 -0700244/* Private ioctls and their sub-ioctls */
245#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
246#define WE_LOG_DUMP_CMD 1
247
Jeff Johnson295189b2012-06-20 16:38:30 -0700248#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800249//IOCTL to configure MCC params
250#define WE_MCC_CONFIG_CREDENTIAL 3
251#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700252
Chilam NG571c65a2013-01-19 12:27:36 +0530253#ifdef FEATURE_WLAN_TDLS
254#define WE_TDLS_CONFIG_PARAMS 5
255#endif
256
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700257#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530258#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Katya Nigamf0511f62015-05-05 16:40:57 +0530259#define WE_CONFIGURE_MONITOR_MODE 10
260#define WE_SET_MONITOR_MODE_FILTER 11
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700261
Chilam Ng01120412013-02-19 18:32:21 -0800262#ifdef FEATURE_WLAN_TDLS
263#undef MAX_VAR_ARGS
264#define MAX_VAR_ARGS 10
265#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700266#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800267#endif
268
Jeff Johnson295189b2012-06-20 16:38:30 -0700269/* Private ioctls (with no sub-ioctls) */
270/* note that they must be odd so that they have "get" semantics */
271#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
272#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
273#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
274
Girish Gowli464c9c82014-06-09 19:47:53 +0530275/* (SIOCIWFIRSTPRIV + 8) is currently unused */
276/* (SIOCIWFIRSTPRIV + 16) is currently unused */
277/* (SIOCIWFIRSTPRIV + 10) is currently unused */
278/* (SIOCIWFIRSTPRIV + 12) is currently unused */
279/* (SIOCIWFIRSTPRIV + 14) is currently unused */
280/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700281
Jeff Johnsone7245742012-09-05 17:12:55 -0700282#ifdef FEATURE_OEM_DATA_SUPPORT
283/* Private ioctls for setting the measurement configuration */
284#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
285#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
286#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288#ifdef WLAN_FEATURE_VOWIFI_11R
289#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
290#endif
291
292/* Private ioctl for setting the host offload feature */
293#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
294
295/* Private ioctl to get the statistics */
296#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
297
298/* Private ioctl to set the Keep Alive Params */
299#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
300#ifdef WLAN_FEATURE_PACKET_FILTERING
301/* Private ioctl to set the Packet Filtering Params */
302#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
303#endif
304
305#ifdef FEATURE_WLAN_SCAN_PNO
306/* Private ioctl to get the statistics */
307#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
308#endif
309
310#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
311
312#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
313#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700314/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700315
Jeff Johnson295189b2012-06-20 16:38:30 -0700316#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
317#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
318
319#define WLAN_STATS_INVALID 0
320#define WLAN_STATS_RETRY_CNT 1
321#define WLAN_STATS_MUL_RETRY_CNT 2
322#define WLAN_STATS_TX_FRM_CNT 3
323#define WLAN_STATS_RX_FRM_CNT 4
324#define WLAN_STATS_FRM_DUP_CNT 5
325#define WLAN_STATS_FAIL_CNT 6
326#define WLAN_STATS_RTS_FAIL_CNT 7
327#define WLAN_STATS_ACK_FAIL_CNT 8
328#define WLAN_STATS_RTS_SUC_CNT 9
329#define WLAN_STATS_RX_DISCARD_CNT 10
330#define WLAN_STATS_RX_ERROR_CNT 11
331#define WLAN_STATS_TX_BYTE_CNT 12
332
333#define WLAN_STATS_RX_BYTE_CNT 13
334#define WLAN_STATS_RX_RATE 14
335#define WLAN_STATS_TX_RATE 15
336
Jeff Johnsone7245742012-09-05 17:12:55 -0700337#define WLAN_STATS_RX_UC_BYTE_CNT 16
338#define WLAN_STATS_RX_MC_BYTE_CNT 17
339#define WLAN_STATS_RX_BC_BYTE_CNT 18
340#define WLAN_STATS_TX_UC_BYTE_CNT 19
341#define WLAN_STATS_TX_MC_BYTE_CNT 20
342#define WLAN_STATS_TX_BC_BYTE_CNT 21
343
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800344#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
345 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
346 { \
347 *__p++ = __type; \
348 *__p++ = __size; \
349 memcpy(__p, __val, __size); \
350 __p += __size; \
351 __tlen += __size + 2; \
352 } \
353 else \
354 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800355 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800356 } \
357 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700358
359#define VERSION_VALUE_MAX_LEN 32
360
361#define TX_PER_TRACKING_DEFAULT_RATIO 5
362#define TX_PER_TRACKING_MAX_RATIO 10
363#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
364
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530365#define WLAN_ADAPTER 0
366#define P2P_ADAPTER 1
367
Abhishek Singh2ec36ab2014-08-07 16:14:25 +0530368/*
369 * When supplicant sends SETBAND ioctl it queries for channels from
370 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
371 * This is not required if the return type from ioctl is
372 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
373 * event as part of regulatory_hint.
374 */
375enum {
376 SEND_CHANNEL_CHANGE_EVENT = 0,
377 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
378};
379
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800380/*MCC Configuration parameters */
381enum {
382 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
383 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
384 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
385 MCC_RX_DRAIN_TIME_CFG_PARAM,
386 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
387 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
388 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
389 MCC_MIN_AFTER_DTIM_CFG_PARAM,
390 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
391};
392
393int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
394 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
395
Jeff Johnson295189b2012-06-20 16:38:30 -0700396#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800397int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700398 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700399#endif
400
Jeff Johnson295189b2012-06-20 16:38:30 -0700401/**---------------------------------------------------------------------------
402
Arif Hussain0273cba2014-01-07 20:58:29 -0800403 \brief mem_alloc_copy_from_user_helper -
404
405 Helper function to allocate buffer and copy user data.
406
407 \param - wrqu - Pointer to IOCTL Data.
408 len - size
409
410 \return - On Success pointer to buffer, On failure NULL
411
412 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530413void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800414{
415 u8 *ptr = NULL;
416
417 /* in order to protect the code, an extra byte is post appended to the buffer
418 * and the null termination is added. However, when allocating (len+1) byte
419 * of memory, we need to make sure that there is no uint overflow when doing
420 * addition. In theory check len < UINT_MAX protects the uint overflow. For
421 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
422 * guess, now, it is assumed that the private command buffer size is no
423 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
424 */
425 if (len > MAX_USER_COMMAND_SIZE)
426 {
427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
428 "Invalid length");
429 return NULL;
430 }
431
432 ptr = kmalloc(len + 1, GFP_KERNEL);
433 if (NULL == ptr)
434 {
435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
436 "unable to allocate memory");
437 return NULL;
438 }
439
440 if (copy_from_user(ptr, wrqu_data, len))
441 {
442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
443 "%s: failed to copy data to user buffer", __func__);
444 kfree(ptr);
445 return NULL;
446 }
447 ptr[len] = '\0';
448 return ptr;
449}
450
Girish Gowli488ef492014-06-12 18:44:33 +0530451// Function to handle and get compatible struct iw_point passed to ioctl.
452int hdd_priv_get_data(struct iw_point *p_priv_data,
453 union iwreq_data *wrqu)
454{
455 if ((NULL == p_priv_data) || (NULL == wrqu))
456 {
457 return -EINVAL;
458 }
459
460#ifdef CONFIG_COMPAT
461 if (is_compat_task())
462 {
463 struct compat_iw_point *p_compat_priv_data;
464
465 // Compat task: typecast to campat structure and copy the members.
466 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
467
468 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
469 p_priv_data->length = p_compat_priv_data->length;
470 p_priv_data->flags = p_compat_priv_data->flags;
471 }//if(is_compat_task())
472 else
473 {
474#endif //#ifdef CONFIG_COMPAT
475
476 // Non compat task: directly copy the structure.
477 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
478
479#ifdef CONFIG_COMPAT
480 }//else of - if(is_compat_task())
481#endif //#ifdef CONFIG_COMPAT
482
483 return 0;
484}
485
Arif Hussain0273cba2014-01-07 20:58:29 -0800486/**---------------------------------------------------------------------------
487
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 \brief hdd_wlan_get_version() -
489
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800490 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700491
492 \param - pAdapter Pointer to the adapter.
493 wrqu - Pointer to IOCTL REQUEST Data.
494 extra - Pointer to char
495
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800496 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700497
498 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800499void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
500 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700501{
502 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800503 tSirVersionString wcnss_SW_version;
504 tSirVersionString wcnss_HW_version;
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530505 tSirVersionString iris_name;
506 char *pIRISversion;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800507 char *pSWversion;
508 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800511 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
512 sizeof(wcnss_SW_version));
513 if (VOS_IS_STATUS_SUCCESS(status))
514 {
515 pSWversion = wcnss_SW_version;
516 }
517 else
518 {
519 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700520 }
521
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800522 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
523 sizeof(wcnss_HW_version));
524 if (VOS_IS_STATUS_SUCCESS(status))
525 {
526 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800528 else
529 {
530 pHWversion = "Unknown";
531 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700532
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530533 status = wcnss_get_iris_name(iris_name);
534
535 if (!status) {
536 pIRISversion = iris_name;
537 } else {
538 pIRISversion = "Unknown";
539 }
540
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700541 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530542 "Host SW:%s, FW:%s, HW:%s, IRIS_HW:%s",
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800543 QWLAN_VERSIONSTR,
544 pSWversion,
Anand N Sunkad0a3436f2015-05-01 14:22:19 +0530545 pHWversion, pIRISversion);
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800546
547 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700548}
549
Jeff Johnson295189b2012-06-20 16:38:30 -0700550int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
551{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530552 tHalHandle hHal;
553 hdd_context_t *pHddCtx;
554 v_U32_t threshold = 0;
555 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700556
557 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530558 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530559 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
561 "%s: Adapter is NULL",__func__);
562 return -EINVAL;
563 }
564
565 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
566 ret = wlan_hdd_validate_context(pHddCtx);
567 if (0 != ret)
568 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530569 return ret;
570 }
571
572 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
573 if (NULL == hHal)
574 {
575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
576 "%s: Hal Context is NULL",__func__);
577 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700578 }
579
580 if ( eHAL_STATUS_SUCCESS !=
581 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
582 {
c_hpothub8245442013-11-20 23:41:09 +0530583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
584 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 return -EIO;
586 }
587 wrqu->rts.value = threshold;
588
589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800590 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700591
592 EXIT();
593
594 return 0;
595}
596
597int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
598{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530599 tHalHandle hHal;
600 hdd_context_t *pHddCtx;
601 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700602
603 ENTER();
604
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530605 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530606 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
608 "%s: Adapter is NULL",__func__);
609 return -EINVAL;
610 }
611
612 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
613 status = wlan_hdd_validate_context(pHddCtx);
614 if (0 != status)
615 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530616 return status;
617 }
618
619 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
620 if (NULL == hHal)
621 {
622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
623 "%s: Hal Context is NULL",__func__);
624 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 }
626
627 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
628 != eHAL_STATUS_SUCCESS )
629 {
c_hpothub8245442013-11-20 23:41:09 +0530630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
631 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 return -EIO;
633 }
634 wrqu->frag.value = threshold;
635
636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800637 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700638
639 EXIT();
640
641 return 0;
642}
643
644int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
645{
Jeff Johnsone7245742012-09-05 17:12:55 -0700646 int i;
647 if (channel > 0)
648 {
649 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
650 {
651 if (channel == freq_chan_map[i].chan)
652 {
653 *pfreq = freq_chan_map[i].freq;
654 return 1;
655 }
656 }
657 }
658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800659 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700660 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700661}
662
663static v_BOOL_t
664hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
665{
666 v_BOOL_t rsnType = VOS_FALSE;
667 // is the authType supported?
668 switch (authType)
669 {
670 case eCSR_AUTH_TYPE_NONE: //never used
671 rsnType = eANI_BOOLEAN_FALSE;
672 break;
673 // MAC layer authentication types
674 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
675 rsnType = eANI_BOOLEAN_FALSE;
676 break;
677 case eCSR_AUTH_TYPE_SHARED_KEY:
678 rsnType = eANI_BOOLEAN_FALSE;
679 break;
680 case eCSR_AUTH_TYPE_AUTOSWITCH:
681 rsnType = eANI_BOOLEAN_FALSE;
682 break;
683
684 // Upper layer authentication types
685 case eCSR_AUTH_TYPE_WPA:
686 rsnType = eANI_BOOLEAN_TRUE;
687 break;
688 case eCSR_AUTH_TYPE_WPA_PSK:
689 rsnType = eANI_BOOLEAN_TRUE;
690 break;
691 case eCSR_AUTH_TYPE_WPA_NONE:
692 rsnType = eANI_BOOLEAN_TRUE;
693 break;
694#ifdef WLAN_FEATURE_VOWIFI_11R
695 case eCSR_AUTH_TYPE_FT_RSN:
696#endif
697 case eCSR_AUTH_TYPE_RSN:
698 rsnType = eANI_BOOLEAN_TRUE;
699 break;
700#ifdef WLAN_FEATURE_VOWIFI_11R
701 case eCSR_AUTH_TYPE_FT_RSN_PSK:
702#endif
703 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700704#ifdef WLAN_FEATURE_11W
705 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530706 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700707#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 rsnType = eANI_BOOLEAN_TRUE;
709 break;
710 //case eCSR_AUTH_TYPE_FAILED:
711 case eCSR_AUTH_TYPE_UNKNOWN:
712 rsnType = eANI_BOOLEAN_FALSE;
713 break;
714 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800715 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
716 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 rsnType = eANI_BOOLEAN_FALSE;
718 break;
719 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800720 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700721 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 return rsnType;
723}
724
725static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
726{
727 struct statsContext *pStatsContext;
728 hdd_adapter_t *pAdapter;
729
730 if (ioctl_debug)
731 {
732 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700733 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 }
735
736 if (NULL == pContext)
737 {
738 hddLog(VOS_TRACE_LEVEL_ERROR,
739 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700740 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 return;
742 }
743
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 pStatsContext = pContext;
745 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800746
747 /* there is a race condition that exists between this callback
748 function and the caller since the caller could time out either
749 before or while this code is executing. we use a spinlock to
750 serialize these actions */
751 spin_lock(&hdd_context_lock);
752
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
754 {
755 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800756 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 hddLog(VOS_TRACE_LEVEL_WARN,
758 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700759 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 if (ioctl_debug)
761 {
762 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700763 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 }
765 return;
766 }
767
Jeff Johnson72a40512013-12-19 10:14:15 -0800768 /* context is valid so caller is still waiting */
769
770 /* paranoia: invalidate the magic */
771 pStatsContext->magic = 0;
772
773 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +0530775 if (pAdapter->rssi > 0)
776 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -0800777 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800779
780 /* serialization is complete */
781 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700782}
783
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530784static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
785{
786 struct statsContext *pStatsContext;
787 hdd_adapter_t *pAdapter;
788
789 if (ioctl_debug)
790 {
791 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
792 __func__, (int)snr, (int)staId, pContext);
793 }
794
795 if (NULL == pContext)
796 {
797 hddLog(VOS_TRACE_LEVEL_ERROR,
798 "%s: Bad param, pContext [%p]",
799 __func__, pContext);
800 return;
801 }
802
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530803 pStatsContext = pContext;
804 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800805
806 /* there is a race condition that exists between this callback
807 function and the caller since the caller could time out either
808 before or while this code is executing. we use a spinlock to
809 serialize these actions */
810 spin_lock(&hdd_context_lock);
811
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530812 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
813 {
814 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800815 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530816 hddLog(VOS_TRACE_LEVEL_WARN,
817 "%s: Invalid context, pAdapter [%p] magic [%08x]",
818 __func__, pAdapter, pStatsContext->magic);
819 if (ioctl_debug)
820 {
821 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
822 __func__, pAdapter, pStatsContext->magic);
823 }
824 return;
825 }
826
Jeff Johnson72a40512013-12-19 10:14:15 -0800827 /* context is valid so caller is still waiting */
828
829 /* paranoia: invalidate the magic */
830 pStatsContext->magic = 0;
831
832 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530833 pAdapter->snr = snr;
834
Jeff Johnson72a40512013-12-19 10:14:15 -0800835 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530836 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800837
838 /* serialization is complete */
839 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530840}
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
843{
844 struct statsContext context;
845 hdd_context_t *pHddCtx;
846 hdd_station_ctx_t *pHddStaCtx;
847 eHalStatus hstatus;
848 long lrc;
849
850 if (NULL == pAdapter)
851 {
852 hddLog(VOS_TRACE_LEVEL_WARN,
853 "%s: Invalid context, pAdapter", __func__);
854 return VOS_STATUS_E_FAULT;
855 }
856 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
857 {
858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
859 /* return a cached value */
860 *rssi_value = pAdapter->rssi;
861 return VOS_STATUS_SUCCESS;
862 }
863
864 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
865 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
866
mukul sharma8aec69b2015-06-10 22:28:43 +0530867 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
868 {
869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
870 *rssi_value = 0;
871 return VOS_STATUS_SUCCESS;
872 }
873
874 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
875 {
876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
877 "%s: Roaming in progress, hence return last cached RSSI", __func__);
878 *rssi_value = pAdapter->rssi;
879 return VOS_STATUS_SUCCESS;
880 }
881
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 init_completion(&context.completion);
883 context.pAdapter = pAdapter;
884 context.magic = RSSI_CONTEXT_MAGIC;
885
886 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
887 pHddStaCtx->conn_info.staId[ 0 ],
888 pHddStaCtx->conn_info.bssId,
889 &context, pHddCtx->pvosContext);
890 if (eHAL_STATUS_SUCCESS != hstatus)
891 {
892 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700893 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 /* we'll returned a cached value below */
895 }
896 else
897 {
898 /* request was sent -- wait for the response */
899 lrc = wait_for_completion_interruptible_timeout(&context.completion,
900 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 if (lrc <= 0)
902 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800903 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700904 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 /* we'll now returned a cached value below */
906 }
907 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800908
909 /* either we never sent a request, we sent a request and received a
910 response or we sent a request and timed out. if we never sent a
911 request or if we sent a request and got a response, we want to
912 clear the magic out of paranoia. if we timed out there is a
913 race condition such that the callback function could be
914 executing at the same time we are. of primary concern is if the
915 callback function had already verified the "magic" but had not
916 yet set the completion variable when a timeout occurred. we
917 serialize these activities by invalidating the magic while
918 holding a shared spinlock which will cause us to block if the
919 callback is currently executing */
920 spin_lock(&hdd_context_lock);
921 context.magic = 0;
922 spin_unlock(&hdd_context_lock);
923
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 *rssi_value = pAdapter->rssi;
925
926 return VOS_STATUS_SUCCESS;
927}
Siddharth Bhal64246172015-02-27 01:04:37 +0530928/**---------------------------------------------------------------------------
929
930 \brief wlan_hdd_get_frame_logs() -
931
932 This function use to get Frames log.
933
934 \param - pAdapter Pointer to the adapter.
935 flag - Specify type of request. Clear and Send request are
936 supported.
937
938 \return - none
939
940 --------------------------------------------------------------------------*/
941VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
942{
Siddharth Bhal64246172015-02-27 01:04:37 +0530943 hdd_context_t *pHddCtx;
944 eHalStatus hstatus;
Siddharth Bhal64246172015-02-27 01:04:37 +0530945
946 if (NULL == pAdapter)
947 {
948 hddLog(VOS_TRACE_LEVEL_WARN,
949 "%s: Invalid context, pAdapter", __func__);
950 return VOS_STATUS_E_FAULT;
951 }
952
953 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
954 if (!pHddCtx->mgmt_frame_logging)
955 {
956 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
957 return VOS_STATUS_E_AGAIN;
958 }
959
Siddharth Bhal4507c262015-04-29 20:20:42 +0530960 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
961 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
962 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +0530963 {
964 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
965 return VOS_STATUS_E_INVAL;
966 }
967
Siddharth Bhal4507c262015-04-29 20:20:42 +0530968 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
969 (!pHddCtx->cfg_ini->enableBMUHWtracing))
970 {
971 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
972 return VOS_STATUS_E_INVAL;
973 }
974
Abhishek Singh611295e2015-07-09 11:11:54 +0530975 hstatus = sme_GetFramesLog(pHddCtx->hHal, flag);
Siddharth Bhal64246172015-02-27 01:04:37 +0530976 if (eHAL_STATUS_SUCCESS != hstatus)
977 {
978 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
Abhishek Singh611295e2015-07-09 11:11:54 +0530979 return VOS_STATUS_E_FAILURE;
Siddharth Bhal64246172015-02-27 01:04:37 +0530980 }
Siddharth Bhal64246172015-02-27 01:04:37 +0530981
982 return VOS_STATUS_SUCCESS;
983}
984
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530985VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
986{
987 struct statsContext context;
988 hdd_context_t *pHddCtx;
989 hdd_station_ctx_t *pHddStaCtx;
990 eHalStatus hstatus;
991 long lrc;
992 int valid;
993
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530994 ENTER();
995
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530996 if (NULL == pAdapter)
997 {
998 hddLog(VOS_TRACE_LEVEL_ERROR,
999 "%s: Invalid context, pAdapter", __func__);
1000 return VOS_STATUS_E_FAULT;
1001 }
1002
1003 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1004
1005 valid = wlan_hdd_validate_context(pHddCtx);
1006 if (0 != valid)
1007 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301008 return VOS_STATUS_E_FAULT;
1009 }
1010
1011 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1012 if (NULL == pHddStaCtx)
1013 {
1014 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1015 return VOS_STATUS_E_FAULT;
1016 }
1017
1018 init_completion(&context.completion);
1019 context.pAdapter = pAdapter;
1020 context.magic = SNR_CONTEXT_MAGIC;
1021
1022 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1023 pHddStaCtx->conn_info.staId[ 0 ],
1024 pHddStaCtx->conn_info.bssId,
1025 &context);
1026 if (eHAL_STATUS_SUCCESS != hstatus)
1027 {
1028 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1029 __func__);
1030 /* we'll returned a cached value below */
1031 }
1032 else
1033 {
1034 /* request was sent -- wait for the response */
1035 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1036 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301037 if (lrc <= 0)
1038 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001039 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301040 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301041 /* we'll now returned a cached value below */
1042 }
1043 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001044
1045 /* either we never sent a request, we sent a request and received a
1046 response or we sent a request and timed out. if we never sent a
1047 request or if we sent a request and got a response, we want to
1048 clear the magic out of paranoia. if we timed out there is a
1049 race condition such that the callback function could be
1050 executing at the same time we are. of primary concern is if the
1051 callback function had already verified the "magic" but had not
1052 yet set the completion variable when a timeout occurred. we
1053 serialize these activities by invalidating the magic while
1054 holding a shared spinlock which will cause us to block if the
1055 callback is currently executing */
1056 spin_lock(&hdd_context_lock);
1057 context.magic = 0;
1058 spin_unlock(&hdd_context_lock);
1059
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301060 *snr = pAdapter->snr;
1061
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301062 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301063 return VOS_STATUS_SUCCESS;
1064}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001065#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001066
1067static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1068{
1069 struct statsContext *pStatsContext;
1070 hdd_adapter_t *pAdapter;
1071 if (ioctl_debug)
1072 {
1073 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1074 __func__, (int)rssi, (int)staId, pContext);
1075 }
1076
1077 if (NULL == pContext)
1078 {
1079 hddLog(VOS_TRACE_LEVEL_ERROR,
1080 "%s: Bad param, pContext [%p]",
1081 __func__, pContext);
1082 return;
1083 }
1084
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001085 pStatsContext = pContext;
1086 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001087
1088 /* there is a race condition that exists between this callback
1089 function and the caller since the caller could time out either
1090 before or while this code is executing. we use a spinlock to
1091 serialize these actions */
1092 spin_lock(&hdd_context_lock);
1093
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001094 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1095 {
1096 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001097 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001098 hddLog(VOS_TRACE_LEVEL_WARN,
1099 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1100 __func__, pAdapter, pStatsContext->magic);
1101 if (ioctl_debug)
1102 {
1103 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1104 __func__, pAdapter, pStatsContext->magic);
1105 }
1106 return;
1107 }
1108
Jeff Johnson72a40512013-12-19 10:14:15 -08001109 /* context is valid so caller is still waiting */
1110
1111 /* paranoia: invalidate the magic */
1112 pStatsContext->magic = 0;
1113
1114 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001115 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301116 if (pAdapter->rssi > 0)
1117 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001118 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001119 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001120
1121 /* serialization is complete */
1122 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001123}
1124
1125
1126
1127VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1128{
1129 struct statsContext context;
1130 hdd_context_t *pHddCtx = NULL;
1131 hdd_station_ctx_t *pHddStaCtx = NULL;
1132 eHalStatus hstatus;
1133 long lrc;
1134
1135 if (NULL == pAdapter)
1136 {
1137 hddLog(VOS_TRACE_LEVEL_WARN,
1138 "%s: Invalid context, pAdapter", __func__);
1139 return VOS_STATUS_E_FAULT;
1140 }
1141 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1142 {
1143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1144 /* return a cached value */
1145 *rssi_value = pAdapter->rssi;
1146 return VOS_STATUS_SUCCESS;
1147 }
1148
1149 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1150 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1151
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301152 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001153 {
1154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1155 /* return a cached value */
1156 *rssi_value = 0;
1157 return VOS_STATUS_SUCCESS;
1158 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301159
1160 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1161 {
1162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1163 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1164 *rssi_value = pAdapter->rssi;
1165 return VOS_STATUS_SUCCESS;
1166 }
1167
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001168 init_completion(&context.completion);
1169 context.pAdapter = pAdapter;
1170 context.magic = RSSI_CONTEXT_MAGIC;
1171
1172 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1173 pHddStaCtx->conn_info.staId[ 0 ],
1174 pHddStaCtx->conn_info.bssId,
1175 &context, pHddCtx->pvosContext);
1176 if (eHAL_STATUS_SUCCESS != hstatus)
1177 {
1178 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1179 __func__);
1180 /* we'll returned a cached value below */
1181 }
1182 else
1183 {
1184 /* request was sent -- wait for the response */
1185 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1186 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001187 if (lrc <= 0)
1188 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001189 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001190 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001191 /* we'll now returned a cached value below */
1192 }
1193 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001194
1195 /* either we never sent a request, we sent a request and received a
1196 response or we sent a request and timed out. if we never sent a
1197 request or if we sent a request and got a response, we want to
1198 clear the magic out of paranoia. if we timed out there is a
1199 race condition such that the callback function could be
1200 executing at the same time we are. of primary concern is if the
1201 callback function had already verified the "magic" but had not
1202 yet set the completion variable when a timeout occurred. we
1203 serialize these activities by invalidating the magic while
1204 holding a shared spinlock which will cause us to block if the
1205 callback is currently executing */
1206 spin_lock(&hdd_context_lock);
1207 context.magic = 0;
1208 spin_unlock(&hdd_context_lock);
1209
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001210 *rssi_value = pAdapter->rssi;
1211
1212 return VOS_STATUS_SUCCESS;
1213}
1214#endif
1215
1216
Jeff Johnson295189b2012-06-20 16:38:30 -07001217void hdd_StatisticsCB( void *pStats, void *pContext )
1218{
1219 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1220 hdd_stats_t *pStatsCache = NULL;
1221 hdd_wext_state_t *pWextState;
1222 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1223
1224 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1225 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1226 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1227 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1228 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1229 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1230
1231 if (pAdapter!= NULL)
1232 pStatsCache = &pAdapter->hdd_stats;
1233
1234
1235 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1236 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1237 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1238 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1239 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1240 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1241
1242 if (pStatsCache!=NULL)
1243 {
1244 // and copy the stats into the cache we keep in the adapter instance structure
1245 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1246 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1247 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1248 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1249 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1250 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1251 }
1252
1253 if(pAdapter)
1254 {
1255 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1256 if(pWextState)
1257 {
1258 vos_status = vos_event_set(&pWextState->vosevent);
1259 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1260 {
1261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001262 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 return;
1264 }
1265 }
1266 }
1267}
1268
1269void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1270{
1271 v_CONTEXT_t pVosContext;
1272 hdd_context_t *pHddCtx;
1273 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1274#if 0
1275 hdd_wext_state_t *pWextState;
1276 v_U32_t roamId;
1277#endif
1278
1279 ENTER();
1280
1281 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1282
1283 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1284 if (NULL == pHddCtx)
1285 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001286 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001287 return;
1288 }
1289#if 0
1290 pWextState = pAdapter->pWextState;
1291#endif
1292
1293 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1294 {
1295 //TODO Verify is this is really used. If yes need to fix it.
1296 hdd_reconnect_all_adapters( pHddCtx );
1297#if 0
1298 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1299 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1300 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1301
1302 if(VOS_STATUS_SUCCESS == vosStatus)
1303 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1304 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1305
1306 sme_RoamConnect(halHandle,
1307 pAdapter->sessionId, &(pWextState->roamProfile),
1308 &roamId);
1309#endif
1310 }
1311
1312 EXIT();
1313
1314}
1315
1316void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1317{
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1319
1320 /* clear WPA/RSN/WSC IE information in the profile */
1321 pWextState->roamProfile.nWPAReqIELength = 0;
1322 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1323 pWextState->roamProfile.nRSNReqIELength = 0;
1324 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1325
Chet Lanctot186b5732013-03-18 10:26:30 -07001326#ifdef FEATURE_WLAN_WAPI
1327 pWextState->roamProfile.nWAPIReqIELength = 0;
1328 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1329#endif
1330
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001332 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301334 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1336 pWextState->roamProfile.nAddIEAssocLength = 0;
1337
1338 pWextState->roamProfile.EncryptionType.numEntries = 1;
1339 pWextState->roamProfile.EncryptionType.encryptionType[0]
1340 = eCSR_ENCRYPT_TYPE_NONE;
1341
1342 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1343 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1344 = eCSR_ENCRYPT_TYPE_NONE;
1345
1346 pWextState->roamProfile.AuthType.numEntries = 1;
1347 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1348
Chet Lanctot186b5732013-03-18 10:26:30 -07001349#ifdef WLAN_FEATURE_11W
1350 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1351 pWextState->roamProfile.MFPRequired = 0;
1352 pWextState->roamProfile.MFPCapable = 0;
1353#endif
1354
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 pWextState->authKeyMgmt = 0;
1356
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301357 vos_mem_zero(&pWextState->roamProfile.Keys,
1358 sizeof(pWextState->roamProfile.Keys));
1359
Jeff Johnson295189b2012-06-20 16:38:30 -07001360#ifdef FEATURE_WLAN_WAPI
1361 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1362 pAdapter->wapi_info.nWapiMode = 0;
1363#endif
1364
1365 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1366
1367}
1368
1369void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1370{
1371 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001372
Nirav Shahf6bd2672015-03-11 12:53:15 +05301373 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001374 {
1375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301376 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001377 }
1378 else
1379 {
1380 complete(&pAdapter->ula_complete);
1381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001382}
1383
1384VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1385{
1386 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001388 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001389
1390 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1391 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001392 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
1394 /*To avoid race condition between the set key and the last EAPOL
1395 packet, notify TL to finish upper layer authentication incase if the
1396 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001397 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001398
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001399 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 {
1401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1402 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1403 __LINE__, vos_status );
1404 return vos_status;
1405
1406 }
1407
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001408 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301410 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001411 {
1412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301413 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001414 /* we'll still fall through and return success since the
1415 * connection may still get established but is just taking
1416 * too long for us to wait */
1417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 }
1419 return VOS_STATUS_SUCCESS;
1420}
1421
1422v_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)
1423{
1424
1425 int left = ie_len;
1426 v_U8_t *ptr = ie;
1427 v_U8_t elem_id,elem_len;
1428 v_U8_t eid = 0xDD;
1429
1430 if ( NULL == ie || 0 == ie_len )
1431 return NULL;
1432
1433 while(left >= 2)
1434 {
1435 elem_id = ptr[0];
1436 elem_len = ptr[1];
1437 left -= 2;
1438 if(elem_len > left)
1439 {
1440 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001441 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 eid,elem_len,left);
1443 return NULL;
1444 }
1445 if (elem_id == eid)
1446 {
1447 if(memcmp( &ptr[2], oui, oui_size)==0)
1448 return ptr;
1449 }
1450
1451 left -= elem_len;
1452 ptr += (elem_len + 2);
1453 }
1454 return NULL;
1455}
1456
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301457static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 union iwreq_data *wrqu, char *extra)
1459{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301460 hdd_adapter_t *pAdapter;
1461 hdd_context_t *pHddCtx;
1462 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301463
1464 ENTER();
1465
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301466 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1467 if (NULL == pAdapter)
1468 {
1469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1470 "%s: pAdapter is NULL\n", __func__);
1471 return -EINVAL;
1472 }
1473 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1474 ret = wlan_hdd_validate_context(pHddCtx);
1475 if (0 != ret)
1476 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301477 return ret;
1478 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301479
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301481
1482 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301483 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001484}
1485
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301486static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1487 union iwreq_data *wrqu, char *extra)
1488{
1489 int ret;
1490
1491 vos_ssr_protect(__func__);
1492 ret = __iw_set_commit(dev, info, wrqu, extra);
1493 vos_ssr_unprotect(__func__);
1494
1495 return ret;
1496}
1497
1498static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 struct iw_request_info *info,
1500 char *wrqu, char *extra)
1501{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301502 hdd_adapter_t *pAdapter;
1503 hdd_context_t *pHddCtx;
1504 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301505
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301507 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1508 if (NULL == pAdapter)
1509 {
1510 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1511 "%s: pAdapter is NULL\n", __func__);
1512 return -EINVAL;
1513 }
1514 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1515 ret = wlan_hdd_validate_context(pHddCtx);
1516 if (0 != ret)
1517 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301518 return ret;
1519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1521 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301522 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001523}
1524
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301525static int iw_get_name(struct net_device *dev,
1526 struct iw_request_info *info,
1527 char *wrqu, char *extra)
1528{
1529 int ret;
1530
1531 vos_ssr_protect(__func__);
1532 ret = __iw_get_name(dev, info, wrqu, extra);
1533 vos_ssr_unprotect(__func__);
1534
1535 return ret;
1536}
1537
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301538static int __iw_set_mode(struct net_device *dev,
1539 struct iw_request_info *info,
1540 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001541{
1542 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301543 hdd_adapter_t *pAdapter;
1544 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 tCsrRoamProfile *pRoamProfile;
1546 eCsrRoamBssType LastBSSType;
1547 eMib_dot11DesiredBssType connectedBssType;
1548 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301550 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001551
1552 ENTER();
1553
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301554 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 if (NULL == pAdapter)
1556 {
1557 hddLog(VOS_TRACE_LEVEL_WARN,
1558 "%s: Invalid context, pAdapter", __func__);
1559 return 0;
1560 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301561 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1562 status = wlan_hdd_validate_context(pHddCtx);
1563 if (0 != status)
1564 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301565 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 }
1567
1568 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1569 if (pWextState == NULL)
1570 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301571 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 return -EINVAL;
1573 }
1574
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 pRoamProfile = &pWextState->roamProfile;
1577 LastBSSType = pRoamProfile->BSSType;
1578
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301579 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001580
1581 switch (wrqu->mode)
1582 {
1583 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301584 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1586 // Set the phymode correctly for IBSS.
1587 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1588 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001589 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001591 break;
1592 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301593 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 break;
1597 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301598 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1600 break;
1601 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301602 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 return -EOPNOTSUPP;
1604 }
1605
1606 if ( LastBSSType != pRoamProfile->BSSType )
1607 {
1608 //the BSS mode changed
1609 // We need to issue disconnect if connected or in IBSS disconnect state
1610 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1611 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1612 {
1613 VOS_STATUS vosStatus;
1614 // need to issue a disconnect to CSR.
1615 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1616 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1617 pAdapter->sessionId,
1618 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1619 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301620 {
1621 long ret;
1622 ret = wait_for_completion_interruptible_timeout(
1623 &pAdapter->disconnect_comp_var,
1624 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1625 if (ret <= 0)
1626 hddLog(VOS_TRACE_LEVEL_ERROR,
1627 FL("failed wait on disconnect_comp_var %ld"), ret);
1628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 }
1630 }
1631
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 EXIT();
1633 return 0;
1634}
1635
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301636static int iw_set_mode(struct net_device *dev,
1637 struct iw_request_info *info,
1638 union iwreq_data *wrqu, char *extra)
1639{
1640 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301642 vos_ssr_protect(__func__);
1643 ret = __iw_set_mode(dev, info, wrqu, extra);
1644 vos_ssr_unprotect(__func__);
1645
1646 return ret;
1647}
1648
1649static int __iw_get_mode(struct net_device *dev,
1650 struct iw_request_info *info,
1651 union iwreq_data *wrqu,
1652 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001653{
1654
1655 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301656 hdd_adapter_t *pAdapter;
1657 hdd_context_t *pHddCtx;
1658 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001659
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301660 ENTER();
1661
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301662 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 if (NULL == pAdapter)
1664 {
1665 hddLog(VOS_TRACE_LEVEL_WARN,
1666 "%s: Invalid context, pAdapter", __func__);
1667 return 0;
1668 }
1669
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301670 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1671 ret = wlan_hdd_validate_context(pHddCtx);
1672 if (0 != ret)
1673 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301674 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1677 if (pWextState == NULL)
1678 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301679 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 return -EINVAL;
1681 }
1682
1683 switch (pWextState->roamProfile.BSSType)
1684 {
1685 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001686 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301687 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 break;
1689 case eCSR_BSS_TYPE_IBSS:
1690 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001691 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301692 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 break;
1694 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001695 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301696 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 break;
1698 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001699 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 break;
1701 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301702
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301703 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 return 0;
1705}
1706
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301707static int iw_get_mode(struct net_device *dev,
1708 struct iw_request_info *info,
1709 union iwreq_data *wrqu,
1710 char *extra)
1711{
1712 int ret;
1713
1714 vos_ssr_protect(__func__);
1715 ret = __iw_get_mode(dev, info, wrqu, extra);
1716 vos_ssr_unprotect(__func__);
1717
1718 return ret;
1719}
1720
1721static int __iw_set_freq(struct net_device *dev,
1722 struct iw_request_info *info,
1723 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001724{
1725 v_U32_t numChans = 0;
1726 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1727 v_U32_t indx = 0;
1728 v_U32_t status = 0;
1729
1730 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301731 hdd_adapter_t *pAdapter;
1732 hdd_context_t *pHddCtx;
1733 tHalHandle hHal;
1734 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301736
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 ENTER();
1738
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301739 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1740 if (NULL == pAdapter)
1741 {
1742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1743 "%s:Invalid Adapter",__func__);
1744 return -EINVAL;
1745 }
1746
1747 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1748 status = wlan_hdd_validate_context(pHddCtx);
1749 if (0 != status)
1750 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 return status;
1752 }
1753
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301754 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1755 if (NULL == hHal)
1756 {
1757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1758 "%s: Hal Context is NULL",__func__);
1759 return -EINVAL;
1760 }
1761
1762 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1763 if (NULL == pHddStaCtx)
1764 {
1765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1766 "%s:STA context is NULL",__func__);
1767 return -EINVAL;
1768 }
1769
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301771 if (NULL == pWextState)
1772 {
1773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1774 "%s: pWextState is NULL",__func__);
1775 return -EINVAL;
1776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001777
1778 pRoamProfile = &pWextState->roamProfile;
1779
Arif Hussain6d2a3322013-11-17 19:50:10 -08001780 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001781
1782 /* Link is up then return cant set channel*/
1783 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1784 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1785 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001786 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 return -EOPNOTSUPP;
1788 }
1789
1790 /* Settings by Frequency as input */
1791 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1792 (wrqu->freq.m <= (tANI_U32)5.825e8))
1793 {
1794 tANI_U32 freq = wrqu->freq.m / 100000;
1795
1796 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1797 indx++;
1798 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1799 {
1800 return -EINVAL;
1801 }
1802 wrqu->freq.e = 0;
1803 wrqu->freq.m = freq_chan_map[indx].chan;
1804
1805 }
1806
1807 if (wrqu->freq.e == 0)
1808 {
1809 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1810 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1811 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001812 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001813 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1815 return -EINVAL;
1816 }
1817
1818 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1819
1820 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1821 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1823 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 return -EIO;
1825 }
1826
1827 for (indx = 0; indx < numChans; indx++) {
1828 if (wrqu->freq.m == validChan[indx]){
1829 break;
1830 }
1831 }
1832 }
1833 else{
1834
1835 return -EINVAL;
1836 }
1837
1838 if(indx >= numChans)
1839 {
1840 return -EINVAL;
1841 }
1842
1843 /* Set the Operational Channel */
1844 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1845 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1846 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1847
Arif Hussain6d2a3322013-11-17 19:50:10 -08001848 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001849
1850 EXIT();
1851
1852 return status;
1853}
1854
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301855static int iw_set_freq(struct net_device *dev,
1856 struct iw_request_info *info,
1857 union iwreq_data *wrqu, char *extra)
1858{
1859 int ret;
1860
1861 vos_ssr_protect(__func__);
1862 ret = __iw_set_freq(dev, info, wrqu, extra);
1863 vos_ssr_unprotect(__func__);
1864
1865 return ret;
1866}
1867
1868static int __iw_get_freq(struct net_device *dev,
1869 struct iw_request_info *info,
1870 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001871{
Jeff Johnsone7245742012-09-05 17:12:55 -07001872 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301873 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 tHalHandle hHal;
1875 hdd_wext_state_t *pWextState;
1876 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301877 hdd_station_ctx_t *pHddStaCtx;
1878 hdd_context_t *pHddCtx;
1879 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001880
1881 ENTER();
1882
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301883 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1884 if (NULL == pAdapter)
1885 {
1886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1887 "%s: Adapter is NULL", __func__);
1888 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301890 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1891 ret = wlan_hdd_validate_context(pHddCtx);
1892 if (0 != ret)
1893 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301894 return ret;
1895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301897 if (NULL == hHal)
1898 {
1899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1900 "%s: Hal Context is NULL",__func__);
1901 return -EINVAL;
1902 }
1903 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1904 if (NULL == pHddStaCtx)
1905 {
1906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1907 "%s: HddStaCtx is NULL", __func__);
1908 return -EINVAL;
1909 }
1910 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1911 if (NULL == pWextState)
1912 {
1913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1914 "%s: pWextState is NULL",__func__);
1915 return -EINVAL;
1916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 pRoamProfile = &pWextState->roamProfile;
1918
1919 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1920 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001921 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 {
c_hpothub8245442013-11-20 23:41:09 +05301923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1924 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 return -EIO;
1926 }
1927 else
1928 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001929 status = hdd_wlan_get_freq(channel, &freq);
1930 if( TRUE == status )
1931 {
1932 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1933 * iwlist & iwconfig command shows frequency into proper
1934 * format (2.412 GHz instead of 246.2 MHz)*/
1935 fwrq->m = freq;
1936 fwrq->e = MHZ;
1937 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 }
1939 }
1940 else
1941 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001942 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1943 * iwlist & iwconfig command shows frequency into proper
1944 * format (2.412 GHz instead of 246.2 MHz)*/
1945 fwrq->m = 0;
1946 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301948
1949 EXIT();
1950 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001951}
1952
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301953static int iw_get_freq(struct net_device *dev,
1954 struct iw_request_info *info,
1955 struct iw_freq *fwrq, char *extra)
1956{
1957 int ret;
1958
1959 vos_ssr_protect(__func__);
1960 ret = __iw_get_freq(dev, info, fwrq, extra);
1961 vos_ssr_unprotect(__func__);
1962
1963 return ret;
1964}
1965
1966static int __iw_get_tx_power(struct net_device *dev,
1967 struct iw_request_info *info,
1968 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001969{
1970
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301971 hdd_adapter_t *pAdapter;
1972 hdd_context_t *pHddCtx;
1973 hdd_station_ctx_t *pHddStaCtx;
1974 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001975
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301976 ENTER();
1977
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301978 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1979 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1982 "%s: Adapter is NULL",__func__);
1983 return -EINVAL;
1984 }
1985 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1986 ret = wlan_hdd_validate_context(pHddCtx);
1987 if (0 != ret)
1988 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301989 return ret;
1990 }
1991
1992 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1993 if (NULL == pHddStaCtx)
1994 {
1995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1996 "%s: STA Context is NULL",__func__);
1997 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001998 }
1999
2000 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2001 {
2002 wrqu->txpower.value = 0;
2003 return 0;
2004 }
2005 wlan_hdd_get_classAstats(pAdapter);
2006 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2007
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302008 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 return 0;
2010}
2011
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302012static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 struct iw_request_info *info,
2014 union iwreq_data *wrqu, char *extra)
2015{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302016 int ret;
2017
2018 vos_ssr_protect(__func__);
2019 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2020 vos_ssr_unprotect(__func__);
2021
2022 return ret;
2023}
2024
2025static int __iw_set_tx_power(struct net_device *dev,
2026 struct iw_request_info *info,
2027 union iwreq_data *wrqu, char *extra)
2028{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302029 hdd_adapter_t *pAdapter;
2030 tHalHandle hHal;
2031 hdd_context_t *pHddCtx;
2032 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002033
2034 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302035 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2036 if (NULL == pAdapter)
2037 {
2038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2039 "%s: Adapter is NULL",__func__);
2040 return -EINVAL;
2041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002042
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302043 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2044 ret = wlan_hdd_validate_context(pHddCtx);
2045 if (0 != ret)
2046 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302047 return ret;
2048 }
2049
2050 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2051 if (NULL == hHal)
2052 {
2053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2054 "%s: Hal Context is NULL",__func__);
2055 return -EINVAL;
2056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2058 {
c_hpothub8245442013-11-20 23:41:09 +05302059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2060 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 return -EIO;
2062 }
2063
2064 EXIT();
2065
2066 return 0;
2067}
2068
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302069static int iw_set_tx_power(struct net_device *dev,
2070 struct iw_request_info *info,
2071 union iwreq_data *wrqu, char *extra)
2072{
2073 int ret;
2074
2075 vos_ssr_protect(__func__);
2076 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2077 vos_ssr_unprotect(__func__);
2078
2079 return ret;
2080}
2081
2082static int __iw_get_bitrate(struct net_device *dev,
2083 struct iw_request_info *info,
2084 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002085{
2086 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2087 eHalStatus status = eHAL_STATUS_SUCCESS;
2088 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302089 hdd_adapter_t *pAdapter;
2090 hdd_context_t *pHddCtx;
2091 hdd_station_ctx_t *pHddStaCtx;
2092 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002093
2094 ENTER();
2095
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302096 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2097 if (NULL == pAdapter)
2098 {
2099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2100 "%s: Adapter is NULL",__func__);
2101 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 }
2103
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302104 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2105 ret = wlan_hdd_validate_context(pHddCtx);
2106 if (0 != ret)
2107 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302108 return ret;
2109 }
2110
2111 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2112 if (NULL == pHddStaCtx)
2113 {
2114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2115 "%s: STA Context is NULL",__func__);
2116 return -EINVAL;
2117 }
2118
2119 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 wrqu->bitrate.value = 0;
2121 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302122 else
2123 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2125 SME_SUMMARY_STATS |
2126 SME_GLOBAL_CLASSA_STATS |
2127 SME_GLOBAL_CLASSB_STATS |
2128 SME_GLOBAL_CLASSC_STATS |
2129 SME_GLOBAL_CLASSD_STATS |
2130 SME_PER_STA_STATS,
2131 hdd_StatisticsCB, 0, FALSE,
2132 pHddStaCtx->conn_info.staId[0], pAdapter );
2133
2134 if(eHAL_STATUS_SUCCESS != status)
2135 {
2136 hddLog(VOS_TRACE_LEVEL_ERROR,
2137 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002138 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 return status;
2140 }
2141
2142 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302143 if (NULL == pWextState)
2144 {
2145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2146 "%s: pWextState is NULL",__func__);
2147 return -EINVAL;
2148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002149
2150 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2151
2152 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2153 {
2154 hddLog(VOS_TRACE_LEVEL_ERROR,
2155 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002156 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 return VOS_STATUS_E_FAILURE;
2158 }
2159
2160 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2161 }
2162
2163 EXIT();
2164
2165 return vos_status;
2166}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302167
2168static int iw_get_bitrate(struct net_device *dev,
2169 struct iw_request_info *info,
2170 union iwreq_data *wrqu, char *extra)
2171{
2172 int ret;
2173
2174 vos_ssr_protect(__func__);
2175 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2176 vos_ssr_unprotect(__func__);
2177
2178 return ret;
2179}
2180
2181
Jeff Johnson295189b2012-06-20 16:38:30 -07002182/* ccm call back function */
2183
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302184static int __iw_set_bitrate(struct net_device *dev,
2185 struct iw_request_info *info,
2186 union iwreq_data *wrqu,
2187 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002188{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302189 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302191 hdd_station_ctx_t *pHddStaCtx;
2192 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2194 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2195 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2196 v_U32_t i, rate;
2197 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302198 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002199
2200 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302201 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2202 if (NULL == pAdapter)
2203 {
2204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2205 "%s: Adapter is NULL",__func__);
2206 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 }
2208
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302209 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2210 ret = wlan_hdd_validate_context(pHddCtx);
2211 if (0 != ret)
2212 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302213 return ret;
2214 }
2215
2216 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2217 if (NULL == pHddStaCtx)
2218 {
2219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2220 "%s: STA Context is NULL",__func__);
2221 return -EINVAL;
2222 }
2223
2224
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302226 if (NULL == pWextState)
2227 {
2228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2229 "%s: pWextState is NULL",__func__);
2230 return -EINVAL;
2231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002232
2233 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2234 {
2235 return -ENXIO ;
2236 }
2237
2238 rate = wrqu->bitrate.value;
2239
2240 if (rate == -1)
2241 {
2242 rate = WNI_CFG_FIXED_RATE_AUTO;
2243 valid_rate = TRUE;
2244 }
2245 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2246 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2247 {
2248 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2249 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2250 {
2251 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2252 WNI_CFG_SUPPORTED_RATES_11A,
2253 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2254 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2255 WNI_CFG_SUPPORTED_RATES_11B,
2256 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2257 {
2258 for (i = 0; i < (b_len + a_len); ++i)
2259 {
2260 /* supported rates returned is double the actual rate so we divide it by 2 */
2261 if ((supp_rates[i]&0x7F)/2 == rate)
2262 {
2263 valid_rate = TRUE;
2264 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2265 break;
2266 }
2267 }
2268 }
2269 }
2270 }
2271 if (valid_rate != TRUE)
2272 {
2273 return -EINVAL;
2274 }
2275 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2276 WNI_CFG_FIXED_RATE, rate,
2277 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2278 {
c_hpothub8245442013-11-20 23:41:09 +05302279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2280 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 return -EIO;
2282 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302283
2284 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 return 0;
2286}
2287
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302288static int iw_set_bitrate(struct net_device *dev,
2289 struct iw_request_info *info,
2290 union iwreq_data *wrqu,
2291 char *extra)
2292{
2293 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002294
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302295 vos_ssr_protect(__func__);
2296 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2297 vos_ssr_unprotect(__func__);
2298
2299 return ret;
2300}
2301
2302static int __iw_set_genie(struct net_device *dev,
2303 struct iw_request_info *info,
2304 union iwreq_data *wrqu,
2305 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002306{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302307 hdd_adapter_t *pAdapter;
2308 hdd_context_t *pHddCtx;
2309 hdd_wext_state_t *pWextState;
2310 u_int8_t *genie = NULL;
2311 u_int8_t *base_genie = NULL;
2312 v_U16_t remLen;
2313 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002314
2315 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002316
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302317 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2318 if (NULL == pAdapter)
2319 {
2320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2321 "%s: Adapter is NULL",__func__);
2322 return -EINVAL;
2323 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002324
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302325 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2326 ret = wlan_hdd_validate_context(pHddCtx);
2327 if (0 != ret)
2328 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302329 return ret;
2330 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002331
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302332 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2333 if (NULL == pWextState)
2334 {
2335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2336 "%s: pWextState is NULL",__func__);
2337 return -EINVAL;
2338 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002339
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302340 if (!wrqu->data.length) {
2341 hdd_clearRoamProfileIe(pAdapter);
2342 EXIT();
2343 return 0;
2344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002345
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302346 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2347 wrqu->data.length);
2348 if (NULL == base_genie)
2349 {
2350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2351 "mem_alloc_copy_from_user_helper fail");
2352 return -ENOMEM;
2353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002354
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302355 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002356
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302357 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002358
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302359 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2360
2361 /* clear any previous genIE before this call */
2362 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2363
2364 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 {
2366 v_U16_t eLen = 0;
2367 v_U8_t elementId;
2368 elementId = *genie++;
2369 eLen = *genie++;
2370 remLen -= 2;
2371
Arif Hussain6d2a3322013-11-17 19:50:10 -08002372 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 __func__, elementId, eLen);
2374
2375 switch ( elementId )
2376 {
2377 case IE_EID_VENDOR:
2378 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002379 {
2380 kfree(base_genie);
2381 return -EINVAL;
2382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002383
2384 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2385 {
2386 v_U16_t curGenIELen = pWextState->genIE.length;
2387 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2388 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2389
2390 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2391 {
2392 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002393 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002395 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 return -ENOMEM;
2397 }
2398 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2399 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2400 pWextState->genIE.length += eLen + 2;
2401 }
2402 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2403 {
2404 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2405 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2406 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2407 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2408 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2409 }
2410 else /* any vendorId except WPA IE should be accumulated to genIE */
2411 {
2412 v_U16_t curGenIELen = pWextState->genIE.length;
2413 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2414 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2415
2416 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2417 {
2418 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002419 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002421 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 return -ENOMEM;
2423 }
2424 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2425 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2426 pWextState->genIE.length += eLen + 2;
2427 }
2428 break;
2429 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002430 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2432 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2433 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2434 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2435 break;
2436
2437 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002438 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002439 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 return 0;
2441 }
2442 genie += eLen;
2443 remLen -= eLen;
2444 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302445
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002447 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 return 0;
2449}
2450
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302451static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 struct iw_request_info *info,
2453 union iwreq_data *wrqu,
2454 char *extra)
2455{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302456 int ret;
2457
2458 vos_ssr_protect(__func__);
2459 ret = __iw_set_genie(dev, info, wrqu, extra);
2460 vos_ssr_unprotect(__func__);
2461
2462 return ret;
2463}
2464
2465static int __iw_get_genie(struct net_device *dev,
2466 struct iw_request_info *info,
2467 union iwreq_data *wrqu,
2468 char *extra)
2469{
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302471 hdd_context_t *pHddCtx;
2472 hdd_adapter_t *pAdapter;
2473 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 eHalStatus status;
2475 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2476 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2477
2478 ENTER();
2479
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302480 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2481 if (NULL == pAdapter)
2482 {
2483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2484 "%s: Adapter is NULL",__func__);
2485 return -EINVAL;
2486 }
2487 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2488 status = wlan_hdd_validate_context(pHddCtx);
2489 if (0 != status)
2490 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302491 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002492 }
2493
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302495 if (NULL == pWextState)
2496 {
2497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2498 "%s: pWextState is NULL",__func__);
2499 return -EINVAL;
2500 }
2501
2502 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2503 if (NULL == pHddStaCtx)
2504 {
2505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2506 "%s: STA Context is NULL",__func__);
2507 return -EINVAL;
2508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002509
2510 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2511 {
2512 return -ENXIO;
2513 }
2514
2515 // Return something ONLY if we are associated with an RSN or WPA network
2516 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2517 pWextState->roamProfile.negotiatedAuthType))
2518 {
2519 return -ENXIO;
2520 }
2521
2522 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2523 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2524 pAdapter->sessionId,
2525 &length,
2526 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002527 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2528 if (wrqu->data.length < length)
2529 {
2530 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2531 return -EFAULT;
2532 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002533 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002534 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002535
Arif Hussain6d2a3322013-11-17 19:50:10 -08002536 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002537
2538 EXIT();
2539
2540 return 0;
2541}
2542
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302543static int iw_get_genie(struct net_device *dev,
2544 struct iw_request_info *info,
2545 union iwreq_data *wrqu,
2546 char *extra)
2547{
2548 int ret;
2549
2550 vos_ssr_protect(__func__);
2551 ret = __iw_get_genie(dev, info, wrqu, extra);
2552 vos_ssr_unprotect(__func__);
2553
2554 return ret;
2555}
2556
2557
2558static int __iw_get_encode(struct net_device *dev,
2559 struct iw_request_info *info,
2560 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002561{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302562 hdd_adapter_t *pAdapter;
2563 hdd_context_t *pHddCtx;
2564 hdd_wext_state_t *pWextState;
2565 tCsrRoamProfile *pRoamProfile;
2566 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002568
2569 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302570 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2571 if (NULL == pAdapter)
2572 {
2573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2574 "%s: Adapter is NULL",__func__);
2575 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 }
2577
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302578 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2579 ret = wlan_hdd_validate_context(pHddCtx);
2580 if (0 != ret)
2581 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302582 return ret;
2583 }
2584 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2585 if (NULL == pWextState)
2586 {
2587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2588 "%s: pWextState is NULL",__func__);
2589 return -EINVAL;
2590 }
2591
2592 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 keyId = pRoamProfile->Keys.defaultIndex;
2594
2595 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2596 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002597 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 return -EINVAL;
2599 }
2600
2601 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2602 {
2603 dwrq->flags |= IW_ENCODE_ENABLED;
2604 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2605 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2606
2607 dwrq->flags |= (keyId + 1);
2608
2609 }
2610 else
2611 {
2612 dwrq->flags |= IW_ENCODE_DISABLED;
2613 }
2614
2615 for(i=0; i < MAX_WEP_KEYS; i++)
2616 {
2617 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2618 {
2619 continue;
2620 }
2621 else
2622 {
2623 break;
2624 }
2625 }
2626
2627 if(MAX_WEP_KEYS == i)
2628 {
2629 dwrq->flags |= IW_ENCODE_NOKEY;
2630 }
2631
2632 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2633
2634 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2635 {
2636 dwrq->flags |= IW_ENCODE_OPEN;
2637 }
2638 else
2639 {
2640 dwrq->flags |= IW_ENCODE_RESTRICTED;
2641 }
2642 EXIT();
2643 return 0;
2644}
2645
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302646static int iw_get_encode(struct net_device *dev,
2647 struct iw_request_info *info,
2648 struct iw_point *dwrq, char *extra)
2649{
2650 int ret;
2651
2652 vos_ssr_protect(__func__);
2653 ret = __iw_get_encode(dev, info, dwrq, extra);
2654 vos_ssr_unprotect(__func__);
2655
2656 return ret;
2657}
2658
Jeff Johnson295189b2012-06-20 16:38:30 -07002659#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2660#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2661
2662
2663/*
2664 * This function sends a single 'key' to LIM at all time.
2665 */
2666
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302667static int __iw_get_rts_threshold(struct net_device *dev,
2668 struct iw_request_info *info,
2669 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002670{
2671 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2672 v_U32_t status = 0;
2673
2674 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2675
2676 return status;
2677}
2678
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302679static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 struct iw_request_info *info,
2681 union iwreq_data *wrqu, char *extra)
2682{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302683 int ret;
2684
2685 vos_ssr_protect(__func__);
2686 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2687 vos_ssr_unprotect(__func__);
2688
2689 return ret;
2690}
2691
2692static int __iw_set_rts_threshold(struct net_device *dev,
2693 struct iw_request_info *info,
2694 union iwreq_data *wrqu, char *extra)
2695{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302696 hdd_adapter_t *pAdapter;
2697 hdd_context_t *pHddCtx;
2698 tHalHandle hHal;
2699 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002700
2701 ENTER();
2702
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302703 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2704 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002705 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2707 "%s: Adapter is NULL",__func__);
2708 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002709 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302710
2711 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2712 ret = wlan_hdd_validate_context(pHddCtx);
2713 if (0 != ret)
2714 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302715 return ret;
2716 }
2717
2718 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2719 if (NULL == hHal)
2720 {
2721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2722 "%s: Hal Context is NULL",__func__);
2723 return -EINVAL;
2724 }
2725
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2727 {
2728 return -EINVAL;
2729 }
2730
2731 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2732 {
c_hpothub8245442013-11-20 23:41:09 +05302733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2734 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 return -EIO;
2736 }
2737
2738 EXIT();
2739
2740 return 0;
2741}
2742
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302743static int iw_set_rts_threshold(struct net_device *dev,
2744 struct iw_request_info *info,
2745 union iwreq_data *wrqu, char *extra)
2746{
2747 int ret;
2748
2749 vos_ssr_protect(__func__);
2750 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2751 vos_ssr_unprotect(__func__);
2752
2753 return ret;
2754}
2755
2756static int __iw_get_frag_threshold(struct net_device *dev,
2757 struct iw_request_info *info,
2758 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002759{
2760 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2761 v_U32_t status = 0;
2762
2763 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2764
2765 return status;
2766}
2767
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302768static int iw_get_frag_threshold(struct net_device *dev,
2769 struct iw_request_info *info,
2770 union iwreq_data *wrqu, char *extra)
2771{
2772 int ret;
2773
2774 vos_ssr_protect(__func__);
2775 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2776 vos_ssr_unprotect(__func__);
2777
2778 return ret;
2779}
2780
2781static int __iw_set_frag_threshold(struct net_device *dev,
2782 struct iw_request_info *info,
2783 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002784{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302785 hdd_adapter_t *pAdapter;
2786 hdd_context_t *pHddCtx;
2787 tHalHandle hHal;
2788 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002789
2790 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302791 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2792 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002793 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2795 "%s: Adapter is NULL",__func__);
2796 return -EINVAL;
2797 }
2798
2799 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2800 ret = wlan_hdd_validate_context(pHddCtx);
2801 if (0 != ret)
2802 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302803 return ret;
2804 }
2805
2806 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2807 if (NULL == hHal)
2808 {
2809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2810 "%s: Hal Context is NULL",__func__);
2811 return -EINVAL;
2812 }
2813
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2815 {
2816 return -EINVAL;
2817 }
2818
2819 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2820 {
c_hpothub8245442013-11-20 23:41:09 +05302821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2822 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 return -EIO;
2824 }
2825
2826 EXIT();
2827
2828 return 0;
2829}
2830
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302831static int iw_set_frag_threshold(struct net_device *dev,
2832 struct iw_request_info *info,
2833 union iwreq_data *wrqu, char *extra)
2834{
2835 int ret;
2836
2837 vos_ssr_protect(__func__);
2838 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2839 vos_ssr_unprotect(__func__);
2840
2841 return ret;
2842}
2843
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302844static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 struct iw_request_info *info,
2846 union iwreq_data *wrqu, char *extra)
2847{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302848 hdd_adapter_t *pAdapter;
2849 hdd_context_t *pHddCtx;
2850 int ret = 0;
2851
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302853 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2854 if (NULL == pAdapter)
2855 {
2856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2857 "%s: Adapter is NULL",__func__);
2858 return -EINVAL;
2859 }
2860 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2861 ret = wlan_hdd_validate_context(pHddCtx);
2862 if (0 != ret)
2863 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302864 return ret;
2865 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302866
2867 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 return -EOPNOTSUPP;
2869}
2870
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302871static int iw_get_power_mode(struct net_device *dev,
2872 struct iw_request_info *info,
2873 union iwreq_data *wrqu, char *extra)
2874{
2875 int ret;
2876
2877 vos_ssr_protect(__func__);
2878 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2879 vos_ssr_unprotect(__func__);
2880
2881 return ret;
2882}
2883static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 struct iw_request_info *info,
2885 union iwreq_data *wrqu, char *extra)
2886{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302887 hdd_adapter_t *pAdapter;
2888 hdd_context_t *pHddCtx;
2889 int ret = 0;
2890
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302892 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2893 if (NULL == pAdapter)
2894 {
2895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2896 "%s: Adapter is NULL",__func__);
2897 return -EINVAL;
2898 }
2899 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2900 ret = wlan_hdd_validate_context(pHddCtx);
2901 if (0 != ret)
2902 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302903 return ret;
2904 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302905
2906 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 return -EOPNOTSUPP;
2908}
2909
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302910static int iw_set_power_mode(struct net_device *dev,
2911 struct iw_request_info *info,
2912 union iwreq_data *wrqu, char *extra)
2913{
2914 int ret;
2915
2916 vos_ssr_protect(__func__);
2917 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2918 vos_ssr_unprotect(__func__);
2919
2920 return ret;
2921}
2922
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302923static int __iw_get_range(struct net_device *dev,
2924 struct iw_request_info *info,
2925 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002926{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302927 hdd_adapter_t *pAdapter;
2928 tHalHandle hHal;
2929 hdd_context_t *pHddCtx;
2930 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 struct iw_range *range = (struct iw_range *) extra;
2932
2933 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2934
2935 v_U32_t num_channels = sizeof(channels);
2936 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2937 v_U32_t a_len;
2938 v_U32_t b_len;
2939 v_U32_t active_phy_mode = 0;
2940 v_U8_t index = 0, i;
2941
2942 ENTER();
2943
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302944 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2945 if (NULL == pAdapter)
2946 {
2947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2948 "%s: pAdapter is NULL", __func__);
2949 return -EINVAL;
2950 }
2951 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2952 ret = wlan_hdd_validate_context(pHddCtx);
2953 if (0 != ret)
2954 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302955 return ret;
2956 }
2957 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2958 if (NULL == hHal)
2959 {
2960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2961 "%s: pAdapter is NULL", __func__);
2962 return -EINVAL;
2963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 wrqu->data.length = sizeof(struct iw_range);
2965 memset(range, 0, sizeof(struct iw_range));
2966
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 /*Get the phy mode*/
2968 if (ccmCfgGetInt(hHal,
2969 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2970 {
2971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002972 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002973
2974 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2975 {
2976 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002977 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 if (ccmCfgGetStr(hHal,
2979 WNI_CFG_SUPPORTED_RATES_11A,
2980 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2981 {
2982 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2983 {
2984 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2985 }
2986 for (i = 0; i < a_len; i++)
2987 {
2988 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2989 }
2990 range->num_bitrates = a_len;
2991 }
2992 else
2993 {
2994 return -EIO;
2995 }
2996 }
2997 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2998 {
2999 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003000 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 if (ccmCfgGetStr(hHal,
3002 WNI_CFG_SUPPORTED_RATES_11B,
3003 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3004 {
3005 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3006 {
3007 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3008 }
3009 for (i = 0; i < b_len; i++)
3010 {
3011 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3012 }
3013 range->num_bitrates = b_len;
3014 }
3015 else
3016 {
3017 return -EIO;
3018 }
3019 }
3020 }
3021
3022 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3023 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3024 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3025
3026 range->encoding_size[0] = 5;
3027 range->encoding_size[1] = 13;
3028 range->num_encoding_sizes = 2;
3029 range->max_encoding_tokens = MAX_WEP_KEYS;
3030
3031 // we support through Wireless Extensions 22
3032 range->we_version_compiled = WIRELESS_EXT;
3033 range->we_version_source = 22;
3034
3035 /*Supported Channels and Frequencies*/
3036 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3037 {
c_hpothub8245442013-11-20 23:41:09 +05303038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3039 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 return -EIO;
3041 }
3042 if (num_channels > IW_MAX_FREQUENCIES)
3043 {
3044 num_channels = IW_MAX_FREQUENCIES;
3045 }
3046
3047 range->num_channels = num_channels;
3048 range->num_frequency = num_channels;
3049
3050 for (index=0; index < num_channels; index++)
3051 {
3052 v_U32_t frq_indx = 0;
3053
3054 range->freq[index].i = channels[index];
3055 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3056 {
3057 if(channels[index] == freq_chan_map[frq_indx].chan)
3058 {
3059 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3060 range->freq[index].e = 1;
3061 break;
3062 }
3063 frq_indx++;
3064 }
3065 }
3066
3067 /* Event capability (kernel + driver) */
3068 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3069 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3070 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3071 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3072
3073 /*Encryption capability*/
3074 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3075 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3076
3077 /* Txpower capability */
3078 range->txpower_capa = IW_TXPOW_MWATT;
3079
3080 /*Scanning capability*/
3081 #if WIRELESS_EXT >= 22
3082 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3083 #endif
3084
3085 EXIT();
3086 return 0;
3087}
3088
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303089static int iw_get_range(struct net_device *dev,
3090 struct iw_request_info *info,
3091 union iwreq_data *wrqu, char *extra)
3092{
3093 int ret;
3094
3095 vos_ssr_protect(__func__);
3096 ret = __iw_get_range(dev, info, wrqu, extra);
3097 vos_ssr_unprotect(__func__);
3098
3099 return ret;
3100}
3101
Jeff Johnson295189b2012-06-20 16:38:30 -07003102/* Callback function registered with PMC to know status of PMC request */
3103static void iw_power_callback_fn (void *pContext, eHalStatus status)
3104{
3105 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003106
3107 if (NULL == pContext)
3108 {
3109 hddLog(VOS_TRACE_LEVEL_ERROR,
3110 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003111 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 return;
3113 }
3114
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003116
Jeff Johnson72a40512013-12-19 10:14:15 -08003117 /* there is a race condition that exists between this callback
3118 function and the caller since the caller could time out either
3119 before or while this code is executing. we use a spinlock to
3120 serialize these actions */
3121 spin_lock(&hdd_context_lock);
3122
3123 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 {
3125 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003126 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003128 "%s: Invalid context, magic [%08x]",
3129 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003130
3131 if (ioctl_debug)
3132 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003133 pr_info("%s: Invalid context, magic [%08x]\n",
3134 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 }
3136 return;
3137 }
3138
Jeff Johnson72a40512013-12-19 10:14:15 -08003139 /* context is valid so caller is still waiting */
3140
3141 /* paranoia: invalidate the magic */
3142 pStatsContext->magic = 0;
3143
3144 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003146
3147 /* serialization is complete */
3148 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003149}
3150
3151/* Callback function for tx per hit */
3152void hdd_tx_per_hit_cb (void *pCallbackContext)
3153{
3154 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3155 unsigned char tx_fail[16];
3156 union iwreq_data wrqu;
3157
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303158 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003160 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 return;
3162 }
3163 memset(&wrqu, 0, sizeof(wrqu));
3164 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3165 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3166}
3167
3168void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3169{
3170 struct statsContext *pStatsContext;
3171 tCsrGlobalClassAStatsInfo *pClassAStats;
3172 hdd_adapter_t *pAdapter;
3173
3174 if (ioctl_debug)
3175 {
3176 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003177 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 }
3179
3180 if ((NULL == pStats) || (NULL == pContext))
3181 {
3182 hddLog(VOS_TRACE_LEVEL_ERROR,
3183 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003184 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 return;
3186 }
3187
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 pClassAStats = pStats;
3189 pStatsContext = pContext;
3190 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003191
3192 /* there is a race condition that exists between this callback
3193 function and the caller since the caller could time out either
3194 before or while this code is executing. we use a spinlock to
3195 serialize these actions */
3196 spin_lock(&hdd_context_lock);
3197
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3199 {
3200 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003201 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 hddLog(VOS_TRACE_LEVEL_WARN,
3203 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003204 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 if (ioctl_debug)
3206 {
3207 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003208 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 }
3210 return;
3211 }
3212
Jeff Johnson72a40512013-12-19 10:14:15 -08003213 /* context is valid so caller is still waiting */
3214
3215 /* paranoia: invalidate the magic */
3216 pStatsContext->magic = 0;
3217
3218 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3220
Jeff Johnson72a40512013-12-19 10:14:15 -08003221 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003223
3224 /* serialization is complete */
3225 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003226}
3227
3228VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3229{
3230 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3231 eHalStatus hstatus;
3232 long lrc;
3233 struct statsContext context;
3234
3235 if (NULL == pAdapter)
3236 {
3237 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3238 return VOS_STATUS_E_FAULT;
3239 }
3240 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3241 {
3242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3243 return VOS_STATUS_SUCCESS;
3244 }
3245
3246 /* we are connected
3247 prepare our callback context */
3248 init_completion(&context.completion);
3249 context.pAdapter = pAdapter;
3250 context.magic = STATS_CONTEXT_MAGIC;
3251 /* query only for Class A statistics (which include link speed) */
3252 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3253 eCSR_HDD,
3254 SME_GLOBAL_CLASSA_STATS,
3255 hdd_GetClassA_statisticsCB,
3256 0, // not periodic
3257 FALSE, //non-cached results
3258 pHddStaCtx->conn_info.staId[0],
3259 &context);
3260 if (eHAL_STATUS_SUCCESS != hstatus)
3261 {
3262 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003263 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003264 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 /* we'll returned a cached value below */
3266 }
3267 else
3268 {
3269 /* request was sent -- wait for the response */
3270 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3271 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 if (lrc <= 0)
3273 {
3274 hddLog(VOS_TRACE_LEVEL_ERROR,
3275 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003276 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 }
3278 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003279
3280 /* either we never sent a request, we sent a request and received a
3281 response or we sent a request and timed out. if we never sent a
3282 request or if we sent a request and got a response, we want to
3283 clear the magic out of paranoia. if we timed out there is a
3284 race condition such that the callback function could be
3285 executing at the same time we are. of primary concern is if the
3286 callback function had already verified the "magic" but had not
3287 yet set the completion variable when a timeout occurred. we
3288 serialize these activities by invalidating the magic while
3289 holding a shared spinlock which will cause us to block if the
3290 callback is currently executing */
3291 spin_lock(&hdd_context_lock);
3292 context.magic = 0;
3293 spin_unlock(&hdd_context_lock);
3294
3295 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 return VOS_STATUS_SUCCESS;
3297}
3298
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003299static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3300{
3301 struct statsContext *pStatsContext;
3302 tCsrSummaryStatsInfo *pSummaryStats;
3303 tCsrGlobalClassAStatsInfo *pClassAStats;
3304 hdd_adapter_t *pAdapter;
3305
3306 if (ioctl_debug)
3307 {
3308 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003309 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003310 }
3311
3312 if ((NULL == pStats) || (NULL == pContext))
3313 {
3314 hddLog(VOS_TRACE_LEVEL_ERROR,
3315 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003316 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003317 return;
3318 }
3319
Jeff Johnson72a40512013-12-19 10:14:15 -08003320 /* there is a race condition that exists between this callback
3321 function and the caller since the caller could time out either
3322 before or while this code is executing. we use a spinlock to
3323 serialize these actions */
3324 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003325
3326 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3327 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3328 pStatsContext = pContext;
3329 pAdapter = pStatsContext->pAdapter;
3330 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3331 {
3332 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003333 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003334 hddLog(VOS_TRACE_LEVEL_WARN,
3335 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003336 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003337 if (ioctl_debug)
3338 {
3339 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003340 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003341 }
3342 return;
3343 }
3344
Jeff Johnson72a40512013-12-19 10:14:15 -08003345 /* context is valid so caller is still waiting */
3346
3347 /* paranoia: invalidate the magic */
3348 pStatsContext->magic = 0;
3349
3350 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003351 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3352 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3353
Jeff Johnson72a40512013-12-19 10:14:15 -08003354 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003355 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003356
3357 /* serialization is complete */
3358 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003359}
3360
3361VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3362{
3363 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3364 eHalStatus hstatus;
3365 long lrc;
3366 struct statsContext context;
3367
3368 if (NULL == pAdapter)
3369 {
3370 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3371 return VOS_STATUS_SUCCESS;
3372 }
3373
3374 /* we are connected
3375 prepare our callback context */
3376 init_completion(&context.completion);
3377 context.pAdapter = pAdapter;
3378 context.magic = STATS_CONTEXT_MAGIC;
3379
3380 /* query only for Summary & Class A statistics */
3381 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3382 eCSR_HDD,
3383 SME_SUMMARY_STATS |
3384 SME_GLOBAL_CLASSA_STATS,
3385 hdd_get_station_statisticsCB,
3386 0, // not periodic
3387 FALSE, //non-cached results
3388 pHddStaCtx->conn_info.staId[0],
3389 &context);
3390 if (eHAL_STATUS_SUCCESS != hstatus)
3391 {
3392 hddLog(VOS_TRACE_LEVEL_ERROR,
3393 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003394 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003395 /* we'll return with cached values */
3396 }
3397 else
3398 {
3399 /* request was sent -- wait for the response */
3400 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3401 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003402
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003403 if (lrc <= 0)
3404 {
3405 hddLog(VOS_TRACE_LEVEL_ERROR,
3406 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003407 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003408 }
3409 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003410
3411 /* either we never sent a request, we sent a request and received a
3412 response or we sent a request and timed out. if we never sent a
3413 request or if we sent a request and got a response, we want to
3414 clear the magic out of paranoia. if we timed out there is a
3415 race condition such that the callback function could be
3416 executing at the same time we are. of primary concern is if the
3417 callback function had already verified the "magic" but had not
3418 yet set the completion variable when a timeout occurred. we
3419 serialize these activities by invalidating the magic while
3420 holding a shared spinlock which will cause us to block if the
3421 callback is currently executing */
3422 spin_lock(&hdd_context_lock);
3423 context.magic = 0;
3424 spin_unlock(&hdd_context_lock);
3425
3426 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003427 return VOS_STATUS_SUCCESS;
3428}
3429
3430
Jeff Johnson295189b2012-06-20 16:38:30 -07003431/*
3432 * Support for the LINKSPEED private command
3433 * Per the WiFi framework the response must be of the form
3434 * "LinkSpeed xx"
3435 */
3436static int iw_get_linkspeed(struct net_device *dev,
3437 struct iw_request_info *info,
3438 union iwreq_data *wrqu, char *extra)
3439{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303440 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303441 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303443 int len = sizeof(v_U32_t) + 1;
3444 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303445 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303446 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303447 int rc, valid = 0;
3448
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303449 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303450 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3451 if (NULL == pAdapter)
3452 {
3453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3454 "%s: Adapter is NULL",__func__);
3455 return -EINVAL;
3456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003457
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303458 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303459 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303460 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003461 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303462 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003463 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303464 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3465 if (NULL == pHddStaCtx)
3466 {
3467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3468 "%s: STA Context is NULL",__func__);
3469 return -EINVAL;
3470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3472 {
3473 /* we are not connected so we don't have a classAstats */
3474 link_speed = 0;
3475 }
3476 else
3477 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303478 status = wlan_hdd_get_classAstats(pAdapter);
3479
3480 if (!VOS_IS_STATUS_SUCCESS(status ))
3481 {
3482 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3483 return -EINVAL;
3484 }
3485
3486 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3487 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3488 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3489 &link_speed);
3490
3491 link_speed = link_speed / 10;
3492
3493 if (0 == link_speed)
3494 {
3495 /* The linkspeed returned by HAL is in units of 500kbps.
3496 * converting it to mbps.
3497 * This is required to support legacy firmware which does
3498 * not return link capacity.
3499 */
3500 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3501 }
3502
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 }
3504
3505 wrqu->data.length = len;
3506 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003507 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 if ((rc < 0) || (rc >= len))
3509 {
3510 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303511 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 return -EIO;
3513 }
3514
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303515 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003517 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003518}
3519
Arif Hussain695279c2014-03-24 14:06:07 -07003520/*
3521 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3522 *
3523 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303524static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003525 struct iw_request_info *info,
3526 union iwreq_data *wrqu, char *extra)
3527{
3528 int rc;
3529
3530 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3531
3532 if (rc < 0)
3533 return rc;
3534
3535 /* a value is being successfully returned */
3536 return 0;
3537}
Jeff Johnson295189b2012-06-20 16:38:30 -07003538
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303539static int iw_get_linkspeed_priv(struct net_device *dev,
3540 struct iw_request_info *info,
3541 union iwreq_data *wrqu, char *extra)
3542{
3543 int ret;
3544
3545 vos_ssr_protect(__func__);
3546 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3547 vos_ssr_unprotect(__func__);
3548
3549 return ret;
3550}
3551
Jeff Johnson295189b2012-06-20 16:38:30 -07003552/*
3553 * Support for the RSSI & RSSI-APPROX private commands
3554 * Per the WiFi framework the response must be of the form
3555 * "<ssid> rssi <xx>"
3556 * unless we are not associated, in which case the response is
3557 * "OK"
3558 */
3559static int iw_get_rssi(struct net_device *dev,
3560 struct iw_request_info *info,
3561 union iwreq_data *wrqu, char *extra)
3562{
3563 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003564 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 int len = wrqu->data.length;
3566 v_S7_t s7Rssi = 0;
3567 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3568 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3569 VOS_STATUS vosStatus;
3570 int rc;
3571
3572 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3573 (0 == ssidlen) || (ssidlen >= len))
3574 {
3575 /* we are not connected or our SSID is too long
3576 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003577 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 }
3579 else
3580 {
3581 /* we are connected with a valid SSID
3582 so we can write the SSID into the return buffer
3583 (note that it is not NUL-terminated) */
3584 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3585
3586 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3587
3588 if (VOS_STATUS_SUCCESS == vosStatus)
3589 {
3590 /* append the rssi to the ssid in the format required by
3591 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003592 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303593 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 }
3595 else
3596 {
3597 rc = -1;
3598 }
3599 }
3600
3601 /* verify that we wrote a valid response */
3602 if ((rc < 0) || (rc >= len))
3603 {
3604 // encoding or length error?
3605 hddLog(VOS_TRACE_LEVEL_ERROR,
3606 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003607 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 return -EIO;
3609 }
3610
3611 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003612 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003613}
3614
3615/*
3616 * Support for SoftAP channel range private command
3617 */
3618static int iw_softap_set_channel_range( struct net_device *dev,
3619 int startChannel,
3620 int endChannel,
3621 int band)
3622{
Jeff Johnson43971f52012-07-17 12:26:56 -07003623 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 int ret = 0;
3625 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3626 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003627 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3628
Jeff Johnson295189b2012-06-20 16:38:30 -07003629
3630 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3631 if (VOS_STATUS_SUCCESS != status)
3632 {
3633 ret = -EINVAL;
3634 }
Yathish9f22e662012-12-10 14:21:35 -08003635 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 return ret;
3637}
3638
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303639static uint8 chartohex(char c)
3640{
3641 uint8 val = 0;
3642 if (c >= '0' && c <= '9')
3643 val = c - '0';
3644 else if (c >= 'a' && c <= 'f')
3645 val = c - 'a' + 10;
3646 else if (c >= 'A' && c <= 'F')
3647 val = c - 'A' + 10;
3648 else
3649 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3650
3651 return val;
3652}
3653
3654uint8 getByte(char **buf)
3655{
3656 uint8 byte = 0;
3657 char *temp = *buf;
3658 byte = chartohex(*temp) * 16;
3659 temp++;
3660 byte += chartohex(*temp);
3661 temp++;
3662 *buf = temp;
3663 return byte;
3664}
3665
3666static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3667{
3668 tSir80211Header *macHeader;
3669 int i = 0, j = 0, length = 0;
3670 uint8 byte = 0;
3671 char *temp = pBuffer;
3672 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303673 char *pHeader;
3674 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303675
3676 macHeader = &pkt->macHeader;
3677
3678 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3679
3680 temp++;
3681
3682 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3683 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3684 pkt->encParams.keyParams.key[0].keyId);
3685
3686 for (i = 0; i< 16; i++) {
3687 pkt->encParams.keyParams.key[0].key[i]
3688 = getByte(&temp);
3689 }
3690
3691 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3692 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3693
3694 for (i = 0; i< 6; i++) {
3695 pkt->encParams.pn[i]
3696 = getByte(&temp);
3697 }
3698
3699 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3700 &pkt->encParams.pn[0], 6, 0);
3701
3702 for (i = 0, j= 5; i< 3; i++, j--) {
3703 byte = pkt->encParams.pn[i];
3704 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3705 pkt->encParams.pn[j] = byte;
3706 }
3707
3708 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303709 if (length > sizeof(tSir80211Header))
3710 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303711
Srinivas Dasari2382de62015-01-22 15:00:04 +05303712 pHeader = temp;
3713 vos_mem_zero(&header, sizeof(tSir80211Header));
3714 for (i = 0; i < length; i++) {
3715 *((uint8 *)&header + i) = getByte(&pHeader);
3716 }
3717
3718 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3719 (char *)&header, length, 0);
3720
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303721 byte = getByte(&temp);
3722
3723 macHeader->frameCtrl.protVer = byte & 0x3;
3724 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3725 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3726
3727 byte = getByte(&temp);
3728 macHeader->frameCtrl.toDS = (byte) & 0x1;
3729 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3730 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3731 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3732 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3733 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3734 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3735 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3736
3737 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3738 "macHeader->frameCtrl.type : %x "
3739 "macHeader->frameCtrl.subType : %x "
3740 "macHeader->frameCtrl.toDS : %x "
3741 "macHeader->frameCtrl.fromDS : %x "
3742 "macHeader->frameCtrl.moreFrag : %x "
3743 "macHeader->frameCtrl.retry : %x "
3744 "macHeader->frameCtrl.powerMgmt : %x "
3745 "macHeader->frameCtrl.MoreData : %x "
3746 "macHeader->frameCtrl.wep : %x "
3747 "macHeader->frameCtrl.order : %x "
3748 , macHeader->frameCtrl.protVer
3749 , macHeader->frameCtrl.type
3750 , macHeader->frameCtrl.subType
3751 , macHeader->frameCtrl.toDS
3752 , macHeader->frameCtrl.fromDS
3753 , macHeader->frameCtrl.moreFrag
3754 , macHeader->frameCtrl.retry
3755 , macHeader->frameCtrl.powerMgmt
3756 , macHeader->frameCtrl.moreData
3757 , macHeader->frameCtrl.wep
3758 , macHeader->frameCtrl.order);
3759
3760
3761 macHeader->usDurationId = getByte(&temp);
3762 macHeader->usDurationId += getByte(&temp) << 8;
3763
3764 macHeader->vA1[0] = getByte(&temp);
3765 macHeader->vA1[1] = getByte(&temp);
3766 macHeader->vA1[2] = getByte(&temp);
3767 macHeader->vA1[3] = getByte(&temp);
3768 macHeader->vA1[4] = getByte(&temp);
3769 macHeader->vA1[5] = getByte(&temp);
3770
3771 macHeader->vA2[0] = getByte(&temp);
3772 macHeader->vA2[1] = getByte(&temp);
3773 macHeader->vA2[2] = getByte(&temp);
3774 macHeader->vA2[3] = getByte(&temp);
3775 macHeader->vA2[4] = getByte(&temp);
3776 macHeader->vA2[5] = getByte(&temp);
3777
3778 macHeader->vA3[0] = getByte(&temp);
3779 macHeader->vA3[1] = getByte(&temp);
3780 macHeader->vA3[2] = getByte(&temp);
3781 macHeader->vA3[3] = getByte(&temp);
3782 macHeader->vA3[4] = getByte(&temp);
3783 macHeader->vA3[5] = getByte(&temp);
3784
3785 macHeader->sSeqCtrl = getByte(&temp);
3786 fragNum = macHeader->sSeqCtrl & 0xF;
3787 macHeader->sSeqCtrl >>= 4;
3788
3789 macHeader->sSeqCtrl += getByte(&temp) << 4;
3790
3791 macHeader->sSeqCtrl |= fragNum << 12;
3792
3793 if (length == 30 || length == 32) {
3794 macHeader->optvA4[0] = getByte(&temp);
3795 macHeader->optvA4[1] = getByte(&temp);
3796 macHeader->optvA4[2] = getByte(&temp);
3797 macHeader->optvA4[3] = getByte(&temp);
3798 macHeader->optvA4[4] = getByte(&temp);
3799 macHeader->optvA4[5] = getByte(&temp);
3800 }
3801
3802 if (length == 26 || length == 32) {
3803 macHeader->usQosCtrl = getByte(&temp);
3804 macHeader->usQosCtrl += getByte(&temp) << 8;
3805 }
3806
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303807 //parse payload
3808 length = getByte(&temp);
3809 length += getByte(&temp) << 8;
3810 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3811
3812 pkt->data.length = length;
3813
3814 for (i = 0; i< length; i++) {
3815 pkt->data.data[i] = getByte(&temp);
3816 }
3817
3818 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3819 &pkt->data.data[0], pkt->data.length, 0);
3820}
3821
3822/**---------------------------------------------------------------------------
3823
3824 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3825 encrypt message request
3826 This is an asynchronous callback function from SME when the encrypted data
3827 is received
3828
3829 \pEncInfoRsp -> Encrypted data info
3830
3831 \return - 0 for success non-zero for failure
3832 --------------------------------------------------------------------------*/
3833static void
3834hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3835{
3836 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3837
3838 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3839
3840 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3841 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3842 pEncryptedDataRsp->encryptedPayload.length);
3843 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3844 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3845 pEncryptedDataRsp->encryptedPayload.data,
3846 pEncryptedDataRsp->encryptedPayload.length, 0);
3847}
3848
Jeff Johnson295189b2012-06-20 16:38:30 -07003849VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3850{
3851 struct statsContext context;
3852 eHalStatus status;
3853 hdd_context_t *pHddCtx;
3854
3855 if (NULL == pAdapter)
3856 {
3857 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3858 return VOS_STATUS_E_FAULT;
3859 }
3860
3861 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3862 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303863 if (pHddCtx->isLogpInProgress) {
3864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3865 "%s:LOGP in Progress. Ignore!!!", __func__);
3866 return VOS_STATUS_E_FAILURE;
3867 }
3868
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 init_completion(&context.completion);
3870
3871 context.pAdapter = pAdapter;
3872 context.magic = POWER_CONTEXT_MAGIC;
3873
3874 if (DRIVER_POWER_MODE_ACTIVE == mode)
3875 {
3876 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3877 "Full Power", __func__);
3878 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3879 iw_power_callback_fn, &context,
3880 eSME_FULL_PWR_NEEDED_BY_HDD);
3881 // Enter Full power command received from GUI this means we are disconnected
3882 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3883 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3884 if (eHAL_STATUS_PMC_PENDING == status)
3885 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003886 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 int lrc = wait_for_completion_interruptible_timeout(
3888 &context.completion,
3889 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003890
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 if (lrc <= 0)
3892 {
3893 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003894 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 }
3896 }
3897 }
3898 else if (DRIVER_POWER_MODE_AUTO == mode)
3899 {
3900 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3901 {
3902 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3903 __func__);
3904 // Enter BMPS command received from GUI this means DHCP is completed
3905 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3906 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3907 FALSE);
3908 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3909 iw_power_callback_fn, &context);
3910 if (eHAL_STATUS_PMC_PENDING == status)
3911 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003912 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 int lrc = wait_for_completion_interruptible_timeout(
3914 &context.completion,
3915 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 if (lrc <= 0)
3917 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003918 hddLog(VOS_TRACE_LEVEL_ERROR,
3919 "%s: SME %s while requesting BMPS",
3920 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 }
3922 }
3923 }
3924 else
3925 {
3926 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3927 "enabled in the cfg");
3928 }
3929 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003930
3931 /* either we never sent a request, we sent a request and received a
3932 response or we sent a request and timed out. if we never sent a
3933 request or if we sent a request and got a response, we want to
3934 clear the magic out of paranoia. if we timed out there is a
3935 race condition such that the callback function could be
3936 executing at the same time we are. of primary concern is if the
3937 callback function had already verified the "magic" but had not
3938 yet set the completion variable when a timeout occurred. we
3939 serialize these activities by invalidating the magic while
3940 holding a shared spinlock which will cause us to block if the
3941 callback is currently executing */
3942 spin_lock(&hdd_context_lock);
3943 context.magic = 0;
3944 spin_unlock(&hdd_context_lock);
3945
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 return VOS_STATUS_SUCCESS;
3947}
3948
3949VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3950 hdd_adapter_t *pAdapter)
3951{
3952 VOS_STATUS vos_Status;
3953
3954 if ((NULL == pAdapter) || (NULL == pHddCtx))
3955 {
3956 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3957 return VOS_STATUS_E_FAULT;
3958 }
3959
3960 /**Exit from Deep sleep or standby if we get the driver
3961 START cmd from android GUI
3962 */
3963 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3964 {
3965 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3966 "from Stand by",__func__);
3967 vos_Status = hdd_exit_standby(pHddCtx);
3968 }
3969 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3970 {
3971 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3972 "from deep sleep",__func__);
3973 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3974 }
3975 else
3976 {
3977 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3978 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3979 vos_Status = VOS_STATUS_SUCCESS;
3980 }
3981
3982 return vos_Status;
3983}
3984
3985VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3986{
3987 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3988
3989 if (NULL == pHddCtx)
3990 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303991 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 return VOS_STATUS_E_FAULT;
3993 }
3994
3995 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3996 {
3997 //Execute standby procedure.
3998 //Executing standby procedure will cause the STA to
3999 //disassociate first and then the chip will be put into standby.
4000 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4001 vos_Status = hdd_enter_standby(pHddCtx);
4002 }
4003 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4004 pHddCtx->cfg_ini->nEnableDriverStop)
4005 {
4006 //Execute deep sleep procedure
4007 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004008 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 //Deep sleep not supported
4010 vos_Status = hdd_enter_standby(pHddCtx);
4011 }
4012 else
4013 {
4014 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4015 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4016 vos_Status = VOS_STATUS_SUCCESS;
4017 }
4018
4019 return vos_Status;
4020}
4021
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004022
4023void* wlan_hdd_change_country_code_callback(void *pAdapter)
4024{
4025
4026 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004027 complete(&call_back_pAdapter->change_country_code);
4028
4029 return NULL;
4030}
4031
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304032static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 struct iw_request_info *info,
4034 union iwreq_data *wrqu, char *extra)
4035{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304036 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004037 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304039 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004040 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4041
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304042 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004043
4044 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304045
4046 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4047 if (NULL == pAdapter)
4048 {
4049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4050 "mem_alloc_copy_from_user_helper fail");
4051 return -EINVAL;
4052 }
4053 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4054 rc = wlan_hdd_validate_context(pHddCtx);
4055 if (0 != rc)
4056 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304057 return rc;
4058 }
4059
Arif Hussain24bfa702014-01-22 13:51:30 -08004060 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4061 wrqu->data.length);
4062 if (NULL == cmd)
4063 {
4064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4065 "mem_alloc_copy_from_user_helper fail");
4066 return -ENOMEM;
4067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004068
4069 if (ioctl_debug)
4070 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004071 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 }
4073
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004074 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4075 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004076
Arif Hussain24bfa702014-01-22 13:51:30 -08004077 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004079 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4081 "%s: Error in iw_set_scan!", __func__);
4082 rc = -EINVAL;
4083 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 }
4085 else if( strcasecmp(cmd, "start") == 0 ) {
4086
Arif Hussain6d2a3322013-11-17 19:50:10 -08004087 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004089
Arif Hussain24bfa702014-01-22 13:51:30 -08004090 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4091 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 {
4093 union iwreq_data wrqu;
4094 char buf[10];
4095
4096 memset(&wrqu, 0, sizeof(wrqu));
4097 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4098 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4099 }
4100 else
4101 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004102 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4103 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 }
4105 goto done;
4106 }
4107 else if( strcasecmp(cmd, "stop") == 0 )
4108 {
4109 union iwreq_data wrqu;
4110 char buf[10];
4111
Arif Hussain6d2a3322013-11-17 19:50:10 -08004112 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004113
4114 wlan_hdd_enter_lowpower(pHddCtx);
4115 memset(&wrqu, 0, sizeof(wrqu));
4116 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4117 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 goto done;
4119 }
4120 else if (strcasecmp(cmd, "macaddr") == 0)
4121 {
4122 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4123 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4124 }
4125 else if (strcasecmp(cmd, "scan-active") == 0)
4126 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304127 hddLog(VOS_TRACE_LEVEL_ERROR,
4128 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004129 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 ret = snprintf(cmd, cmd_len, "OK");
4131 }
4132 else if (strcasecmp(cmd, "scan-passive") == 0)
4133 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304134 hddLog(VOS_TRACE_LEVEL_ERROR,
4135 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004136 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 ret = snprintf(cmd, cmd_len, "OK");
4138 }
4139 else if( strcasecmp(cmd, "scan-mode") == 0 )
4140 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004141 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 }
4143 else if( strcasecmp(cmd, "linkspeed") == 0 )
4144 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004145 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 }
4147 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4148 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004149 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004150 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004151
4152 country_code = cmd + 8;
4153
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004154 init_completion(&pAdapter->change_country_code);
4155
Arif Hussain24bfa702014-01-22 13:51:30 -08004156 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004157 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004158 country_code,
4159 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304160 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304161 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304162 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004163
4164 /* Wait for completion */
4165 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4166 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4167
4168 if (lrc <= 0)
4169 {
4170 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004171 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004172 }
4173
Arif Hussain24bfa702014-01-22 13:51:30 -08004174 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004176 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004177 "%s: SME Change Country code fail", __func__);
4178 kfree(cmd);
4179 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 }
4181 }
4182 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4183 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004184 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 }
4186 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4187 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004188 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004189
Wilson Yang1be3e652013-10-09 15:18:31 -07004190 if (9 < cmd_len)
4191 {
4192 ptr = (char*)(cmd + 9);
4193
4194 }else{
4195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4196 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004197 kfree(cmd);
4198 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004199 }
4200
4201 if (1 != sscanf(ptr,"%d",&mode))
4202 {
4203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4204 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004205 kfree(cmd);
4206 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004207 }
4208
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 wlan_hdd_enter_bmps(pAdapter, mode);
4210 /*TODO:Set the power mode*/
4211 }
4212 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4213 v_U32_t pmc_state;
4214 v_U16_t value;
4215
4216 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4217 if(pmc_state == BMPS) {
4218 value = DRIVER_POWER_MODE_AUTO;
4219 }
4220 else {
4221 value = DRIVER_POWER_MODE_ACTIVE;
4222 }
4223 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4224 }
4225 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004226 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 /*TODO: set the btcoexmode*/
4228 }
4229 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4230
Arif Hussain6d2a3322013-11-17 19:50:10 -08004231 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 /*TODO: Return the btcoex status*/
4233 }
4234 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4235
Arif Hussain6d2a3322013-11-17 19:50:10 -08004236 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004237
4238 /*TODO: Enable Rx data Filter*/
4239 }
4240 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4241
Arif Hussain6d2a3322013-11-17 19:50:10 -08004242 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004243
4244 /*TODO: Disable Rx data Filter*/
4245 }
4246 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4247
Arif Hussain6d2a3322013-11-17 19:50:10 -08004248 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 /*TODO: rxfilter-statistics*/
4250 }
4251 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4252
Arif Hussain6d2a3322013-11-17 19:50:10 -08004253 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 /*TODO: rxfilter-add*/
4255 }
4256 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4257
Arif Hussain6d2a3322013-11-17 19:50:10 -08004258 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 /*TODO: rxfilter-remove*/
4260 }
4261#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004262 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4263 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4264 /*TODO: support pnosetup*/
4265 }
4266 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4267 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4268 /*TODO: support pnoforce*/
4269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4271
Arif Hussain6d2a3322013-11-17 19:50:10 -08004272 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004273 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4274 kfree(cmd);
4275 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 }
4277 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004278 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004279 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4280 kfree(cmd);
4281 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 }
4283#endif /*FEATURE_WLAN_SCAN_PNO*/
4284 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004285 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004286 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4287 kfree(cmd);
4288 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 }
4290 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4291 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004292 char *ptr;
4293
4294 if (18 < cmd_len)
4295 {
4296 ptr = (char*)(cmd + 18);
4297 }else{
4298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4299 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004300 kfree(cmd);
4301 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004302 }
4303
Jeff Johnson02797792013-10-26 19:17:13 -07004304 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004305 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4306 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4307 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4308 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4309 {
4310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4311 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004312 kfree(cmd);
4313 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004315
4316 // parameters checking
4317 // period has to be larger than 0
4318 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4319 {
4320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004321 kfree(cmd);
4322 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 }
4324
4325 // use default value 5 is the input is not reasonable. in unit of 10%
4326 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4327 {
4328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4329 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4330 }
4331
4332 // default is 5
4333 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4334 {
4335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4336 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4337 }
4338
Arif Hussain24bfa702014-01-22 13:51:30 -08004339 if (eHAL_STATUS_SUCCESS !=
4340 sme_SetTxPerTracking(pHddCtx->hHal,
4341 hdd_tx_per_hit_cb,
4342 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004344 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 }
4346 }
4347 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004348 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4349 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 }
4351done:
4352 /* many of the commands write information back into the command
4353 string using snprintf(). check the return value here in one
4354 place */
4355 if ((ret < 0) || (ret >= cmd_len))
4356 {
4357 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004358 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004360 else if (ret > 0)
4361 {
4362 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4363 {
4364 hddLog(VOS_TRACE_LEVEL_ERROR,
4365 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004366 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004367 return -EFAULT;
4368 }
4369 wrqu->data.length = ret;
4370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004371
4372 if (ioctl_debug)
4373 {
4374 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004375 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004377 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304378 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004379 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004380}
4381
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304382static int iw_set_priv(struct net_device *dev,
4383 struct iw_request_info *info,
4384 union iwreq_data *wrqu, char *extra)
4385{
4386 int ret;
4387 vos_ssr_protect(__func__);
4388 ret = __iw_set_priv(dev, info, wrqu, extra);
4389 vos_ssr_unprotect(__func__);
4390
4391 return ret;
4392}
4393
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304394static int __iw_set_nick(struct net_device *dev,
4395 struct iw_request_info *info,
4396 union iwreq_data *wrqu, char *extra)
4397{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304398 hdd_adapter_t *pAdapter;
4399 hdd_context_t *pHddCtx;
4400 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304401
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304402 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304403
4404 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4405 if (NULL == pAdapter)
4406 {
4407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4408 "%s: Adapter is NULL",__func__);
4409 return -EINVAL;
4410 }
4411
4412 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4413 ret = wlan_hdd_validate_context(pHddCtx);
4414 if (0 != ret)
4415 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304416 return ret;
4417 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304418 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304419 return 0;
4420}
4421
Jeff Johnson295189b2012-06-20 16:38:30 -07004422static int iw_set_nick(struct net_device *dev,
4423 struct iw_request_info *info,
4424 union iwreq_data *wrqu, char *extra)
4425{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304426 int ret;
4427
4428 vos_ssr_protect(__func__);
4429 ret = __iw_set_nick(dev, info, wrqu, extra);
4430 vos_ssr_unprotect(__func__);
4431
4432 return ret;
4433}
4434
4435static int __iw_get_nick(struct net_device *dev,
4436 struct iw_request_info *info,
4437 union iwreq_data *wrqu, char *extra)
4438{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304439 hdd_adapter_t *pAdapter;
4440 hdd_context_t *pHddCtx;
4441 int ret = 0;
4442
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304444
4445 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4446 if (NULL == pAdapter)
4447 {
4448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4449 "%s: Adapter is NULL",__func__);
4450 return -EINVAL;
4451 }
4452
4453 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4454 ret = wlan_hdd_validate_context(pHddCtx);
4455 if (0 != ret)
4456 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304457 return ret;
4458 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304459 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 return 0;
4461}
4462
4463static int iw_get_nick(struct net_device *dev,
4464 struct iw_request_info *info,
4465 union iwreq_data *wrqu, char *extra)
4466{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304467 int ret;
4468
4469 vos_ssr_protect(__func__);
4470 ret = __iw_get_nick(dev, info, wrqu, extra);
4471 vos_ssr_unprotect(__func__);
4472
4473 return ret;
4474}
4475
4476static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4477{
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304479 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004480}
4481
4482static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4483{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304484
4485 struct iw_statistics *stats;
4486
4487 vos_ssr_protect(__func__);
4488 stats = __get_wireless_stats(dev);
4489 vos_ssr_unprotect(__func__);
4490
4491 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004492}
4493
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304494static int __iw_set_encode(struct net_device *dev,
4495 struct iw_request_info *info,
4496 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004497
4498{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304499 hdd_adapter_t *pAdapter;
4500 hdd_station_ctx_t *pHddStaCtx;
4501 hdd_wext_state_t *pWextState;
4502 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 struct iw_point *encoderq = &(wrqu->encoding);
4504 v_U32_t keyId;
4505 v_U8_t key_length;
4506 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4507 v_BOOL_t fKeyPresent = 0;
4508 int i;
4509 eHalStatus status = eHAL_STATUS_SUCCESS;
4510
4511
4512 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304513 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4514 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4517 "%s: Adapter is NULL",__func__);
4518 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 }
4520
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304521 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4522 status = wlan_hdd_validate_context(pHddCtx);
4523 if (0 != status)
4524 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304525 return status;
4526 }
4527 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4528 if (NULL == pWextState)
4529 {
4530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4531 "%s: pWextState is NULL ",__func__);
4532 return -EINVAL;
4533 }
4534 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4535 if (NULL == pHddStaCtx)
4536 {
4537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4538 "%s: STA Context is NULL",__func__);
4539 return -EINVAL;
4540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004541
4542 keyId = encoderq->flags & IW_ENCODE_INDEX;
4543
4544 if(keyId)
4545 {
4546 if(keyId > MAX_WEP_KEYS)
4547 {
4548 return -EINVAL;
4549 }
4550
4551 fKeyPresent = 1;
4552 keyId--;
4553 }
4554 else
4555 {
4556 fKeyPresent = 0;
4557 }
4558
4559
4560 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4561 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 if(!fKeyPresent) {
4564
4565 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4566
4567 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4568 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4569 }
4570 }
4571 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4572 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4573 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4574 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4575
4576 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4577 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4578
4579 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4580 {
4581 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4582 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004583 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304584 {
4585 long ret;
4586 ret = wait_for_completion_interruptible_timeout(
4587 &pAdapter->disconnect_comp_var,
4588 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4589 if (ret <= 0)
4590 hddLog(VOS_TRACE_LEVEL_ERROR,
4591 FL("failed wait on disconnect_comp_var %ld"), ret);
4592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 }
4594
4595 return status;
4596
4597 }
4598
4599 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4600 {
4601 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4602
4603 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4604
4605 }
4606
4607
4608 if(wrqu->data.length > 0)
4609 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004610 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004611
4612 key_length = wrqu->data.length;
4613
4614 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4615
4616 if(5 == key_length)
4617 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004618 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004619
4620 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4621 {
4622 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4623 }
4624 else
4625 {
4626 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4627 }
4628 }
4629 else if(13 == key_length)
4630 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004631 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004632
4633 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4634 {
4635 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4636 }
4637 else
4638 {
4639 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4640 }
4641 }
4642 else
4643 {
4644 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004645 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 return -EINVAL;
4647 }
4648
4649 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4650 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4651 pWextState->roamProfile.EncryptionType.numEntries = 1;
4652 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4653 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4654 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4655
4656 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4657 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4658 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4659 {
4660
4661 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4662
4663 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4664 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4665
4666 return status;
4667 }
4668 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304669 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 return 0;
4671}
4672
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304673static int iw_set_encode(struct net_device *dev,
4674 struct iw_request_info *info,
4675 union iwreq_data *wrqu,char *extra)
4676{
4677 int ret;
4678
4679 vos_ssr_protect(__func__);
4680 ret = __iw_set_encode(dev, info, wrqu, extra);
4681 vos_ssr_unprotect(__func__);
4682
4683 return ret;
4684}
4685
4686static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 struct iw_request_info *info,
4688 struct iw_point *dwrq,
4689 char *extra)
4690{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304691 hdd_adapter_t *pAdapter;
4692 hdd_wext_state_t *pWextState;
4693 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 int keyId;
4695 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4696 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304697 int i, ret = 0;
4698 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004699
4700 ENTER();
4701
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304702 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4703 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004704 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4706 "%s: Adapter is NULL",__func__);
4707 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004708 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304709 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4710 ret = wlan_hdd_validate_context(pHddCtx);
4711 if (0 != ret)
4712 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304713 return ret;
4714 }
4715 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4716 if (NULL == pWextState)
4717 {
4718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4719 "%s: pWextState is NULL",__func__);
4720 return -EINVAL;
4721 }
4722 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004723
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 keyId = pRoamProfile->Keys.defaultIndex;
4725
4726 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4727 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004728 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 return -EINVAL;
4730 }
4731
4732 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4733 {
4734 dwrq->flags |= IW_ENCODE_ENABLED;
4735 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304736 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4737 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 }
4739 else
4740 {
4741 dwrq->flags |= IW_ENCODE_DISABLED;
4742 }
4743
4744 for(i=0; i < MAX_WEP_KEYS; i++)
4745 {
4746 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4747 {
4748 continue;
4749 }
4750 else
4751 {
4752 break;
4753 }
4754 }
4755
4756 if(MAX_WEP_KEYS == i)
4757 {
4758 dwrq->flags |= IW_ENCODE_NOKEY;
4759 }
4760 else
4761 {
4762 dwrq->flags |= IW_ENCODE_ENABLED;
4763 }
4764
4765 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4766
4767 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4768 {
4769 dwrq->flags |= IW_ENCODE_DISABLED;
4770 }
4771
4772 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4773
4774 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4775 {
4776 dwrq->flags |= IW_ENCODE_OPEN;
4777 }
4778 else
4779 {
4780 dwrq->flags |= IW_ENCODE_RESTRICTED;
4781 }
4782 EXIT();
4783 return 0;
4784
4785}
4786
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304787static int iw_get_encodeext(struct net_device *dev,
4788 struct iw_request_info *info,
4789 struct iw_point *dwrq,
4790 char *extra)
4791{
4792 int ret;
4793 vos_ssr_protect(__func__);
4794 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4795 vos_ssr_unprotect(__func__);
4796
4797 return ret;
4798}
4799
4800static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 struct iw_request_info *info,
4802 union iwreq_data *wrqu, char *extra)
4803{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304804 hdd_adapter_t *pAdapter;
4805 hdd_station_ctx_t *pHddStaCtx;
4806 hdd_wext_state_t *pWextState;
4807 hdd_context_t *pHddCtx;
4808 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004809
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304810 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 v_U32_t status = 0;
4812
4813 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4814
4815 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4816
4817 int key_index;
4818 struct iw_point *encoding = &wrqu->encoding;
4819 tCsrRoamSetKey setKey;
4820 v_U32_t roamId= 0xFF;
4821 VOS_STATUS vos_status;
4822
4823 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304824 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4825 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4828 "%s: Adapter is NULL",__func__);
4829 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304831 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4832 status = wlan_hdd_validate_context(pHddCtx);
4833 if (0 != status)
4834 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304835 return status;
4836 }
4837 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4838 if (NULL == pHddStaCtx)
4839 {
4840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4841 "%s: STA Context is NULL",__func__);
4842 return -EINVAL;
4843 }
4844 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4845 if (NULL == pWextState)
4846 {
4847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4848 "%s: pWextState is NULL",__func__);
4849 return -EINVAL;
4850 }
4851 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004852 key_index = encoding->flags & IW_ENCODE_INDEX;
4853
4854 if(key_index > 0) {
4855
4856 /*Convert from 1-based to 0-based keying*/
4857 key_index--;
4858 }
4859 if(!ext->key_len) {
4860
4861 /*Set the encrytion type to NONE*/
4862 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4863 return status;
4864 }
4865
4866 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4867 (IW_ENCODE_ALG_WEP == ext->alg))
4868 {
4869 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4870
Agarwal Ashish971c2882013-10-30 20:11:12 +05304871 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4872 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 return -EINVAL;
4874 }
4875 else {
4876 /*Static wep, update the roam profile with the keys */
4877 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4878 key_index < CSR_MAX_NUM_KEY) {
4879 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4880 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4881
4882 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4883 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4884
4885 }
4886 }
4887 return status;
4888 }
4889
4890 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4891
4892 setKey.keyId = key_index;
4893 setKey.keyLength = ext->key_len;
4894
4895 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4896 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4897 }
4898
4899 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4900 /*Key direction for group is RX only*/
4901 setKey.keyDirection = eSIR_RX_ONLY;
4902 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4903 }
4904 else {
4905
4906 setKey.keyDirection = eSIR_TX_RX;
4907 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4908 }
4909
4910 /*For supplicant pae role is zero*/
4911 setKey.paeRole = 0;
4912
4913 switch(ext->alg)
4914 {
4915 case IW_ENCODE_ALG_NONE:
4916 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4917 break;
4918
4919 case IW_ENCODE_ALG_WEP:
4920 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4921 break;
4922
4923 case IW_ENCODE_ALG_TKIP:
4924 {
4925 v_U8_t *pKey = &setKey.Key[0];
4926
4927 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4928
4929 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4930
4931 /*Supplicant sends the 32bytes key in this order
4932
4933 |--------------|----------|----------|
4934 | Tk1 |TX-MIC | RX Mic |
4935 |--------------|----------|----------|
4936 <---16bytes---><--8bytes--><--8bytes-->
4937
4938 */
4939 /*Sme expects the 32 bytes key to be in the below order
4940
4941 |--------------|----------|----------|
4942 | Tk1 |RX-MIC | TX Mic |
4943 |--------------|----------|----------|
4944 <---16bytes---><--8bytes--><--8bytes-->
4945 */
4946 /* Copy the Temporal Key 1 (TK1) */
4947 vos_mem_copy(pKey,ext->key,16);
4948
4949 /*Copy the rx mic first*/
4950 vos_mem_copy(&pKey[16],&ext->key[24],8);
4951
4952 /*Copy the tx mic */
4953 vos_mem_copy(&pKey[24],&ext->key[16],8);
4954
4955 }
4956 break;
4957
4958 case IW_ENCODE_ALG_CCMP:
4959 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4960 break;
4961
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004962#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004963#define IW_ENCODE_ALG_KRK 6
4964 case IW_ENCODE_ALG_KRK:
4965 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4966 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004967#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004968
4969 default:
4970 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4971 break;
4972 }
4973
4974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004975 ("%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 -07004976
4977#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304978 /* The supplicant may attempt to set the PTK once pre-authentication
4979 is done. Save the key in the UMAC and include it in the ADD
4980 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304982 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304984 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4985 "%s: Update PreAuth Key success", __func__);
4986 return 0;
4987 }
4988 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4989 {
4990 hddLog(VOS_TRACE_LEVEL_ERROR,
4991 "%s: Update PreAuth Key failed", __func__);
4992 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 }
4994#endif /* WLAN_FEATURE_VOWIFI_11R */
4995
4996 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4997
4998 vos_status = wlan_hdd_check_ula_done(pAdapter);
4999 if ( vos_status != VOS_STATUS_SUCCESS )
5000 {
5001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5002 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5003 __LINE__, vos_status );
5004
5005 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5006 }
5007
5008 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5009
5010 if ( halStatus != eHAL_STATUS_SUCCESS )
5011 {
5012 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5013 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5014 __LINE__, halStatus );
5015
5016 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5017 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305018 EXIT();
5019 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005020}
5021
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305022static int iw_set_encodeext(struct net_device *dev,
5023 struct iw_request_info *info,
5024 union iwreq_data *wrqu, char *extra)
5025{
5026 int ret;
5027
5028 vos_ssr_protect(__func__);
5029 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5030 vos_ssr_unprotect(__func__);
5031
5032 return ret;
5033}
5034
5035static int __iw_set_retry(struct net_device *dev,
5036 struct iw_request_info *info,
5037 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005038{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305039 hdd_adapter_t *pAdapter;
5040 tHalHandle hHal;
5041 hdd_context_t *pHddCtx;
5042 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005043
5044 ENTER();
5045
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305046 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5047 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005048 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5050 "%s: Adapter is NULL",__func__);
5051 return -EINVAL;
5052 }
5053
5054 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5055 ret = wlan_hdd_validate_context(pHddCtx);
5056 if (0 != ret)
5057 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305058 return ret;
5059 }
5060
5061 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5062 if (NULL == hHal)
5063 {
5064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5065 "%s: Hal Context is NULL",__func__);
5066 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005067 }
5068
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5070 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5071
Arif Hussain6d2a3322013-11-17 19:50:10 -08005072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005073
5074 return -EINVAL;
5075 }
5076
5077 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5078
5079 if((wrqu->retry.flags & IW_RETRY_LONG))
5080 {
5081 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5082 {
c_hpothub8245442013-11-20 23:41:09 +05305083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5084 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 return -EIO;
5086 }
5087 }
5088 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5089 {
5090 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5091 {
c_hpothub8245442013-11-20 23:41:09 +05305092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5093 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 return -EIO;
5095 }
5096 }
5097 }
5098 else
5099 {
5100 return -EOPNOTSUPP;
5101 }
5102
Arif Hussain6d2a3322013-11-17 19:50:10 -08005103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005104
5105 EXIT();
5106
5107 return 0;
5108
5109}
5110
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305111static int iw_set_retry(struct net_device *dev,
5112 struct iw_request_info *info,
5113 union iwreq_data *wrqu, char *extra)
5114{
5115 int ret;
5116
5117 vos_ssr_protect(__func__);
5118 ret = __iw_set_retry(dev, info, wrqu, extra);
5119 vos_ssr_unprotect(__func__);
5120
5121 return ret;
5122}
5123
5124static int __iw_get_retry(struct net_device *dev,
5125 struct iw_request_info *info,
5126 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005127{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305128 hdd_adapter_t *pAdapter;
5129 hdd_context_t *pHddCtx;
5130 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305132 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.flags & IW_RETRY_LONG))
5160 {
5161 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5162
5163 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5164 {
c_hpothub8245442013-11-20 23:41:09 +05305165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5166 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 return -EIO;
5168 }
5169
5170 wrqu->retry.value = retry;
5171 }
5172 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5173 {
5174 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5175
5176 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5177 {
c_hpothub8245442013-11-20 23:41:09 +05305178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5179 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 return -EIO;
5181 }
5182
5183 wrqu->retry.value = retry;
5184 }
5185 else {
5186 return -EOPNOTSUPP;
5187 }
5188
Arif Hussain6d2a3322013-11-17 19:50:10 -08005189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005190
5191 EXIT();
5192
5193 return 0;
5194}
5195
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305196static int iw_get_retry(struct net_device *dev,
5197 struct iw_request_info *info,
5198 union iwreq_data *wrqu, char *extra)
5199{
5200 int ret;
5201
5202 vos_ssr_protect(__func__);
5203 ret = __iw_get_retry(dev, info, wrqu, extra);
5204 vos_ssr_unprotect(__func__);
5205
5206 return ret;
5207}
5208
5209static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005210 struct iw_request_info *info,
5211 union iwreq_data *wrqu,
5212 char *extra)
5213{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305214 hdd_adapter_t *pAdapter;
5215 hdd_context_t *pHddCtx;
5216 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5218 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305219 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005220
5221 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305222 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5223 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5226 "%s:Adapter is NULL",__func__);
5227 return -EINVAL;
5228 }
5229 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5230 ret = wlan_hdd_validate_context(pHddCtx);
5231 if (0 != ret)
5232 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305233 return ret;
5234 }
5235 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5236 if (NULL == pHddStaCtx)
5237 {
5238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5239 "%s:STA context is NULL",__func__);
5240 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 }
5242
5243 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5244 switch (mlme->cmd) {
5245 case IW_MLME_DISASSOC:
5246 case IW_MLME_DEAUTH:
5247
5248 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5249 {
5250 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5251
5252 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5253 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5254
5255 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5256 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5257
Jeff Johnson43971f52012-07-17 12:26:56 -07005258 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305259 {
5260 long ret;
5261 ret = wait_for_completion_interruptible_timeout(
5262 &pAdapter->disconnect_comp_var,
5263 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5264 if (ret <= 0)
5265 hddLog(VOS_TRACE_LEVEL_ERROR,
5266 FL("failed wait on disconnect_comp_var %ld"), ret);
5267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005269 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005270 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005271
5272 /* Resetting authKeyMgmt */
5273 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5274
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305275 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 netif_tx_disable(dev);
5277 netif_carrier_off(dev);
5278
5279 }
5280 else
5281 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005282 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 -07005283 }
5284 break;
5285 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005286 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 return -EINVAL;
5288 }//end of switch
5289
5290 EXIT();
5291
5292 return status;
5293
5294}
5295
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305296static int iw_set_mlme(struct net_device *dev,
5297 struct iw_request_info *info,
5298 union iwreq_data *wrqu,
5299 char *extra)
5300{
5301 int ret;
5302
5303 vos_ssr_protect(__func__);
5304 ret = __iw_set_mlme(dev, info, wrqu, extra);
5305 vos_ssr_unprotect(__func__);
5306
5307 return ret;
5308}
5309
Jeff Johnson295189b2012-06-20 16:38:30 -07005310/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305311static int __iw_setint_getnone(struct net_device *dev,
5312 struct iw_request_info *info,
5313 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005314{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305315 hdd_adapter_t *pAdapter;
5316 tHalHandle hHal;
5317 hdd_wext_state_t *pWextState;
5318 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305319 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 int *value = (int *)extra;
5321 int sub_cmd = value[0];
5322 int set_value = value[1];
5323 int ret = 0; /* success */
5324 int enable_pbm, enable_mp;
5325#ifdef CONFIG_HAS_EARLYSUSPEND
5326 v_U8_t nEnableSuspendOld;
5327#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005328
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305329 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305330 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5331 if (NULL == pAdapter)
5332 {
5333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5334 "%s: Adapter is NULL",__func__);
5335 return -EINVAL;
5336 }
5337 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5338 ret = wlan_hdd_validate_context(pHddCtx);
5339 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005340 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305341 return ret;
5342 }
Katya Nigameae74b62015-05-28 17:19:16 +05305343 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305344 {
Katya Nigameae74b62015-05-28 17:19:16 +05305345 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5346 if (NULL == hHal)
5347 {
5348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5349 "%s: Hal Context is NULL",__func__);
5350 return -EINVAL;
5351 }
5352 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5353 if (NULL == pWextState)
5354 {
5355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5356 "%s: pWextState is NULL",__func__);
5357 return -EINVAL;
5358 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005359
Katya Nigameae74b62015-05-28 17:19:16 +05305360 INIT_COMPLETION(pWextState->completion_var);
5361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 switch(sub_cmd)
5363 {
5364 case WE_SET_11D_STATE:
5365 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005366 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005367 memset(&smeConfig, 0x00, sizeof(smeConfig));
5368
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5370
5371 sme_GetConfigParam(hHal,&smeConfig);
5372 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5373
Arif Hussain6d2a3322013-11-17 19:50:10 -08005374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005375
5376 sme_UpdateConfig(hHal,&smeConfig);
5377 }
5378 else {
5379 return -EINVAL;
5380 }
5381 break;
5382 }
5383
5384 case WE_WOWL:
5385 {
5386 switch (set_value)
5387 {
5388 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305389 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 break;
5391 case 0x01:
5392 case 0x02:
5393 case 0x03:
5394 enable_mp = (set_value & 0x01) ? 1 : 0;
5395 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005396 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5398 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5399 break;
5400 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005401 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 ret = -EINVAL;
5403 break;
5404 }
5405
5406 break;
5407 }
5408 case WE_SET_POWER:
5409 {
5410 switch (set_value)
5411 {
5412 case 0: //Full Power
5413 {
5414 struct statsContext context;
5415 eHalStatus status;
5416
5417 init_completion(&context.completion);
5418
5419 context.pAdapter = pAdapter;
5420 context.magic = POWER_CONTEXT_MAGIC;
5421
5422 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5423 iw_power_callback_fn, &context,
5424 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005425 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 {
5427 int lrc = wait_for_completion_interruptible_timeout(
5428 &context.completion,
5429 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005430
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 if (lrc <= 0)
5432 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005433 hddLog(VOS_TRACE_LEVEL_ERROR,
5434 "%s: SME %s while requesting fullpower",
5435 __func__, (0 == lrc) ?
5436 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 }
5438 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005439 /* either we have a response or we timed out. if we timed
5440 out there is a race condition such that the callback
5441 function could be executing at the same time we are. of
5442 primary concern is if the callback function had already
5443 verified the "magic" but had not yet set the completion
5444 variable when a timeout occurred. we serialize these
5445 activities by invalidating the magic while holding a
5446 shared spinlock which will cause us to block if the
5447 callback is currently executing */
5448 spin_lock(&hdd_context_lock);
5449 context.magic = 0;
5450 spin_unlock(&hdd_context_lock);
5451
Arif Hussain6d2a3322013-11-17 19:50:10 -08005452 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 break;
5454 }
5455 case 1: //Enable BMPS
5456 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5457 break;
5458 case 2: //Disable BMPS
5459 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5460 break;
5461 case 3: //Request Bmps
5462 {
5463 struct statsContext context;
5464 eHalStatus status;
5465
5466 init_completion(&context.completion);
5467
5468 context.pAdapter = pAdapter;
5469 context.magic = POWER_CONTEXT_MAGIC;
5470
5471 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5472 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005473 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005474 {
5475 int lrc = wait_for_completion_interruptible_timeout(
5476 &context.completion,
5477 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 if (lrc <= 0)
5479 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005480 hddLog(VOS_TRACE_LEVEL_ERROR,
5481 "%s: SME %s while requesting BMPS",
5482 __func__, (0 == lrc) ? "timeout" :
5483 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 }
5485 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005486 /* either we have a response or we timed out. if we
5487 timed out there is a race condition such that the
5488 callback function could be executing at the same
5489 time we are. of primary concern is if the callback
5490 function had already verified the "magic" but had
5491 not yet set the completion variable when a timeout
5492 occurred. we serialize these activities by
5493 invalidating the magic while holding a shared
5494 spinlock which will cause us to block if the
5495 callback is currently executing */
5496 spin_lock(&hdd_context_lock);
5497 context.magic = 0;
5498 spin_unlock(&hdd_context_lock);
5499
Arif Hussain6d2a3322013-11-17 19:50:10 -08005500 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 break;
5502 }
5503 case 4: //Enable IMPS
5504 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5505 break;
5506 case 5: //Disable IMPS
5507 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5508 break;
5509 case 6: //Enable Standby
5510 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5511 break;
5512 case 7: //Disable Standby
5513 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5514 break;
5515 case 8: //Request Standby
5516#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005517#endif
5518 break;
5519 case 9: //Start Auto Bmps Timer
5520 sme_StartAutoBmpsTimer(hHal);
5521 break;
5522 case 10://Stop Auto BMPS Timer
5523 sme_StopAutoBmpsTimer(hHal);
5524 break;
5525#ifdef CONFIG_HAS_EARLYSUSPEND
5526 case 11://suspend to standby
5527#ifdef CONFIG_HAS_EARLYSUSPEND
5528 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5529 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5531#endif
5532 break;
5533 case 12://suspend to deep sleep
5534#ifdef CONFIG_HAS_EARLYSUSPEND
5535 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5536 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5538#endif
5539 break;
5540 case 13://resume from suspend
5541#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005542#endif
5543 break;
5544#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005546 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 ret = -EINVAL;
5548 break;
5549 }
5550 break;
5551 }
5552
5553 case WE_SET_MAX_ASSOC:
5554 {
5555 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5556 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5557 {
5558 ret = -EINVAL;
5559 }
5560 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5561 set_value, NULL, eANI_BOOLEAN_FALSE)
5562 != eHAL_STATUS_SUCCESS )
5563 {
c_hpothub8245442013-11-20 23:41:09 +05305564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5565 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 ret = -EIO;
5567 }
5568 break;
5569 }
5570
5571 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5572 {
5573 if( 0 == set_value )
5574 {
5575 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5576 }
5577 else if ( 1 == set_value )
5578 {
5579 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5580 }
5581 else
5582 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005583 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 ret = -EINVAL;
5585 }
5586 break;
5587 }
5588
5589 case WE_SET_DATA_INACTIVITY_TO:
5590 {
5591 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5592 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5593 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5594 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5595 set_value,
5596 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5597 {
5598 hddLog(LOGE,"Failure: Could not pass on "
5599 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005600 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 ret = -EINVAL;
5602 }
5603 break;
5604 }
5605 case WE_SET_MAX_TX_POWER:
5606 {
5607 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5608 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5609
5610 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5611 __func__, set_value);
5612 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5613 eHAL_STATUS_SUCCESS )
5614 {
5615 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5616 __func__);
5617 return -EIO;
5618 }
5619
5620 break;
5621 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005622 case WE_SET_MAX_TX_POWER_2_4:
5623 {
5624 hddLog(VOS_TRACE_LEVEL_INFO,
5625 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5626 __func__, set_value);
5627 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5628 eHAL_STATUS_SUCCESS)
5629 {
5630 hddLog(VOS_TRACE_LEVEL_ERROR,
5631 "%s: Setting maximum tx power failed for 2.4 GHz band",
5632 __func__);
5633 return -EIO;
5634 }
5635
5636 break;
5637 }
5638 case WE_SET_MAX_TX_POWER_5_0:
5639 {
5640 hddLog(VOS_TRACE_LEVEL_INFO,
5641 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5642 __func__, set_value);
5643 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5644 eHAL_STATUS_SUCCESS)
5645 {
5646 hddLog(VOS_TRACE_LEVEL_ERROR,
5647 "%s: Setting maximum tx power failed for 5.0 GHz band",
5648 __func__);
5649 return -EIO;
5650 }
5651
5652 break;
5653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 case WE_SET_HIGHER_DTIM_TRANSITION:
5655 {
5656 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5657 (set_value == eANI_BOOLEAN_TRUE)))
5658 {
5659 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5660 ret = -EINVAL;
5661 }
5662 else
5663 {
5664 if(pAdapter->higherDtimTransition != set_value)
5665 {
5666 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005667 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 }
5669 }
5670
5671 break;
5672 }
5673
5674 case WE_SET_TM_LEVEL:
5675 {
5676 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005677 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5679
5680 break;
5681 }
5682
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305683 case WE_ENABLE_STRICT_FCC_REG:
5684 {
5685 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5686 struct wiphy *wiphy = NULL;
5687 long lrc;
5688 int status;
5689
5690 wiphy = hddCtxt->wiphy;
5691 if(wiphy == NULL)
5692 {
5693 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5694 break;
5695 }
5696 init_completion(&hddCtxt->wiphy_channel_update_event);
5697
5698 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5699
5700 status = regulatory_hint(wiphy, "00");
5701 if(status < 0)
5702 {
5703 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5704 break;
5705 }
5706
5707 /* Wait for completion */
5708 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5709 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5710 if (lrc <= 0)
5711 {
5712 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5713 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5714 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5715 }
5716 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5717
5718 break;
5719 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005720 case WE_SET_DEBUG_LOG:
5721 {
5722 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5723 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5724 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5725 break;
5726 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305727#ifdef FEATURE_WLAN_TDLS
5728 case WE_SET_TDLS_OFF_CHAN:
5729 {
5730 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5732 __func__, set_value);
5733 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5734 break;
5735 }
5736 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5737 {
5738 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5740 __func__, set_value);
5741 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5742 break;
5743 }
5744 case WE_SET_TDLS_OFF_CHAN_MODE:
5745 {
5746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5747 __func__, set_value);
5748 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5749 break;
5750 }
5751#endif
Peng Xu2446a892014-09-05 17:21:18 +05305752 case WE_SET_SCAN_BAND_PREFERENCE:
5753 {
5754 tSmeConfigParams smeConfig;
5755 memset(&smeConfig, 0x00, sizeof(smeConfig));
5756 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5757 ret = -EINVAL;
5758 break;
5759 }
5760 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5761
5762 if (eCSR_BAND_ALL == set_value ||
5763 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5764 sme_GetConfigParam(hHal, &smeConfig);
5765 smeConfig.csrConfig.scanBandPreference = set_value;
5766
5767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5768 "set band scan preference = %d\n",
5769 smeConfig.csrConfig.scanBandPreference);
5770
5771 sme_UpdateConfig(hHal, &smeConfig);
5772 }
5773 else {
5774 ret = -EINVAL;
5775 }
5776 break;
5777 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305778 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5779 * connection happens so that the params can take effect during
5780 * association. Also this should not be used in STA+p2p concurrency
5781 * as the param will also effect the STA mode.
5782 */
5783 case WE_SET_MIRACAST_VENDOR_CONFIG:
5784 {
5785 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305786
Abhishek Singh01c73d12015-03-12 15:13:44 +05305787 hddLog(LOG1, FL(
5788 "Set Miracast vendor tuning %d"), set_value);
5789
5790 if (1 == set_value || 0 == set_value)
5791 {
5792 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5793 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5794 {
5795 hddLog( LOGE, FL("set vendor miracast config failed"));
5796 ret = -EIO;
5797 }
5798 }
5799 else
5800 {
5801 hddLog(LOGE,
5802 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5803 ret = -EINVAL;
5804 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305805 break;
5806 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305807
5808 case WE_GET_FRAME_LOG:
5809 {
5810 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5811 != VOS_STATUS_SUCCESS)
5812 {
5813 ret = -EINVAL;
5814 }
5815 break;
5816 }
5817
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305818 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5819 {
5820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5821 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5822 if (set_value == 0 || set_value == 1)
5823 {
5824 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5825 set_value);
5826 }
5827 else
5828 ret = -EINVAL;
5829
5830 break;
5831 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05305832 /* Bit mask value to enable RTS/CTS for different modes
5833 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
5834 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
5835 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
5836 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
5837 * for 5 GHz, VHT80 - 0x1000
5838 */
5839 case WE_SET_RTS_CTS_HTVHT:
5840 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305841
Abhishek Singh41988ba2015-05-25 19:42:29 +05305842 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
5843
5844 if (eHAL_STATUS_SUCCESS !=
5845 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
5846 {
5847 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
5848 ret = -EINVAL;
5849 }
5850 break;
5851 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305852 case WE_SET_MONITOR_STATE:
5853 {
5854
5855 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
5856 if( pMonCtx == NULL )
5857 {
5858 hddLog(LOGE, "Monitor Context NULL");
5859 break;
5860 }
5861 pMonCtx->state = set_value;
5862 if( set_value )
5863 wlan_hdd_mon_poststartmsg(pMonCtx);
5864 else
5865 wlan_hdd_mon_poststopmsg();
5866
5867 break;
5868 }
5869
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 default:
5871 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005872 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 sub_cmd, set_value);
5874 break;
5875 }
5876 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305877 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 return ret;
5879}
5880
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305881static int iw_setint_getnone(struct net_device *dev,
5882 struct iw_request_info *info,
5883 union iwreq_data *wrqu, char *extra)
5884{
5885 int ret;
5886
5887 vos_ssr_protect(__func__);
5888 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5889 vos_ssr_unprotect(__func__);
5890
5891 return 0;
5892}
Jeff Johnson295189b2012-06-20 16:38:30 -07005893/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305894static int __iw_setchar_getnone(struct net_device *dev,
5895 struct iw_request_info *info,
5896 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005897{
5898 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305899 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005901 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305902 hdd_adapter_t *pAdapter;
5903 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005904#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305905 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005906#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305907 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305908 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005909
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305910 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305911 pAdapter = (netdev_priv(dev));
5912 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005913 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5915 "%s: Adapter is NULL",__func__);
5916 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005917 }
5918
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305919 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5920 ret = wlan_hdd_validate_context(pHddCtx);
5921 if (0 != ret)
5922 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305923 return ret;
5924 }
5925#ifdef WLAN_FEATURE_VOWIFI
5926 pConfig = pHddCtx->cfg_ini;
5927#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305928 /* helper function to get iwreq_data with compat handling. */
5929 if (hdd_priv_get_data(&s_priv_data, wrqu))
5930 {
5931 return -EINVAL;
5932 }
5933
5934 /* make sure all params are correctly passed to function */
5935 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5936 {
5937 return -EINVAL;
5938 }
5939
5940 sub_cmd = s_priv_data.flags;
5941
Arif Hussain0273cba2014-01-07 20:58:29 -08005942 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305943 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5944 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005945 if (NULL == pBuffer)
5946 {
5947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5948 "mem_alloc_copy_from_user_helper fail");
5949 return -ENOMEM;
5950 }
5951
5952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305953 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5955 "%s: Received data %s", __func__, pBuffer);
5956
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 switch(sub_cmd)
5958 {
5959 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005961 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 break;
5963 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005965 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 break;
5967#if defined WLAN_FEATURE_VOWIFI
5968 case WE_NEIGHBOR_REPORT_REQUEST:
5969 {
5970 tRrmNeighborReq neighborReq;
5971 tRrmNeighborRspCallbackInfo callbackInfo;
5972
5973 if (pConfig->fRrmEnable)
5974 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305976 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 if( !neighborReq.no_ssid )
5978 {
Girish Gowli552fc072014-06-14 18:26:16 +05305979 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005980 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 }
5982
5983 callbackInfo.neighborRspCallback = NULL;
5984 callbackInfo.neighborRspCallbackContext = NULL;
5985 callbackInfo.timeout = 5000; //5 seconds
5986 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5987 }
5988 else
5989 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005990 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 ret = -EINVAL;
5992 }
5993 }
5994 break;
5995#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 case WE_SET_AP_WPS_IE:
5997 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05305998 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006001 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 if (VOS_STATUS_SUCCESS != vstatus)
6003 {
6004 ret = -EINVAL;
6005 }
6006 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306007 case WE_SET_ENCRYPT_MSG:
6008 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6009 if (NULL == pkt)
6010 {
6011 hddLog(VOS_TRACE_LEVEL_ERROR,
6012 "%s: vos_mem_alloc failed", __func__);
6013 return -ENOMEM;
6014 }
6015
6016 memset(pkt, 0, sizeof(tSirpkt80211));
6017
6018 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6019 hddLog(VOS_TRACE_LEVEL_ERROR,
6020 FL("Firmware is not DISA capable"));
6021 ret = -EINVAL;
6022 vos_mem_free(pkt);
6023 break;
6024 }
6025
6026 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6027
6028 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6029 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6030 if (eHAL_STATUS_SUCCESS != ret) {
6031 hddLog(VOS_TRACE_LEVEL_ERROR,
6032 FL("SENDEncryptMSG: fail to post WDA cmd"));
6033 ret = -EINVAL;
6034 }
6035 vos_mem_free(pkt);
6036
6037 break;
6038
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 default:
6040 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006041 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 ret = -EINVAL;
6043 break;
6044 }
6045 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006046 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306047
6048 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 return ret;
6050}
6051
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306052static int iw_setchar_getnone(struct net_device *dev,
6053 struct iw_request_info *info,
6054 union iwreq_data *wrqu, char *extra)
6055{
6056 int ret;
6057
6058 vos_ssr_protect(__func__);
6059 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6060 vos_ssr_unprotect(__func__);
6061
6062 return ret;
6063}
6064
Jeff Johnson295189b2012-06-20 16:38:30 -07006065/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306066static int __iw_setnone_getint(struct net_device *dev,
6067 struct iw_request_info *info,
6068 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006069{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306070 hdd_adapter_t *pAdapter;
6071 tHalHandle hHal;
6072 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 int *value = (int *)extra;
6074 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05306075 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006076
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306077 ENTER();
6078
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306079 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6080 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006081 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6083 "%s: Adapter is NULL",__func__);
6084 return -EINVAL;
6085 }
6086 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6087 ret = wlan_hdd_validate_context(pHddCtx);
6088 if (0 != ret)
6089 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306090 return ret;
6091 }
6092 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6093 if (NULL == hHal)
6094 {
6095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6096 "%s: Hal Context is NULL",__func__);
6097 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006099
6100 switch (value[0])
6101 {
6102 case WE_GET_11D_STATE:
6103 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006104 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306106
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6108
Arif Hussain6d2a3322013-11-17 19:50:10 -08006109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006110
6111 break;
6112 }
6113
6114 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 break;
6117
6118 case WE_PMC_STATE:
6119 {
6120 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 break;
6123 }
6124 case WE_GET_WLAN_DBG:
6125 {
6126 vos_trace_display();
6127 *value = 0;
6128 break;
6129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 case WE_GET_MAX_ASSOC:
6131 {
6132 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6133 {
c_hpothub8245442013-11-20 23:41:09 +05306134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6135 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 ret = -EIO;
6137 }
Girish Gowli385be612014-09-18 11:17:20 +05306138#ifdef WLAN_SOFTAP_VSTA_FEATURE
6139 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6140 {
6141 if (*value > VSTA_NUM_ASSOC_STA)
6142 {
6143 *value = VSTA_NUM_ASSOC_STA;
6144 }
6145 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6146 (*value > (VSTA_NUM_ASSOC_STA -
6147 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6148 {
6149 *value = (VSTA_NUM_ASSOC_STA -
6150 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6151 }
6152 }
6153 else
6154#endif
6155 {
6156 if (*value > NUM_ASSOC_STA)
6157 {
6158 *value = NUM_ASSOC_STA;
6159 }
6160 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6161 (*value > (NUM_ASSOC_STA -
6162 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6163 {
6164 *value = (NUM_ASSOC_STA -
6165 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6166 }
6167 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 break;
6169 }
6170
Jeff Johnson295189b2012-06-20 16:38:30 -07006171 case WE_GET_WDI_DBG:
6172 {
6173 wpalTraceDisplay();
6174 *value = 0;
6175 break;
6176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006177
6178 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6179 {
6180 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6181 break;
6182 }
6183 case WE_GET_CONCURRENCY_MODE:
6184 {
6185 *value = hdd_get_concurrency_mode ( );
6186
Arif Hussain6d2a3322013-11-17 19:50:10 -08006187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 break;
6189 }
6190
Peng Xu2446a892014-09-05 17:21:18 +05306191 case WE_GET_SCAN_BAND_PREFERENCE:
6192 {
6193 sme_GetConfigParam(hHal, &smeConfig);
6194 *value = smeConfig.csrConfig.scanBandPreference;
6195
6196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6197 "scanBandPreference = %d\n", *value);
6198 break;
6199 }
6200
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 default:
6202 {
6203 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6204 break;
6205 }
6206 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306207 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 return ret;
6209}
6210
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306211static int iw_setnone_getint(struct net_device *dev,
6212 struct iw_request_info *info,
6213 union iwreq_data *wrqu, char *extra)
6214{
6215 int ret;
6216
6217 vos_ssr_protect(__func__);
6218 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6219 vos_ssr_unprotect(__func__);
6220
6221 return ret;
6222
6223}
Jeff Johnson295189b2012-06-20 16:38:30 -07006224/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306225int __iw_set_three_ints_getnone(struct net_device *dev,
6226 struct iw_request_info *info,
6227 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006228{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306229 hdd_adapter_t *pAdapter;
6230 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 int *value = (int *)extra;
6232 int sub_cmd = value[0];
6233 int ret = 0;
6234
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306235 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306236 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6237 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006238 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6240 "%s: Adapter is NULL",__func__);
6241 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006242 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306243 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6244 ret = wlan_hdd_validate_context(pHddCtx);
6245 if (0 != ret)
6246 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306247 return ret;
6248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006249 switch(sub_cmd)
6250 {
6251 case WE_SET_WLAN_DBG:
6252 {
6253 vos_trace_setValue( value[1], value[2], value[3]);
6254 break;
6255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 case WE_SET_WDI_DBG:
6257 {
6258 wpalTraceSetLevel( value[1], value[2], value[3]);
6259 break;
6260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 case WE_SET_SAP_CHANNELS:
6262 {
6263 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6264 break;
6265 }
6266
6267 default:
6268 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006269 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 break;
6271 }
6272 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306273 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 return ret;
6275}
6276
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306277int iw_set_three_ints_getnone(struct net_device *dev,
6278 struct iw_request_info *info,
6279 union iwreq_data *wrqu, char *extra)
6280{
6281 int ret;
6282
6283 vos_ssr_protect(__func__);
6284 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6285 vos_ssr_unprotect(__func__);
6286
6287 return ret;
6288}
6289
6290static int __iw_get_char_setnone(struct net_device *dev,
6291 struct iw_request_info *info,
6292 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006293{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306294 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306296 hdd_context_t *pHddCtx;
6297 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006298#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006299 hdd_wext_state_t *pWextState;
6300#endif
6301
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306302 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306303 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006304 if (pAdapter == NULL)
6305 {
6306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6307 "%s: pAdapter is NULL!", __func__);
6308 return -EINVAL;
6309 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306310 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6311 ret = wlan_hdd_validate_context(pHddCtx);
6312 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006313 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306314 return ret;
6315 }
6316#ifdef WLAN_FEATURE_11W
6317 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6318 if (NULL == pWextState)
6319 {
6320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6321 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006322 return -EINVAL;
6323 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306324#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006325
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 switch(sub_cmd)
6327 {
6328 case WE_WLAN_VERSION:
6329 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006330 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 break;
6332 }
6333
6334 case WE_GET_STATS:
6335 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306336 tHalHandle hHal = NULL;
6337 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6339 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6340 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6341
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306342
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 snprintf(extra, WE_MAX_STR_LEN,
6344 "\nTransmit"
6345 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6346 "\n dropped BK %u, BE %u, VI %u, VO %u"
6347 "\n classified BK %u, BE %u, VI %u, VO %u"
6348 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6349 "\n queued BK %u, BE %u, VI %u, VO %u"
6350 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006351 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 "\n fetched BK %u, BE %u, VI %u, VO %u"
6353 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6354 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006355 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 "\n flushed BK %u, BE %u, VI %u, VO %u"
6357 "\n\nReceive"
6358 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6359 "\n\nResetsStats"
6360 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6361 "\n",
6362 pStats->txXmitCalled,
6363 pStats->txXmitDropped,
6364 pStats->txXmitBackPressured,
6365 pStats->txXmitQueued,
6366
6367 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6368 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6369 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6370 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6371
6372 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6373 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6374 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6375 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6376
6377 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6378 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6379 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6380 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6381
6382 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6383 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6384 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6385 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6386
6387 pStats->txFetched,
6388 pStats->txFetchEmpty,
6389 pStats->txFetchLowResources,
6390 pStats->txFetchDequeueError,
6391
6392 pStats->txFetchDequeued,
6393 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006394 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 pStats->txCompleted,
6396 pStats->txFlushed,
6397
6398 pStats->txFetchedAC[WLANTL_AC_BK],
6399 pStats->txFetchedAC[WLANTL_AC_BE],
6400 pStats->txFetchedAC[WLANTL_AC_VI],
6401 pStats->txFetchedAC[WLANTL_AC_VO],
6402
6403 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6404 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6405 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6406 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6407
6408 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6409 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6410 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6411 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6412
Ravi Joshi41914632013-10-21 23:02:21 -07006413 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6414 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6415 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6416 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6417
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 pStats->txFlushedAC[WLANTL_AC_BK],
6419 pStats->txFlushedAC[WLANTL_AC_BE],
6420 pStats->txFlushedAC[WLANTL_AC_VI],
6421 pStats->txFlushedAC[WLANTL_AC_VO],
6422
6423 pStats->rxChains,
6424 pStats->rxPackets,
6425 pStats->rxDropped,
6426 pStats->rxDelivered,
6427 pStats->rxRefused,
6428
6429 pResetStats->totalLogpResets,
6430 pResetStats->totalCMD53Failures,
6431 pResetStats->totalMutexReadFailures,
6432 pResetStats->totalMIFErrorFailures,
6433 pResetStats->totalFWHearbeatFailures,
6434 pResetStats->totalUnknownExceptions
6435 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306436 wrqu->data.length = strlen(extra);
6437
6438 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6439
6440 if (hHal)
6441 pMac = PMAC_STRUCT( hHal );
6442
6443 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6444 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6445 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306446 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6447 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6448 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6449 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306450 "\n",
6451 pMac->pmm.BmpscntSleep,
6452 pMac->pmm.BmpscntAwake,
6453 pMac->pmm.BmpsSleeReqFailCnt,
6454 pMac->pmm.BmpsWakeupReqFailCnt,
6455 pMac->pmm.ImpsCntSleep,
6456 pMac->pmm.ImpsCntAwake,
6457 pMac->pmm.ImpsSleepErrCnt,
6458 pMac->pmm.ImpsWakeupErrCnt,
6459 pMac->pmm.ImpsLastErr
6460 );
6461 }
6462
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 wrqu->data.length = strlen(extra)+1;
6464 break;
6465 }
6466
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306467/* The case prints the current state of the HDD, SME, CSR, PE, TL
6468 *it can be extended for WDI Global State as well.
6469 *And currently it only checks P2P_CLIENT adapter.
6470 *P2P_DEVICE and P2P_GO have not been added as of now.
6471*/
6472 case WE_GET_STATES:
6473 {
6474 int buf = 0, len = 0;
6475 int adapter_num = 0;
6476 int count = 0, check = 1;
6477
6478 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006479 tHalHandle hHal = NULL;
6480 tpAniSirGlobal pMac = NULL;
6481 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306482
6483 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6484 hdd_adapter_t *useAdapter = NULL;
6485
6486 /* Print wlan0 or p2p0 states based on the adapter_num
6487 *by using the correct adapter
6488 */
6489 while ( adapter_num < 2 )
6490 {
6491 if ( WLAN_ADAPTER == adapter_num )
6492 {
6493 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006494 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306495 "\n\n wlan0 States:-");
6496 len += buf;
6497 }
6498 else if ( P2P_ADAPTER == adapter_num )
6499 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006500 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306501 "\n\n p2p0 States:-");
6502 len += buf;
6503
6504 if( !pHddCtx )
6505 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006506 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306507 "\n pHddCtx is NULL");
6508 len += buf;
6509 break;
6510 }
6511
6512 /*Printing p2p0 states only in the case when the device is
6513 configured as a p2p_client*/
6514 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6515 if ( !useAdapter )
6516 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006517 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306518 "\n Device not configured as P2P_CLIENT.");
6519 len += buf;
6520 break;
6521 }
6522 }
6523
6524 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006525 if (!hHal) {
6526 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6527 "\n pMac is NULL");
6528 len += buf;
6529 break;
6530 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306531 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006532 if (!pMac) {
6533 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6534 "\n pMac is NULL");
6535 len += buf;
6536 break;
6537 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306538 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6539 if( !pHddStaCtx )
6540 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006541 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306542 "\n pHddStaCtx is NULL");
6543 len += buf;
6544 break;
6545 }
6546
6547 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6548
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006549 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306550 "\n HDD Conn State - %s "
6551 "\n \n SME State:"
6552 "\n Neighbour Roam State - %s"
6553 "\n CSR State - %s"
6554 "\n CSR Substate - %s"
6555 "\n \n TL STA %d State: %s",
6556 macTraceGetHDDWlanConnState(
6557 pHddStaCtx->conn_info.connState),
6558 macTraceGetNeighbourRoamState(
6559 pMac->roam.neighborRoamInfo.neighborRoamState),
6560 macTraceGetcsrRoamState(
6561 pMac->roam.curState[useAdapter->sessionId]),
6562 macTraceGetcsrRoamSubState(
6563 pMac->roam.curSubState[useAdapter->sessionId]),
6564 pHddStaCtx->conn_info.staId[0],
6565 macTraceGetTLState(tlState)
6566 );
6567 len += buf;
6568 adapter_num++;
6569 }
6570
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006571 if (pMac) {
6572 /* Printing Lim State starting with global lim states */
6573 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6574 "\n \n LIM STATES:-"
6575 "\n Global Sme State - %s "\
6576 "\n Global mlm State - %s "\
6577 "\n",
6578 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6579 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6580 );
6581 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306582
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006583 /*printing the PE Sme and Mlm states for valid lim sessions*/
Hanumantha Reddy Pothula21ecc302015-07-27 16:23:46 +05306584 while ( check < 3 && count < pMac->lim.maxBssId)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306585 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006586 if ( pMac->lim.gpSession[count].valid )
6587 {
6588 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6589 "\n Lim Valid Session %d:-"
6590 "\n PE Sme State - %s "
6591 "\n PE Mlm State - %s "
6592 "\n",
6593 check,
6594 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6595 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6596 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306597
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006598 len += buf;
6599 check++;
6600 }
6601 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306602 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306603 }
6604
6605 wrqu->data.length = strlen(extra)+1;
6606 break;
6607 }
6608
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 case WE_GET_CFG:
6610 {
6611 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6612 wrqu->data.length = strlen(extra)+1;
6613 break;
6614 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006615#ifdef WLAN_FEATURE_11AC
6616 case WE_GET_RSSI:
6617 {
6618 v_S7_t s7Rssi = 0;
6619 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6620 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6621 wrqu->data.length = strlen(extra)+1;
6622 break;
6623 }
6624#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306625
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006626#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006627 case WE_GET_ROAM_RSSI:
6628 {
6629 v_S7_t s7Rssi = 0;
6630 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6631 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6632 wrqu->data.length = strlen(extra)+1;
6633 break;
6634 }
6635#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 case WE_GET_WMM_STATUS:
6637 {
6638 snprintf(extra, WE_MAX_STR_LEN,
6639 "\nDir: 0=up, 1=down, 3=both\n"
6640 "|------------------------|\n"
6641 "|AC | ACM |Admitted| Dir |\n"
6642 "|------------------------|\n"
6643 "|VO | %d | %3s | %d |\n"
6644 "|VI | %d | %3s | %d |\n"
6645 "|BE | %d | %3s | %d |\n"
6646 "|BK | %d | %3s | %d |\n"
6647 "|------------------------|\n",
6648 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6649 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6650 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6651 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6652 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6653 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6654 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6655 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6656 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6657 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6658 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6659 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6660
Jeff Johnsone7245742012-09-05 17:12:55 -07006661
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 wrqu->data.length = strlen(extra)+1;
6663 break;
6664 }
6665 case WE_GET_CHANNEL_LIST:
6666 {
6667 VOS_STATUS status;
6668 v_U8_t i, len;
6669 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306670 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6671 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6672 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 tChannelListInfo channel_list;
6674
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006675 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006677 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006678 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006679 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 return -EINVAL;
6681 }
6682 buf = extra;
6683
6684 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006685 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6686 * needed = 5 * number of channels. Check ifsufficient
6687 * buffer is available and then proceed to fill the buffer.
6688 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006689 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6690 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006691 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006692 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006693 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 return -EINVAL;
6695 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006696 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6697 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306698 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6699 {
6700 //Printing Country code in getChannelList
6701 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6702 {
6703 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6704 "%c ", pBuf[i]);
6705 }
6706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 for(i = 0 ; i < channel_list.num_channels; i++)
6708 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006709 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006711 }
6712 wrqu->data.length = strlen(extra)+1;
6713
6714 break;
6715 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006716#ifdef FEATURE_WLAN_TDLS
6717 case WE_GET_TDLS_PEERS:
6718 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006719 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006720 break;
6721 }
6722#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006723#ifdef WLAN_FEATURE_11W
6724 case WE_GET_11W_INFO:
6725 {
6726 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6727
6728 snprintf(extra, WE_MAX_STR_LEN,
6729 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6730 "\n Number of Unprotected Disassocs %d"
6731 "\n Number of Unprotected Deauths %d",
6732 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6733 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6734 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6735 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6736 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6737
6738 wrqu->data.length = strlen(extra)+1;
6739 break;
6740 }
6741#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306742 case WE_GET_SNR:
6743 {
6744 v_S7_t s7snr = 0;
6745 int status = 0;
6746 hdd_context_t *pHddCtx;
6747 hdd_station_ctx_t *pHddStaCtx;
6748
6749 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6750 status = wlan_hdd_validate_context(pHddCtx);
6751 if (0 != status)
6752 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306753 return status;
6754 }
6755
6756 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6757
6758 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6759 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6760 {
6761 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6762 " ConnectionState-%d", __func__,
6763 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6764 pHddStaCtx->conn_info.connState);
6765 return -ENONET;
6766 }
6767
6768 /*update the stats in TL*/
6769 wlan_hdd_get_station_stats(pAdapter);
6770 wlan_hdd_get_snr(pAdapter, &s7snr);
6771 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6772 wrqu->data.length = strlen(extra) + 1;
6773 break;
6774 }
6775
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306776 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006778 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 break;
6780 }
6781 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306782 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006783 return 0;
6784}
6785
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306786static int iw_get_char_setnone(struct net_device *dev,
6787 struct iw_request_info *info,
6788 union iwreq_data *wrqu, char *extra)
6789{
6790 int ret;
6791
6792 vos_ssr_protect(__func__);
6793 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6794 vos_ssr_unprotect(__func__);
6795
6796 return ret;
6797}
6798
Jeff Johnson295189b2012-06-20 16:38:30 -07006799/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306800static int __iw_setnone_getnone(struct net_device *dev,
6801 struct iw_request_info *info,
6802 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006803{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306804 hdd_adapter_t *pAdapter;
6805 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306806 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006807 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306808 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006809
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306810 ENTER();
6811
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306812 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6813 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006814 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6816 "%s: Adapter is NULL",__func__);
6817 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006818 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306819 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6820 ret = wlan_hdd_validate_context(pHddCtx);
6821 if (0 != ret)
6822 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306823 return ret;
6824 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306825 /* helper function to get iwreq_data with compat handling. */
6826 if (hdd_priv_get_data(&s_priv_data, wrqu))
6827 {
6828 return -EINVAL;
6829 }
6830
6831 sub_cmd = s_priv_data.flags;
6832
Jeff Johnson295189b2012-06-20 16:38:30 -07006833 switch (sub_cmd)
6834 {
6835 case WE_CLEAR_STATS:
6836 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6839 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6840 break;
6841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 case WE_INIT_AP:
6843 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306844 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6845
6846 /* As Soft AP mode might been changed to STA already with
6847 * killing of Hostapd, need to find the adpater by name
6848 * rather than mode */
6849 hdd_adapter_t* pAdapter_to_stop =
6850 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6851 if( pAdapter_to_stop )
6852 {
6853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6854 "Adapter with name softap.0 already "
6855 "exist, ignoring the request.\nRemove the "
6856 "adapter and try again\n");
6857 break;
6858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006859 pr_info("Init AP trigger\n");
6860 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6861 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6862 break;
6863 }
6864 case WE_STOP_AP:
6865 {
6866 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6867 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6868 * this is a dead code and need to find the adpater by name rather than mode */
6869 hdd_adapter_t* pAdapter_to_stop =
6870 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6871 if( pAdapter_to_stop )
6872 {
6873 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6874
6875 pr_info("Stopping AP mode\n");
6876
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306877 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6878 {
6879 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6880 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6881 }
6882
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306884 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306885 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6887
6888 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6889 pAdapter_to_stop->macAddressCurrent.bytes);
6890 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6891 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306892
6893 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6894 {
6895 /* put the device back into BMPS */
6896 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006898 }
6899 else
6900 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006901 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 }
6903
6904 break;
6905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006906#ifdef WLAN_BTAMP_FEATURE
6907 case WE_ENABLE_AMP:
6908 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 WLANBAP_RegisterWithHCI(pAdapter);
6911 break;
6912 }
6913 case WE_DISABLE_AMP:
6914 {
6915 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6916 VOS_STATUS status;
6917
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006919
6920 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6921 status = WLANBAP_StopAmp();
6922 if(VOS_STATUS_SUCCESS != status )
6923 {
6924 pHddCtx->isAmpAllowed = VOS_TRUE;
6925 hddLog(VOS_TRACE_LEVEL_FATAL,
6926 "%s: Failed to stop AMP", __func__);
6927 }
6928 else
6929 {
6930 //a state m/c implementation in PAL is TBD to avoid this delay
6931 msleep(500);
6932 pHddCtx->isAmpAllowed = VOS_FALSE;
6933 WLANBAP_DeregisterFromHCI();
6934 }
6935
6936 break;
6937 }
6938#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006939 case WE_ENABLE_DXE_STALL_DETECT:
6940 {
schang6295e542013-03-12 15:31:23 -07006941 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6942 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006943 break;
6944 }
6945 case WE_DISPLAY_DXE_SNAP_SHOT:
6946 {
schang6295e542013-03-12 15:31:23 -07006947 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6948 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006949 break;
6950 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306951 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6952 {
6953 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6954 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306955 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306956 break;
6957 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306958
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306959 case WE_SET_REASSOC_TRIGGER:
6960 {
6961 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6962 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6963 v_U32_t roamId = 0;
6964 tCsrRoamModifyProfileFields modProfileFields;
6965 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6966 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6967 return 0;
6968 }
6969
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306970 case WE_STOP_OBSS_SCAN:
6971 {
6972 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6973 2.OBSS scan is stopped by Firmware during the disassociation
6974 3.OBSS stop comamnd is added for debugging purpose*/
6975 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6976 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006977
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306978 if (pAdapter == NULL)
6979 {
6980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6981 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306982 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306983 }
6984 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6985 if (pMac == NULL)
6986 {
6987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6988 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306989 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306990 }
6991 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6992 }
6993 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306994 case WE_DUMP_ROAM_TIMER_LOG:
6995 {
6996 vos_dump_roam_time_log_service();
6997 break;
6998 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306999
Mukul Sharma84f27252014-07-14 18:11:42 +05307000 case WE_RESET_ROAM_TIMER_LOG:
7001 {
7002 vos_reset_roam_timer_log();
7003 break;
7004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 default:
7006 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007007 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 break;
7009 }
7010 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307011 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 return ret;
7013}
7014
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307015static int iw_setnone_getnone(struct net_device *dev,
7016 struct iw_request_info *info,
7017 union iwreq_data *wrqu, char *extra)
7018{
7019 int ret;
7020
7021 vos_ssr_protect(__func__);
7022 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7023 vos_ssr_unprotect(__func__);
7024
7025 return ret;
7026}
7027
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307028void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7029{
7030 /*
7031 * Function to display HDD WMM information
7032 * for Tx Queues.
7033 * Prints globala as well as per client depending
7034 * whether the clients are registered or not.
7035 */
7036 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307037 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7038 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307039 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7040 hdd_ibss_peer_info_t *pPeerInfo;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307041
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307042 for ( i=0; i< NUM_TX_QUEUES; i++)
7043 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307044 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307045
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007046 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307047 i, pAdapter->wmm_tx_queue[i].count,
7048 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307049 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307050 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307051 if(pSapCtx == NULL){
7052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7053 FL("psapCtx is NULL"));
7054 return;
7055 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307056
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307057 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307058 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7059 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307060 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307061 {
7062 hddLog(LOGE, "******STAIndex: %d*********", i);
7063 for ( j=0; j< NUM_TX_QUEUES; j++)
7064 {
Katya Nigamd5c24212015-06-19 15:40:58 +05307065 if( pSapCtx->aStaInfo[i].wmm_tx_queue[j].count )
7066 {
7067 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7068 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d"
7069 "PrevAdress:%p, NextAddress:%p",
7070 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
7071 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
7072 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
7073 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
7074 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307075 }
7076 }
7077 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307078 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307079
Katya Nigam1fd24402015-02-16 14:52:19 +05307080 if(pHddStaCtx == NULL){
7081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7082 FL("pHddStaCtx is NULL"));
7083 return;
7084 }
7085
7086 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7087 if(pPeerInfo == NULL){
7088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7089 FL("ppeerinfo is NULL"));
7090 return;
7091 }
7092
7093 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7094 {
7095 if(pPeerInfo->ibssStaInfo[i].isUsed)
7096 {
7097 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7098 for ( j=0; j< NUM_TX_QUEUES; j++)
7099 {
7100 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7101 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7102 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7103 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7104 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7105 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7106 }
7107 }
7108 }
7109
7110
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307111}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307112static int __iw_set_var_ints_getnone(struct net_device *dev,
7113 struct iw_request_info *info,
7114 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007115{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307116 hdd_adapter_t *pAdapter;
7117 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307118 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307119 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007120 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307121 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307122 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007123 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307124 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007125 int cmd = 0;
7126 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307127 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007128
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307129 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307130 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307131 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7133 "%s: NULL extra buffer pointer", __func__);
7134 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307135 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307136 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7137 if (NULL == pAdapter)
7138 {
7139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7140 "%s: Adapter is NULL",__func__);
7141 return -EINVAL;
7142 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307143 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307144 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7145 ret = wlan_hdd_validate_context(pHddCtx);
7146 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007147 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307148 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007149 }
Katya Nigameae74b62015-05-28 17:19:16 +05307150 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307151 {
Katya Nigameae74b62015-05-28 17:19:16 +05307152 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7153 if (NULL == hHal)
7154 {
7155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7156 "%s: Hal Context is NULL",__func__);
7157 return -EINVAL;
7158 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307159 }
7160 sub_cmd = wrqu->data.flags;
7161
7162 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7163
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007164
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007165 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7166 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7167 {
7168 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7169 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7170 {
7171 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7172 staId = pStaCtx->conn_info.staId[0];
7173 }
7174 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7175 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7176 {
7177 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7178 staId = pAPCtx->uBCStaId;
7179 }
7180 else
7181 {
7182 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7183 return 0;
7184 }
7185 }
7186
Jeff Johnson295189b2012-06-20 16:38:30 -07007187 switch (sub_cmd)
7188 {
7189 case WE_LOG_DUMP_CMD:
7190 {
7191 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007192 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007193 apps_args[3], apps_args[4]);
7194
7195 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7196 apps_args[3], apps_args[4]);
7197
7198 }
7199 break;
7200
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 case WE_P2P_NOA_CMD:
7202 {
7203 p2p_app_setP2pPs_t p2pNoA;
7204
7205 p2pNoA.opp_ps = apps_args[0];
7206 p2pNoA.ctWindow = apps_args[1];
7207 p2pNoA.duration = apps_args[2];
7208 p2pNoA.interval = apps_args[3];
7209 p2pNoA.count = apps_args[4];
7210 p2pNoA.single_noa_duration = apps_args[5];
7211 p2pNoA.psSelection = apps_args[6];
7212
7213 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7214 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007215 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7217
7218 hdd_setP2pPs(dev, &p2pNoA);
7219
7220 }
7221 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007222
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307223 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7224 {
7225 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7226 __func__, apps_args[0], apps_args[1]);
7227 vosTraceEnable(apps_args[0], apps_args[1]);
7228 }
7229 break;
7230
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007231 case WE_MTRACE_DUMP_CMD:
7232 {
7233 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7234 "bitmask_of_module %d ",
7235 __func__, apps_args[0], apps_args[1], apps_args[2],
7236 apps_args[3]);
7237 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7238 apps_args[2], apps_args[3]);
7239
7240 }
7241 break;
7242
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007243 case WE_MCC_CONFIG_CREDENTIAL :
7244 {
7245 cmd = 287; //Command should be updated if there is any change
7246 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007247 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007248 {
7249 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7250 }
7251 else
7252 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007253 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007254 return 0;
7255 }
7256 }
7257 break;
7258
7259 case WE_MCC_CONFIG_PARAMS :
7260 {
7261 cmd = 288; //command Should be updated if there is any change
7262 // in the Riva dump command
7263 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7264 }
7265 break;
7266
Chilam NG571c65a2013-01-19 12:27:36 +05307267#ifdef FEATURE_WLAN_TDLS
7268 case WE_TDLS_CONFIG_PARAMS :
7269 {
7270 tdls_config_params_t tdlsParams;
7271
Chilam Ng01120412013-02-19 18:32:21 -08007272 tdlsParams.tdls = apps_args[0];
7273 tdlsParams.tx_period_t = apps_args[1];
7274 tdlsParams.tx_packet_n = apps_args[2];
7275 tdlsParams.discovery_period_t = apps_args[3];
7276 tdlsParams.discovery_tries_n = apps_args[4];
7277 tdlsParams.idle_timeout_t = apps_args[5];
7278 tdlsParams.idle_packet_n = apps_args[6];
7279 tdlsParams.rssi_hysteresis = apps_args[7];
7280 tdlsParams.rssi_trigger_threshold = apps_args[8];
7281 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307282
Chilam Ng01120412013-02-19 18:32:21 -08007283 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307284 }
7285 break;
7286#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307287 case WE_CONFIGURE_MONITOR_MODE:
7288 {
7289 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7290 if( pMonCtx == NULL )
7291 {
7292 hddLog(LOGE, "Monitor Context NULL");
7293 break;
7294 }
7295 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7296 __func__, apps_args[0], apps_args[1], apps_args[2],
7297 apps_args[3], apps_args[4]);
7298 /* Input Validation part of FW */
7299 pMonCtx->ChannelNo = apps_args[0];
7300 pMonCtx->ChannelBW = apps_args[1];
7301 pMonCtx->crcCheckEnabled = apps_args[2];
7302 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7303 pMonCtx->is80211to803ConReq = apps_args[4];
7304 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7305 if( pMonCtx->is80211to803ConReq )
7306 pAdapter->dev->type = ARPHRD_ETHER;
7307 else
7308 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7309 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7310 {
7311 hddLog(LOGE, "%s: Filtering data packets as management and control"
7312 " cannot be converted to 802.3 ",__func__);
7313 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7314 }
7315 if( pMonCtx->state )
7316 wlan_hdd_mon_poststartmsg(pMonCtx);
7317 }
7318 break;
7319
7320 case WE_SET_MONITOR_MODE_FILTER:
7321 {
7322 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7323 if( pMonCtx == NULL )
7324 {
7325 hddLog(LOGE, "Monitor Context NULL");
7326 break;
7327 }
7328 /* Input Validation Part of FW */
7329 pMonCtx->numOfMacFilters=1;
7330 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7331 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7332 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7333 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7334 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7335 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7336 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7337 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7338 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7339 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7340 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7341 apps_args[6], apps_args[7], apps_args[8]);
7342 if( pMonCtx->state )
7343 wlan_hdd_mon_poststartmsg(pMonCtx);
7344 }
7345 break;
7346
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 default:
7348 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007349 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7350 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 }
7352 break;
7353 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307354 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 return 0;
7356}
7357
Girish Gowlifb9758e2014-11-19 15:19:17 +05307358static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7359 struct iw_request_info *info,
7360 union iwreq_data *wrqu, char *extra)
7361{
7362 int ret;
7363 union iwreq_data u_priv_wrqu;
7364 int apps_args[MAX_VAR_ARGS] = {0};
7365 int num_args;
7366
7367 /* helper function to get iwreq_data with compat handling. */
7368 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7369 {
7370 return -EINVAL;
7371 }
7372
7373 if (NULL == u_priv_wrqu.data.pointer)
7374 {
7375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7376 "%s: NULL data pointer", __func__);
7377 return -EINVAL;
7378 }
7379
7380 num_args = u_priv_wrqu.data.length;
7381 if (num_args > MAX_VAR_ARGS)
7382 {
7383 num_args = MAX_VAR_ARGS;
7384 }
7385
7386 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7387 (sizeof(int)) * num_args))
7388 {
7389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7390 "%s: failed to copy data from user buffer", __func__);
7391 return -EFAULT;
7392 }
7393
7394 vos_ssr_protect(__func__);
7395 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7396 (char *)&apps_args);
7397 vos_ssr_unprotect(__func__);
7398
7399 return ret;
7400}
7401
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307402int iw_set_var_ints_getnone(struct net_device *dev,
7403 struct iw_request_info *info,
7404 union iwreq_data *wrqu, char *extra)
7405{
7406 int ret;
7407 vos_ssr_protect(__func__);
7408 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7409 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007410
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307411 return ret;
7412}
7413
7414static int __iw_add_tspec(struct net_device *dev,
7415 struct iw_request_info *info,
7416 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007417{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307418 hdd_adapter_t *pAdapter;
7419 hdd_station_ctx_t *pHddStaCtx;
7420 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7422 int params[HDD_WLAN_WMM_PARAM_COUNT];
7423 sme_QosWmmTspecInfo tSpec;
7424 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307425 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307426 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007427
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307428 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307429 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7430 if (NULL == pAdapter)
7431 {
7432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7433 "%s: Adapter is NULL",__func__);
7434 return -EINVAL;
7435 }
7436 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7437 ret = wlan_hdd_validate_context(pHddCtx);
7438 if (0 != ret)
7439 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307440 return ret;
7441 }
7442 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7443 if (NULL == pHddStaCtx)
7444 {
7445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7446 "%s: STA Context is NULL",__func__);
7447 return -EINVAL;
7448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 // make sure the application is sufficiently priviledged
7450 // note that the kernel will do this for "set" ioctls, but since
7451 // this ioctl wants to return status to user space it must be
7452 // defined as a "get" ioctl
7453 if (!capable(CAP_NET_ADMIN))
7454 {
7455 return -EPERM;
7456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 // we must be associated in order to add a tspec
7458 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7459 {
7460 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7461 return 0;
7462 }
7463
7464 // since we are defined to be a "get" ioctl, and since the number
7465 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307466 // will pass down in the iwreq_data, we must copy the "set" params.
7467 // We must handle the compat for iwreq_data in 32U/64K environment.
7468
7469 // helper fucntion to get iwreq_data with compat handling.
7470 if (hdd_priv_get_data(&s_priv_data, wrqu))
7471 {
7472 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7473 return 0;
7474 }
7475
7476 // make sure all params are correctly passed to function
7477 if ((NULL == s_priv_data.pointer) ||
7478 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7479 {
7480 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7481 return 0;
7482 }
7483
Jeff Johnson295189b2012-06-20 16:38:30 -07007484 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307485 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 {
7487 // hmmm, can't get them
7488 return -EIO;
7489 }
7490
7491 // clear the tspec
7492 memset(&tSpec, 0, sizeof(tSpec));
7493
7494 // validate the handle
7495 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7496 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7497 {
7498 // that one is reserved
7499 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7500 return 0;
7501 }
7502
7503 // validate the TID
7504 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7505 {
7506 // out of range
7507 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7508 return 0;
7509 }
7510 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7511
7512 // validate the direction
7513 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7514 {
7515 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7516 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7517 break;
7518
7519 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7520 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7521 break;
7522
7523 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7524 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7525 break;
7526
7527 default:
7528 // unknown
7529 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7530 return 0;
7531 }
7532
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307533 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7534
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 // validate the user priority
7536 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7537 {
7538 // out of range
7539 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7540 return 0;
7541 }
7542 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307543 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7544 {
7545 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7546 return 0;
7547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007548
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7550 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7551 tSpec.ts_info.psb, tSpec.ts_info.up);
7552
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7554 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7555 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7556 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7557 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7558 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7559 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7560 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7561 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7562 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7563 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7564 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7565
7566 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7567
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307568 // Save the expected UAPSD settings by application, this will be needed
7569 // when re-negotiating UAPSD settings during BT Coex cases.
7570 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7571
Jeff Johnson295189b2012-06-20 16:38:30 -07007572 // validate the ts info ack policy
7573 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7574 {
7575 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7576 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7577 break;
7578
7579 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7580 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7581 break;
7582
7583 default:
7584 // unknown
7585 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7586 return 0;
7587 }
7588
7589 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307590
7591 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 return 0;
7593}
7594
7595
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307596static int iw_add_tspec(struct net_device *dev,
7597 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007598 union iwreq_data *wrqu, char *extra)
7599{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307600 int ret;
7601
7602 vos_ssr_protect(__func__);
7603 ret = __iw_add_tspec(dev, info, wrqu, extra);
7604 vos_ssr_unprotect(__func__);
7605
7606 return ret;
7607}
7608
7609static int __iw_del_tspec(struct net_device *dev,
7610 struct iw_request_info *info,
7611 union iwreq_data *wrqu, char *extra)
7612{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307613 hdd_adapter_t *pAdapter;
7614 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007615 int *params = (int *)extra;
7616 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7617 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307618 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007619
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307620 ENTER();
7621
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307622 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7623 if (NULL == pAdapter)
7624 {
7625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7626 "%s: Adapter is NULL",__func__);
7627 return -EINVAL;
7628 }
7629
7630 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7631 ret = wlan_hdd_validate_context(pHddCtx);
7632 if (0 != ret)
7633 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307634 return ret;
7635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 // make sure the application is sufficiently priviledged
7637 // note that the kernel will do this for "set" ioctls, but since
7638 // this ioctl wants to return status to user space it must be
7639 // defined as a "get" ioctl
7640 if (!capable(CAP_NET_ADMIN))
7641 {
7642 return -EPERM;
7643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 // although we are defined to be a "get" ioctl, the params we require
7645 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7646 // is no need to copy the params from user space
7647
7648 // validate the handle
7649 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7650 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7651 {
7652 // that one is reserved
7653 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7654 return 0;
7655 }
7656
7657 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307658
7659 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 return 0;
7661}
7662
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307663static int iw_del_tspec(struct net_device *dev,
7664 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007665 union iwreq_data *wrqu, char *extra)
7666{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307667 int ret;
7668
7669 vos_ssr_protect(__func__);
7670 ret = __iw_del_tspec(dev, info, wrqu, extra);
7671 vos_ssr_unprotect(__func__);
7672
7673 return ret;
7674}
7675
7676
7677static int __iw_get_tspec(struct net_device *dev,
7678 struct iw_request_info *info,
7679 union iwreq_data *wrqu, char *extra)
7680{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307681 hdd_adapter_t *pAdapter;
7682 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 int *params = (int *)extra;
7684 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7685 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307686 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007687
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307688 ENTER();
7689
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 // although we are defined to be a "get" ioctl, the params we require
7691 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7692 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307693 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7694 if (NULL == pAdapter)
7695 {
7696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7697 "%s: Adapter is NULL",__func__);
7698 return -EINVAL;
7699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007700
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307701 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7702 ret = wlan_hdd_validate_context(pHddCtx);
7703 if (0 != ret)
7704 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307705 return ret;
7706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 // validate the handle
7708 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7709 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7710 {
7711 // that one is reserved
7712 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7713 return 0;
7714 }
7715
7716 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307717 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 return 0;
7719}
7720
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307721static int iw_get_tspec(struct net_device *dev,
7722 struct iw_request_info *info,
7723 union iwreq_data *wrqu, char *extra)
7724{
7725 int ret;
7726
7727 vos_ssr_protect(__func__);
7728 ret = __iw_get_tspec(dev, info, wrqu, extra);
7729 vos_ssr_unprotect(__func__);
7730
7731 return ret;
7732}
7733
Jeff Johnson295189b2012-06-20 16:38:30 -07007734#ifdef WLAN_FEATURE_VOWIFI_11R
7735//
7736//
7737// Each time the supplicant has the auth_request or reassoc request
7738// IEs ready. This is pushed to the driver. The driver will inturn use
7739// it to send out the auth req and reassoc req for 11r FT Assoc.
7740//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307741static int __iw_set_fties(struct net_device *dev,
7742 struct iw_request_info *info,
7743 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007744{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307745 hdd_adapter_t *pAdapter;
7746 hdd_station_ctx_t *pHddStaCtx;
7747 hdd_context_t *pHddCtx;
7748 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007749 //v_CONTEXT_t pVosContext;
7750
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307751 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307752 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7753 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007754 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7756 "%s: Adapter is NULL",__func__);
7757 return -EINVAL;
7758 }
7759 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7760 ret = wlan_hdd_validate_context(pHddCtx);
7761 if (0 != ret)
7762 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307763 return ret;
7764 }
7765 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7766 if (NULL == pHddStaCtx)
7767 {
7768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7769 "%s: STA Context is NULL",__func__);
7770 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007772 if (!wrqu->data.length)
7773 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007774 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007775 return -EINVAL;
7776 }
7777 if (wrqu->data.pointer == NULL)
7778 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007779 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007780 return -EINVAL;
7781 }
7782
7783 // Added for debug on reception of Re-assoc Req.
7784 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7785 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007786 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007787 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007788 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007789 }
7790
7791#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007792 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007793#endif
7794
7795 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007796 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 wrqu->data.length);
7798
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307799 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 return 0;
7801}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307802
7803static int iw_set_fties(struct net_device *dev,
7804 struct iw_request_info *info,
7805 union iwreq_data *wrqu, char *extra)
7806{
7807 int ret;
7808
7809 vos_ssr_protect(__func__);
7810 ret = __iw_set_fties(dev, info, wrqu, extra);
7811 vos_ssr_unprotect(__func__);
7812
7813 return ret;
7814}
Jeff Johnson295189b2012-06-20 16:38:30 -07007815#endif
7816
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307817static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007818 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007819 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007820{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307821 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007822 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307823 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007824 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307825 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007826 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7827 int idx;
7828 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307830 ENTER();
7831
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307832 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7833 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007834 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307835 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7836 "%s: Adapter is NULL",__func__);
7837 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007838 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307839 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7840 ret_val = wlan_hdd_validate_context(pHddCtx);
7841 if (0 != ret_val)
7842 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307843 return ret_val;
7844 }
7845 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7846 if (NULL == hHal)
7847 {
7848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7849 "%s: Hal Context is NULL",__func__);
7850 return -EINVAL;
7851 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307852 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7853 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307854#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007855
Amar Singhalf3a6e762013-02-19 15:06:50 -08007856 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7857 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007858 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007859 hddLog(VOS_TRACE_LEVEL_ERROR,
7860 "%s: vos_mem_alloc failed", __func__);
7861 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007862 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007863
7864 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7865
7866 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7867 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7868
7869 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7870 mc_addr_list_ptr->ulMulticastAddrCnt);
7871
7872 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007873 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007874 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7875 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7876
7877 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7878 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007879 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007880
Amar Singhalf3a6e762013-02-19 15:06:50 -08007881 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7882 vos_mem_free(mc_addr_list_ptr);
7883 if (eHAL_STATUS_SUCCESS != ret_val)
7884 {
7885 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7886 __func__);
7887 return -EINVAL;
7888 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307889#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307890 }
7891 else
7892 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007893
Amar Singhalf3a6e762013-02-19 15:06:50 -08007894 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7895 "%s: Set MC BC Filter Config request: %d suspend %d",
7896 __func__, pRequest->mcastBcastFilterSetting,
7897 pHddCtx->hdd_wlan_suspended);
7898
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307899 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007900
7901 if (pHddCtx->hdd_wlan_suspended)
7902 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007903 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7904 if (NULL == wlanRxpFilterParam)
7905 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307906 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007907 "%s: vos_mem_alloc failed", __func__);
7908 return -EINVAL;
7909 }
7910
Amar Singhalf3a6e762013-02-19 15:06:50 -08007911 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7912 pRequest->mcastBcastFilterSetting;
7913 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7914
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307915 hdd_conf_hostoffload(pAdapter, TRUE);
7916 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7917 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007918
7919 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7920 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307921 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007922 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7923 wlanRxpFilterParam->setMcstBcstFilter);
7924
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307925 if (eHAL_STATUS_SUCCESS !=
7926 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7927 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007928 {
7929 hddLog(VOS_TRACE_LEVEL_ERROR,
7930 "%s: Failure to execute set HW MC/BC Filter request",
7931 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007932 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007933 return -EINVAL;
7934 }
7935
c_hpothud3ce76d2014-10-28 10:34:13 +05307936 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7937 {
7938 pHddCtx->sus_res_mcastbcast_filter =
7939 pRequest->mcastBcastFilterSetting;
7940 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007941 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007943
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307944 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007945 return 0;
7946}
7947
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307948static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7949 struct iw_request_info *info,
7950 union iwreq_data *wrqu, char *extra)
7951{
7952 int ret;
7953
7954 vos_ssr_protect(__func__);
7955 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
7956 vos_ssr_unprotect(__func__);
7957
7958 return ret;
7959}
7960
7961static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7962 struct iw_request_info *info,
7963 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007964{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307965 hdd_adapter_t *pAdapter;
7966 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307967 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307968 int ret = 0;
7969
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307970 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007971
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307972 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7973 if (NULL == pAdapter)
7974 {
7975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7976 "%s: Adapter is NULL",__func__);
7977 return -EINVAL;
7978 }
7979
7980 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7981 ret = wlan_hdd_validate_context(pHddCtx);
7982 if (0 != ret)
7983 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307984 return ret;
7985 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307986 //Reset the filter to INI value as we have to clear the dynamic filter
7987 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07007988
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307989 //Configure FW with new setting
7990 if (pHddCtx->hdd_wlan_suspended)
7991 {
7992 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7993 if (NULL == wlanRxpFilterParam)
7994 {
7995 hddLog(VOS_TRACE_LEVEL_ERROR,
7996 "%s: vos_mem_alloc failed", __func__);
7997 return -EINVAL;
7998 }
7999
8000 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8001 pHddCtx->configuredMcastBcastFilter;
8002 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8003
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308004 hdd_conf_hostoffload(pAdapter, TRUE);
8005 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8006 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308007
8008 if (eHAL_STATUS_SUCCESS !=
8009 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8010 wlanRxpFilterParam))
8011 {
8012 hddLog(VOS_TRACE_LEVEL_ERROR,
8013 "%s: Failure to execute set HW MC/BC Filter request",
8014 __func__);
8015 vos_mem_free(wlanRxpFilterParam);
8016 return -EINVAL;
8017 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308018
8019 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8020 {
8021 pHddCtx->sus_res_mcastbcast_filter =
8022 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8023 }
8024
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308025 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308026 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 return 0;
8028}
8029
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308030
8031static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8032 struct iw_request_info *info,
8033 union iwreq_data *wrqu, char *extra)
8034{
8035 int ret;
8036
8037 vos_ssr_protect(__func__);
8038 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8039 vos_ssr_unprotect(__func__);
8040
8041 return ret;
8042}
8043
8044static int __iw_set_host_offload(struct net_device *dev,
8045 struct iw_request_info *info,
8046 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008047{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308048 hdd_adapter_t *pAdapter;
8049 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008050 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008051 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308052 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008053
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308054 ENTER();
8055
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308056 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8057 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008058 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8060 "%s: Adapter is NULL",__func__);
8061 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008062 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308063 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8064 ret = wlan_hdd_validate_context(pHddCtx);
8065 if (0 != ret)
8066 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308067 return ret;
8068 }
8069
Jeff Johnson295189b2012-06-20 16:38:30 -07008070 /* Debug display of request components. */
8071 switch (pRequest->offloadType)
8072 {
8073 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008074 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 switch (pRequest->enableOrDisable)
8076 {
8077 case WLAN_OFFLOAD_DISABLE:
8078 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8079 break;
8080 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8081 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8082 case WLAN_OFFLOAD_ENABLE:
8083 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8084 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8085 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8086 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8087 }
8088 break;
8089
8090 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008091 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008092 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 switch (pRequest->enableOrDisable)
8094 {
8095 case WLAN_OFFLOAD_DISABLE:
8096 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8097 break;
8098 case WLAN_OFFLOAD_ENABLE:
8099 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8100 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8101 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8102 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8103 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8104 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8105 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8106 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8107 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8108 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8109 }
8110 }
8111
8112 /* Execute offload request. The reason that we can copy the request information
8113 from the ioctl structure to the SME structure is that they are laid out
8114 exactly the same. Otherwise, each piece of information would have to be
8115 copied individually. */
8116 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008117 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8118 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008120 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008121 __func__);
8122 return -EINVAL;
8123 }
8124
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308125 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 return 0;
8127}
8128
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308129static int iw_set_host_offload(struct net_device *dev,
8130 struct iw_request_info *info,
8131 union iwreq_data *wrqu, char *extra)
8132{
8133 int ret;
8134
8135 vos_ssr_protect(__func__);
8136 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8137 vos_ssr_unprotect(__func__);
8138
8139 return ret;
8140}
8141
8142static int __iw_set_keepalive_params(struct net_device *dev,
8143 struct iw_request_info *info,
8144 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008145{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308146 hdd_adapter_t *pAdapter;
8147 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008148 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008149 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308150 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008151
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308152 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308153 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8154 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008155 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8157 "%s: Adapter is NULL",__func__);
8158 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008159 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308160 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8161 ret = wlan_hdd_validate_context(pHddCtx);
8162 if (0 != ret)
8163 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308164 return ret;
8165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008167 hddLog(VOS_TRACE_LEVEL_INFO,
8168 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8169 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008170
8171 switch (pRequest->packetType)
8172 {
8173 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008174 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 break;
8176
8177 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8178
Arif Hussain6d2a3322013-11-17 19:50:10 -08008179 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008180 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008181
8182 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8183 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8184 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8185
8186 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8187 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8188 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8189
8190 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8191 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8192 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8193 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8194 break;
8195
8196 }
8197
8198 /* Execute keep alive request. The reason that we can copy the request information
8199 from the ioctl structure to the SME structure is that they are laid out
8200 exactly the same. Otherwise, each piece of information would have to be
8201 copied individually. */
8202 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8203
Arif Hussain6d2a3322013-11-17 19:50:10 -08008204 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008205
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008206 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008207 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008208 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008209 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008210 __func__);
8211 return -EINVAL;
8212 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308213 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 return 0;
8215}
8216
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308217static int iw_set_keepalive_params(struct net_device *dev,
8218 struct iw_request_info *info,
8219 union iwreq_data *wrqu, char *extra)
8220{
8221 int ret;
8222 vos_ssr_protect(__func__);
8223 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8224 vos_ssr_unprotect(__func__);
8225
8226 return ret;
8227}
8228
Jeff Johnson295189b2012-06-20 16:38:30 -07008229#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008230int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008231 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008232{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008233 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8234 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 int i=0;
8236
8237 if (pHddCtx->cfg_ini->disablePacketFilter)
8238 {
8239 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008240 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008241 return 0;
8242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 /* Debug display of request components. */
8244 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008245 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008246
8247 switch (pRequest->filterAction)
8248 {
8249 case HDD_RCV_FILTER_SET:
8250 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008251 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008252
8253 packetFilterSetReq.filterId = pRequest->filterId;
8254 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8255 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008256 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 __func__, pRequest->numParams);
8258 return -EINVAL;
8259 }
8260 packetFilterSetReq.numFieldParams = pRequest->numParams;
8261 packetFilterSetReq.coalesceTime = 0;
8262 packetFilterSetReq.filterType = 1;
8263 for (i=0; i < pRequest->numParams; i++)
8264 {
8265 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8266 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8267 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8268 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8269 packetFilterSetReq.paramsData[i].reserved = 0;
8270
Arif Hussain6d2a3322013-11-17 19:50:10 -08008271 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8273 packetFilterSetReq.filterType);
8274
Arif Hussain6d2a3322013-11-17 19:50:10 -08008275 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008276 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8277
8278 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8279 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8280 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8281 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8282
Arif Hussain6d2a3322013-11-17 19:50:10 -08008283 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8285 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8286 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8287
Arif Hussain6d2a3322013-11-17 19:50:10 -08008288 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8290 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8291 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8292 }
8293
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008294 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008296 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 __func__);
8298 return -EINVAL;
8299 }
8300
8301 break;
8302
8303 case HDD_RCV_FILTER_CLEAR:
8304
Arif Hussain6d2a3322013-11-17 19:50:10 -08008305 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008306 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008308 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 __func__);
8312 return -EINVAL;
8313 }
8314 break;
8315
8316 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008317 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008318 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 return -EINVAL;
8320 }
8321 return 0;
8322}
8323
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308324int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8325 tANI_U8 sessionId)
8326{
8327 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8328 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8329
8330 if (NULL == pHddCtx)
8331 {
8332 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8333 return -EINVAL;
8334 }
8335
8336 if (pHddCtx->isLogpInProgress)
8337 {
8338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8339 "%s:LOGP in Progress. Ignore!!!", __func__);
8340 return -EBUSY;
8341 }
8342
8343 if (pHddCtx->cfg_ini->disablePacketFilter)
8344 {
8345 hddLog(VOS_TRACE_LEVEL_ERROR,
8346 "%s: Packet Filtering Disabled. Returning ",
8347 __func__ );
8348 return -EINVAL;
8349 }
8350
8351 switch (filterType)
8352 {
8353 /* For setting IPV6 MC and UC Filter we need to configure
8354 * 2 filters, one for MC and one for UC.
8355 * The Filter ID shouldn't be swapped, which results in making
8356 * UC Filter ineffective.
8357 * We have Hardcode all the values
8358 *
8359 * Reason for a seperate UC filter is because, driver need to
8360 * specify the FW that the specific filter is for unicast
8361 * otherwise FW will not pass the unicast frames by default
8362 * through the filter. This is required to avoid any performance
8363 * hits when no unicast filter is set and only MC/BC are set.
8364 * The way driver informs host is by using the MAC protocol
8365 * layer, CMP flag set to MAX, CMP Data set to 1.
8366 */
8367
8368 case HDD_FILTER_IPV6_MC_UC:
8369 /* Setting IPV6 MC Filter below
8370 */
8371 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8372 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8373 packetFilterSetReq.numFieldParams = 2;
8374 packetFilterSetReq.paramsData[0].protocolLayer =
8375 HDD_FILTER_PROTO_TYPE_MAC;
8376 packetFilterSetReq.paramsData[0].cmpFlag =
8377 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8378 packetFilterSetReq.paramsData[0].dataOffset =
8379 WLAN_HDD_80211_FRM_DA_OFFSET;
8380 packetFilterSetReq.paramsData[0].dataLength = 1;
8381 packetFilterSetReq.paramsData[0].compareData[0] =
8382 HDD_IPV6_MC_CMP_DATA;
8383
8384 packetFilterSetReq.paramsData[1].protocolLayer =
8385 HDD_FILTER_PROTO_TYPE_ARP;
8386 packetFilterSetReq.paramsData[1].cmpFlag =
8387 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8388 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8389 packetFilterSetReq.paramsData[1].dataLength = 2;
8390 packetFilterSetReq.paramsData[1].compareData[0] =
8391 HDD_IPV6_CMP_DATA_0;
8392 packetFilterSetReq.paramsData[1].compareData[1] =
8393 HDD_IPV6_CMP_DATA_1;
8394
8395
8396 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8397 &packetFilterSetReq, sessionId))
8398 {
8399 hddLog(VOS_TRACE_LEVEL_ERROR,
8400 "%s: Failure to execute Set IPv6 Mulicast Filter",
8401 __func__);
8402 return -EINVAL;
8403 }
8404
8405 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8406
8407 /*
8408 * Setting IPV6 UC Filter below
8409 */
8410 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8411 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8412 packetFilterSetReq.numFieldParams = 2;
8413 packetFilterSetReq.paramsData[0].protocolLayer =
8414 HDD_FILTER_PROTO_TYPE_MAC;
8415 packetFilterSetReq.paramsData[0].cmpFlag =
8416 HDD_FILTER_CMP_TYPE_MAX;
8417 packetFilterSetReq.paramsData[0].dataOffset = 0;
8418 packetFilterSetReq.paramsData[0].dataLength = 1;
8419 packetFilterSetReq.paramsData[0].compareData[0] =
8420 HDD_IPV6_UC_CMP_DATA;
8421
8422 packetFilterSetReq.paramsData[1].protocolLayer =
8423 HDD_FILTER_PROTO_TYPE_ARP;
8424 packetFilterSetReq.paramsData[1].cmpFlag =
8425 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8426 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8427 packetFilterSetReq.paramsData[1].dataLength = 2;
8428 packetFilterSetReq.paramsData[1].compareData[0] =
8429 HDD_IPV6_CMP_DATA_0;
8430 packetFilterSetReq.paramsData[1].compareData[1] =
8431 HDD_IPV6_CMP_DATA_1;
8432
8433 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8434 &packetFilterSetReq, sessionId))
8435 {
8436 hddLog(VOS_TRACE_LEVEL_ERROR,
8437 "%s: Failure to execute Set IPv6 Unicast Filter",
8438 __func__);
8439 return -EINVAL;
8440 }
8441
8442 break;
8443
8444 case HDD_FILTER_IPV6_MC:
8445 /*
8446 * IPV6 UC Filter might be already set,
8447 * clear the UC Filter. As the Filter
8448 * IDs are static, we can directly clear it.
8449 */
8450 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8451 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8452 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8453 &packetFilterClrReq, sessionId))
8454 {
8455 hddLog(VOS_TRACE_LEVEL_ERROR,
8456 "%s: Failure to execute Clear IPv6 Unicast Filter",
8457 __func__);
8458 return -EINVAL;
8459 }
8460
8461 /*
8462 * Setting IPV6 MC Filter below
8463 */
8464 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8465 packetFilterSetReq.numFieldParams = 2;
8466 packetFilterSetReq.paramsData[0].protocolLayer =
8467 HDD_FILTER_PROTO_TYPE_MAC;
8468 packetFilterSetReq.paramsData[0].cmpFlag =
8469 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8470 packetFilterSetReq.paramsData[0].dataOffset =
8471 WLAN_HDD_80211_FRM_DA_OFFSET;
8472 packetFilterSetReq.paramsData[0].dataLength = 1;
8473 packetFilterSetReq.paramsData[0].compareData[0] =
8474 HDD_IPV6_MC_CMP_DATA;
8475
8476 packetFilterSetReq.paramsData[1].protocolLayer =
8477 HDD_FILTER_PROTO_TYPE_ARP;
8478 packetFilterSetReq.paramsData[1].cmpFlag =
8479 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8480 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8481 packetFilterSetReq.paramsData[1].dataLength = 2;
8482 packetFilterSetReq.paramsData[1].compareData[0] =
8483 HDD_IPV6_CMP_DATA_0;
8484 packetFilterSetReq.paramsData[1].compareData[1] =
8485 HDD_IPV6_CMP_DATA_1;
8486
8487
8488 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8489 &packetFilterSetReq, sessionId))
8490 {
8491 hddLog(VOS_TRACE_LEVEL_ERROR,
8492 "%s: Failure to execute Set IPv6 Multicast Filter",
8493 __func__);
8494 return -EINVAL;
8495 }
8496 break;
8497
8498 default :
8499 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8500 "%s: Packet Filter Request: Invalid",
8501 __func__);
8502 return -EINVAL;
8503 }
8504 return 0;
8505}
8506
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308507void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008508{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308509 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308510 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008511 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308512 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008513
Yue Ma3ede6052013-08-29 00:33:26 -07008514 if (NULL == pHddCtx)
8515 {
8516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8517 return;
8518 }
8519
8520 hHal = pHddCtx->hHal;
8521
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308522 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308524 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8525 return;
8526 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308527
8528 /* Check if INI is enabled or not, other wise just return
8529 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308530 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308531 {
8532 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8533 if (NULL == pMulticastAddrs)
8534 {
8535 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8536 return;
8537 }
8538
Jeff Johnson295189b2012-06-20 16:38:30 -07008539 if (set)
8540 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308541 /* Following pre-conditions should be satisfied before wei
8542 * configure the MC address list.
8543 */
8544 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8545 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8546 && pAdapter->mc_addr_list.mc_cnt
8547 && (eConnectionState_Associated ==
8548 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8549 {
8550 pMulticastAddrs->ulMulticastAddrCnt =
8551 pAdapter->mc_addr_list.mc_cnt;
8552 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8553 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008554 memcpy(pMulticastAddrs->multicastAddr[i],
8555 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308556 sizeof(pAdapter->mc_addr_list.addr[i]));
8557 hddLog(VOS_TRACE_LEVEL_INFO,
8558 "%s: %s multicast filter: addr ="
8559 MAC_ADDRESS_STR,
8560 __func__, set ? "setting" : "clearing",
8561 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8562 }
8563 /* Set multicast filter */
8564 sme_8023MulticastList(hHal, pAdapter->sessionId,
8565 pMulticastAddrs);
8566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008567 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308568 else
8569 {
8570 /* Need to clear only if it was previously configured
8571 */
8572 if (pAdapter->mc_addr_list.isFilterApplied)
8573 {
8574 pMulticastAddrs->ulMulticastAddrCnt = 0;
8575 sme_8023MulticastList(hHal, pAdapter->sessionId,
8576 pMulticastAddrs);
8577 }
8578
8579 }
8580 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008581 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008582 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308583 else
8584 {
8585 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308586 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308587 }
8588 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008589}
8590
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308591static int __iw_set_packet_filter_params(struct net_device *dev,
8592 struct iw_request_info *info,
8593 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308594{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308595 hdd_adapter_t *pAdapter;
8596 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008597 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308598 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308599 struct iw_point s_priv_data;
8600
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308601 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308602 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8603 if (NULL == pAdapter)
8604 {
8605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8606 "%s: Adapter is NULL",__func__);
8607 return -EINVAL;
8608 }
8609 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8610 ret = wlan_hdd_validate_context(pHddCtx);
8611 if (0 != ret)
8612 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308613 return ret;
8614 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308615 if (hdd_priv_get_data(&s_priv_data, wrqu))
8616 {
8617 return -EINVAL;
8618 }
8619
8620 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8621 {
8622 return -EINVAL;
8623 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008624
Arif Hussain0273cba2014-01-07 20:58:29 -08008625 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308626 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8627 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008628 if (NULL == pRequest)
8629 {
8630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8631 "mem_alloc_copy_from_user_helper fail");
8632 return -ENOMEM;
8633 }
8634
8635 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8636 kfree(pRequest);
8637
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308638 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008639 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008640}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308641
8642static int iw_set_packet_filter_params(struct net_device *dev,
8643 struct iw_request_info *info,
8644 union iwreq_data *wrqu, char *extra)
8645{
8646 int ret;
8647
8648 vos_ssr_protect(__func__);
8649 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8650 vos_ssr_unprotect(__func__);
8651
8652 return ret;
8653}
Jeff Johnson295189b2012-06-20 16:38:30 -07008654#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308655static int __iw_get_statistics(struct net_device *dev,
8656 struct iw_request_info *info,
8657 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008658{
8659
8660 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8661 eHalStatus status = eHAL_STATUS_SUCCESS;
8662 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308663 hdd_adapter_t *pAdapter;
8664 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008665 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308666 int tlen = 0, ret = 0;
8667 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008668
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308669 tCsrGlobalClassAStatsInfo *aStats;
8670 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008671
8672 ENTER();
8673
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308674 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8675 if (NULL == pAdapter)
8676 {
8677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8678 "%s: Adapter is NULL",__func__);
8679 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008680 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308681 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8682 ret = wlan_hdd_validate_context(pHddCtx);
8683 if (0 != ret)
8684 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308685 return ret;
8686 }
8687 pStats = &(pAdapter->hdd_stats.summary_stat);
8688 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8689 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8691
8692 wrqu->txpower.value = 0;
8693 }
8694 else {
8695 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8696 SME_SUMMARY_STATS |
8697 SME_GLOBAL_CLASSA_STATS |
8698 SME_GLOBAL_CLASSB_STATS |
8699 SME_GLOBAL_CLASSC_STATS |
8700 SME_GLOBAL_CLASSD_STATS |
8701 SME_PER_STA_STATS,
8702 hdd_StatisticsCB, 0, FALSE,
8703 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8704
8705 if (eHAL_STATUS_SUCCESS != status)
8706 {
8707 hddLog(VOS_TRACE_LEVEL_ERROR,
8708 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008709 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 return -EINVAL;
8711 }
8712
8713 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308714 if (NULL == pWextState)
8715 {
8716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8717 "%s: pWextState is NULL",__func__);
8718 return -EINVAL;
8719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008720
8721 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8722 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8723 {
8724 hddLog(VOS_TRACE_LEVEL_ERROR,
8725 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008726 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 /*Remove the SME statistics list by passing NULL in callback argument*/
8728 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8729 SME_SUMMARY_STATS |
8730 SME_GLOBAL_CLASSA_STATS |
8731 SME_GLOBAL_CLASSB_STATS |
8732 SME_GLOBAL_CLASSC_STATS |
8733 SME_GLOBAL_CLASSD_STATS |
8734 SME_PER_STA_STATS,
8735 NULL, 0, FALSE,
8736 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8737
8738 return -EINVAL;
8739 }
8740 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8741 (tANI_U8) sizeof (pStats->retry_cnt),
8742 (char*) &(pStats->retry_cnt[0]),
8743 tlen);
8744
8745 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8746 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8747 (char*) &(pStats->multiple_retry_cnt[0]),
8748 tlen);
8749
8750 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8751 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8752 (char*) &(pStats->tx_frm_cnt[0]),
8753 tlen);
8754
8755 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8756 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8757 (char*) &(pStats->rx_frm_cnt),
8758 tlen);
8759
8760 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8761 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8762 (char*) &(pStats->frm_dup_cnt),
8763 tlen);
8764
8765 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8766 (tANI_U8) sizeof (pStats->fail_cnt),
8767 (char*) &(pStats->fail_cnt[0]),
8768 tlen);
8769
8770 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8771 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8772 (char*) &(pStats->rts_fail_cnt),
8773 tlen);
8774
8775 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8776 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8777 (char*) &(pStats->ack_fail_cnt),
8778 tlen);
8779
8780 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8781 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8782 (char*) &(pStats->rts_succ_cnt),
8783 tlen);
8784
8785 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8786 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8787 (char*) &(pStats->rx_discard_cnt),
8788 tlen);
8789
8790 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8791 (tANI_U8) sizeof (pStats->rx_error_cnt),
8792 (char*) &(pStats->rx_error_cnt),
8793 tlen);
8794
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008795 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008796 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008797 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008798 tlen);
8799
8800 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8801 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8802 (char*) &(dStats->rx_byte_cnt),
8803 tlen);
8804
8805 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8806 (tANI_U8) sizeof (dStats->rx_rate),
8807 (char*) &(dStats->rx_rate),
8808 tlen);
8809
8810 /* Transmit rate, in units of 500 kbit/sec */
8811 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8812 (tANI_U8) sizeof (aStats->tx_rate),
8813 (char*) &(aStats->tx_rate),
8814 tlen);
8815
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008816 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8817 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8818 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008819 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008820 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8821 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8822 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008823 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008824 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8825 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8826 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008827 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008828 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8829 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8830 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008831 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008832 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8833 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8834 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008835 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008836 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8837 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8838 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008839 tlen);
8840
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 wrqu->data.length = tlen;
8842
8843 }
8844
8845 EXIT();
8846
8847 return 0;
8848}
8849
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308850static int iw_get_statistics(struct net_device *dev,
8851 struct iw_request_info *info,
8852 union iwreq_data *wrqu, char *extra)
8853{
8854 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008855
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308856 vos_ssr_protect(__func__);
8857 ret = __iw_get_statistics(dev, info, wrqu, extra);
8858 vos_ssr_unprotect(__func__);
8859
8860 return ret;
8861}
Jeff Johnson295189b2012-06-20 16:38:30 -07008862#ifdef FEATURE_WLAN_SCAN_PNO
8863
8864/*Max Len for PNO notification*/
8865#define MAX_PNO_NOTIFY_LEN 100
8866void found_pref_network_cb (void *callbackContext,
8867 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8868{
8869 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8870 union iwreq_data wrqu;
8871 char buf[MAX_PNO_NOTIFY_LEN+1];
8872
8873 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8874 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8875
8876 // create the event
8877 memset(&wrqu, 0, sizeof(wrqu));
8878 memset(buf, 0, sizeof(buf));
8879
8880 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8881 pPrefNetworkFoundInd->ssId.ssId,
8882 (unsigned int)pPrefNetworkFoundInd->rssi);
8883
8884 wrqu.data.pointer = buf;
8885 wrqu.data.length = strlen(buf);
8886
8887 // send the event
8888
8889 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8890
8891}
8892
8893
8894/*string based input*/
8895VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8896 union iwreq_data *wrqu, char *extra, int nOffset)
8897{
8898 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308899 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008900 /* pnoRequest is a large struct, so we make it static to avoid stack
8901 overflow. This API is only invoked via ioctl, so it is
8902 serialized by the kernel rtnl_lock and hence does not need to be
8903 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308904 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008905 char *ptr;
8906 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308907 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008908 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8909
8910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8911 "PNO data len %d data %s",
8912 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008913 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008914
8915 if (wrqu->data.length <= nOffset )
8916 {
8917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8918 return VOS_STATUS_E_FAILURE;
8919 }
8920
8921 pnoRequest.enable = 0;
8922 pnoRequest.ucNetworksCount = 0;
8923 /*-----------------------------------------------------------------------
8924 Input is string based and expected to be like this:
8925
8926 <enabled> <netw_count>
8927 for each network:
8928 <ssid_len> <ssid> <authentication> <encryption>
8929 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8930 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8931
8932 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008933 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 -07008934
8935 this translates into:
8936 -----------------------------
8937 enable PNO
8938 look for 2 networks:
8939 test - with authentication type 0 and encryption type 0,
8940 that can be found on 3 channels: 1 6 and 11 ,
8941 SSID bcast type is unknown (directed probe will be sent if AP not found)
8942 and must meet -40dBm RSSI
8943
8944 test2 - with auth and enrytption type 4/4
8945 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
8946 bcast type is non-bcast (directed probe will be sent)
8947 and must not meet any RSSI threshold
8948
Jeff Johnson8301aa12013-03-28 14:27:29 -07008949 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07008950 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08008951 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008952
Wilson Yang623f6592013-10-08 16:33:37 -07008953 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
8954 {
8955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8956 "PNO enable input is not valid %s",ptr);
8957 return VOS_STATUS_E_FAILURE;
8958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008959
8960 if ( 0 == pnoRequest.enable )
8961 {
8962 /*Disable PNO*/
8963 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05308964 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8965 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 pAdapter->sessionId,
8967 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308968 if (eHAL_STATUS_SUCCESS != status)
8969 {
8970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8971 "%s: failed to disable PNO", __func__);
8972 return VOS_STATUS_E_FAILURE;
8973 }
8974 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008975 return VOS_STATUS_SUCCESS;
8976 }
8977
c_hpothu37f21312014-04-09 21:49:54 +05308978 if (TRUE == pHddCtx->isPnoEnable)
8979 {
8980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8981 FL("already PNO is enabled"));
8982 return -EBUSY;
8983 }
8984 pHddCtx->isPnoEnable = TRUE;
8985
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07008987
8988 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
8989 {
8990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8991 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308992 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008994
8995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8996 "PNO enable %d networks count %d offset %d",
8997 pnoRequest.enable,
8998 pnoRequest.ucNetworksCount,
8999 nOffset);
9000
9001 /* Parameters checking:
9002 ucNetworksCount has to be larger than 0*/
9003 if (( 0 == pnoRequest.ucNetworksCount ) ||
9004 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9005 {
9006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309007 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 }
9009
9010 ptr += nOffset;
9011
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309012 pnoRequest.aNetworks =
9013 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9014 if (pnoRequest.aNetworks == NULL)
9015 {
9016 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9017 FL("failed to allocate memory aNetworks %u"),
9018 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9019 goto error;
9020 }
9021 vos_mem_zero(pnoRequest.aNetworks,
9022 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9023
Jeff Johnson295189b2012-06-20 16:38:30 -07009024 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9025 {
9026
9027 pnoRequest.aNetworks[i].ssId.length = 0;
9028
Wilson Yang623f6592013-10-08 16:33:37 -07009029 ucParams = sscanf(ptr,"%hhu %n",
9030 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9031
9032 if (1 != ucParams)
9033 {
9034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9035 "PNO ssid length input is not valid %s",ptr);
9036 return VOS_STATUS_E_FAILURE;
9037 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009038
9039 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9040 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9041 {
9042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9043 "SSID Len %d is not correct for network %d",
9044 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309045 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 }
9047
9048 /*Advance to SSID*/
9049 ptr += nOffset;
9050
Jeff Johnson8301aa12013-03-28 14:27:29 -07009051 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009052 pnoRequest.aNetworks[i].ssId.length);
9053 ptr += pnoRequest.aNetworks[i].ssId.length;
9054
Jeff Johnson02797792013-10-26 19:17:13 -07009055 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009056 &(pnoRequest.aNetworks[i].authentication),
9057 &(pnoRequest.aNetworks[i].encryption),
9058 &(pnoRequest.aNetworks[i].ucChannelCount),
9059 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009060
Wilson Yang623f6592013-10-08 16:33:37 -07009061 if ( 3 != ucParams )
9062 {
9063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9064 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309065 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009066 }
9067
Jeff Johnson295189b2012-06-20 16:38:30 -07009068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009069 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009070 "auth %d encry %d channel count %d offset %d",
9071 pnoRequest.aNetworks[i].ssId.length,
9072 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9073 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9074 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9075 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9076 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9077 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9078 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9079 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9080 pnoRequest.aNetworks[i].authentication,
9081 pnoRequest.aNetworks[i].encryption,
9082 pnoRequest.aNetworks[i].ucChannelCount,
9083 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009084
Jeff Johnson295189b2012-06-20 16:38:30 -07009085 /*Advance to channel list*/
9086 ptr += nOffset;
9087
Wilson Yang623f6592013-10-08 16:33:37 -07009088 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009089 {
9090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9091 "Incorrect number of channels");
9092 return VOS_STATUS_E_FAILURE;
9093 }
9094
9095 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9096 {
9097 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9098 {
Wilson Yang623f6592013-10-08 16:33:37 -07009099 if (1 != sscanf(ptr,"%hhu %n",
9100 &(pnoRequest.aNetworks[i].aChannels[j]),
9101 &nOffset))
9102 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9103 "PNO network channel input is not valid %s",ptr);
9104 return VOS_STATUS_E_FAILURE;
9105 }
9106 /*Advance to next channel number*/
9107 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009108 }
9109 }
9110
Jeff Johnson02797792013-10-26 19:17:13 -07009111 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009112 &(pnoRequest.aNetworks[i].bcastNetwType),
9113 &nOffset))
9114 {
9115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9116 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309117 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009119
9120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9121 "PNO bcastNetwType %d offset %d",
9122 pnoRequest.aNetworks[i].bcastNetwType,
9123 nOffset );
9124
9125 /*Advance to rssi Threshold*/
9126 ptr += nOffset;
9127
Wilson Yang623f6592013-10-08 16:33:37 -07009128 if (1 != sscanf(ptr,"%hhu %n",
9129 &(pnoRequest.aNetworks[i].rssiThreshold),
9130 &nOffset))
9131 {
9132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9133 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309134 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009136
9137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9138 "PNO rssi %d offset %d",
9139 pnoRequest.aNetworks[i].rssiThreshold,
9140 nOffset );
9141 /*Advance to next network*/
9142 ptr += nOffset;
9143 }/*For ucNetworkCount*/
9144
9145 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009146 &(pnoRequest.scanTimers.ucScanTimersCount),
9147 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009148
9149 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009150 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009151 {
9152 ptr += nOffset;
9153
Jeff Johnson8301aa12013-03-28 14:27:29 -07009154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9155 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009156 pnoRequest.scanTimers.ucScanTimersCount,
9157 nOffset );
9158
9159 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9160 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009162 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309163 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 }
9165
9166 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9167 {
Jeff Johnson02797792013-10-26 19:17:13 -07009168 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009169 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9170 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9171 &nOffset);
9172
Wilson Yang623f6592013-10-08 16:33:37 -07009173 if (2 != ucParams)
9174 {
9175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9176 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309177 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009178 }
9179
Jeff Johnson8301aa12013-03-28 14:27:29 -07009180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9181 "PNO Timer value %d Timer repeat %d offset %d",
9182 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9184 nOffset );
9185
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 ptr += nOffset;
9187 }
9188
9189 }
9190 else
9191 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9193 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009194 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9195
9196 /*Scan timers defaults to 5 minutes*/
9197 pnoRequest.scanTimers.ucScanTimersCount = 1;
9198 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9199 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9200 }
9201
Wilson Yang623f6592013-10-08 16:33:37 -07009202 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009203
9204 pnoRequest.modePNO = ucMode;
9205 /*for LA we just expose suspend option*/
9206 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9207 {
9208 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9209 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309210 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9211 if (pnoRequest.p24GProbeTemplate == NULL){
9212 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9213 FL("failed to allocate memory p24GProbeTemplate %u"),
9214 SIR_PNO_MAX_PB_REQ_SIZE);
9215 goto error;
9216 }
9217
9218 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9219 if (pnoRequest.p5GProbeTemplate == NULL){
9220 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9221 FL("failed to allocate memory p5GProbeTemplate %u"),
9222 SIR_PNO_MAX_PB_REQ_SIZE);
9223 goto error;
9224 }
9225
9226 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9227 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009228
c_hpothu37f21312014-04-09 21:49:54 +05309229 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 pAdapter->sessionId,
9231 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309232 if (eHAL_STATUS_SUCCESS == status)
9233 {
9234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9235 "%s: PNO enabled", __func__);
9236 return VOS_STATUS_SUCCESS;
9237 }
9238error:
9239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9240 "%s: Failed to enable PNO", __func__);
9241 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309242 if (pnoRequest.aNetworks)
9243 vos_mem_free(pnoRequest.aNetworks);
9244 if (pnoRequest.p24GProbeTemplate)
9245 vos_mem_free(pnoRequest.p24GProbeTemplate);
9246 if (pnoRequest.p5GProbeTemplate)
9247 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309248 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009249}/*iw_set_pno*/
9250
9251VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9252 union iwreq_data *wrqu, char *extra, int nOffset)
9253{
9254 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9255 v_U8_t rssiThreshold = 0;
9256 v_U8_t nRead;
9257
Arif Hussain7adce1b2013-11-11 22:59:34 -08009258 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 &rssiThreshold);
9260
9261 if ( 1 != nRead )
9262 {
9263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9264 "Incorrect format");
9265 return VOS_STATUS_E_FAILURE;
9266 }
9267
9268 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9269 return VOS_STATUS_SUCCESS;
9270}
9271
9272
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309273static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009274 struct iw_request_info *info,
9275 union iwreq_data *wrqu, char *extra)
9276{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309277 hdd_adapter_t *pAdapter;
9278 hdd_context_t *pHddCtx;
9279 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309280 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309281
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309282 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309283 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9284 if (NULL == pAdapter)
9285 {
9286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9287 "%s: Adapter is NULL",__func__);
9288 return -EINVAL;
9289 }
9290
9291 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9292 ret = wlan_hdd_validate_context(pHddCtx);
9293 if (0 != ret)
9294 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309295 return ret;
9296 }
9297
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009298
9299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009301
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309302 status = iw_set_pno(dev,info,wrqu,extra,0);
9303
9304 EXIT();
9305 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009306}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309307
9308static int iw_set_pno_priv(struct net_device *dev,
9309 struct iw_request_info *info,
9310 union iwreq_data *wrqu, char *extra)
9311{
9312 int ret;
9313
9314 vos_ssr_protect(__func__);
9315 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9316 vos_ssr_unprotect(__func__);
9317
9318 return ret;
9319}
Jeff Johnson295189b2012-06-20 16:38:30 -07009320#endif /*FEATURE_WLAN_SCAN_PNO*/
9321
9322//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309323int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009324{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309325 hdd_adapter_t *pAdapter;
9326 tHalHandle hHal;
9327 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309328 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309329 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309330 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009331 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309332 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309333 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309334 tpAniSirGlobal pMac;
9335 int retval = 0;
9336
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309337 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309338 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9339 if (NULL == pAdapter)
9340 {
9341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9342 "%s: Adapter is NULL",__func__);
9343 return -EINVAL;
9344 }
9345 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9346 retval = wlan_hdd_validate_context(pHddCtx);
9347 if (0 != retval)
9348 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309349 return retval;
9350 }
9351 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9352 if (NULL == hHal)
9353 {
9354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9355 "%s: Hal Context is NULL",__func__);
9356 return -EINVAL;
9357 }
9358 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009359
Atul Mittal54378cb2014-04-02 16:51:50 +05309360 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009361 {
9362 case WLAN_HDD_UI_BAND_AUTO:
9363 band = eCSR_BAND_ALL;
9364 break;
9365 case WLAN_HDD_UI_BAND_5_GHZ:
9366 band = eCSR_BAND_5G;
9367 break;
9368 case WLAN_HDD_UI_BAND_2_4_GHZ:
9369 band = eCSR_BAND_24;
9370 break;
9371 default:
9372 band = eCSR_BAND_MAX;
9373 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309374 connectedBand =
9375 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009376
Atul Mittal54378cb2014-04-02 16:51:50 +05309377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009378 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009379
9380 if (band == eCSR_BAND_MAX)
9381 {
9382 /* Received change band request with invalid band value */
9383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309384 "%s: Invalid band value %u", __func__, ui_band);
9385 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009386 }
9387
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309388 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309389 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309390 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009392 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009393 band, pHddCtx->cfg_ini->nBandCapability);
9394 return -EIO;
9395 }
9396
Sushant Kaushik1165f872015-03-30 20:25:27 +05309397 if (band == eCSR_BAND_ALL)
9398 {
9399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9400 "received. Setting band same as ini value %d"),
9401 pHddCtx->cfg_ini->nBandCapability);
9402 band = pHddCtx->cfg_ini->nBandCapability;
9403 }
9404
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9406 {
9407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9408 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009409 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 return -EIO;
9411 }
9412
9413 if (currBand != band)
9414 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309415 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309416 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309417 /* Return failure if current country code is world regulatory domain*/
9418 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9419 pMac->scan.countryCodeCurrent[1] == '0') )
9420 {
9421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9422 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309423 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309424 return -EAGAIN;
9425 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309426 }
9427
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 /* Change band request received.
9429 * Abort pending scan requests, flush the existing scan results,
9430 * and change the band capability
9431 */
9432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9433 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009434 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009435
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309436 /* We need to change the band and flush the scan results here itself
9437 * as we may get timeout for disconnection in which we will return
9438 * with out doing any of these
9439 */
9440 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9441 {
9442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9443 "%s: failed to set the band value to %u ",
9444 __func__, band);
9445 return -EINVAL;
9446 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309447 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9448 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309449 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309450 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9451 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309452 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309453 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9454 * information available in NV so to get the channel information from kernel
9455 * we need to send regulatory hint for the currunt country
9456 * And to set the same country again we need to set the dummy country
9457 * first and then the actual country.
9458 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309459#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9460 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9461#else
9462 regulatory_hint_user("00");
9463#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309464 wait_result = wait_for_completion_interruptible_timeout(
9465 &pHddCtx->linux_reg_req,
9466 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9467
9468 /* if the country information does not exist with the kernel,
9469 then the driver callback would not be called */
9470
9471 if (wait_result >= 0)
9472 {
9473 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9474 "runtime country code is found in kernel db");
9475 }
9476 else
9477 {
9478 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9479 "runtime country code is not found"
9480 " in kernel db");
9481 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309482
9483 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309484
9485 /*
9486 * Update 11dcountry and current country here as the hint
9487 * with 00 results in 11d and current country with 00
9488 */
9489 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9490 WNI_CFG_COUNTRY_CODE_LEN);
9491 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9492 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309493#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9494 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9495#else
9496 regulatory_hint_user(curr_country);
9497#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309498 wait_result = wait_for_completion_interruptible_timeout(
9499 &pHddCtx->linux_reg_req,
9500 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9501
9502 /* if the country information does not exist with the kernel,
9503 then the driver callback would not be called */
9504 if (wait_result >= 0)
9505 {
9506 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9507 "runtime country code is found in kernel db");
9508 }
9509 else
9510 {
9511 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9512 "runtime country code is not found"
9513 " in kernel db");
9514 }
9515
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309516 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
9517 }
9518 else
9519 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309520#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309521 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9522 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309523#else
9524 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9525#endif
9526
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309527 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309528 pScanInfo = &pHddCtx->scan_info;
9529 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9530 {
9531 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9532 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9533 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309534 sme_FilterScanResults(hHal, pAdapter->sessionId);
9535
9536 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309537 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9538 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 eHalStatus status = eHAL_STATUS_SUCCESS;
9541 long lrc;
9542
9543 /* STA already connected on current band, So issue disconnect first,
9544 * then change the band*/
9545
9546 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309547 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309548 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009549
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9551
9552 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9553 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9554
Jeff Johnson43971f52012-07-17 12:26:56 -07009555 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009556 {
9557 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009558 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009559 __func__, (int)status );
9560 return -EINVAL;
9561 }
9562
9563 lrc = wait_for_completion_interruptible_timeout(
9564 &pAdapter->disconnect_comp_var,
9565 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9566
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309567 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009568
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009569 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009570 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009571
9572 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9573 }
9574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309576 EXIT();
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309577 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009578}
9579
Atul Mittal54378cb2014-04-02 16:51:50 +05309580int hdd_setBand_helper(struct net_device *dev, const char *command)
9581{
9582 u8 band;
9583
9584 /*convert the band value from ascii to integer*/
9585 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9586
9587 return hdd_setBand(dev, band);
9588
9589}
9590
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309591static int __iw_set_band_config(struct net_device *dev,
9592 struct iw_request_info *info,
9593 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009594{
Atul Mittal54378cb2014-04-02 16:51:50 +05309595 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009596
Arif Hussain0273cba2014-01-07 20:58:29 -08009597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009598
Atul Mittal54378cb2014-04-02 16:51:50 +05309599 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009600}
9601
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309602static int iw_set_band_config(struct net_device *dev,
9603 struct iw_request_info *info,
9604 union iwreq_data *wrqu, char *extra)
9605{
9606 int ret;
9607
9608 vos_ssr_protect(__func__);
9609 ret = __iw_set_band_config(dev, info, wrqu, extra);
9610 vos_ssr_unprotect(__func__);
9611
9612 return ret;
9613}
9614
9615static int __iw_set_power_params_priv(struct net_device *dev,
9616 struct iw_request_info *info,
9617 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009618{
Arif Hussain0273cba2014-01-07 20:58:29 -08009619 int ret;
9620 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9622 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009623 /* ODD number is used for set, copy data using copy_from_user */
9624 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9625 wrqu->data.length);
9626 if (NULL == ptr)
9627 {
9628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9629 "mem_alloc_copy_from_user_helper fail");
9630 return -ENOMEM;
9631 }
9632
9633 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9634 kfree(ptr);
9635 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009636}
9637
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309638static int iw_set_power_params_priv(struct net_device *dev,
9639 struct iw_request_info *info,
9640 union iwreq_data *wrqu, char *extra)
9641{
9642 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009643
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309644 vos_ssr_protect(__func__);
9645 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9646 vos_ssr_unprotect(__func__);
9647
9648 return ret;
9649}
Jeff Johnson295189b2012-06-20 16:38:30 -07009650
9651/*string based input*/
9652VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9653 union iwreq_data *wrqu, char *extra, int nOffset)
9654{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309655 hdd_adapter_t *pAdapter;
9656 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009657 tSirSetPowerParamsReq powerRequest;
9658 char *ptr;
9659 v_U8_t ucType;
9660 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309661 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009662
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309663 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309664 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9665 if (NULL == pAdapter)
9666 {
9667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9668 "%s: Adapter is NULL",__func__);
9669 return -EINVAL;
9670 }
9671
9672 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9673 ret = wlan_hdd_validate_context(pHddCtx);
9674 if (0 != ret)
9675 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309676 return ret;
9677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9679 "Power Params data len %d data %s",
9680 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009681 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009682
9683 if (wrqu->data.length <= nOffset )
9684 {
9685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9686 return VOS_STATUS_E_FAILURE;
9687 }
9688
9689 uTotalSize = wrqu->data.length - nOffset;
9690
9691 /*-----------------------------------------------------------------------
9692 Input is string based and expected to be like this:
9693
9694 <param_type> <param_value> <param_type> <param_value> ...
9695
9696 e.g:
9697 1 2 2 3 3 0 4 1 5 1
9698
9699 e.g. setting just a few:
9700 1 2 4 1
9701
9702 parameter types:
9703 -----------------------------
9704 1 - Ignore DTIM
9705 2 - Listen Interval
9706 3 - Broadcast Multicas Filter
9707 4 - Beacon Early Termination
9708 5 - Beacon Early Termination Interval
9709 -----------------------------------------------------------------------*/
9710 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9711 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9712 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9713 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9714 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9715
Arif Hussain7adce1b2013-11-11 22:59:34 -08009716 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009717
9718 while ( uTotalSize )
9719 {
Wilson Yang6f971452013-10-08 15:00:00 -07009720 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9721 {
9722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9723 "Invalid input parameter type %s",ptr);
9724 return VOS_STATUS_E_FAILURE;
9725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009726
9727 uTotalSize -= nOffset;
9728
9729 if (!uTotalSize)
9730 {
9731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009732 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 ucType, nOffset);
9734 return VOS_STATUS_E_FAILURE;
9735 }
9736
9737 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009738
Jeff Johnson02797792013-10-26 19:17:13 -07009739 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009740 {
9741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9742 "Invalid input parameter value %s",ptr);
9743 return VOS_STATUS_E_FAILURE;
9744 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009745
9746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9747 "Power request parameter %d value %d offset %d",
9748 ucType, uValue, nOffset);
9749
9750 switch (ucType)
9751 {
9752 case eSIR_IGNORE_DTIM:
9753 powerRequest.uIgnoreDTIM = uValue;
9754 break;
9755 case eSIR_LISTEN_INTERVAL:
9756 powerRequest.uListenInterval = uValue;
9757 break;
9758 case eSIR_MCAST_BCAST_FILTER:
9759 powerRequest.uBcastMcastFilter = uValue;
9760 break;
9761 case eSIR_ENABLE_BET:
9762 powerRequest.uEnableBET = uValue;
9763 break;
9764 case eSIR_BET_INTERVAL:
9765 powerRequest.uBETInterval = uValue;
9766 break;
9767 default:
9768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009769 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009770 ucType, uValue, nOffset);
9771 return VOS_STATUS_E_FAILURE;
9772 }
9773
9774 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9776 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009777 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009779 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009780 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009781 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9782 {
9783 uTotalSize = 0;
9784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009785
9786 }/*Go for as long as we have a valid string*/
9787
9788 /* put the device into full power*/
9789 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9790
9791 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009792 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009793
9794 /* put the device back to power save*/
9795 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9796
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309797 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009798 return VOS_STATUS_SUCCESS;
9799}/*iw_set_power_params*/
9800
Atul Mittalc0f739f2014-07-31 13:47:47 +05309801// tdlsoffchan
9802#ifdef FEATURE_WLAN_TDLS
9803
Atul Mittal87ec2422014-09-24 13:12:50 +05309804int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309805{
9806 if (offchannel < 0 || offchannel > 165)
9807 {
9808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9809 __func__, offchannel);
9810 return -1;
9811
9812 }
9813
9814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9815 __func__, tdlsOffCh, offchannel);
9816
9817 tdlsOffCh = offchannel;
9818 return 0;
9819}
9820
Atul Mittal87ec2422014-09-24 13:12:50 +05309821int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309822{
9823 if (offchanoffset == 0)
9824 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309825 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9827 __func__, tdlsOffChBwOffset);
9828
9829 return 0;
9830
9831 }
9832
9833 if ( offchanoffset == 40 )
9834 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309835 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9837 __func__, tdlsOffChBwOffset);
9838
9839 return 0;
9840
9841 }
9842 if (offchanoffset == -40)
9843 {
9844 tdlsOffChBwOffset = 3;
9845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9846 __func__, tdlsOffChBwOffset);
9847
9848 return 0;
9849
9850 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +05309851
9852 if ((offchanoffset == 80) &&
9853 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
9854 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
9855 {
9856 tdlsOffChBwOffset = 4;
9857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9858 "%s: change tdls secondary off channel offset to %u",
9859 __func__, tdlsOffChBwOffset);
9860
9861 return 0;
9862 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05309863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9864 __func__, offchanoffset);
9865 return -1;
9866}
9867
Atul Mittal87ec2422014-09-24 13:12:50 +05309868int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309869{
9870 hddTdlsPeer_t *connPeer = NULL;
9871 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9872 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9873
9874 if (offchanmode < 0 || offchanmode > 4)
9875 {
9876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9877 "%s: Invalid tdls off channel mode %d",
9878 __func__, offchanmode);
9879 return -1;
9880 }
9881
9882 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9883 {
9884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9885 "%s: tdls off channel mode req in not associated state %d",
9886 __func__, offchanmode);
9887 return -1;
9888 }
9889
9890 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9891 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9892 {
9893 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309894 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309895 if (NULL == connPeer) {
9896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9897 "%s: No TDLS Connected Peer", __func__);
9898 return -1;
9899 }
9900 }
9901 else
9902 {
9903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9904 "%s: TDLS Connection not supported", __func__);
9905 return -1;
9906 }
9907
9908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9909 ("%s: TDLS Channel Switch in swmode=%d"),
9910 __func__, offchanmode);
9911
9912 switch (offchanmode)
9913 {
9914 case 1:/*Enable*/
9915 case 2:/*Disable*/
9916 {
9917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9918 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9919 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9920 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9921 {
9922
9923 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9924 pAdapter->sessionId, connPeer->peerMac,
9925 tdlsOffCh, tdlsOffChBwOffset,
9926 offchanmode);
9927 }
9928 else
9929 {
9930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9931 "%s: TDLS Off Channel not supported", __func__);
9932 return -1;
9933 }
9934 break;
9935 }
9936 case 3:
9937 {
9938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9939 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
9940 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9941
9942 break;
9943 }
9944 case 4:
9945 {
9946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9947 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
9948 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9949 break;
9950 }
9951 default:
9952 {
9953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9954 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
9955 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9956 break;
9957 }
9958
9959 }
9960
9961 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
9962 __func__, offchanmode);
9963 return 0;
9964}
Atul Mittalc0f739f2014-07-31 13:47:47 +05309965#endif
9966
Jeff Johnson295189b2012-06-20 16:38:30 -07009967
9968// Define the Wireless Extensions to the Linux Network Device structure
9969// A number of these routines are NULL (meaning they are not implemented.)
9970
9971static const iw_handler we_handler[] =
9972{
9973 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9974 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9975 (iw_handler) NULL, /* SIOCSIWNWID */
9976 (iw_handler) NULL, /* SIOCGIWNWID */
9977 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9978 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9979 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9980 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9981 (iw_handler) NULL, /* SIOCSIWSENS */
9982 (iw_handler) NULL, /* SIOCGIWSENS */
9983 (iw_handler) NULL, /* SIOCSIWRANGE */
9984 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9985 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
9986 (iw_handler) NULL, /* SIOCGIWPRIV */
9987 (iw_handler) NULL, /* SIOCSIWSTATS */
9988 (iw_handler) NULL, /* SIOCGIWSTATS */
9989 iw_handler_set_spy, /* SIOCSIWSPY */
9990 iw_handler_get_spy, /* SIOCGIWSPY */
9991 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
9992 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
9993 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9994 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9995 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9996 (iw_handler) NULL, /* SIOCGIWAPLIST */
9997 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9998 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9999 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10000 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10001 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10002 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10003 (iw_handler) NULL, /* -- hole -- */
10004 (iw_handler) NULL, /* -- hole -- */
10005 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10006 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10007 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10008 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10009 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10010 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10011 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10012 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10013 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10014 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10015 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10016 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10017 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10018 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10019 (iw_handler) NULL, /* -- hole -- */
10020 (iw_handler) NULL, /* -- hole -- */
10021 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10022 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10023 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10024 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10025 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10026 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10027 (iw_handler) NULL, /* SIOCSIWPMKSA */
10028};
10029
10030static const iw_handler we_private[] = {
10031
10032 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10033 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10034 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10035 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10036 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10037 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010038 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10040 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10041 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010042#ifdef FEATURE_OEM_DATA_SUPPORT
10043 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10044 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10045#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010046
Jeff Johnson295189b2012-06-20 16:38:30 -070010047#ifdef WLAN_FEATURE_VOWIFI_11R
10048 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10049#endif
10050 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10051 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10052 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10053#ifdef WLAN_FEATURE_PACKET_FILTERING
10054 ,
10055 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10056#endif
10057#ifdef FEATURE_WLAN_SCAN_PNO
10058 ,
10059 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10060#endif
10061 ,
10062 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10063 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10064 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10065 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010066 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010067};
10068
10069/*Maximum command length can be only 15 */
10070static const struct iw_priv_args we_private_args[] = {
10071
Katya Nigamf0511f62015-05-05 16:40:57 +053010072 { WE_SET_MONITOR_STATE,
10073 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10074 0, "monitor" },
10075
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 /* handlers for main ioctl */
10077 { WLAN_PRIV_SET_INT_GET_NONE,
10078 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10079 0,
10080 "" },
10081
10082 /* handlers for sub-ioctl */
10083 { WE_SET_11D_STATE,
10084 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10085 0,
10086 "set11Dstate" },
10087
10088 { WE_WOWL,
10089 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10090 0,
10091 "wowl" },
10092
10093 { WE_SET_POWER,
10094 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10095 0,
10096 "setPower" },
10097
10098 { WE_SET_MAX_ASSOC,
10099 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10100 0,
10101 "setMaxAssoc" },
10102
10103 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10104 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10105 0,
10106 "setAutoChannel" },
10107
10108 { WE_SET_DATA_INACTIVITY_TO,
10109 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10110 0,
10111 "inactivityTO" },
10112
10113 { WE_SET_MAX_TX_POWER,
10114 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10115 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010116 "setMaxTxPower" },
10117
10118 { WE_SET_MAX_TX_POWER_2_4,
10119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10120 0,
10121 "setTxMaxPower2G" },
10122
10123 { WE_SET_MAX_TX_POWER_5_0,
10124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10125 0,
10126 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010127
10128 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10129 * as well to keep same syntax as in SAP. Now onwards, STA
10130 * will support both */
10131 { WE_SET_MAX_TX_POWER,
10132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10133 0,
10134 "setTxMaxPower" },
10135
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10137 * 1 = enable and 0 = disable */
10138 {
10139 WE_SET_HIGHER_DTIM_TRANSITION,
10140 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10141 0,
10142 "setHDtimTransn" },
10143
10144 { WE_SET_TM_LEVEL,
10145 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010146 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 "setTmLevel" },
10148
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010149 { WE_ENABLE_STRICT_FCC_REG,
10150 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10151 0,
10152 "setStrictFCCreg" },
10153
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010154 { WE_SET_DEBUG_LOG,
10155 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10156 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010157#ifdef FEATURE_WLAN_TDLS
10158 {
10159 WE_SET_TDLS_OFF_CHAN,
10160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10161 0,
10162 "tdlsoffchan" },
10163 {
10164 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10166 0,
10167 "tdlsecchnoffst" },
10168 {
10169 WE_SET_TDLS_OFF_CHAN_MODE,
10170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10171 0,
10172 "tdlsoffchnmode" },
10173#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010174
Peng Xu2446a892014-09-05 17:21:18 +053010175 { WE_SET_SCAN_BAND_PREFERENCE,
10176 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10177 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010178 {
10179 WE_GET_FRAME_LOG,
10180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10181 0,
10182 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010183
Abhishek Singh01c73d12015-03-12 15:13:44 +053010184 { WE_SET_MIRACAST_VENDOR_CONFIG,
10185 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10186 0, "setMiracstConf" },
10187
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010188#ifdef FEATURE_WLAN_TDLS
10189 {
10190 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10191 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10192 0,
10193 "tdls_2040bsscox" },
10194#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010195 { WE_SET_RTS_CTS_HTVHT,
10196 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10197 0, "setRtsCtsHtVht" },
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010198
Jeff Johnson295189b2012-06-20 16:38:30 -070010199 /* handlers for main ioctl */
10200 { WLAN_PRIV_SET_NONE_GET_INT,
10201 0,
10202 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10203 "" },
10204
10205 /* handlers for sub-ioctl */
10206 { WE_GET_11D_STATE,
10207 0,
10208 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10209 "get11Dstate" },
10210
10211 { WE_IBSS_STATUS,
10212 0,
10213 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10214 "getAdhocStatus" },
10215
10216 { WE_PMC_STATE,
10217 0,
10218 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10219 "pmcState" },
10220
10221 { WE_GET_WLAN_DBG,
10222 0,
10223 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10224 "getwlandbg" },
10225
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 { WE_GET_MAX_ASSOC,
10227 0,
10228 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10229 "getMaxAssoc" },
10230
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 { WE_GET_WDI_DBG,
10232 0,
10233 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10234 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010235
10236 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10237 0,
10238 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10239 "getAutoChannel" },
10240
10241 { WE_GET_CONCURRENCY_MODE,
10242 0,
10243 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10244 "getconcurrency" },
10245
Peng Xu2446a892014-09-05 17:21:18 +053010246 { WE_GET_SCAN_BAND_PREFERENCE,
10247 0,
10248 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10249 "get_scan_pref"},
10250
Jeff Johnson295189b2012-06-20 16:38:30 -070010251 /* handlers for main ioctl */
10252 { WLAN_PRIV_SET_CHAR_GET_NONE,
10253 IW_PRIV_TYPE_CHAR| 512,
10254 0,
10255 "" },
10256
10257 /* handlers for sub-ioctl */
10258 { WE_WOWL_ADD_PTRN,
10259 IW_PRIV_TYPE_CHAR| 512,
10260 0,
10261 "wowlAddPtrn" },
10262
10263 { WE_WOWL_DEL_PTRN,
10264 IW_PRIV_TYPE_CHAR| 512,
10265 0,
10266 "wowlDelPtrn" },
10267
10268#if defined WLAN_FEATURE_VOWIFI
10269 /* handlers for sub-ioctl */
10270 { WE_NEIGHBOR_REPORT_REQUEST,
10271 IW_PRIV_TYPE_CHAR | 512,
10272 0,
10273 "neighbor" },
10274#endif
10275 { WE_SET_AP_WPS_IE,
10276 IW_PRIV_TYPE_CHAR| 512,
10277 0,
10278 "set_ap_wps_ie" },
10279
10280 { WE_SET_CONFIG,
10281 IW_PRIV_TYPE_CHAR| 512,
10282 0,
10283 "setConfig" },
10284
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010285 { WE_SET_ENCRYPT_MSG,
10286 IW_PRIV_TYPE_CHAR| 512,
10287 0,
10288 "encryptMsg" },
10289
10290
Jeff Johnson295189b2012-06-20 16:38:30 -070010291 /* handlers for main ioctl */
10292 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10293 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10294 0,
10295 "" },
10296
10297 /* handlers for sub-ioctl */
10298 { WE_SET_WLAN_DBG,
10299 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10300 0,
10301 "setwlandbg" },
10302
Jeff Johnson295189b2012-06-20 16:38:30 -070010303 { WE_SET_WDI_DBG,
10304 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10305 0,
10306 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010307
10308 { WE_SET_SAP_CHANNELS,
10309 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10310 0,
10311 "setsapchannels" },
10312
10313 /* handlers for main ioctl */
10314 { WLAN_PRIV_GET_CHAR_SET_NONE,
10315 0,
10316 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10317 "" },
10318
10319 /* handlers for sub-ioctl */
10320 { WE_WLAN_VERSION,
10321 0,
10322 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10323 "version" },
10324 { WE_GET_STATS,
10325 0,
10326 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10327 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010328 { WE_GET_STATES,
10329 0,
10330 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10331 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010332 { WE_GET_CFG,
10333 0,
10334 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10335 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010336#ifdef WLAN_FEATURE_11AC
10337 { WE_GET_RSSI,
10338 0,
10339 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10340 "getRSSI" },
10341#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010342#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010343 { WE_GET_ROAM_RSSI,
10344 0,
10345 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10346 "getRoamRSSI" },
10347#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010348 { WE_GET_WMM_STATUS,
10349 0,
10350 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10351 "getWmmStatus" },
10352 {
10353 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010354 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010355 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10356 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010357#ifdef FEATURE_WLAN_TDLS
10358 {
10359 WE_GET_TDLS_PEERS,
10360 0,
10361 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10362 "getTdlsPeers" },
10363#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010364#ifdef WLAN_FEATURE_11W
10365 {
10366 WE_GET_11W_INFO,
10367 0,
10368 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10369 "getPMFInfo" },
10370#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010371 { WE_GET_SNR,
10372 0,
10373 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10374 "getSNR" },
10375
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 /* handlers for main ioctl */
10377 { WLAN_PRIV_SET_NONE_GET_NONE,
10378 0,
10379 0,
10380 "" },
10381
10382 /* handlers for sub-ioctl */
10383 { WE_CLEAR_STATS,
10384 0,
10385 0,
10386 "clearStats" },
10387 { WE_INIT_AP,
10388 0,
10389 0,
10390 "initAP" },
10391 { WE_STOP_AP,
10392 0,
10393 0,
10394 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010395#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 { WE_ENABLE_AMP,
10397 0,
10398 0,
10399 "enableAMP" },
10400 { WE_DISABLE_AMP,
10401 0,
10402 0,
10403 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010404#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010405 { WE_ENABLE_DXE_STALL_DETECT,
10406 0,
10407 0,
10408 "dxeStallDetect" },
10409 { WE_DISPLAY_DXE_SNAP_SHOT,
10410 0,
10411 0,
10412 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010413 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10414 0,
10415 0,
10416 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010417 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010418 WE_SET_REASSOC_TRIGGER,
10419 0,
10420 0,
10421 "reassoc" },
10422 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010423 WE_STOP_OBSS_SCAN,
10424 0,
10425 0,
10426 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010427 {
10428 WE_DUMP_ROAM_TIMER_LOG,
10429 0,
10430 0,
10431 "dumpRoamDelay" },
10432 {
10433 WE_RESET_ROAM_TIMER_LOG,
10434 0,
10435 0,
10436 "resetRoamDelay" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 /* handlers for main ioctl */
10438 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10439 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10440 0,
10441 "" },
10442
10443 /* handlers for sub-ioctl */
10444 { WE_LOG_DUMP_CMD,
10445 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10446 0,
10447 "dump" },
10448
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010449 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010450 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10451 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10452 0,
10453 "setdumplog" },
10454
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010455 { WE_MTRACE_DUMP_CMD,
10456 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10457 0,
10458 "dumplog" },
10459
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010460 /* handlers for sub ioctl */
10461 {
10462 WE_MCC_CONFIG_CREDENTIAL,
10463 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10464 0,
10465 "setMccCrdnl" },
10466
10467 /* handlers for sub ioctl */
10468 {
10469 WE_MCC_CONFIG_PARAMS,
10470 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10471 0,
10472 "setMccConfig" },
10473
Chilam NG571c65a2013-01-19 12:27:36 +053010474#ifdef FEATURE_WLAN_TDLS
10475 /* handlers for sub ioctl */
10476 {
10477 WE_TDLS_CONFIG_PARAMS,
10478 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10479 0,
10480 "setTdlsConfig" },
10481#endif
10482
Katya Nigamf0511f62015-05-05 16:40:57 +053010483 {
10484 WE_CONFIGURE_MONITOR_MODE,
10485 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10486 0,
10487 "MonitorModeConf" },
10488
10489 {
10490 WE_SET_MONITOR_MODE_FILTER,
10491 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10492 0,
10493 "MonitorFilter" },
10494
Jeff Johnson295189b2012-06-20 16:38:30 -070010495 /* handlers for main ioctl */
10496 { WLAN_PRIV_ADD_TSPEC,
10497 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10498 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10499 "addTspec" },
10500
10501 /* handlers for main ioctl */
10502 { WLAN_PRIV_DEL_TSPEC,
10503 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10504 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10505 "delTspec" },
10506
10507 /* handlers for main ioctl */
10508 { WLAN_PRIV_GET_TSPEC,
10509 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10510 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10511 "getTspec" },
10512
Jeff Johnsone7245742012-09-05 17:12:55 -070010513#ifdef FEATURE_OEM_DATA_SUPPORT
10514 /* handlers for main ioctl - OEM DATA */
10515 {
10516 WLAN_PRIV_SET_OEM_DATA_REQ,
10517 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10518 0,
10519 "set_oem_data_req" },
10520
10521 /* handlers for main ioctl - OEM DATA */
10522 {
10523 WLAN_PRIV_GET_OEM_DATA_RSP,
10524 0,
10525 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10526 "get_oem_data_rsp" },
10527#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010528
Jeff Johnson295189b2012-06-20 16:38:30 -070010529 /* handlers for main ioctl - host offload */
10530 {
10531 WLAN_PRIV_SET_HOST_OFFLOAD,
10532 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10533 0,
10534 "setHostOffload" },
10535
10536 {
10537 WLAN_GET_WLAN_STATISTICS,
10538 0,
10539 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10540 "getWlanStats" },
10541
10542 {
10543 WLAN_SET_KEEPALIVE_PARAMS,
10544 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10545 0,
10546 "setKeepAlive" },
10547#ifdef WLAN_FEATURE_PACKET_FILTERING
10548 {
10549 WLAN_SET_PACKET_FILTER_PARAMS,
10550 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10551 0,
10552 "setPktFilter" },
10553#endif
10554#ifdef FEATURE_WLAN_SCAN_PNO
10555 {
10556 WLAN_SET_PNO,
10557 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10558 0,
10559 "setpno" },
10560#endif
10561 {
10562 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010563 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 0,
10565 "SETBAND" },
10566 /* handlers for dynamic MC BC ioctl */
10567 {
10568 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010569 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010570 0,
10571 "setMCBCFilter" },
10572 {
10573 WLAN_PRIV_CLEAR_MCBC_FILTER,
10574 0,
10575 0,
10576 "clearMCBCFilter" },
10577 {
10578 WLAN_SET_POWER_PARAMS,
10579 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10580 0,
10581 "setpowerparams" },
10582 {
10583 WLAN_GET_LINK_SPEED,
10584 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010585 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010586};
10587
10588
10589
10590const struct iw_handler_def we_handler_def = {
10591 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10592 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10593 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10594
10595 .standard = (iw_handler *)we_handler,
10596 .private = (iw_handler *)we_private,
10597 .private_args = we_private_args,
10598 .get_wireless_stats = get_wireless_stats,
10599};
10600
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010601int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10602{
10603 v_U32_t cmd = 288; //Command to RIVA
10604 hdd_context_t *pHddCtx = NULL;
10605 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10606 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10607 /*
10608 *configMccParam : specify the bit which needs to be modified
10609 *allowed to update based on wlan_qcom_cfg.ini
10610 * configuration
10611 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10612 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10613 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10614 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10615 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10616 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10617 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10618 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10619 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10620 * Bit 9 : Reserved
10621 */
10622 switch (arg1)
10623 {
10624 //Update MCC SCHEDULE_TIME_SLICE parameter
10625 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10626 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10627 {
10628 if((arg2 >= 5) && (arg2 <= 20))
10629 {
10630 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10631 }
10632 else
10633 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010634 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010635 return 0;
10636 }
10637 }
10638 break;
10639
10640 //Update MCC MAX_NULL_SEND_TIME parameter
10641 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10642 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10643 {
10644 if((arg2 >= 1) && (arg2 <= 10))
10645 {
10646 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10647 }
10648 else
10649 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010650 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010651 return 0;
10652 }
10653 }
10654 break;
10655
10656 //Update MCC TX_EARLY_STOP_TIME parameter
10657 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10658 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10659 {
10660 if((arg2 >= 1) && (arg2 <= 10))
10661 {
10662 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10663 }
10664 else
10665 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010666 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010667 return 0;
10668 }
10669 }
10670 break;
10671
10672 //Update MCC RX_DRAIN_TIME parameter
10673 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10674 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10675 {
10676 if((arg2 >= 1) && (arg2 <= 10))
10677 {
10678 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10679 }
10680 else
10681 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010682 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010683 return 0;
10684 }
10685 }
10686 break;
10687
10688 //Update MCC CHANNEL_SWITCH_TIME parameter
10689 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10690 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10691 {
10692 if((arg2 >= 1) && (arg2 <= 20))
10693 {
10694 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10695 }
10696 else
10697 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010698 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010699 return 0;
10700 }
10701 }
10702 break;
10703
10704 //Update MCC MIN_CHANNEL_TIME parameter
10705 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10706 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10707 {
10708 if((arg2 >= 5) && (arg2 <= 20))
10709 {
10710 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10711 }
10712 else
10713 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010714 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010715 return 0;
10716 }
10717 }
10718 break;
10719
10720 //Update MCC PARK_BEFORE_TBTT parameter
10721 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10722 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10723 {
10724 if((arg2 >= 1) && (arg2 <= 5))
10725 {
10726 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10727 }
10728 else
10729 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010730 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010731 return 0;
10732 }
10733 }
10734 break;
10735
10736 //Update MCC MIN_AFTER_DTIM parameter
10737 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10738 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10739 {
10740 if((arg2 >= 5) && (arg2 <= 15))
10741 {
10742 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10743 }
10744 else
10745 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010746 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010747 return 0;
10748 }
10749 }
10750 break;
10751
10752 //Update MCC TOO_CLOSE_MARGIN parameter
10753 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10754 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10755 {
10756 if((arg2 >= 1) && (arg2 <= 3))
10757 {
10758 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10759 }
10760 else
10761 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010762 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010763 return 0;
10764 }
10765 }
10766 break;
10767
10768 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010769 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010770 __FUNCTION__,arg1);
10771 break;
10772 }
10773 return 0;
10774}
10775
Jeff Johnson295189b2012-06-20 16:38:30 -070010776int hdd_set_wext(hdd_adapter_t *pAdapter)
10777{
10778 hdd_wext_state_t *pwextBuf;
10779 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010780 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010781
10782 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10783
10784 // Now configure the roaming profile links. To SSID and bssid.
10785 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10786 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10787
10788 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10789 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10790
10791 /*Set the numOfChannels to zero to scan all the channels*/
10792 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10793 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10794
10795 /* Default is no encryption */
10796 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10797 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10798
10799 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10800 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10801
10802 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10803
10804 /* Default is no authentication */
10805 pwextBuf->roamProfile.AuthType.numEntries = 1;
10806 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10807
10808 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10809 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10810
10811 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010812 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010813
10814 hdd_clearRoamProfileIe(pAdapter);
10815
10816 return VOS_STATUS_SUCCESS;
10817
10818 }
10819
10820int hdd_register_wext(struct net_device *dev)
10821 {
10822 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10823 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10824 VOS_STATUS status;
10825
10826 ENTER();
10827
10828 // Zero the memory. This zeros the profile structure.
10829 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10830
10831 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10832
10833
10834 status = hdd_set_wext(pAdapter);
10835
10836 if(!VOS_IS_STATUS_SUCCESS(status)) {
10837
Arif Hussain6d2a3322013-11-17 19:50:10 -080010838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010839 return eHAL_STATUS_FAILURE;
10840 }
10841
10842 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10843 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010845 return eHAL_STATUS_FAILURE;
10846 }
10847
10848 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10849 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010851 return eHAL_STATUS_FAILURE;
10852 }
10853
10854 // Register as a wireless device
10855 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10856
10857 EXIT();
10858 return 0;
10859}
10860
10861int hdd_UnregisterWext(struct net_device *dev)
10862{
c_hpothu2a13bc32015-01-21 12:48:54 +053010863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10864 if (dev != NULL)
10865 {
10866 rtnl_lock();
10867 dev->wireless_handlers = NULL;
10868 rtnl_unlock();
10869 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010870
Jeff Johnson295189b2012-06-20 16:38:30 -070010871 return 0;
10872}
10873
10874