blob: e7022eb4d05f76764e6c48cac48ef4cea4060721 [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}
928
Siddharth Bhal64246172015-02-27 01:04:37 +0530929static void hdd_GetFrameLogCB( void *pContext )
930{
931 struct getFrameLogCtx *pGetFrameLogCtx;
932 hdd_adapter_t *pAdapter;
933
934 if (NULL == pContext)
935 {
936 hddLog(VOS_TRACE_LEVEL_ERROR,
937 "%s: Bad param, pContext [%p]", __func__, pContext);
938 return;
939 }
940
941 pGetFrameLogCtx = pContext;
942 pAdapter = pGetFrameLogCtx->pAdapter;
943
944 /* there is a race condition that exists between this callback
945 function and the caller since the caller could time out either
946 before or while this code is executing. we use a spinlock to
947 serialize these actions */
948 spin_lock(&hdd_context_lock);
949
950 if (GET_FRAME_LOG_MAGIC != pGetFrameLogCtx->magic)
951 {
952 /* the caller presumably timed out so there is nothing we can do */
953 spin_unlock(&hdd_context_lock);
Siddharth Bhalda0d1622015-04-24 15:47:49 +0530954 hddLog(VOS_TRACE_LEVEL_WARN,
Siddharth Bhal64246172015-02-27 01:04:37 +0530955 "%s: Invalid context, pAdapter [%p] magic [%08x]",
956 __func__, pAdapter, pGetFrameLogCtx->magic);
957 return;
958 }
959
960 /* context is valid so caller is still waiting */
961
962 /* paranoia: invalidate the magic */
963 pGetFrameLogCtx->magic = 0;
964
965 /* notify the caller */
966 complete(&pGetFrameLogCtx->completion);
967
968 /* serialization is complete */
969 spin_unlock(&hdd_context_lock);
970}
971
972/**---------------------------------------------------------------------------
973
974 \brief wlan_hdd_get_frame_logs() -
975
976 This function use to get Frames log.
977
978 \param - pAdapter Pointer to the adapter.
979 flag - Specify type of request. Clear and Send request are
980 supported.
981
982 \return - none
983
984 --------------------------------------------------------------------------*/
985VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
986{
987 struct getFrameLogCtx context;
988 hdd_context_t *pHddCtx;
989 eHalStatus hstatus;
990 long lrc;
991
992 if (NULL == pAdapter)
993 {
994 hddLog(VOS_TRACE_LEVEL_WARN,
995 "%s: Invalid context, pAdapter", __func__);
996 return VOS_STATUS_E_FAULT;
997 }
998
999 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1000 if (!pHddCtx->mgmt_frame_logging)
1001 {
1002 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
1003 return VOS_STATUS_E_AGAIN;
1004 }
1005
Siddharth Bhal4507c262015-04-29 20:20:42 +05301006 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
1007 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
1008 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +05301009 {
1010 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
1011 return VOS_STATUS_E_INVAL;
1012 }
1013
Siddharth Bhal4507c262015-04-29 20:20:42 +05301014 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
1015 (!pHddCtx->cfg_ini->enableBMUHWtracing))
1016 {
1017 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
1018 return VOS_STATUS_E_INVAL;
1019 }
1020
Siddharth Bhal64246172015-02-27 01:04:37 +05301021 init_completion(&context.completion);
1022 context.pAdapter = pAdapter;
1023 context.magic = GET_FRAME_LOG_MAGIC;
1024
1025 hstatus = sme_GetFramesLog(pHddCtx->hHal, hdd_GetFrameLogCB,
1026 flag, &context);
1027 if (eHAL_STATUS_SUCCESS != hstatus)
1028 {
1029 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
1030 }
1031 else
1032 {
1033 /* request was sent -- wait for the response */
1034 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1035 msecs_to_jiffies(WLAN_WAIT_TIME_FRAME_LOG));
1036 if (lrc <= 0)
1037 {
1038 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while fetching Frame logs",
1039 __func__, (0 == lrc) ? "timeout" : "interrupt");
1040 }
1041 }
1042
1043 spin_lock(&hdd_context_lock);
1044 context.magic = 0;
1045 spin_unlock(&hdd_context_lock);
1046
1047 return VOS_STATUS_SUCCESS;
1048}
1049
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301050VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1051{
1052 struct statsContext context;
1053 hdd_context_t *pHddCtx;
1054 hdd_station_ctx_t *pHddStaCtx;
1055 eHalStatus hstatus;
1056 long lrc;
1057 int valid;
1058
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301059 ENTER();
1060
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301061 if (NULL == pAdapter)
1062 {
1063 hddLog(VOS_TRACE_LEVEL_ERROR,
1064 "%s: Invalid context, pAdapter", __func__);
1065 return VOS_STATUS_E_FAULT;
1066 }
1067
1068 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1069
1070 valid = wlan_hdd_validate_context(pHddCtx);
1071 if (0 != valid)
1072 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301073 return VOS_STATUS_E_FAULT;
1074 }
1075
1076 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1077 if (NULL == pHddStaCtx)
1078 {
1079 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1080 return VOS_STATUS_E_FAULT;
1081 }
1082
1083 init_completion(&context.completion);
1084 context.pAdapter = pAdapter;
1085 context.magic = SNR_CONTEXT_MAGIC;
1086
1087 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1088 pHddStaCtx->conn_info.staId[ 0 ],
1089 pHddStaCtx->conn_info.bssId,
1090 &context);
1091 if (eHAL_STATUS_SUCCESS != hstatus)
1092 {
1093 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1094 __func__);
1095 /* we'll returned a cached value below */
1096 }
1097 else
1098 {
1099 /* request was sent -- wait for the response */
1100 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1101 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301102 if (lrc <= 0)
1103 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001104 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301105 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301106 /* we'll now returned a cached value below */
1107 }
1108 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001109
1110 /* either we never sent a request, we sent a request and received a
1111 response or we sent a request and timed out. if we never sent a
1112 request or if we sent a request and got a response, we want to
1113 clear the magic out of paranoia. if we timed out there is a
1114 race condition such that the callback function could be
1115 executing at the same time we are. of primary concern is if the
1116 callback function had already verified the "magic" but had not
1117 yet set the completion variable when a timeout occurred. we
1118 serialize these activities by invalidating the magic while
1119 holding a shared spinlock which will cause us to block if the
1120 callback is currently executing */
1121 spin_lock(&hdd_context_lock);
1122 context.magic = 0;
1123 spin_unlock(&hdd_context_lock);
1124
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301125 *snr = pAdapter->snr;
1126
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301127 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301128 return VOS_STATUS_SUCCESS;
1129}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001130#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001131
1132static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1133{
1134 struct statsContext *pStatsContext;
1135 hdd_adapter_t *pAdapter;
1136 if (ioctl_debug)
1137 {
1138 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1139 __func__, (int)rssi, (int)staId, pContext);
1140 }
1141
1142 if (NULL == pContext)
1143 {
1144 hddLog(VOS_TRACE_LEVEL_ERROR,
1145 "%s: Bad param, pContext [%p]",
1146 __func__, pContext);
1147 return;
1148 }
1149
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001150 pStatsContext = pContext;
1151 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001152
1153 /* there is a race condition that exists between this callback
1154 function and the caller since the caller could time out either
1155 before or while this code is executing. we use a spinlock to
1156 serialize these actions */
1157 spin_lock(&hdd_context_lock);
1158
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001159 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1160 {
1161 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001162 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001163 hddLog(VOS_TRACE_LEVEL_WARN,
1164 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1165 __func__, pAdapter, pStatsContext->magic);
1166 if (ioctl_debug)
1167 {
1168 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1169 __func__, pAdapter, pStatsContext->magic);
1170 }
1171 return;
1172 }
1173
Jeff Johnson72a40512013-12-19 10:14:15 -08001174 /* context is valid so caller is still waiting */
1175
1176 /* paranoia: invalidate the magic */
1177 pStatsContext->magic = 0;
1178
1179 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001180 pAdapter->rssi = rssi;
Sachin Ahujabfb16d52015-05-22 17:40:27 +05301181 if (pAdapter->rssi > 0)
1182 pAdapter->rssi = 0;
Jeff Johnson72a40512013-12-19 10:14:15 -08001183 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001184 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001185
1186 /* serialization is complete */
1187 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001188}
1189
1190
1191
1192VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1193{
1194 struct statsContext context;
1195 hdd_context_t *pHddCtx = NULL;
1196 hdd_station_ctx_t *pHddStaCtx = NULL;
1197 eHalStatus hstatus;
1198 long lrc;
1199
1200 if (NULL == pAdapter)
1201 {
1202 hddLog(VOS_TRACE_LEVEL_WARN,
1203 "%s: Invalid context, pAdapter", __func__);
1204 return VOS_STATUS_E_FAULT;
1205 }
1206 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1207 {
1208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1209 /* return a cached value */
1210 *rssi_value = pAdapter->rssi;
1211 return VOS_STATUS_SUCCESS;
1212 }
1213
1214 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1215 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1216
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301217 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001218 {
1219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1220 /* return a cached value */
1221 *rssi_value = 0;
1222 return VOS_STATUS_SUCCESS;
1223 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301224
1225 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1226 {
1227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1228 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1229 *rssi_value = pAdapter->rssi;
1230 return VOS_STATUS_SUCCESS;
1231 }
1232
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001233 init_completion(&context.completion);
1234 context.pAdapter = pAdapter;
1235 context.magic = RSSI_CONTEXT_MAGIC;
1236
1237 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1238 pHddStaCtx->conn_info.staId[ 0 ],
1239 pHddStaCtx->conn_info.bssId,
1240 &context, pHddCtx->pvosContext);
1241 if (eHAL_STATUS_SUCCESS != hstatus)
1242 {
1243 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1244 __func__);
1245 /* we'll returned a cached value below */
1246 }
1247 else
1248 {
1249 /* request was sent -- wait for the response */
1250 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1251 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001252 if (lrc <= 0)
1253 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001254 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001255 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001256 /* we'll now returned a cached value below */
1257 }
1258 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001259
1260 /* either we never sent a request, we sent a request and received a
1261 response or we sent a request and timed out. if we never sent a
1262 request or if we sent a request and got a response, we want to
1263 clear the magic out of paranoia. if we timed out there is a
1264 race condition such that the callback function could be
1265 executing at the same time we are. of primary concern is if the
1266 callback function had already verified the "magic" but had not
1267 yet set the completion variable when a timeout occurred. we
1268 serialize these activities by invalidating the magic while
1269 holding a shared spinlock which will cause us to block if the
1270 callback is currently executing */
1271 spin_lock(&hdd_context_lock);
1272 context.magic = 0;
1273 spin_unlock(&hdd_context_lock);
1274
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001275 *rssi_value = pAdapter->rssi;
1276
1277 return VOS_STATUS_SUCCESS;
1278}
1279#endif
1280
1281
Jeff Johnson295189b2012-06-20 16:38:30 -07001282void hdd_StatisticsCB( void *pStats, void *pContext )
1283{
1284 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1285 hdd_stats_t *pStatsCache = NULL;
1286 hdd_wext_state_t *pWextState;
1287 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1288
1289 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1290 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1291 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1292 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1293 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1294 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1295
1296 if (pAdapter!= NULL)
1297 pStatsCache = &pAdapter->hdd_stats;
1298
1299
1300 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1301 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1302 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1303 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1304 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1305 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1306
1307 if (pStatsCache!=NULL)
1308 {
1309 // and copy the stats into the cache we keep in the adapter instance structure
1310 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1311 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1312 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1313 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1314 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1315 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1316 }
1317
1318 if(pAdapter)
1319 {
1320 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1321 if(pWextState)
1322 {
1323 vos_status = vos_event_set(&pWextState->vosevent);
1324 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1325 {
1326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001327 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 return;
1329 }
1330 }
1331 }
1332}
1333
1334void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1335{
1336 v_CONTEXT_t pVosContext;
1337 hdd_context_t *pHddCtx;
1338 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1339#if 0
1340 hdd_wext_state_t *pWextState;
1341 v_U32_t roamId;
1342#endif
1343
1344 ENTER();
1345
1346 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1347
1348 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1349 if (NULL == pHddCtx)
1350 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001351 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 return;
1353 }
1354#if 0
1355 pWextState = pAdapter->pWextState;
1356#endif
1357
1358 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1359 {
1360 //TODO Verify is this is really used. If yes need to fix it.
1361 hdd_reconnect_all_adapters( pHddCtx );
1362#if 0
1363 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1364 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1365 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1366
1367 if(VOS_STATUS_SUCCESS == vosStatus)
1368 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1369 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1370
1371 sme_RoamConnect(halHandle,
1372 pAdapter->sessionId, &(pWextState->roamProfile),
1373 &roamId);
1374#endif
1375 }
1376
1377 EXIT();
1378
1379}
1380
1381void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1382{
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1384
1385 /* clear WPA/RSN/WSC IE information in the profile */
1386 pWextState->roamProfile.nWPAReqIELength = 0;
1387 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1388 pWextState->roamProfile.nRSNReqIELength = 0;
1389 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1390
Chet Lanctot186b5732013-03-18 10:26:30 -07001391#ifdef FEATURE_WLAN_WAPI
1392 pWextState->roamProfile.nWAPIReqIELength = 0;
1393 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1394#endif
1395
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001397 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001398 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301399 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1401 pWextState->roamProfile.nAddIEAssocLength = 0;
1402
1403 pWextState->roamProfile.EncryptionType.numEntries = 1;
1404 pWextState->roamProfile.EncryptionType.encryptionType[0]
1405 = eCSR_ENCRYPT_TYPE_NONE;
1406
1407 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1408 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1409 = eCSR_ENCRYPT_TYPE_NONE;
1410
1411 pWextState->roamProfile.AuthType.numEntries = 1;
1412 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1413
Chet Lanctot186b5732013-03-18 10:26:30 -07001414#ifdef WLAN_FEATURE_11W
1415 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1416 pWextState->roamProfile.MFPRequired = 0;
1417 pWextState->roamProfile.MFPCapable = 0;
1418#endif
1419
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 pWextState->authKeyMgmt = 0;
1421
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301422 vos_mem_zero(&pWextState->roamProfile.Keys,
1423 sizeof(pWextState->roamProfile.Keys));
1424
Jeff Johnson295189b2012-06-20 16:38:30 -07001425#ifdef FEATURE_WLAN_WAPI
1426 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1427 pAdapter->wapi_info.nWapiMode = 0;
1428#endif
1429
1430 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1431
1432}
1433
1434void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1435{
1436 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001437
Nirav Shahf6bd2672015-03-11 12:53:15 +05301438 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001439 {
1440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301441 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001442 }
1443 else
1444 {
1445 complete(&pAdapter->ula_complete);
1446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001447}
1448
1449VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1450{
1451 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001453 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001454
1455 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1456 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001457 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001458
1459 /*To avoid race condition between the set key and the last EAPOL
1460 packet, notify TL to finish upper layer authentication incase if the
1461 last EAPOL packet pending in the TL queue.*/
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001462 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001463
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001464 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 {
1466 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1467 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1468 __LINE__, vos_status );
1469 return vos_status;
1470
1471 }
1472
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001473 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301475 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001476 {
1477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301478 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001479 /* we'll still fall through and return success since the
1480 * connection may still get established but is just taking
1481 * too long for us to wait */
1482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001483 }
1484 return VOS_STATUS_SUCCESS;
1485}
1486
1487v_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)
1488{
1489
1490 int left = ie_len;
1491 v_U8_t *ptr = ie;
1492 v_U8_t elem_id,elem_len;
1493 v_U8_t eid = 0xDD;
1494
1495 if ( NULL == ie || 0 == ie_len )
1496 return NULL;
1497
1498 while(left >= 2)
1499 {
1500 elem_id = ptr[0];
1501 elem_len = ptr[1];
1502 left -= 2;
1503 if(elem_len > left)
1504 {
1505 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001506 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 eid,elem_len,left);
1508 return NULL;
1509 }
1510 if (elem_id == eid)
1511 {
1512 if(memcmp( &ptr[2], oui, oui_size)==0)
1513 return ptr;
1514 }
1515
1516 left -= elem_len;
1517 ptr += (elem_len + 2);
1518 }
1519 return NULL;
1520}
1521
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301522static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 union iwreq_data *wrqu, char *extra)
1524{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301525 hdd_adapter_t *pAdapter;
1526 hdd_context_t *pHddCtx;
1527 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301528
1529 ENTER();
1530
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301531 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1532 if (NULL == pAdapter)
1533 {
1534 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1535 "%s: pAdapter is NULL\n", __func__);
1536 return -EINVAL;
1537 }
1538 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1539 ret = wlan_hdd_validate_context(pHddCtx);
1540 if (0 != ret)
1541 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301542 return ret;
1543 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301544
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301546
1547 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301548 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001549}
1550
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301551static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1552 union iwreq_data *wrqu, char *extra)
1553{
1554 int ret;
1555
1556 vos_ssr_protect(__func__);
1557 ret = __iw_set_commit(dev, info, wrqu, extra);
1558 vos_ssr_unprotect(__func__);
1559
1560 return ret;
1561}
1562
1563static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 struct iw_request_info *info,
1565 char *wrqu, char *extra)
1566{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301567 hdd_adapter_t *pAdapter;
1568 hdd_context_t *pHddCtx;
1569 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301570
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301572 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1573 if (NULL == pAdapter)
1574 {
1575 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1576 "%s: pAdapter is NULL\n", __func__);
1577 return -EINVAL;
1578 }
1579 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1580 ret = wlan_hdd_validate_context(pHddCtx);
1581 if (0 != ret)
1582 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301583 return ret;
1584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1586 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301587 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001588}
1589
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301590static int iw_get_name(struct net_device *dev,
1591 struct iw_request_info *info,
1592 char *wrqu, char *extra)
1593{
1594 int ret;
1595
1596 vos_ssr_protect(__func__);
1597 ret = __iw_get_name(dev, info, wrqu, extra);
1598 vos_ssr_unprotect(__func__);
1599
1600 return ret;
1601}
1602
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301603static int __iw_set_mode(struct net_device *dev,
1604 struct iw_request_info *info,
1605 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001606{
1607 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301608 hdd_adapter_t *pAdapter;
1609 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 tCsrRoamProfile *pRoamProfile;
1611 eCsrRoamBssType LastBSSType;
1612 eMib_dot11DesiredBssType connectedBssType;
1613 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301615 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616
1617 ENTER();
1618
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301619 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 if (NULL == pAdapter)
1621 {
1622 hddLog(VOS_TRACE_LEVEL_WARN,
1623 "%s: Invalid context, pAdapter", __func__);
1624 return 0;
1625 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301626 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1627 status = wlan_hdd_validate_context(pHddCtx);
1628 if (0 != status)
1629 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301630 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 }
1632
1633 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1634 if (pWextState == NULL)
1635 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301636 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 return -EINVAL;
1638 }
1639
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 pRoamProfile = &pWextState->roamProfile;
1642 LastBSSType = pRoamProfile->BSSType;
1643
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301644 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001645
1646 switch (wrqu->mode)
1647 {
1648 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301649 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1651 // Set the phymode correctly for IBSS.
1652 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1653 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001654 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 break;
1657 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301658 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 break;
1662 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301663 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1665 break;
1666 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301667 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 return -EOPNOTSUPP;
1669 }
1670
1671 if ( LastBSSType != pRoamProfile->BSSType )
1672 {
1673 //the BSS mode changed
1674 // We need to issue disconnect if connected or in IBSS disconnect state
1675 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1676 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1677 {
1678 VOS_STATUS vosStatus;
1679 // need to issue a disconnect to CSR.
1680 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1681 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1682 pAdapter->sessionId,
1683 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1684 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301685 {
1686 long ret;
1687 ret = wait_for_completion_interruptible_timeout(
1688 &pAdapter->disconnect_comp_var,
1689 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1690 if (ret <= 0)
1691 hddLog(VOS_TRACE_LEVEL_ERROR,
1692 FL("failed wait on disconnect_comp_var %ld"), ret);
1693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 }
1695 }
1696
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 EXIT();
1698 return 0;
1699}
1700
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301701static int iw_set_mode(struct net_device *dev,
1702 struct iw_request_info *info,
1703 union iwreq_data *wrqu, char *extra)
1704{
1705 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001706
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301707 vos_ssr_protect(__func__);
1708 ret = __iw_set_mode(dev, info, wrqu, extra);
1709 vos_ssr_unprotect(__func__);
1710
1711 return ret;
1712}
1713
1714static int __iw_get_mode(struct net_device *dev,
1715 struct iw_request_info *info,
1716 union iwreq_data *wrqu,
1717 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001718{
1719
1720 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301721 hdd_adapter_t *pAdapter;
1722 hdd_context_t *pHddCtx;
1723 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001724
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301725 ENTER();
1726
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301727 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 if (NULL == pAdapter)
1729 {
1730 hddLog(VOS_TRACE_LEVEL_WARN,
1731 "%s: Invalid context, pAdapter", __func__);
1732 return 0;
1733 }
1734
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301735 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1736 ret = wlan_hdd_validate_context(pHddCtx);
1737 if (0 != ret)
1738 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301739 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1742 if (pWextState == NULL)
1743 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301744 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 return -EINVAL;
1746 }
1747
1748 switch (pWextState->roamProfile.BSSType)
1749 {
1750 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001751 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301752 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 break;
1754 case eCSR_BSS_TYPE_IBSS:
1755 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001756 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301757 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 break;
1759 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001760 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301761 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001762 break;
1763 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001764 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001765 break;
1766 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301767
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301768 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 return 0;
1770}
1771
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301772static int iw_get_mode(struct net_device *dev,
1773 struct iw_request_info *info,
1774 union iwreq_data *wrqu,
1775 char *extra)
1776{
1777 int ret;
1778
1779 vos_ssr_protect(__func__);
1780 ret = __iw_get_mode(dev, info, wrqu, extra);
1781 vos_ssr_unprotect(__func__);
1782
1783 return ret;
1784}
1785
1786static int __iw_set_freq(struct net_device *dev,
1787 struct iw_request_info *info,
1788 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001789{
1790 v_U32_t numChans = 0;
1791 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1792 v_U32_t indx = 0;
1793 v_U32_t status = 0;
1794
1795 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301796 hdd_adapter_t *pAdapter;
1797 hdd_context_t *pHddCtx;
1798 tHalHandle hHal;
1799 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301801
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 ENTER();
1803
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301804 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1805 if (NULL == pAdapter)
1806 {
1807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1808 "%s:Invalid Adapter",__func__);
1809 return -EINVAL;
1810 }
1811
1812 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1813 status = wlan_hdd_validate_context(pHddCtx);
1814 if (0 != status)
1815 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 return status;
1817 }
1818
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301819 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1820 if (NULL == hHal)
1821 {
1822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1823 "%s: Hal Context is NULL",__func__);
1824 return -EINVAL;
1825 }
1826
1827 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1828 if (NULL == pHddStaCtx)
1829 {
1830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1831 "%s:STA context is NULL",__func__);
1832 return -EINVAL;
1833 }
1834
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301836 if (NULL == pWextState)
1837 {
1838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1839 "%s: pWextState is NULL",__func__);
1840 return -EINVAL;
1841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001842
1843 pRoamProfile = &pWextState->roamProfile;
1844
Arif Hussain6d2a3322013-11-17 19:50:10 -08001845 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001846
1847 /* Link is up then return cant set channel*/
1848 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1849 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1850 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001851 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 return -EOPNOTSUPP;
1853 }
1854
1855 /* Settings by Frequency as input */
1856 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1857 (wrqu->freq.m <= (tANI_U32)5.825e8))
1858 {
1859 tANI_U32 freq = wrqu->freq.m / 100000;
1860
1861 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1862 indx++;
1863 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1864 {
1865 return -EINVAL;
1866 }
1867 wrqu->freq.e = 0;
1868 wrqu->freq.m = freq_chan_map[indx].chan;
1869
1870 }
1871
1872 if (wrqu->freq.e == 0)
1873 {
1874 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1875 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1876 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001877 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001878 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1880 return -EINVAL;
1881 }
1882
1883 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1884
1885 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1886 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1888 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 return -EIO;
1890 }
1891
1892 for (indx = 0; indx < numChans; indx++) {
1893 if (wrqu->freq.m == validChan[indx]){
1894 break;
1895 }
1896 }
1897 }
1898 else{
1899
1900 return -EINVAL;
1901 }
1902
1903 if(indx >= numChans)
1904 {
1905 return -EINVAL;
1906 }
1907
1908 /* Set the Operational Channel */
1909 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1910 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1911 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1912
Arif Hussain6d2a3322013-11-17 19:50:10 -08001913 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001914
1915 EXIT();
1916
1917 return status;
1918}
1919
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301920static int iw_set_freq(struct net_device *dev,
1921 struct iw_request_info *info,
1922 union iwreq_data *wrqu, char *extra)
1923{
1924 int ret;
1925
1926 vos_ssr_protect(__func__);
1927 ret = __iw_set_freq(dev, info, wrqu, extra);
1928 vos_ssr_unprotect(__func__);
1929
1930 return ret;
1931}
1932
1933static int __iw_get_freq(struct net_device *dev,
1934 struct iw_request_info *info,
1935 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001936{
Jeff Johnsone7245742012-09-05 17:12:55 -07001937 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301938 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 tHalHandle hHal;
1940 hdd_wext_state_t *pWextState;
1941 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301942 hdd_station_ctx_t *pHddStaCtx;
1943 hdd_context_t *pHddCtx;
1944 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001945
1946 ENTER();
1947
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301948 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1949 if (NULL == pAdapter)
1950 {
1951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1952 "%s: Adapter is NULL", __func__);
1953 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301955 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1956 ret = wlan_hdd_validate_context(pHddCtx);
1957 if (0 != ret)
1958 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301959 return ret;
1960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301962 if (NULL == hHal)
1963 {
1964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1965 "%s: Hal Context is NULL",__func__);
1966 return -EINVAL;
1967 }
1968 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1969 if (NULL == pHddStaCtx)
1970 {
1971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1972 "%s: HddStaCtx is NULL", __func__);
1973 return -EINVAL;
1974 }
1975 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1976 if (NULL == pWextState)
1977 {
1978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1979 "%s: pWextState is NULL",__func__);
1980 return -EINVAL;
1981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001982 pRoamProfile = &pWextState->roamProfile;
1983
1984 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1985 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001986 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 {
c_hpothub8245442013-11-20 23:41:09 +05301988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1989 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001990 return -EIO;
1991 }
1992 else
1993 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001994 status = hdd_wlan_get_freq(channel, &freq);
1995 if( TRUE == status )
1996 {
1997 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1998 * iwlist & iwconfig command shows frequency into proper
1999 * format (2.412 GHz instead of 246.2 MHz)*/
2000 fwrq->m = freq;
2001 fwrq->e = MHZ;
2002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 }
2004 }
2005 else
2006 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07002007 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2008 * iwlist & iwconfig command shows frequency into proper
2009 * format (2.412 GHz instead of 246.2 MHz)*/
2010 fwrq->m = 0;
2011 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302013
2014 EXIT();
2015 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002016}
2017
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302018static int iw_get_freq(struct net_device *dev,
2019 struct iw_request_info *info,
2020 struct iw_freq *fwrq, char *extra)
2021{
2022 int ret;
2023
2024 vos_ssr_protect(__func__);
2025 ret = __iw_get_freq(dev, info, fwrq, extra);
2026 vos_ssr_unprotect(__func__);
2027
2028 return ret;
2029}
2030
2031static int __iw_get_tx_power(struct net_device *dev,
2032 struct iw_request_info *info,
2033 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002034{
2035
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302036 hdd_adapter_t *pAdapter;
2037 hdd_context_t *pHddCtx;
2038 hdd_station_ctx_t *pHddStaCtx;
2039 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002040
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302041 ENTER();
2042
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302043 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2044 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002045 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2047 "%s: Adapter is NULL",__func__);
2048 return -EINVAL;
2049 }
2050 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2051 ret = wlan_hdd_validate_context(pHddCtx);
2052 if (0 != ret)
2053 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302054 return ret;
2055 }
2056
2057 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2058 if (NULL == pHddStaCtx)
2059 {
2060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2061 "%s: STA Context is NULL",__func__);
2062 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 }
2064
2065 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2066 {
2067 wrqu->txpower.value = 0;
2068 return 0;
2069 }
2070 wlan_hdd_get_classAstats(pAdapter);
2071 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2072
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302073 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 return 0;
2075}
2076
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302077static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 struct iw_request_info *info,
2079 union iwreq_data *wrqu, char *extra)
2080{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302081 int ret;
2082
2083 vos_ssr_protect(__func__);
2084 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2085 vos_ssr_unprotect(__func__);
2086
2087 return ret;
2088}
2089
2090static int __iw_set_tx_power(struct net_device *dev,
2091 struct iw_request_info *info,
2092 union iwreq_data *wrqu, char *extra)
2093{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302094 hdd_adapter_t *pAdapter;
2095 tHalHandle hHal;
2096 hdd_context_t *pHddCtx;
2097 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002098
2099 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302100 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2101 if (NULL == pAdapter)
2102 {
2103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2104 "%s: Adapter is NULL",__func__);
2105 return -EINVAL;
2106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002107
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302108 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2109 ret = wlan_hdd_validate_context(pHddCtx);
2110 if (0 != ret)
2111 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302112 return ret;
2113 }
2114
2115 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2116 if (NULL == hHal)
2117 {
2118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2119 "%s: Hal Context is NULL",__func__);
2120 return -EINVAL;
2121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2123 {
c_hpothub8245442013-11-20 23:41:09 +05302124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2125 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 return -EIO;
2127 }
2128
2129 EXIT();
2130
2131 return 0;
2132}
2133
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302134static int iw_set_tx_power(struct net_device *dev,
2135 struct iw_request_info *info,
2136 union iwreq_data *wrqu, char *extra)
2137{
2138 int ret;
2139
2140 vos_ssr_protect(__func__);
2141 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2142 vos_ssr_unprotect(__func__);
2143
2144 return ret;
2145}
2146
2147static int __iw_get_bitrate(struct net_device *dev,
2148 struct iw_request_info *info,
2149 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002150{
2151 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2152 eHalStatus status = eHAL_STATUS_SUCCESS;
2153 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302154 hdd_adapter_t *pAdapter;
2155 hdd_context_t *pHddCtx;
2156 hdd_station_ctx_t *pHddStaCtx;
2157 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002158
2159 ENTER();
2160
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302161 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2162 if (NULL == pAdapter)
2163 {
2164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2165 "%s: Adapter is NULL",__func__);
2166 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 }
2168
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302169 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2170 ret = wlan_hdd_validate_context(pHddCtx);
2171 if (0 != ret)
2172 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302173 return ret;
2174 }
2175
2176 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2177 if (NULL == pHddStaCtx)
2178 {
2179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2180 "%s: STA Context is NULL",__func__);
2181 return -EINVAL;
2182 }
2183
2184 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 wrqu->bitrate.value = 0;
2186 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302187 else
2188 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2190 SME_SUMMARY_STATS |
2191 SME_GLOBAL_CLASSA_STATS |
2192 SME_GLOBAL_CLASSB_STATS |
2193 SME_GLOBAL_CLASSC_STATS |
2194 SME_GLOBAL_CLASSD_STATS |
2195 SME_PER_STA_STATS,
2196 hdd_StatisticsCB, 0, FALSE,
2197 pHddStaCtx->conn_info.staId[0], pAdapter );
2198
2199 if(eHAL_STATUS_SUCCESS != status)
2200 {
2201 hddLog(VOS_TRACE_LEVEL_ERROR,
2202 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002203 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 return status;
2205 }
2206
2207 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302208 if (NULL == pWextState)
2209 {
2210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2211 "%s: pWextState is NULL",__func__);
2212 return -EINVAL;
2213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002214
2215 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2216
2217 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2218 {
2219 hddLog(VOS_TRACE_LEVEL_ERROR,
2220 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002221 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 return VOS_STATUS_E_FAILURE;
2223 }
2224
2225 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2226 }
2227
2228 EXIT();
2229
2230 return vos_status;
2231}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302232
2233static int iw_get_bitrate(struct net_device *dev,
2234 struct iw_request_info *info,
2235 union iwreq_data *wrqu, char *extra)
2236{
2237 int ret;
2238
2239 vos_ssr_protect(__func__);
2240 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2241 vos_ssr_unprotect(__func__);
2242
2243 return ret;
2244}
2245
2246
Jeff Johnson295189b2012-06-20 16:38:30 -07002247/* ccm call back function */
2248
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302249static int __iw_set_bitrate(struct net_device *dev,
2250 struct iw_request_info *info,
2251 union iwreq_data *wrqu,
2252 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002253{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302254 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302256 hdd_station_ctx_t *pHddStaCtx;
2257 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2259 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2260 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2261 v_U32_t i, rate;
2262 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302263 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002264
2265 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302266 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2267 if (NULL == pAdapter)
2268 {
2269 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2270 "%s: Adapter is NULL",__func__);
2271 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 }
2273
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302274 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2275 ret = wlan_hdd_validate_context(pHddCtx);
2276 if (0 != ret)
2277 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302278 return ret;
2279 }
2280
2281 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2282 if (NULL == pHddStaCtx)
2283 {
2284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2285 "%s: STA Context is NULL",__func__);
2286 return -EINVAL;
2287 }
2288
2289
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302291 if (NULL == pWextState)
2292 {
2293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2294 "%s: pWextState is NULL",__func__);
2295 return -EINVAL;
2296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002297
2298 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2299 {
2300 return -ENXIO ;
2301 }
2302
2303 rate = wrqu->bitrate.value;
2304
2305 if (rate == -1)
2306 {
2307 rate = WNI_CFG_FIXED_RATE_AUTO;
2308 valid_rate = TRUE;
2309 }
2310 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2311 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2312 {
2313 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2314 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2315 {
2316 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2317 WNI_CFG_SUPPORTED_RATES_11A,
2318 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2319 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2320 WNI_CFG_SUPPORTED_RATES_11B,
2321 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2322 {
2323 for (i = 0; i < (b_len + a_len); ++i)
2324 {
2325 /* supported rates returned is double the actual rate so we divide it by 2 */
2326 if ((supp_rates[i]&0x7F)/2 == rate)
2327 {
2328 valid_rate = TRUE;
2329 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2330 break;
2331 }
2332 }
2333 }
2334 }
2335 }
2336 if (valid_rate != TRUE)
2337 {
2338 return -EINVAL;
2339 }
2340 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2341 WNI_CFG_FIXED_RATE, rate,
2342 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2343 {
c_hpothub8245442013-11-20 23:41:09 +05302344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2345 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 return -EIO;
2347 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302348
2349 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 return 0;
2351}
2352
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302353static int iw_set_bitrate(struct net_device *dev,
2354 struct iw_request_info *info,
2355 union iwreq_data *wrqu,
2356 char *extra)
2357{
2358 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002359
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302360 vos_ssr_protect(__func__);
2361 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2362 vos_ssr_unprotect(__func__);
2363
2364 return ret;
2365}
2366
2367static int __iw_set_genie(struct net_device *dev,
2368 struct iw_request_info *info,
2369 union iwreq_data *wrqu,
2370 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002371{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302372 hdd_adapter_t *pAdapter;
2373 hdd_context_t *pHddCtx;
2374 hdd_wext_state_t *pWextState;
2375 u_int8_t *genie = NULL;
2376 u_int8_t *base_genie = NULL;
2377 v_U16_t remLen;
2378 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002379
2380 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002381
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302382 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2383 if (NULL == pAdapter)
2384 {
2385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2386 "%s: Adapter is NULL",__func__);
2387 return -EINVAL;
2388 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002389
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302390 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2391 ret = wlan_hdd_validate_context(pHddCtx);
2392 if (0 != ret)
2393 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302394 return ret;
2395 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002396
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302397 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2398 if (NULL == pWextState)
2399 {
2400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2401 "%s: pWextState is NULL",__func__);
2402 return -EINVAL;
2403 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002404
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302405 if (!wrqu->data.length) {
2406 hdd_clearRoamProfileIe(pAdapter);
2407 EXIT();
2408 return 0;
2409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002410
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302411 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2412 wrqu->data.length);
2413 if (NULL == base_genie)
2414 {
2415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2416 "mem_alloc_copy_from_user_helper fail");
2417 return -ENOMEM;
2418 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002419
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302420 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002421
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302422 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002423
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302424 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2425
2426 /* clear any previous genIE before this call */
2427 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2428
2429 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 {
2431 v_U16_t eLen = 0;
2432 v_U8_t elementId;
2433 elementId = *genie++;
2434 eLen = *genie++;
2435 remLen -= 2;
2436
Arif Hussain6d2a3322013-11-17 19:50:10 -08002437 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 __func__, elementId, eLen);
2439
2440 switch ( elementId )
2441 {
2442 case IE_EID_VENDOR:
2443 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002444 {
2445 kfree(base_genie);
2446 return -EINVAL;
2447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002448
2449 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2450 {
2451 v_U16_t curGenIELen = pWextState->genIE.length;
2452 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2453 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2454
2455 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2456 {
2457 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002458 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002460 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 return -ENOMEM;
2462 }
2463 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2464 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2465 pWextState->genIE.length += eLen + 2;
2466 }
2467 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2468 {
2469 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2470 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2471 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2472 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2473 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2474 }
2475 else /* any vendorId except WPA IE should be accumulated to genIE */
2476 {
2477 v_U16_t curGenIELen = pWextState->genIE.length;
2478 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2479 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2480
2481 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2482 {
2483 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002484 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002486 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 return -ENOMEM;
2488 }
2489 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2490 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2491 pWextState->genIE.length += eLen + 2;
2492 }
2493 break;
2494 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002495 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2497 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2498 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2499 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2500 break;
2501
2502 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002503 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002504 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 return 0;
2506 }
2507 genie += eLen;
2508 remLen -= eLen;
2509 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302510
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002512 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 return 0;
2514}
2515
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302516static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 struct iw_request_info *info,
2518 union iwreq_data *wrqu,
2519 char *extra)
2520{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302521 int ret;
2522
2523 vos_ssr_protect(__func__);
2524 ret = __iw_set_genie(dev, info, wrqu, extra);
2525 vos_ssr_unprotect(__func__);
2526
2527 return ret;
2528}
2529
2530static int __iw_get_genie(struct net_device *dev,
2531 struct iw_request_info *info,
2532 union iwreq_data *wrqu,
2533 char *extra)
2534{
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302536 hdd_context_t *pHddCtx;
2537 hdd_adapter_t *pAdapter;
2538 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 eHalStatus status;
2540 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2541 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2542
2543 ENTER();
2544
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302545 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2546 if (NULL == pAdapter)
2547 {
2548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2549 "%s: Adapter is NULL",__func__);
2550 return -EINVAL;
2551 }
2552 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2553 status = wlan_hdd_validate_context(pHddCtx);
2554 if (0 != status)
2555 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302556 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 }
2558
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302560 if (NULL == pWextState)
2561 {
2562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2563 "%s: pWextState is NULL",__func__);
2564 return -EINVAL;
2565 }
2566
2567 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2568 if (NULL == pHddStaCtx)
2569 {
2570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2571 "%s: STA Context is NULL",__func__);
2572 return -EINVAL;
2573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002574
2575 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2576 {
2577 return -ENXIO;
2578 }
2579
2580 // Return something ONLY if we are associated with an RSN or WPA network
2581 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2582 pWextState->roamProfile.negotiatedAuthType))
2583 {
2584 return -ENXIO;
2585 }
2586
2587 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2588 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2589 pAdapter->sessionId,
2590 &length,
2591 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002592 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2593 if (wrqu->data.length < length)
2594 {
2595 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2596 return -EFAULT;
2597 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002598 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002599 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002600
Arif Hussain6d2a3322013-11-17 19:50:10 -08002601 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002602
2603 EXIT();
2604
2605 return 0;
2606}
2607
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302608static int iw_get_genie(struct net_device *dev,
2609 struct iw_request_info *info,
2610 union iwreq_data *wrqu,
2611 char *extra)
2612{
2613 int ret;
2614
2615 vos_ssr_protect(__func__);
2616 ret = __iw_get_genie(dev, info, wrqu, extra);
2617 vos_ssr_unprotect(__func__);
2618
2619 return ret;
2620}
2621
2622
2623static int __iw_get_encode(struct net_device *dev,
2624 struct iw_request_info *info,
2625 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002626{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302627 hdd_adapter_t *pAdapter;
2628 hdd_context_t *pHddCtx;
2629 hdd_wext_state_t *pWextState;
2630 tCsrRoamProfile *pRoamProfile;
2631 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002633
2634 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302635 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2636 if (NULL == pAdapter)
2637 {
2638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2639 "%s: Adapter is NULL",__func__);
2640 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 }
2642
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302643 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2644 ret = wlan_hdd_validate_context(pHddCtx);
2645 if (0 != ret)
2646 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302647 return ret;
2648 }
2649 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2650 if (NULL == pWextState)
2651 {
2652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2653 "%s: pWextState is NULL",__func__);
2654 return -EINVAL;
2655 }
2656
2657 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 keyId = pRoamProfile->Keys.defaultIndex;
2659
2660 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2661 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002662 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 return -EINVAL;
2664 }
2665
2666 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2667 {
2668 dwrq->flags |= IW_ENCODE_ENABLED;
2669 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2670 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2671
2672 dwrq->flags |= (keyId + 1);
2673
2674 }
2675 else
2676 {
2677 dwrq->flags |= IW_ENCODE_DISABLED;
2678 }
2679
2680 for(i=0; i < MAX_WEP_KEYS; i++)
2681 {
2682 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2683 {
2684 continue;
2685 }
2686 else
2687 {
2688 break;
2689 }
2690 }
2691
2692 if(MAX_WEP_KEYS == i)
2693 {
2694 dwrq->flags |= IW_ENCODE_NOKEY;
2695 }
2696
2697 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2698
2699 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2700 {
2701 dwrq->flags |= IW_ENCODE_OPEN;
2702 }
2703 else
2704 {
2705 dwrq->flags |= IW_ENCODE_RESTRICTED;
2706 }
2707 EXIT();
2708 return 0;
2709}
2710
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302711static int iw_get_encode(struct net_device *dev,
2712 struct iw_request_info *info,
2713 struct iw_point *dwrq, char *extra)
2714{
2715 int ret;
2716
2717 vos_ssr_protect(__func__);
2718 ret = __iw_get_encode(dev, info, dwrq, extra);
2719 vos_ssr_unprotect(__func__);
2720
2721 return ret;
2722}
2723
Jeff Johnson295189b2012-06-20 16:38:30 -07002724#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2725#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2726
2727
2728/*
2729 * This function sends a single 'key' to LIM at all time.
2730 */
2731
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302732static int __iw_get_rts_threshold(struct net_device *dev,
2733 struct iw_request_info *info,
2734 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002735{
2736 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2737 v_U32_t status = 0;
2738
2739 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2740
2741 return status;
2742}
2743
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302744static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 struct iw_request_info *info,
2746 union iwreq_data *wrqu, char *extra)
2747{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302748 int ret;
2749
2750 vos_ssr_protect(__func__);
2751 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2752 vos_ssr_unprotect(__func__);
2753
2754 return ret;
2755}
2756
2757static int __iw_set_rts_threshold(struct net_device *dev,
2758 struct iw_request_info *info,
2759 union iwreq_data *wrqu, char *extra)
2760{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302761 hdd_adapter_t *pAdapter;
2762 hdd_context_t *pHddCtx;
2763 tHalHandle hHal;
2764 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002765
2766 ENTER();
2767
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302768 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2769 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002770 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2772 "%s: Adapter is NULL",__func__);
2773 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002774 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302775
2776 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2777 ret = wlan_hdd_validate_context(pHddCtx);
2778 if (0 != ret)
2779 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302780 return ret;
2781 }
2782
2783 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2784 if (NULL == hHal)
2785 {
2786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2787 "%s: Hal Context is NULL",__func__);
2788 return -EINVAL;
2789 }
2790
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2792 {
2793 return -EINVAL;
2794 }
2795
2796 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2797 {
c_hpothub8245442013-11-20 23:41:09 +05302798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2799 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 return -EIO;
2801 }
2802
2803 EXIT();
2804
2805 return 0;
2806}
2807
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302808static int iw_set_rts_threshold(struct net_device *dev,
2809 struct iw_request_info *info,
2810 union iwreq_data *wrqu, char *extra)
2811{
2812 int ret;
2813
2814 vos_ssr_protect(__func__);
2815 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2816 vos_ssr_unprotect(__func__);
2817
2818 return ret;
2819}
2820
2821static int __iw_get_frag_threshold(struct net_device *dev,
2822 struct iw_request_info *info,
2823 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002824{
2825 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2826 v_U32_t status = 0;
2827
2828 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2829
2830 return status;
2831}
2832
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302833static int iw_get_frag_threshold(struct net_device *dev,
2834 struct iw_request_info *info,
2835 union iwreq_data *wrqu, char *extra)
2836{
2837 int ret;
2838
2839 vos_ssr_protect(__func__);
2840 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2841 vos_ssr_unprotect(__func__);
2842
2843 return ret;
2844}
2845
2846static int __iw_set_frag_threshold(struct net_device *dev,
2847 struct iw_request_info *info,
2848 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002849{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302850 hdd_adapter_t *pAdapter;
2851 hdd_context_t *pHddCtx;
2852 tHalHandle hHal;
2853 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002854
2855 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302856 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2857 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002858 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2860 "%s: Adapter is NULL",__func__);
2861 return -EINVAL;
2862 }
2863
2864 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2865 ret = wlan_hdd_validate_context(pHddCtx);
2866 if (0 != ret)
2867 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302868 return ret;
2869 }
2870
2871 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2872 if (NULL == hHal)
2873 {
2874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2875 "%s: Hal Context is NULL",__func__);
2876 return -EINVAL;
2877 }
2878
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2880 {
2881 return -EINVAL;
2882 }
2883
2884 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2885 {
c_hpothub8245442013-11-20 23:41:09 +05302886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2887 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 return -EIO;
2889 }
2890
2891 EXIT();
2892
2893 return 0;
2894}
2895
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302896static int iw_set_frag_threshold(struct net_device *dev,
2897 struct iw_request_info *info,
2898 union iwreq_data *wrqu, char *extra)
2899{
2900 int ret;
2901
2902 vos_ssr_protect(__func__);
2903 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2904 vos_ssr_unprotect(__func__);
2905
2906 return ret;
2907}
2908
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302909static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 struct iw_request_info *info,
2911 union iwreq_data *wrqu, char *extra)
2912{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302913 hdd_adapter_t *pAdapter;
2914 hdd_context_t *pHddCtx;
2915 int ret = 0;
2916
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302918 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2919 if (NULL == pAdapter)
2920 {
2921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2922 "%s: Adapter is NULL",__func__);
2923 return -EINVAL;
2924 }
2925 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2926 ret = wlan_hdd_validate_context(pHddCtx);
2927 if (0 != ret)
2928 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302929 return ret;
2930 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302931
2932 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002933 return -EOPNOTSUPP;
2934}
2935
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302936static int iw_get_power_mode(struct net_device *dev,
2937 struct iw_request_info *info,
2938 union iwreq_data *wrqu, char *extra)
2939{
2940 int ret;
2941
2942 vos_ssr_protect(__func__);
2943 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2944 vos_ssr_unprotect(__func__);
2945
2946 return ret;
2947}
2948static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 struct iw_request_info *info,
2950 union iwreq_data *wrqu, char *extra)
2951{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302952 hdd_adapter_t *pAdapter;
2953 hdd_context_t *pHddCtx;
2954 int ret = 0;
2955
Jeff Johnson295189b2012-06-20 16:38:30 -07002956 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302957 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2958 if (NULL == pAdapter)
2959 {
2960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2961 "%s: Adapter is NULL",__func__);
2962 return -EINVAL;
2963 }
2964 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2965 ret = wlan_hdd_validate_context(pHddCtx);
2966 if (0 != ret)
2967 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302968 return ret;
2969 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302970
2971 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 return -EOPNOTSUPP;
2973}
2974
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302975static int iw_set_power_mode(struct net_device *dev,
2976 struct iw_request_info *info,
2977 union iwreq_data *wrqu, char *extra)
2978{
2979 int ret;
2980
2981 vos_ssr_protect(__func__);
2982 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2983 vos_ssr_unprotect(__func__);
2984
2985 return ret;
2986}
2987
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302988static int __iw_get_range(struct net_device *dev,
2989 struct iw_request_info *info,
2990 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002991{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302992 hdd_adapter_t *pAdapter;
2993 tHalHandle hHal;
2994 hdd_context_t *pHddCtx;
2995 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 struct iw_range *range = (struct iw_range *) extra;
2997
2998 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2999
3000 v_U32_t num_channels = sizeof(channels);
3001 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3002 v_U32_t a_len;
3003 v_U32_t b_len;
3004 v_U32_t active_phy_mode = 0;
3005 v_U8_t index = 0, i;
3006
3007 ENTER();
3008
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303009 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3010 if (NULL == pAdapter)
3011 {
3012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3013 "%s: pAdapter is NULL", __func__);
3014 return -EINVAL;
3015 }
3016 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3017 ret = wlan_hdd_validate_context(pHddCtx);
3018 if (0 != ret)
3019 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303020 return ret;
3021 }
3022 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3023 if (NULL == hHal)
3024 {
3025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3026 "%s: pAdapter is NULL", __func__);
3027 return -EINVAL;
3028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 wrqu->data.length = sizeof(struct iw_range);
3030 memset(range, 0, sizeof(struct iw_range));
3031
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 /*Get the phy mode*/
3033 if (ccmCfgGetInt(hHal,
3034 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3035 {
3036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003037 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003038
3039 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3040 {
3041 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003042 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 if (ccmCfgGetStr(hHal,
3044 WNI_CFG_SUPPORTED_RATES_11A,
3045 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3046 {
3047 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3048 {
3049 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3050 }
3051 for (i = 0; i < a_len; i++)
3052 {
3053 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3054 }
3055 range->num_bitrates = a_len;
3056 }
3057 else
3058 {
3059 return -EIO;
3060 }
3061 }
3062 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3063 {
3064 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003065 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 if (ccmCfgGetStr(hHal,
3067 WNI_CFG_SUPPORTED_RATES_11B,
3068 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3069 {
3070 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3071 {
3072 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3073 }
3074 for (i = 0; i < b_len; i++)
3075 {
3076 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3077 }
3078 range->num_bitrates = b_len;
3079 }
3080 else
3081 {
3082 return -EIO;
3083 }
3084 }
3085 }
3086
3087 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3088 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3089 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3090
3091 range->encoding_size[0] = 5;
3092 range->encoding_size[1] = 13;
3093 range->num_encoding_sizes = 2;
3094 range->max_encoding_tokens = MAX_WEP_KEYS;
3095
3096 // we support through Wireless Extensions 22
3097 range->we_version_compiled = WIRELESS_EXT;
3098 range->we_version_source = 22;
3099
3100 /*Supported Channels and Frequencies*/
3101 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3102 {
c_hpothub8245442013-11-20 23:41:09 +05303103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3104 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 return -EIO;
3106 }
3107 if (num_channels > IW_MAX_FREQUENCIES)
3108 {
3109 num_channels = IW_MAX_FREQUENCIES;
3110 }
3111
3112 range->num_channels = num_channels;
3113 range->num_frequency = num_channels;
3114
3115 for (index=0; index < num_channels; index++)
3116 {
3117 v_U32_t frq_indx = 0;
3118
3119 range->freq[index].i = channels[index];
3120 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3121 {
3122 if(channels[index] == freq_chan_map[frq_indx].chan)
3123 {
3124 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3125 range->freq[index].e = 1;
3126 break;
3127 }
3128 frq_indx++;
3129 }
3130 }
3131
3132 /* Event capability (kernel + driver) */
3133 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3134 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3135 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3136 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3137
3138 /*Encryption capability*/
3139 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3140 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3141
3142 /* Txpower capability */
3143 range->txpower_capa = IW_TXPOW_MWATT;
3144
3145 /*Scanning capability*/
3146 #if WIRELESS_EXT >= 22
3147 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3148 #endif
3149
3150 EXIT();
3151 return 0;
3152}
3153
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303154static int iw_get_range(struct net_device *dev,
3155 struct iw_request_info *info,
3156 union iwreq_data *wrqu, char *extra)
3157{
3158 int ret;
3159
3160 vos_ssr_protect(__func__);
3161 ret = __iw_get_range(dev, info, wrqu, extra);
3162 vos_ssr_unprotect(__func__);
3163
3164 return ret;
3165}
3166
Jeff Johnson295189b2012-06-20 16:38:30 -07003167/* Callback function registered with PMC to know status of PMC request */
3168static void iw_power_callback_fn (void *pContext, eHalStatus status)
3169{
3170 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003171
3172 if (NULL == pContext)
3173 {
3174 hddLog(VOS_TRACE_LEVEL_ERROR,
3175 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003176 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 return;
3178 }
3179
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003181
Jeff Johnson72a40512013-12-19 10:14:15 -08003182 /* there is a race condition that exists between this callback
3183 function and the caller since the caller could time out either
3184 before or while this code is executing. we use a spinlock to
3185 serialize these actions */
3186 spin_lock(&hdd_context_lock);
3187
3188 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 {
3190 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003191 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003193 "%s: Invalid context, magic [%08x]",
3194 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003195
3196 if (ioctl_debug)
3197 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003198 pr_info("%s: Invalid context, magic [%08x]\n",
3199 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 }
3201 return;
3202 }
3203
Jeff Johnson72a40512013-12-19 10:14:15 -08003204 /* context is valid so caller is still waiting */
3205
3206 /* paranoia: invalidate the magic */
3207 pStatsContext->magic = 0;
3208
3209 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003211
3212 /* serialization is complete */
3213 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003214}
3215
3216/* Callback function for tx per hit */
3217void hdd_tx_per_hit_cb (void *pCallbackContext)
3218{
3219 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3220 unsigned char tx_fail[16];
3221 union iwreq_data wrqu;
3222
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303223 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003225 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 return;
3227 }
3228 memset(&wrqu, 0, sizeof(wrqu));
3229 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3230 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3231}
3232
3233void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3234{
3235 struct statsContext *pStatsContext;
3236 tCsrGlobalClassAStatsInfo *pClassAStats;
3237 hdd_adapter_t *pAdapter;
3238
3239 if (ioctl_debug)
3240 {
3241 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003242 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 }
3244
3245 if ((NULL == pStats) || (NULL == pContext))
3246 {
3247 hddLog(VOS_TRACE_LEVEL_ERROR,
3248 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003249 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 return;
3251 }
3252
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 pClassAStats = pStats;
3254 pStatsContext = pContext;
3255 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003256
3257 /* there is a race condition that exists between this callback
3258 function and the caller since the caller could time out either
3259 before or while this code is executing. we use a spinlock to
3260 serialize these actions */
3261 spin_lock(&hdd_context_lock);
3262
Jeff Johnson295189b2012-06-20 16:38:30 -07003263 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3264 {
3265 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003266 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 hddLog(VOS_TRACE_LEVEL_WARN,
3268 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003269 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 if (ioctl_debug)
3271 {
3272 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003273 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 }
3275 return;
3276 }
3277
Jeff Johnson72a40512013-12-19 10:14:15 -08003278 /* context is valid so caller is still waiting */
3279
3280 /* paranoia: invalidate the magic */
3281 pStatsContext->magic = 0;
3282
3283 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3285
Jeff Johnson72a40512013-12-19 10:14:15 -08003286 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003288
3289 /* serialization is complete */
3290 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003291}
3292
3293VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3294{
3295 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3296 eHalStatus hstatus;
3297 long lrc;
3298 struct statsContext context;
3299
3300 if (NULL == pAdapter)
3301 {
3302 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3303 return VOS_STATUS_E_FAULT;
3304 }
3305 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3306 {
3307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3308 return VOS_STATUS_SUCCESS;
3309 }
3310
3311 /* we are connected
3312 prepare our callback context */
3313 init_completion(&context.completion);
3314 context.pAdapter = pAdapter;
3315 context.magic = STATS_CONTEXT_MAGIC;
3316 /* query only for Class A statistics (which include link speed) */
3317 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3318 eCSR_HDD,
3319 SME_GLOBAL_CLASSA_STATS,
3320 hdd_GetClassA_statisticsCB,
3321 0, // not periodic
3322 FALSE, //non-cached results
3323 pHddStaCtx->conn_info.staId[0],
3324 &context);
3325 if (eHAL_STATUS_SUCCESS != hstatus)
3326 {
3327 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003328 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003329 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 /* we'll returned a cached value below */
3331 }
3332 else
3333 {
3334 /* request was sent -- wait for the response */
3335 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3336 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 if (lrc <= 0)
3338 {
3339 hddLog(VOS_TRACE_LEVEL_ERROR,
3340 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003341 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 }
3343 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003344
3345 /* either we never sent a request, we sent a request and received a
3346 response or we sent a request and timed out. if we never sent a
3347 request or if we sent a request and got a response, we want to
3348 clear the magic out of paranoia. if we timed out there is a
3349 race condition such that the callback function could be
3350 executing at the same time we are. of primary concern is if the
3351 callback function had already verified the "magic" but had not
3352 yet set the completion variable when a timeout occurred. we
3353 serialize these activities by invalidating the magic while
3354 holding a shared spinlock which will cause us to block if the
3355 callback is currently executing */
3356 spin_lock(&hdd_context_lock);
3357 context.magic = 0;
3358 spin_unlock(&hdd_context_lock);
3359
3360 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 return VOS_STATUS_SUCCESS;
3362}
3363
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003364static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3365{
3366 struct statsContext *pStatsContext;
3367 tCsrSummaryStatsInfo *pSummaryStats;
3368 tCsrGlobalClassAStatsInfo *pClassAStats;
3369 hdd_adapter_t *pAdapter;
3370
3371 if (ioctl_debug)
3372 {
3373 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003374 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003375 }
3376
3377 if ((NULL == pStats) || (NULL == pContext))
3378 {
3379 hddLog(VOS_TRACE_LEVEL_ERROR,
3380 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003381 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003382 return;
3383 }
3384
Jeff Johnson72a40512013-12-19 10:14:15 -08003385 /* there is a race condition that exists between this callback
3386 function and the caller since the caller could time out either
3387 before or while this code is executing. we use a spinlock to
3388 serialize these actions */
3389 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003390
3391 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3392 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3393 pStatsContext = pContext;
3394 pAdapter = pStatsContext->pAdapter;
3395 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3396 {
3397 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003398 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003399 hddLog(VOS_TRACE_LEVEL_WARN,
3400 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003401 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003402 if (ioctl_debug)
3403 {
3404 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003405 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003406 }
3407 return;
3408 }
3409
Jeff Johnson72a40512013-12-19 10:14:15 -08003410 /* context is valid so caller is still waiting */
3411
3412 /* paranoia: invalidate the magic */
3413 pStatsContext->magic = 0;
3414
3415 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003416 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3417 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3418
Jeff Johnson72a40512013-12-19 10:14:15 -08003419 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003420 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003421
3422 /* serialization is complete */
3423 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003424}
3425
3426VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3427{
3428 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3429 eHalStatus hstatus;
3430 long lrc;
3431 struct statsContext context;
3432
3433 if (NULL == pAdapter)
3434 {
3435 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3436 return VOS_STATUS_SUCCESS;
3437 }
3438
3439 /* we are connected
3440 prepare our callback context */
3441 init_completion(&context.completion);
3442 context.pAdapter = pAdapter;
3443 context.magic = STATS_CONTEXT_MAGIC;
3444
3445 /* query only for Summary & Class A statistics */
3446 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3447 eCSR_HDD,
3448 SME_SUMMARY_STATS |
3449 SME_GLOBAL_CLASSA_STATS,
3450 hdd_get_station_statisticsCB,
3451 0, // not periodic
3452 FALSE, //non-cached results
3453 pHddStaCtx->conn_info.staId[0],
3454 &context);
3455 if (eHAL_STATUS_SUCCESS != hstatus)
3456 {
3457 hddLog(VOS_TRACE_LEVEL_ERROR,
3458 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003459 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003460 /* we'll return with cached values */
3461 }
3462 else
3463 {
3464 /* request was sent -- wait for the response */
3465 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3466 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003467
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003468 if (lrc <= 0)
3469 {
3470 hddLog(VOS_TRACE_LEVEL_ERROR,
3471 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003472 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003473 }
3474 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003475
3476 /* either we never sent a request, we sent a request and received a
3477 response or we sent a request and timed out. if we never sent a
3478 request or if we sent a request and got a response, we want to
3479 clear the magic out of paranoia. if we timed out there is a
3480 race condition such that the callback function could be
3481 executing at the same time we are. of primary concern is if the
3482 callback function had already verified the "magic" but had not
3483 yet set the completion variable when a timeout occurred. we
3484 serialize these activities by invalidating the magic while
3485 holding a shared spinlock which will cause us to block if the
3486 callback is currently executing */
3487 spin_lock(&hdd_context_lock);
3488 context.magic = 0;
3489 spin_unlock(&hdd_context_lock);
3490
3491 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003492 return VOS_STATUS_SUCCESS;
3493}
3494
3495
Jeff Johnson295189b2012-06-20 16:38:30 -07003496/*
3497 * Support for the LINKSPEED private command
3498 * Per the WiFi framework the response must be of the form
3499 * "LinkSpeed xx"
3500 */
3501static int iw_get_linkspeed(struct net_device *dev,
3502 struct iw_request_info *info,
3503 union iwreq_data *wrqu, char *extra)
3504{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303505 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303506 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303508 int len = sizeof(v_U32_t) + 1;
3509 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303510 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303511 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303512 int rc, valid = 0;
3513
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303514 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303515 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3516 if (NULL == pAdapter)
3517 {
3518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3519 "%s: Adapter is NULL",__func__);
3520 return -EINVAL;
3521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003522
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303523 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303524 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303525 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003526 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303527 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003528 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303529 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3530 if (NULL == pHddStaCtx)
3531 {
3532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3533 "%s: STA Context is NULL",__func__);
3534 return -EINVAL;
3535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3537 {
3538 /* we are not connected so we don't have a classAstats */
3539 link_speed = 0;
3540 }
3541 else
3542 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303543 status = wlan_hdd_get_classAstats(pAdapter);
3544
3545 if (!VOS_IS_STATUS_SUCCESS(status ))
3546 {
3547 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3548 return -EINVAL;
3549 }
3550
3551 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3552 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3553 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3554 &link_speed);
3555
3556 link_speed = link_speed / 10;
3557
3558 if (0 == link_speed)
3559 {
3560 /* The linkspeed returned by HAL is in units of 500kbps.
3561 * converting it to mbps.
3562 * This is required to support legacy firmware which does
3563 * not return link capacity.
3564 */
3565 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3566 }
3567
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 }
3569
3570 wrqu->data.length = len;
3571 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003572 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 if ((rc < 0) || (rc >= len))
3574 {
3575 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303576 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 return -EIO;
3578 }
3579
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303580 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003582 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003583}
3584
Arif Hussain695279c2014-03-24 14:06:07 -07003585/*
3586 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3587 *
3588 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303589static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003590 struct iw_request_info *info,
3591 union iwreq_data *wrqu, char *extra)
3592{
3593 int rc;
3594
3595 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3596
3597 if (rc < 0)
3598 return rc;
3599
3600 /* a value is being successfully returned */
3601 return 0;
3602}
Jeff Johnson295189b2012-06-20 16:38:30 -07003603
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303604static int iw_get_linkspeed_priv(struct net_device *dev,
3605 struct iw_request_info *info,
3606 union iwreq_data *wrqu, char *extra)
3607{
3608 int ret;
3609
3610 vos_ssr_protect(__func__);
3611 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3612 vos_ssr_unprotect(__func__);
3613
3614 return ret;
3615}
3616
Jeff Johnson295189b2012-06-20 16:38:30 -07003617/*
3618 * Support for the RSSI & RSSI-APPROX private commands
3619 * Per the WiFi framework the response must be of the form
3620 * "<ssid> rssi <xx>"
3621 * unless we are not associated, in which case the response is
3622 * "OK"
3623 */
3624static int iw_get_rssi(struct net_device *dev,
3625 struct iw_request_info *info,
3626 union iwreq_data *wrqu, char *extra)
3627{
3628 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003629 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 int len = wrqu->data.length;
3631 v_S7_t s7Rssi = 0;
3632 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3633 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3634 VOS_STATUS vosStatus;
3635 int rc;
3636
3637 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3638 (0 == ssidlen) || (ssidlen >= len))
3639 {
3640 /* we are not connected or our SSID is too long
3641 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003642 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 }
3644 else
3645 {
3646 /* we are connected with a valid SSID
3647 so we can write the SSID into the return buffer
3648 (note that it is not NUL-terminated) */
3649 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3650
3651 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3652
3653 if (VOS_STATUS_SUCCESS == vosStatus)
3654 {
3655 /* append the rssi to the ssid in the format required by
3656 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003657 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303658 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 }
3660 else
3661 {
3662 rc = -1;
3663 }
3664 }
3665
3666 /* verify that we wrote a valid response */
3667 if ((rc < 0) || (rc >= len))
3668 {
3669 // encoding or length error?
3670 hddLog(VOS_TRACE_LEVEL_ERROR,
3671 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003672 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003673 return -EIO;
3674 }
3675
3676 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003677 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003678}
3679
3680/*
3681 * Support for SoftAP channel range private command
3682 */
3683static int iw_softap_set_channel_range( struct net_device *dev,
3684 int startChannel,
3685 int endChannel,
3686 int band)
3687{
Jeff Johnson43971f52012-07-17 12:26:56 -07003688 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 int ret = 0;
3690 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3691 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003692 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3693
Jeff Johnson295189b2012-06-20 16:38:30 -07003694
3695 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3696 if (VOS_STATUS_SUCCESS != status)
3697 {
3698 ret = -EINVAL;
3699 }
Yathish9f22e662012-12-10 14:21:35 -08003700 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 return ret;
3702}
3703
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303704static uint8 chartohex(char c)
3705{
3706 uint8 val = 0;
3707 if (c >= '0' && c <= '9')
3708 val = c - '0';
3709 else if (c >= 'a' && c <= 'f')
3710 val = c - 'a' + 10;
3711 else if (c >= 'A' && c <= 'F')
3712 val = c - 'A' + 10;
3713 else
3714 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3715
3716 return val;
3717}
3718
3719uint8 getByte(char **buf)
3720{
3721 uint8 byte = 0;
3722 char *temp = *buf;
3723 byte = chartohex(*temp) * 16;
3724 temp++;
3725 byte += chartohex(*temp);
3726 temp++;
3727 *buf = temp;
3728 return byte;
3729}
3730
3731static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3732{
3733 tSir80211Header *macHeader;
3734 int i = 0, j = 0, length = 0;
3735 uint8 byte = 0;
3736 char *temp = pBuffer;
3737 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303738 char *pHeader;
3739 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303740
3741 macHeader = &pkt->macHeader;
3742
3743 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3744
3745 temp++;
3746
3747 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3748 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3749 pkt->encParams.keyParams.key[0].keyId);
3750
3751 for (i = 0; i< 16; i++) {
3752 pkt->encParams.keyParams.key[0].key[i]
3753 = getByte(&temp);
3754 }
3755
3756 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3757 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3758
3759 for (i = 0; i< 6; i++) {
3760 pkt->encParams.pn[i]
3761 = getByte(&temp);
3762 }
3763
3764 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3765 &pkt->encParams.pn[0], 6, 0);
3766
3767 for (i = 0, j= 5; i< 3; i++, j--) {
3768 byte = pkt->encParams.pn[i];
3769 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3770 pkt->encParams.pn[j] = byte;
3771 }
3772
3773 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303774 if (length > sizeof(tSir80211Header))
3775 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303776
Srinivas Dasari2382de62015-01-22 15:00:04 +05303777 pHeader = temp;
3778 vos_mem_zero(&header, sizeof(tSir80211Header));
3779 for (i = 0; i < length; i++) {
3780 *((uint8 *)&header + i) = getByte(&pHeader);
3781 }
3782
3783 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3784 (char *)&header, length, 0);
3785
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303786 byte = getByte(&temp);
3787
3788 macHeader->frameCtrl.protVer = byte & 0x3;
3789 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3790 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3791
3792 byte = getByte(&temp);
3793 macHeader->frameCtrl.toDS = (byte) & 0x1;
3794 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3795 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3796 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3797 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3798 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3799 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3800 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3801
3802 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3803 "macHeader->frameCtrl.type : %x "
3804 "macHeader->frameCtrl.subType : %x "
3805 "macHeader->frameCtrl.toDS : %x "
3806 "macHeader->frameCtrl.fromDS : %x "
3807 "macHeader->frameCtrl.moreFrag : %x "
3808 "macHeader->frameCtrl.retry : %x "
3809 "macHeader->frameCtrl.powerMgmt : %x "
3810 "macHeader->frameCtrl.MoreData : %x "
3811 "macHeader->frameCtrl.wep : %x "
3812 "macHeader->frameCtrl.order : %x "
3813 , macHeader->frameCtrl.protVer
3814 , macHeader->frameCtrl.type
3815 , macHeader->frameCtrl.subType
3816 , macHeader->frameCtrl.toDS
3817 , macHeader->frameCtrl.fromDS
3818 , macHeader->frameCtrl.moreFrag
3819 , macHeader->frameCtrl.retry
3820 , macHeader->frameCtrl.powerMgmt
3821 , macHeader->frameCtrl.moreData
3822 , macHeader->frameCtrl.wep
3823 , macHeader->frameCtrl.order);
3824
3825
3826 macHeader->usDurationId = getByte(&temp);
3827 macHeader->usDurationId += getByte(&temp) << 8;
3828
3829 macHeader->vA1[0] = getByte(&temp);
3830 macHeader->vA1[1] = getByte(&temp);
3831 macHeader->vA1[2] = getByte(&temp);
3832 macHeader->vA1[3] = getByte(&temp);
3833 macHeader->vA1[4] = getByte(&temp);
3834 macHeader->vA1[5] = getByte(&temp);
3835
3836 macHeader->vA2[0] = getByte(&temp);
3837 macHeader->vA2[1] = getByte(&temp);
3838 macHeader->vA2[2] = getByte(&temp);
3839 macHeader->vA2[3] = getByte(&temp);
3840 macHeader->vA2[4] = getByte(&temp);
3841 macHeader->vA2[5] = getByte(&temp);
3842
3843 macHeader->vA3[0] = getByte(&temp);
3844 macHeader->vA3[1] = getByte(&temp);
3845 macHeader->vA3[2] = getByte(&temp);
3846 macHeader->vA3[3] = getByte(&temp);
3847 macHeader->vA3[4] = getByte(&temp);
3848 macHeader->vA3[5] = getByte(&temp);
3849
3850 macHeader->sSeqCtrl = getByte(&temp);
3851 fragNum = macHeader->sSeqCtrl & 0xF;
3852 macHeader->sSeqCtrl >>= 4;
3853
3854 macHeader->sSeqCtrl += getByte(&temp) << 4;
3855
3856 macHeader->sSeqCtrl |= fragNum << 12;
3857
3858 if (length == 30 || length == 32) {
3859 macHeader->optvA4[0] = getByte(&temp);
3860 macHeader->optvA4[1] = getByte(&temp);
3861 macHeader->optvA4[2] = getByte(&temp);
3862 macHeader->optvA4[3] = getByte(&temp);
3863 macHeader->optvA4[4] = getByte(&temp);
3864 macHeader->optvA4[5] = getByte(&temp);
3865 }
3866
3867 if (length == 26 || length == 32) {
3868 macHeader->usQosCtrl = getByte(&temp);
3869 macHeader->usQosCtrl += getByte(&temp) << 8;
3870 }
3871
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303872 //parse payload
3873 length = getByte(&temp);
3874 length += getByte(&temp) << 8;
3875 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3876
3877 pkt->data.length = length;
3878
3879 for (i = 0; i< length; i++) {
3880 pkt->data.data[i] = getByte(&temp);
3881 }
3882
3883 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3884 &pkt->data.data[0], pkt->data.length, 0);
3885}
3886
3887/**---------------------------------------------------------------------------
3888
3889 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3890 encrypt message request
3891 This is an asynchronous callback function from SME when the encrypted data
3892 is received
3893
3894 \pEncInfoRsp -> Encrypted data info
3895
3896 \return - 0 for success non-zero for failure
3897 --------------------------------------------------------------------------*/
3898static void
3899hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3900{
3901 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3902
3903 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3904
3905 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3906 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3907 pEncryptedDataRsp->encryptedPayload.length);
3908 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3909 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3910 pEncryptedDataRsp->encryptedPayload.data,
3911 pEncryptedDataRsp->encryptedPayload.length, 0);
3912}
3913
Jeff Johnson295189b2012-06-20 16:38:30 -07003914VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3915{
3916 struct statsContext context;
3917 eHalStatus status;
3918 hdd_context_t *pHddCtx;
3919
3920 if (NULL == pAdapter)
3921 {
3922 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3923 return VOS_STATUS_E_FAULT;
3924 }
3925
3926 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3927 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303928 if (pHddCtx->isLogpInProgress) {
3929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3930 "%s:LOGP in Progress. Ignore!!!", __func__);
3931 return VOS_STATUS_E_FAILURE;
3932 }
3933
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 init_completion(&context.completion);
3935
3936 context.pAdapter = pAdapter;
3937 context.magic = POWER_CONTEXT_MAGIC;
3938
3939 if (DRIVER_POWER_MODE_ACTIVE == mode)
3940 {
3941 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3942 "Full Power", __func__);
3943 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3944 iw_power_callback_fn, &context,
3945 eSME_FULL_PWR_NEEDED_BY_HDD);
3946 // Enter Full power command received from GUI this means we are disconnected
3947 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3948 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3949 if (eHAL_STATUS_PMC_PENDING == status)
3950 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003951 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 int lrc = wait_for_completion_interruptible_timeout(
3953 &context.completion,
3954 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003955
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 if (lrc <= 0)
3957 {
3958 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003959 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 }
3961 }
3962 }
3963 else if (DRIVER_POWER_MODE_AUTO == mode)
3964 {
3965 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3966 {
3967 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3968 __func__);
3969 // Enter BMPS command received from GUI this means DHCP is completed
3970 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3971 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3972 FALSE);
3973 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3974 iw_power_callback_fn, &context);
3975 if (eHAL_STATUS_PMC_PENDING == status)
3976 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003977 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 int lrc = wait_for_completion_interruptible_timeout(
3979 &context.completion,
3980 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 if (lrc <= 0)
3982 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003983 hddLog(VOS_TRACE_LEVEL_ERROR,
3984 "%s: SME %s while requesting BMPS",
3985 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 }
3987 }
3988 }
3989 else
3990 {
3991 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3992 "enabled in the cfg");
3993 }
3994 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003995
3996 /* either we never sent a request, we sent a request and received a
3997 response or we sent a request and timed out. if we never sent a
3998 request or if we sent a request and got a response, we want to
3999 clear the magic out of paranoia. if we timed out there is a
4000 race condition such that the callback function could be
4001 executing at the same time we are. of primary concern is if the
4002 callback function had already verified the "magic" but had not
4003 yet set the completion variable when a timeout occurred. we
4004 serialize these activities by invalidating the magic while
4005 holding a shared spinlock which will cause us to block if the
4006 callback is currently executing */
4007 spin_lock(&hdd_context_lock);
4008 context.magic = 0;
4009 spin_unlock(&hdd_context_lock);
4010
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 return VOS_STATUS_SUCCESS;
4012}
4013
4014VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
4015 hdd_adapter_t *pAdapter)
4016{
4017 VOS_STATUS vos_Status;
4018
4019 if ((NULL == pAdapter) || (NULL == pHddCtx))
4020 {
4021 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
4022 return VOS_STATUS_E_FAULT;
4023 }
4024
4025 /**Exit from Deep sleep or standby if we get the driver
4026 START cmd from android GUI
4027 */
4028 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4029 {
4030 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4031 "from Stand by",__func__);
4032 vos_Status = hdd_exit_standby(pHddCtx);
4033 }
4034 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4035 {
4036 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4037 "from deep sleep",__func__);
4038 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4039 }
4040 else
4041 {
4042 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4043 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4044 vos_Status = VOS_STATUS_SUCCESS;
4045 }
4046
4047 return vos_Status;
4048}
4049
4050VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4051{
4052 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4053
4054 if (NULL == pHddCtx)
4055 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304056 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 return VOS_STATUS_E_FAULT;
4058 }
4059
4060 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4061 {
4062 //Execute standby procedure.
4063 //Executing standby procedure will cause the STA to
4064 //disassociate first and then the chip will be put into standby.
4065 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4066 vos_Status = hdd_enter_standby(pHddCtx);
4067 }
4068 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4069 pHddCtx->cfg_ini->nEnableDriverStop)
4070 {
4071 //Execute deep sleep procedure
4072 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004073 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 //Deep sleep not supported
4075 vos_Status = hdd_enter_standby(pHddCtx);
4076 }
4077 else
4078 {
4079 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4080 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4081 vos_Status = VOS_STATUS_SUCCESS;
4082 }
4083
4084 return vos_Status;
4085}
4086
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004087
4088void* wlan_hdd_change_country_code_callback(void *pAdapter)
4089{
4090
4091 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004092 complete(&call_back_pAdapter->change_country_code);
4093
4094 return NULL;
4095}
4096
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304097static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 struct iw_request_info *info,
4099 union iwreq_data *wrqu, char *extra)
4100{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304101 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004102 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304104 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004105 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4106
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304107 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004108
4109 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304110
4111 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4112 if (NULL == pAdapter)
4113 {
4114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4115 "mem_alloc_copy_from_user_helper fail");
4116 return -EINVAL;
4117 }
4118 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4119 rc = wlan_hdd_validate_context(pHddCtx);
4120 if (0 != rc)
4121 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304122 return rc;
4123 }
4124
Arif Hussain24bfa702014-01-22 13:51:30 -08004125 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4126 wrqu->data.length);
4127 if (NULL == cmd)
4128 {
4129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4130 "mem_alloc_copy_from_user_helper fail");
4131 return -ENOMEM;
4132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004133
4134 if (ioctl_debug)
4135 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004136 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 }
4138
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004139 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4140 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004141
Arif Hussain24bfa702014-01-22 13:51:30 -08004142 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004144 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4146 "%s: Error in iw_set_scan!", __func__);
4147 rc = -EINVAL;
4148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 }
4150 else if( strcasecmp(cmd, "start") == 0 ) {
4151
Arif Hussain6d2a3322013-11-17 19:50:10 -08004152 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004154
Arif Hussain24bfa702014-01-22 13:51:30 -08004155 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4156 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 {
4158 union iwreq_data wrqu;
4159 char buf[10];
4160
4161 memset(&wrqu, 0, sizeof(wrqu));
4162 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4163 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4164 }
4165 else
4166 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004167 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4168 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 }
4170 goto done;
4171 }
4172 else if( strcasecmp(cmd, "stop") == 0 )
4173 {
4174 union iwreq_data wrqu;
4175 char buf[10];
4176
Arif Hussain6d2a3322013-11-17 19:50:10 -08004177 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004178
4179 wlan_hdd_enter_lowpower(pHddCtx);
4180 memset(&wrqu, 0, sizeof(wrqu));
4181 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4182 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 goto done;
4184 }
4185 else if (strcasecmp(cmd, "macaddr") == 0)
4186 {
4187 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4188 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4189 }
4190 else if (strcasecmp(cmd, "scan-active") == 0)
4191 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304192 hddLog(VOS_TRACE_LEVEL_ERROR,
4193 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004194 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 ret = snprintf(cmd, cmd_len, "OK");
4196 }
4197 else if (strcasecmp(cmd, "scan-passive") == 0)
4198 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304199 hddLog(VOS_TRACE_LEVEL_ERROR,
4200 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004201 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 ret = snprintf(cmd, cmd_len, "OK");
4203 }
4204 else if( strcasecmp(cmd, "scan-mode") == 0 )
4205 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004206 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 }
4208 else if( strcasecmp(cmd, "linkspeed") == 0 )
4209 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004210 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004211 }
4212 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4213 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004214 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004215 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004216
4217 country_code = cmd + 8;
4218
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004219 init_completion(&pAdapter->change_country_code);
4220
Arif Hussain24bfa702014-01-22 13:51:30 -08004221 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004222 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 country_code,
4224 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304225 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304226 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304227 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004228
4229 /* Wait for completion */
4230 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4231 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4232
4233 if (lrc <= 0)
4234 {
4235 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004236 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004237 }
4238
Arif Hussain24bfa702014-01-22 13:51:30 -08004239 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004241 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004242 "%s: SME Change Country code fail", __func__);
4243 kfree(cmd);
4244 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 }
4246 }
4247 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4248 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004249 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 }
4251 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4252 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004253 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004254
Wilson Yang1be3e652013-10-09 15:18:31 -07004255 if (9 < cmd_len)
4256 {
4257 ptr = (char*)(cmd + 9);
4258
4259 }else{
4260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4261 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004262 kfree(cmd);
4263 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004264 }
4265
4266 if (1 != sscanf(ptr,"%d",&mode))
4267 {
4268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4269 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004270 kfree(cmd);
4271 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004272 }
4273
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 wlan_hdd_enter_bmps(pAdapter, mode);
4275 /*TODO:Set the power mode*/
4276 }
4277 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4278 v_U32_t pmc_state;
4279 v_U16_t value;
4280
4281 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4282 if(pmc_state == BMPS) {
4283 value = DRIVER_POWER_MODE_AUTO;
4284 }
4285 else {
4286 value = DRIVER_POWER_MODE_ACTIVE;
4287 }
4288 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4289 }
4290 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004291 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 /*TODO: set the btcoexmode*/
4293 }
4294 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4295
Arif Hussain6d2a3322013-11-17 19:50:10 -08004296 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 /*TODO: Return the btcoex status*/
4298 }
4299 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4300
Arif Hussain6d2a3322013-11-17 19:50:10 -08004301 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004302
4303 /*TODO: Enable Rx data Filter*/
4304 }
4305 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4306
Arif Hussain6d2a3322013-11-17 19:50:10 -08004307 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004308
4309 /*TODO: Disable Rx data Filter*/
4310 }
4311 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4312
Arif Hussain6d2a3322013-11-17 19:50:10 -08004313 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 /*TODO: rxfilter-statistics*/
4315 }
4316 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4317
Arif Hussain6d2a3322013-11-17 19:50:10 -08004318 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 /*TODO: rxfilter-add*/
4320 }
4321 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4322
Arif Hussain6d2a3322013-11-17 19:50:10 -08004323 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004324 /*TODO: rxfilter-remove*/
4325 }
4326#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004327 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4328 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4329 /*TODO: support pnosetup*/
4330 }
4331 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4332 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4333 /*TODO: support pnoforce*/
4334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4336
Arif Hussain6d2a3322013-11-17 19:50:10 -08004337 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004338 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4339 kfree(cmd);
4340 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 }
4342 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004343 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004344 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4345 kfree(cmd);
4346 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 }
4348#endif /*FEATURE_WLAN_SCAN_PNO*/
4349 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004350 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004351 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4352 kfree(cmd);
4353 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 }
4355 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4356 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004357 char *ptr;
4358
4359 if (18 < cmd_len)
4360 {
4361 ptr = (char*)(cmd + 18);
4362 }else{
4363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4364 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004365 kfree(cmd);
4366 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004367 }
4368
Jeff Johnson02797792013-10-26 19:17:13 -07004369 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004370 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4371 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4372 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4373 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4374 {
4375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4376 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004377 kfree(cmd);
4378 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004380
4381 // parameters checking
4382 // period has to be larger than 0
4383 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4384 {
4385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004386 kfree(cmd);
4387 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 }
4389
4390 // use default value 5 is the input is not reasonable. in unit of 10%
4391 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4392 {
4393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4394 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4395 }
4396
4397 // default is 5
4398 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4399 {
4400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4401 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4402 }
4403
Arif Hussain24bfa702014-01-22 13:51:30 -08004404 if (eHAL_STATUS_SUCCESS !=
4405 sme_SetTxPerTracking(pHddCtx->hHal,
4406 hdd_tx_per_hit_cb,
4407 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004409 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 }
4411 }
4412 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004413 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4414 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 }
4416done:
4417 /* many of the commands write information back into the command
4418 string using snprintf(). check the return value here in one
4419 place */
4420 if ((ret < 0) || (ret >= cmd_len))
4421 {
4422 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004423 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004425 else if (ret > 0)
4426 {
4427 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4428 {
4429 hddLog(VOS_TRACE_LEVEL_ERROR,
4430 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004431 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004432 return -EFAULT;
4433 }
4434 wrqu->data.length = ret;
4435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004436
4437 if (ioctl_debug)
4438 {
4439 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004440 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004442 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304443 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004444 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004445}
4446
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304447static int iw_set_priv(struct net_device *dev,
4448 struct iw_request_info *info,
4449 union iwreq_data *wrqu, char *extra)
4450{
4451 int ret;
4452 vos_ssr_protect(__func__);
4453 ret = __iw_set_priv(dev, info, wrqu, extra);
4454 vos_ssr_unprotect(__func__);
4455
4456 return ret;
4457}
4458
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304459static int __iw_set_nick(struct net_device *dev,
4460 struct iw_request_info *info,
4461 union iwreq_data *wrqu, char *extra)
4462{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304463 hdd_adapter_t *pAdapter;
4464 hdd_context_t *pHddCtx;
4465 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304466
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304467 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304468
4469 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4470 if (NULL == pAdapter)
4471 {
4472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4473 "%s: Adapter is NULL",__func__);
4474 return -EINVAL;
4475 }
4476
4477 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4478 ret = wlan_hdd_validate_context(pHddCtx);
4479 if (0 != ret)
4480 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304481 return ret;
4482 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304483 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304484 return 0;
4485}
4486
Jeff Johnson295189b2012-06-20 16:38:30 -07004487static int iw_set_nick(struct net_device *dev,
4488 struct iw_request_info *info,
4489 union iwreq_data *wrqu, char *extra)
4490{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304491 int ret;
4492
4493 vos_ssr_protect(__func__);
4494 ret = __iw_set_nick(dev, info, wrqu, extra);
4495 vos_ssr_unprotect(__func__);
4496
4497 return ret;
4498}
4499
4500static int __iw_get_nick(struct net_device *dev,
4501 struct iw_request_info *info,
4502 union iwreq_data *wrqu, char *extra)
4503{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304504 hdd_adapter_t *pAdapter;
4505 hdd_context_t *pHddCtx;
4506 int ret = 0;
4507
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304509
4510 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4511 if (NULL == pAdapter)
4512 {
4513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4514 "%s: Adapter is NULL",__func__);
4515 return -EINVAL;
4516 }
4517
4518 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4519 ret = wlan_hdd_validate_context(pHddCtx);
4520 if (0 != ret)
4521 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304522 return ret;
4523 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304524 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 return 0;
4526}
4527
4528static int iw_get_nick(struct net_device *dev,
4529 struct iw_request_info *info,
4530 union iwreq_data *wrqu, char *extra)
4531{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304532 int ret;
4533
4534 vos_ssr_protect(__func__);
4535 ret = __iw_get_nick(dev, info, wrqu, extra);
4536 vos_ssr_unprotect(__func__);
4537
4538 return ret;
4539}
4540
4541static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4542{
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304544 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004545}
4546
4547static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4548{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304549
4550 struct iw_statistics *stats;
4551
4552 vos_ssr_protect(__func__);
4553 stats = __get_wireless_stats(dev);
4554 vos_ssr_unprotect(__func__);
4555
4556 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004557}
4558
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304559static int __iw_set_encode(struct net_device *dev,
4560 struct iw_request_info *info,
4561 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004562
4563{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304564 hdd_adapter_t *pAdapter;
4565 hdd_station_ctx_t *pHddStaCtx;
4566 hdd_wext_state_t *pWextState;
4567 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 struct iw_point *encoderq = &(wrqu->encoding);
4569 v_U32_t keyId;
4570 v_U8_t key_length;
4571 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4572 v_BOOL_t fKeyPresent = 0;
4573 int i;
4574 eHalStatus status = eHAL_STATUS_SUCCESS;
4575
4576
4577 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304578 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4579 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4582 "%s: Adapter is NULL",__func__);
4583 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 }
4585
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304586 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4587 status = wlan_hdd_validate_context(pHddCtx);
4588 if (0 != status)
4589 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304590 return status;
4591 }
4592 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4593 if (NULL == pWextState)
4594 {
4595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4596 "%s: pWextState is NULL ",__func__);
4597 return -EINVAL;
4598 }
4599 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4600 if (NULL == pHddStaCtx)
4601 {
4602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4603 "%s: STA Context is NULL",__func__);
4604 return -EINVAL;
4605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004606
4607 keyId = encoderq->flags & IW_ENCODE_INDEX;
4608
4609 if(keyId)
4610 {
4611 if(keyId > MAX_WEP_KEYS)
4612 {
4613 return -EINVAL;
4614 }
4615
4616 fKeyPresent = 1;
4617 keyId--;
4618 }
4619 else
4620 {
4621 fKeyPresent = 0;
4622 }
4623
4624
4625 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4626 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004628 if(!fKeyPresent) {
4629
4630 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4631
4632 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4633 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4634 }
4635 }
4636 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4637 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4638 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4639 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4640
4641 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4642 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4643
4644 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4645 {
4646 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4647 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004648 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304649 {
4650 long ret;
4651 ret = wait_for_completion_interruptible_timeout(
4652 &pAdapter->disconnect_comp_var,
4653 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4654 if (ret <= 0)
4655 hddLog(VOS_TRACE_LEVEL_ERROR,
4656 FL("failed wait on disconnect_comp_var %ld"), ret);
4657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 }
4659
4660 return status;
4661
4662 }
4663
4664 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4665 {
4666 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4667
4668 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4669
4670 }
4671
4672
4673 if(wrqu->data.length > 0)
4674 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004675 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004676
4677 key_length = wrqu->data.length;
4678
4679 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4680
4681 if(5 == key_length)
4682 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004683 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004684
4685 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4686 {
4687 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4688 }
4689 else
4690 {
4691 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4692 }
4693 }
4694 else if(13 == key_length)
4695 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004696 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004697
4698 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4699 {
4700 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4701 }
4702 else
4703 {
4704 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4705 }
4706 }
4707 else
4708 {
4709 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004710 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 return -EINVAL;
4712 }
4713
4714 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4715 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4716 pWextState->roamProfile.EncryptionType.numEntries = 1;
4717 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4718 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4719 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4720
4721 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4722 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4723 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4724 {
4725
4726 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4727
4728 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4729 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4730
4731 return status;
4732 }
4733 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304734 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 return 0;
4736}
4737
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304738static int iw_set_encode(struct net_device *dev,
4739 struct iw_request_info *info,
4740 union iwreq_data *wrqu,char *extra)
4741{
4742 int ret;
4743
4744 vos_ssr_protect(__func__);
4745 ret = __iw_set_encode(dev, info, wrqu, extra);
4746 vos_ssr_unprotect(__func__);
4747
4748 return ret;
4749}
4750
4751static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 struct iw_request_info *info,
4753 struct iw_point *dwrq,
4754 char *extra)
4755{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304756 hdd_adapter_t *pAdapter;
4757 hdd_wext_state_t *pWextState;
4758 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 int keyId;
4760 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4761 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304762 int i, ret = 0;
4763 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004764
4765 ENTER();
4766
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304767 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4768 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004769 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4771 "%s: Adapter is NULL",__func__);
4772 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004773 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304774 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4775 ret = wlan_hdd_validate_context(pHddCtx);
4776 if (0 != ret)
4777 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304778 return ret;
4779 }
4780 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4781 if (NULL == pWextState)
4782 {
4783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4784 "%s: pWextState is NULL",__func__);
4785 return -EINVAL;
4786 }
4787 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004788
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 keyId = pRoamProfile->Keys.defaultIndex;
4790
4791 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4792 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004793 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 return -EINVAL;
4795 }
4796
4797 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4798 {
4799 dwrq->flags |= IW_ENCODE_ENABLED;
4800 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304801 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4802 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 }
4804 else
4805 {
4806 dwrq->flags |= IW_ENCODE_DISABLED;
4807 }
4808
4809 for(i=0; i < MAX_WEP_KEYS; i++)
4810 {
4811 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4812 {
4813 continue;
4814 }
4815 else
4816 {
4817 break;
4818 }
4819 }
4820
4821 if(MAX_WEP_KEYS == i)
4822 {
4823 dwrq->flags |= IW_ENCODE_NOKEY;
4824 }
4825 else
4826 {
4827 dwrq->flags |= IW_ENCODE_ENABLED;
4828 }
4829
4830 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4831
4832 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4833 {
4834 dwrq->flags |= IW_ENCODE_DISABLED;
4835 }
4836
4837 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4838
4839 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4840 {
4841 dwrq->flags |= IW_ENCODE_OPEN;
4842 }
4843 else
4844 {
4845 dwrq->flags |= IW_ENCODE_RESTRICTED;
4846 }
4847 EXIT();
4848 return 0;
4849
4850}
4851
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304852static int iw_get_encodeext(struct net_device *dev,
4853 struct iw_request_info *info,
4854 struct iw_point *dwrq,
4855 char *extra)
4856{
4857 int ret;
4858 vos_ssr_protect(__func__);
4859 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4860 vos_ssr_unprotect(__func__);
4861
4862 return ret;
4863}
4864
4865static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 struct iw_request_info *info,
4867 union iwreq_data *wrqu, char *extra)
4868{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304869 hdd_adapter_t *pAdapter;
4870 hdd_station_ctx_t *pHddStaCtx;
4871 hdd_wext_state_t *pWextState;
4872 hdd_context_t *pHddCtx;
4873 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004874
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304875 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 v_U32_t status = 0;
4877
4878 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4879
4880 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4881
4882 int key_index;
4883 struct iw_point *encoding = &wrqu->encoding;
4884 tCsrRoamSetKey setKey;
4885 v_U32_t roamId= 0xFF;
4886 VOS_STATUS vos_status;
4887
4888 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304889 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4890 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4893 "%s: Adapter is NULL",__func__);
4894 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304896 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4897 status = wlan_hdd_validate_context(pHddCtx);
4898 if (0 != status)
4899 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304900 return status;
4901 }
4902 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4903 if (NULL == pHddStaCtx)
4904 {
4905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4906 "%s: STA Context is NULL",__func__);
4907 return -EINVAL;
4908 }
4909 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4910 if (NULL == pWextState)
4911 {
4912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4913 "%s: pWextState is NULL",__func__);
4914 return -EINVAL;
4915 }
4916 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 key_index = encoding->flags & IW_ENCODE_INDEX;
4918
4919 if(key_index > 0) {
4920
4921 /*Convert from 1-based to 0-based keying*/
4922 key_index--;
4923 }
4924 if(!ext->key_len) {
4925
4926 /*Set the encrytion type to NONE*/
4927 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4928 return status;
4929 }
4930
4931 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4932 (IW_ENCODE_ALG_WEP == ext->alg))
4933 {
4934 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4935
Agarwal Ashish971c2882013-10-30 20:11:12 +05304936 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4937 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 return -EINVAL;
4939 }
4940 else {
4941 /*Static wep, update the roam profile with the keys */
4942 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4943 key_index < CSR_MAX_NUM_KEY) {
4944 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4945 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4946
4947 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4948 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4949
4950 }
4951 }
4952 return status;
4953 }
4954
4955 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4956
4957 setKey.keyId = key_index;
4958 setKey.keyLength = ext->key_len;
4959
4960 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4961 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4962 }
4963
4964 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4965 /*Key direction for group is RX only*/
4966 setKey.keyDirection = eSIR_RX_ONLY;
4967 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4968 }
4969 else {
4970
4971 setKey.keyDirection = eSIR_TX_RX;
4972 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4973 }
4974
4975 /*For supplicant pae role is zero*/
4976 setKey.paeRole = 0;
4977
4978 switch(ext->alg)
4979 {
4980 case IW_ENCODE_ALG_NONE:
4981 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4982 break;
4983
4984 case IW_ENCODE_ALG_WEP:
4985 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4986 break;
4987
4988 case IW_ENCODE_ALG_TKIP:
4989 {
4990 v_U8_t *pKey = &setKey.Key[0];
4991
4992 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4993
4994 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4995
4996 /*Supplicant sends the 32bytes key in this order
4997
4998 |--------------|----------|----------|
4999 | Tk1 |TX-MIC | RX Mic |
5000 |--------------|----------|----------|
5001 <---16bytes---><--8bytes--><--8bytes-->
5002
5003 */
5004 /*Sme expects the 32 bytes key to be in the below order
5005
5006 |--------------|----------|----------|
5007 | Tk1 |RX-MIC | TX Mic |
5008 |--------------|----------|----------|
5009 <---16bytes---><--8bytes--><--8bytes-->
5010 */
5011 /* Copy the Temporal Key 1 (TK1) */
5012 vos_mem_copy(pKey,ext->key,16);
5013
5014 /*Copy the rx mic first*/
5015 vos_mem_copy(&pKey[16],&ext->key[24],8);
5016
5017 /*Copy the tx mic */
5018 vos_mem_copy(&pKey[24],&ext->key[16],8);
5019
5020 }
5021 break;
5022
5023 case IW_ENCODE_ALG_CCMP:
5024 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5025 break;
5026
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005027#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005028#define IW_ENCODE_ALG_KRK 6
5029 case IW_ENCODE_ALG_KRK:
5030 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5031 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005032#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005033
5034 default:
5035 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5036 break;
5037 }
5038
5039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005040 ("%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 -07005041
5042#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305043 /* The supplicant may attempt to set the PTK once pre-authentication
5044 is done. Save the key in the UMAC and include it in the ADD
5045 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005046 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305047 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305049 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5050 "%s: Update PreAuth Key success", __func__);
5051 return 0;
5052 }
5053 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5054 {
5055 hddLog(VOS_TRACE_LEVEL_ERROR,
5056 "%s: Update PreAuth Key failed", __func__);
5057 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 }
5059#endif /* WLAN_FEATURE_VOWIFI_11R */
5060
5061 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5062
5063 vos_status = wlan_hdd_check_ula_done(pAdapter);
5064 if ( vos_status != VOS_STATUS_SUCCESS )
5065 {
5066 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5067 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5068 __LINE__, vos_status );
5069
5070 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5071 }
5072
5073 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5074
5075 if ( halStatus != eHAL_STATUS_SUCCESS )
5076 {
5077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5078 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5079 __LINE__, halStatus );
5080
5081 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5082 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305083 EXIT();
5084 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005085}
5086
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305087static int iw_set_encodeext(struct net_device *dev,
5088 struct iw_request_info *info,
5089 union iwreq_data *wrqu, char *extra)
5090{
5091 int ret;
5092
5093 vos_ssr_protect(__func__);
5094 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5095 vos_ssr_unprotect(__func__);
5096
5097 return ret;
5098}
5099
5100static int __iw_set_retry(struct net_device *dev,
5101 struct iw_request_info *info,
5102 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005103{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305104 hdd_adapter_t *pAdapter;
5105 tHalHandle hHal;
5106 hdd_context_t *pHddCtx;
5107 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005108
5109 ENTER();
5110
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305111 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5112 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005113 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5115 "%s: Adapter is NULL",__func__);
5116 return -EINVAL;
5117 }
5118
5119 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5120 ret = wlan_hdd_validate_context(pHddCtx);
5121 if (0 != ret)
5122 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305123 return ret;
5124 }
5125
5126 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5127 if (NULL == hHal)
5128 {
5129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5130 "%s: Hal Context is NULL",__func__);
5131 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005132 }
5133
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5135 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5136
Arif Hussain6d2a3322013-11-17 19:50:10 -08005137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005138
5139 return -EINVAL;
5140 }
5141
5142 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5143
5144 if((wrqu->retry.flags & IW_RETRY_LONG))
5145 {
5146 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5147 {
c_hpothub8245442013-11-20 23:41:09 +05305148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5149 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 return -EIO;
5151 }
5152 }
5153 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5154 {
5155 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5156 {
c_hpothub8245442013-11-20 23:41:09 +05305157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5158 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 return -EIO;
5160 }
5161 }
5162 }
5163 else
5164 {
5165 return -EOPNOTSUPP;
5166 }
5167
Arif Hussain6d2a3322013-11-17 19:50:10 -08005168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005169
5170 EXIT();
5171
5172 return 0;
5173
5174}
5175
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305176static int iw_set_retry(struct net_device *dev,
5177 struct iw_request_info *info,
5178 union iwreq_data *wrqu, char *extra)
5179{
5180 int ret;
5181
5182 vos_ssr_protect(__func__);
5183 ret = __iw_set_retry(dev, info, wrqu, extra);
5184 vos_ssr_unprotect(__func__);
5185
5186 return ret;
5187}
5188
5189static int __iw_get_retry(struct net_device *dev,
5190 struct iw_request_info *info,
5191 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005192{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305193 hdd_adapter_t *pAdapter;
5194 hdd_context_t *pHddCtx;
5195 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305197 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005198
5199 ENTER();
5200
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305201 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5202 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005203 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5205 "%s: Adapter is NULL",__func__);
5206 return -EINVAL;
5207 }
5208
5209 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5210 ret = wlan_hdd_validate_context(pHddCtx);
5211 if (0 != ret)
5212 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305213 return ret;
5214 }
5215
5216 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5217 if (NULL == hHal)
5218 {
5219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5220 "%s: Hal Context is NULL",__func__);
5221 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005222 }
5223
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 if((wrqu->retry.flags & IW_RETRY_LONG))
5225 {
5226 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5227
5228 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5229 {
c_hpothub8245442013-11-20 23:41:09 +05305230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5231 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005232 return -EIO;
5233 }
5234
5235 wrqu->retry.value = retry;
5236 }
5237 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5238 {
5239 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5240
5241 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5242 {
c_hpothub8245442013-11-20 23:41:09 +05305243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5244 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 return -EIO;
5246 }
5247
5248 wrqu->retry.value = retry;
5249 }
5250 else {
5251 return -EOPNOTSUPP;
5252 }
5253
Arif Hussain6d2a3322013-11-17 19:50:10 -08005254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005255
5256 EXIT();
5257
5258 return 0;
5259}
5260
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305261static int iw_get_retry(struct net_device *dev,
5262 struct iw_request_info *info,
5263 union iwreq_data *wrqu, char *extra)
5264{
5265 int ret;
5266
5267 vos_ssr_protect(__func__);
5268 ret = __iw_get_retry(dev, info, wrqu, extra);
5269 vos_ssr_unprotect(__func__);
5270
5271 return ret;
5272}
5273
5274static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 struct iw_request_info *info,
5276 union iwreq_data *wrqu,
5277 char *extra)
5278{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305279 hdd_adapter_t *pAdapter;
5280 hdd_context_t *pHddCtx;
5281 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5283 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305284 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005285
5286 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305287 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5288 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5291 "%s:Adapter is NULL",__func__);
5292 return -EINVAL;
5293 }
5294 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5295 ret = wlan_hdd_validate_context(pHddCtx);
5296 if (0 != ret)
5297 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305298 return ret;
5299 }
5300 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5301 if (NULL == pHddStaCtx)
5302 {
5303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5304 "%s:STA context is NULL",__func__);
5305 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005306 }
5307
5308 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5309 switch (mlme->cmd) {
5310 case IW_MLME_DISASSOC:
5311 case IW_MLME_DEAUTH:
5312
5313 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5314 {
5315 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5316
5317 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5318 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5319
5320 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5321 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5322
Jeff Johnson43971f52012-07-17 12:26:56 -07005323 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305324 {
5325 long ret;
5326 ret = wait_for_completion_interruptible_timeout(
5327 &pAdapter->disconnect_comp_var,
5328 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5329 if (ret <= 0)
5330 hddLog(VOS_TRACE_LEVEL_ERROR,
5331 FL("failed wait on disconnect_comp_var %ld"), ret);
5332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005334 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005335 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005336
5337 /* Resetting authKeyMgmt */
5338 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5339
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305340 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 netif_tx_disable(dev);
5342 netif_carrier_off(dev);
5343
5344 }
5345 else
5346 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005347 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 -07005348 }
5349 break;
5350 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005351 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005352 return -EINVAL;
5353 }//end of switch
5354
5355 EXIT();
5356
5357 return status;
5358
5359}
5360
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305361static int iw_set_mlme(struct net_device *dev,
5362 struct iw_request_info *info,
5363 union iwreq_data *wrqu,
5364 char *extra)
5365{
5366 int ret;
5367
5368 vos_ssr_protect(__func__);
5369 ret = __iw_set_mlme(dev, info, wrqu, extra);
5370 vos_ssr_unprotect(__func__);
5371
5372 return ret;
5373}
5374
Jeff Johnson295189b2012-06-20 16:38:30 -07005375/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305376static int __iw_setint_getnone(struct net_device *dev,
5377 struct iw_request_info *info,
5378 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005379{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305380 hdd_adapter_t *pAdapter;
5381 tHalHandle hHal;
5382 hdd_wext_state_t *pWextState;
5383 hdd_context_t *pHddCtx;
Katya Nigamf0511f62015-05-05 16:40:57 +05305384 hdd_mon_ctx_t *pMonCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 int *value = (int *)extra;
5386 int sub_cmd = value[0];
5387 int set_value = value[1];
5388 int ret = 0; /* success */
5389 int enable_pbm, enable_mp;
5390#ifdef CONFIG_HAS_EARLYSUSPEND
5391 v_U8_t nEnableSuspendOld;
5392#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005393
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305394 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305395 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5396 if (NULL == pAdapter)
5397 {
5398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5399 "%s: Adapter is NULL",__func__);
5400 return -EINVAL;
5401 }
5402 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5403 ret = wlan_hdd_validate_context(pHddCtx);
5404 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005405 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305406 return ret;
5407 }
Katya Nigameae74b62015-05-28 17:19:16 +05305408 if ( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305409 {
Katya Nigameae74b62015-05-28 17:19:16 +05305410 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5411 if (NULL == hHal)
5412 {
5413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5414 "%s: Hal Context is NULL",__func__);
5415 return -EINVAL;
5416 }
5417 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5418 if (NULL == pWextState)
5419 {
5420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5421 "%s: pWextState is NULL",__func__);
5422 return -EINVAL;
5423 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005424
Katya Nigameae74b62015-05-28 17:19:16 +05305425 INIT_COMPLETION(pWextState->completion_var);
5426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 switch(sub_cmd)
5428 {
5429 case WE_SET_11D_STATE:
5430 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005431 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005432 memset(&smeConfig, 0x00, sizeof(smeConfig));
5433
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5435
5436 sme_GetConfigParam(hHal,&smeConfig);
5437 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5438
Arif Hussain6d2a3322013-11-17 19:50:10 -08005439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005440
5441 sme_UpdateConfig(hHal,&smeConfig);
5442 }
5443 else {
5444 return -EINVAL;
5445 }
5446 break;
5447 }
5448
5449 case WE_WOWL:
5450 {
5451 switch (set_value)
5452 {
5453 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305454 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 break;
5456 case 0x01:
5457 case 0x02:
5458 case 0x03:
5459 enable_mp = (set_value & 0x01) ? 1 : 0;
5460 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005461 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5463 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5464 break;
5465 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005466 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 ret = -EINVAL;
5468 break;
5469 }
5470
5471 break;
5472 }
5473 case WE_SET_POWER:
5474 {
5475 switch (set_value)
5476 {
5477 case 0: //Full Power
5478 {
5479 struct statsContext context;
5480 eHalStatus status;
5481
5482 init_completion(&context.completion);
5483
5484 context.pAdapter = pAdapter;
5485 context.magic = POWER_CONTEXT_MAGIC;
5486
5487 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5488 iw_power_callback_fn, &context,
5489 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005490 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 {
5492 int lrc = wait_for_completion_interruptible_timeout(
5493 &context.completion,
5494 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005495
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 if (lrc <= 0)
5497 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005498 hddLog(VOS_TRACE_LEVEL_ERROR,
5499 "%s: SME %s while requesting fullpower",
5500 __func__, (0 == lrc) ?
5501 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 }
5503 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005504 /* either we have a response or we timed out. if we timed
5505 out there is a race condition such that the callback
5506 function could be executing at the same time we are. of
5507 primary concern is if the callback function had already
5508 verified the "magic" but had not yet set the completion
5509 variable when a timeout occurred. we serialize these
5510 activities by invalidating the magic while holding a
5511 shared spinlock which will cause us to block if the
5512 callback is currently executing */
5513 spin_lock(&hdd_context_lock);
5514 context.magic = 0;
5515 spin_unlock(&hdd_context_lock);
5516
Arif Hussain6d2a3322013-11-17 19:50:10 -08005517 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 break;
5519 }
5520 case 1: //Enable BMPS
5521 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5522 break;
5523 case 2: //Disable BMPS
5524 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5525 break;
5526 case 3: //Request Bmps
5527 {
5528 struct statsContext context;
5529 eHalStatus status;
5530
5531 init_completion(&context.completion);
5532
5533 context.pAdapter = pAdapter;
5534 context.magic = POWER_CONTEXT_MAGIC;
5535
5536 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5537 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005538 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 {
5540 int lrc = wait_for_completion_interruptible_timeout(
5541 &context.completion,
5542 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 if (lrc <= 0)
5544 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005545 hddLog(VOS_TRACE_LEVEL_ERROR,
5546 "%s: SME %s while requesting BMPS",
5547 __func__, (0 == lrc) ? "timeout" :
5548 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 }
5550 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005551 /* either we have a response or we timed out. if we
5552 timed out there is a race condition such that the
5553 callback function could be executing at the same
5554 time we are. of primary concern is if the callback
5555 function had already verified the "magic" but had
5556 not yet set the completion variable when a timeout
5557 occurred. we serialize these activities by
5558 invalidating the magic while holding a shared
5559 spinlock which will cause us to block if the
5560 callback is currently executing */
5561 spin_lock(&hdd_context_lock);
5562 context.magic = 0;
5563 spin_unlock(&hdd_context_lock);
5564
Arif Hussain6d2a3322013-11-17 19:50:10 -08005565 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 break;
5567 }
5568 case 4: //Enable IMPS
5569 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5570 break;
5571 case 5: //Disable IMPS
5572 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5573 break;
5574 case 6: //Enable Standby
5575 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5576 break;
5577 case 7: //Disable Standby
5578 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5579 break;
5580 case 8: //Request Standby
5581#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005582#endif
5583 break;
5584 case 9: //Start Auto Bmps Timer
5585 sme_StartAutoBmpsTimer(hHal);
5586 break;
5587 case 10://Stop Auto BMPS Timer
5588 sme_StopAutoBmpsTimer(hHal);
5589 break;
5590#ifdef CONFIG_HAS_EARLYSUSPEND
5591 case 11://suspend to standby
5592#ifdef CONFIG_HAS_EARLYSUSPEND
5593 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5594 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5596#endif
5597 break;
5598 case 12://suspend to deep sleep
5599#ifdef CONFIG_HAS_EARLYSUSPEND
5600 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5601 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5603#endif
5604 break;
5605 case 13://resume from suspend
5606#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005607#endif
5608 break;
5609#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005611 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 ret = -EINVAL;
5613 break;
5614 }
5615 break;
5616 }
5617
5618 case WE_SET_MAX_ASSOC:
5619 {
5620 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5621 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5622 {
5623 ret = -EINVAL;
5624 }
5625 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5626 set_value, NULL, eANI_BOOLEAN_FALSE)
5627 != eHAL_STATUS_SUCCESS )
5628 {
c_hpothub8245442013-11-20 23:41:09 +05305629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5630 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 ret = -EIO;
5632 }
5633 break;
5634 }
5635
5636 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5637 {
5638 if( 0 == set_value )
5639 {
5640 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5641 }
5642 else if ( 1 == set_value )
5643 {
5644 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5645 }
5646 else
5647 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005648 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 ret = -EINVAL;
5650 }
5651 break;
5652 }
5653
5654 case WE_SET_DATA_INACTIVITY_TO:
5655 {
5656 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5657 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5658 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5659 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5660 set_value,
5661 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5662 {
5663 hddLog(LOGE,"Failure: Could not pass on "
5664 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005665 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 ret = -EINVAL;
5667 }
5668 break;
5669 }
5670 case WE_SET_MAX_TX_POWER:
5671 {
5672 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5673 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5674
5675 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5676 __func__, set_value);
5677 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5678 eHAL_STATUS_SUCCESS )
5679 {
5680 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5681 __func__);
5682 return -EIO;
5683 }
5684
5685 break;
5686 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005687 case WE_SET_MAX_TX_POWER_2_4:
5688 {
5689 hddLog(VOS_TRACE_LEVEL_INFO,
5690 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5691 __func__, set_value);
5692 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5693 eHAL_STATUS_SUCCESS)
5694 {
5695 hddLog(VOS_TRACE_LEVEL_ERROR,
5696 "%s: Setting maximum tx power failed for 2.4 GHz band",
5697 __func__);
5698 return -EIO;
5699 }
5700
5701 break;
5702 }
5703 case WE_SET_MAX_TX_POWER_5_0:
5704 {
5705 hddLog(VOS_TRACE_LEVEL_INFO,
5706 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5707 __func__, set_value);
5708 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5709 eHAL_STATUS_SUCCESS)
5710 {
5711 hddLog(VOS_TRACE_LEVEL_ERROR,
5712 "%s: Setting maximum tx power failed for 5.0 GHz band",
5713 __func__);
5714 return -EIO;
5715 }
5716
5717 break;
5718 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 case WE_SET_HIGHER_DTIM_TRANSITION:
5720 {
5721 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5722 (set_value == eANI_BOOLEAN_TRUE)))
5723 {
5724 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5725 ret = -EINVAL;
5726 }
5727 else
5728 {
5729 if(pAdapter->higherDtimTransition != set_value)
5730 {
5731 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005732 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 }
5734 }
5735
5736 break;
5737 }
5738
5739 case WE_SET_TM_LEVEL:
5740 {
5741 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005742 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5744
5745 break;
5746 }
5747
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305748 case WE_ENABLE_STRICT_FCC_REG:
5749 {
5750 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5751 struct wiphy *wiphy = NULL;
5752 long lrc;
5753 int status;
5754
5755 wiphy = hddCtxt->wiphy;
5756 if(wiphy == NULL)
5757 {
5758 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5759 break;
5760 }
5761 init_completion(&hddCtxt->wiphy_channel_update_event);
5762
5763 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5764
5765 status = regulatory_hint(wiphy, "00");
5766 if(status < 0)
5767 {
5768 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5769 break;
5770 }
5771
5772 /* Wait for completion */
5773 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5774 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5775 if (lrc <= 0)
5776 {
5777 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5778 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5779 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5780 }
5781 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5782
5783 break;
5784 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005785 case WE_SET_DEBUG_LOG:
5786 {
5787 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5788 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5789 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5790 break;
5791 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305792#ifdef FEATURE_WLAN_TDLS
5793 case WE_SET_TDLS_OFF_CHAN:
5794 {
5795 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5797 __func__, set_value);
5798 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5799 break;
5800 }
5801 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5802 {
5803 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5805 __func__, set_value);
5806 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5807 break;
5808 }
5809 case WE_SET_TDLS_OFF_CHAN_MODE:
5810 {
5811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5812 __func__, set_value);
5813 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5814 break;
5815 }
5816#endif
Peng Xu2446a892014-09-05 17:21:18 +05305817 case WE_SET_SCAN_BAND_PREFERENCE:
5818 {
5819 tSmeConfigParams smeConfig;
5820 memset(&smeConfig, 0x00, sizeof(smeConfig));
5821 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5822 ret = -EINVAL;
5823 break;
5824 }
5825 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5826
5827 if (eCSR_BAND_ALL == set_value ||
5828 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5829 sme_GetConfigParam(hHal, &smeConfig);
5830 smeConfig.csrConfig.scanBandPreference = set_value;
5831
5832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5833 "set band scan preference = %d\n",
5834 smeConfig.csrConfig.scanBandPreference);
5835
5836 sme_UpdateConfig(hHal, &smeConfig);
5837 }
5838 else {
5839 ret = -EINVAL;
5840 }
5841 break;
5842 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305843 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5844 * connection happens so that the params can take effect during
5845 * association. Also this should not be used in STA+p2p concurrency
5846 * as the param will also effect the STA mode.
5847 */
5848 case WE_SET_MIRACAST_VENDOR_CONFIG:
5849 {
5850 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305851
Abhishek Singh01c73d12015-03-12 15:13:44 +05305852 hddLog(LOG1, FL(
5853 "Set Miracast vendor tuning %d"), set_value);
5854
5855 if (1 == set_value || 0 == set_value)
5856 {
5857 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5858 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5859 {
5860 hddLog( LOGE, FL("set vendor miracast config failed"));
5861 ret = -EIO;
5862 }
5863 }
5864 else
5865 {
5866 hddLog(LOGE,
5867 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5868 ret = -EINVAL;
5869 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305870 break;
5871 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305872
5873 case WE_GET_FRAME_LOG:
5874 {
5875 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5876 != VOS_STATUS_SUCCESS)
5877 {
5878 ret = -EINVAL;
5879 }
5880 break;
5881 }
5882
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305883 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5884 {
5885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5886 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5887 if (set_value == 0 || set_value == 1)
5888 {
5889 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5890 set_value);
5891 }
5892 else
5893 ret = -EINVAL;
5894
5895 break;
5896 }
Abhishek Singh41988ba2015-05-25 19:42:29 +05305897 /* Bit mask value to enable RTS/CTS for different modes
5898 * for 2.4 GHz, HT20 - 0x0001, for 2.4 GHz, HT40 - 0x0002
5899 * for 2.4 GHz, VHT20 - 0x0004, for 2.4 GHz, VHT40 - 0x0008
5900 * for 5 GHz, HT20 - 0x0100, for 5 GHz, HT40 - 0x0200
5901 * for 5 GHz, VHT20 - 0x0400, for 5 GHz, VHT40 - 0x0800
5902 * for 5 GHz, VHT80 - 0x1000
5903 */
5904 case WE_SET_RTS_CTS_HTVHT:
5905 {
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305906
Abhishek Singh41988ba2015-05-25 19:42:29 +05305907 hddLog( LOG1, FL("WE_SET_RTS_CTS_HTVHT set value %d"), set_value);
5908
5909 if (eHAL_STATUS_SUCCESS !=
5910 sme_SetRtsCtsHtVht( pHddCtx->hHal, set_value))
5911 {
5912 hddLog( LOGE, FL("set WE_SET_RTS_CTS_HTVHT failed"));
5913 ret = -EINVAL;
5914 }
5915 break;
5916 }
Katya Nigamf0511f62015-05-05 16:40:57 +05305917 case WE_SET_MONITOR_STATE:
5918 {
5919
5920 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
5921 if( pMonCtx == NULL )
5922 {
5923 hddLog(LOGE, "Monitor Context NULL");
5924 break;
5925 }
5926 pMonCtx->state = set_value;
5927 if( set_value )
5928 wlan_hdd_mon_poststartmsg(pMonCtx);
5929 else
5930 wlan_hdd_mon_poststopmsg();
5931
5932 break;
5933 }
5934
Jeff Johnson295189b2012-06-20 16:38:30 -07005935 default:
5936 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005937 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 sub_cmd, set_value);
5939 break;
5940 }
5941 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305942 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 return ret;
5944}
5945
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305946static int iw_setint_getnone(struct net_device *dev,
5947 struct iw_request_info *info,
5948 union iwreq_data *wrqu, char *extra)
5949{
5950 int ret;
5951
5952 vos_ssr_protect(__func__);
5953 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5954 vos_ssr_unprotect(__func__);
5955
5956 return 0;
5957}
Jeff Johnson295189b2012-06-20 16:38:30 -07005958/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305959static int __iw_setchar_getnone(struct net_device *dev,
5960 struct iw_request_info *info,
5961 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005962{
5963 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305964 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005966 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305967 hdd_adapter_t *pAdapter;
5968 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005969#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305970 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005971#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305972 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305973 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005974
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305975 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305976 pAdapter = (netdev_priv(dev));
5977 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005978 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5980 "%s: Adapter is NULL",__func__);
5981 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005982 }
5983
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305984 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5985 ret = wlan_hdd_validate_context(pHddCtx);
5986 if (0 != ret)
5987 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305988 return ret;
5989 }
5990#ifdef WLAN_FEATURE_VOWIFI
5991 pConfig = pHddCtx->cfg_ini;
5992#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305993 /* helper function to get iwreq_data with compat handling. */
5994 if (hdd_priv_get_data(&s_priv_data, wrqu))
5995 {
5996 return -EINVAL;
5997 }
5998
5999 /* make sure all params are correctly passed to function */
6000 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6001 {
6002 return -EINVAL;
6003 }
6004
6005 sub_cmd = s_priv_data.flags;
6006
Arif Hussain0273cba2014-01-07 20:58:29 -08006007 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05306008 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6009 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006010 if (NULL == pBuffer)
6011 {
6012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6013 "mem_alloc_copy_from_user_helper fail");
6014 return -ENOMEM;
6015 }
6016
6017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05306018 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6020 "%s: Received data %s", __func__, pBuffer);
6021
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 switch(sub_cmd)
6023 {
6024 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006026 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 break;
6028 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08006030 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 break;
6032#if defined WLAN_FEATURE_VOWIFI
6033 case WE_NEIGHBOR_REPORT_REQUEST:
6034 {
6035 tRrmNeighborReq neighborReq;
6036 tRrmNeighborRspCallbackInfo callbackInfo;
6037
6038 if (pConfig->fRrmEnable)
6039 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05306041 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 if( !neighborReq.no_ssid )
6043 {
Girish Gowli552fc072014-06-14 18:26:16 +05306044 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08006045 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 }
6047
6048 callbackInfo.neighborRspCallback = NULL;
6049 callbackInfo.neighborRspCallbackContext = NULL;
6050 callbackInfo.timeout = 5000; //5 seconds
6051 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
6052 }
6053 else
6054 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006055 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 ret = -EINVAL;
6057 }
6058 }
6059 break;
6060#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 case WE_SET_AP_WPS_IE:
6062 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05306063 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006066 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 if (VOS_STATUS_SUCCESS != vstatus)
6068 {
6069 ret = -EINVAL;
6070 }
6071 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306072 case WE_SET_ENCRYPT_MSG:
6073 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6074 if (NULL == pkt)
6075 {
6076 hddLog(VOS_TRACE_LEVEL_ERROR,
6077 "%s: vos_mem_alloc failed", __func__);
6078 return -ENOMEM;
6079 }
6080
6081 memset(pkt, 0, sizeof(tSirpkt80211));
6082
6083 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6084 hddLog(VOS_TRACE_LEVEL_ERROR,
6085 FL("Firmware is not DISA capable"));
6086 ret = -EINVAL;
6087 vos_mem_free(pkt);
6088 break;
6089 }
6090
6091 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6092
6093 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6094 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6095 if (eHAL_STATUS_SUCCESS != ret) {
6096 hddLog(VOS_TRACE_LEVEL_ERROR,
6097 FL("SENDEncryptMSG: fail to post WDA cmd"));
6098 ret = -EINVAL;
6099 }
6100 vos_mem_free(pkt);
6101
6102 break;
6103
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 default:
6105 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006106 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 ret = -EINVAL;
6108 break;
6109 }
6110 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006111 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306112
6113 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 return ret;
6115}
6116
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306117static int iw_setchar_getnone(struct net_device *dev,
6118 struct iw_request_info *info,
6119 union iwreq_data *wrqu, char *extra)
6120{
6121 int ret;
6122
6123 vos_ssr_protect(__func__);
6124 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6125 vos_ssr_unprotect(__func__);
6126
6127 return ret;
6128}
6129
Jeff Johnson295189b2012-06-20 16:38:30 -07006130/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306131static int __iw_setnone_getint(struct net_device *dev,
6132 struct iw_request_info *info,
6133 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006134{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306135 hdd_adapter_t *pAdapter;
6136 tHalHandle hHal;
6137 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 int *value = (int *)extra;
6139 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05306140 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006141
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306142 ENTER();
6143
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306144 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6145 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006146 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6148 "%s: Adapter is NULL",__func__);
6149 return -EINVAL;
6150 }
6151 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6152 ret = wlan_hdd_validate_context(pHddCtx);
6153 if (0 != ret)
6154 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306155 return ret;
6156 }
6157 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6158 if (NULL == hHal)
6159 {
6160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6161 "%s: Hal Context is NULL",__func__);
6162 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006164
6165 switch (value[0])
6166 {
6167 case WE_GET_11D_STATE:
6168 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006169 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306171
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6173
Arif Hussain6d2a3322013-11-17 19:50:10 -08006174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006175
6176 break;
6177 }
6178
6179 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 break;
6182
6183 case WE_PMC_STATE:
6184 {
6185 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 break;
6188 }
6189 case WE_GET_WLAN_DBG:
6190 {
6191 vos_trace_display();
6192 *value = 0;
6193 break;
6194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 case WE_GET_MAX_ASSOC:
6196 {
6197 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6198 {
c_hpothub8245442013-11-20 23:41:09 +05306199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6200 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 ret = -EIO;
6202 }
Girish Gowli385be612014-09-18 11:17:20 +05306203#ifdef WLAN_SOFTAP_VSTA_FEATURE
6204 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6205 {
6206 if (*value > VSTA_NUM_ASSOC_STA)
6207 {
6208 *value = VSTA_NUM_ASSOC_STA;
6209 }
6210 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6211 (*value > (VSTA_NUM_ASSOC_STA -
6212 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6213 {
6214 *value = (VSTA_NUM_ASSOC_STA -
6215 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6216 }
6217 }
6218 else
6219#endif
6220 {
6221 if (*value > NUM_ASSOC_STA)
6222 {
6223 *value = NUM_ASSOC_STA;
6224 }
6225 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6226 (*value > (NUM_ASSOC_STA -
6227 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6228 {
6229 *value = (NUM_ASSOC_STA -
6230 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6231 }
6232 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 break;
6234 }
6235
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 case WE_GET_WDI_DBG:
6237 {
6238 wpalTraceDisplay();
6239 *value = 0;
6240 break;
6241 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006242
6243 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6244 {
6245 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6246 break;
6247 }
6248 case WE_GET_CONCURRENCY_MODE:
6249 {
6250 *value = hdd_get_concurrency_mode ( );
6251
Arif Hussain6d2a3322013-11-17 19:50:10 -08006252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 break;
6254 }
6255
Peng Xu2446a892014-09-05 17:21:18 +05306256 case WE_GET_SCAN_BAND_PREFERENCE:
6257 {
6258 sme_GetConfigParam(hHal, &smeConfig);
6259 *value = smeConfig.csrConfig.scanBandPreference;
6260
6261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6262 "scanBandPreference = %d\n", *value);
6263 break;
6264 }
6265
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 default:
6267 {
6268 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6269 break;
6270 }
6271 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306272 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 return ret;
6274}
6275
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306276static int iw_setnone_getint(struct net_device *dev,
6277 struct iw_request_info *info,
6278 union iwreq_data *wrqu, char *extra)
6279{
6280 int ret;
6281
6282 vos_ssr_protect(__func__);
6283 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6284 vos_ssr_unprotect(__func__);
6285
6286 return ret;
6287
6288}
Jeff Johnson295189b2012-06-20 16:38:30 -07006289/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306290int __iw_set_three_ints_getnone(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;
6295 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006296 int *value = (int *)extra;
6297 int sub_cmd = value[0];
6298 int ret = 0;
6299
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306300 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306301 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6302 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006303 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6305 "%s: Adapter is NULL",__func__);
6306 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006307 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306308 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6309 ret = wlan_hdd_validate_context(pHddCtx);
6310 if (0 != ret)
6311 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306312 return ret;
6313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 switch(sub_cmd)
6315 {
6316 case WE_SET_WLAN_DBG:
6317 {
6318 vos_trace_setValue( value[1], value[2], value[3]);
6319 break;
6320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 case WE_SET_WDI_DBG:
6322 {
6323 wpalTraceSetLevel( value[1], value[2], value[3]);
6324 break;
6325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 case WE_SET_SAP_CHANNELS:
6327 {
6328 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6329 break;
6330 }
6331
6332 default:
6333 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006334 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 break;
6336 }
6337 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306338 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 return ret;
6340}
6341
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306342int iw_set_three_ints_getnone(struct net_device *dev,
6343 struct iw_request_info *info,
6344 union iwreq_data *wrqu, char *extra)
6345{
6346 int ret;
6347
6348 vos_ssr_protect(__func__);
6349 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6350 vos_ssr_unprotect(__func__);
6351
6352 return ret;
6353}
6354
6355static int __iw_get_char_setnone(struct net_device *dev,
6356 struct iw_request_info *info,
6357 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006358{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306359 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306361 hdd_context_t *pHddCtx;
6362 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006363#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006364 hdd_wext_state_t *pWextState;
6365#endif
6366
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306367 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306368 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006369 if (pAdapter == NULL)
6370 {
6371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6372 "%s: pAdapter is NULL!", __func__);
6373 return -EINVAL;
6374 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306375 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6376 ret = wlan_hdd_validate_context(pHddCtx);
6377 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006378 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306379 return ret;
6380 }
6381#ifdef WLAN_FEATURE_11W
6382 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6383 if (NULL == pWextState)
6384 {
6385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6386 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006387 return -EINVAL;
6388 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306389#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006390
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 switch(sub_cmd)
6392 {
6393 case WE_WLAN_VERSION:
6394 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006395 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 break;
6397 }
6398
6399 case WE_GET_STATS:
6400 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306401 tHalHandle hHal = NULL;
6402 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6404 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6405 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6406
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306407
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 snprintf(extra, WE_MAX_STR_LEN,
6409 "\nTransmit"
6410 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6411 "\n dropped BK %u, BE %u, VI %u, VO %u"
6412 "\n classified BK %u, BE %u, VI %u, VO %u"
6413 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6414 "\n queued BK %u, BE %u, VI %u, VO %u"
6415 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006416 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 "\n fetched BK %u, BE %u, VI %u, VO %u"
6418 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6419 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006420 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 "\n flushed BK %u, BE %u, VI %u, VO %u"
6422 "\n\nReceive"
6423 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6424 "\n\nResetsStats"
6425 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6426 "\n",
6427 pStats->txXmitCalled,
6428 pStats->txXmitDropped,
6429 pStats->txXmitBackPressured,
6430 pStats->txXmitQueued,
6431
6432 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6433 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6434 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6435 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6436
6437 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6438 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6439 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6440 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6441
6442 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6443 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6444 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6445 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6446
6447 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6448 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6449 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6450 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6451
6452 pStats->txFetched,
6453 pStats->txFetchEmpty,
6454 pStats->txFetchLowResources,
6455 pStats->txFetchDequeueError,
6456
6457 pStats->txFetchDequeued,
6458 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006459 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 pStats->txCompleted,
6461 pStats->txFlushed,
6462
6463 pStats->txFetchedAC[WLANTL_AC_BK],
6464 pStats->txFetchedAC[WLANTL_AC_BE],
6465 pStats->txFetchedAC[WLANTL_AC_VI],
6466 pStats->txFetchedAC[WLANTL_AC_VO],
6467
6468 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6469 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6470 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6471 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6472
6473 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6474 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6475 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6476 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6477
Ravi Joshi41914632013-10-21 23:02:21 -07006478 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6479 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6480 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6481 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6482
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 pStats->txFlushedAC[WLANTL_AC_BK],
6484 pStats->txFlushedAC[WLANTL_AC_BE],
6485 pStats->txFlushedAC[WLANTL_AC_VI],
6486 pStats->txFlushedAC[WLANTL_AC_VO],
6487
6488 pStats->rxChains,
6489 pStats->rxPackets,
6490 pStats->rxDropped,
6491 pStats->rxDelivered,
6492 pStats->rxRefused,
6493
6494 pResetStats->totalLogpResets,
6495 pResetStats->totalCMD53Failures,
6496 pResetStats->totalMutexReadFailures,
6497 pResetStats->totalMIFErrorFailures,
6498 pResetStats->totalFWHearbeatFailures,
6499 pResetStats->totalUnknownExceptions
6500 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306501 wrqu->data.length = strlen(extra);
6502
6503 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6504
6505 if (hHal)
6506 pMac = PMAC_STRUCT( hHal );
6507
6508 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6509 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6510 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306511 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6512 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6513 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6514 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306515 "\n",
6516 pMac->pmm.BmpscntSleep,
6517 pMac->pmm.BmpscntAwake,
6518 pMac->pmm.BmpsSleeReqFailCnt,
6519 pMac->pmm.BmpsWakeupReqFailCnt,
6520 pMac->pmm.ImpsCntSleep,
6521 pMac->pmm.ImpsCntAwake,
6522 pMac->pmm.ImpsSleepErrCnt,
6523 pMac->pmm.ImpsWakeupErrCnt,
6524 pMac->pmm.ImpsLastErr
6525 );
6526 }
6527
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 wrqu->data.length = strlen(extra)+1;
6529 break;
6530 }
6531
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306532/* The case prints the current state of the HDD, SME, CSR, PE, TL
6533 *it can be extended for WDI Global State as well.
6534 *And currently it only checks P2P_CLIENT adapter.
6535 *P2P_DEVICE and P2P_GO have not been added as of now.
6536*/
6537 case WE_GET_STATES:
6538 {
6539 int buf = 0, len = 0;
6540 int adapter_num = 0;
6541 int count = 0, check = 1;
6542
6543 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006544 tHalHandle hHal = NULL;
6545 tpAniSirGlobal pMac = NULL;
6546 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306547
6548 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6549 hdd_adapter_t *useAdapter = NULL;
6550
6551 /* Print wlan0 or p2p0 states based on the adapter_num
6552 *by using the correct adapter
6553 */
6554 while ( adapter_num < 2 )
6555 {
6556 if ( WLAN_ADAPTER == adapter_num )
6557 {
6558 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006559 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306560 "\n\n wlan0 States:-");
6561 len += buf;
6562 }
6563 else if ( P2P_ADAPTER == adapter_num )
6564 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006565 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306566 "\n\n p2p0 States:-");
6567 len += buf;
6568
6569 if( !pHddCtx )
6570 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006571 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306572 "\n pHddCtx is NULL");
6573 len += buf;
6574 break;
6575 }
6576
6577 /*Printing p2p0 states only in the case when the device is
6578 configured as a p2p_client*/
6579 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6580 if ( !useAdapter )
6581 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006582 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306583 "\n Device not configured as P2P_CLIENT.");
6584 len += buf;
6585 break;
6586 }
6587 }
6588
6589 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006590 if (!hHal) {
6591 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6592 "\n pMac is NULL");
6593 len += buf;
6594 break;
6595 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306596 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006597 if (!pMac) {
6598 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6599 "\n pMac is NULL");
6600 len += buf;
6601 break;
6602 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306603 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6604 if( !pHddStaCtx )
6605 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006606 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306607 "\n pHddStaCtx is NULL");
6608 len += buf;
6609 break;
6610 }
6611
6612 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6613
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006614 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306615 "\n HDD Conn State - %s "
6616 "\n \n SME State:"
6617 "\n Neighbour Roam State - %s"
6618 "\n CSR State - %s"
6619 "\n CSR Substate - %s"
6620 "\n \n TL STA %d State: %s",
6621 macTraceGetHDDWlanConnState(
6622 pHddStaCtx->conn_info.connState),
6623 macTraceGetNeighbourRoamState(
6624 pMac->roam.neighborRoamInfo.neighborRoamState),
6625 macTraceGetcsrRoamState(
6626 pMac->roam.curState[useAdapter->sessionId]),
6627 macTraceGetcsrRoamSubState(
6628 pMac->roam.curSubState[useAdapter->sessionId]),
6629 pHddStaCtx->conn_info.staId[0],
6630 macTraceGetTLState(tlState)
6631 );
6632 len += buf;
6633 adapter_num++;
6634 }
6635
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006636 if (pMac) {
6637 /* Printing Lim State starting with global lim states */
6638 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6639 "\n \n LIM STATES:-"
6640 "\n Global Sme State - %s "\
6641 "\n Global mlm State - %s "\
6642 "\n",
6643 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6644 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6645 );
6646 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306647
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006648 /*printing the PE Sme and Mlm states for valid lim sessions*/
6649 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306650 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006651 if ( pMac->lim.gpSession[count].valid )
6652 {
6653 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6654 "\n Lim Valid Session %d:-"
6655 "\n PE Sme State - %s "
6656 "\n PE Mlm State - %s "
6657 "\n",
6658 check,
6659 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6660 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6661 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306662
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006663 len += buf;
6664 check++;
6665 }
6666 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306667 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306668 }
6669
6670 wrqu->data.length = strlen(extra)+1;
6671 break;
6672 }
6673
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 case WE_GET_CFG:
6675 {
6676 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6677 wrqu->data.length = strlen(extra)+1;
6678 break;
6679 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006680#ifdef WLAN_FEATURE_11AC
6681 case WE_GET_RSSI:
6682 {
6683 v_S7_t s7Rssi = 0;
6684 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6685 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6686 wrqu->data.length = strlen(extra)+1;
6687 break;
6688 }
6689#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306690
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006691#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006692 case WE_GET_ROAM_RSSI:
6693 {
6694 v_S7_t s7Rssi = 0;
6695 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6696 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6697 wrqu->data.length = strlen(extra)+1;
6698 break;
6699 }
6700#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 case WE_GET_WMM_STATUS:
6702 {
6703 snprintf(extra, WE_MAX_STR_LEN,
6704 "\nDir: 0=up, 1=down, 3=both\n"
6705 "|------------------------|\n"
6706 "|AC | ACM |Admitted| Dir |\n"
6707 "|------------------------|\n"
6708 "|VO | %d | %3s | %d |\n"
6709 "|VI | %d | %3s | %d |\n"
6710 "|BE | %d | %3s | %d |\n"
6711 "|BK | %d | %3s | %d |\n"
6712 "|------------------------|\n",
6713 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6714 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6715 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6716 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6717 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6718 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6719 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6720 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6721 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6722 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6723 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6724 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6725
Jeff Johnsone7245742012-09-05 17:12:55 -07006726
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 wrqu->data.length = strlen(extra)+1;
6728 break;
6729 }
6730 case WE_GET_CHANNEL_LIST:
6731 {
6732 VOS_STATUS status;
6733 v_U8_t i, len;
6734 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306735 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6736 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6737 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 tChannelListInfo channel_list;
6739
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006740 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006742 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006744 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 return -EINVAL;
6746 }
6747 buf = extra;
6748
6749 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006750 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6751 * needed = 5 * number of channels. Check ifsufficient
6752 * buffer is available and then proceed to fill the buffer.
6753 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6755 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006756 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006757 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006758 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 return -EINVAL;
6760 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006761 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6762 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306763 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6764 {
6765 //Printing Country code in getChannelList
6766 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6767 {
6768 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6769 "%c ", pBuf[i]);
6770 }
6771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 for(i = 0 ; i < channel_list.num_channels; i++)
6773 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006774 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 }
6777 wrqu->data.length = strlen(extra)+1;
6778
6779 break;
6780 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006781#ifdef FEATURE_WLAN_TDLS
6782 case WE_GET_TDLS_PEERS:
6783 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006784 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006785 break;
6786 }
6787#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006788#ifdef WLAN_FEATURE_11W
6789 case WE_GET_11W_INFO:
6790 {
6791 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6792
6793 snprintf(extra, WE_MAX_STR_LEN,
6794 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6795 "\n Number of Unprotected Disassocs %d"
6796 "\n Number of Unprotected Deauths %d",
6797 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6798 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6799 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6800 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6801 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6802
6803 wrqu->data.length = strlen(extra)+1;
6804 break;
6805 }
6806#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306807 case WE_GET_SNR:
6808 {
6809 v_S7_t s7snr = 0;
6810 int status = 0;
6811 hdd_context_t *pHddCtx;
6812 hdd_station_ctx_t *pHddStaCtx;
6813
6814 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6815 status = wlan_hdd_validate_context(pHddCtx);
6816 if (0 != status)
6817 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306818 return status;
6819 }
6820
6821 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6822
6823 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6824 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6825 {
6826 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6827 " ConnectionState-%d", __func__,
6828 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6829 pHddStaCtx->conn_info.connState);
6830 return -ENONET;
6831 }
6832
6833 /*update the stats in TL*/
6834 wlan_hdd_get_station_stats(pAdapter);
6835 wlan_hdd_get_snr(pAdapter, &s7snr);
6836 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6837 wrqu->data.length = strlen(extra) + 1;
6838 break;
6839 }
6840
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306841 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006843 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006844 break;
6845 }
6846 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306847 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006848 return 0;
6849}
6850
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306851static int iw_get_char_setnone(struct net_device *dev,
6852 struct iw_request_info *info,
6853 union iwreq_data *wrqu, char *extra)
6854{
6855 int ret;
6856
6857 vos_ssr_protect(__func__);
6858 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6859 vos_ssr_unprotect(__func__);
6860
6861 return ret;
6862}
6863
Jeff Johnson295189b2012-06-20 16:38:30 -07006864/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306865static int __iw_setnone_getnone(struct net_device *dev,
6866 struct iw_request_info *info,
6867 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006868{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306869 hdd_adapter_t *pAdapter;
6870 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306871 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006872 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306873 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006874
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306875 ENTER();
6876
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306877 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6878 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006879 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6881 "%s: Adapter is NULL",__func__);
6882 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006883 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306884 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6885 ret = wlan_hdd_validate_context(pHddCtx);
6886 if (0 != ret)
6887 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306888 return ret;
6889 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306890 /* helper function to get iwreq_data with compat handling. */
6891 if (hdd_priv_get_data(&s_priv_data, wrqu))
6892 {
6893 return -EINVAL;
6894 }
6895
6896 sub_cmd = s_priv_data.flags;
6897
Jeff Johnson295189b2012-06-20 16:38:30 -07006898 switch (sub_cmd)
6899 {
6900 case WE_CLEAR_STATS:
6901 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6904 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6905 break;
6906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 case WE_INIT_AP:
6908 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306909 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6910
6911 /* As Soft AP mode might been changed to STA already with
6912 * killing of Hostapd, need to find the adpater by name
6913 * rather than mode */
6914 hdd_adapter_t* pAdapter_to_stop =
6915 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6916 if( pAdapter_to_stop )
6917 {
6918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6919 "Adapter with name softap.0 already "
6920 "exist, ignoring the request.\nRemove the "
6921 "adapter and try again\n");
6922 break;
6923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 pr_info("Init AP trigger\n");
6925 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6926 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6927 break;
6928 }
6929 case WE_STOP_AP:
6930 {
6931 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6932 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6933 * this is a dead code and need to find the adpater by name rather than mode */
6934 hdd_adapter_t* pAdapter_to_stop =
6935 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6936 if( pAdapter_to_stop )
6937 {
6938 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6939
6940 pr_info("Stopping AP mode\n");
6941
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306942 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6943 {
6944 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6945 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6946 }
6947
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306949 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306950 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6952
6953 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6954 pAdapter_to_stop->macAddressCurrent.bytes);
6955 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6956 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306957
6958 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6959 {
6960 /* put the device back into BMPS */
6961 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 }
6964 else
6965 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006966 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 }
6968
6969 break;
6970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006971#ifdef WLAN_BTAMP_FEATURE
6972 case WE_ENABLE_AMP:
6973 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 WLANBAP_RegisterWithHCI(pAdapter);
6976 break;
6977 }
6978 case WE_DISABLE_AMP:
6979 {
6980 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6981 VOS_STATUS status;
6982
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006984
6985 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6986 status = WLANBAP_StopAmp();
6987 if(VOS_STATUS_SUCCESS != status )
6988 {
6989 pHddCtx->isAmpAllowed = VOS_TRUE;
6990 hddLog(VOS_TRACE_LEVEL_FATAL,
6991 "%s: Failed to stop AMP", __func__);
6992 }
6993 else
6994 {
6995 //a state m/c implementation in PAL is TBD to avoid this delay
6996 msleep(500);
6997 pHddCtx->isAmpAllowed = VOS_FALSE;
6998 WLANBAP_DeregisterFromHCI();
6999 }
7000
7001 break;
7002 }
7003#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007004 case WE_ENABLE_DXE_STALL_DETECT:
7005 {
schang6295e542013-03-12 15:31:23 -07007006 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7007 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007008 break;
7009 }
7010 case WE_DISPLAY_DXE_SNAP_SHOT:
7011 {
schang6295e542013-03-12 15:31:23 -07007012 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7013 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007014 break;
7015 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307016 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
7017 {
7018 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
7019 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05307020 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307021 break;
7022 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307023
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307024 case WE_SET_REASSOC_TRIGGER:
7025 {
7026 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7027 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7028 v_U32_t roamId = 0;
7029 tCsrRoamModifyProfileFields modProfileFields;
7030 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
7031 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
7032 return 0;
7033 }
7034
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307035 case WE_STOP_OBSS_SCAN:
7036 {
7037 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
7038 2.OBSS scan is stopped by Firmware during the disassociation
7039 3.OBSS stop comamnd is added for debugging purpose*/
7040 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7041 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007042
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307043 if (pAdapter == NULL)
7044 {
7045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7046 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307047 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307048 }
7049 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
7050 if (pMac == NULL)
7051 {
7052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7053 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05307054 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05307055 }
7056 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
7057 }
7058 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05307059 case WE_DUMP_ROAM_TIMER_LOG:
7060 {
7061 vos_dump_roam_time_log_service();
7062 break;
7063 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05307064
Mukul Sharma84f27252014-07-14 18:11:42 +05307065 case WE_RESET_ROAM_TIMER_LOG:
7066 {
7067 vos_reset_roam_timer_log();
7068 break;
7069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 default:
7071 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007072 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007073 break;
7074 }
7075 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307076 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007077 return ret;
7078}
7079
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307080static int iw_setnone_getnone(struct net_device *dev,
7081 struct iw_request_info *info,
7082 union iwreq_data *wrqu, char *extra)
7083{
7084 int ret;
7085
7086 vos_ssr_protect(__func__);
7087 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7088 vos_ssr_unprotect(__func__);
7089
7090 return ret;
7091}
7092
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307093void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7094{
7095 /*
7096 * Function to display HDD WMM information
7097 * for Tx Queues.
7098 * Prints globala as well as per client depending
7099 * whether the clients are registered or not.
7100 */
7101 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307102 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7103 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307104 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7105 hdd_ibss_peer_info_t *pPeerInfo;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307106
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307107 for ( i=0; i< NUM_TX_QUEUES; i++)
7108 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307109 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307110
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007111 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307112 i, pAdapter->wmm_tx_queue[i].count,
7113 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307114 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307115 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307116 if(pSapCtx == NULL){
7117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7118 FL("psapCtx is NULL"));
7119 return;
7120 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307121
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307122 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307123 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7124 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307125 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307126 {
7127 hddLog(LOGE, "******STAIndex: %d*********", i);
7128 for ( j=0; j< NUM_TX_QUEUES; j++)
7129 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307130 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007131 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307132 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
7133 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
7134 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
7135 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307136 }
7137 }
7138 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307139 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307140
Katya Nigam1fd24402015-02-16 14:52:19 +05307141 if(pHddStaCtx == NULL){
7142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7143 FL("pHddStaCtx is NULL"));
7144 return;
7145 }
7146
7147 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7148 if(pPeerInfo == NULL){
7149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7150 FL("ppeerinfo is NULL"));
7151 return;
7152 }
7153
7154 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7155 {
7156 if(pPeerInfo->ibssStaInfo[i].isUsed)
7157 {
7158 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7159 for ( j=0; j< NUM_TX_QUEUES; j++)
7160 {
7161 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7162 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7163 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7164 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7165 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7166 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7167 }
7168 }
7169 }
7170
7171
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307172}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307173static int __iw_set_var_ints_getnone(struct net_device *dev,
7174 struct iw_request_info *info,
7175 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007176{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307177 hdd_adapter_t *pAdapter;
7178 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307179 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307180 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007181 hdd_station_ctx_t *pStaCtx = NULL ;
Katya Nigamf0511f62015-05-05 16:40:57 +05307182 hdd_mon_ctx_t *pMonCtx = NULL;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307183 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007184 hdd_ap_ctx_t *pAPCtx = NULL;
Katya Nigamf0511f62015-05-05 16:40:57 +05307185 v_CONTEXT_t pVosContext;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007186 int cmd = 0;
7187 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307188 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007189
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307190 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307191 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307192 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7194 "%s: NULL extra buffer pointer", __func__);
7195 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307196 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307197 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7198 if (NULL == pAdapter)
7199 {
7200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7201 "%s: Adapter is NULL",__func__);
7202 return -EINVAL;
7203 }
Katya Nigamf0511f62015-05-05 16:40:57 +05307204 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307205 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7206 ret = wlan_hdd_validate_context(pHddCtx);
7207 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007208 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307209 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007210 }
Katya Nigameae74b62015-05-28 17:19:16 +05307211 if( VOS_MONITOR_MODE != hdd_get_conparam())
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307212 {
Katya Nigameae74b62015-05-28 17:19:16 +05307213 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7214 if (NULL == hHal)
7215 {
7216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7217 "%s: Hal Context is NULL",__func__);
7218 return -EINVAL;
7219 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307220 }
7221 sub_cmd = wrqu->data.flags;
7222
7223 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7224
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007225
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007226 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7227 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7228 {
7229 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7230 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7231 {
7232 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7233 staId = pStaCtx->conn_info.staId[0];
7234 }
7235 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7236 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7237 {
7238 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7239 staId = pAPCtx->uBCStaId;
7240 }
7241 else
7242 {
7243 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7244 return 0;
7245 }
7246 }
7247
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 switch (sub_cmd)
7249 {
7250 case WE_LOG_DUMP_CMD:
7251 {
7252 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007253 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 apps_args[3], apps_args[4]);
7255
7256 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7257 apps_args[3], apps_args[4]);
7258
7259 }
7260 break;
7261
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 case WE_P2P_NOA_CMD:
7263 {
7264 p2p_app_setP2pPs_t p2pNoA;
7265
7266 p2pNoA.opp_ps = apps_args[0];
7267 p2pNoA.ctWindow = apps_args[1];
7268 p2pNoA.duration = apps_args[2];
7269 p2pNoA.interval = apps_args[3];
7270 p2pNoA.count = apps_args[4];
7271 p2pNoA.single_noa_duration = apps_args[5];
7272 p2pNoA.psSelection = apps_args[6];
7273
7274 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7275 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007276 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007277 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7278
7279 hdd_setP2pPs(dev, &p2pNoA);
7280
7281 }
7282 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007283
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307284 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7285 {
7286 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7287 __func__, apps_args[0], apps_args[1]);
7288 vosTraceEnable(apps_args[0], apps_args[1]);
7289 }
7290 break;
7291
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007292 case WE_MTRACE_DUMP_CMD:
7293 {
7294 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7295 "bitmask_of_module %d ",
7296 __func__, apps_args[0], apps_args[1], apps_args[2],
7297 apps_args[3]);
7298 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7299 apps_args[2], apps_args[3]);
7300
7301 }
7302 break;
7303
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007304 case WE_MCC_CONFIG_CREDENTIAL :
7305 {
7306 cmd = 287; //Command should be updated if there is any change
7307 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007308 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007309 {
7310 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7311 }
7312 else
7313 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007314 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007315 return 0;
7316 }
7317 }
7318 break;
7319
7320 case WE_MCC_CONFIG_PARAMS :
7321 {
7322 cmd = 288; //command Should be updated if there is any change
7323 // in the Riva dump command
7324 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7325 }
7326 break;
7327
Chilam NG571c65a2013-01-19 12:27:36 +05307328#ifdef FEATURE_WLAN_TDLS
7329 case WE_TDLS_CONFIG_PARAMS :
7330 {
7331 tdls_config_params_t tdlsParams;
7332
Chilam Ng01120412013-02-19 18:32:21 -08007333 tdlsParams.tdls = apps_args[0];
7334 tdlsParams.tx_period_t = apps_args[1];
7335 tdlsParams.tx_packet_n = apps_args[2];
7336 tdlsParams.discovery_period_t = apps_args[3];
7337 tdlsParams.discovery_tries_n = apps_args[4];
7338 tdlsParams.idle_timeout_t = apps_args[5];
7339 tdlsParams.idle_packet_n = apps_args[6];
7340 tdlsParams.rssi_hysteresis = apps_args[7];
7341 tdlsParams.rssi_trigger_threshold = apps_args[8];
7342 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307343
Chilam Ng01120412013-02-19 18:32:21 -08007344 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307345 }
7346 break;
7347#endif
Katya Nigamf0511f62015-05-05 16:40:57 +05307348 case WE_CONFIGURE_MONITOR_MODE:
7349 {
7350 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7351 if( pMonCtx == NULL )
7352 {
7353 hddLog(LOGE, "Monitor Context NULL");
7354 break;
7355 }
7356 hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
7357 __func__, apps_args[0], apps_args[1], apps_args[2],
7358 apps_args[3], apps_args[4]);
7359 /* Input Validation part of FW */
7360 pMonCtx->ChannelNo = apps_args[0];
7361 pMonCtx->ChannelBW = apps_args[1];
7362 pMonCtx->crcCheckEnabled = apps_args[2];
7363 wlan_hdd_mon_set_typesubtype( pMonCtx,apps_args[3]);
7364 pMonCtx->is80211to803ConReq = apps_args[4];
7365 WLANTL_SetIsConversionReq(pVosContext,apps_args[4]);
7366 if( pMonCtx->is80211to803ConReq )
7367 pAdapter->dev->type = ARPHRD_ETHER;
7368 else
7369 pAdapter->dev->type = ARPHRD_IEEE80211_RADIOTAP;
7370 if( (apps_args[3]!= 100 && apps_args[3]!= 0) && apps_args[4] )
7371 {
7372 hddLog(LOGE, "%s: Filtering data packets as management and control"
7373 " cannot be converted to 802.3 ",__func__);
7374 pMonCtx->typeSubtypeBitmap = 0xFFFF00000000;
7375 }
7376 if( pMonCtx->state )
7377 wlan_hdd_mon_poststartmsg(pMonCtx);
7378 }
7379 break;
7380
7381 case WE_SET_MONITOR_MODE_FILTER:
7382 {
7383 pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
7384 if( pMonCtx == NULL )
7385 {
7386 hddLog(LOGE, "Monitor Context NULL");
7387 break;
7388 }
7389 /* Input Validation Part of FW */
7390 pMonCtx->numOfMacFilters=1;
7391 pMonCtx->mmFilters[0].macAddr.bytes[0]=apps_args[0];
7392 pMonCtx->mmFilters[0].macAddr.bytes[1]=apps_args[1];
7393 pMonCtx->mmFilters[0].macAddr.bytes[2]=apps_args[2];
7394 pMonCtx->mmFilters[0].macAddr.bytes[3]=apps_args[3];
7395 pMonCtx->mmFilters[0].macAddr.bytes[4]=apps_args[4];
7396 pMonCtx->mmFilters[0].macAddr.bytes[5]=apps_args[5];
7397 pMonCtx->mmFilters[0].isA1filter = apps_args[6];
7398 pMonCtx->mmFilters[0].isA2filter = apps_args[7];
7399 pMonCtx->mmFilters[0].isA3filter = apps_args[8];
7400 hddLog(LOG1, "%s: Monitor Filter: %pM A1=%d A2=%d A3=%d ",
7401 __func__, pMonCtx->mmFilters[0].macAddr.bytes,
7402 apps_args[6], apps_args[7], apps_args[8]);
7403 if( pMonCtx->state )
7404 wlan_hdd_mon_poststartmsg(pMonCtx);
7405 }
7406 break;
7407
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 default:
7409 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007410 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7411 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 }
7413 break;
7414 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307415 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 return 0;
7417}
7418
Girish Gowlifb9758e2014-11-19 15:19:17 +05307419static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7420 struct iw_request_info *info,
7421 union iwreq_data *wrqu, char *extra)
7422{
7423 int ret;
7424 union iwreq_data u_priv_wrqu;
7425 int apps_args[MAX_VAR_ARGS] = {0};
7426 int num_args;
7427
7428 /* helper function to get iwreq_data with compat handling. */
7429 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7430 {
7431 return -EINVAL;
7432 }
7433
7434 if (NULL == u_priv_wrqu.data.pointer)
7435 {
7436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7437 "%s: NULL data pointer", __func__);
7438 return -EINVAL;
7439 }
7440
7441 num_args = u_priv_wrqu.data.length;
7442 if (num_args > MAX_VAR_ARGS)
7443 {
7444 num_args = MAX_VAR_ARGS;
7445 }
7446
7447 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7448 (sizeof(int)) * num_args))
7449 {
7450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7451 "%s: failed to copy data from user buffer", __func__);
7452 return -EFAULT;
7453 }
7454
7455 vos_ssr_protect(__func__);
7456 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7457 (char *)&apps_args);
7458 vos_ssr_unprotect(__func__);
7459
7460 return ret;
7461}
7462
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307463int iw_set_var_ints_getnone(struct net_device *dev,
7464 struct iw_request_info *info,
7465 union iwreq_data *wrqu, char *extra)
7466{
7467 int ret;
7468 vos_ssr_protect(__func__);
7469 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7470 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007471
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307472 return ret;
7473}
7474
7475static int __iw_add_tspec(struct net_device *dev,
7476 struct iw_request_info *info,
7477 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007478{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307479 hdd_adapter_t *pAdapter;
7480 hdd_station_ctx_t *pHddStaCtx;
7481 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7483 int params[HDD_WLAN_WMM_PARAM_COUNT];
7484 sme_QosWmmTspecInfo tSpec;
7485 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307486 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307487 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007488
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307489 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307490 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7491 if (NULL == pAdapter)
7492 {
7493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7494 "%s: Adapter is NULL",__func__);
7495 return -EINVAL;
7496 }
7497 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7498 ret = wlan_hdd_validate_context(pHddCtx);
7499 if (0 != ret)
7500 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307501 return ret;
7502 }
7503 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7504 if (NULL == pHddStaCtx)
7505 {
7506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7507 "%s: STA Context is NULL",__func__);
7508 return -EINVAL;
7509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 // make sure the application is sufficiently priviledged
7511 // note that the kernel will do this for "set" ioctls, but since
7512 // this ioctl wants to return status to user space it must be
7513 // defined as a "get" ioctl
7514 if (!capable(CAP_NET_ADMIN))
7515 {
7516 return -EPERM;
7517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007518 // we must be associated in order to add a tspec
7519 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7520 {
7521 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7522 return 0;
7523 }
7524
7525 // since we are defined to be a "get" ioctl, and since the number
7526 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307527 // will pass down in the iwreq_data, we must copy the "set" params.
7528 // We must handle the compat for iwreq_data in 32U/64K environment.
7529
7530 // helper fucntion to get iwreq_data with compat handling.
7531 if (hdd_priv_get_data(&s_priv_data, wrqu))
7532 {
7533 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7534 return 0;
7535 }
7536
7537 // make sure all params are correctly passed to function
7538 if ((NULL == s_priv_data.pointer) ||
7539 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7540 {
7541 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7542 return 0;
7543 }
7544
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307546 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007547 {
7548 // hmmm, can't get them
7549 return -EIO;
7550 }
7551
7552 // clear the tspec
7553 memset(&tSpec, 0, sizeof(tSpec));
7554
7555 // validate the handle
7556 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7557 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7558 {
7559 // that one is reserved
7560 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7561 return 0;
7562 }
7563
7564 // validate the TID
7565 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7566 {
7567 // out of range
7568 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7569 return 0;
7570 }
7571 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7572
7573 // validate the direction
7574 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7575 {
7576 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7577 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7578 break;
7579
7580 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7581 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7582 break;
7583
7584 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7585 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7586 break;
7587
7588 default:
7589 // unknown
7590 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7591 return 0;
7592 }
7593
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307594 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7595
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 // validate the user priority
7597 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7598 {
7599 // out of range
7600 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7601 return 0;
7602 }
7603 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307604 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7605 {
7606 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7607 return 0;
7608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007609
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7611 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7612 tSpec.ts_info.psb, tSpec.ts_info.up);
7613
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7615 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7616 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7617 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7618 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7619 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7620 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7621 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7622 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7623 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7624 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7625 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7626
7627 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7628
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307629 // Save the expected UAPSD settings by application, this will be needed
7630 // when re-negotiating UAPSD settings during BT Coex cases.
7631 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7632
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 // validate the ts info ack policy
7634 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7635 {
7636 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7637 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7638 break;
7639
7640 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7641 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7642 break;
7643
7644 default:
7645 // unknown
7646 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7647 return 0;
7648 }
7649
7650 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307651
7652 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 return 0;
7654}
7655
7656
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307657static int iw_add_tspec(struct net_device *dev,
7658 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007659 union iwreq_data *wrqu, char *extra)
7660{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307661 int ret;
7662
7663 vos_ssr_protect(__func__);
7664 ret = __iw_add_tspec(dev, info, wrqu, extra);
7665 vos_ssr_unprotect(__func__);
7666
7667 return ret;
7668}
7669
7670static int __iw_del_tspec(struct net_device *dev,
7671 struct iw_request_info *info,
7672 union iwreq_data *wrqu, char *extra)
7673{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307674 hdd_adapter_t *pAdapter;
7675 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 int *params = (int *)extra;
7677 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7678 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307679 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007680
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307681 ENTER();
7682
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307683 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7684 if (NULL == pAdapter)
7685 {
7686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7687 "%s: Adapter is NULL",__func__);
7688 return -EINVAL;
7689 }
7690
7691 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7692 ret = wlan_hdd_validate_context(pHddCtx);
7693 if (0 != ret)
7694 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307695 return ret;
7696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007697 // make sure the application is sufficiently priviledged
7698 // note that the kernel will do this for "set" ioctls, but since
7699 // this ioctl wants to return status to user space it must be
7700 // defined as a "get" ioctl
7701 if (!capable(CAP_NET_ADMIN))
7702 {
7703 return -EPERM;
7704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007705 // although we are defined to be a "get" ioctl, the params we require
7706 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7707 // is no need to copy the params from user space
7708
7709 // validate the handle
7710 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7711 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7712 {
7713 // that one is reserved
7714 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7715 return 0;
7716 }
7717
7718 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307719
7720 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 return 0;
7722}
7723
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307724static int iw_del_tspec(struct net_device *dev,
7725 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007726 union iwreq_data *wrqu, char *extra)
7727{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307728 int ret;
7729
7730 vos_ssr_protect(__func__);
7731 ret = __iw_del_tspec(dev, info, wrqu, extra);
7732 vos_ssr_unprotect(__func__);
7733
7734 return ret;
7735}
7736
7737
7738static int __iw_get_tspec(struct net_device *dev,
7739 struct iw_request_info *info,
7740 union iwreq_data *wrqu, char *extra)
7741{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307742 hdd_adapter_t *pAdapter;
7743 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007744 int *params = (int *)extra;
7745 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7746 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307747 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007748
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307749 ENTER();
7750
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 // although we are defined to be a "get" ioctl, the params we require
7752 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7753 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307754 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7755 if (NULL == pAdapter)
7756 {
7757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7758 "%s: Adapter is NULL",__func__);
7759 return -EINVAL;
7760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007761
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307762 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7763 ret = wlan_hdd_validate_context(pHddCtx);
7764 if (0 != ret)
7765 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307766 return ret;
7767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007768 // validate the handle
7769 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7770 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7771 {
7772 // that one is reserved
7773 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7774 return 0;
7775 }
7776
7777 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307778 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007779 return 0;
7780}
7781
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307782static int iw_get_tspec(struct net_device *dev,
7783 struct iw_request_info *info,
7784 union iwreq_data *wrqu, char *extra)
7785{
7786 int ret;
7787
7788 vos_ssr_protect(__func__);
7789 ret = __iw_get_tspec(dev, info, wrqu, extra);
7790 vos_ssr_unprotect(__func__);
7791
7792 return ret;
7793}
7794
Jeff Johnson295189b2012-06-20 16:38:30 -07007795#ifdef WLAN_FEATURE_VOWIFI_11R
7796//
7797//
7798// Each time the supplicant has the auth_request or reassoc request
7799// IEs ready. This is pushed to the driver. The driver will inturn use
7800// it to send out the auth req and reassoc req for 11r FT Assoc.
7801//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307802static int __iw_set_fties(struct net_device *dev,
7803 struct iw_request_info *info,
7804 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007805{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307806 hdd_adapter_t *pAdapter;
7807 hdd_station_ctx_t *pHddStaCtx;
7808 hdd_context_t *pHddCtx;
7809 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 //v_CONTEXT_t pVosContext;
7811
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307812 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307813 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7814 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007815 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7817 "%s: Adapter is NULL",__func__);
7818 return -EINVAL;
7819 }
7820 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7821 ret = wlan_hdd_validate_context(pHddCtx);
7822 if (0 != ret)
7823 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307824 return ret;
7825 }
7826 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7827 if (NULL == pHddStaCtx)
7828 {
7829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7830 "%s: STA Context is NULL",__func__);
7831 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 if (!wrqu->data.length)
7834 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007835 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007836 return -EINVAL;
7837 }
7838 if (wrqu->data.pointer == NULL)
7839 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007840 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 return -EINVAL;
7842 }
7843
7844 // Added for debug on reception of Re-assoc Req.
7845 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7846 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007847 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007849 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 }
7851
7852#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007853 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007854#endif
7855
7856 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007857 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007858 wrqu->data.length);
7859
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307860 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007861 return 0;
7862}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307863
7864static int iw_set_fties(struct net_device *dev,
7865 struct iw_request_info *info,
7866 union iwreq_data *wrqu, char *extra)
7867{
7868 int ret;
7869
7870 vos_ssr_protect(__func__);
7871 ret = __iw_set_fties(dev, info, wrqu, extra);
7872 vos_ssr_unprotect(__func__);
7873
7874 return ret;
7875}
Jeff Johnson295189b2012-06-20 16:38:30 -07007876#endif
7877
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307878static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007879 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007880 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007881{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307882 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007883 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307884 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007885 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307886 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007887 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7888 int idx;
7889 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007890
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307891 ENTER();
7892
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307893 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7894 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007895 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7897 "%s: Adapter is NULL",__func__);
7898 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007899 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307900 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7901 ret_val = wlan_hdd_validate_context(pHddCtx);
7902 if (0 != ret_val)
7903 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307904 return ret_val;
7905 }
7906 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7907 if (NULL == hHal)
7908 {
7909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7910 "%s: Hal Context is NULL",__func__);
7911 return -EINVAL;
7912 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307913 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7914 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307915#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007916
Amar Singhalf3a6e762013-02-19 15:06:50 -08007917 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7918 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007919 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007920 hddLog(VOS_TRACE_LEVEL_ERROR,
7921 "%s: vos_mem_alloc failed", __func__);
7922 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007923 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007924
7925 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7926
7927 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7928 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7929
7930 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7931 mc_addr_list_ptr->ulMulticastAddrCnt);
7932
7933 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007934 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007935 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7936 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7937
7938 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7939 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007940 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007941
Amar Singhalf3a6e762013-02-19 15:06:50 -08007942 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7943 vos_mem_free(mc_addr_list_ptr);
7944 if (eHAL_STATUS_SUCCESS != ret_val)
7945 {
7946 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7947 __func__);
7948 return -EINVAL;
7949 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307950#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307951 }
7952 else
7953 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007954
Amar Singhalf3a6e762013-02-19 15:06:50 -08007955 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7956 "%s: Set MC BC Filter Config request: %d suspend %d",
7957 __func__, pRequest->mcastBcastFilterSetting,
7958 pHddCtx->hdd_wlan_suspended);
7959
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307960 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007961
7962 if (pHddCtx->hdd_wlan_suspended)
7963 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007964 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7965 if (NULL == wlanRxpFilterParam)
7966 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307967 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007968 "%s: vos_mem_alloc failed", __func__);
7969 return -EINVAL;
7970 }
7971
Amar Singhalf3a6e762013-02-19 15:06:50 -08007972 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7973 pRequest->mcastBcastFilterSetting;
7974 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7975
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307976 hdd_conf_hostoffload(pAdapter, TRUE);
7977 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7978 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007979
7980 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7981 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307982 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007983 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7984 wlanRxpFilterParam->setMcstBcstFilter);
7985
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307986 if (eHAL_STATUS_SUCCESS !=
7987 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7988 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007989 {
7990 hddLog(VOS_TRACE_LEVEL_ERROR,
7991 "%s: Failure to execute set HW MC/BC Filter request",
7992 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007993 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007994 return -EINVAL;
7995 }
7996
c_hpothud3ce76d2014-10-28 10:34:13 +05307997 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7998 {
7999 pHddCtx->sus_res_mcastbcast_filter =
8000 pRequest->mcastBcastFilterSetting;
8001 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08008002 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07008003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008004
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308005 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 return 0;
8007}
8008
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308009static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
8010 struct iw_request_info *info,
8011 union iwreq_data *wrqu, char *extra)
8012{
8013 int ret;
8014
8015 vos_ssr_protect(__func__);
8016 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
8017 vos_ssr_unprotect(__func__);
8018
8019 return ret;
8020}
8021
8022static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8023 struct iw_request_info *info,
8024 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008025{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308026 hdd_adapter_t *pAdapter;
8027 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308028 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308029 int ret = 0;
8030
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308031 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07008032
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308033 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8034 if (NULL == pAdapter)
8035 {
8036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8037 "%s: Adapter is NULL",__func__);
8038 return -EINVAL;
8039 }
8040
8041 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8042 ret = wlan_hdd_validate_context(pHddCtx);
8043 if (0 != ret)
8044 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308045 return ret;
8046 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308047 //Reset the filter to INI value as we have to clear the dynamic filter
8048 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07008049
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308050 //Configure FW with new setting
8051 if (pHddCtx->hdd_wlan_suspended)
8052 {
8053 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
8054 if (NULL == wlanRxpFilterParam)
8055 {
8056 hddLog(VOS_TRACE_LEVEL_ERROR,
8057 "%s: vos_mem_alloc failed", __func__);
8058 return -EINVAL;
8059 }
8060
8061 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8062 pHddCtx->configuredMcastBcastFilter;
8063 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
8064
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05308065 hdd_conf_hostoffload(pAdapter, TRUE);
8066 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
8067 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308068
8069 if (eHAL_STATUS_SUCCESS !=
8070 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
8071 wlanRxpFilterParam))
8072 {
8073 hddLog(VOS_TRACE_LEVEL_ERROR,
8074 "%s: Failure to execute set HW MC/BC Filter request",
8075 __func__);
8076 vos_mem_free(wlanRxpFilterParam);
8077 return -EINVAL;
8078 }
c_hpothud3ce76d2014-10-28 10:34:13 +05308079
8080 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
8081 {
8082 pHddCtx->sus_res_mcastbcast_filter =
8083 pHddCtx->cfg_ini->mcastBcastFilterSetting;
8084 }
8085
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05308086 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308087 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 return 0;
8089}
8090
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308091
8092static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
8093 struct iw_request_info *info,
8094 union iwreq_data *wrqu, char *extra)
8095{
8096 int ret;
8097
8098 vos_ssr_protect(__func__);
8099 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
8100 vos_ssr_unprotect(__func__);
8101
8102 return ret;
8103}
8104
8105static int __iw_set_host_offload(struct net_device *dev,
8106 struct iw_request_info *info,
8107 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008108{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308109 hdd_adapter_t *pAdapter;
8110 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008111 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308113 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008114
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308115 ENTER();
8116
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308117 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8118 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008119 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8121 "%s: Adapter is NULL",__func__);
8122 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008123 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308124 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8125 ret = wlan_hdd_validate_context(pHddCtx);
8126 if (0 != ret)
8127 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308128 return ret;
8129 }
8130
Jeff Johnson295189b2012-06-20 16:38:30 -07008131 /* Debug display of request components. */
8132 switch (pRequest->offloadType)
8133 {
8134 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008135 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 switch (pRequest->enableOrDisable)
8137 {
8138 case WLAN_OFFLOAD_DISABLE:
8139 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8140 break;
8141 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8142 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8143 case WLAN_OFFLOAD_ENABLE:
8144 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8145 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8146 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8147 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8148 }
8149 break;
8150
8151 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008152 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008153 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008154 switch (pRequest->enableOrDisable)
8155 {
8156 case WLAN_OFFLOAD_DISABLE:
8157 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8158 break;
8159 case WLAN_OFFLOAD_ENABLE:
8160 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8161 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8162 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8163 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8164 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8165 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8166 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8167 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8168 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8169 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8170 }
8171 }
8172
8173 /* Execute offload request. The reason that we can copy the request information
8174 from the ioctl structure to the SME structure is that they are laid out
8175 exactly the same. Otherwise, each piece of information would have to be
8176 copied individually. */
8177 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008178 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8179 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008181 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008182 __func__);
8183 return -EINVAL;
8184 }
8185
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308186 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008187 return 0;
8188}
8189
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308190static int iw_set_host_offload(struct net_device *dev,
8191 struct iw_request_info *info,
8192 union iwreq_data *wrqu, char *extra)
8193{
8194 int ret;
8195
8196 vos_ssr_protect(__func__);
8197 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8198 vos_ssr_unprotect(__func__);
8199
8200 return ret;
8201}
8202
8203static int __iw_set_keepalive_params(struct net_device *dev,
8204 struct iw_request_info *info,
8205 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008206{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308207 hdd_adapter_t *pAdapter;
8208 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008209 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008210 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308211 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008212
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308213 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308214 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8215 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8218 "%s: Adapter is NULL",__func__);
8219 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308221 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8222 ret = wlan_hdd_validate_context(pHddCtx);
8223 if (0 != ret)
8224 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308225 return ret;
8226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008228 hddLog(VOS_TRACE_LEVEL_INFO,
8229 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8230 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008231
8232 switch (pRequest->packetType)
8233 {
8234 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008235 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 break;
8237
8238 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8239
Arif Hussain6d2a3322013-11-17 19:50:10 -08008240 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008241 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008242
8243 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8244 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8245 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8246
8247 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8248 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8249 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8250
8251 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8252 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8253 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8254 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8255 break;
8256
8257 }
8258
8259 /* Execute keep alive request. The reason that we can copy the request information
8260 from the ioctl structure to the SME structure is that they are laid out
8261 exactly the same. Otherwise, each piece of information would have to be
8262 copied individually. */
8263 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8264
Arif Hussain6d2a3322013-11-17 19:50:10 -08008265 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008266
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008267 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008268 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008270 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008271 __func__);
8272 return -EINVAL;
8273 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308274 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 return 0;
8276}
8277
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308278static int iw_set_keepalive_params(struct net_device *dev,
8279 struct iw_request_info *info,
8280 union iwreq_data *wrqu, char *extra)
8281{
8282 int ret;
8283 vos_ssr_protect(__func__);
8284 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8285 vos_ssr_unprotect(__func__);
8286
8287 return ret;
8288}
8289
Jeff Johnson295189b2012-06-20 16:38:30 -07008290#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008291int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008292 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008293{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008294 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8295 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 int i=0;
8297
8298 if (pHddCtx->cfg_ini->disablePacketFilter)
8299 {
8300 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008301 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 return 0;
8303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008304 /* Debug display of request components. */
8305 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008306 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008307
8308 switch (pRequest->filterAction)
8309 {
8310 case HDD_RCV_FILTER_SET:
8311 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008312 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008313
8314 packetFilterSetReq.filterId = pRequest->filterId;
8315 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8316 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008317 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008318 __func__, pRequest->numParams);
8319 return -EINVAL;
8320 }
8321 packetFilterSetReq.numFieldParams = pRequest->numParams;
8322 packetFilterSetReq.coalesceTime = 0;
8323 packetFilterSetReq.filterType = 1;
8324 for (i=0; i < pRequest->numParams; i++)
8325 {
8326 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8327 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8328 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8329 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8330 packetFilterSetReq.paramsData[i].reserved = 0;
8331
Arif Hussain6d2a3322013-11-17 19:50:10 -08008332 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8334 packetFilterSetReq.filterType);
8335
Arif Hussain6d2a3322013-11-17 19:50:10 -08008336 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8338
8339 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8340 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8341 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8342 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8343
Arif Hussain6d2a3322013-11-17 19:50:10 -08008344 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008345 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8346 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8347 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8348
Arif Hussain6d2a3322013-11-17 19:50:10 -08008349 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8351 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8352 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8353 }
8354
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008355 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008357 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008358 __func__);
8359 return -EINVAL;
8360 }
8361
8362 break;
8363
8364 case HDD_RCV_FILTER_CLEAR:
8365
Arif Hussain6d2a3322013-11-17 19:50:10 -08008366 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008367 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008368 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008369 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008371 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 __func__);
8373 return -EINVAL;
8374 }
8375 break;
8376
8377 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008378 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008379 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 return -EINVAL;
8381 }
8382 return 0;
8383}
8384
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308385int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8386 tANI_U8 sessionId)
8387{
8388 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8389 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8390
8391 if (NULL == pHddCtx)
8392 {
8393 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8394 return -EINVAL;
8395 }
8396
8397 if (pHddCtx->isLogpInProgress)
8398 {
8399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8400 "%s:LOGP in Progress. Ignore!!!", __func__);
8401 return -EBUSY;
8402 }
8403
8404 if (pHddCtx->cfg_ini->disablePacketFilter)
8405 {
8406 hddLog(VOS_TRACE_LEVEL_ERROR,
8407 "%s: Packet Filtering Disabled. Returning ",
8408 __func__ );
8409 return -EINVAL;
8410 }
8411
8412 switch (filterType)
8413 {
8414 /* For setting IPV6 MC and UC Filter we need to configure
8415 * 2 filters, one for MC and one for UC.
8416 * The Filter ID shouldn't be swapped, which results in making
8417 * UC Filter ineffective.
8418 * We have Hardcode all the values
8419 *
8420 * Reason for a seperate UC filter is because, driver need to
8421 * specify the FW that the specific filter is for unicast
8422 * otherwise FW will not pass the unicast frames by default
8423 * through the filter. This is required to avoid any performance
8424 * hits when no unicast filter is set and only MC/BC are set.
8425 * The way driver informs host is by using the MAC protocol
8426 * layer, CMP flag set to MAX, CMP Data set to 1.
8427 */
8428
8429 case HDD_FILTER_IPV6_MC_UC:
8430 /* Setting IPV6 MC Filter below
8431 */
8432 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8433 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8434 packetFilterSetReq.numFieldParams = 2;
8435 packetFilterSetReq.paramsData[0].protocolLayer =
8436 HDD_FILTER_PROTO_TYPE_MAC;
8437 packetFilterSetReq.paramsData[0].cmpFlag =
8438 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8439 packetFilterSetReq.paramsData[0].dataOffset =
8440 WLAN_HDD_80211_FRM_DA_OFFSET;
8441 packetFilterSetReq.paramsData[0].dataLength = 1;
8442 packetFilterSetReq.paramsData[0].compareData[0] =
8443 HDD_IPV6_MC_CMP_DATA;
8444
8445 packetFilterSetReq.paramsData[1].protocolLayer =
8446 HDD_FILTER_PROTO_TYPE_ARP;
8447 packetFilterSetReq.paramsData[1].cmpFlag =
8448 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8449 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8450 packetFilterSetReq.paramsData[1].dataLength = 2;
8451 packetFilterSetReq.paramsData[1].compareData[0] =
8452 HDD_IPV6_CMP_DATA_0;
8453 packetFilterSetReq.paramsData[1].compareData[1] =
8454 HDD_IPV6_CMP_DATA_1;
8455
8456
8457 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8458 &packetFilterSetReq, sessionId))
8459 {
8460 hddLog(VOS_TRACE_LEVEL_ERROR,
8461 "%s: Failure to execute Set IPv6 Mulicast Filter",
8462 __func__);
8463 return -EINVAL;
8464 }
8465
8466 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8467
8468 /*
8469 * Setting IPV6 UC Filter below
8470 */
8471 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8472 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8473 packetFilterSetReq.numFieldParams = 2;
8474 packetFilterSetReq.paramsData[0].protocolLayer =
8475 HDD_FILTER_PROTO_TYPE_MAC;
8476 packetFilterSetReq.paramsData[0].cmpFlag =
8477 HDD_FILTER_CMP_TYPE_MAX;
8478 packetFilterSetReq.paramsData[0].dataOffset = 0;
8479 packetFilterSetReq.paramsData[0].dataLength = 1;
8480 packetFilterSetReq.paramsData[0].compareData[0] =
8481 HDD_IPV6_UC_CMP_DATA;
8482
8483 packetFilterSetReq.paramsData[1].protocolLayer =
8484 HDD_FILTER_PROTO_TYPE_ARP;
8485 packetFilterSetReq.paramsData[1].cmpFlag =
8486 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8487 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8488 packetFilterSetReq.paramsData[1].dataLength = 2;
8489 packetFilterSetReq.paramsData[1].compareData[0] =
8490 HDD_IPV6_CMP_DATA_0;
8491 packetFilterSetReq.paramsData[1].compareData[1] =
8492 HDD_IPV6_CMP_DATA_1;
8493
8494 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8495 &packetFilterSetReq, sessionId))
8496 {
8497 hddLog(VOS_TRACE_LEVEL_ERROR,
8498 "%s: Failure to execute Set IPv6 Unicast Filter",
8499 __func__);
8500 return -EINVAL;
8501 }
8502
8503 break;
8504
8505 case HDD_FILTER_IPV6_MC:
8506 /*
8507 * IPV6 UC Filter might be already set,
8508 * clear the UC Filter. As the Filter
8509 * IDs are static, we can directly clear it.
8510 */
8511 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8512 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8513 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8514 &packetFilterClrReq, sessionId))
8515 {
8516 hddLog(VOS_TRACE_LEVEL_ERROR,
8517 "%s: Failure to execute Clear IPv6 Unicast Filter",
8518 __func__);
8519 return -EINVAL;
8520 }
8521
8522 /*
8523 * Setting IPV6 MC Filter below
8524 */
8525 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8526 packetFilterSetReq.numFieldParams = 2;
8527 packetFilterSetReq.paramsData[0].protocolLayer =
8528 HDD_FILTER_PROTO_TYPE_MAC;
8529 packetFilterSetReq.paramsData[0].cmpFlag =
8530 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8531 packetFilterSetReq.paramsData[0].dataOffset =
8532 WLAN_HDD_80211_FRM_DA_OFFSET;
8533 packetFilterSetReq.paramsData[0].dataLength = 1;
8534 packetFilterSetReq.paramsData[0].compareData[0] =
8535 HDD_IPV6_MC_CMP_DATA;
8536
8537 packetFilterSetReq.paramsData[1].protocolLayer =
8538 HDD_FILTER_PROTO_TYPE_ARP;
8539 packetFilterSetReq.paramsData[1].cmpFlag =
8540 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8541 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8542 packetFilterSetReq.paramsData[1].dataLength = 2;
8543 packetFilterSetReq.paramsData[1].compareData[0] =
8544 HDD_IPV6_CMP_DATA_0;
8545 packetFilterSetReq.paramsData[1].compareData[1] =
8546 HDD_IPV6_CMP_DATA_1;
8547
8548
8549 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8550 &packetFilterSetReq, sessionId))
8551 {
8552 hddLog(VOS_TRACE_LEVEL_ERROR,
8553 "%s: Failure to execute Set IPv6 Multicast Filter",
8554 __func__);
8555 return -EINVAL;
8556 }
8557 break;
8558
8559 default :
8560 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8561 "%s: Packet Filter Request: Invalid",
8562 __func__);
8563 return -EINVAL;
8564 }
8565 return 0;
8566}
8567
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308568void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008569{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308570 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308571 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008572 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308573 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008574
Yue Ma3ede6052013-08-29 00:33:26 -07008575 if (NULL == pHddCtx)
8576 {
8577 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8578 return;
8579 }
8580
8581 hHal = pHddCtx->hHal;
8582
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308583 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008584 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8586 return;
8587 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308588
8589 /* Check if INI is enabled or not, other wise just return
8590 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308591 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308592 {
8593 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8594 if (NULL == pMulticastAddrs)
8595 {
8596 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8597 return;
8598 }
8599
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 if (set)
8601 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308602 /* Following pre-conditions should be satisfied before wei
8603 * configure the MC address list.
8604 */
8605 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8606 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8607 && pAdapter->mc_addr_list.mc_cnt
8608 && (eConnectionState_Associated ==
8609 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8610 {
8611 pMulticastAddrs->ulMulticastAddrCnt =
8612 pAdapter->mc_addr_list.mc_cnt;
8613 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8614 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008615 memcpy(pMulticastAddrs->multicastAddr[i],
8616 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308617 sizeof(pAdapter->mc_addr_list.addr[i]));
8618 hddLog(VOS_TRACE_LEVEL_INFO,
8619 "%s: %s multicast filter: addr ="
8620 MAC_ADDRESS_STR,
8621 __func__, set ? "setting" : "clearing",
8622 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8623 }
8624 /* Set multicast filter */
8625 sme_8023MulticastList(hHal, pAdapter->sessionId,
8626 pMulticastAddrs);
8627 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008628 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308629 else
8630 {
8631 /* Need to clear only if it was previously configured
8632 */
8633 if (pAdapter->mc_addr_list.isFilterApplied)
8634 {
8635 pMulticastAddrs->ulMulticastAddrCnt = 0;
8636 sme_8023MulticastList(hHal, pAdapter->sessionId,
8637 pMulticastAddrs);
8638 }
8639
8640 }
8641 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008642 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008643 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308644 else
8645 {
8646 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308647 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308648 }
8649 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008650}
8651
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308652static int __iw_set_packet_filter_params(struct net_device *dev,
8653 struct iw_request_info *info,
8654 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308655{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308656 hdd_adapter_t *pAdapter;
8657 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008658 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308659 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308660 struct iw_point s_priv_data;
8661
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308662 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308663 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8664 if (NULL == pAdapter)
8665 {
8666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8667 "%s: Adapter is NULL",__func__);
8668 return -EINVAL;
8669 }
8670 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8671 ret = wlan_hdd_validate_context(pHddCtx);
8672 if (0 != ret)
8673 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308674 return ret;
8675 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308676 if (hdd_priv_get_data(&s_priv_data, wrqu))
8677 {
8678 return -EINVAL;
8679 }
8680
8681 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8682 {
8683 return -EINVAL;
8684 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008685
Arif Hussain0273cba2014-01-07 20:58:29 -08008686 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308687 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8688 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008689 if (NULL == pRequest)
8690 {
8691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8692 "mem_alloc_copy_from_user_helper fail");
8693 return -ENOMEM;
8694 }
8695
8696 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8697 kfree(pRequest);
8698
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308699 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008700 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008701}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308702
8703static int iw_set_packet_filter_params(struct net_device *dev,
8704 struct iw_request_info *info,
8705 union iwreq_data *wrqu, char *extra)
8706{
8707 int ret;
8708
8709 vos_ssr_protect(__func__);
8710 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8711 vos_ssr_unprotect(__func__);
8712
8713 return ret;
8714}
Jeff Johnson295189b2012-06-20 16:38:30 -07008715#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308716static int __iw_get_statistics(struct net_device *dev,
8717 struct iw_request_info *info,
8718 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008719{
8720
8721 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8722 eHalStatus status = eHAL_STATUS_SUCCESS;
8723 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308724 hdd_adapter_t *pAdapter;
8725 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308727 int tlen = 0, ret = 0;
8728 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008729
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308730 tCsrGlobalClassAStatsInfo *aStats;
8731 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008732
8733 ENTER();
8734
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308735 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8736 if (NULL == pAdapter)
8737 {
8738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8739 "%s: Adapter is NULL",__func__);
8740 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308742 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8743 ret = wlan_hdd_validate_context(pHddCtx);
8744 if (0 != ret)
8745 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308746 return ret;
8747 }
8748 pStats = &(pAdapter->hdd_stats.summary_stat);
8749 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8750 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8752
8753 wrqu->txpower.value = 0;
8754 }
8755 else {
8756 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8757 SME_SUMMARY_STATS |
8758 SME_GLOBAL_CLASSA_STATS |
8759 SME_GLOBAL_CLASSB_STATS |
8760 SME_GLOBAL_CLASSC_STATS |
8761 SME_GLOBAL_CLASSD_STATS |
8762 SME_PER_STA_STATS,
8763 hdd_StatisticsCB, 0, FALSE,
8764 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8765
8766 if (eHAL_STATUS_SUCCESS != status)
8767 {
8768 hddLog(VOS_TRACE_LEVEL_ERROR,
8769 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008770 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008771 return -EINVAL;
8772 }
8773
8774 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308775 if (NULL == pWextState)
8776 {
8777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8778 "%s: pWextState is NULL",__func__);
8779 return -EINVAL;
8780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008781
8782 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8783 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8784 {
8785 hddLog(VOS_TRACE_LEVEL_ERROR,
8786 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008787 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008788 /*Remove the SME statistics list by passing NULL in callback argument*/
8789 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8790 SME_SUMMARY_STATS |
8791 SME_GLOBAL_CLASSA_STATS |
8792 SME_GLOBAL_CLASSB_STATS |
8793 SME_GLOBAL_CLASSC_STATS |
8794 SME_GLOBAL_CLASSD_STATS |
8795 SME_PER_STA_STATS,
8796 NULL, 0, FALSE,
8797 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8798
8799 return -EINVAL;
8800 }
8801 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8802 (tANI_U8) sizeof (pStats->retry_cnt),
8803 (char*) &(pStats->retry_cnt[0]),
8804 tlen);
8805
8806 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8807 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8808 (char*) &(pStats->multiple_retry_cnt[0]),
8809 tlen);
8810
8811 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8812 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8813 (char*) &(pStats->tx_frm_cnt[0]),
8814 tlen);
8815
8816 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8817 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8818 (char*) &(pStats->rx_frm_cnt),
8819 tlen);
8820
8821 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8822 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8823 (char*) &(pStats->frm_dup_cnt),
8824 tlen);
8825
8826 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8827 (tANI_U8) sizeof (pStats->fail_cnt),
8828 (char*) &(pStats->fail_cnt[0]),
8829 tlen);
8830
8831 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8832 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8833 (char*) &(pStats->rts_fail_cnt),
8834 tlen);
8835
8836 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8837 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8838 (char*) &(pStats->ack_fail_cnt),
8839 tlen);
8840
8841 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8842 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8843 (char*) &(pStats->rts_succ_cnt),
8844 tlen);
8845
8846 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8847 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8848 (char*) &(pStats->rx_discard_cnt),
8849 tlen);
8850
8851 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8852 (tANI_U8) sizeof (pStats->rx_error_cnt),
8853 (char*) &(pStats->rx_error_cnt),
8854 tlen);
8855
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008856 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008857 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008858 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008859 tlen);
8860
8861 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8862 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8863 (char*) &(dStats->rx_byte_cnt),
8864 tlen);
8865
8866 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8867 (tANI_U8) sizeof (dStats->rx_rate),
8868 (char*) &(dStats->rx_rate),
8869 tlen);
8870
8871 /* Transmit rate, in units of 500 kbit/sec */
8872 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8873 (tANI_U8) sizeof (aStats->tx_rate),
8874 (char*) &(aStats->tx_rate),
8875 tlen);
8876
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008877 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8878 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8879 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008880 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008881 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8882 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8883 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008884 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008885 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8886 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8887 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008888 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008889 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8890 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8891 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008892 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008893 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8894 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8895 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008896 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008897 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8898 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8899 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008900 tlen);
8901
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 wrqu->data.length = tlen;
8903
8904 }
8905
8906 EXIT();
8907
8908 return 0;
8909}
8910
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308911static int iw_get_statistics(struct net_device *dev,
8912 struct iw_request_info *info,
8913 union iwreq_data *wrqu, char *extra)
8914{
8915 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008916
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308917 vos_ssr_protect(__func__);
8918 ret = __iw_get_statistics(dev, info, wrqu, extra);
8919 vos_ssr_unprotect(__func__);
8920
8921 return ret;
8922}
Jeff Johnson295189b2012-06-20 16:38:30 -07008923#ifdef FEATURE_WLAN_SCAN_PNO
8924
8925/*Max Len for PNO notification*/
8926#define MAX_PNO_NOTIFY_LEN 100
8927void found_pref_network_cb (void *callbackContext,
8928 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8929{
8930 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8931 union iwreq_data wrqu;
8932 char buf[MAX_PNO_NOTIFY_LEN+1];
8933
8934 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8935 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8936
8937 // create the event
8938 memset(&wrqu, 0, sizeof(wrqu));
8939 memset(buf, 0, sizeof(buf));
8940
8941 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8942 pPrefNetworkFoundInd->ssId.ssId,
8943 (unsigned int)pPrefNetworkFoundInd->rssi);
8944
8945 wrqu.data.pointer = buf;
8946 wrqu.data.length = strlen(buf);
8947
8948 // send the event
8949
8950 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8951
8952}
8953
8954
8955/*string based input*/
8956VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8957 union iwreq_data *wrqu, char *extra, int nOffset)
8958{
8959 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308960 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008961 /* pnoRequest is a large struct, so we make it static to avoid stack
8962 overflow. This API is only invoked via ioctl, so it is
8963 serialized by the kernel rtnl_lock and hence does not need to be
8964 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308965 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 char *ptr;
8967 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308968 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008969 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8970
8971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8972 "PNO data len %d data %s",
8973 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008974 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008975
8976 if (wrqu->data.length <= nOffset )
8977 {
8978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8979 return VOS_STATUS_E_FAILURE;
8980 }
8981
8982 pnoRequest.enable = 0;
8983 pnoRequest.ucNetworksCount = 0;
8984 /*-----------------------------------------------------------------------
8985 Input is string based and expected to be like this:
8986
8987 <enabled> <netw_count>
8988 for each network:
8989 <ssid_len> <ssid> <authentication> <encryption>
8990 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8991 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8992
8993 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008994 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 -07008995
8996 this translates into:
8997 -----------------------------
8998 enable PNO
8999 look for 2 networks:
9000 test - with authentication type 0 and encryption type 0,
9001 that can be found on 3 channels: 1 6 and 11 ,
9002 SSID bcast type is unknown (directed probe will be sent if AP not found)
9003 and must meet -40dBm RSSI
9004
9005 test2 - with auth and enrytption type 4/4
9006 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
9007 bcast type is non-bcast (directed probe will be sent)
9008 and must not meet any RSSI threshold
9009
Jeff Johnson8301aa12013-03-28 14:27:29 -07009010 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07009011 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08009012 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009013
Wilson Yang623f6592013-10-08 16:33:37 -07009014 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
9015 {
9016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9017 "PNO enable input is not valid %s",ptr);
9018 return VOS_STATUS_E_FAILURE;
9019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009020
9021 if ( 0 == pnoRequest.enable )
9022 {
9023 /*Disable PNO*/
9024 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05309025 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
9026 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 pAdapter->sessionId,
9028 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309029 if (eHAL_STATUS_SUCCESS != status)
9030 {
9031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9032 "%s: failed to disable PNO", __func__);
9033 return VOS_STATUS_E_FAILURE;
9034 }
9035 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009036 return VOS_STATUS_SUCCESS;
9037 }
9038
c_hpothu37f21312014-04-09 21:49:54 +05309039 if (TRUE == pHddCtx->isPnoEnable)
9040 {
9041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9042 FL("already PNO is enabled"));
9043 return -EBUSY;
9044 }
9045 pHddCtx->isPnoEnable = TRUE;
9046
Jeff Johnson295189b2012-06-20 16:38:30 -07009047 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07009048
9049 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
9050 {
9051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9052 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309053 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009055
9056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9057 "PNO enable %d networks count %d offset %d",
9058 pnoRequest.enable,
9059 pnoRequest.ucNetworksCount,
9060 nOffset);
9061
9062 /* Parameters checking:
9063 ucNetworksCount has to be larger than 0*/
9064 if (( 0 == pnoRequest.ucNetworksCount ) ||
9065 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9066 {
9067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05309068 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009069 }
9070
9071 ptr += nOffset;
9072
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309073 pnoRequest.aNetworks =
9074 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9075 if (pnoRequest.aNetworks == NULL)
9076 {
9077 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9078 FL("failed to allocate memory aNetworks %u"),
9079 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9080 goto error;
9081 }
9082 vos_mem_zero(pnoRequest.aNetworks,
9083 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
9084
Jeff Johnson295189b2012-06-20 16:38:30 -07009085 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
9086 {
9087
9088 pnoRequest.aNetworks[i].ssId.length = 0;
9089
Wilson Yang623f6592013-10-08 16:33:37 -07009090 ucParams = sscanf(ptr,"%hhu %n",
9091 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
9092
9093 if (1 != ucParams)
9094 {
9095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9096 "PNO ssid length input is not valid %s",ptr);
9097 return VOS_STATUS_E_FAILURE;
9098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009099
9100 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
9101 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
9102 {
9103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9104 "SSID Len %d is not correct for network %d",
9105 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05309106 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009107 }
9108
9109 /*Advance to SSID*/
9110 ptr += nOffset;
9111
Jeff Johnson8301aa12013-03-28 14:27:29 -07009112 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08009113 pnoRequest.aNetworks[i].ssId.length);
9114 ptr += pnoRequest.aNetworks[i].ssId.length;
9115
Jeff Johnson02797792013-10-26 19:17:13 -07009116 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08009117 &(pnoRequest.aNetworks[i].authentication),
9118 &(pnoRequest.aNetworks[i].encryption),
9119 &(pnoRequest.aNetworks[i].ucChannelCount),
9120 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009121
Wilson Yang623f6592013-10-08 16:33:37 -07009122 if ( 3 != ucParams )
9123 {
9124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9125 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309126 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009127 }
9128
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009130 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08009131 "auth %d encry %d channel count %d offset %d",
9132 pnoRequest.aNetworks[i].ssId.length,
9133 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9134 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9135 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9136 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9137 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9138 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9139 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9140 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9141 pnoRequest.aNetworks[i].authentication,
9142 pnoRequest.aNetworks[i].encryption,
9143 pnoRequest.aNetworks[i].ucChannelCount,
9144 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009145
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 /*Advance to channel list*/
9147 ptr += nOffset;
9148
Wilson Yang623f6592013-10-08 16:33:37 -07009149 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009150 {
9151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9152 "Incorrect number of channels");
9153 return VOS_STATUS_E_FAILURE;
9154 }
9155
9156 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9157 {
9158 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9159 {
Wilson Yang623f6592013-10-08 16:33:37 -07009160 if (1 != sscanf(ptr,"%hhu %n",
9161 &(pnoRequest.aNetworks[i].aChannels[j]),
9162 &nOffset))
9163 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9164 "PNO network channel input is not valid %s",ptr);
9165 return VOS_STATUS_E_FAILURE;
9166 }
9167 /*Advance to next channel number*/
9168 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009169 }
9170 }
9171
Jeff Johnson02797792013-10-26 19:17:13 -07009172 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009173 &(pnoRequest.aNetworks[i].bcastNetwType),
9174 &nOffset))
9175 {
9176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9177 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309178 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009180
9181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9182 "PNO bcastNetwType %d offset %d",
9183 pnoRequest.aNetworks[i].bcastNetwType,
9184 nOffset );
9185
9186 /*Advance to rssi Threshold*/
9187 ptr += nOffset;
9188
Wilson Yang623f6592013-10-08 16:33:37 -07009189 if (1 != sscanf(ptr,"%hhu %n",
9190 &(pnoRequest.aNetworks[i].rssiThreshold),
9191 &nOffset))
9192 {
9193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9194 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309195 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009197
9198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9199 "PNO rssi %d offset %d",
9200 pnoRequest.aNetworks[i].rssiThreshold,
9201 nOffset );
9202 /*Advance to next network*/
9203 ptr += nOffset;
9204 }/*For ucNetworkCount*/
9205
9206 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009207 &(pnoRequest.scanTimers.ucScanTimersCount),
9208 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009209
9210 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009211 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009212 {
9213 ptr += nOffset;
9214
Jeff Johnson8301aa12013-03-28 14:27:29 -07009215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9216 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 pnoRequest.scanTimers.ucScanTimersCount,
9218 nOffset );
9219
9220 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9221 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309224 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 }
9226
9227 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9228 {
Jeff Johnson02797792013-10-26 19:17:13 -07009229 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9231 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9232 &nOffset);
9233
Wilson Yang623f6592013-10-08 16:33:37 -07009234 if (2 != ucParams)
9235 {
9236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9237 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309238 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009239 }
9240
Jeff Johnson8301aa12013-03-28 14:27:29 -07009241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9242 "PNO Timer value %d Timer repeat %d offset %d",
9243 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9245 nOffset );
9246
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 ptr += nOffset;
9248 }
9249
9250 }
9251 else
9252 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9254 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9256
9257 /*Scan timers defaults to 5 minutes*/
9258 pnoRequest.scanTimers.ucScanTimersCount = 1;
9259 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9260 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9261 }
9262
Wilson Yang623f6592013-10-08 16:33:37 -07009263 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009264
9265 pnoRequest.modePNO = ucMode;
9266 /*for LA we just expose suspend option*/
9267 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9268 {
9269 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9270 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309271 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9272 if (pnoRequest.p24GProbeTemplate == NULL){
9273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9274 FL("failed to allocate memory p24GProbeTemplate %u"),
9275 SIR_PNO_MAX_PB_REQ_SIZE);
9276 goto error;
9277 }
9278
9279 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9280 if (pnoRequest.p5GProbeTemplate == NULL){
9281 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9282 FL("failed to allocate memory p5GProbeTemplate %u"),
9283 SIR_PNO_MAX_PB_REQ_SIZE);
9284 goto error;
9285 }
9286
9287 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9288 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009289
c_hpothu37f21312014-04-09 21:49:54 +05309290 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009291 pAdapter->sessionId,
9292 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309293 if (eHAL_STATUS_SUCCESS == status)
9294 {
9295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9296 "%s: PNO enabled", __func__);
9297 return VOS_STATUS_SUCCESS;
9298 }
9299error:
9300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9301 "%s: Failed to enable PNO", __func__);
9302 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309303 if (pnoRequest.aNetworks)
9304 vos_mem_free(pnoRequest.aNetworks);
9305 if (pnoRequest.p24GProbeTemplate)
9306 vos_mem_free(pnoRequest.p24GProbeTemplate);
9307 if (pnoRequest.p5GProbeTemplate)
9308 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309309 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009310}/*iw_set_pno*/
9311
9312VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9313 union iwreq_data *wrqu, char *extra, int nOffset)
9314{
9315 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9316 v_U8_t rssiThreshold = 0;
9317 v_U8_t nRead;
9318
Arif Hussain7adce1b2013-11-11 22:59:34 -08009319 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 &rssiThreshold);
9321
9322 if ( 1 != nRead )
9323 {
9324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9325 "Incorrect format");
9326 return VOS_STATUS_E_FAILURE;
9327 }
9328
9329 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9330 return VOS_STATUS_SUCCESS;
9331}
9332
9333
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309334static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009335 struct iw_request_info *info,
9336 union iwreq_data *wrqu, char *extra)
9337{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309338 hdd_adapter_t *pAdapter;
9339 hdd_context_t *pHddCtx;
9340 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309341 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309342
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309343 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309344 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9345 if (NULL == pAdapter)
9346 {
9347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9348 "%s: Adapter is NULL",__func__);
9349 return -EINVAL;
9350 }
9351
9352 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9353 ret = wlan_hdd_validate_context(pHddCtx);
9354 if (0 != ret)
9355 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309356 return ret;
9357 }
9358
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009359
9360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009361 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009362
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309363 status = iw_set_pno(dev,info,wrqu,extra,0);
9364
9365 EXIT();
9366 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009367}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309368
9369static int iw_set_pno_priv(struct net_device *dev,
9370 struct iw_request_info *info,
9371 union iwreq_data *wrqu, char *extra)
9372{
9373 int ret;
9374
9375 vos_ssr_protect(__func__);
9376 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9377 vos_ssr_unprotect(__func__);
9378
9379 return ret;
9380}
Jeff Johnson295189b2012-06-20 16:38:30 -07009381#endif /*FEATURE_WLAN_SCAN_PNO*/
9382
9383//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309384int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009385{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309386 hdd_adapter_t *pAdapter;
9387 tHalHandle hHal;
9388 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309389 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309390 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309391 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009392 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309393 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309394 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309395 tpAniSirGlobal pMac;
9396 int retval = 0;
9397
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309398 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309399 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9400 if (NULL == pAdapter)
9401 {
9402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9403 "%s: Adapter is NULL",__func__);
9404 return -EINVAL;
9405 }
9406 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9407 retval = wlan_hdd_validate_context(pHddCtx);
9408 if (0 != retval)
9409 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309410 return retval;
9411 }
9412 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9413 if (NULL == hHal)
9414 {
9415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9416 "%s: Hal Context is NULL",__func__);
9417 return -EINVAL;
9418 }
9419 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009420
Atul Mittal54378cb2014-04-02 16:51:50 +05309421 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 {
9423 case WLAN_HDD_UI_BAND_AUTO:
9424 band = eCSR_BAND_ALL;
9425 break;
9426 case WLAN_HDD_UI_BAND_5_GHZ:
9427 band = eCSR_BAND_5G;
9428 break;
9429 case WLAN_HDD_UI_BAND_2_4_GHZ:
9430 band = eCSR_BAND_24;
9431 break;
9432 default:
9433 band = eCSR_BAND_MAX;
9434 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309435 connectedBand =
9436 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009437
Atul Mittal54378cb2014-04-02 16:51:50 +05309438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009439 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009440
9441 if (band == eCSR_BAND_MAX)
9442 {
9443 /* Received change band request with invalid band value */
9444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309445 "%s: Invalid band value %u", __func__, ui_band);
9446 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 }
9448
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309449 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309450 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309451 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009453 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009454 band, pHddCtx->cfg_ini->nBandCapability);
9455 return -EIO;
9456 }
9457
Sushant Kaushik1165f872015-03-30 20:25:27 +05309458 if (band == eCSR_BAND_ALL)
9459 {
9460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9461 "received. Setting band same as ini value %d"),
9462 pHddCtx->cfg_ini->nBandCapability);
9463 band = pHddCtx->cfg_ini->nBandCapability;
9464 }
9465
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9467 {
9468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9469 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009470 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009471 return -EIO;
9472 }
9473
9474 if (currBand != band)
9475 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309476 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309477 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309478 /* Return failure if current country code is world regulatory domain*/
9479 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9480 pMac->scan.countryCodeCurrent[1] == '0') )
9481 {
9482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9483 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309484 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309485 return -EAGAIN;
9486 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309487 }
9488
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 /* Change band request received.
9490 * Abort pending scan requests, flush the existing scan results,
9491 * and change the band capability
9492 */
9493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9494 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009495 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009496
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309497 /* We need to change the band and flush the scan results here itself
9498 * as we may get timeout for disconnection in which we will return
9499 * with out doing any of these
9500 */
9501 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9502 {
9503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9504 "%s: failed to set the band value to %u ",
9505 __func__, band);
9506 return -EINVAL;
9507 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309508 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9509 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309510 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309511 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9512 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309513 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309514 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9515 * information available in NV so to get the channel information from kernel
9516 * we need to send regulatory hint for the currunt country
9517 * And to set the same country again we need to set the dummy country
9518 * first and then the actual country.
9519 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309520#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9521 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9522#else
9523 regulatory_hint_user("00");
9524#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309525 wait_result = wait_for_completion_interruptible_timeout(
9526 &pHddCtx->linux_reg_req,
9527 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9528
9529 /* if the country information does not exist with the kernel,
9530 then the driver callback would not be called */
9531
9532 if (wait_result >= 0)
9533 {
9534 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9535 "runtime country code is found in kernel db");
9536 }
9537 else
9538 {
9539 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9540 "runtime country code is not found"
9541 " in kernel db");
9542 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309543
9544 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309545
9546 /*
9547 * Update 11dcountry and current country here as the hint
9548 * with 00 results in 11d and current country with 00
9549 */
9550 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9551 WNI_CFG_COUNTRY_CODE_LEN);
9552 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9553 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309554#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9555 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9556#else
9557 regulatory_hint_user(curr_country);
9558#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309559 wait_result = wait_for_completion_interruptible_timeout(
9560 &pHddCtx->linux_reg_req,
9561 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9562
9563 /* if the country information does not exist with the kernel,
9564 then the driver callback would not be called */
9565 if (wait_result >= 0)
9566 {
9567 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9568 "runtime country code is found in kernel db");
9569 }
9570 else
9571 {
9572 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9573 "runtime country code is not found"
9574 " in kernel db");
9575 }
9576
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309577 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
9578 }
9579 else
9580 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309581#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309582 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9583 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309584#else
9585 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9586#endif
9587
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309588 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309589 pScanInfo = &pHddCtx->scan_info;
9590 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9591 {
9592 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9593 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9594 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309595 sme_FilterScanResults(hHal, pAdapter->sessionId);
9596
9597 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309598 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9599 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009600 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 eHalStatus status = eHAL_STATUS_SUCCESS;
9602 long lrc;
9603
9604 /* STA already connected on current band, So issue disconnect first,
9605 * then change the band*/
9606
9607 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309608 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309609 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009610
Jeff Johnson295189b2012-06-20 16:38:30 -07009611 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9612
9613 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9614 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9615
Jeff Johnson43971f52012-07-17 12:26:56 -07009616 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009617 {
9618 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009619 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009620 __func__, (int)status );
9621 return -EINVAL;
9622 }
9623
9624 lrc = wait_for_completion_interruptible_timeout(
9625 &pAdapter->disconnect_comp_var,
9626 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9627
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309628 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009629
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009630 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009631 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009632
9633 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9634 }
9635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309637 EXIT();
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309638 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009639}
9640
Atul Mittal54378cb2014-04-02 16:51:50 +05309641int hdd_setBand_helper(struct net_device *dev, const char *command)
9642{
9643 u8 band;
9644
9645 /*convert the band value from ascii to integer*/
9646 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9647
9648 return hdd_setBand(dev, band);
9649
9650}
9651
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309652static int __iw_set_band_config(struct net_device *dev,
9653 struct iw_request_info *info,
9654 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009655{
Atul Mittal54378cb2014-04-02 16:51:50 +05309656 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009657
Arif Hussain0273cba2014-01-07 20:58:29 -08009658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009659
Atul Mittal54378cb2014-04-02 16:51:50 +05309660 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009661}
9662
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309663static int iw_set_band_config(struct net_device *dev,
9664 struct iw_request_info *info,
9665 union iwreq_data *wrqu, char *extra)
9666{
9667 int ret;
9668
9669 vos_ssr_protect(__func__);
9670 ret = __iw_set_band_config(dev, info, wrqu, extra);
9671 vos_ssr_unprotect(__func__);
9672
9673 return ret;
9674}
9675
9676static int __iw_set_power_params_priv(struct net_device *dev,
9677 struct iw_request_info *info,
9678 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009679{
Arif Hussain0273cba2014-01-07 20:58:29 -08009680 int ret;
9681 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9683 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009684 /* ODD number is used for set, copy data using copy_from_user */
9685 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9686 wrqu->data.length);
9687 if (NULL == ptr)
9688 {
9689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9690 "mem_alloc_copy_from_user_helper fail");
9691 return -ENOMEM;
9692 }
9693
9694 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9695 kfree(ptr);
9696 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009697}
9698
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309699static int iw_set_power_params_priv(struct net_device *dev,
9700 struct iw_request_info *info,
9701 union iwreq_data *wrqu, char *extra)
9702{
9703 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009704
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309705 vos_ssr_protect(__func__);
9706 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9707 vos_ssr_unprotect(__func__);
9708
9709 return ret;
9710}
Jeff Johnson295189b2012-06-20 16:38:30 -07009711
9712/*string based input*/
9713VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9714 union iwreq_data *wrqu, char *extra, int nOffset)
9715{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309716 hdd_adapter_t *pAdapter;
9717 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 tSirSetPowerParamsReq powerRequest;
9719 char *ptr;
9720 v_U8_t ucType;
9721 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309722 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009723
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309724 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309725 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9726 if (NULL == pAdapter)
9727 {
9728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9729 "%s: Adapter is NULL",__func__);
9730 return -EINVAL;
9731 }
9732
9733 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9734 ret = wlan_hdd_validate_context(pHddCtx);
9735 if (0 != ret)
9736 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309737 return ret;
9738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9740 "Power Params data len %d data %s",
9741 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009742 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009743
9744 if (wrqu->data.length <= nOffset )
9745 {
9746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9747 return VOS_STATUS_E_FAILURE;
9748 }
9749
9750 uTotalSize = wrqu->data.length - nOffset;
9751
9752 /*-----------------------------------------------------------------------
9753 Input is string based and expected to be like this:
9754
9755 <param_type> <param_value> <param_type> <param_value> ...
9756
9757 e.g:
9758 1 2 2 3 3 0 4 1 5 1
9759
9760 e.g. setting just a few:
9761 1 2 4 1
9762
9763 parameter types:
9764 -----------------------------
9765 1 - Ignore DTIM
9766 2 - Listen Interval
9767 3 - Broadcast Multicas Filter
9768 4 - Beacon Early Termination
9769 5 - Beacon Early Termination Interval
9770 -----------------------------------------------------------------------*/
9771 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9772 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9773 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9774 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9775 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9776
Arif Hussain7adce1b2013-11-11 22:59:34 -08009777 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009778
9779 while ( uTotalSize )
9780 {
Wilson Yang6f971452013-10-08 15:00:00 -07009781 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9782 {
9783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9784 "Invalid input parameter type %s",ptr);
9785 return VOS_STATUS_E_FAILURE;
9786 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009787
9788 uTotalSize -= nOffset;
9789
9790 if (!uTotalSize)
9791 {
9792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009793 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009794 ucType, nOffset);
9795 return VOS_STATUS_E_FAILURE;
9796 }
9797
9798 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009799
Jeff Johnson02797792013-10-26 19:17:13 -07009800 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009801 {
9802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9803 "Invalid input parameter value %s",ptr);
9804 return VOS_STATUS_E_FAILURE;
9805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009806
9807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9808 "Power request parameter %d value %d offset %d",
9809 ucType, uValue, nOffset);
9810
9811 switch (ucType)
9812 {
9813 case eSIR_IGNORE_DTIM:
9814 powerRequest.uIgnoreDTIM = uValue;
9815 break;
9816 case eSIR_LISTEN_INTERVAL:
9817 powerRequest.uListenInterval = uValue;
9818 break;
9819 case eSIR_MCAST_BCAST_FILTER:
9820 powerRequest.uBcastMcastFilter = uValue;
9821 break;
9822 case eSIR_ENABLE_BET:
9823 powerRequest.uEnableBET = uValue;
9824 break;
9825 case eSIR_BET_INTERVAL:
9826 powerRequest.uBETInterval = uValue;
9827 break;
9828 default:
9829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009830 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 ucType, uValue, nOffset);
9832 return VOS_STATUS_E_FAILURE;
9833 }
9834
9835 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9837 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009838 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009839 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009840 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009841 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009842 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9843 {
9844 uTotalSize = 0;
9845 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009846
9847 }/*Go for as long as we have a valid string*/
9848
9849 /* put the device into full power*/
9850 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9851
9852 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009853 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009854
9855 /* put the device back to power save*/
9856 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9857
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309858 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 return VOS_STATUS_SUCCESS;
9860}/*iw_set_power_params*/
9861
Atul Mittalc0f739f2014-07-31 13:47:47 +05309862// tdlsoffchan
9863#ifdef FEATURE_WLAN_TDLS
9864
Atul Mittal87ec2422014-09-24 13:12:50 +05309865int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309866{
9867 if (offchannel < 0 || offchannel > 165)
9868 {
9869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9870 __func__, offchannel);
9871 return -1;
9872
9873 }
9874
9875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9876 __func__, tdlsOffCh, offchannel);
9877
9878 tdlsOffCh = offchannel;
9879 return 0;
9880}
9881
Atul Mittal87ec2422014-09-24 13:12:50 +05309882int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309883{
9884 if (offchanoffset == 0)
9885 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309886 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9888 __func__, tdlsOffChBwOffset);
9889
9890 return 0;
9891
9892 }
9893
9894 if ( offchanoffset == 40 )
9895 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309896 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9898 __func__, tdlsOffChBwOffset);
9899
9900 return 0;
9901
9902 }
9903 if (offchanoffset == -40)
9904 {
9905 tdlsOffChBwOffset = 3;
9906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9907 __func__, tdlsOffChBwOffset);
9908
9909 return 0;
9910
9911 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +05309912
9913 if ((offchanoffset == 80) &&
9914 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
9915 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
9916 {
9917 tdlsOffChBwOffset = 4;
9918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9919 "%s: change tdls secondary off channel offset to %u",
9920 __func__, tdlsOffChBwOffset);
9921
9922 return 0;
9923 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05309924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9925 __func__, offchanoffset);
9926 return -1;
9927}
9928
Atul Mittal87ec2422014-09-24 13:12:50 +05309929int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309930{
9931 hddTdlsPeer_t *connPeer = NULL;
9932 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9933 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9934
9935 if (offchanmode < 0 || offchanmode > 4)
9936 {
9937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9938 "%s: Invalid tdls off channel mode %d",
9939 __func__, offchanmode);
9940 return -1;
9941 }
9942
9943 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9944 {
9945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9946 "%s: tdls off channel mode req in not associated state %d",
9947 __func__, offchanmode);
9948 return -1;
9949 }
9950
9951 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9952 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9953 {
9954 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309955 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309956 if (NULL == connPeer) {
9957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9958 "%s: No TDLS Connected Peer", __func__);
9959 return -1;
9960 }
9961 }
9962 else
9963 {
9964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9965 "%s: TDLS Connection not supported", __func__);
9966 return -1;
9967 }
9968
9969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9970 ("%s: TDLS Channel Switch in swmode=%d"),
9971 __func__, offchanmode);
9972
9973 switch (offchanmode)
9974 {
9975 case 1:/*Enable*/
9976 case 2:/*Disable*/
9977 {
9978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9979 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9980 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9981 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9982 {
9983
9984 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9985 pAdapter->sessionId, connPeer->peerMac,
9986 tdlsOffCh, tdlsOffChBwOffset,
9987 offchanmode);
9988 }
9989 else
9990 {
9991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9992 "%s: TDLS Off Channel not supported", __func__);
9993 return -1;
9994 }
9995 break;
9996 }
9997 case 3:
9998 {
9999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10000 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
10001 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10002
10003 break;
10004 }
10005 case 4:
10006 {
10007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10008 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
10009 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10010 break;
10011 }
10012 default:
10013 {
10014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10015 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
10016 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
10017 break;
10018 }
10019
10020 }
10021
10022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
10023 __func__, offchanmode);
10024 return 0;
10025}
Atul Mittalc0f739f2014-07-31 13:47:47 +053010026#endif
10027
Jeff Johnson295189b2012-06-20 16:38:30 -070010028
10029// Define the Wireless Extensions to the Linux Network Device structure
10030// A number of these routines are NULL (meaning they are not implemented.)
10031
10032static const iw_handler we_handler[] =
10033{
10034 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10035 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10036 (iw_handler) NULL, /* SIOCSIWNWID */
10037 (iw_handler) NULL, /* SIOCGIWNWID */
10038 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10039 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10040 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10041 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10042 (iw_handler) NULL, /* SIOCSIWSENS */
10043 (iw_handler) NULL, /* SIOCGIWSENS */
10044 (iw_handler) NULL, /* SIOCSIWRANGE */
10045 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10046 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
10047 (iw_handler) NULL, /* SIOCGIWPRIV */
10048 (iw_handler) NULL, /* SIOCSIWSTATS */
10049 (iw_handler) NULL, /* SIOCGIWSTATS */
10050 iw_handler_set_spy, /* SIOCSIWSPY */
10051 iw_handler_get_spy, /* SIOCGIWSPY */
10052 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
10053 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
10054 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10055 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10056 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10057 (iw_handler) NULL, /* SIOCGIWAPLIST */
10058 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10059 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10060 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10061 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10062 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10063 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10064 (iw_handler) NULL, /* -- hole -- */
10065 (iw_handler) NULL, /* -- hole -- */
10066 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10067 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10068 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
10069 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
10070 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10071 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10072 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10073 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10074 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10075 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10076 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10077 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10078 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10079 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10080 (iw_handler) NULL, /* -- hole -- */
10081 (iw_handler) NULL, /* -- hole -- */
10082 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10083 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10084 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10085 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10086 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10087 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10088 (iw_handler) NULL, /* SIOCSIWPMKSA */
10089};
10090
10091static const iw_handler we_private[] = {
10092
10093 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
10094 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
10095 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
10096 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
10097 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10098 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +053010099 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10101 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10102 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -070010103#ifdef FEATURE_OEM_DATA_SUPPORT
10104 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
10105 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
10106#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010107
Jeff Johnson295189b2012-06-20 16:38:30 -070010108#ifdef WLAN_FEATURE_VOWIFI_11R
10109 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
10110#endif
10111 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10112 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10113 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
10114#ifdef WLAN_FEATURE_PACKET_FILTERING
10115 ,
10116 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
10117#endif
10118#ifdef FEATURE_WLAN_SCAN_PNO
10119 ,
10120 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
10121#endif
10122 ,
10123 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10124 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
10125 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
10126 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -070010127 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -070010128};
10129
10130/*Maximum command length can be only 15 */
10131static const struct iw_priv_args we_private_args[] = {
10132
Katya Nigamf0511f62015-05-05 16:40:57 +053010133 { WE_SET_MONITOR_STATE,
10134 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10135 0, "monitor" },
10136
Jeff Johnson295189b2012-06-20 16:38:30 -070010137 /* handlers for main ioctl */
10138 { WLAN_PRIV_SET_INT_GET_NONE,
10139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10140 0,
10141 "" },
10142
10143 /* handlers for sub-ioctl */
10144 { WE_SET_11D_STATE,
10145 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10146 0,
10147 "set11Dstate" },
10148
10149 { WE_WOWL,
10150 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10151 0,
10152 "wowl" },
10153
10154 { WE_SET_POWER,
10155 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10156 0,
10157 "setPower" },
10158
10159 { WE_SET_MAX_ASSOC,
10160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10161 0,
10162 "setMaxAssoc" },
10163
10164 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10166 0,
10167 "setAutoChannel" },
10168
10169 { WE_SET_DATA_INACTIVITY_TO,
10170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10171 0,
10172 "inactivityTO" },
10173
10174 { WE_SET_MAX_TX_POWER,
10175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10176 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010177 "setMaxTxPower" },
10178
10179 { WE_SET_MAX_TX_POWER_2_4,
10180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10181 0,
10182 "setTxMaxPower2G" },
10183
10184 { WE_SET_MAX_TX_POWER_5_0,
10185 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10186 0,
10187 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010188
10189 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10190 * as well to keep same syntax as in SAP. Now onwards, STA
10191 * will support both */
10192 { WE_SET_MAX_TX_POWER,
10193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10194 0,
10195 "setTxMaxPower" },
10196
Jeff Johnson295189b2012-06-20 16:38:30 -070010197 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10198 * 1 = enable and 0 = disable */
10199 {
10200 WE_SET_HIGHER_DTIM_TRANSITION,
10201 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10202 0,
10203 "setHDtimTransn" },
10204
10205 { WE_SET_TM_LEVEL,
10206 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010207 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 "setTmLevel" },
10209
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010210 { WE_ENABLE_STRICT_FCC_REG,
10211 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10212 0,
10213 "setStrictFCCreg" },
10214
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010215 { WE_SET_DEBUG_LOG,
10216 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10217 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010218#ifdef FEATURE_WLAN_TDLS
10219 {
10220 WE_SET_TDLS_OFF_CHAN,
10221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10222 0,
10223 "tdlsoffchan" },
10224 {
10225 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10227 0,
10228 "tdlsecchnoffst" },
10229 {
10230 WE_SET_TDLS_OFF_CHAN_MODE,
10231 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10232 0,
10233 "tdlsoffchnmode" },
10234#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010235
Peng Xu2446a892014-09-05 17:21:18 +053010236 { WE_SET_SCAN_BAND_PREFERENCE,
10237 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10238 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010239 {
10240 WE_GET_FRAME_LOG,
10241 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10242 0,
10243 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010244
Abhishek Singh01c73d12015-03-12 15:13:44 +053010245 { WE_SET_MIRACAST_VENDOR_CONFIG,
10246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10247 0, "setMiracstConf" },
10248
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010249#ifdef FEATURE_WLAN_TDLS
10250 {
10251 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10252 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10253 0,
10254 "tdls_2040bsscox" },
10255#endif
Abhishek Singh41988ba2015-05-25 19:42:29 +053010256 { WE_SET_RTS_CTS_HTVHT,
10257 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10258 0, "setRtsCtsHtVht" },
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010259
Jeff Johnson295189b2012-06-20 16:38:30 -070010260 /* handlers for main ioctl */
10261 { WLAN_PRIV_SET_NONE_GET_INT,
10262 0,
10263 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10264 "" },
10265
10266 /* handlers for sub-ioctl */
10267 { WE_GET_11D_STATE,
10268 0,
10269 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10270 "get11Dstate" },
10271
10272 { WE_IBSS_STATUS,
10273 0,
10274 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10275 "getAdhocStatus" },
10276
10277 { WE_PMC_STATE,
10278 0,
10279 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10280 "pmcState" },
10281
10282 { WE_GET_WLAN_DBG,
10283 0,
10284 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10285 "getwlandbg" },
10286
Jeff Johnson295189b2012-06-20 16:38:30 -070010287 { WE_GET_MAX_ASSOC,
10288 0,
10289 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10290 "getMaxAssoc" },
10291
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 { WE_GET_WDI_DBG,
10293 0,
10294 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10295 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010296
10297 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10298 0,
10299 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10300 "getAutoChannel" },
10301
10302 { WE_GET_CONCURRENCY_MODE,
10303 0,
10304 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10305 "getconcurrency" },
10306
Peng Xu2446a892014-09-05 17:21:18 +053010307 { WE_GET_SCAN_BAND_PREFERENCE,
10308 0,
10309 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10310 "get_scan_pref"},
10311
Jeff Johnson295189b2012-06-20 16:38:30 -070010312 /* handlers for main ioctl */
10313 { WLAN_PRIV_SET_CHAR_GET_NONE,
10314 IW_PRIV_TYPE_CHAR| 512,
10315 0,
10316 "" },
10317
10318 /* handlers for sub-ioctl */
10319 { WE_WOWL_ADD_PTRN,
10320 IW_PRIV_TYPE_CHAR| 512,
10321 0,
10322 "wowlAddPtrn" },
10323
10324 { WE_WOWL_DEL_PTRN,
10325 IW_PRIV_TYPE_CHAR| 512,
10326 0,
10327 "wowlDelPtrn" },
10328
10329#if defined WLAN_FEATURE_VOWIFI
10330 /* handlers for sub-ioctl */
10331 { WE_NEIGHBOR_REPORT_REQUEST,
10332 IW_PRIV_TYPE_CHAR | 512,
10333 0,
10334 "neighbor" },
10335#endif
10336 { WE_SET_AP_WPS_IE,
10337 IW_PRIV_TYPE_CHAR| 512,
10338 0,
10339 "set_ap_wps_ie" },
10340
10341 { WE_SET_CONFIG,
10342 IW_PRIV_TYPE_CHAR| 512,
10343 0,
10344 "setConfig" },
10345
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010346 { WE_SET_ENCRYPT_MSG,
10347 IW_PRIV_TYPE_CHAR| 512,
10348 0,
10349 "encryptMsg" },
10350
10351
Jeff Johnson295189b2012-06-20 16:38:30 -070010352 /* handlers for main ioctl */
10353 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10354 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10355 0,
10356 "" },
10357
10358 /* handlers for sub-ioctl */
10359 { WE_SET_WLAN_DBG,
10360 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10361 0,
10362 "setwlandbg" },
10363
Jeff Johnson295189b2012-06-20 16:38:30 -070010364 { WE_SET_WDI_DBG,
10365 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10366 0,
10367 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010368
10369 { WE_SET_SAP_CHANNELS,
10370 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10371 0,
10372 "setsapchannels" },
10373
10374 /* handlers for main ioctl */
10375 { WLAN_PRIV_GET_CHAR_SET_NONE,
10376 0,
10377 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10378 "" },
10379
10380 /* handlers for sub-ioctl */
10381 { WE_WLAN_VERSION,
10382 0,
10383 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10384 "version" },
10385 { WE_GET_STATS,
10386 0,
10387 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10388 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010389 { WE_GET_STATES,
10390 0,
10391 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10392 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010393 { WE_GET_CFG,
10394 0,
10395 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10396 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010397#ifdef WLAN_FEATURE_11AC
10398 { WE_GET_RSSI,
10399 0,
10400 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10401 "getRSSI" },
10402#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010403#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010404 { WE_GET_ROAM_RSSI,
10405 0,
10406 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10407 "getRoamRSSI" },
10408#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010409 { WE_GET_WMM_STATUS,
10410 0,
10411 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10412 "getWmmStatus" },
10413 {
10414 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010415 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10417 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010418#ifdef FEATURE_WLAN_TDLS
10419 {
10420 WE_GET_TDLS_PEERS,
10421 0,
10422 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10423 "getTdlsPeers" },
10424#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010425#ifdef WLAN_FEATURE_11W
10426 {
10427 WE_GET_11W_INFO,
10428 0,
10429 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10430 "getPMFInfo" },
10431#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010432 { WE_GET_SNR,
10433 0,
10434 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10435 "getSNR" },
10436
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 /* handlers for main ioctl */
10438 { WLAN_PRIV_SET_NONE_GET_NONE,
10439 0,
10440 0,
10441 "" },
10442
10443 /* handlers for sub-ioctl */
10444 { WE_CLEAR_STATS,
10445 0,
10446 0,
10447 "clearStats" },
10448 { WE_INIT_AP,
10449 0,
10450 0,
10451 "initAP" },
10452 { WE_STOP_AP,
10453 0,
10454 0,
10455 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010456#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 { WE_ENABLE_AMP,
10458 0,
10459 0,
10460 "enableAMP" },
10461 { WE_DISABLE_AMP,
10462 0,
10463 0,
10464 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010465#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010466 { WE_ENABLE_DXE_STALL_DETECT,
10467 0,
10468 0,
10469 "dxeStallDetect" },
10470 { WE_DISPLAY_DXE_SNAP_SHOT,
10471 0,
10472 0,
10473 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010474 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10475 0,
10476 0,
10477 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010478 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010479 WE_SET_REASSOC_TRIGGER,
10480 0,
10481 0,
10482 "reassoc" },
10483 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010484 WE_STOP_OBSS_SCAN,
10485 0,
10486 0,
10487 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010488 {
10489 WE_DUMP_ROAM_TIMER_LOG,
10490 0,
10491 0,
10492 "dumpRoamDelay" },
10493 {
10494 WE_RESET_ROAM_TIMER_LOG,
10495 0,
10496 0,
10497 "resetRoamDelay" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010498 /* handlers for main ioctl */
10499 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10500 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10501 0,
10502 "" },
10503
10504 /* handlers for sub-ioctl */
10505 { WE_LOG_DUMP_CMD,
10506 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10507 0,
10508 "dump" },
10509
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010510 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010511 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10512 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10513 0,
10514 "setdumplog" },
10515
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010516 { WE_MTRACE_DUMP_CMD,
10517 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10518 0,
10519 "dumplog" },
10520
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010521 /* handlers for sub ioctl */
10522 {
10523 WE_MCC_CONFIG_CREDENTIAL,
10524 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10525 0,
10526 "setMccCrdnl" },
10527
10528 /* handlers for sub ioctl */
10529 {
10530 WE_MCC_CONFIG_PARAMS,
10531 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10532 0,
10533 "setMccConfig" },
10534
Chilam NG571c65a2013-01-19 12:27:36 +053010535#ifdef FEATURE_WLAN_TDLS
10536 /* handlers for sub ioctl */
10537 {
10538 WE_TDLS_CONFIG_PARAMS,
10539 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10540 0,
10541 "setTdlsConfig" },
10542#endif
10543
Katya Nigamf0511f62015-05-05 16:40:57 +053010544 {
10545 WE_CONFIGURE_MONITOR_MODE,
10546 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10547 0,
10548 "MonitorModeConf" },
10549
10550 {
10551 WE_SET_MONITOR_MODE_FILTER,
10552 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10553 0,
10554 "MonitorFilter" },
10555
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 /* handlers for main ioctl */
10557 { WLAN_PRIV_ADD_TSPEC,
10558 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10559 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10560 "addTspec" },
10561
10562 /* handlers for main ioctl */
10563 { WLAN_PRIV_DEL_TSPEC,
10564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10565 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10566 "delTspec" },
10567
10568 /* handlers for main ioctl */
10569 { WLAN_PRIV_GET_TSPEC,
10570 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10571 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10572 "getTspec" },
10573
Jeff Johnsone7245742012-09-05 17:12:55 -070010574#ifdef FEATURE_OEM_DATA_SUPPORT
10575 /* handlers for main ioctl - OEM DATA */
10576 {
10577 WLAN_PRIV_SET_OEM_DATA_REQ,
10578 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10579 0,
10580 "set_oem_data_req" },
10581
10582 /* handlers for main ioctl - OEM DATA */
10583 {
10584 WLAN_PRIV_GET_OEM_DATA_RSP,
10585 0,
10586 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10587 "get_oem_data_rsp" },
10588#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010589
Jeff Johnson295189b2012-06-20 16:38:30 -070010590 /* handlers for main ioctl - host offload */
10591 {
10592 WLAN_PRIV_SET_HOST_OFFLOAD,
10593 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10594 0,
10595 "setHostOffload" },
10596
10597 {
10598 WLAN_GET_WLAN_STATISTICS,
10599 0,
10600 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10601 "getWlanStats" },
10602
10603 {
10604 WLAN_SET_KEEPALIVE_PARAMS,
10605 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10606 0,
10607 "setKeepAlive" },
10608#ifdef WLAN_FEATURE_PACKET_FILTERING
10609 {
10610 WLAN_SET_PACKET_FILTER_PARAMS,
10611 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10612 0,
10613 "setPktFilter" },
10614#endif
10615#ifdef FEATURE_WLAN_SCAN_PNO
10616 {
10617 WLAN_SET_PNO,
10618 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10619 0,
10620 "setpno" },
10621#endif
10622 {
10623 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010624 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010625 0,
10626 "SETBAND" },
10627 /* handlers for dynamic MC BC ioctl */
10628 {
10629 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010630 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010631 0,
10632 "setMCBCFilter" },
10633 {
10634 WLAN_PRIV_CLEAR_MCBC_FILTER,
10635 0,
10636 0,
10637 "clearMCBCFilter" },
10638 {
10639 WLAN_SET_POWER_PARAMS,
10640 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10641 0,
10642 "setpowerparams" },
10643 {
10644 WLAN_GET_LINK_SPEED,
10645 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010646 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010647};
10648
10649
10650
10651const struct iw_handler_def we_handler_def = {
10652 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10653 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10654 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10655
10656 .standard = (iw_handler *)we_handler,
10657 .private = (iw_handler *)we_private,
10658 .private_args = we_private_args,
10659 .get_wireless_stats = get_wireless_stats,
10660};
10661
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010662int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10663{
10664 v_U32_t cmd = 288; //Command to RIVA
10665 hdd_context_t *pHddCtx = NULL;
10666 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10667 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10668 /*
10669 *configMccParam : specify the bit which needs to be modified
10670 *allowed to update based on wlan_qcom_cfg.ini
10671 * configuration
10672 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10673 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10674 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10675 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10676 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10677 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10678 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10679 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10680 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10681 * Bit 9 : Reserved
10682 */
10683 switch (arg1)
10684 {
10685 //Update MCC SCHEDULE_TIME_SLICE parameter
10686 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10687 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10688 {
10689 if((arg2 >= 5) && (arg2 <= 20))
10690 {
10691 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10692 }
10693 else
10694 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010695 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010696 return 0;
10697 }
10698 }
10699 break;
10700
10701 //Update MCC MAX_NULL_SEND_TIME parameter
10702 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10703 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10704 {
10705 if((arg2 >= 1) && (arg2 <= 10))
10706 {
10707 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10708 }
10709 else
10710 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010711 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010712 return 0;
10713 }
10714 }
10715 break;
10716
10717 //Update MCC TX_EARLY_STOP_TIME parameter
10718 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10719 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10720 {
10721 if((arg2 >= 1) && (arg2 <= 10))
10722 {
10723 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10724 }
10725 else
10726 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010727 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010728 return 0;
10729 }
10730 }
10731 break;
10732
10733 //Update MCC RX_DRAIN_TIME parameter
10734 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10735 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10736 {
10737 if((arg2 >= 1) && (arg2 <= 10))
10738 {
10739 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10740 }
10741 else
10742 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010743 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010744 return 0;
10745 }
10746 }
10747 break;
10748
10749 //Update MCC CHANNEL_SWITCH_TIME parameter
10750 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10751 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10752 {
10753 if((arg2 >= 1) && (arg2 <= 20))
10754 {
10755 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10756 }
10757 else
10758 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010759 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010760 return 0;
10761 }
10762 }
10763 break;
10764
10765 //Update MCC MIN_CHANNEL_TIME parameter
10766 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10767 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10768 {
10769 if((arg2 >= 5) && (arg2 <= 20))
10770 {
10771 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10772 }
10773 else
10774 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010775 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010776 return 0;
10777 }
10778 }
10779 break;
10780
10781 //Update MCC PARK_BEFORE_TBTT parameter
10782 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10783 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10784 {
10785 if((arg2 >= 1) && (arg2 <= 5))
10786 {
10787 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10788 }
10789 else
10790 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010791 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010792 return 0;
10793 }
10794 }
10795 break;
10796
10797 //Update MCC MIN_AFTER_DTIM parameter
10798 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10799 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10800 {
10801 if((arg2 >= 5) && (arg2 <= 15))
10802 {
10803 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10804 }
10805 else
10806 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010807 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010808 return 0;
10809 }
10810 }
10811 break;
10812
10813 //Update MCC TOO_CLOSE_MARGIN parameter
10814 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10815 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10816 {
10817 if((arg2 >= 1) && (arg2 <= 3))
10818 {
10819 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10820 }
10821 else
10822 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010823 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010824 return 0;
10825 }
10826 }
10827 break;
10828
10829 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010830 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010831 __FUNCTION__,arg1);
10832 break;
10833 }
10834 return 0;
10835}
10836
Jeff Johnson295189b2012-06-20 16:38:30 -070010837int hdd_set_wext(hdd_adapter_t *pAdapter)
10838{
10839 hdd_wext_state_t *pwextBuf;
10840 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010841 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010842
10843 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10844
10845 // Now configure the roaming profile links. To SSID and bssid.
10846 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10847 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10848
10849 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10850 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10851
10852 /*Set the numOfChannels to zero to scan all the channels*/
10853 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10854 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10855
10856 /* Default is no encryption */
10857 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10858 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10859
10860 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10861 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10862
10863 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10864
10865 /* Default is no authentication */
10866 pwextBuf->roamProfile.AuthType.numEntries = 1;
10867 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10868
10869 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10870 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10871
10872 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010873 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010874
10875 hdd_clearRoamProfileIe(pAdapter);
10876
10877 return VOS_STATUS_SUCCESS;
10878
10879 }
10880
10881int hdd_register_wext(struct net_device *dev)
10882 {
10883 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10884 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10885 VOS_STATUS status;
10886
10887 ENTER();
10888
10889 // Zero the memory. This zeros the profile structure.
10890 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10891
10892 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10893
10894
10895 status = hdd_set_wext(pAdapter);
10896
10897 if(!VOS_IS_STATUS_SUCCESS(status)) {
10898
Arif Hussain6d2a3322013-11-17 19:50:10 -080010899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010900 return eHAL_STATUS_FAILURE;
10901 }
10902
10903 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10904 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010906 return eHAL_STATUS_FAILURE;
10907 }
10908
10909 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10910 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010912 return eHAL_STATUS_FAILURE;
10913 }
10914
10915 // Register as a wireless device
10916 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10917
10918 EXIT();
10919 return 0;
10920}
10921
10922int hdd_UnregisterWext(struct net_device *dev)
10923{
c_hpothu2a13bc32015-01-21 12:48:54 +053010924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10925 if (dev != NULL)
10926 {
10927 rtnl_lock();
10928 dev->wireless_handlers = NULL;
10929 rtnl_unlock();
10930 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010931
Jeff Johnson295189b2012-06-20 16:38:30 -070010932 return 0;
10933}
10934
10935