blob: 12a0d73e34d8d8aaa47c4da07c41290670427748 [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>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053053#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include <wlan_hdd_includes.h>
55#include <wlan_btc_svc.h>
56#include <wlan_nlink_common.h>
57#ifdef WLAN_BTAMP_FEATURE
58#include <bap_hdd_main.h>
59#endif
60#include <vos_api.h>
61#include <net/arp.h>
62#include "ccmApi.h"
63#include "sirParams.h"
64#include "csrApi.h"
65#include "csrInsideApi.h"
66#if defined WLAN_FEATURE_VOWIFI
67#include "smeRrmInternal.h"
68#endif
69#include <aniGlobal.h>
70#include "dot11f.h"
71#include <wlan_hdd_wowl.h>
72#include <wlan_hdd_cfg.h>
73#include <wlan_hdd_wmm.h>
74#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070075#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053076#ifdef FEATURE_WLAN_TDLS
77#include "wlan_hdd_tdls.h"
78#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070079
80#ifdef CONFIG_HAS_EARLYSUSPEND
81#include <linux/earlysuspend.h>
82#endif
83#include "wlan_hdd_power.h"
84#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070085#include "wlan_hdd_host_offload.h"
86#include "wlan_hdd_keep_alive.h"
87#ifdef WLAN_FEATURE_PACKET_FILTERING
88#include "wlan_hdd_packet_filtering.h"
89#endif
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091#include <linux/wireless.h>
92#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053094#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96#include "wlan_hdd_misc.h"
97#include "bap_hdd_misc.h"
98
99#include "wlan_hdd_dev_pwr.h"
100#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530101#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700102#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530103#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
Mukul Sharma84f27252014-07-14 18:11:42 +0530105#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530106#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#ifdef CONFIG_HAS_EARLYSUSPEND
109extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
110extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
111#endif
112
Jeff Johnsone7245742012-09-05 17:12:55 -0700113#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800114#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700115#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700116
117#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530118#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700119
Jeff Johnson295189b2012-06-20 16:38:30 -0700120
Atul Mittalc0f739f2014-07-31 13:47:47 +0530121// tdlsoffchan
122#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530123static int tdlsOffCh = 1;
124static int tdlsOffChBwOffset = 0;
125#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530126
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700127static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
129
Jeff Johnson295189b2012-06-20 16:38:30 -0700130/* To Validate Channel against the Frequency and Vice-Versa */
131static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
132 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
133 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
134 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
135 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
136 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
137 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
138 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800139 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
140 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700141
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800142#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700143
144/* Private ioctls and their sub-ioctls */
145#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
146#define WE_SET_11D_STATE 1
147#define WE_WOWL 2
148#define WE_SET_POWER 3
149#define WE_SET_MAX_ASSOC 4
150#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
151#define WE_SET_DATA_INACTIVITY_TO 6
152#define WE_SET_MAX_TX_POWER 7
153#define WE_SET_HIGHER_DTIM_TRANSITION 8
154#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530155#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700156#define WE_SET_MAX_TX_POWER_2_4 11
157#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800158/* Private IOCTL for debug connection issues */
159#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530160// tdlsoffchan
161#ifdef FEATURE_WLAN_TDLS
162#define WE_SET_TDLS_OFF_CHAN 14
163#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
164#define WE_SET_TDLS_OFF_CHAN_MODE 16
165#endif
Peng Xu2446a892014-09-05 17:21:18 +0530166#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530167#define WE_SET_MIRACAST_VENDOR_CONFIG 18
168
Jeff Johnson295189b2012-06-20 16:38:30 -0700169
170/* Private ioctls and their sub-ioctls */
171#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
172#define WE_GET_11D_STATE 1
173#define WE_IBSS_STATUS 2
174#define WE_PMC_STATE 3
175#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700176#define WE_GET_MAX_ASSOC 6
177#define WE_GET_WDI_DBG 7
178#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
179#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530180#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700181/* Private ioctls and their sub-ioctls */
182#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
183
184/* Private ioctls and their sub-ioctls */
185#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
186#define WE_WOWL_ADD_PTRN 1
187#define WE_WOWL_DEL_PTRN 2
188#if defined WLAN_FEATURE_VOWIFI
189#define WE_NEIGHBOR_REPORT_REQUEST 3
190#endif
191#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
192#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530193#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700194
195/* Private ioctls and their sub-ioctls */
196#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
197#define WE_SET_WLAN_DBG 1
198#define WE_SET_WDI_DBG 2
199#define WE_SET_SAP_CHANNELS 3
200
201/* Private ioctls and their sub-ioctls */
202#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
203#define WE_WLAN_VERSION 1
204#define WE_GET_STATS 2
205#define WE_GET_CFG 3
206#define WE_GET_WMM_STATUS 4
207#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700208#ifdef WLAN_FEATURE_11AC
209#define WE_GET_RSSI 6
210#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800211#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800212#ifdef FEATURE_WLAN_TDLS
213#define WE_GET_TDLS_PEERS 8
214#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700215#ifdef WLAN_FEATURE_11W
216#define WE_GET_11W_INFO 9
217#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530218#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530219#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700220
221/* Private ioctls and their sub-ioctls */
222#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
223#define WE_CLEAR_STATS 1
224#define WE_INIT_AP 2
225#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530226#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700227#define WE_ENABLE_AMP 4
228#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530229#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700230#define WE_ENABLE_DXE_STALL_DETECT 6
231#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700232#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530233#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530234#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530235#define WE_DUMP_ROAM_TIMER_LOG 12
236#define WE_RESET_ROAM_TIMER_LOG 13
Mukul Sharma84f27252014-07-14 18:11:42 +0530237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238/* Private ioctls and their sub-ioctls */
239#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
240#define WE_LOG_DUMP_CMD 1
241
Jeff Johnson295189b2012-06-20 16:38:30 -0700242#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800243//IOCTL to configure MCC params
244#define WE_MCC_CONFIG_CREDENTIAL 3
245#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700246
Chilam NG571c65a2013-01-19 12:27:36 +0530247#ifdef FEATURE_WLAN_TDLS
248#define WE_TDLS_CONFIG_PARAMS 5
249#endif
250
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700251#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530252#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700253
Chilam Ng01120412013-02-19 18:32:21 -0800254#ifdef FEATURE_WLAN_TDLS
255#undef MAX_VAR_ARGS
256#define MAX_VAR_ARGS 10
257#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700258#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800259#endif
260
Jeff Johnson295189b2012-06-20 16:38:30 -0700261/* Private ioctls (with no sub-ioctls) */
262/* note that they must be odd so that they have "get" semantics */
263#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
264#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
265#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
266
Girish Gowli464c9c82014-06-09 19:47:53 +0530267/* (SIOCIWFIRSTPRIV + 8) is currently unused */
268/* (SIOCIWFIRSTPRIV + 16) is currently unused */
269/* (SIOCIWFIRSTPRIV + 10) is currently unused */
270/* (SIOCIWFIRSTPRIV + 12) is currently unused */
271/* (SIOCIWFIRSTPRIV + 14) is currently unused */
272/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
Jeff Johnsone7245742012-09-05 17:12:55 -0700274#ifdef FEATURE_OEM_DATA_SUPPORT
275/* Private ioctls for setting the measurement configuration */
276#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
277#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
278#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280#ifdef WLAN_FEATURE_VOWIFI_11R
281#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
282#endif
283
284/* Private ioctl for setting the host offload feature */
285#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
286
287/* Private ioctl to get the statistics */
288#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
289
290/* Private ioctl to set the Keep Alive Params */
291#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
292#ifdef WLAN_FEATURE_PACKET_FILTERING
293/* Private ioctl to set the Packet Filtering Params */
294#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
295#endif
296
297#ifdef FEATURE_WLAN_SCAN_PNO
298/* Private ioctl to get the statistics */
299#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
300#endif
301
302#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
303
304#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
305#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700306/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700307
Jeff Johnson295189b2012-06-20 16:38:30 -0700308#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
309#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
310
311#define WLAN_STATS_INVALID 0
312#define WLAN_STATS_RETRY_CNT 1
313#define WLAN_STATS_MUL_RETRY_CNT 2
314#define WLAN_STATS_TX_FRM_CNT 3
315#define WLAN_STATS_RX_FRM_CNT 4
316#define WLAN_STATS_FRM_DUP_CNT 5
317#define WLAN_STATS_FAIL_CNT 6
318#define WLAN_STATS_RTS_FAIL_CNT 7
319#define WLAN_STATS_ACK_FAIL_CNT 8
320#define WLAN_STATS_RTS_SUC_CNT 9
321#define WLAN_STATS_RX_DISCARD_CNT 10
322#define WLAN_STATS_RX_ERROR_CNT 11
323#define WLAN_STATS_TX_BYTE_CNT 12
324
325#define WLAN_STATS_RX_BYTE_CNT 13
326#define WLAN_STATS_RX_RATE 14
327#define WLAN_STATS_TX_RATE 15
328
Jeff Johnsone7245742012-09-05 17:12:55 -0700329#define WLAN_STATS_RX_UC_BYTE_CNT 16
330#define WLAN_STATS_RX_MC_BYTE_CNT 17
331#define WLAN_STATS_RX_BC_BYTE_CNT 18
332#define WLAN_STATS_TX_UC_BYTE_CNT 19
333#define WLAN_STATS_TX_MC_BYTE_CNT 20
334#define WLAN_STATS_TX_BC_BYTE_CNT 21
335
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800336#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
337 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
338 { \
339 *__p++ = __type; \
340 *__p++ = __size; \
341 memcpy(__p, __val, __size); \
342 __p += __size; \
343 __tlen += __size + 2; \
344 } \
345 else \
346 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800347 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800348 } \
349 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700350
351#define VERSION_VALUE_MAX_LEN 32
352
353#define TX_PER_TRACKING_DEFAULT_RATIO 5
354#define TX_PER_TRACKING_MAX_RATIO 10
355#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
356
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530357#define WLAN_ADAPTER 0
358#define P2P_ADAPTER 1
359
Abhishek Singh2ec36ab2014-08-07 16:14:25 +0530360/*
361 * When supplicant sends SETBAND ioctl it queries for channels from
362 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
363 * This is not required if the return type from ioctl is
364 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
365 * event as part of regulatory_hint.
366 */
367enum {
368 SEND_CHANNEL_CHANGE_EVENT = 0,
369 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
370};
371
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800372/*MCC Configuration parameters */
373enum {
374 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
375 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
376 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
377 MCC_RX_DRAIN_TIME_CFG_PARAM,
378 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
379 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
380 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
381 MCC_MIN_AFTER_DTIM_CFG_PARAM,
382 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
383};
384
385int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
386 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
387
Jeff Johnson295189b2012-06-20 16:38:30 -0700388#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800389int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700390 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700391#endif
392
Jeff Johnson295189b2012-06-20 16:38:30 -0700393/**---------------------------------------------------------------------------
394
Arif Hussain0273cba2014-01-07 20:58:29 -0800395 \brief mem_alloc_copy_from_user_helper -
396
397 Helper function to allocate buffer and copy user data.
398
399 \param - wrqu - Pointer to IOCTL Data.
400 len - size
401
402 \return - On Success pointer to buffer, On failure NULL
403
404 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530405void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800406{
407 u8 *ptr = NULL;
408
409 /* in order to protect the code, an extra byte is post appended to the buffer
410 * and the null termination is added. However, when allocating (len+1) byte
411 * of memory, we need to make sure that there is no uint overflow when doing
412 * addition. In theory check len < UINT_MAX protects the uint overflow. For
413 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
414 * guess, now, it is assumed that the private command buffer size is no
415 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
416 */
417 if (len > MAX_USER_COMMAND_SIZE)
418 {
419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
420 "Invalid length");
421 return NULL;
422 }
423
424 ptr = kmalloc(len + 1, GFP_KERNEL);
425 if (NULL == ptr)
426 {
427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
428 "unable to allocate memory");
429 return NULL;
430 }
431
432 if (copy_from_user(ptr, wrqu_data, len))
433 {
434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
435 "%s: failed to copy data to user buffer", __func__);
436 kfree(ptr);
437 return NULL;
438 }
439 ptr[len] = '\0';
440 return ptr;
441}
442
Girish Gowli488ef492014-06-12 18:44:33 +0530443// Function to handle and get compatible struct iw_point passed to ioctl.
444int hdd_priv_get_data(struct iw_point *p_priv_data,
445 union iwreq_data *wrqu)
446{
447 if ((NULL == p_priv_data) || (NULL == wrqu))
448 {
449 return -EINVAL;
450 }
451
452#ifdef CONFIG_COMPAT
453 if (is_compat_task())
454 {
455 struct compat_iw_point *p_compat_priv_data;
456
457 // Compat task: typecast to campat structure and copy the members.
458 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
459
460 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
461 p_priv_data->length = p_compat_priv_data->length;
462 p_priv_data->flags = p_compat_priv_data->flags;
463 }//if(is_compat_task())
464 else
465 {
466#endif //#ifdef CONFIG_COMPAT
467
468 // Non compat task: directly copy the structure.
469 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
470
471#ifdef CONFIG_COMPAT
472 }//else of - if(is_compat_task())
473#endif //#ifdef CONFIG_COMPAT
474
475 return 0;
476}
477
Arif Hussain0273cba2014-01-07 20:58:29 -0800478/**---------------------------------------------------------------------------
479
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 \brief hdd_wlan_get_version() -
481
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800482 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700483
484 \param - pAdapter Pointer to the adapter.
485 wrqu - Pointer to IOCTL REQUEST Data.
486 extra - Pointer to char
487
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800488 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700489
490 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800491void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
492 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700493{
494 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800495 tSirVersionString wcnss_SW_version;
496 tSirVersionString wcnss_HW_version;
497 char *pSWversion;
498 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700500
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800501 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
502 sizeof(wcnss_SW_version));
503 if (VOS_IS_STATUS_SUCCESS(status))
504 {
505 pSWversion = wcnss_SW_version;
506 }
507 else
508 {
509 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 }
511
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800512 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
513 sizeof(wcnss_HW_version));
514 if (VOS_IS_STATUS_SUCCESS(status))
515 {
516 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700517 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800518 else
519 {
520 pHWversion = "Unknown";
521 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700523 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800524 "Host SW:%s, FW:%s, HW:%s",
525 QWLAN_VERSIONSTR,
526 pSWversion,
527 pHWversion);
528
529 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700530}
531
Jeff Johnson295189b2012-06-20 16:38:30 -0700532int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
533{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530534 tHalHandle hHal;
535 hdd_context_t *pHddCtx;
536 v_U32_t threshold = 0;
537 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700538
539 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530540 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530541 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
543 "%s: Adapter is NULL",__func__);
544 return -EINVAL;
545 }
546
547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
548 ret = wlan_hdd_validate_context(pHddCtx);
549 if (0 != ret)
550 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530551 return ret;
552 }
553
554 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
555 if (NULL == hHal)
556 {
557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
558 "%s: Hal Context is NULL",__func__);
559 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 }
561
562 if ( eHAL_STATUS_SUCCESS !=
563 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
564 {
c_hpothub8245442013-11-20 23:41:09 +0530565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
566 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700567 return -EIO;
568 }
569 wrqu->rts.value = threshold;
570
571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800572 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700573
574 EXIT();
575
576 return 0;
577}
578
579int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
580{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530581 tHalHandle hHal;
582 hdd_context_t *pHddCtx;
583 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700584
585 ENTER();
586
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530587 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530588 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
590 "%s: Adapter is NULL",__func__);
591 return -EINVAL;
592 }
593
594 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
595 status = wlan_hdd_validate_context(pHddCtx);
596 if (0 != status)
597 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530598 return status;
599 }
600
601 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
602 if (NULL == hHal)
603 {
604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
605 "%s: Hal Context is NULL",__func__);
606 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 }
608
609 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
610 != eHAL_STATUS_SUCCESS )
611 {
c_hpothub8245442013-11-20 23:41:09 +0530612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
613 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 return -EIO;
615 }
616 wrqu->frag.value = threshold;
617
618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800619 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700620
621 EXIT();
622
623 return 0;
624}
625
626int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
627{
Jeff Johnsone7245742012-09-05 17:12:55 -0700628 int i;
629 if (channel > 0)
630 {
631 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
632 {
633 if (channel == freq_chan_map[i].chan)
634 {
635 *pfreq = freq_chan_map[i].freq;
636 return 1;
637 }
638 }
639 }
640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800641 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700642 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700643}
644
645static v_BOOL_t
646hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
647{
648 v_BOOL_t rsnType = VOS_FALSE;
649 // is the authType supported?
650 switch (authType)
651 {
652 case eCSR_AUTH_TYPE_NONE: //never used
653 rsnType = eANI_BOOLEAN_FALSE;
654 break;
655 // MAC layer authentication types
656 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
657 rsnType = eANI_BOOLEAN_FALSE;
658 break;
659 case eCSR_AUTH_TYPE_SHARED_KEY:
660 rsnType = eANI_BOOLEAN_FALSE;
661 break;
662 case eCSR_AUTH_TYPE_AUTOSWITCH:
663 rsnType = eANI_BOOLEAN_FALSE;
664 break;
665
666 // Upper layer authentication types
667 case eCSR_AUTH_TYPE_WPA:
668 rsnType = eANI_BOOLEAN_TRUE;
669 break;
670 case eCSR_AUTH_TYPE_WPA_PSK:
671 rsnType = eANI_BOOLEAN_TRUE;
672 break;
673 case eCSR_AUTH_TYPE_WPA_NONE:
674 rsnType = eANI_BOOLEAN_TRUE;
675 break;
676#ifdef WLAN_FEATURE_VOWIFI_11R
677 case eCSR_AUTH_TYPE_FT_RSN:
678#endif
679 case eCSR_AUTH_TYPE_RSN:
680 rsnType = eANI_BOOLEAN_TRUE;
681 break;
682#ifdef WLAN_FEATURE_VOWIFI_11R
683 case eCSR_AUTH_TYPE_FT_RSN_PSK:
684#endif
685 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700686#ifdef WLAN_FEATURE_11W
687 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530688 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700689#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 rsnType = eANI_BOOLEAN_TRUE;
691 break;
692 //case eCSR_AUTH_TYPE_FAILED:
693 case eCSR_AUTH_TYPE_UNKNOWN:
694 rsnType = eANI_BOOLEAN_FALSE;
695 break;
696 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800697 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
698 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 rsnType = eANI_BOOLEAN_FALSE;
700 break;
701 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800702 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700703 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700704 return rsnType;
705}
706
707static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
708{
709 struct statsContext *pStatsContext;
710 hdd_adapter_t *pAdapter;
711
712 if (ioctl_debug)
713 {
714 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700715 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 }
717
718 if (NULL == pContext)
719 {
720 hddLog(VOS_TRACE_LEVEL_ERROR,
721 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700722 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 return;
724 }
725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 pStatsContext = pContext;
727 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800728
729 /* there is a race condition that exists between this callback
730 function and the caller since the caller could time out either
731 before or while this code is executing. we use a spinlock to
732 serialize these actions */
733 spin_lock(&hdd_context_lock);
734
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
736 {
737 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800738 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 hddLog(VOS_TRACE_LEVEL_WARN,
740 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700741 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 if (ioctl_debug)
743 {
744 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700745 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 }
747 return;
748 }
749
Jeff Johnson72a40512013-12-19 10:14:15 -0800750 /* context is valid so caller is still waiting */
751
752 /* paranoia: invalidate the magic */
753 pStatsContext->magic = 0;
754
755 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 pAdapter->rssi = rssi;
757
Jeff Johnson72a40512013-12-19 10:14:15 -0800758 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800760
761 /* serialization is complete */
762 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700763}
764
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530765static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
766{
767 struct statsContext *pStatsContext;
768 hdd_adapter_t *pAdapter;
769
770 if (ioctl_debug)
771 {
772 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
773 __func__, (int)snr, (int)staId, pContext);
774 }
775
776 if (NULL == pContext)
777 {
778 hddLog(VOS_TRACE_LEVEL_ERROR,
779 "%s: Bad param, pContext [%p]",
780 __func__, pContext);
781 return;
782 }
783
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530784 pStatsContext = pContext;
785 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800786
787 /* there is a race condition that exists between this callback
788 function and the caller since the caller could time out either
789 before or while this code is executing. we use a spinlock to
790 serialize these actions */
791 spin_lock(&hdd_context_lock);
792
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530793 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
794 {
795 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800796 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530797 hddLog(VOS_TRACE_LEVEL_WARN,
798 "%s: Invalid context, pAdapter [%p] magic [%08x]",
799 __func__, pAdapter, pStatsContext->magic);
800 if (ioctl_debug)
801 {
802 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
803 __func__, pAdapter, pStatsContext->magic);
804 }
805 return;
806 }
807
Jeff Johnson72a40512013-12-19 10:14:15 -0800808 /* context is valid so caller is still waiting */
809
810 /* paranoia: invalidate the magic */
811 pStatsContext->magic = 0;
812
813 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530814 pAdapter->snr = snr;
815
Jeff Johnson72a40512013-12-19 10:14:15 -0800816 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530817 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800818
819 /* serialization is complete */
820 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530821}
822
Jeff Johnson295189b2012-06-20 16:38:30 -0700823VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
824{
825 struct statsContext context;
826 hdd_context_t *pHddCtx;
827 hdd_station_ctx_t *pHddStaCtx;
828 eHalStatus hstatus;
829 long lrc;
830
831 if (NULL == pAdapter)
832 {
833 hddLog(VOS_TRACE_LEVEL_WARN,
834 "%s: Invalid context, pAdapter", __func__);
835 return VOS_STATUS_E_FAULT;
836 }
837 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
838 {
839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
840 /* return a cached value */
841 *rssi_value = pAdapter->rssi;
842 return VOS_STATUS_SUCCESS;
843 }
844
845 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
846 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
847
848 init_completion(&context.completion);
849 context.pAdapter = pAdapter;
850 context.magic = RSSI_CONTEXT_MAGIC;
851
852 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
853 pHddStaCtx->conn_info.staId[ 0 ],
854 pHddStaCtx->conn_info.bssId,
855 &context, pHddCtx->pvosContext);
856 if (eHAL_STATUS_SUCCESS != hstatus)
857 {
858 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700859 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 /* we'll returned a cached value below */
861 }
862 else
863 {
864 /* request was sent -- wait for the response */
865 lrc = wait_for_completion_interruptible_timeout(&context.completion,
866 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700867 if (lrc <= 0)
868 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800869 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700870 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 /* we'll now returned a cached value below */
872 }
873 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800874
875 /* either we never sent a request, we sent a request and received a
876 response or we sent a request and timed out. if we never sent a
877 request or if we sent a request and got a response, we want to
878 clear the magic out of paranoia. if we timed out there is a
879 race condition such that the callback function could be
880 executing at the same time we are. of primary concern is if the
881 callback function had already verified the "magic" but had not
882 yet set the completion variable when a timeout occurred. we
883 serialize these activities by invalidating the magic while
884 holding a shared spinlock which will cause us to block if the
885 callback is currently executing */
886 spin_lock(&hdd_context_lock);
887 context.magic = 0;
888 spin_unlock(&hdd_context_lock);
889
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 *rssi_value = pAdapter->rssi;
891
892 return VOS_STATUS_SUCCESS;
893}
894
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530895VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
896{
897 struct statsContext context;
898 hdd_context_t *pHddCtx;
899 hdd_station_ctx_t *pHddStaCtx;
900 eHalStatus hstatus;
901 long lrc;
902 int valid;
903
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530904 ENTER();
905
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530906 if (NULL == pAdapter)
907 {
908 hddLog(VOS_TRACE_LEVEL_ERROR,
909 "%s: Invalid context, pAdapter", __func__);
910 return VOS_STATUS_E_FAULT;
911 }
912
913 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
914
915 valid = wlan_hdd_validate_context(pHddCtx);
916 if (0 != valid)
917 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530918 return VOS_STATUS_E_FAULT;
919 }
920
921 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
922 if (NULL == pHddStaCtx)
923 {
924 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
925 return VOS_STATUS_E_FAULT;
926 }
927
928 init_completion(&context.completion);
929 context.pAdapter = pAdapter;
930 context.magic = SNR_CONTEXT_MAGIC;
931
932 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
933 pHddStaCtx->conn_info.staId[ 0 ],
934 pHddStaCtx->conn_info.bssId,
935 &context);
936 if (eHAL_STATUS_SUCCESS != hstatus)
937 {
938 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
939 __func__);
940 /* we'll returned a cached value below */
941 }
942 else
943 {
944 /* request was sent -- wait for the response */
945 lrc = wait_for_completion_interruptible_timeout(&context.completion,
946 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530947 if (lrc <= 0)
948 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800949 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530950 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530951 /* we'll now returned a cached value below */
952 }
953 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800954
955 /* either we never sent a request, we sent a request and received a
956 response or we sent a request and timed out. if we never sent a
957 request or if we sent a request and got a response, we want to
958 clear the magic out of paranoia. if we timed out there is a
959 race condition such that the callback function could be
960 executing at the same time we are. of primary concern is if the
961 callback function had already verified the "magic" but had not
962 yet set the completion variable when a timeout occurred. we
963 serialize these activities by invalidating the magic while
964 holding a shared spinlock which will cause us to block if the
965 callback is currently executing */
966 spin_lock(&hdd_context_lock);
967 context.magic = 0;
968 spin_unlock(&hdd_context_lock);
969
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530970 *snr = pAdapter->snr;
971
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530972 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530973 return VOS_STATUS_SUCCESS;
974}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800975#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800976
977static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
978{
979 struct statsContext *pStatsContext;
980 hdd_adapter_t *pAdapter;
981 if (ioctl_debug)
982 {
983 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
984 __func__, (int)rssi, (int)staId, pContext);
985 }
986
987 if (NULL == pContext)
988 {
989 hddLog(VOS_TRACE_LEVEL_ERROR,
990 "%s: Bad param, pContext [%p]",
991 __func__, pContext);
992 return;
993 }
994
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800995 pStatsContext = pContext;
996 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800997
998 /* there is a race condition that exists between this callback
999 function and the caller since the caller could time out either
1000 before or while this code is executing. we use a spinlock to
1001 serialize these actions */
1002 spin_lock(&hdd_context_lock);
1003
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001004 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1005 {
1006 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001007 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001008 hddLog(VOS_TRACE_LEVEL_WARN,
1009 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1010 __func__, pAdapter, pStatsContext->magic);
1011 if (ioctl_debug)
1012 {
1013 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1014 __func__, pAdapter, pStatsContext->magic);
1015 }
1016 return;
1017 }
1018
Jeff Johnson72a40512013-12-19 10:14:15 -08001019 /* context is valid so caller is still waiting */
1020
1021 /* paranoia: invalidate the magic */
1022 pStatsContext->magic = 0;
1023
1024 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001025 pAdapter->rssi = rssi;
1026
Jeff Johnson72a40512013-12-19 10:14:15 -08001027 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001028 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001029
1030 /* serialization is complete */
1031 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001032}
1033
1034
1035
1036VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1037{
1038 struct statsContext context;
1039 hdd_context_t *pHddCtx = NULL;
1040 hdd_station_ctx_t *pHddStaCtx = NULL;
1041 eHalStatus hstatus;
1042 long lrc;
1043
1044 if (NULL == pAdapter)
1045 {
1046 hddLog(VOS_TRACE_LEVEL_WARN,
1047 "%s: Invalid context, pAdapter", __func__);
1048 return VOS_STATUS_E_FAULT;
1049 }
1050 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1051 {
1052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1053 /* return a cached value */
1054 *rssi_value = pAdapter->rssi;
1055 return VOS_STATUS_SUCCESS;
1056 }
1057
1058 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1059 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1060
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301061 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001062 {
1063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1064 /* return a cached value */
1065 *rssi_value = 0;
1066 return VOS_STATUS_SUCCESS;
1067 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301068
1069 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1070 {
1071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1072 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1073 *rssi_value = pAdapter->rssi;
1074 return VOS_STATUS_SUCCESS;
1075 }
1076
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001077 init_completion(&context.completion);
1078 context.pAdapter = pAdapter;
1079 context.magic = RSSI_CONTEXT_MAGIC;
1080
1081 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1082 pHddStaCtx->conn_info.staId[ 0 ],
1083 pHddStaCtx->conn_info.bssId,
1084 &context, pHddCtx->pvosContext);
1085 if (eHAL_STATUS_SUCCESS != hstatus)
1086 {
1087 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1088 __func__);
1089 /* we'll returned a cached value below */
1090 }
1091 else
1092 {
1093 /* request was sent -- wait for the response */
1094 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1095 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001096 if (lrc <= 0)
1097 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001098 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001099 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001100 /* we'll now returned a cached value below */
1101 }
1102 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001103
1104 /* either we never sent a request, we sent a request and received a
1105 response or we sent a request and timed out. if we never sent a
1106 request or if we sent a request and got a response, we want to
1107 clear the magic out of paranoia. if we timed out there is a
1108 race condition such that the callback function could be
1109 executing at the same time we are. of primary concern is if the
1110 callback function had already verified the "magic" but had not
1111 yet set the completion variable when a timeout occurred. we
1112 serialize these activities by invalidating the magic while
1113 holding a shared spinlock which will cause us to block if the
1114 callback is currently executing */
1115 spin_lock(&hdd_context_lock);
1116 context.magic = 0;
1117 spin_unlock(&hdd_context_lock);
1118
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001119 *rssi_value = pAdapter->rssi;
1120
1121 return VOS_STATUS_SUCCESS;
1122}
1123#endif
1124
1125
Jeff Johnson295189b2012-06-20 16:38:30 -07001126void hdd_StatisticsCB( void *pStats, void *pContext )
1127{
1128 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1129 hdd_stats_t *pStatsCache = NULL;
1130 hdd_wext_state_t *pWextState;
1131 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1132
1133 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1134 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1135 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1136 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1137 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1138 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1139
1140 if (pAdapter!= NULL)
1141 pStatsCache = &pAdapter->hdd_stats;
1142
1143
1144 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1145 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1146 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1147 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1148 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1149 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1150
1151 if (pStatsCache!=NULL)
1152 {
1153 // and copy the stats into the cache we keep in the adapter instance structure
1154 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1155 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1156 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1157 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1158 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1159 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1160 }
1161
1162 if(pAdapter)
1163 {
1164 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1165 if(pWextState)
1166 {
1167 vos_status = vos_event_set(&pWextState->vosevent);
1168 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1169 {
1170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001171 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 return;
1173 }
1174 }
1175 }
1176}
1177
1178void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1179{
1180 v_CONTEXT_t pVosContext;
1181 hdd_context_t *pHddCtx;
1182 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1183#if 0
1184 hdd_wext_state_t *pWextState;
1185 v_U32_t roamId;
1186#endif
1187
1188 ENTER();
1189
1190 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1191
1192 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1193 if (NULL == pHddCtx)
1194 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001195 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 return;
1197 }
1198#if 0
1199 pWextState = pAdapter->pWextState;
1200#endif
1201
1202 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1203 {
1204 //TODO Verify is this is really used. If yes need to fix it.
1205 hdd_reconnect_all_adapters( pHddCtx );
1206#if 0
1207 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1208 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1209 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1210
1211 if(VOS_STATUS_SUCCESS == vosStatus)
1212 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1213 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1214
1215 sme_RoamConnect(halHandle,
1216 pAdapter->sessionId, &(pWextState->roamProfile),
1217 &roamId);
1218#endif
1219 }
1220
1221 EXIT();
1222
1223}
1224
1225void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1226{
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1228
1229 /* clear WPA/RSN/WSC IE information in the profile */
1230 pWextState->roamProfile.nWPAReqIELength = 0;
1231 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1232 pWextState->roamProfile.nRSNReqIELength = 0;
1233 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1234
Chet Lanctot186b5732013-03-18 10:26:30 -07001235#ifdef FEATURE_WLAN_WAPI
1236 pWextState->roamProfile.nWAPIReqIELength = 0;
1237 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1238#endif
1239
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001241 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301243 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001244 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1245 pWextState->roamProfile.nAddIEAssocLength = 0;
1246
1247 pWextState->roamProfile.EncryptionType.numEntries = 1;
1248 pWextState->roamProfile.EncryptionType.encryptionType[0]
1249 = eCSR_ENCRYPT_TYPE_NONE;
1250
1251 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1252 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1253 = eCSR_ENCRYPT_TYPE_NONE;
1254
1255 pWextState->roamProfile.AuthType.numEntries = 1;
1256 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1257
Chet Lanctot186b5732013-03-18 10:26:30 -07001258#ifdef WLAN_FEATURE_11W
1259 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1260 pWextState->roamProfile.MFPRequired = 0;
1261 pWextState->roamProfile.MFPCapable = 0;
1262#endif
1263
Jeff Johnson295189b2012-06-20 16:38:30 -07001264 pWextState->authKeyMgmt = 0;
1265
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301266 vos_mem_zero(&pWextState->roamProfile.Keys,
1267 sizeof(pWextState->roamProfile.Keys));
1268
Jeff Johnson295189b2012-06-20 16:38:30 -07001269#ifdef FEATURE_WLAN_WAPI
1270 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1271 pAdapter->wapi_info.nWapiMode = 0;
1272#endif
1273
1274 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1275
1276}
1277
1278void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1279{
1280 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001281
Nirav Shahf6bd2672015-03-11 12:53:15 +05301282 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001283 {
1284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301285 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001286 }
1287 else
1288 {
1289 complete(&pAdapter->ula_complete);
1290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001291}
1292
1293VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1294{
1295 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001297 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001298
1299 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1300 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001301 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001302
1303 /*To avoid race condition between the set key and the last EAPOL
1304 packet, notify TL to finish upper layer authentication incase if the
1305 last EAPOL packet pending in the TL queue.*/
Nirav Shah4f765af2015-01-21 19:51:30 +05301306 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter,
1307 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1308 pHddStaCtx->conn_info.staId[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001309
Nirav Shah4f765af2015-01-21 19:51:30 +05301310 if ( vos_status == VOS_STATUS_E_ALREADY )
1311 {
1312 return VOS_STATUS_SUCCESS;
1313 }
1314 else if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 {
1316 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1317 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1318 __LINE__, vos_status );
1319 return vos_status;
1320
1321 }
1322
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001323 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301325 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001326 {
1327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301328 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001329 /* we'll still fall through and return success since the
1330 * connection may still get established but is just taking
1331 * too long for us to wait */
1332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 }
1334 return VOS_STATUS_SUCCESS;
1335}
1336
1337v_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)
1338{
1339
1340 int left = ie_len;
1341 v_U8_t *ptr = ie;
1342 v_U8_t elem_id,elem_len;
1343 v_U8_t eid = 0xDD;
1344
1345 if ( NULL == ie || 0 == ie_len )
1346 return NULL;
1347
1348 while(left >= 2)
1349 {
1350 elem_id = ptr[0];
1351 elem_len = ptr[1];
1352 left -= 2;
1353 if(elem_len > left)
1354 {
1355 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001356 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 eid,elem_len,left);
1358 return NULL;
1359 }
1360 if (elem_id == eid)
1361 {
1362 if(memcmp( &ptr[2], oui, oui_size)==0)
1363 return ptr;
1364 }
1365
1366 left -= elem_len;
1367 ptr += (elem_len + 2);
1368 }
1369 return NULL;
1370}
1371
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301372static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 union iwreq_data *wrqu, char *extra)
1374{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301375 hdd_adapter_t *pAdapter;
1376 hdd_context_t *pHddCtx;
1377 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301378
1379 ENTER();
1380
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301381 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1382 if (NULL == pAdapter)
1383 {
1384 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1385 "%s: pAdapter is NULL\n", __func__);
1386 return -EINVAL;
1387 }
1388 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1389 ret = wlan_hdd_validate_context(pHddCtx);
1390 if (0 != ret)
1391 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301392 return ret;
1393 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301394
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301396
1397 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301398 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001399}
1400
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301401static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1402 union iwreq_data *wrqu, char *extra)
1403{
1404 int ret;
1405
1406 vos_ssr_protect(__func__);
1407 ret = __iw_set_commit(dev, info, wrqu, extra);
1408 vos_ssr_unprotect(__func__);
1409
1410 return ret;
1411}
1412
1413static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 struct iw_request_info *info,
1415 char *wrqu, char *extra)
1416{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301417 hdd_adapter_t *pAdapter;
1418 hdd_context_t *pHddCtx;
1419 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301420
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301422 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1423 if (NULL == pAdapter)
1424 {
1425 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1426 "%s: pAdapter is NULL\n", __func__);
1427 return -EINVAL;
1428 }
1429 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1430 ret = wlan_hdd_validate_context(pHddCtx);
1431 if (0 != ret)
1432 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301433 return ret;
1434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1436 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301437 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001438}
1439
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301440static int iw_get_name(struct net_device *dev,
1441 struct iw_request_info *info,
1442 char *wrqu, char *extra)
1443{
1444 int ret;
1445
1446 vos_ssr_protect(__func__);
1447 ret = __iw_get_name(dev, info, wrqu, extra);
1448 vos_ssr_unprotect(__func__);
1449
1450 return ret;
1451}
1452
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301453static int __iw_set_mode(struct net_device *dev,
1454 struct iw_request_info *info,
1455 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001456{
1457 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301458 hdd_adapter_t *pAdapter;
1459 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 tCsrRoamProfile *pRoamProfile;
1461 eCsrRoamBssType LastBSSType;
1462 eMib_dot11DesiredBssType connectedBssType;
1463 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301465 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001466
1467 ENTER();
1468
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301469 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 if (NULL == pAdapter)
1471 {
1472 hddLog(VOS_TRACE_LEVEL_WARN,
1473 "%s: Invalid context, pAdapter", __func__);
1474 return 0;
1475 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301476 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1477 status = wlan_hdd_validate_context(pHddCtx);
1478 if (0 != status)
1479 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301480 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 }
1482
1483 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1484 if (pWextState == NULL)
1485 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301486 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 return -EINVAL;
1488 }
1489
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 pRoamProfile = &pWextState->roamProfile;
1492 LastBSSType = pRoamProfile->BSSType;
1493
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301494 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001495
1496 switch (wrqu->mode)
1497 {
1498 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301499 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1501 // Set the phymode correctly for IBSS.
1502 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1503 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001504 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001506 break;
1507 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301508 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 break;
1512 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301513 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1515 break;
1516 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301517 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 return -EOPNOTSUPP;
1519 }
1520
1521 if ( LastBSSType != pRoamProfile->BSSType )
1522 {
1523 //the BSS mode changed
1524 // We need to issue disconnect if connected or in IBSS disconnect state
1525 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1526 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1527 {
1528 VOS_STATUS vosStatus;
1529 // need to issue a disconnect to CSR.
1530 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1531 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1532 pAdapter->sessionId,
1533 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1534 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301535 {
1536 long ret;
1537 ret = wait_for_completion_interruptible_timeout(
1538 &pAdapter->disconnect_comp_var,
1539 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1540 if (ret <= 0)
1541 hddLog(VOS_TRACE_LEVEL_ERROR,
1542 FL("failed wait on disconnect_comp_var %ld"), ret);
1543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 }
1545 }
1546
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 EXIT();
1548 return 0;
1549}
1550
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301551static int iw_set_mode(struct net_device *dev,
1552 struct iw_request_info *info,
1553 union iwreq_data *wrqu, char *extra)
1554{
1555 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001556
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301557 vos_ssr_protect(__func__);
1558 ret = __iw_set_mode(dev, info, wrqu, extra);
1559 vos_ssr_unprotect(__func__);
1560
1561 return ret;
1562}
1563
1564static int __iw_get_mode(struct net_device *dev,
1565 struct iw_request_info *info,
1566 union iwreq_data *wrqu,
1567 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001568{
1569
1570 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301571 hdd_adapter_t *pAdapter;
1572 hdd_context_t *pHddCtx;
1573 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001574
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301575 ENTER();
1576
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301577 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 if (NULL == pAdapter)
1579 {
1580 hddLog(VOS_TRACE_LEVEL_WARN,
1581 "%s: Invalid context, pAdapter", __func__);
1582 return 0;
1583 }
1584
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301585 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1586 ret = wlan_hdd_validate_context(pHddCtx);
1587 if (0 != ret)
1588 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301589 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001591 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1592 if (pWextState == NULL)
1593 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301594 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 return -EINVAL;
1596 }
1597
1598 switch (pWextState->roamProfile.BSSType)
1599 {
1600 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001601 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301602 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 break;
1604 case eCSR_BSS_TYPE_IBSS:
1605 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001606 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301607 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 break;
1609 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001610 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301611 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 break;
1613 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001614 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 break;
1616 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301617
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301618 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 return 0;
1620}
1621
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301622static int iw_get_mode(struct net_device *dev,
1623 struct iw_request_info *info,
1624 union iwreq_data *wrqu,
1625 char *extra)
1626{
1627 int ret;
1628
1629 vos_ssr_protect(__func__);
1630 ret = __iw_get_mode(dev, info, wrqu, extra);
1631 vos_ssr_unprotect(__func__);
1632
1633 return ret;
1634}
1635
1636static int __iw_set_freq(struct net_device *dev,
1637 struct iw_request_info *info,
1638 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001639{
1640 v_U32_t numChans = 0;
1641 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1642 v_U32_t indx = 0;
1643 v_U32_t status = 0;
1644
1645 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301646 hdd_adapter_t *pAdapter;
1647 hdd_context_t *pHddCtx;
1648 tHalHandle hHal;
1649 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301651
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 ENTER();
1653
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301654 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1655 if (NULL == pAdapter)
1656 {
1657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1658 "%s:Invalid Adapter",__func__);
1659 return -EINVAL;
1660 }
1661
1662 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1663 status = wlan_hdd_validate_context(pHddCtx);
1664 if (0 != status)
1665 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 return status;
1667 }
1668
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301669 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1670 if (NULL == hHal)
1671 {
1672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1673 "%s: Hal Context is NULL",__func__);
1674 return -EINVAL;
1675 }
1676
1677 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1678 if (NULL == pHddStaCtx)
1679 {
1680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1681 "%s:STA context is NULL",__func__);
1682 return -EINVAL;
1683 }
1684
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301686 if (NULL == pWextState)
1687 {
1688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1689 "%s: pWextState is NULL",__func__);
1690 return -EINVAL;
1691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001692
1693 pRoamProfile = &pWextState->roamProfile;
1694
Arif Hussain6d2a3322013-11-17 19:50:10 -08001695 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001696
1697 /* Link is up then return cant set channel*/
1698 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1699 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1700 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001701 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 return -EOPNOTSUPP;
1703 }
1704
1705 /* Settings by Frequency as input */
1706 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1707 (wrqu->freq.m <= (tANI_U32)5.825e8))
1708 {
1709 tANI_U32 freq = wrqu->freq.m / 100000;
1710
1711 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1712 indx++;
1713 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1714 {
1715 return -EINVAL;
1716 }
1717 wrqu->freq.e = 0;
1718 wrqu->freq.m = freq_chan_map[indx].chan;
1719
1720 }
1721
1722 if (wrqu->freq.e == 0)
1723 {
1724 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1725 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1726 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001727 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001728 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1730 return -EINVAL;
1731 }
1732
1733 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1734
1735 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1736 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1738 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 return -EIO;
1740 }
1741
1742 for (indx = 0; indx < numChans; indx++) {
1743 if (wrqu->freq.m == validChan[indx]){
1744 break;
1745 }
1746 }
1747 }
1748 else{
1749
1750 return -EINVAL;
1751 }
1752
1753 if(indx >= numChans)
1754 {
1755 return -EINVAL;
1756 }
1757
1758 /* Set the Operational Channel */
1759 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1760 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1761 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1762
Arif Hussain6d2a3322013-11-17 19:50:10 -08001763 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764
1765 EXIT();
1766
1767 return status;
1768}
1769
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301770static int iw_set_freq(struct net_device *dev,
1771 struct iw_request_info *info,
1772 union iwreq_data *wrqu, char *extra)
1773{
1774 int ret;
1775
1776 vos_ssr_protect(__func__);
1777 ret = __iw_set_freq(dev, info, wrqu, extra);
1778 vos_ssr_unprotect(__func__);
1779
1780 return ret;
1781}
1782
1783static int __iw_get_freq(struct net_device *dev,
1784 struct iw_request_info *info,
1785 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001786{
Jeff Johnsone7245742012-09-05 17:12:55 -07001787 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301788 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 tHalHandle hHal;
1790 hdd_wext_state_t *pWextState;
1791 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301792 hdd_station_ctx_t *pHddStaCtx;
1793 hdd_context_t *pHddCtx;
1794 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001795
1796 ENTER();
1797
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301798 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1799 if (NULL == pAdapter)
1800 {
1801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1802 "%s: Adapter is NULL", __func__);
1803 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301805 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1806 ret = wlan_hdd_validate_context(pHddCtx);
1807 if (0 != ret)
1808 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301809 return ret;
1810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301812 if (NULL == hHal)
1813 {
1814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1815 "%s: Hal Context is NULL",__func__);
1816 return -EINVAL;
1817 }
1818 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1819 if (NULL == pHddStaCtx)
1820 {
1821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1822 "%s: HddStaCtx is NULL", __func__);
1823 return -EINVAL;
1824 }
1825 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1826 if (NULL == pWextState)
1827 {
1828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1829 "%s: pWextState is NULL",__func__);
1830 return -EINVAL;
1831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 pRoamProfile = &pWextState->roamProfile;
1833
1834 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1835 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001836 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 {
c_hpothub8245442013-11-20 23:41:09 +05301838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1839 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 return -EIO;
1841 }
1842 else
1843 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001844 status = hdd_wlan_get_freq(channel, &freq);
1845 if( TRUE == status )
1846 {
1847 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1848 * iwlist & iwconfig command shows frequency into proper
1849 * format (2.412 GHz instead of 246.2 MHz)*/
1850 fwrq->m = freq;
1851 fwrq->e = MHZ;
1852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 }
1854 }
1855 else
1856 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001857 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1858 * iwlist & iwconfig command shows frequency into proper
1859 * format (2.412 GHz instead of 246.2 MHz)*/
1860 fwrq->m = 0;
1861 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001862 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301863
1864 EXIT();
1865 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001866}
1867
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301868static int iw_get_freq(struct net_device *dev,
1869 struct iw_request_info *info,
1870 struct iw_freq *fwrq, char *extra)
1871{
1872 int ret;
1873
1874 vos_ssr_protect(__func__);
1875 ret = __iw_get_freq(dev, info, fwrq, extra);
1876 vos_ssr_unprotect(__func__);
1877
1878 return ret;
1879}
1880
1881static int __iw_get_tx_power(struct net_device *dev,
1882 struct iw_request_info *info,
1883 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001884{
1885
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301886 hdd_adapter_t *pAdapter;
1887 hdd_context_t *pHddCtx;
1888 hdd_station_ctx_t *pHddStaCtx;
1889 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001890
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301891 ENTER();
1892
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301893 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1894 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1897 "%s: Adapter is NULL",__func__);
1898 return -EINVAL;
1899 }
1900 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1901 ret = wlan_hdd_validate_context(pHddCtx);
1902 if (0 != ret)
1903 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301904 return ret;
1905 }
1906
1907 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1908 if (NULL == pHddStaCtx)
1909 {
1910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1911 "%s: STA Context is NULL",__func__);
1912 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 }
1914
1915 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1916 {
1917 wrqu->txpower.value = 0;
1918 return 0;
1919 }
1920 wlan_hdd_get_classAstats(pAdapter);
1921 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1922
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301923 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 return 0;
1925}
1926
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301927static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 struct iw_request_info *info,
1929 union iwreq_data *wrqu, char *extra)
1930{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301931 int ret;
1932
1933 vos_ssr_protect(__func__);
1934 ret = __iw_get_tx_power(dev, info, wrqu, extra);
1935 vos_ssr_unprotect(__func__);
1936
1937 return ret;
1938}
1939
1940static int __iw_set_tx_power(struct net_device *dev,
1941 struct iw_request_info *info,
1942 union iwreq_data *wrqu, char *extra)
1943{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301944 hdd_adapter_t *pAdapter;
1945 tHalHandle hHal;
1946 hdd_context_t *pHddCtx;
1947 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001948
1949 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301950 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1951 if (NULL == pAdapter)
1952 {
1953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1954 "%s: Adapter is NULL",__func__);
1955 return -EINVAL;
1956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001957
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301958 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1959 ret = wlan_hdd_validate_context(pHddCtx);
1960 if (0 != ret)
1961 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301962 return ret;
1963 }
1964
1965 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1966 if (NULL == hHal)
1967 {
1968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1969 "%s: Hal Context is NULL",__func__);
1970 return -EINVAL;
1971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1973 {
c_hpothub8245442013-11-20 23:41:09 +05301974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1975 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 return -EIO;
1977 }
1978
1979 EXIT();
1980
1981 return 0;
1982}
1983
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301984static int iw_set_tx_power(struct net_device *dev,
1985 struct iw_request_info *info,
1986 union iwreq_data *wrqu, char *extra)
1987{
1988 int ret;
1989
1990 vos_ssr_protect(__func__);
1991 ret = __iw_set_tx_power(dev, info, wrqu, extra);
1992 vos_ssr_unprotect(__func__);
1993
1994 return ret;
1995}
1996
1997static int __iw_get_bitrate(struct net_device *dev,
1998 struct iw_request_info *info,
1999 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002000{
2001 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2002 eHalStatus status = eHAL_STATUS_SUCCESS;
2003 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302004 hdd_adapter_t *pAdapter;
2005 hdd_context_t *pHddCtx;
2006 hdd_station_ctx_t *pHddStaCtx;
2007 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002008
2009 ENTER();
2010
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302011 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2012 if (NULL == pAdapter)
2013 {
2014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2015 "%s: Adapter is NULL",__func__);
2016 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 }
2018
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302019 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2020 ret = wlan_hdd_validate_context(pHddCtx);
2021 if (0 != ret)
2022 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302023 return ret;
2024 }
2025
2026 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2027 if (NULL == pHddStaCtx)
2028 {
2029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2030 "%s: STA Context is NULL",__func__);
2031 return -EINVAL;
2032 }
2033
2034 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 wrqu->bitrate.value = 0;
2036 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302037 else
2038 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2040 SME_SUMMARY_STATS |
2041 SME_GLOBAL_CLASSA_STATS |
2042 SME_GLOBAL_CLASSB_STATS |
2043 SME_GLOBAL_CLASSC_STATS |
2044 SME_GLOBAL_CLASSD_STATS |
2045 SME_PER_STA_STATS,
2046 hdd_StatisticsCB, 0, FALSE,
2047 pHddStaCtx->conn_info.staId[0], pAdapter );
2048
2049 if(eHAL_STATUS_SUCCESS != status)
2050 {
2051 hddLog(VOS_TRACE_LEVEL_ERROR,
2052 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002053 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 return status;
2055 }
2056
2057 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302058 if (NULL == pWextState)
2059 {
2060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2061 "%s: pWextState is NULL",__func__);
2062 return -EINVAL;
2063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002064
2065 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2066
2067 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2068 {
2069 hddLog(VOS_TRACE_LEVEL_ERROR,
2070 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002071 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 return VOS_STATUS_E_FAILURE;
2073 }
2074
2075 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2076 }
2077
2078 EXIT();
2079
2080 return vos_status;
2081}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302082
2083static int iw_get_bitrate(struct net_device *dev,
2084 struct iw_request_info *info,
2085 union iwreq_data *wrqu, char *extra)
2086{
2087 int ret;
2088
2089 vos_ssr_protect(__func__);
2090 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2091 vos_ssr_unprotect(__func__);
2092
2093 return ret;
2094}
2095
2096
Jeff Johnson295189b2012-06-20 16:38:30 -07002097/* ccm call back function */
2098
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302099static int __iw_set_bitrate(struct net_device *dev,
2100 struct iw_request_info *info,
2101 union iwreq_data *wrqu,
2102 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002103{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302104 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002105 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302106 hdd_station_ctx_t *pHddStaCtx;
2107 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2109 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2110 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2111 v_U32_t i, rate;
2112 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302113 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002114
2115 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302116 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2117 if (NULL == pAdapter)
2118 {
2119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2120 "%s: Adapter is NULL",__func__);
2121 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 }
2123
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302124 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2125 ret = wlan_hdd_validate_context(pHddCtx);
2126 if (0 != ret)
2127 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302128 return ret;
2129 }
2130
2131 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2132 if (NULL == pHddStaCtx)
2133 {
2134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2135 "%s: STA Context is NULL",__func__);
2136 return -EINVAL;
2137 }
2138
2139
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302141 if (NULL == pWextState)
2142 {
2143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2144 "%s: pWextState is NULL",__func__);
2145 return -EINVAL;
2146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002147
2148 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2149 {
2150 return -ENXIO ;
2151 }
2152
2153 rate = wrqu->bitrate.value;
2154
2155 if (rate == -1)
2156 {
2157 rate = WNI_CFG_FIXED_RATE_AUTO;
2158 valid_rate = TRUE;
2159 }
2160 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2161 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2162 {
2163 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2164 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2165 {
2166 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2167 WNI_CFG_SUPPORTED_RATES_11A,
2168 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2169 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2170 WNI_CFG_SUPPORTED_RATES_11B,
2171 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2172 {
2173 for (i = 0; i < (b_len + a_len); ++i)
2174 {
2175 /* supported rates returned is double the actual rate so we divide it by 2 */
2176 if ((supp_rates[i]&0x7F)/2 == rate)
2177 {
2178 valid_rate = TRUE;
2179 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2180 break;
2181 }
2182 }
2183 }
2184 }
2185 }
2186 if (valid_rate != TRUE)
2187 {
2188 return -EINVAL;
2189 }
2190 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2191 WNI_CFG_FIXED_RATE, rate,
2192 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2193 {
c_hpothub8245442013-11-20 23:41:09 +05302194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2195 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 return -EIO;
2197 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302198
2199 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 return 0;
2201}
2202
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302203static int iw_set_bitrate(struct net_device *dev,
2204 struct iw_request_info *info,
2205 union iwreq_data *wrqu,
2206 char *extra)
2207{
2208 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002209
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302210 vos_ssr_protect(__func__);
2211 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2212 vos_ssr_unprotect(__func__);
2213
2214 return ret;
2215}
2216
2217static int __iw_set_genie(struct net_device *dev,
2218 struct iw_request_info *info,
2219 union iwreq_data *wrqu,
2220 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002221{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302222 hdd_adapter_t *pAdapter;
2223 hdd_context_t *pHddCtx;
2224 hdd_wext_state_t *pWextState;
2225 u_int8_t *genie = NULL;
2226 u_int8_t *base_genie = NULL;
2227 v_U16_t remLen;
2228 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002229
2230 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002231
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302232 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2233 if (NULL == pAdapter)
2234 {
2235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2236 "%s: Adapter is NULL",__func__);
2237 return -EINVAL;
2238 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002239
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302240 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2241 ret = wlan_hdd_validate_context(pHddCtx);
2242 if (0 != ret)
2243 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302244 return ret;
2245 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002246
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302247 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2248 if (NULL == pWextState)
2249 {
2250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2251 "%s: pWextState is NULL",__func__);
2252 return -EINVAL;
2253 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002254
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302255 if (!wrqu->data.length) {
2256 hdd_clearRoamProfileIe(pAdapter);
2257 EXIT();
2258 return 0;
2259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002260
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302261 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2262 wrqu->data.length);
2263 if (NULL == base_genie)
2264 {
2265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2266 "mem_alloc_copy_from_user_helper fail");
2267 return -ENOMEM;
2268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002269
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302270 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002271
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302272 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002273
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302274 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2275
2276 /* clear any previous genIE before this call */
2277 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2278
2279 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 {
2281 v_U16_t eLen = 0;
2282 v_U8_t elementId;
2283 elementId = *genie++;
2284 eLen = *genie++;
2285 remLen -= 2;
2286
Arif Hussain6d2a3322013-11-17 19:50:10 -08002287 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 __func__, elementId, eLen);
2289
2290 switch ( elementId )
2291 {
2292 case IE_EID_VENDOR:
2293 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002294 {
2295 kfree(base_genie);
2296 return -EINVAL;
2297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002298
2299 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2300 {
2301 v_U16_t curGenIELen = pWextState->genIE.length;
2302 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2303 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2304
2305 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2306 {
2307 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002308 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002310 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 return -ENOMEM;
2312 }
2313 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2314 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2315 pWextState->genIE.length += eLen + 2;
2316 }
2317 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2318 {
2319 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2320 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2321 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2322 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2323 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2324 }
2325 else /* any vendorId except WPA IE should be accumulated to genIE */
2326 {
2327 v_U16_t curGenIELen = pWextState->genIE.length;
2328 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2329 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2330
2331 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2332 {
2333 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002334 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002335 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002336 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 return -ENOMEM;
2338 }
2339 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2340 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2341 pWextState->genIE.length += eLen + 2;
2342 }
2343 break;
2344 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002345 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2347 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2348 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2349 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2350 break;
2351
2352 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002353 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002354 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 return 0;
2356 }
2357 genie += eLen;
2358 remLen -= eLen;
2359 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302360
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002362 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 return 0;
2364}
2365
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302366static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 struct iw_request_info *info,
2368 union iwreq_data *wrqu,
2369 char *extra)
2370{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302371 int ret;
2372
2373 vos_ssr_protect(__func__);
2374 ret = __iw_set_genie(dev, info, wrqu, extra);
2375 vos_ssr_unprotect(__func__);
2376
2377 return ret;
2378}
2379
2380static int __iw_get_genie(struct net_device *dev,
2381 struct iw_request_info *info,
2382 union iwreq_data *wrqu,
2383 char *extra)
2384{
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302386 hdd_context_t *pHddCtx;
2387 hdd_adapter_t *pAdapter;
2388 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 eHalStatus status;
2390 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2391 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2392
2393 ENTER();
2394
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302395 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2396 if (NULL == pAdapter)
2397 {
2398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2399 "%s: Adapter is NULL",__func__);
2400 return -EINVAL;
2401 }
2402 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2403 status = wlan_hdd_validate_context(pHddCtx);
2404 if (0 != status)
2405 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302406 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 }
2408
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302410 if (NULL == pWextState)
2411 {
2412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2413 "%s: pWextState is NULL",__func__);
2414 return -EINVAL;
2415 }
2416
2417 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2418 if (NULL == pHddStaCtx)
2419 {
2420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2421 "%s: STA Context is NULL",__func__);
2422 return -EINVAL;
2423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002424
2425 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2426 {
2427 return -ENXIO;
2428 }
2429
2430 // Return something ONLY if we are associated with an RSN or WPA network
2431 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2432 pWextState->roamProfile.negotiatedAuthType))
2433 {
2434 return -ENXIO;
2435 }
2436
2437 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2438 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2439 pAdapter->sessionId,
2440 &length,
2441 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002442 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2443 if (wrqu->data.length < length)
2444 {
2445 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2446 return -EFAULT;
2447 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002448 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002449 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002450
Arif Hussain6d2a3322013-11-17 19:50:10 -08002451 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002452
2453 EXIT();
2454
2455 return 0;
2456}
2457
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302458static int iw_get_genie(struct net_device *dev,
2459 struct iw_request_info *info,
2460 union iwreq_data *wrqu,
2461 char *extra)
2462{
2463 int ret;
2464
2465 vos_ssr_protect(__func__);
2466 ret = __iw_get_genie(dev, info, wrqu, extra);
2467 vos_ssr_unprotect(__func__);
2468
2469 return ret;
2470}
2471
2472
2473static int __iw_get_encode(struct net_device *dev,
2474 struct iw_request_info *info,
2475 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002476{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302477 hdd_adapter_t *pAdapter;
2478 hdd_context_t *pHddCtx;
2479 hdd_wext_state_t *pWextState;
2480 tCsrRoamProfile *pRoamProfile;
2481 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002483
2484 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302485 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2486 if (NULL == pAdapter)
2487 {
2488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2489 "%s: Adapter is NULL",__func__);
2490 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 }
2492
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302493 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2494 ret = wlan_hdd_validate_context(pHddCtx);
2495 if (0 != ret)
2496 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302497 return ret;
2498 }
2499 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2500 if (NULL == pWextState)
2501 {
2502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2503 "%s: pWextState is NULL",__func__);
2504 return -EINVAL;
2505 }
2506
2507 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 keyId = pRoamProfile->Keys.defaultIndex;
2509
2510 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2511 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002512 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 return -EINVAL;
2514 }
2515
2516 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2517 {
2518 dwrq->flags |= IW_ENCODE_ENABLED;
2519 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2520 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2521
2522 dwrq->flags |= (keyId + 1);
2523
2524 }
2525 else
2526 {
2527 dwrq->flags |= IW_ENCODE_DISABLED;
2528 }
2529
2530 for(i=0; i < MAX_WEP_KEYS; i++)
2531 {
2532 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2533 {
2534 continue;
2535 }
2536 else
2537 {
2538 break;
2539 }
2540 }
2541
2542 if(MAX_WEP_KEYS == i)
2543 {
2544 dwrq->flags |= IW_ENCODE_NOKEY;
2545 }
2546
2547 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2548
2549 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2550 {
2551 dwrq->flags |= IW_ENCODE_OPEN;
2552 }
2553 else
2554 {
2555 dwrq->flags |= IW_ENCODE_RESTRICTED;
2556 }
2557 EXIT();
2558 return 0;
2559}
2560
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302561static int iw_get_encode(struct net_device *dev,
2562 struct iw_request_info *info,
2563 struct iw_point *dwrq, char *extra)
2564{
2565 int ret;
2566
2567 vos_ssr_protect(__func__);
2568 ret = __iw_get_encode(dev, info, dwrq, extra);
2569 vos_ssr_unprotect(__func__);
2570
2571 return ret;
2572}
2573
Jeff Johnson295189b2012-06-20 16:38:30 -07002574#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2575#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2576
2577
2578/*
2579 * This function sends a single 'key' to LIM at all time.
2580 */
2581
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302582static int __iw_get_rts_threshold(struct net_device *dev,
2583 struct iw_request_info *info,
2584 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002585{
2586 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2587 v_U32_t status = 0;
2588
2589 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2590
2591 return status;
2592}
2593
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302594static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 struct iw_request_info *info,
2596 union iwreq_data *wrqu, char *extra)
2597{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302598 int ret;
2599
2600 vos_ssr_protect(__func__);
2601 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2602 vos_ssr_unprotect(__func__);
2603
2604 return ret;
2605}
2606
2607static int __iw_set_rts_threshold(struct net_device *dev,
2608 struct iw_request_info *info,
2609 union iwreq_data *wrqu, char *extra)
2610{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302611 hdd_adapter_t *pAdapter;
2612 hdd_context_t *pHddCtx;
2613 tHalHandle hHal;
2614 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002615
2616 ENTER();
2617
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302618 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2619 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002620 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2622 "%s: Adapter is NULL",__func__);
2623 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002624 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302625
2626 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2627 ret = wlan_hdd_validate_context(pHddCtx);
2628 if (0 != ret)
2629 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302630 return ret;
2631 }
2632
2633 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2634 if (NULL == hHal)
2635 {
2636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2637 "%s: Hal Context is NULL",__func__);
2638 return -EINVAL;
2639 }
2640
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2642 {
2643 return -EINVAL;
2644 }
2645
2646 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2647 {
c_hpothub8245442013-11-20 23:41:09 +05302648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2649 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 return -EIO;
2651 }
2652
2653 EXIT();
2654
2655 return 0;
2656}
2657
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302658static int iw_set_rts_threshold(struct net_device *dev,
2659 struct iw_request_info *info,
2660 union iwreq_data *wrqu, char *extra)
2661{
2662 int ret;
2663
2664 vos_ssr_protect(__func__);
2665 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2666 vos_ssr_unprotect(__func__);
2667
2668 return ret;
2669}
2670
2671static int __iw_get_frag_threshold(struct net_device *dev,
2672 struct iw_request_info *info,
2673 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002674{
2675 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2676 v_U32_t status = 0;
2677
2678 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2679
2680 return status;
2681}
2682
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302683static int iw_get_frag_threshold(struct net_device *dev,
2684 struct iw_request_info *info,
2685 union iwreq_data *wrqu, char *extra)
2686{
2687 int ret;
2688
2689 vos_ssr_protect(__func__);
2690 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2691 vos_ssr_unprotect(__func__);
2692
2693 return ret;
2694}
2695
2696static int __iw_set_frag_threshold(struct net_device *dev,
2697 struct iw_request_info *info,
2698 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002699{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302700 hdd_adapter_t *pAdapter;
2701 hdd_context_t *pHddCtx;
2702 tHalHandle hHal;
2703 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002704
2705 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302706 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2707 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002708 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2710 "%s: Adapter is NULL",__func__);
2711 return -EINVAL;
2712 }
2713
2714 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2715 ret = wlan_hdd_validate_context(pHddCtx);
2716 if (0 != ret)
2717 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302718 return ret;
2719 }
2720
2721 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2722 if (NULL == hHal)
2723 {
2724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2725 "%s: Hal Context is NULL",__func__);
2726 return -EINVAL;
2727 }
2728
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2730 {
2731 return -EINVAL;
2732 }
2733
2734 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2735 {
c_hpothub8245442013-11-20 23:41:09 +05302736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2737 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 return -EIO;
2739 }
2740
2741 EXIT();
2742
2743 return 0;
2744}
2745
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302746static int iw_set_frag_threshold(struct net_device *dev,
2747 struct iw_request_info *info,
2748 union iwreq_data *wrqu, char *extra)
2749{
2750 int ret;
2751
2752 vos_ssr_protect(__func__);
2753 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2754 vos_ssr_unprotect(__func__);
2755
2756 return ret;
2757}
2758
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302759static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 struct iw_request_info *info,
2761 union iwreq_data *wrqu, char *extra)
2762{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302763 hdd_adapter_t *pAdapter;
2764 hdd_context_t *pHddCtx;
2765 int ret = 0;
2766
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302768 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2769 if (NULL == pAdapter)
2770 {
2771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2772 "%s: Adapter is NULL",__func__);
2773 return -EINVAL;
2774 }
2775 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2776 ret = wlan_hdd_validate_context(pHddCtx);
2777 if (0 != ret)
2778 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302779 return ret;
2780 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302781
2782 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 return -EOPNOTSUPP;
2784}
2785
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302786static int iw_get_power_mode(struct net_device *dev,
2787 struct iw_request_info *info,
2788 union iwreq_data *wrqu, char *extra)
2789{
2790 int ret;
2791
2792 vos_ssr_protect(__func__);
2793 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2794 vos_ssr_unprotect(__func__);
2795
2796 return ret;
2797}
2798static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 struct iw_request_info *info,
2800 union iwreq_data *wrqu, char *extra)
2801{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302802 hdd_adapter_t *pAdapter;
2803 hdd_context_t *pHddCtx;
2804 int ret = 0;
2805
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302807 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2808 if (NULL == pAdapter)
2809 {
2810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2811 "%s: Adapter is NULL",__func__);
2812 return -EINVAL;
2813 }
2814 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2815 ret = wlan_hdd_validate_context(pHddCtx);
2816 if (0 != ret)
2817 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302818 return ret;
2819 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302820
2821 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 return -EOPNOTSUPP;
2823}
2824
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302825static int iw_set_power_mode(struct net_device *dev,
2826 struct iw_request_info *info,
2827 union iwreq_data *wrqu, char *extra)
2828{
2829 int ret;
2830
2831 vos_ssr_protect(__func__);
2832 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2833 vos_ssr_unprotect(__func__);
2834
2835 return ret;
2836}
2837
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302838static int __iw_get_range(struct net_device *dev,
2839 struct iw_request_info *info,
2840 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002841{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302842 hdd_adapter_t *pAdapter;
2843 tHalHandle hHal;
2844 hdd_context_t *pHddCtx;
2845 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 struct iw_range *range = (struct iw_range *) extra;
2847
2848 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2849
2850 v_U32_t num_channels = sizeof(channels);
2851 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2852 v_U32_t a_len;
2853 v_U32_t b_len;
2854 v_U32_t active_phy_mode = 0;
2855 v_U8_t index = 0, i;
2856
2857 ENTER();
2858
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302859 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2860 if (NULL == pAdapter)
2861 {
2862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2863 "%s: pAdapter is NULL", __func__);
2864 return -EINVAL;
2865 }
2866 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2867 ret = wlan_hdd_validate_context(pHddCtx);
2868 if (0 != ret)
2869 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302870 return ret;
2871 }
2872 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2873 if (NULL == hHal)
2874 {
2875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2876 "%s: pAdapter is NULL", __func__);
2877 return -EINVAL;
2878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 wrqu->data.length = sizeof(struct iw_range);
2880 memset(range, 0, sizeof(struct iw_range));
2881
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 /*Get the phy mode*/
2883 if (ccmCfgGetInt(hHal,
2884 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2885 {
2886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002887 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002888
2889 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2890 {
2891 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002892 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 if (ccmCfgGetStr(hHal,
2894 WNI_CFG_SUPPORTED_RATES_11A,
2895 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2896 {
2897 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2898 {
2899 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2900 }
2901 for (i = 0; i < a_len; i++)
2902 {
2903 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2904 }
2905 range->num_bitrates = a_len;
2906 }
2907 else
2908 {
2909 return -EIO;
2910 }
2911 }
2912 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2913 {
2914 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002915 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 if (ccmCfgGetStr(hHal,
2917 WNI_CFG_SUPPORTED_RATES_11B,
2918 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2919 {
2920 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2921 {
2922 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2923 }
2924 for (i = 0; i < b_len; i++)
2925 {
2926 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2927 }
2928 range->num_bitrates = b_len;
2929 }
2930 else
2931 {
2932 return -EIO;
2933 }
2934 }
2935 }
2936
2937 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2938 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2939 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2940
2941 range->encoding_size[0] = 5;
2942 range->encoding_size[1] = 13;
2943 range->num_encoding_sizes = 2;
2944 range->max_encoding_tokens = MAX_WEP_KEYS;
2945
2946 // we support through Wireless Extensions 22
2947 range->we_version_compiled = WIRELESS_EXT;
2948 range->we_version_source = 22;
2949
2950 /*Supported Channels and Frequencies*/
2951 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2952 {
c_hpothub8245442013-11-20 23:41:09 +05302953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2954 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 return -EIO;
2956 }
2957 if (num_channels > IW_MAX_FREQUENCIES)
2958 {
2959 num_channels = IW_MAX_FREQUENCIES;
2960 }
2961
2962 range->num_channels = num_channels;
2963 range->num_frequency = num_channels;
2964
2965 for (index=0; index < num_channels; index++)
2966 {
2967 v_U32_t frq_indx = 0;
2968
2969 range->freq[index].i = channels[index];
2970 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2971 {
2972 if(channels[index] == freq_chan_map[frq_indx].chan)
2973 {
2974 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2975 range->freq[index].e = 1;
2976 break;
2977 }
2978 frq_indx++;
2979 }
2980 }
2981
2982 /* Event capability (kernel + driver) */
2983 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2984 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2985 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2986 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2987
2988 /*Encryption capability*/
2989 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2990 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2991
2992 /* Txpower capability */
2993 range->txpower_capa = IW_TXPOW_MWATT;
2994
2995 /*Scanning capability*/
2996 #if WIRELESS_EXT >= 22
2997 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2998 #endif
2999
3000 EXIT();
3001 return 0;
3002}
3003
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303004static int iw_get_range(struct net_device *dev,
3005 struct iw_request_info *info,
3006 union iwreq_data *wrqu, char *extra)
3007{
3008 int ret;
3009
3010 vos_ssr_protect(__func__);
3011 ret = __iw_get_range(dev, info, wrqu, extra);
3012 vos_ssr_unprotect(__func__);
3013
3014 return ret;
3015}
3016
Jeff Johnson295189b2012-06-20 16:38:30 -07003017/* Callback function registered with PMC to know status of PMC request */
3018static void iw_power_callback_fn (void *pContext, eHalStatus status)
3019{
3020 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003021
3022 if (NULL == pContext)
3023 {
3024 hddLog(VOS_TRACE_LEVEL_ERROR,
3025 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003026 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 return;
3028 }
3029
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003031
Jeff Johnson72a40512013-12-19 10:14:15 -08003032 /* there is a race condition that exists between this callback
3033 function and the caller since the caller could time out either
3034 before or while this code is executing. we use a spinlock to
3035 serialize these actions */
3036 spin_lock(&hdd_context_lock);
3037
3038 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 {
3040 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003041 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003043 "%s: Invalid context, magic [%08x]",
3044 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003045
3046 if (ioctl_debug)
3047 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003048 pr_info("%s: Invalid context, magic [%08x]\n",
3049 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 }
3051 return;
3052 }
3053
Jeff Johnson72a40512013-12-19 10:14:15 -08003054 /* context is valid so caller is still waiting */
3055
3056 /* paranoia: invalidate the magic */
3057 pStatsContext->magic = 0;
3058
3059 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003061
3062 /* serialization is complete */
3063 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003064}
3065
3066/* Callback function for tx per hit */
3067void hdd_tx_per_hit_cb (void *pCallbackContext)
3068{
3069 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3070 unsigned char tx_fail[16];
3071 union iwreq_data wrqu;
3072
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303073 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003075 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 return;
3077 }
3078 memset(&wrqu, 0, sizeof(wrqu));
3079 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3080 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3081}
3082
3083void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3084{
3085 struct statsContext *pStatsContext;
3086 tCsrGlobalClassAStatsInfo *pClassAStats;
3087 hdd_adapter_t *pAdapter;
3088
3089 if (ioctl_debug)
3090 {
3091 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003092 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 }
3094
3095 if ((NULL == pStats) || (NULL == pContext))
3096 {
3097 hddLog(VOS_TRACE_LEVEL_ERROR,
3098 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003099 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 return;
3101 }
3102
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 pClassAStats = pStats;
3104 pStatsContext = pContext;
3105 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003106
3107 /* there is a race condition that exists between this callback
3108 function and the caller since the caller could time out either
3109 before or while this code is executing. we use a spinlock to
3110 serialize these actions */
3111 spin_lock(&hdd_context_lock);
3112
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3114 {
3115 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003116 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 hddLog(VOS_TRACE_LEVEL_WARN,
3118 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003119 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 if (ioctl_debug)
3121 {
3122 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003123 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 }
3125 return;
3126 }
3127
Jeff Johnson72a40512013-12-19 10:14:15 -08003128 /* context is valid so caller is still waiting */
3129
3130 /* paranoia: invalidate the magic */
3131 pStatsContext->magic = 0;
3132
3133 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3135
Jeff Johnson72a40512013-12-19 10:14:15 -08003136 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003138
3139 /* serialization is complete */
3140 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003141}
3142
3143VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3144{
3145 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3146 eHalStatus hstatus;
3147 long lrc;
3148 struct statsContext context;
3149
3150 if (NULL == pAdapter)
3151 {
3152 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3153 return VOS_STATUS_E_FAULT;
3154 }
3155 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3156 {
3157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3158 return VOS_STATUS_SUCCESS;
3159 }
3160
3161 /* we are connected
3162 prepare our callback context */
3163 init_completion(&context.completion);
3164 context.pAdapter = pAdapter;
3165 context.magic = STATS_CONTEXT_MAGIC;
3166 /* query only for Class A statistics (which include link speed) */
3167 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3168 eCSR_HDD,
3169 SME_GLOBAL_CLASSA_STATS,
3170 hdd_GetClassA_statisticsCB,
3171 0, // not periodic
3172 FALSE, //non-cached results
3173 pHddStaCtx->conn_info.staId[0],
3174 &context);
3175 if (eHAL_STATUS_SUCCESS != hstatus)
3176 {
3177 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003178 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003179 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 /* we'll returned a cached value below */
3181 }
3182 else
3183 {
3184 /* request was sent -- wait for the response */
3185 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3186 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 if (lrc <= 0)
3188 {
3189 hddLog(VOS_TRACE_LEVEL_ERROR,
3190 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003191 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 }
3193 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003194
3195 /* either we never sent a request, we sent a request and received a
3196 response or we sent a request and timed out. if we never sent a
3197 request or if we sent a request and got a response, we want to
3198 clear the magic out of paranoia. if we timed out there is a
3199 race condition such that the callback function could be
3200 executing at the same time we are. of primary concern is if the
3201 callback function had already verified the "magic" but had not
3202 yet set the completion variable when a timeout occurred. we
3203 serialize these activities by invalidating the magic while
3204 holding a shared spinlock which will cause us to block if the
3205 callback is currently executing */
3206 spin_lock(&hdd_context_lock);
3207 context.magic = 0;
3208 spin_unlock(&hdd_context_lock);
3209
3210 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 return VOS_STATUS_SUCCESS;
3212}
3213
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003214static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3215{
3216 struct statsContext *pStatsContext;
3217 tCsrSummaryStatsInfo *pSummaryStats;
3218 tCsrGlobalClassAStatsInfo *pClassAStats;
3219 hdd_adapter_t *pAdapter;
3220
3221 if (ioctl_debug)
3222 {
3223 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003224 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003225 }
3226
3227 if ((NULL == pStats) || (NULL == pContext))
3228 {
3229 hddLog(VOS_TRACE_LEVEL_ERROR,
3230 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003231 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003232 return;
3233 }
3234
Jeff Johnson72a40512013-12-19 10:14:15 -08003235 /* there is a race condition that exists between this callback
3236 function and the caller since the caller could time out either
3237 before or while this code is executing. we use a spinlock to
3238 serialize these actions */
3239 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003240
3241 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3242 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3243 pStatsContext = pContext;
3244 pAdapter = pStatsContext->pAdapter;
3245 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3246 {
3247 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003248 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003249 hddLog(VOS_TRACE_LEVEL_WARN,
3250 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003251 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003252 if (ioctl_debug)
3253 {
3254 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003255 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003256 }
3257 return;
3258 }
3259
Jeff Johnson72a40512013-12-19 10:14:15 -08003260 /* context is valid so caller is still waiting */
3261
3262 /* paranoia: invalidate the magic */
3263 pStatsContext->magic = 0;
3264
3265 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003266 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3267 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3268
Jeff Johnson72a40512013-12-19 10:14:15 -08003269 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003270 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003271
3272 /* serialization is complete */
3273 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003274}
3275
3276VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3277{
3278 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3279 eHalStatus hstatus;
3280 long lrc;
3281 struct statsContext context;
3282
3283 if (NULL == pAdapter)
3284 {
3285 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3286 return VOS_STATUS_SUCCESS;
3287 }
3288
3289 /* we are connected
3290 prepare our callback context */
3291 init_completion(&context.completion);
3292 context.pAdapter = pAdapter;
3293 context.magic = STATS_CONTEXT_MAGIC;
3294
3295 /* query only for Summary & Class A statistics */
3296 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3297 eCSR_HDD,
3298 SME_SUMMARY_STATS |
3299 SME_GLOBAL_CLASSA_STATS,
3300 hdd_get_station_statisticsCB,
3301 0, // not periodic
3302 FALSE, //non-cached results
3303 pHddStaCtx->conn_info.staId[0],
3304 &context);
3305 if (eHAL_STATUS_SUCCESS != hstatus)
3306 {
3307 hddLog(VOS_TRACE_LEVEL_ERROR,
3308 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003309 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003310 /* we'll return with cached values */
3311 }
3312 else
3313 {
3314 /* request was sent -- wait for the response */
3315 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3316 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003317
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003318 if (lrc <= 0)
3319 {
3320 hddLog(VOS_TRACE_LEVEL_ERROR,
3321 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003322 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003323 }
3324 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003325
3326 /* either we never sent a request, we sent a request and received a
3327 response or we sent a request and timed out. if we never sent a
3328 request or if we sent a request and got a response, we want to
3329 clear the magic out of paranoia. if we timed out there is a
3330 race condition such that the callback function could be
3331 executing at the same time we are. of primary concern is if the
3332 callback function had already verified the "magic" but had not
3333 yet set the completion variable when a timeout occurred. we
3334 serialize these activities by invalidating the magic while
3335 holding a shared spinlock which will cause us to block if the
3336 callback is currently executing */
3337 spin_lock(&hdd_context_lock);
3338 context.magic = 0;
3339 spin_unlock(&hdd_context_lock);
3340
3341 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003342 return VOS_STATUS_SUCCESS;
3343}
3344
3345
Jeff Johnson295189b2012-06-20 16:38:30 -07003346/*
3347 * Support for the LINKSPEED private command
3348 * Per the WiFi framework the response must be of the form
3349 * "LinkSpeed xx"
3350 */
3351static int iw_get_linkspeed(struct net_device *dev,
3352 struct iw_request_info *info,
3353 union iwreq_data *wrqu, char *extra)
3354{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303355 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303356 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303358 int len = sizeof(v_U32_t) + 1;
3359 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303360 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303361 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303362 int rc, valid = 0;
3363
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303364 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303365 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3366 if (NULL == pAdapter)
3367 {
3368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3369 "%s: Adapter is NULL",__func__);
3370 return -EINVAL;
3371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003372
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303373 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303374 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303375 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003376 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303377 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003378 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303379 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3380 if (NULL == pHddStaCtx)
3381 {
3382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3383 "%s: STA Context is NULL",__func__);
3384 return -EINVAL;
3385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3387 {
3388 /* we are not connected so we don't have a classAstats */
3389 link_speed = 0;
3390 }
3391 else
3392 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303393 status = wlan_hdd_get_classAstats(pAdapter);
3394
3395 if (!VOS_IS_STATUS_SUCCESS(status ))
3396 {
3397 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3398 return -EINVAL;
3399 }
3400
3401 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3402 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3403 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3404 &link_speed);
3405
3406 link_speed = link_speed / 10;
3407
3408 if (0 == link_speed)
3409 {
3410 /* The linkspeed returned by HAL is in units of 500kbps.
3411 * converting it to mbps.
3412 * This is required to support legacy firmware which does
3413 * not return link capacity.
3414 */
3415 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3416 }
3417
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 }
3419
3420 wrqu->data.length = len;
3421 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003422 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 if ((rc < 0) || (rc >= len))
3424 {
3425 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303426 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003427 return -EIO;
3428 }
3429
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303430 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003432 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003433}
3434
Arif Hussain695279c2014-03-24 14:06:07 -07003435/*
3436 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3437 *
3438 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303439static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003440 struct iw_request_info *info,
3441 union iwreq_data *wrqu, char *extra)
3442{
3443 int rc;
3444
3445 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3446
3447 if (rc < 0)
3448 return rc;
3449
3450 /* a value is being successfully returned */
3451 return 0;
3452}
Jeff Johnson295189b2012-06-20 16:38:30 -07003453
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303454static int iw_get_linkspeed_priv(struct net_device *dev,
3455 struct iw_request_info *info,
3456 union iwreq_data *wrqu, char *extra)
3457{
3458 int ret;
3459
3460 vos_ssr_protect(__func__);
3461 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3462 vos_ssr_unprotect(__func__);
3463
3464 return ret;
3465}
3466
Jeff Johnson295189b2012-06-20 16:38:30 -07003467/*
3468 * Support for the RSSI & RSSI-APPROX private commands
3469 * Per the WiFi framework the response must be of the form
3470 * "<ssid> rssi <xx>"
3471 * unless we are not associated, in which case the response is
3472 * "OK"
3473 */
3474static int iw_get_rssi(struct net_device *dev,
3475 struct iw_request_info *info,
3476 union iwreq_data *wrqu, char *extra)
3477{
3478 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003479 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 int len = wrqu->data.length;
3481 v_S7_t s7Rssi = 0;
3482 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3483 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3484 VOS_STATUS vosStatus;
3485 int rc;
3486
3487 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3488 (0 == ssidlen) || (ssidlen >= len))
3489 {
3490 /* we are not connected or our SSID is too long
3491 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003492 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 }
3494 else
3495 {
3496 /* we are connected with a valid SSID
3497 so we can write the SSID into the return buffer
3498 (note that it is not NUL-terminated) */
3499 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3500
3501 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3502
3503 if (VOS_STATUS_SUCCESS == vosStatus)
3504 {
3505 /* append the rssi to the ssid in the format required by
3506 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003507 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303508 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 }
3510 else
3511 {
3512 rc = -1;
3513 }
3514 }
3515
3516 /* verify that we wrote a valid response */
3517 if ((rc < 0) || (rc >= len))
3518 {
3519 // encoding or length error?
3520 hddLog(VOS_TRACE_LEVEL_ERROR,
3521 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003522 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 return -EIO;
3524 }
3525
3526 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003527 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003528}
3529
3530/*
3531 * Support for SoftAP channel range private command
3532 */
3533static int iw_softap_set_channel_range( struct net_device *dev,
3534 int startChannel,
3535 int endChannel,
3536 int band)
3537{
Jeff Johnson43971f52012-07-17 12:26:56 -07003538 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 int ret = 0;
3540 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3541 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003542 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3543
Jeff Johnson295189b2012-06-20 16:38:30 -07003544
3545 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3546 if (VOS_STATUS_SUCCESS != status)
3547 {
3548 ret = -EINVAL;
3549 }
Yathish9f22e662012-12-10 14:21:35 -08003550 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 return ret;
3552}
3553
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303554static uint8 chartohex(char c)
3555{
3556 uint8 val = 0;
3557 if (c >= '0' && c <= '9')
3558 val = c - '0';
3559 else if (c >= 'a' && c <= 'f')
3560 val = c - 'a' + 10;
3561 else if (c >= 'A' && c <= 'F')
3562 val = c - 'A' + 10;
3563 else
3564 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3565
3566 return val;
3567}
3568
3569uint8 getByte(char **buf)
3570{
3571 uint8 byte = 0;
3572 char *temp = *buf;
3573 byte = chartohex(*temp) * 16;
3574 temp++;
3575 byte += chartohex(*temp);
3576 temp++;
3577 *buf = temp;
3578 return byte;
3579}
3580
3581static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3582{
3583 tSir80211Header *macHeader;
3584 int i = 0, j = 0, length = 0;
3585 uint8 byte = 0;
3586 char *temp = pBuffer;
3587 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303588 char *pHeader;
3589 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303590
3591 macHeader = &pkt->macHeader;
3592
3593 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3594
3595 temp++;
3596
3597 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3598 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3599 pkt->encParams.keyParams.key[0].keyId);
3600
3601 for (i = 0; i< 16; i++) {
3602 pkt->encParams.keyParams.key[0].key[i]
3603 = getByte(&temp);
3604 }
3605
3606 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3607 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3608
3609 for (i = 0; i< 6; i++) {
3610 pkt->encParams.pn[i]
3611 = getByte(&temp);
3612 }
3613
3614 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3615 &pkt->encParams.pn[0], 6, 0);
3616
3617 for (i = 0, j= 5; i< 3; i++, j--) {
3618 byte = pkt->encParams.pn[i];
3619 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3620 pkt->encParams.pn[j] = byte;
3621 }
3622
3623 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303624 if (length > sizeof(tSir80211Header))
3625 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303626
Srinivas Dasari2382de62015-01-22 15:00:04 +05303627 pHeader = temp;
3628 vos_mem_zero(&header, sizeof(tSir80211Header));
3629 for (i = 0; i < length; i++) {
3630 *((uint8 *)&header + i) = getByte(&pHeader);
3631 }
3632
3633 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3634 (char *)&header, length, 0);
3635
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303636 byte = getByte(&temp);
3637
3638 macHeader->frameCtrl.protVer = byte & 0x3;
3639 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3640 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3641
3642 byte = getByte(&temp);
3643 macHeader->frameCtrl.toDS = (byte) & 0x1;
3644 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3645 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3646 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3647 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3648 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3649 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3650 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3651
3652 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3653 "macHeader->frameCtrl.type : %x "
3654 "macHeader->frameCtrl.subType : %x "
3655 "macHeader->frameCtrl.toDS : %x "
3656 "macHeader->frameCtrl.fromDS : %x "
3657 "macHeader->frameCtrl.moreFrag : %x "
3658 "macHeader->frameCtrl.retry : %x "
3659 "macHeader->frameCtrl.powerMgmt : %x "
3660 "macHeader->frameCtrl.MoreData : %x "
3661 "macHeader->frameCtrl.wep : %x "
3662 "macHeader->frameCtrl.order : %x "
3663 , macHeader->frameCtrl.protVer
3664 , macHeader->frameCtrl.type
3665 , macHeader->frameCtrl.subType
3666 , macHeader->frameCtrl.toDS
3667 , macHeader->frameCtrl.fromDS
3668 , macHeader->frameCtrl.moreFrag
3669 , macHeader->frameCtrl.retry
3670 , macHeader->frameCtrl.powerMgmt
3671 , macHeader->frameCtrl.moreData
3672 , macHeader->frameCtrl.wep
3673 , macHeader->frameCtrl.order);
3674
3675
3676 macHeader->usDurationId = getByte(&temp);
3677 macHeader->usDurationId += getByte(&temp) << 8;
3678
3679 macHeader->vA1[0] = getByte(&temp);
3680 macHeader->vA1[1] = getByte(&temp);
3681 macHeader->vA1[2] = getByte(&temp);
3682 macHeader->vA1[3] = getByte(&temp);
3683 macHeader->vA1[4] = getByte(&temp);
3684 macHeader->vA1[5] = getByte(&temp);
3685
3686 macHeader->vA2[0] = getByte(&temp);
3687 macHeader->vA2[1] = getByte(&temp);
3688 macHeader->vA2[2] = getByte(&temp);
3689 macHeader->vA2[3] = getByte(&temp);
3690 macHeader->vA2[4] = getByte(&temp);
3691 macHeader->vA2[5] = getByte(&temp);
3692
3693 macHeader->vA3[0] = getByte(&temp);
3694 macHeader->vA3[1] = getByte(&temp);
3695 macHeader->vA3[2] = getByte(&temp);
3696 macHeader->vA3[3] = getByte(&temp);
3697 macHeader->vA3[4] = getByte(&temp);
3698 macHeader->vA3[5] = getByte(&temp);
3699
3700 macHeader->sSeqCtrl = getByte(&temp);
3701 fragNum = macHeader->sSeqCtrl & 0xF;
3702 macHeader->sSeqCtrl >>= 4;
3703
3704 macHeader->sSeqCtrl += getByte(&temp) << 4;
3705
3706 macHeader->sSeqCtrl |= fragNum << 12;
3707
3708 if (length == 30 || length == 32) {
3709 macHeader->optvA4[0] = getByte(&temp);
3710 macHeader->optvA4[1] = getByte(&temp);
3711 macHeader->optvA4[2] = getByte(&temp);
3712 macHeader->optvA4[3] = getByte(&temp);
3713 macHeader->optvA4[4] = getByte(&temp);
3714 macHeader->optvA4[5] = getByte(&temp);
3715 }
3716
3717 if (length == 26 || length == 32) {
3718 macHeader->usQosCtrl = getByte(&temp);
3719 macHeader->usQosCtrl += getByte(&temp) << 8;
3720 }
3721
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303722 //parse payload
3723 length = getByte(&temp);
3724 length += getByte(&temp) << 8;
3725 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3726
3727 pkt->data.length = length;
3728
3729 for (i = 0; i< length; i++) {
3730 pkt->data.data[i] = getByte(&temp);
3731 }
3732
3733 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3734 &pkt->data.data[0], pkt->data.length, 0);
3735}
3736
3737/**---------------------------------------------------------------------------
3738
3739 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3740 encrypt message request
3741 This is an asynchronous callback function from SME when the encrypted data
3742 is received
3743
3744 \pEncInfoRsp -> Encrypted data info
3745
3746 \return - 0 for success non-zero for failure
3747 --------------------------------------------------------------------------*/
3748static void
3749hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3750{
3751 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3752
3753 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3754
3755 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3756 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3757 pEncryptedDataRsp->encryptedPayload.length);
3758 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3759 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3760 pEncryptedDataRsp->encryptedPayload.data,
3761 pEncryptedDataRsp->encryptedPayload.length, 0);
3762}
3763
Jeff Johnson295189b2012-06-20 16:38:30 -07003764VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3765{
3766 struct statsContext context;
3767 eHalStatus status;
3768 hdd_context_t *pHddCtx;
3769
3770 if (NULL == pAdapter)
3771 {
3772 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3773 return VOS_STATUS_E_FAULT;
3774 }
3775
3776 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3777 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303778 if (pHddCtx->isLogpInProgress) {
3779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3780 "%s:LOGP in Progress. Ignore!!!", __func__);
3781 return VOS_STATUS_E_FAILURE;
3782 }
3783
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 init_completion(&context.completion);
3785
3786 context.pAdapter = pAdapter;
3787 context.magic = POWER_CONTEXT_MAGIC;
3788
3789 if (DRIVER_POWER_MODE_ACTIVE == mode)
3790 {
3791 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3792 "Full Power", __func__);
3793 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3794 iw_power_callback_fn, &context,
3795 eSME_FULL_PWR_NEEDED_BY_HDD);
3796 // Enter Full power command received from GUI this means we are disconnected
3797 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3798 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3799 if (eHAL_STATUS_PMC_PENDING == status)
3800 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003801 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 int lrc = wait_for_completion_interruptible_timeout(
3803 &context.completion,
3804 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003805
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 if (lrc <= 0)
3807 {
3808 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003809 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 }
3811 }
3812 }
3813 else if (DRIVER_POWER_MODE_AUTO == mode)
3814 {
3815 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3816 {
3817 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3818 __func__);
3819 // Enter BMPS command received from GUI this means DHCP is completed
3820 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3821 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3822 FALSE);
3823 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3824 iw_power_callback_fn, &context);
3825 if (eHAL_STATUS_PMC_PENDING == status)
3826 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003827 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 int lrc = wait_for_completion_interruptible_timeout(
3829 &context.completion,
3830 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 if (lrc <= 0)
3832 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003833 hddLog(VOS_TRACE_LEVEL_ERROR,
3834 "%s: SME %s while requesting BMPS",
3835 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 }
3837 }
3838 }
3839 else
3840 {
3841 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3842 "enabled in the cfg");
3843 }
3844 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003845
3846 /* either we never sent a request, we sent a request and received a
3847 response or we sent a request and timed out. if we never sent a
3848 request or if we sent a request and got a response, we want to
3849 clear the magic out of paranoia. if we timed out there is a
3850 race condition such that the callback function could be
3851 executing at the same time we are. of primary concern is if the
3852 callback function had already verified the "magic" but had not
3853 yet set the completion variable when a timeout occurred. we
3854 serialize these activities by invalidating the magic while
3855 holding a shared spinlock which will cause us to block if the
3856 callback is currently executing */
3857 spin_lock(&hdd_context_lock);
3858 context.magic = 0;
3859 spin_unlock(&hdd_context_lock);
3860
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 return VOS_STATUS_SUCCESS;
3862}
3863
3864VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3865 hdd_adapter_t *pAdapter)
3866{
3867 VOS_STATUS vos_Status;
3868
3869 if ((NULL == pAdapter) || (NULL == pHddCtx))
3870 {
3871 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3872 return VOS_STATUS_E_FAULT;
3873 }
3874
3875 /**Exit from Deep sleep or standby if we get the driver
3876 START cmd from android GUI
3877 */
3878 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3879 {
3880 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3881 "from Stand by",__func__);
3882 vos_Status = hdd_exit_standby(pHddCtx);
3883 }
3884 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3885 {
3886 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3887 "from deep sleep",__func__);
3888 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3889 }
3890 else
3891 {
3892 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3893 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3894 vos_Status = VOS_STATUS_SUCCESS;
3895 }
3896
3897 return vos_Status;
3898}
3899
3900VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3901{
3902 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3903
3904 if (NULL == pHddCtx)
3905 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303906 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 return VOS_STATUS_E_FAULT;
3908 }
3909
3910 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3911 {
3912 //Execute standby procedure.
3913 //Executing standby procedure will cause the STA to
3914 //disassociate first and then the chip will be put into standby.
3915 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3916 vos_Status = hdd_enter_standby(pHddCtx);
3917 }
3918 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3919 pHddCtx->cfg_ini->nEnableDriverStop)
3920 {
3921 //Execute deep sleep procedure
3922 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003923 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 //Deep sleep not supported
3925 vos_Status = hdd_enter_standby(pHddCtx);
3926 }
3927 else
3928 {
3929 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3930 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3931 vos_Status = VOS_STATUS_SUCCESS;
3932 }
3933
3934 return vos_Status;
3935}
3936
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003937
3938void* wlan_hdd_change_country_code_callback(void *pAdapter)
3939{
3940
3941 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003942 complete(&call_back_pAdapter->change_country_code);
3943
3944 return NULL;
3945}
3946
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303947static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 struct iw_request_info *info,
3949 union iwreq_data *wrqu, char *extra)
3950{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303951 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08003952 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003953 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303954 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003955 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3956
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303957 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003958
3959 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303960
3961 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3962 if (NULL == pAdapter)
3963 {
3964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3965 "mem_alloc_copy_from_user_helper fail");
3966 return -EINVAL;
3967 }
3968 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3969 rc = wlan_hdd_validate_context(pHddCtx);
3970 if (0 != rc)
3971 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303972 return rc;
3973 }
3974
Arif Hussain24bfa702014-01-22 13:51:30 -08003975 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3976 wrqu->data.length);
3977 if (NULL == cmd)
3978 {
3979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3980 "mem_alloc_copy_from_user_helper fail");
3981 return -ENOMEM;
3982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003983
3984 if (ioctl_debug)
3985 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003986 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 }
3988
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003989 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3990 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003991
Arif Hussain24bfa702014-01-22 13:51:30 -08003992 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003994 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3996 "%s: Error in iw_set_scan!", __func__);
3997 rc = -EINVAL;
3998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 }
4000 else if( strcasecmp(cmd, "start") == 0 ) {
4001
Arif Hussain6d2a3322013-11-17 19:50:10 -08004002 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004004
Arif Hussain24bfa702014-01-22 13:51:30 -08004005 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4006 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 {
4008 union iwreq_data wrqu;
4009 char buf[10];
4010
4011 memset(&wrqu, 0, sizeof(wrqu));
4012 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4013 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4014 }
4015 else
4016 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004017 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4018 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 }
4020 goto done;
4021 }
4022 else if( strcasecmp(cmd, "stop") == 0 )
4023 {
4024 union iwreq_data wrqu;
4025 char buf[10];
4026
Arif Hussain6d2a3322013-11-17 19:50:10 -08004027 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004028
4029 wlan_hdd_enter_lowpower(pHddCtx);
4030 memset(&wrqu, 0, sizeof(wrqu));
4031 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4032 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 goto done;
4034 }
4035 else if (strcasecmp(cmd, "macaddr") == 0)
4036 {
4037 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4038 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4039 }
4040 else if (strcasecmp(cmd, "scan-active") == 0)
4041 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304042 hddLog(VOS_TRACE_LEVEL_ERROR,
4043 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004044 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 ret = snprintf(cmd, cmd_len, "OK");
4046 }
4047 else if (strcasecmp(cmd, "scan-passive") == 0)
4048 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304049 hddLog(VOS_TRACE_LEVEL_ERROR,
4050 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004051 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 ret = snprintf(cmd, cmd_len, "OK");
4053 }
4054 else if( strcasecmp(cmd, "scan-mode") == 0 )
4055 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004056 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 }
4058 else if( strcasecmp(cmd, "linkspeed") == 0 )
4059 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004060 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 }
4062 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4063 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004064 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004065 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004066
4067 country_code = cmd + 8;
4068
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004069 init_completion(&pAdapter->change_country_code);
4070
Arif Hussain24bfa702014-01-22 13:51:30 -08004071 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004072 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 country_code,
4074 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304075 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304076 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304077 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004078
4079 /* Wait for completion */
4080 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4081 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4082
4083 if (lrc <= 0)
4084 {
4085 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004086 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004087 }
4088
Arif Hussain24bfa702014-01-22 13:51:30 -08004089 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004091 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004092 "%s: SME Change Country code fail", __func__);
4093 kfree(cmd);
4094 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 }
4096 }
4097 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4098 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004099 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004100 }
4101 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4102 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004103 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004104
Wilson Yang1be3e652013-10-09 15:18:31 -07004105 if (9 < cmd_len)
4106 {
4107 ptr = (char*)(cmd + 9);
4108
4109 }else{
4110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4111 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004112 kfree(cmd);
4113 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004114 }
4115
4116 if (1 != sscanf(ptr,"%d",&mode))
4117 {
4118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4119 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004120 kfree(cmd);
4121 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004122 }
4123
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 wlan_hdd_enter_bmps(pAdapter, mode);
4125 /*TODO:Set the power mode*/
4126 }
4127 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4128 v_U32_t pmc_state;
4129 v_U16_t value;
4130
4131 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4132 if(pmc_state == BMPS) {
4133 value = DRIVER_POWER_MODE_AUTO;
4134 }
4135 else {
4136 value = DRIVER_POWER_MODE_ACTIVE;
4137 }
4138 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4139 }
4140 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004141 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 /*TODO: set the btcoexmode*/
4143 }
4144 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4145
Arif Hussain6d2a3322013-11-17 19:50:10 -08004146 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 /*TODO: Return the btcoex status*/
4148 }
4149 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4150
Arif Hussain6d2a3322013-11-17 19:50:10 -08004151 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004152
4153 /*TODO: Enable Rx data Filter*/
4154 }
4155 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4156
Arif Hussain6d2a3322013-11-17 19:50:10 -08004157 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004158
4159 /*TODO: Disable Rx data Filter*/
4160 }
4161 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4162
Arif Hussain6d2a3322013-11-17 19:50:10 -08004163 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 /*TODO: rxfilter-statistics*/
4165 }
4166 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4167
Arif Hussain6d2a3322013-11-17 19:50:10 -08004168 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 /*TODO: rxfilter-add*/
4170 }
4171 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4172
Arif Hussain6d2a3322013-11-17 19:50:10 -08004173 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 /*TODO: rxfilter-remove*/
4175 }
4176#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004177 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4178 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4179 /*TODO: support pnosetup*/
4180 }
4181 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4182 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4183 /*TODO: support pnoforce*/
4184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4186
Arif Hussain6d2a3322013-11-17 19:50:10 -08004187 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004188 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4189 kfree(cmd);
4190 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 }
4192 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004193 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004194 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4195 kfree(cmd);
4196 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 }
4198#endif /*FEATURE_WLAN_SCAN_PNO*/
4199 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004200 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004201 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4202 kfree(cmd);
4203 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 }
4205 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4206 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004207 char *ptr;
4208
4209 if (18 < cmd_len)
4210 {
4211 ptr = (char*)(cmd + 18);
4212 }else{
4213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4214 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004215 kfree(cmd);
4216 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004217 }
4218
Jeff Johnson02797792013-10-26 19:17:13 -07004219 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004220 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4221 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4222 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4223 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4224 {
4225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4226 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004227 kfree(cmd);
4228 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004230
4231 // parameters checking
4232 // period has to be larger than 0
4233 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4234 {
4235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004236 kfree(cmd);
4237 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 }
4239
4240 // use default value 5 is the input is not reasonable. in unit of 10%
4241 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4242 {
4243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4244 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4245 }
4246
4247 // default is 5
4248 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4249 {
4250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4251 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4252 }
4253
Arif Hussain24bfa702014-01-22 13:51:30 -08004254 if (eHAL_STATUS_SUCCESS !=
4255 sme_SetTxPerTracking(pHddCtx->hHal,
4256 hdd_tx_per_hit_cb,
4257 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004259 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004260 }
4261 }
4262 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004263 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4264 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 }
4266done:
4267 /* many of the commands write information back into the command
4268 string using snprintf(). check the return value here in one
4269 place */
4270 if ((ret < 0) || (ret >= cmd_len))
4271 {
4272 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004273 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004275 else if (ret > 0)
4276 {
4277 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4278 {
4279 hddLog(VOS_TRACE_LEVEL_ERROR,
4280 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004281 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004282 return -EFAULT;
4283 }
4284 wrqu->data.length = ret;
4285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004286
4287 if (ioctl_debug)
4288 {
4289 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004290 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004292 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304293 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004294 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004295}
4296
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304297static int iw_set_priv(struct net_device *dev,
4298 struct iw_request_info *info,
4299 union iwreq_data *wrqu, char *extra)
4300{
4301 int ret;
4302 vos_ssr_protect(__func__);
4303 ret = __iw_set_priv(dev, info, wrqu, extra);
4304 vos_ssr_unprotect(__func__);
4305
4306 return ret;
4307}
4308
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304309static int __iw_set_nick(struct net_device *dev,
4310 struct iw_request_info *info,
4311 union iwreq_data *wrqu, char *extra)
4312{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304313 hdd_adapter_t *pAdapter;
4314 hdd_context_t *pHddCtx;
4315 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304316
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304317 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304318
4319 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4320 if (NULL == pAdapter)
4321 {
4322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4323 "%s: Adapter is NULL",__func__);
4324 return -EINVAL;
4325 }
4326
4327 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4328 ret = wlan_hdd_validate_context(pHddCtx);
4329 if (0 != ret)
4330 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304331 return ret;
4332 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304333 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304334 return 0;
4335}
4336
Jeff Johnson295189b2012-06-20 16:38:30 -07004337static int iw_set_nick(struct net_device *dev,
4338 struct iw_request_info *info,
4339 union iwreq_data *wrqu, char *extra)
4340{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304341 int ret;
4342
4343 vos_ssr_protect(__func__);
4344 ret = __iw_set_nick(dev, info, wrqu, extra);
4345 vos_ssr_unprotect(__func__);
4346
4347 return ret;
4348}
4349
4350static int __iw_get_nick(struct net_device *dev,
4351 struct iw_request_info *info,
4352 union iwreq_data *wrqu, char *extra)
4353{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304354 hdd_adapter_t *pAdapter;
4355 hdd_context_t *pHddCtx;
4356 int ret = 0;
4357
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304359
4360 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4361 if (NULL == pAdapter)
4362 {
4363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4364 "%s: Adapter is NULL",__func__);
4365 return -EINVAL;
4366 }
4367
4368 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4369 ret = wlan_hdd_validate_context(pHddCtx);
4370 if (0 != ret)
4371 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304372 return ret;
4373 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304374 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 return 0;
4376}
4377
4378static int iw_get_nick(struct net_device *dev,
4379 struct iw_request_info *info,
4380 union iwreq_data *wrqu, char *extra)
4381{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304382 int ret;
4383
4384 vos_ssr_protect(__func__);
4385 ret = __iw_get_nick(dev, info, wrqu, extra);
4386 vos_ssr_unprotect(__func__);
4387
4388 return ret;
4389}
4390
4391static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4392{
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304394 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004395}
4396
4397static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4398{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304399
4400 struct iw_statistics *stats;
4401
4402 vos_ssr_protect(__func__);
4403 stats = __get_wireless_stats(dev);
4404 vos_ssr_unprotect(__func__);
4405
4406 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004407}
4408
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304409static int __iw_set_encode(struct net_device *dev,
4410 struct iw_request_info *info,
4411 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004412
4413{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304414 hdd_adapter_t *pAdapter;
4415 hdd_station_ctx_t *pHddStaCtx;
4416 hdd_wext_state_t *pWextState;
4417 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 struct iw_point *encoderq = &(wrqu->encoding);
4419 v_U32_t keyId;
4420 v_U8_t key_length;
4421 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4422 v_BOOL_t fKeyPresent = 0;
4423 int i;
4424 eHalStatus status = eHAL_STATUS_SUCCESS;
4425
4426
4427 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304428 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4429 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004430 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4432 "%s: Adapter is NULL",__func__);
4433 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 }
4435
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304436 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4437 status = wlan_hdd_validate_context(pHddCtx);
4438 if (0 != status)
4439 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304440 return status;
4441 }
4442 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4443 if (NULL == pWextState)
4444 {
4445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4446 "%s: pWextState is NULL ",__func__);
4447 return -EINVAL;
4448 }
4449 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4450 if (NULL == pHddStaCtx)
4451 {
4452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4453 "%s: STA Context is NULL",__func__);
4454 return -EINVAL;
4455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004456
4457 keyId = encoderq->flags & IW_ENCODE_INDEX;
4458
4459 if(keyId)
4460 {
4461 if(keyId > MAX_WEP_KEYS)
4462 {
4463 return -EINVAL;
4464 }
4465
4466 fKeyPresent = 1;
4467 keyId--;
4468 }
4469 else
4470 {
4471 fKeyPresent = 0;
4472 }
4473
4474
4475 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4476 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 if(!fKeyPresent) {
4479
4480 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4481
4482 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4483 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4484 }
4485 }
4486 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4487 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4488 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4489 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4490
4491 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4492 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4493
4494 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4495 {
4496 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4497 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004498 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304499 {
4500 long ret;
4501 ret = wait_for_completion_interruptible_timeout(
4502 &pAdapter->disconnect_comp_var,
4503 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4504 if (ret <= 0)
4505 hddLog(VOS_TRACE_LEVEL_ERROR,
4506 FL("failed wait on disconnect_comp_var %ld"), ret);
4507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 }
4509
4510 return status;
4511
4512 }
4513
4514 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4515 {
4516 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4517
4518 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4519
4520 }
4521
4522
4523 if(wrqu->data.length > 0)
4524 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004525 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004526
4527 key_length = wrqu->data.length;
4528
4529 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4530
4531 if(5 == key_length)
4532 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004533 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004534
4535 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4536 {
4537 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4538 }
4539 else
4540 {
4541 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4542 }
4543 }
4544 else if(13 == key_length)
4545 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004546 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004547
4548 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4549 {
4550 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4551 }
4552 else
4553 {
4554 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4555 }
4556 }
4557 else
4558 {
4559 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004560 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 return -EINVAL;
4562 }
4563
4564 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4565 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4566 pWextState->roamProfile.EncryptionType.numEntries = 1;
4567 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4568 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4569 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4570
4571 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4572 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4573 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4574 {
4575
4576 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4577
4578 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4579 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4580
4581 return status;
4582 }
4583 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304584 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 return 0;
4586}
4587
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304588static int iw_set_encode(struct net_device *dev,
4589 struct iw_request_info *info,
4590 union iwreq_data *wrqu,char *extra)
4591{
4592 int ret;
4593
4594 vos_ssr_protect(__func__);
4595 ret = __iw_set_encode(dev, info, wrqu, extra);
4596 vos_ssr_unprotect(__func__);
4597
4598 return ret;
4599}
4600
4601static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 struct iw_request_info *info,
4603 struct iw_point *dwrq,
4604 char *extra)
4605{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304606 hdd_adapter_t *pAdapter;
4607 hdd_wext_state_t *pWextState;
4608 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 int keyId;
4610 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4611 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304612 int i, ret = 0;
4613 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004614
4615 ENTER();
4616
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304617 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4618 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004619 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4621 "%s: Adapter is NULL",__func__);
4622 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004623 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304624 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4625 ret = wlan_hdd_validate_context(pHddCtx);
4626 if (0 != ret)
4627 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304628 return ret;
4629 }
4630 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4631 if (NULL == pWextState)
4632 {
4633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4634 "%s: pWextState is NULL",__func__);
4635 return -EINVAL;
4636 }
4637 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004638
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 keyId = pRoamProfile->Keys.defaultIndex;
4640
4641 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4642 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004643 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 return -EINVAL;
4645 }
4646
4647 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4648 {
4649 dwrq->flags |= IW_ENCODE_ENABLED;
4650 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304651 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4652 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 }
4654 else
4655 {
4656 dwrq->flags |= IW_ENCODE_DISABLED;
4657 }
4658
4659 for(i=0; i < MAX_WEP_KEYS; i++)
4660 {
4661 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4662 {
4663 continue;
4664 }
4665 else
4666 {
4667 break;
4668 }
4669 }
4670
4671 if(MAX_WEP_KEYS == i)
4672 {
4673 dwrq->flags |= IW_ENCODE_NOKEY;
4674 }
4675 else
4676 {
4677 dwrq->flags |= IW_ENCODE_ENABLED;
4678 }
4679
4680 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4681
4682 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4683 {
4684 dwrq->flags |= IW_ENCODE_DISABLED;
4685 }
4686
4687 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4688
4689 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4690 {
4691 dwrq->flags |= IW_ENCODE_OPEN;
4692 }
4693 else
4694 {
4695 dwrq->flags |= IW_ENCODE_RESTRICTED;
4696 }
4697 EXIT();
4698 return 0;
4699
4700}
4701
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304702static int iw_get_encodeext(struct net_device *dev,
4703 struct iw_request_info *info,
4704 struct iw_point *dwrq,
4705 char *extra)
4706{
4707 int ret;
4708 vos_ssr_protect(__func__);
4709 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4710 vos_ssr_unprotect(__func__);
4711
4712 return ret;
4713}
4714
4715static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 struct iw_request_info *info,
4717 union iwreq_data *wrqu, char *extra)
4718{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304719 hdd_adapter_t *pAdapter;
4720 hdd_station_ctx_t *pHddStaCtx;
4721 hdd_wext_state_t *pWextState;
4722 hdd_context_t *pHddCtx;
4723 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004724
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304725 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 v_U32_t status = 0;
4727
4728 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4729
4730 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4731
4732 int key_index;
4733 struct iw_point *encoding = &wrqu->encoding;
4734 tCsrRoamSetKey setKey;
4735 v_U32_t roamId= 0xFF;
4736 VOS_STATUS vos_status;
4737
4738 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304739 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4740 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4743 "%s: Adapter is NULL",__func__);
4744 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304746 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4747 status = wlan_hdd_validate_context(pHddCtx);
4748 if (0 != status)
4749 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304750 return status;
4751 }
4752 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4753 if (NULL == pHddStaCtx)
4754 {
4755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4756 "%s: STA Context is NULL",__func__);
4757 return -EINVAL;
4758 }
4759 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4760 if (NULL == pWextState)
4761 {
4762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4763 "%s: pWextState is NULL",__func__);
4764 return -EINVAL;
4765 }
4766 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 key_index = encoding->flags & IW_ENCODE_INDEX;
4768
4769 if(key_index > 0) {
4770
4771 /*Convert from 1-based to 0-based keying*/
4772 key_index--;
4773 }
4774 if(!ext->key_len) {
4775
4776 /*Set the encrytion type to NONE*/
4777 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4778 return status;
4779 }
4780
4781 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4782 (IW_ENCODE_ALG_WEP == ext->alg))
4783 {
4784 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4785
Agarwal Ashish971c2882013-10-30 20:11:12 +05304786 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4787 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 return -EINVAL;
4789 }
4790 else {
4791 /*Static wep, update the roam profile with the keys */
4792 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4793 key_index < CSR_MAX_NUM_KEY) {
4794 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4795 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4796
4797 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4798 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4799
4800 }
4801 }
4802 return status;
4803 }
4804
4805 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4806
4807 setKey.keyId = key_index;
4808 setKey.keyLength = ext->key_len;
4809
4810 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4811 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4812 }
4813
4814 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4815 /*Key direction for group is RX only*/
4816 setKey.keyDirection = eSIR_RX_ONLY;
4817 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4818 }
4819 else {
4820
4821 setKey.keyDirection = eSIR_TX_RX;
4822 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4823 }
4824
4825 /*For supplicant pae role is zero*/
4826 setKey.paeRole = 0;
4827
4828 switch(ext->alg)
4829 {
4830 case IW_ENCODE_ALG_NONE:
4831 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4832 break;
4833
4834 case IW_ENCODE_ALG_WEP:
4835 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4836 break;
4837
4838 case IW_ENCODE_ALG_TKIP:
4839 {
4840 v_U8_t *pKey = &setKey.Key[0];
4841
4842 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4843
4844 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4845
4846 /*Supplicant sends the 32bytes key in this order
4847
4848 |--------------|----------|----------|
4849 | Tk1 |TX-MIC | RX Mic |
4850 |--------------|----------|----------|
4851 <---16bytes---><--8bytes--><--8bytes-->
4852
4853 */
4854 /*Sme expects the 32 bytes key to be in the below order
4855
4856 |--------------|----------|----------|
4857 | Tk1 |RX-MIC | TX Mic |
4858 |--------------|----------|----------|
4859 <---16bytes---><--8bytes--><--8bytes-->
4860 */
4861 /* Copy the Temporal Key 1 (TK1) */
4862 vos_mem_copy(pKey,ext->key,16);
4863
4864 /*Copy the rx mic first*/
4865 vos_mem_copy(&pKey[16],&ext->key[24],8);
4866
4867 /*Copy the tx mic */
4868 vos_mem_copy(&pKey[24],&ext->key[16],8);
4869
4870 }
4871 break;
4872
4873 case IW_ENCODE_ALG_CCMP:
4874 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4875 break;
4876
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004877#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004878#define IW_ENCODE_ALG_KRK 6
4879 case IW_ENCODE_ALG_KRK:
4880 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4881 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004882#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004883
4884 default:
4885 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4886 break;
4887 }
4888
4889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004890 ("%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 -07004891
4892#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304893 /* The supplicant may attempt to set the PTK once pre-authentication
4894 is done. Save the key in the UMAC and include it in the ADD
4895 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304897 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304899 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4900 "%s: Update PreAuth Key success", __func__);
4901 return 0;
4902 }
4903 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4904 {
4905 hddLog(VOS_TRACE_LEVEL_ERROR,
4906 "%s: Update PreAuth Key failed", __func__);
4907 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 }
4909#endif /* WLAN_FEATURE_VOWIFI_11R */
4910
4911 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4912
4913 vos_status = wlan_hdd_check_ula_done(pAdapter);
4914 if ( vos_status != VOS_STATUS_SUCCESS )
4915 {
4916 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4917 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
4918 __LINE__, vos_status );
4919
4920 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4921 }
4922
4923 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
4924
4925 if ( halStatus != eHAL_STATUS_SUCCESS )
4926 {
4927 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4928 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4929 __LINE__, halStatus );
4930
4931 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4932 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304933 EXIT();
4934 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004935}
4936
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304937static int iw_set_encodeext(struct net_device *dev,
4938 struct iw_request_info *info,
4939 union iwreq_data *wrqu, char *extra)
4940{
4941 int ret;
4942
4943 vos_ssr_protect(__func__);
4944 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4945 vos_ssr_unprotect(__func__);
4946
4947 return ret;
4948}
4949
4950static int __iw_set_retry(struct net_device *dev,
4951 struct iw_request_info *info,
4952 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004953{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304954 hdd_adapter_t *pAdapter;
4955 tHalHandle hHal;
4956 hdd_context_t *pHddCtx;
4957 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004958
4959 ENTER();
4960
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304961 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4962 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004963 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4965 "%s: Adapter is NULL",__func__);
4966 return -EINVAL;
4967 }
4968
4969 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4970 ret = wlan_hdd_validate_context(pHddCtx);
4971 if (0 != ret)
4972 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304973 return ret;
4974 }
4975
4976 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4977 if (NULL == hHal)
4978 {
4979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4980 "%s: Hal Context is NULL",__func__);
4981 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004982 }
4983
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4985 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4986
Arif Hussain6d2a3322013-11-17 19:50:10 -08004987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004988
4989 return -EINVAL;
4990 }
4991
4992 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
4993
4994 if((wrqu->retry.flags & IW_RETRY_LONG))
4995 {
4996 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
4997 {
c_hpothub8245442013-11-20 23:41:09 +05304998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4999 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 return -EIO;
5001 }
5002 }
5003 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5004 {
5005 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5006 {
c_hpothub8245442013-11-20 23:41:09 +05305007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5008 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 return -EIO;
5010 }
5011 }
5012 }
5013 else
5014 {
5015 return -EOPNOTSUPP;
5016 }
5017
Arif Hussain6d2a3322013-11-17 19:50:10 -08005018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005019
5020 EXIT();
5021
5022 return 0;
5023
5024}
5025
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305026static int iw_set_retry(struct net_device *dev,
5027 struct iw_request_info *info,
5028 union iwreq_data *wrqu, char *extra)
5029{
5030 int ret;
5031
5032 vos_ssr_protect(__func__);
5033 ret = __iw_set_retry(dev, info, wrqu, extra);
5034 vos_ssr_unprotect(__func__);
5035
5036 return ret;
5037}
5038
5039static int __iw_get_retry(struct net_device *dev,
5040 struct iw_request_info *info,
5041 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005042{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305043 hdd_adapter_t *pAdapter;
5044 hdd_context_t *pHddCtx;
5045 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005046 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305047 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005048
5049 ENTER();
5050
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305051 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5052 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005053 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5055 "%s: Adapter is NULL",__func__);
5056 return -EINVAL;
5057 }
5058
5059 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5060 ret = wlan_hdd_validate_context(pHddCtx);
5061 if (0 != ret)
5062 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305063 return ret;
5064 }
5065
5066 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5067 if (NULL == hHal)
5068 {
5069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5070 "%s: Hal Context is NULL",__func__);
5071 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005072 }
5073
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 if((wrqu->retry.flags & IW_RETRY_LONG))
5075 {
5076 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5077
5078 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5079 {
c_hpothub8245442013-11-20 23:41:09 +05305080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5081 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 return -EIO;
5083 }
5084
5085 wrqu->retry.value = retry;
5086 }
5087 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5088 {
5089 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5090
5091 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5092 {
c_hpothub8245442013-11-20 23:41:09 +05305093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5094 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 return -EIO;
5096 }
5097
5098 wrqu->retry.value = retry;
5099 }
5100 else {
5101 return -EOPNOTSUPP;
5102 }
5103
Arif Hussain6d2a3322013-11-17 19:50:10 -08005104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005105
5106 EXIT();
5107
5108 return 0;
5109}
5110
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305111static int iw_get_retry(struct net_device *dev,
5112 struct iw_request_info *info,
5113 union iwreq_data *wrqu, char *extra)
5114{
5115 int ret;
5116
5117 vos_ssr_protect(__func__);
5118 ret = __iw_get_retry(dev, info, wrqu, extra);
5119 vos_ssr_unprotect(__func__);
5120
5121 return ret;
5122}
5123
5124static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 struct iw_request_info *info,
5126 union iwreq_data *wrqu,
5127 char *extra)
5128{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305129 hdd_adapter_t *pAdapter;
5130 hdd_context_t *pHddCtx;
5131 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5133 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305134 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005135
5136 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305137 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5138 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005139 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5141 "%s:Adapter is NULL",__func__);
5142 return -EINVAL;
5143 }
5144 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5145 ret = wlan_hdd_validate_context(pHddCtx);
5146 if (0 != ret)
5147 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305148 return ret;
5149 }
5150 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5151 if (NULL == pHddStaCtx)
5152 {
5153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5154 "%s:STA context is NULL",__func__);
5155 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005156 }
5157
5158 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5159 switch (mlme->cmd) {
5160 case IW_MLME_DISASSOC:
5161 case IW_MLME_DEAUTH:
5162
5163 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5164 {
5165 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5166
5167 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5168 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5169
5170 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5171 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5172
Jeff Johnson43971f52012-07-17 12:26:56 -07005173 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305174 {
5175 long ret;
5176 ret = wait_for_completion_interruptible_timeout(
5177 &pAdapter->disconnect_comp_var,
5178 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5179 if (ret <= 0)
5180 hddLog(VOS_TRACE_LEVEL_ERROR,
5181 FL("failed wait on disconnect_comp_var %ld"), ret);
5182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005184 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005185 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005186
5187 /* Resetting authKeyMgmt */
5188 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5189
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305190 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 netif_tx_disable(dev);
5192 netif_carrier_off(dev);
5193
5194 }
5195 else
5196 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005197 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 -07005198 }
5199 break;
5200 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005201 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005202 return -EINVAL;
5203 }//end of switch
5204
5205 EXIT();
5206
5207 return status;
5208
5209}
5210
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305211static int iw_set_mlme(struct net_device *dev,
5212 struct iw_request_info *info,
5213 union iwreq_data *wrqu,
5214 char *extra)
5215{
5216 int ret;
5217
5218 vos_ssr_protect(__func__);
5219 ret = __iw_set_mlme(dev, info, wrqu, extra);
5220 vos_ssr_unprotect(__func__);
5221
5222 return ret;
5223}
5224
Jeff Johnson295189b2012-06-20 16:38:30 -07005225/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305226static int __iw_setint_getnone(struct net_device *dev,
5227 struct iw_request_info *info,
5228 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005229{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305230 hdd_adapter_t *pAdapter;
5231 tHalHandle hHal;
5232 hdd_wext_state_t *pWextState;
5233 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 int *value = (int *)extra;
5235 int sub_cmd = value[0];
5236 int set_value = value[1];
5237 int ret = 0; /* success */
5238 int enable_pbm, enable_mp;
5239#ifdef CONFIG_HAS_EARLYSUSPEND
5240 v_U8_t nEnableSuspendOld;
5241#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005242
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305243 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305244 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5245 if (NULL == pAdapter)
5246 {
5247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5248 "%s: Adapter is NULL",__func__);
5249 return -EINVAL;
5250 }
5251 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5252 ret = wlan_hdd_validate_context(pHddCtx);
5253 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005254 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305255 return ret;
5256 }
5257 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5258 if (NULL == hHal)
5259 {
5260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5261 "%s: Hal Context is NULL",__func__);
5262 return -EINVAL;
5263 }
5264 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5265 if (NULL == pWextState)
5266 {
5267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5268 "%s: pWextState is NULL",__func__);
5269 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005270 }
5271
c_hpothu4a298be2014-12-22 21:12:51 +05305272 INIT_COMPLETION(pWextState->completion_var);
5273
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 switch(sub_cmd)
5275 {
5276 case WE_SET_11D_STATE:
5277 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005278 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005279 memset(&smeConfig, 0x00, sizeof(smeConfig));
5280
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5282
5283 sme_GetConfigParam(hHal,&smeConfig);
5284 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5285
Arif Hussain6d2a3322013-11-17 19:50:10 -08005286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005287
5288 sme_UpdateConfig(hHal,&smeConfig);
5289 }
5290 else {
5291 return -EINVAL;
5292 }
5293 break;
5294 }
5295
5296 case WE_WOWL:
5297 {
5298 switch (set_value)
5299 {
5300 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305301 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 break;
5303 case 0x01:
5304 case 0x02:
5305 case 0x03:
5306 enable_mp = (set_value & 0x01) ? 1 : 0;
5307 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005308 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005309 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5310 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5311 break;
5312 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005313 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 ret = -EINVAL;
5315 break;
5316 }
5317
5318 break;
5319 }
5320 case WE_SET_POWER:
5321 {
5322 switch (set_value)
5323 {
5324 case 0: //Full Power
5325 {
5326 struct statsContext context;
5327 eHalStatus status;
5328
5329 init_completion(&context.completion);
5330
5331 context.pAdapter = pAdapter;
5332 context.magic = POWER_CONTEXT_MAGIC;
5333
5334 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5335 iw_power_callback_fn, &context,
5336 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005337 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 {
5339 int lrc = wait_for_completion_interruptible_timeout(
5340 &context.completion,
5341 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005342
Jeff Johnson295189b2012-06-20 16:38:30 -07005343 if (lrc <= 0)
5344 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005345 hddLog(VOS_TRACE_LEVEL_ERROR,
5346 "%s: SME %s while requesting fullpower",
5347 __func__, (0 == lrc) ?
5348 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 }
5350 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005351 /* either we have a response or we timed out. if we timed
5352 out there is a race condition such that the callback
5353 function could be executing at the same time we are. of
5354 primary concern is if the callback function had already
5355 verified the "magic" but had not yet set the completion
5356 variable when a timeout occurred. we serialize these
5357 activities by invalidating the magic while holding a
5358 shared spinlock which will cause us to block if the
5359 callback is currently executing */
5360 spin_lock(&hdd_context_lock);
5361 context.magic = 0;
5362 spin_unlock(&hdd_context_lock);
5363
Arif Hussain6d2a3322013-11-17 19:50:10 -08005364 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 break;
5366 }
5367 case 1: //Enable BMPS
5368 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5369 break;
5370 case 2: //Disable BMPS
5371 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5372 break;
5373 case 3: //Request Bmps
5374 {
5375 struct statsContext context;
5376 eHalStatus status;
5377
5378 init_completion(&context.completion);
5379
5380 context.pAdapter = pAdapter;
5381 context.magic = POWER_CONTEXT_MAGIC;
5382
5383 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5384 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005385 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 {
5387 int lrc = wait_for_completion_interruptible_timeout(
5388 &context.completion,
5389 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 if (lrc <= 0)
5391 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005392 hddLog(VOS_TRACE_LEVEL_ERROR,
5393 "%s: SME %s while requesting BMPS",
5394 __func__, (0 == lrc) ? "timeout" :
5395 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005396 }
5397 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005398 /* either we have a response or we timed out. if we
5399 timed out there is a race condition such that the
5400 callback function could be executing at the same
5401 time we are. of primary concern is if the callback
5402 function had already verified the "magic" but had
5403 not yet set the completion variable when a timeout
5404 occurred. we serialize these activities by
5405 invalidating the magic while holding a shared
5406 spinlock which will cause us to block if the
5407 callback is currently executing */
5408 spin_lock(&hdd_context_lock);
5409 context.magic = 0;
5410 spin_unlock(&hdd_context_lock);
5411
Arif Hussain6d2a3322013-11-17 19:50:10 -08005412 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005413 break;
5414 }
5415 case 4: //Enable IMPS
5416 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5417 break;
5418 case 5: //Disable IMPS
5419 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5420 break;
5421 case 6: //Enable Standby
5422 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5423 break;
5424 case 7: //Disable Standby
5425 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5426 break;
5427 case 8: //Request Standby
5428#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005429#endif
5430 break;
5431 case 9: //Start Auto Bmps Timer
5432 sme_StartAutoBmpsTimer(hHal);
5433 break;
5434 case 10://Stop Auto BMPS Timer
5435 sme_StopAutoBmpsTimer(hHal);
5436 break;
5437#ifdef CONFIG_HAS_EARLYSUSPEND
5438 case 11://suspend to standby
5439#ifdef CONFIG_HAS_EARLYSUSPEND
5440 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5441 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5443#endif
5444 break;
5445 case 12://suspend to deep sleep
5446#ifdef CONFIG_HAS_EARLYSUSPEND
5447 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5448 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5450#endif
5451 break;
5452 case 13://resume from suspend
5453#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005454#endif
5455 break;
5456#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005458 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 ret = -EINVAL;
5460 break;
5461 }
5462 break;
5463 }
5464
5465 case WE_SET_MAX_ASSOC:
5466 {
5467 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5468 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5469 {
5470 ret = -EINVAL;
5471 }
5472 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5473 set_value, NULL, eANI_BOOLEAN_FALSE)
5474 != eHAL_STATUS_SUCCESS )
5475 {
c_hpothub8245442013-11-20 23:41:09 +05305476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5477 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 ret = -EIO;
5479 }
5480 break;
5481 }
5482
5483 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5484 {
5485 if( 0 == set_value )
5486 {
5487 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5488 }
5489 else if ( 1 == set_value )
5490 {
5491 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5492 }
5493 else
5494 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005495 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 ret = -EINVAL;
5497 }
5498 break;
5499 }
5500
5501 case WE_SET_DATA_INACTIVITY_TO:
5502 {
5503 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5504 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5505 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5506 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5507 set_value,
5508 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5509 {
5510 hddLog(LOGE,"Failure: Could not pass on "
5511 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005512 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 ret = -EINVAL;
5514 }
5515 break;
5516 }
5517 case WE_SET_MAX_TX_POWER:
5518 {
5519 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5520 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5521
5522 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5523 __func__, set_value);
5524 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5525 eHAL_STATUS_SUCCESS )
5526 {
5527 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5528 __func__);
5529 return -EIO;
5530 }
5531
5532 break;
5533 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005534 case WE_SET_MAX_TX_POWER_2_4:
5535 {
5536 hddLog(VOS_TRACE_LEVEL_INFO,
5537 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5538 __func__, set_value);
5539 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5540 eHAL_STATUS_SUCCESS)
5541 {
5542 hddLog(VOS_TRACE_LEVEL_ERROR,
5543 "%s: Setting maximum tx power failed for 2.4 GHz band",
5544 __func__);
5545 return -EIO;
5546 }
5547
5548 break;
5549 }
5550 case WE_SET_MAX_TX_POWER_5_0:
5551 {
5552 hddLog(VOS_TRACE_LEVEL_INFO,
5553 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5554 __func__, set_value);
5555 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5556 eHAL_STATUS_SUCCESS)
5557 {
5558 hddLog(VOS_TRACE_LEVEL_ERROR,
5559 "%s: Setting maximum tx power failed for 5.0 GHz band",
5560 __func__);
5561 return -EIO;
5562 }
5563
5564 break;
5565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 case WE_SET_HIGHER_DTIM_TRANSITION:
5567 {
5568 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5569 (set_value == eANI_BOOLEAN_TRUE)))
5570 {
5571 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5572 ret = -EINVAL;
5573 }
5574 else
5575 {
5576 if(pAdapter->higherDtimTransition != set_value)
5577 {
5578 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005579 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 }
5581 }
5582
5583 break;
5584 }
5585
5586 case WE_SET_TM_LEVEL:
5587 {
5588 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005589 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5591
5592 break;
5593 }
5594
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305595 case WE_ENABLE_STRICT_FCC_REG:
5596 {
5597 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5598 struct wiphy *wiphy = NULL;
5599 long lrc;
5600 int status;
5601
5602 wiphy = hddCtxt->wiphy;
5603 if(wiphy == NULL)
5604 {
5605 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5606 break;
5607 }
5608 init_completion(&hddCtxt->wiphy_channel_update_event);
5609
5610 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5611
5612 status = regulatory_hint(wiphy, "00");
5613 if(status < 0)
5614 {
5615 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5616 break;
5617 }
5618
5619 /* Wait for completion */
5620 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5621 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5622 if (lrc <= 0)
5623 {
5624 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5625 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5626 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5627 }
5628 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5629
5630 break;
5631 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005632 case WE_SET_DEBUG_LOG:
5633 {
5634 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5635 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5636 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5637 break;
5638 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305639#ifdef FEATURE_WLAN_TDLS
5640 case WE_SET_TDLS_OFF_CHAN:
5641 {
5642 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5644 __func__, set_value);
5645 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5646 break;
5647 }
5648 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5649 {
5650 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5652 __func__, set_value);
5653 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5654 break;
5655 }
5656 case WE_SET_TDLS_OFF_CHAN_MODE:
5657 {
5658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5659 __func__, set_value);
5660 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5661 break;
5662 }
5663#endif
Peng Xu2446a892014-09-05 17:21:18 +05305664 case WE_SET_SCAN_BAND_PREFERENCE:
5665 {
5666 tSmeConfigParams smeConfig;
5667 memset(&smeConfig, 0x00, sizeof(smeConfig));
5668 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5669 ret = -EINVAL;
5670 break;
5671 }
5672 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5673
5674 if (eCSR_BAND_ALL == set_value ||
5675 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5676 sme_GetConfigParam(hHal, &smeConfig);
5677 smeConfig.csrConfig.scanBandPreference = set_value;
5678
5679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5680 "set band scan preference = %d\n",
5681 smeConfig.csrConfig.scanBandPreference);
5682
5683 sme_UpdateConfig(hHal, &smeConfig);
5684 }
5685 else {
5686 ret = -EINVAL;
5687 }
5688 break;
5689 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305690 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5691 * connection happens so that the params can take effect during
5692 * association. Also this should not be used in STA+p2p concurrency
5693 * as the param will also effect the STA mode.
5694 */
5695 case WE_SET_MIRACAST_VENDOR_CONFIG:
5696 {
5697 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305698
Abhishek Singh01c73d12015-03-12 15:13:44 +05305699 hddLog(LOG1, FL(
5700 "Set Miracast vendor tuning %d"), set_value);
5701
5702 if (1 == set_value || 0 == set_value)
5703 {
5704 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5705 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5706 {
5707 hddLog( LOGE, FL("set vendor miracast config failed"));
5708 ret = -EIO;
5709 }
5710 }
5711 else
5712 {
5713 hddLog(LOGE,
5714 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5715 ret = -EINVAL;
5716 }
5717
5718 break;
5719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 default:
5721 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005722 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 sub_cmd, set_value);
5724 break;
5725 }
5726 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305727 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 return ret;
5729}
5730
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305731static int iw_setint_getnone(struct net_device *dev,
5732 struct iw_request_info *info,
5733 union iwreq_data *wrqu, char *extra)
5734{
5735 int ret;
5736
5737 vos_ssr_protect(__func__);
5738 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5739 vos_ssr_unprotect(__func__);
5740
5741 return 0;
5742}
Jeff Johnson295189b2012-06-20 16:38:30 -07005743/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305744static int __iw_setchar_getnone(struct net_device *dev,
5745 struct iw_request_info *info,
5746 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005747{
5748 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305749 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005751 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305752 hdd_adapter_t *pAdapter;
5753 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005754#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305755 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005756#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305757 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305758 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005759
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305760 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305761 pAdapter = (netdev_priv(dev));
5762 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005763 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5765 "%s: Adapter is NULL",__func__);
5766 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005767 }
5768
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305769 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5770 ret = wlan_hdd_validate_context(pHddCtx);
5771 if (0 != ret)
5772 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305773 return ret;
5774 }
5775#ifdef WLAN_FEATURE_VOWIFI
5776 pConfig = pHddCtx->cfg_ini;
5777#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305778 /* helper function to get iwreq_data with compat handling. */
5779 if (hdd_priv_get_data(&s_priv_data, wrqu))
5780 {
5781 return -EINVAL;
5782 }
5783
5784 /* make sure all params are correctly passed to function */
5785 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5786 {
5787 return -EINVAL;
5788 }
5789
5790 sub_cmd = s_priv_data.flags;
5791
Arif Hussain0273cba2014-01-07 20:58:29 -08005792 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305793 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5794 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005795 if (NULL == pBuffer)
5796 {
5797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5798 "mem_alloc_copy_from_user_helper fail");
5799 return -ENOMEM;
5800 }
5801
5802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305803 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5805 "%s: Received data %s", __func__, pBuffer);
5806
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 switch(sub_cmd)
5808 {
5809 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005811 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 break;
5813 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005815 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 break;
5817#if defined WLAN_FEATURE_VOWIFI
5818 case WE_NEIGHBOR_REPORT_REQUEST:
5819 {
5820 tRrmNeighborReq neighborReq;
5821 tRrmNeighborRspCallbackInfo callbackInfo;
5822
5823 if (pConfig->fRrmEnable)
5824 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305826 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 if( !neighborReq.no_ssid )
5828 {
Girish Gowli552fc072014-06-14 18:26:16 +05305829 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005830 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005831 }
5832
5833 callbackInfo.neighborRspCallback = NULL;
5834 callbackInfo.neighborRspCallbackContext = NULL;
5835 callbackInfo.timeout = 5000; //5 seconds
5836 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5837 }
5838 else
5839 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005840 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 ret = -EINVAL;
5842 }
5843 }
5844 break;
5845#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 case WE_SET_AP_WPS_IE:
5847 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05305848 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08005851 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 if (VOS_STATUS_SUCCESS != vstatus)
5853 {
5854 ret = -EINVAL;
5855 }
5856 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305857 case WE_SET_ENCRYPT_MSG:
5858 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
5859 if (NULL == pkt)
5860 {
5861 hddLog(VOS_TRACE_LEVEL_ERROR,
5862 "%s: vos_mem_alloc failed", __func__);
5863 return -ENOMEM;
5864 }
5865
5866 memset(pkt, 0, sizeof(tSirpkt80211));
5867
5868 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
5869 hddLog(VOS_TRACE_LEVEL_ERROR,
5870 FL("Firmware is not DISA capable"));
5871 ret = -EINVAL;
5872 vos_mem_free(pkt);
5873 break;
5874 }
5875
5876 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
5877
5878 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
5879 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
5880 if (eHAL_STATUS_SUCCESS != ret) {
5881 hddLog(VOS_TRACE_LEVEL_ERROR,
5882 FL("SENDEncryptMSG: fail to post WDA cmd"));
5883 ret = -EINVAL;
5884 }
5885 vos_mem_free(pkt);
5886
5887 break;
5888
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 default:
5890 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005891 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 ret = -EINVAL;
5893 break;
5894 }
5895 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005896 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305897
5898 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 return ret;
5900}
5901
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305902static int iw_setchar_getnone(struct net_device *dev,
5903 struct iw_request_info *info,
5904 union iwreq_data *wrqu, char *extra)
5905{
5906 int ret;
5907
5908 vos_ssr_protect(__func__);
5909 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
5910 vos_ssr_unprotect(__func__);
5911
5912 return ret;
5913}
5914
Jeff Johnson295189b2012-06-20 16:38:30 -07005915/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305916static int __iw_setnone_getint(struct net_device *dev,
5917 struct iw_request_info *info,
5918 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005919{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305920 hdd_adapter_t *pAdapter;
5921 tHalHandle hHal;
5922 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 int *value = (int *)extra;
5924 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05305925 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005926
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305927 ENTER();
5928
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305929 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5930 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005931 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5933 "%s: Adapter is NULL",__func__);
5934 return -EINVAL;
5935 }
5936 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5937 ret = wlan_hdd_validate_context(pHddCtx);
5938 if (0 != ret)
5939 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305940 return ret;
5941 }
5942 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5943 if (NULL == hHal)
5944 {
5945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5946 "%s: Hal Context is NULL",__func__);
5947 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005949
5950 switch (value[0])
5951 {
5952 case WE_GET_11D_STATE:
5953 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005954 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305956
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 *value = smeConfig.csrConfig.Is11dSupportEnabled;
5958
Arif Hussain6d2a3322013-11-17 19:50:10 -08005959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005960
5961 break;
5962 }
5963
5964 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 break;
5967
5968 case WE_PMC_STATE:
5969 {
5970 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 break;
5973 }
5974 case WE_GET_WLAN_DBG:
5975 {
5976 vos_trace_display();
5977 *value = 0;
5978 break;
5979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 case WE_GET_MAX_ASSOC:
5981 {
5982 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
5983 {
c_hpothub8245442013-11-20 23:41:09 +05305984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5985 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 ret = -EIO;
5987 }
Girish Gowli385be612014-09-18 11:17:20 +05305988#ifdef WLAN_SOFTAP_VSTA_FEATURE
5989 if (pHddCtx->cfg_ini->fEnableVSTASupport)
5990 {
5991 if (*value > VSTA_NUM_ASSOC_STA)
5992 {
5993 *value = VSTA_NUM_ASSOC_STA;
5994 }
5995 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
5996 (*value > (VSTA_NUM_ASSOC_STA -
5997 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
5998 {
5999 *value = (VSTA_NUM_ASSOC_STA -
6000 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6001 }
6002 }
6003 else
6004#endif
6005 {
6006 if (*value > NUM_ASSOC_STA)
6007 {
6008 *value = NUM_ASSOC_STA;
6009 }
6010 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6011 (*value > (NUM_ASSOC_STA -
6012 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6013 {
6014 *value = (NUM_ASSOC_STA -
6015 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6016 }
6017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 break;
6019 }
6020
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 case WE_GET_WDI_DBG:
6022 {
6023 wpalTraceDisplay();
6024 *value = 0;
6025 break;
6026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006027
6028 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6029 {
6030 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6031 break;
6032 }
6033 case WE_GET_CONCURRENCY_MODE:
6034 {
6035 *value = hdd_get_concurrency_mode ( );
6036
Arif Hussain6d2a3322013-11-17 19:50:10 -08006037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 break;
6039 }
6040
Peng Xu2446a892014-09-05 17:21:18 +05306041 case WE_GET_SCAN_BAND_PREFERENCE:
6042 {
6043 sme_GetConfigParam(hHal, &smeConfig);
6044 *value = smeConfig.csrConfig.scanBandPreference;
6045
6046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6047 "scanBandPreference = %d\n", *value);
6048 break;
6049 }
6050
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 default:
6052 {
6053 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6054 break;
6055 }
6056 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306057 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 return ret;
6059}
6060
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306061static int iw_setnone_getint(struct net_device *dev,
6062 struct iw_request_info *info,
6063 union iwreq_data *wrqu, char *extra)
6064{
6065 int ret;
6066
6067 vos_ssr_protect(__func__);
6068 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6069 vos_ssr_unprotect(__func__);
6070
6071 return ret;
6072
6073}
Jeff Johnson295189b2012-06-20 16:38:30 -07006074/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306075int __iw_set_three_ints_getnone(struct net_device *dev,
6076 struct iw_request_info *info,
6077 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006078{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306079 hdd_adapter_t *pAdapter;
6080 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006081 int *value = (int *)extra;
6082 int sub_cmd = value[0];
6083 int ret = 0;
6084
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306085 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306086 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6087 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006088 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6090 "%s: Adapter is NULL",__func__);
6091 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006092 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306093 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6094 ret = wlan_hdd_validate_context(pHddCtx);
6095 if (0 != ret)
6096 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306097 return ret;
6098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 switch(sub_cmd)
6100 {
6101 case WE_SET_WLAN_DBG:
6102 {
6103 vos_trace_setValue( value[1], value[2], value[3]);
6104 break;
6105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 case WE_SET_WDI_DBG:
6107 {
6108 wpalTraceSetLevel( value[1], value[2], value[3]);
6109 break;
6110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 case WE_SET_SAP_CHANNELS:
6112 {
6113 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6114 break;
6115 }
6116
6117 default:
6118 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006119 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 break;
6121 }
6122 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306123 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 return ret;
6125}
6126
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306127int iw_set_three_ints_getnone(struct net_device *dev,
6128 struct iw_request_info *info,
6129 union iwreq_data *wrqu, char *extra)
6130{
6131 int ret;
6132
6133 vos_ssr_protect(__func__);
6134 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6135 vos_ssr_unprotect(__func__);
6136
6137 return ret;
6138}
6139
6140static int __iw_get_char_setnone(struct net_device *dev,
6141 struct iw_request_info *info,
6142 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006143{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306144 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306146 hdd_context_t *pHddCtx;
6147 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006148#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006149 hdd_wext_state_t *pWextState;
6150#endif
6151
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306152 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306153 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006154 if (pAdapter == NULL)
6155 {
6156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6157 "%s: pAdapter is NULL!", __func__);
6158 return -EINVAL;
6159 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306160 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6161 ret = wlan_hdd_validate_context(pHddCtx);
6162 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006163 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306164 return ret;
6165 }
6166#ifdef WLAN_FEATURE_11W
6167 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6168 if (NULL == pWextState)
6169 {
6170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6171 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006172 return -EINVAL;
6173 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306174#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006175
Jeff Johnson295189b2012-06-20 16:38:30 -07006176 switch(sub_cmd)
6177 {
6178 case WE_WLAN_VERSION:
6179 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006180 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 break;
6182 }
6183
6184 case WE_GET_STATS:
6185 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306186 tHalHandle hHal = NULL;
6187 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6189 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6190 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6191
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306192
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 snprintf(extra, WE_MAX_STR_LEN,
6194 "\nTransmit"
6195 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6196 "\n dropped BK %u, BE %u, VI %u, VO %u"
6197 "\n classified BK %u, BE %u, VI %u, VO %u"
6198 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6199 "\n queued BK %u, BE %u, VI %u, VO %u"
6200 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006201 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 "\n fetched BK %u, BE %u, VI %u, VO %u"
6203 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6204 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006205 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 "\n flushed BK %u, BE %u, VI %u, VO %u"
6207 "\n\nReceive"
6208 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6209 "\n\nResetsStats"
6210 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6211 "\n",
6212 pStats->txXmitCalled,
6213 pStats->txXmitDropped,
6214 pStats->txXmitBackPressured,
6215 pStats->txXmitQueued,
6216
6217 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6218 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6219 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6220 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6221
6222 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6223 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6224 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6225 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6226
6227 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6228 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6229 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6230 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6231
6232 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6233 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6234 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6235 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6236
6237 pStats->txFetched,
6238 pStats->txFetchEmpty,
6239 pStats->txFetchLowResources,
6240 pStats->txFetchDequeueError,
6241
6242 pStats->txFetchDequeued,
6243 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006244 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 pStats->txCompleted,
6246 pStats->txFlushed,
6247
6248 pStats->txFetchedAC[WLANTL_AC_BK],
6249 pStats->txFetchedAC[WLANTL_AC_BE],
6250 pStats->txFetchedAC[WLANTL_AC_VI],
6251 pStats->txFetchedAC[WLANTL_AC_VO],
6252
6253 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6254 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6255 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6256 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6257
6258 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6259 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6260 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6261 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6262
Ravi Joshi41914632013-10-21 23:02:21 -07006263 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6264 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6265 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6266 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6267
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 pStats->txFlushedAC[WLANTL_AC_BK],
6269 pStats->txFlushedAC[WLANTL_AC_BE],
6270 pStats->txFlushedAC[WLANTL_AC_VI],
6271 pStats->txFlushedAC[WLANTL_AC_VO],
6272
6273 pStats->rxChains,
6274 pStats->rxPackets,
6275 pStats->rxDropped,
6276 pStats->rxDelivered,
6277 pStats->rxRefused,
6278
6279 pResetStats->totalLogpResets,
6280 pResetStats->totalCMD53Failures,
6281 pResetStats->totalMutexReadFailures,
6282 pResetStats->totalMIFErrorFailures,
6283 pResetStats->totalFWHearbeatFailures,
6284 pResetStats->totalUnknownExceptions
6285 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306286 wrqu->data.length = strlen(extra);
6287
6288 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6289
6290 if (hHal)
6291 pMac = PMAC_STRUCT( hHal );
6292
6293 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6294 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6295 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306296 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6297 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6298 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6299 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306300 "\n",
6301 pMac->pmm.BmpscntSleep,
6302 pMac->pmm.BmpscntAwake,
6303 pMac->pmm.BmpsSleeReqFailCnt,
6304 pMac->pmm.BmpsWakeupReqFailCnt,
6305 pMac->pmm.ImpsCntSleep,
6306 pMac->pmm.ImpsCntAwake,
6307 pMac->pmm.ImpsSleepErrCnt,
6308 pMac->pmm.ImpsWakeupErrCnt,
6309 pMac->pmm.ImpsLastErr
6310 );
6311 }
6312
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 wrqu->data.length = strlen(extra)+1;
6314 break;
6315 }
6316
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306317/* The case prints the current state of the HDD, SME, CSR, PE, TL
6318 *it can be extended for WDI Global State as well.
6319 *And currently it only checks P2P_CLIENT adapter.
6320 *P2P_DEVICE and P2P_GO have not been added as of now.
6321*/
6322 case WE_GET_STATES:
6323 {
6324 int buf = 0, len = 0;
6325 int adapter_num = 0;
6326 int count = 0, check = 1;
6327
6328 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006329 tHalHandle hHal = NULL;
6330 tpAniSirGlobal pMac = NULL;
6331 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306332
6333 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6334 hdd_adapter_t *useAdapter = NULL;
6335
6336 /* Print wlan0 or p2p0 states based on the adapter_num
6337 *by using the correct adapter
6338 */
6339 while ( adapter_num < 2 )
6340 {
6341 if ( WLAN_ADAPTER == adapter_num )
6342 {
6343 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006344 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306345 "\n\n wlan0 States:-");
6346 len += buf;
6347 }
6348 else if ( P2P_ADAPTER == adapter_num )
6349 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006350 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306351 "\n\n p2p0 States:-");
6352 len += buf;
6353
6354 if( !pHddCtx )
6355 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006356 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306357 "\n pHddCtx is NULL");
6358 len += buf;
6359 break;
6360 }
6361
6362 /*Printing p2p0 states only in the case when the device is
6363 configured as a p2p_client*/
6364 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6365 if ( !useAdapter )
6366 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006367 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306368 "\n Device not configured as P2P_CLIENT.");
6369 len += buf;
6370 break;
6371 }
6372 }
6373
6374 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006375 if (!hHal) {
6376 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6377 "\n pMac is NULL");
6378 len += buf;
6379 break;
6380 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306381 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006382 if (!pMac) {
6383 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6384 "\n pMac is NULL");
6385 len += buf;
6386 break;
6387 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306388 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6389 if( !pHddStaCtx )
6390 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006391 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306392 "\n pHddStaCtx is NULL");
6393 len += buf;
6394 break;
6395 }
6396
6397 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6398
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006399 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306400 "\n HDD Conn State - %s "
6401 "\n \n SME State:"
6402 "\n Neighbour Roam State - %s"
6403 "\n CSR State - %s"
6404 "\n CSR Substate - %s"
6405 "\n \n TL STA %d State: %s",
6406 macTraceGetHDDWlanConnState(
6407 pHddStaCtx->conn_info.connState),
6408 macTraceGetNeighbourRoamState(
6409 pMac->roam.neighborRoamInfo.neighborRoamState),
6410 macTraceGetcsrRoamState(
6411 pMac->roam.curState[useAdapter->sessionId]),
6412 macTraceGetcsrRoamSubState(
6413 pMac->roam.curSubState[useAdapter->sessionId]),
6414 pHddStaCtx->conn_info.staId[0],
6415 macTraceGetTLState(tlState)
6416 );
6417 len += buf;
6418 adapter_num++;
6419 }
6420
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006421 if (pMac) {
6422 /* Printing Lim State starting with global lim states */
6423 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6424 "\n \n LIM STATES:-"
6425 "\n Global Sme State - %s "\
6426 "\n Global mlm State - %s "\
6427 "\n",
6428 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6429 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6430 );
6431 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306432
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006433 /*printing the PE Sme and Mlm states for valid lim sessions*/
6434 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306435 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006436 if ( pMac->lim.gpSession[count].valid )
6437 {
6438 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6439 "\n Lim Valid Session %d:-"
6440 "\n PE Sme State - %s "
6441 "\n PE Mlm State - %s "
6442 "\n",
6443 check,
6444 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6445 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6446 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306447
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006448 len += buf;
6449 check++;
6450 }
6451 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306452 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306453 }
6454
6455 wrqu->data.length = strlen(extra)+1;
6456 break;
6457 }
6458
Jeff Johnson295189b2012-06-20 16:38:30 -07006459 case WE_GET_CFG:
6460 {
6461 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6462 wrqu->data.length = strlen(extra)+1;
6463 break;
6464 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006465#ifdef WLAN_FEATURE_11AC
6466 case WE_GET_RSSI:
6467 {
6468 v_S7_t s7Rssi = 0;
6469 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6470 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6471 wrqu->data.length = strlen(extra)+1;
6472 break;
6473 }
6474#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306475
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006476#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006477 case WE_GET_ROAM_RSSI:
6478 {
6479 v_S7_t s7Rssi = 0;
6480 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6481 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6482 wrqu->data.length = strlen(extra)+1;
6483 break;
6484 }
6485#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 case WE_GET_WMM_STATUS:
6487 {
6488 snprintf(extra, WE_MAX_STR_LEN,
6489 "\nDir: 0=up, 1=down, 3=both\n"
6490 "|------------------------|\n"
6491 "|AC | ACM |Admitted| Dir |\n"
6492 "|------------------------|\n"
6493 "|VO | %d | %3s | %d |\n"
6494 "|VI | %d | %3s | %d |\n"
6495 "|BE | %d | %3s | %d |\n"
6496 "|BK | %d | %3s | %d |\n"
6497 "|------------------------|\n",
6498 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6499 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6500 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6501 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6502 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6503 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6504 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6505 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6506 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6507 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6508 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6509 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6510
Jeff Johnsone7245742012-09-05 17:12:55 -07006511
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 wrqu->data.length = strlen(extra)+1;
6513 break;
6514 }
6515 case WE_GET_CHANNEL_LIST:
6516 {
6517 VOS_STATUS status;
6518 v_U8_t i, len;
6519 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306520 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6521 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6522 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 tChannelListInfo channel_list;
6524
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006525 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006527 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006529 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006530 return -EINVAL;
6531 }
6532 buf = extra;
6533
6534 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006535 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6536 * needed = 5 * number of channels. Check ifsufficient
6537 * buffer is available and then proceed to fill the buffer.
6538 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6540 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006541 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006542 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006543 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 return -EINVAL;
6545 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006546 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6547 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306548 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6549 {
6550 //Printing Country code in getChannelList
6551 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6552 {
6553 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6554 "%c ", pBuf[i]);
6555 }
6556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 for(i = 0 ; i < channel_list.num_channels; i++)
6558 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006559 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 }
6562 wrqu->data.length = strlen(extra)+1;
6563
6564 break;
6565 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006566#ifdef FEATURE_WLAN_TDLS
6567 case WE_GET_TDLS_PEERS:
6568 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006569 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006570 break;
6571 }
6572#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006573#ifdef WLAN_FEATURE_11W
6574 case WE_GET_11W_INFO:
6575 {
6576 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6577
6578 snprintf(extra, WE_MAX_STR_LEN,
6579 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6580 "\n Number of Unprotected Disassocs %d"
6581 "\n Number of Unprotected Deauths %d",
6582 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6583 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6584 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6585 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6586 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6587
6588 wrqu->data.length = strlen(extra)+1;
6589 break;
6590 }
6591#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306592 case WE_GET_SNR:
6593 {
6594 v_S7_t s7snr = 0;
6595 int status = 0;
6596 hdd_context_t *pHddCtx;
6597 hdd_station_ctx_t *pHddStaCtx;
6598
6599 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6600 status = wlan_hdd_validate_context(pHddCtx);
6601 if (0 != status)
6602 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306603 return status;
6604 }
6605
6606 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6607
6608 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6609 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6610 {
6611 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6612 " ConnectionState-%d", __func__,
6613 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6614 pHddStaCtx->conn_info.connState);
6615 return -ENONET;
6616 }
6617
6618 /*update the stats in TL*/
6619 wlan_hdd_get_station_stats(pAdapter);
6620 wlan_hdd_get_snr(pAdapter, &s7snr);
6621 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6622 wrqu->data.length = strlen(extra) + 1;
6623 break;
6624 }
6625
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306626 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006628 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 break;
6630 }
6631 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306632 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 return 0;
6634}
6635
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306636static int iw_get_char_setnone(struct net_device *dev,
6637 struct iw_request_info *info,
6638 union iwreq_data *wrqu, char *extra)
6639{
6640 int ret;
6641
6642 vos_ssr_protect(__func__);
6643 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6644 vos_ssr_unprotect(__func__);
6645
6646 return ret;
6647}
6648
Jeff Johnson295189b2012-06-20 16:38:30 -07006649/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306650static int __iw_setnone_getnone(struct net_device *dev,
6651 struct iw_request_info *info,
6652 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006653{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306654 hdd_adapter_t *pAdapter;
6655 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306656 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006657 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306658 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006659
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306660 ENTER();
6661
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306662 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6663 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006664 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6666 "%s: Adapter is NULL",__func__);
6667 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006668 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306669 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6670 ret = wlan_hdd_validate_context(pHddCtx);
6671 if (0 != ret)
6672 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306673 return ret;
6674 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306675 /* helper function to get iwreq_data with compat handling. */
6676 if (hdd_priv_get_data(&s_priv_data, wrqu))
6677 {
6678 return -EINVAL;
6679 }
6680
6681 sub_cmd = s_priv_data.flags;
6682
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 switch (sub_cmd)
6684 {
6685 case WE_CLEAR_STATS:
6686 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6689 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6690 break;
6691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 case WE_INIT_AP:
6693 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306694 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6695
6696 /* As Soft AP mode might been changed to STA already with
6697 * killing of Hostapd, need to find the adpater by name
6698 * rather than mode */
6699 hdd_adapter_t* pAdapter_to_stop =
6700 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6701 if( pAdapter_to_stop )
6702 {
6703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6704 "Adapter with name softap.0 already "
6705 "exist, ignoring the request.\nRemove the "
6706 "adapter and try again\n");
6707 break;
6708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 pr_info("Init AP trigger\n");
6710 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6711 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6712 break;
6713 }
6714 case WE_STOP_AP:
6715 {
6716 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6717 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6718 * this is a dead code and need to find the adpater by name rather than mode */
6719 hdd_adapter_t* pAdapter_to_stop =
6720 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6721 if( pAdapter_to_stop )
6722 {
6723 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6724
6725 pr_info("Stopping AP mode\n");
6726
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306727 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6728 {
6729 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6730 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6731 }
6732
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306734 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306735 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6737
6738 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6739 pAdapter_to_stop->macAddressCurrent.bytes);
6740 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6741 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306742
6743 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6744 {
6745 /* put the device back into BMPS */
6746 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 }
6749 else
6750 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006751 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006752 }
6753
6754 break;
6755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006756#ifdef WLAN_BTAMP_FEATURE
6757 case WE_ENABLE_AMP:
6758 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006760 WLANBAP_RegisterWithHCI(pAdapter);
6761 break;
6762 }
6763 case WE_DISABLE_AMP:
6764 {
6765 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6766 VOS_STATUS status;
6767
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006769
6770 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6771 status = WLANBAP_StopAmp();
6772 if(VOS_STATUS_SUCCESS != status )
6773 {
6774 pHddCtx->isAmpAllowed = VOS_TRUE;
6775 hddLog(VOS_TRACE_LEVEL_FATAL,
6776 "%s: Failed to stop AMP", __func__);
6777 }
6778 else
6779 {
6780 //a state m/c implementation in PAL is TBD to avoid this delay
6781 msleep(500);
6782 pHddCtx->isAmpAllowed = VOS_FALSE;
6783 WLANBAP_DeregisterFromHCI();
6784 }
6785
6786 break;
6787 }
6788#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006789 case WE_ENABLE_DXE_STALL_DETECT:
6790 {
schang6295e542013-03-12 15:31:23 -07006791 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6792 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006793 break;
6794 }
6795 case WE_DISPLAY_DXE_SNAP_SHOT:
6796 {
schang6295e542013-03-12 15:31:23 -07006797 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6798 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006799 break;
6800 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306801 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6802 {
6803 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6804 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306805 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306806 break;
6807 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306808
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306809 case WE_SET_REASSOC_TRIGGER:
6810 {
6811 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6812 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6813 v_U32_t roamId = 0;
6814 tCsrRoamModifyProfileFields modProfileFields;
6815 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6816 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6817 return 0;
6818 }
6819
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306820 case WE_STOP_OBSS_SCAN:
6821 {
6822 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6823 2.OBSS scan is stopped by Firmware during the disassociation
6824 3.OBSS stop comamnd is added for debugging purpose*/
6825 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6826 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006827
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306828 if (pAdapter == NULL)
6829 {
6830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6831 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306832 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306833 }
6834 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6835 if (pMac == NULL)
6836 {
6837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6838 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306839 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306840 }
6841 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6842 }
6843 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306844 case WE_DUMP_ROAM_TIMER_LOG:
6845 {
6846 vos_dump_roam_time_log_service();
6847 break;
6848 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306849
Mukul Sharma84f27252014-07-14 18:11:42 +05306850 case WE_RESET_ROAM_TIMER_LOG:
6851 {
6852 vos_reset_roam_timer_log();
6853 break;
6854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 default:
6856 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006857 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006858 break;
6859 }
6860 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306861 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 return ret;
6863}
6864
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)
6868{
6869 int ret;
6870
6871 vos_ssr_protect(__func__);
6872 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
6873 vos_ssr_unprotect(__func__);
6874
6875 return ret;
6876}
6877
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306878void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
6879{
6880 /*
6881 * Function to display HDD WMM information
6882 * for Tx Queues.
6883 * Prints globala as well as per client depending
6884 * whether the clients are registered or not.
6885 */
6886 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306887 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
6888 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05306889 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6890 hdd_ibss_peer_info_t *pPeerInfo;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306891
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306892 for ( i=0; i< NUM_TX_QUEUES; i++)
6893 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05306894 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306895
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006896 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306897 i, pAdapter->wmm_tx_queue[i].count,
6898 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05306899 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306900 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306901 if(pSapCtx == NULL){
6902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6903 FL("psapCtx is NULL"));
6904 return;
6905 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306906
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05306907 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306908 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
6909 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306910 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306911 {
6912 hddLog(LOGE, "******STAIndex: %d*********", i);
6913 for ( j=0; j< NUM_TX_QUEUES; j++)
6914 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306915 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006916 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306917 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
6918 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
6919 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
6920 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306921 }
6922 }
6923 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05306924 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306925
Katya Nigam1fd24402015-02-16 14:52:19 +05306926 if(pHddStaCtx == NULL){
6927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6928 FL("pHddStaCtx is NULL"));
6929 return;
6930 }
6931
6932 pPeerInfo = &pHddStaCtx->ibss_peer_info;
6933 if(pPeerInfo == NULL){
6934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6935 FL("ppeerinfo is NULL"));
6936 return;
6937 }
6938
6939 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
6940 {
6941 if(pPeerInfo->ibssStaInfo[i].isUsed)
6942 {
6943 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
6944 for ( j=0; j< NUM_TX_QUEUES; j++)
6945 {
6946 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
6947 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
6948 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
6949 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
6950 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
6951 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
6952 }
6953 }
6954 }
6955
6956
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306957}
Girish Gowlifb9758e2014-11-19 15:19:17 +05306958static int __iw_set_var_ints_getnone(struct net_device *dev,
6959 struct iw_request_info *info,
6960 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006961{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306962 hdd_adapter_t *pAdapter;
6963 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05306964 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05306965 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006966 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306967 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006968 hdd_ap_ctx_t *pAPCtx = NULL;
6969 int cmd = 0;
6970 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306971 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006972
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306973 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05306974 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05306975 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05306976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6977 "%s: NULL extra buffer pointer", __func__);
6978 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05306979 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306980 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6981 if (NULL == pAdapter)
6982 {
6983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6984 "%s: Adapter is NULL",__func__);
6985 return -EINVAL;
6986 }
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306987 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6988 ret = wlan_hdd_validate_context(pHddCtx);
6989 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006990 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306991 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006992 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306993 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6994 if (NULL == hHal)
6995 {
6996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6997 "%s: Hal Context is NULL",__func__);
6998 return -EINVAL;
6999 }
7000 sub_cmd = wrqu->data.flags;
7001
7002 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7003
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007004
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007005 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7006 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7007 {
7008 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7009 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7010 {
7011 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7012 staId = pStaCtx->conn_info.staId[0];
7013 }
7014 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7015 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7016 {
7017 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7018 staId = pAPCtx->uBCStaId;
7019 }
7020 else
7021 {
7022 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7023 return 0;
7024 }
7025 }
7026
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 switch (sub_cmd)
7028 {
7029 case WE_LOG_DUMP_CMD:
7030 {
7031 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007032 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 apps_args[3], apps_args[4]);
7034
7035 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7036 apps_args[3], apps_args[4]);
7037
7038 }
7039 break;
7040
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 case WE_P2P_NOA_CMD:
7042 {
7043 p2p_app_setP2pPs_t p2pNoA;
7044
7045 p2pNoA.opp_ps = apps_args[0];
7046 p2pNoA.ctWindow = apps_args[1];
7047 p2pNoA.duration = apps_args[2];
7048 p2pNoA.interval = apps_args[3];
7049 p2pNoA.count = apps_args[4];
7050 p2pNoA.single_noa_duration = apps_args[5];
7051 p2pNoA.psSelection = apps_args[6];
7052
7053 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7054 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007055 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007056 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7057
7058 hdd_setP2pPs(dev, &p2pNoA);
7059
7060 }
7061 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007062
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307063 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7064 {
7065 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7066 __func__, apps_args[0], apps_args[1]);
7067 vosTraceEnable(apps_args[0], apps_args[1]);
7068 }
7069 break;
7070
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007071 case WE_MTRACE_DUMP_CMD:
7072 {
7073 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7074 "bitmask_of_module %d ",
7075 __func__, apps_args[0], apps_args[1], apps_args[2],
7076 apps_args[3]);
7077 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7078 apps_args[2], apps_args[3]);
7079
7080 }
7081 break;
7082
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007083 case WE_MCC_CONFIG_CREDENTIAL :
7084 {
7085 cmd = 287; //Command should be updated if there is any change
7086 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007087 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007088 {
7089 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7090 }
7091 else
7092 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007093 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007094 return 0;
7095 }
7096 }
7097 break;
7098
7099 case WE_MCC_CONFIG_PARAMS :
7100 {
7101 cmd = 288; //command Should be updated if there is any change
7102 // in the Riva dump command
7103 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7104 }
7105 break;
7106
Chilam NG571c65a2013-01-19 12:27:36 +05307107#ifdef FEATURE_WLAN_TDLS
7108 case WE_TDLS_CONFIG_PARAMS :
7109 {
7110 tdls_config_params_t tdlsParams;
7111
Chilam Ng01120412013-02-19 18:32:21 -08007112 tdlsParams.tdls = apps_args[0];
7113 tdlsParams.tx_period_t = apps_args[1];
7114 tdlsParams.tx_packet_n = apps_args[2];
7115 tdlsParams.discovery_period_t = apps_args[3];
7116 tdlsParams.discovery_tries_n = apps_args[4];
7117 tdlsParams.idle_timeout_t = apps_args[5];
7118 tdlsParams.idle_packet_n = apps_args[6];
7119 tdlsParams.rssi_hysteresis = apps_args[7];
7120 tdlsParams.rssi_trigger_threshold = apps_args[8];
7121 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307122
Chilam Ng01120412013-02-19 18:32:21 -08007123 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307124 }
7125 break;
7126#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 default:
7128 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007129 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7130 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 }
7132 break;
7133 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307134 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 return 0;
7136}
7137
Girish Gowlifb9758e2014-11-19 15:19:17 +05307138static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7139 struct iw_request_info *info,
7140 union iwreq_data *wrqu, char *extra)
7141{
7142 int ret;
7143 union iwreq_data u_priv_wrqu;
7144 int apps_args[MAX_VAR_ARGS] = {0};
7145 int num_args;
7146
7147 /* helper function to get iwreq_data with compat handling. */
7148 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7149 {
7150 return -EINVAL;
7151 }
7152
7153 if (NULL == u_priv_wrqu.data.pointer)
7154 {
7155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7156 "%s: NULL data pointer", __func__);
7157 return -EINVAL;
7158 }
7159
7160 num_args = u_priv_wrqu.data.length;
7161 if (num_args > MAX_VAR_ARGS)
7162 {
7163 num_args = MAX_VAR_ARGS;
7164 }
7165
7166 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7167 (sizeof(int)) * num_args))
7168 {
7169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7170 "%s: failed to copy data from user buffer", __func__);
7171 return -EFAULT;
7172 }
7173
7174 vos_ssr_protect(__func__);
7175 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7176 (char *)&apps_args);
7177 vos_ssr_unprotect(__func__);
7178
7179 return ret;
7180}
7181
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307182int iw_set_var_ints_getnone(struct net_device *dev,
7183 struct iw_request_info *info,
7184 union iwreq_data *wrqu, char *extra)
7185{
7186 int ret;
7187 vos_ssr_protect(__func__);
7188 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7189 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007190
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307191 return ret;
7192}
7193
7194static int __iw_add_tspec(struct net_device *dev,
7195 struct iw_request_info *info,
7196 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007197{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307198 hdd_adapter_t *pAdapter;
7199 hdd_station_ctx_t *pHddStaCtx;
7200 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7202 int params[HDD_WLAN_WMM_PARAM_COUNT];
7203 sme_QosWmmTspecInfo tSpec;
7204 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307205 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307206 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007207
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307208 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307209 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7210 if (NULL == pAdapter)
7211 {
7212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7213 "%s: Adapter is NULL",__func__);
7214 return -EINVAL;
7215 }
7216 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7217 ret = wlan_hdd_validate_context(pHddCtx);
7218 if (0 != ret)
7219 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307220 return ret;
7221 }
7222 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7223 if (NULL == pHddStaCtx)
7224 {
7225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7226 "%s: STA Context is NULL",__func__);
7227 return -EINVAL;
7228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 // make sure the application is sufficiently priviledged
7230 // note that the kernel will do this for "set" ioctls, but since
7231 // this ioctl wants to return status to user space it must be
7232 // defined as a "get" ioctl
7233 if (!capable(CAP_NET_ADMIN))
7234 {
7235 return -EPERM;
7236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 // we must be associated in order to add a tspec
7238 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7239 {
7240 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7241 return 0;
7242 }
7243
7244 // since we are defined to be a "get" ioctl, and since the number
7245 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307246 // will pass down in the iwreq_data, we must copy the "set" params.
7247 // We must handle the compat for iwreq_data in 32U/64K environment.
7248
7249 // helper fucntion to get iwreq_data with compat handling.
7250 if (hdd_priv_get_data(&s_priv_data, wrqu))
7251 {
7252 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7253 return 0;
7254 }
7255
7256 // make sure all params are correctly passed to function
7257 if ((NULL == s_priv_data.pointer) ||
7258 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7259 {
7260 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7261 return 0;
7262 }
7263
Jeff Johnson295189b2012-06-20 16:38:30 -07007264 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307265 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 {
7267 // hmmm, can't get them
7268 return -EIO;
7269 }
7270
7271 // clear the tspec
7272 memset(&tSpec, 0, sizeof(tSpec));
7273
7274 // validate the handle
7275 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7276 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7277 {
7278 // that one is reserved
7279 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7280 return 0;
7281 }
7282
7283 // validate the TID
7284 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7285 {
7286 // out of range
7287 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7288 return 0;
7289 }
7290 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7291
7292 // validate the direction
7293 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7294 {
7295 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7296 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7297 break;
7298
7299 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7300 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7301 break;
7302
7303 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7304 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7305 break;
7306
7307 default:
7308 // unknown
7309 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7310 return 0;
7311 }
7312
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307313 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7314
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 // validate the user priority
7316 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7317 {
7318 // out of range
7319 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7320 return 0;
7321 }
7322 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307323 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7324 {
7325 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7326 return 0;
7327 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007328
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7330 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7331 tSpec.ts_info.psb, tSpec.ts_info.up);
7332
Jeff Johnson295189b2012-06-20 16:38:30 -07007333 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7334 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7335 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7336 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7337 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7338 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7339 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7340 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7341 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7342 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7343 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7344 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7345
7346 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7347
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307348 // Save the expected UAPSD settings by application, this will be needed
7349 // when re-negotiating UAPSD settings during BT Coex cases.
7350 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7351
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 // validate the ts info ack policy
7353 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7354 {
7355 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7356 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7357 break;
7358
7359 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7360 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7361 break;
7362
7363 default:
7364 // unknown
7365 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7366 return 0;
7367 }
7368
7369 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307370
7371 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007372 return 0;
7373}
7374
7375
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307376static int iw_add_tspec(struct net_device *dev,
7377 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007378 union iwreq_data *wrqu, char *extra)
7379{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307380 int ret;
7381
7382 vos_ssr_protect(__func__);
7383 ret = __iw_add_tspec(dev, info, wrqu, extra);
7384 vos_ssr_unprotect(__func__);
7385
7386 return ret;
7387}
7388
7389static int __iw_del_tspec(struct net_device *dev,
7390 struct iw_request_info *info,
7391 union iwreq_data *wrqu, char *extra)
7392{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307393 hdd_adapter_t *pAdapter;
7394 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007395 int *params = (int *)extra;
7396 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7397 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307398 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007399
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307400 ENTER();
7401
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307402 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7403 if (NULL == pAdapter)
7404 {
7405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7406 "%s: Adapter is NULL",__func__);
7407 return -EINVAL;
7408 }
7409
7410 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7411 ret = wlan_hdd_validate_context(pHddCtx);
7412 if (0 != ret)
7413 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307414 return ret;
7415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 // make sure the application is sufficiently priviledged
7417 // note that the kernel will do this for "set" ioctls, but since
7418 // this ioctl wants to return status to user space it must be
7419 // defined as a "get" ioctl
7420 if (!capable(CAP_NET_ADMIN))
7421 {
7422 return -EPERM;
7423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 // although we are defined to be a "get" ioctl, the params we require
7425 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7426 // is no need to copy the params from user space
7427
7428 // validate the handle
7429 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7430 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7431 {
7432 // that one is reserved
7433 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7434 return 0;
7435 }
7436
7437 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307438
7439 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007440 return 0;
7441}
7442
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307443static int iw_del_tspec(struct net_device *dev,
7444 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 union iwreq_data *wrqu, char *extra)
7446{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307447 int ret;
7448
7449 vos_ssr_protect(__func__);
7450 ret = __iw_del_tspec(dev, info, wrqu, extra);
7451 vos_ssr_unprotect(__func__);
7452
7453 return ret;
7454}
7455
7456
7457static int __iw_get_tspec(struct net_device *dev,
7458 struct iw_request_info *info,
7459 union iwreq_data *wrqu, char *extra)
7460{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307461 hdd_adapter_t *pAdapter;
7462 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 int *params = (int *)extra;
7464 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7465 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307466 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007467
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307468 ENTER();
7469
Jeff Johnson295189b2012-06-20 16:38:30 -07007470 // although we are defined to be a "get" ioctl, the params we require
7471 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7472 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307473 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7474 if (NULL == pAdapter)
7475 {
7476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7477 "%s: Adapter is NULL",__func__);
7478 return -EINVAL;
7479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007480
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307481 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7482 ret = wlan_hdd_validate_context(pHddCtx);
7483 if (0 != ret)
7484 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307485 return ret;
7486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 // validate the handle
7488 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7489 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7490 {
7491 // that one is reserved
7492 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7493 return 0;
7494 }
7495
7496 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307497 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 return 0;
7499}
7500
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307501static int iw_get_tspec(struct net_device *dev,
7502 struct iw_request_info *info,
7503 union iwreq_data *wrqu, char *extra)
7504{
7505 int ret;
7506
7507 vos_ssr_protect(__func__);
7508 ret = __iw_get_tspec(dev, info, wrqu, extra);
7509 vos_ssr_unprotect(__func__);
7510
7511 return ret;
7512}
7513
Jeff Johnson295189b2012-06-20 16:38:30 -07007514#ifdef WLAN_FEATURE_VOWIFI_11R
7515//
7516//
7517// Each time the supplicant has the auth_request or reassoc request
7518// IEs ready. This is pushed to the driver. The driver will inturn use
7519// it to send out the auth req and reassoc req for 11r FT Assoc.
7520//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307521static int __iw_set_fties(struct net_device *dev,
7522 struct iw_request_info *info,
7523 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007524{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307525 hdd_adapter_t *pAdapter;
7526 hdd_station_ctx_t *pHddStaCtx;
7527 hdd_context_t *pHddCtx;
7528 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007529 //v_CONTEXT_t pVosContext;
7530
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307531 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307532 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7533 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007534 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7536 "%s: Adapter is NULL",__func__);
7537 return -EINVAL;
7538 }
7539 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7540 ret = wlan_hdd_validate_context(pHddCtx);
7541 if (0 != ret)
7542 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307543 return ret;
7544 }
7545 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7546 if (NULL == pHddStaCtx)
7547 {
7548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7549 "%s: STA Context is NULL",__func__);
7550 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007552 if (!wrqu->data.length)
7553 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007554 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007555 return -EINVAL;
7556 }
7557 if (wrqu->data.pointer == NULL)
7558 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007559 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007560 return -EINVAL;
7561 }
7562
7563 // Added for debug on reception of Re-assoc Req.
7564 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7565 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007566 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007567 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007568 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 }
7570
7571#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007572 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007573#endif
7574
7575 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007576 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007577 wrqu->data.length);
7578
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307579 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 return 0;
7581}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307582
7583static int iw_set_fties(struct net_device *dev,
7584 struct iw_request_info *info,
7585 union iwreq_data *wrqu, char *extra)
7586{
7587 int ret;
7588
7589 vos_ssr_protect(__func__);
7590 ret = __iw_set_fties(dev, info, wrqu, extra);
7591 vos_ssr_unprotect(__func__);
7592
7593 return ret;
7594}
Jeff Johnson295189b2012-06-20 16:38:30 -07007595#endif
7596
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307597static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007598 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007600{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307601 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007602 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307603 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007604 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307605 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007606 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7607 int idx;
7608 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007609
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307610 ENTER();
7611
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307612 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7613 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007614 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7616 "%s: Adapter is NULL",__func__);
7617 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007618 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307619 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7620 ret_val = wlan_hdd_validate_context(pHddCtx);
7621 if (0 != ret_val)
7622 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307623 return ret_val;
7624 }
7625 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7626 if (NULL == hHal)
7627 {
7628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7629 "%s: Hal Context is NULL",__func__);
7630 return -EINVAL;
7631 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307632 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7633 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307634#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007635
Amar Singhalf3a6e762013-02-19 15:06:50 -08007636 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7637 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007638 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007639 hddLog(VOS_TRACE_LEVEL_ERROR,
7640 "%s: vos_mem_alloc failed", __func__);
7641 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007642 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007643
7644 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7645
7646 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7647 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7648
7649 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7650 mc_addr_list_ptr->ulMulticastAddrCnt);
7651
7652 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007653 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007654 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7655 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7656
7657 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7658 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007659 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007660
Amar Singhalf3a6e762013-02-19 15:06:50 -08007661 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7662 vos_mem_free(mc_addr_list_ptr);
7663 if (eHAL_STATUS_SUCCESS != ret_val)
7664 {
7665 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7666 __func__);
7667 return -EINVAL;
7668 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307669#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307670 }
7671 else
7672 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007673
Amar Singhalf3a6e762013-02-19 15:06:50 -08007674 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7675 "%s: Set MC BC Filter Config request: %d suspend %d",
7676 __func__, pRequest->mcastBcastFilterSetting,
7677 pHddCtx->hdd_wlan_suspended);
7678
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307679 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007680
7681 if (pHddCtx->hdd_wlan_suspended)
7682 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007683 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7684 if (NULL == wlanRxpFilterParam)
7685 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307686 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007687 "%s: vos_mem_alloc failed", __func__);
7688 return -EINVAL;
7689 }
7690
Amar Singhalf3a6e762013-02-19 15:06:50 -08007691 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7692 pRequest->mcastBcastFilterSetting;
7693 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7694
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307695 hdd_conf_hostoffload(pAdapter, TRUE);
7696 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7697 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007698
7699 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7700 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307701 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007702 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7703 wlanRxpFilterParam->setMcstBcstFilter);
7704
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307705 if (eHAL_STATUS_SUCCESS !=
7706 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7707 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007708 {
7709 hddLog(VOS_TRACE_LEVEL_ERROR,
7710 "%s: Failure to execute set HW MC/BC Filter request",
7711 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007712 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007713 return -EINVAL;
7714 }
7715
c_hpothud3ce76d2014-10-28 10:34:13 +05307716 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7717 {
7718 pHddCtx->sus_res_mcastbcast_filter =
7719 pRequest->mcastBcastFilterSetting;
7720 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007721 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007723
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307724 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 return 0;
7726}
7727
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307728static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7729 struct iw_request_info *info,
7730 union iwreq_data *wrqu, char *extra)
7731{
7732 int ret;
7733
7734 vos_ssr_protect(__func__);
7735 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
7736 vos_ssr_unprotect(__func__);
7737
7738 return ret;
7739}
7740
7741static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7742 struct iw_request_info *info,
7743 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007744{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307745 hdd_adapter_t *pAdapter;
7746 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307747 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307748 int ret = 0;
7749
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307750 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007751
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307752 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7753 if (NULL == pAdapter)
7754 {
7755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7756 "%s: Adapter is NULL",__func__);
7757 return -EINVAL;
7758 }
7759
7760 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7761 ret = wlan_hdd_validate_context(pHddCtx);
7762 if (0 != ret)
7763 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307764 return ret;
7765 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307766 //Reset the filter to INI value as we have to clear the dynamic filter
7767 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07007768
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307769 //Configure FW with new setting
7770 if (pHddCtx->hdd_wlan_suspended)
7771 {
7772 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7773 if (NULL == wlanRxpFilterParam)
7774 {
7775 hddLog(VOS_TRACE_LEVEL_ERROR,
7776 "%s: vos_mem_alloc failed", __func__);
7777 return -EINVAL;
7778 }
7779
7780 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7781 pHddCtx->configuredMcastBcastFilter;
7782 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7783
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307784 hdd_conf_hostoffload(pAdapter, TRUE);
7785 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7786 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307787
7788 if (eHAL_STATUS_SUCCESS !=
7789 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7790 wlanRxpFilterParam))
7791 {
7792 hddLog(VOS_TRACE_LEVEL_ERROR,
7793 "%s: Failure to execute set HW MC/BC Filter request",
7794 __func__);
7795 vos_mem_free(wlanRxpFilterParam);
7796 return -EINVAL;
7797 }
c_hpothud3ce76d2014-10-28 10:34:13 +05307798
7799 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7800 {
7801 pHddCtx->sus_res_mcastbcast_filter =
7802 pHddCtx->cfg_ini->mcastBcastFilterSetting;
7803 }
7804
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307805 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307806 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007807 return 0;
7808}
7809
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307810
7811static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7812 struct iw_request_info *info,
7813 union iwreq_data *wrqu, char *extra)
7814{
7815 int ret;
7816
7817 vos_ssr_protect(__func__);
7818 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
7819 vos_ssr_unprotect(__func__);
7820
7821 return ret;
7822}
7823
7824static int __iw_set_host_offload(struct net_device *dev,
7825 struct iw_request_info *info,
7826 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007827{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307828 hdd_adapter_t *pAdapter;
7829 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007830 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307832 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007833
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307834 ENTER();
7835
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307836 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7837 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007838 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7840 "%s: Adapter is NULL",__func__);
7841 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007842 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307843 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7844 ret = wlan_hdd_validate_context(pHddCtx);
7845 if (0 != ret)
7846 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307847 return ret;
7848 }
7849
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 /* Debug display of request components. */
7851 switch (pRequest->offloadType)
7852 {
7853 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007854 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007855 switch (pRequest->enableOrDisable)
7856 {
7857 case WLAN_OFFLOAD_DISABLE:
7858 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
7859 break;
7860 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
7861 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
7862 case WLAN_OFFLOAD_ENABLE:
7863 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
7864 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
7865 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
7866 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
7867 }
7868 break;
7869
7870 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08007871 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007872 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 switch (pRequest->enableOrDisable)
7874 {
7875 case WLAN_OFFLOAD_DISABLE:
7876 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
7877 break;
7878 case WLAN_OFFLOAD_ENABLE:
7879 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
7880 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
7881 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
7882 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
7883 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
7884 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
7885 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
7886 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
7887 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
7888 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
7889 }
7890 }
7891
7892 /* Execute offload request. The reason that we can copy the request information
7893 from the ioctl structure to the SME structure is that they are laid out
7894 exactly the same. Otherwise, each piece of information would have to be
7895 copied individually. */
7896 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07007897 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
7898 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007900 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 __func__);
7902 return -EINVAL;
7903 }
7904
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307905 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007906 return 0;
7907}
7908
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307909static int iw_set_host_offload(struct net_device *dev,
7910 struct iw_request_info *info,
7911 union iwreq_data *wrqu, char *extra)
7912{
7913 int ret;
7914
7915 vos_ssr_protect(__func__);
7916 ret = __iw_set_host_offload(dev, info, wrqu, extra);
7917 vos_ssr_unprotect(__func__);
7918
7919 return ret;
7920}
7921
7922static int __iw_set_keepalive_params(struct net_device *dev,
7923 struct iw_request_info *info,
7924 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007925{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307926 hdd_adapter_t *pAdapter;
7927 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007928 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007929 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307930 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007931
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307932 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307933 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7934 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07007935 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7937 "%s: Adapter is NULL",__func__);
7938 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007939 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307940 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7941 ret = wlan_hdd_validate_context(pHddCtx);
7942 if (0 != ret)
7943 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307944 return ret;
7945 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007946 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08007947 hddLog(VOS_TRACE_LEVEL_INFO,
7948 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
7949 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07007950
7951 switch (pRequest->packetType)
7952 {
7953 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007954 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 break;
7956
7957 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
7958
Arif Hussain6d2a3322013-11-17 19:50:10 -08007959 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007960 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007961
7962 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
7963 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
7964 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
7965
7966 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
7967 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
7968 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
7969
7970 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
7971 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
7972 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
7973 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
7974 break;
7975
7976 }
7977
7978 /* Execute keep alive request. The reason that we can copy the request information
7979 from the ioctl structure to the SME structure is that they are laid out
7980 exactly the same. Otherwise, each piece of information would have to be
7981 copied individually. */
7982 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
7983
Arif Hussain6d2a3322013-11-17 19:50:10 -08007984 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07007985
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007986 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07007987 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07007988 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007989 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 __func__);
7991 return -EINVAL;
7992 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307993 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007994 return 0;
7995}
7996
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307997static int iw_set_keepalive_params(struct net_device *dev,
7998 struct iw_request_info *info,
7999 union iwreq_data *wrqu, char *extra)
8000{
8001 int ret;
8002 vos_ssr_protect(__func__);
8003 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8004 vos_ssr_unprotect(__func__);
8005
8006 return ret;
8007}
8008
Jeff Johnson295189b2012-06-20 16:38:30 -07008009#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008010int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008011 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008012{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008013 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8014 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008015 int i=0;
8016
8017 if (pHddCtx->cfg_ini->disablePacketFilter)
8018 {
8019 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008020 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008021 return 0;
8022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008023 /* Debug display of request components. */
8024 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008025 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008026
8027 switch (pRequest->filterAction)
8028 {
8029 case HDD_RCV_FILTER_SET:
8030 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008031 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008032
8033 packetFilterSetReq.filterId = pRequest->filterId;
8034 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8035 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008036 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008037 __func__, pRequest->numParams);
8038 return -EINVAL;
8039 }
8040 packetFilterSetReq.numFieldParams = pRequest->numParams;
8041 packetFilterSetReq.coalesceTime = 0;
8042 packetFilterSetReq.filterType = 1;
8043 for (i=0; i < pRequest->numParams; i++)
8044 {
8045 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8046 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8047 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8048 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8049 packetFilterSetReq.paramsData[i].reserved = 0;
8050
Arif Hussain6d2a3322013-11-17 19:50:10 -08008051 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008052 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8053 packetFilterSetReq.filterType);
8054
Arif Hussain6d2a3322013-11-17 19:50:10 -08008055 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8057
8058 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8059 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8060 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8061 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8062
Arif Hussain6d2a3322013-11-17 19:50:10 -08008063 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8065 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8066 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8067
Arif Hussain6d2a3322013-11-17 19:50:10 -08008068 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8070 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8071 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8072 }
8073
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008074 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008076 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008077 __func__);
8078 return -EINVAL;
8079 }
8080
8081 break;
8082
8083 case HDD_RCV_FILTER_CLEAR:
8084
Arif Hussain6d2a3322013-11-17 19:50:10 -08008085 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008086 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008088 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008090 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008091 __func__);
8092 return -EINVAL;
8093 }
8094 break;
8095
8096 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008097 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008098 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008099 return -EINVAL;
8100 }
8101 return 0;
8102}
8103
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308104int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8105 tANI_U8 sessionId)
8106{
8107 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8108 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8109
8110 if (NULL == pHddCtx)
8111 {
8112 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8113 return -EINVAL;
8114 }
8115
8116 if (pHddCtx->isLogpInProgress)
8117 {
8118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8119 "%s:LOGP in Progress. Ignore!!!", __func__);
8120 return -EBUSY;
8121 }
8122
8123 if (pHddCtx->cfg_ini->disablePacketFilter)
8124 {
8125 hddLog(VOS_TRACE_LEVEL_ERROR,
8126 "%s: Packet Filtering Disabled. Returning ",
8127 __func__ );
8128 return -EINVAL;
8129 }
8130
8131 switch (filterType)
8132 {
8133 /* For setting IPV6 MC and UC Filter we need to configure
8134 * 2 filters, one for MC and one for UC.
8135 * The Filter ID shouldn't be swapped, which results in making
8136 * UC Filter ineffective.
8137 * We have Hardcode all the values
8138 *
8139 * Reason for a seperate UC filter is because, driver need to
8140 * specify the FW that the specific filter is for unicast
8141 * otherwise FW will not pass the unicast frames by default
8142 * through the filter. This is required to avoid any performance
8143 * hits when no unicast filter is set and only MC/BC are set.
8144 * The way driver informs host is by using the MAC protocol
8145 * layer, CMP flag set to MAX, CMP Data set to 1.
8146 */
8147
8148 case HDD_FILTER_IPV6_MC_UC:
8149 /* Setting IPV6 MC Filter below
8150 */
8151 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8152 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8153 packetFilterSetReq.numFieldParams = 2;
8154 packetFilterSetReq.paramsData[0].protocolLayer =
8155 HDD_FILTER_PROTO_TYPE_MAC;
8156 packetFilterSetReq.paramsData[0].cmpFlag =
8157 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8158 packetFilterSetReq.paramsData[0].dataOffset =
8159 WLAN_HDD_80211_FRM_DA_OFFSET;
8160 packetFilterSetReq.paramsData[0].dataLength = 1;
8161 packetFilterSetReq.paramsData[0].compareData[0] =
8162 HDD_IPV6_MC_CMP_DATA;
8163
8164 packetFilterSetReq.paramsData[1].protocolLayer =
8165 HDD_FILTER_PROTO_TYPE_ARP;
8166 packetFilterSetReq.paramsData[1].cmpFlag =
8167 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8168 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8169 packetFilterSetReq.paramsData[1].dataLength = 2;
8170 packetFilterSetReq.paramsData[1].compareData[0] =
8171 HDD_IPV6_CMP_DATA_0;
8172 packetFilterSetReq.paramsData[1].compareData[1] =
8173 HDD_IPV6_CMP_DATA_1;
8174
8175
8176 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8177 &packetFilterSetReq, sessionId))
8178 {
8179 hddLog(VOS_TRACE_LEVEL_ERROR,
8180 "%s: Failure to execute Set IPv6 Mulicast Filter",
8181 __func__);
8182 return -EINVAL;
8183 }
8184
8185 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8186
8187 /*
8188 * Setting IPV6 UC Filter below
8189 */
8190 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8191 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8192 packetFilterSetReq.numFieldParams = 2;
8193 packetFilterSetReq.paramsData[0].protocolLayer =
8194 HDD_FILTER_PROTO_TYPE_MAC;
8195 packetFilterSetReq.paramsData[0].cmpFlag =
8196 HDD_FILTER_CMP_TYPE_MAX;
8197 packetFilterSetReq.paramsData[0].dataOffset = 0;
8198 packetFilterSetReq.paramsData[0].dataLength = 1;
8199 packetFilterSetReq.paramsData[0].compareData[0] =
8200 HDD_IPV6_UC_CMP_DATA;
8201
8202 packetFilterSetReq.paramsData[1].protocolLayer =
8203 HDD_FILTER_PROTO_TYPE_ARP;
8204 packetFilterSetReq.paramsData[1].cmpFlag =
8205 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8206 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8207 packetFilterSetReq.paramsData[1].dataLength = 2;
8208 packetFilterSetReq.paramsData[1].compareData[0] =
8209 HDD_IPV6_CMP_DATA_0;
8210 packetFilterSetReq.paramsData[1].compareData[1] =
8211 HDD_IPV6_CMP_DATA_1;
8212
8213 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8214 &packetFilterSetReq, sessionId))
8215 {
8216 hddLog(VOS_TRACE_LEVEL_ERROR,
8217 "%s: Failure to execute Set IPv6 Unicast Filter",
8218 __func__);
8219 return -EINVAL;
8220 }
8221
8222 break;
8223
8224 case HDD_FILTER_IPV6_MC:
8225 /*
8226 * IPV6 UC Filter might be already set,
8227 * clear the UC Filter. As the Filter
8228 * IDs are static, we can directly clear it.
8229 */
8230 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8231 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8232 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8233 &packetFilterClrReq, sessionId))
8234 {
8235 hddLog(VOS_TRACE_LEVEL_ERROR,
8236 "%s: Failure to execute Clear IPv6 Unicast Filter",
8237 __func__);
8238 return -EINVAL;
8239 }
8240
8241 /*
8242 * Setting IPV6 MC Filter below
8243 */
8244 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8245 packetFilterSetReq.numFieldParams = 2;
8246 packetFilterSetReq.paramsData[0].protocolLayer =
8247 HDD_FILTER_PROTO_TYPE_MAC;
8248 packetFilterSetReq.paramsData[0].cmpFlag =
8249 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8250 packetFilterSetReq.paramsData[0].dataOffset =
8251 WLAN_HDD_80211_FRM_DA_OFFSET;
8252 packetFilterSetReq.paramsData[0].dataLength = 1;
8253 packetFilterSetReq.paramsData[0].compareData[0] =
8254 HDD_IPV6_MC_CMP_DATA;
8255
8256 packetFilterSetReq.paramsData[1].protocolLayer =
8257 HDD_FILTER_PROTO_TYPE_ARP;
8258 packetFilterSetReq.paramsData[1].cmpFlag =
8259 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8260 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8261 packetFilterSetReq.paramsData[1].dataLength = 2;
8262 packetFilterSetReq.paramsData[1].compareData[0] =
8263 HDD_IPV6_CMP_DATA_0;
8264 packetFilterSetReq.paramsData[1].compareData[1] =
8265 HDD_IPV6_CMP_DATA_1;
8266
8267
8268 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8269 &packetFilterSetReq, sessionId))
8270 {
8271 hddLog(VOS_TRACE_LEVEL_ERROR,
8272 "%s: Failure to execute Set IPv6 Multicast Filter",
8273 __func__);
8274 return -EINVAL;
8275 }
8276 break;
8277
8278 default :
8279 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8280 "%s: Packet Filter Request: Invalid",
8281 __func__);
8282 return -EINVAL;
8283 }
8284 return 0;
8285}
8286
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308287void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008288{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308289 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308290 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008291 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308292 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008293
Yue Ma3ede6052013-08-29 00:33:26 -07008294 if (NULL == pHddCtx)
8295 {
8296 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8297 return;
8298 }
8299
8300 hHal = pHddCtx->hHal;
8301
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308302 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308304 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8305 return;
8306 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308307
8308 /* Check if INI is enabled or not, other wise just return
8309 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308310 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308311 {
8312 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8313 if (NULL == pMulticastAddrs)
8314 {
8315 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8316 return;
8317 }
8318
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 if (set)
8320 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308321 /* Following pre-conditions should be satisfied before wei
8322 * configure the MC address list.
8323 */
8324 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8325 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8326 && pAdapter->mc_addr_list.mc_cnt
8327 && (eConnectionState_Associated ==
8328 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8329 {
8330 pMulticastAddrs->ulMulticastAddrCnt =
8331 pAdapter->mc_addr_list.mc_cnt;
8332 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8333 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008334 memcpy(pMulticastAddrs->multicastAddr[i],
8335 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308336 sizeof(pAdapter->mc_addr_list.addr[i]));
8337 hddLog(VOS_TRACE_LEVEL_INFO,
8338 "%s: %s multicast filter: addr ="
8339 MAC_ADDRESS_STR,
8340 __func__, set ? "setting" : "clearing",
8341 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8342 }
8343 /* Set multicast filter */
8344 sme_8023MulticastList(hHal, pAdapter->sessionId,
8345 pMulticastAddrs);
8346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008347 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308348 else
8349 {
8350 /* Need to clear only if it was previously configured
8351 */
8352 if (pAdapter->mc_addr_list.isFilterApplied)
8353 {
8354 pMulticastAddrs->ulMulticastAddrCnt = 0;
8355 sme_8023MulticastList(hHal, pAdapter->sessionId,
8356 pMulticastAddrs);
8357 }
8358
8359 }
8360 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008361 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308363 else
8364 {
8365 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308366 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308367 }
8368 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008369}
8370
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308371static int __iw_set_packet_filter_params(struct net_device *dev,
8372 struct iw_request_info *info,
8373 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308374{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308375 hdd_adapter_t *pAdapter;
8376 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008377 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308378 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308379 struct iw_point s_priv_data;
8380
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308381 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308382 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8383 if (NULL == pAdapter)
8384 {
8385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8386 "%s: Adapter is NULL",__func__);
8387 return -EINVAL;
8388 }
8389 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8390 ret = wlan_hdd_validate_context(pHddCtx);
8391 if (0 != ret)
8392 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308393 return ret;
8394 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308395 if (hdd_priv_get_data(&s_priv_data, wrqu))
8396 {
8397 return -EINVAL;
8398 }
8399
8400 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8401 {
8402 return -EINVAL;
8403 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008404
Arif Hussain0273cba2014-01-07 20:58:29 -08008405 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308406 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8407 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008408 if (NULL == pRequest)
8409 {
8410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8411 "mem_alloc_copy_from_user_helper fail");
8412 return -ENOMEM;
8413 }
8414
8415 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8416 kfree(pRequest);
8417
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308418 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008419 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008420}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308421
8422static int iw_set_packet_filter_params(struct net_device *dev,
8423 struct iw_request_info *info,
8424 union iwreq_data *wrqu, char *extra)
8425{
8426 int ret;
8427
8428 vos_ssr_protect(__func__);
8429 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8430 vos_ssr_unprotect(__func__);
8431
8432 return ret;
8433}
Jeff Johnson295189b2012-06-20 16:38:30 -07008434#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308435static int __iw_get_statistics(struct net_device *dev,
8436 struct iw_request_info *info,
8437 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008438{
8439
8440 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8441 eHalStatus status = eHAL_STATUS_SUCCESS;
8442 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308443 hdd_adapter_t *pAdapter;
8444 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308446 int tlen = 0, ret = 0;
8447 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008448
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308449 tCsrGlobalClassAStatsInfo *aStats;
8450 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008451
8452 ENTER();
8453
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308454 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8455 if (NULL == pAdapter)
8456 {
8457 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8458 "%s: Adapter is NULL",__func__);
8459 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008460 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308461 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8462 ret = wlan_hdd_validate_context(pHddCtx);
8463 if (0 != ret)
8464 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308465 return ret;
8466 }
8467 pStats = &(pAdapter->hdd_stats.summary_stat);
8468 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8469 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8471
8472 wrqu->txpower.value = 0;
8473 }
8474 else {
8475 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8476 SME_SUMMARY_STATS |
8477 SME_GLOBAL_CLASSA_STATS |
8478 SME_GLOBAL_CLASSB_STATS |
8479 SME_GLOBAL_CLASSC_STATS |
8480 SME_GLOBAL_CLASSD_STATS |
8481 SME_PER_STA_STATS,
8482 hdd_StatisticsCB, 0, FALSE,
8483 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8484
8485 if (eHAL_STATUS_SUCCESS != status)
8486 {
8487 hddLog(VOS_TRACE_LEVEL_ERROR,
8488 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008489 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008490 return -EINVAL;
8491 }
8492
8493 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308494 if (NULL == pWextState)
8495 {
8496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8497 "%s: pWextState is NULL",__func__);
8498 return -EINVAL;
8499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008500
8501 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8502 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8503 {
8504 hddLog(VOS_TRACE_LEVEL_ERROR,
8505 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008506 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 /*Remove the SME statistics list by passing NULL in callback argument*/
8508 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8509 SME_SUMMARY_STATS |
8510 SME_GLOBAL_CLASSA_STATS |
8511 SME_GLOBAL_CLASSB_STATS |
8512 SME_GLOBAL_CLASSC_STATS |
8513 SME_GLOBAL_CLASSD_STATS |
8514 SME_PER_STA_STATS,
8515 NULL, 0, FALSE,
8516 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8517
8518 return -EINVAL;
8519 }
8520 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8521 (tANI_U8) sizeof (pStats->retry_cnt),
8522 (char*) &(pStats->retry_cnt[0]),
8523 tlen);
8524
8525 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8526 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8527 (char*) &(pStats->multiple_retry_cnt[0]),
8528 tlen);
8529
8530 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8531 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8532 (char*) &(pStats->tx_frm_cnt[0]),
8533 tlen);
8534
8535 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8536 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8537 (char*) &(pStats->rx_frm_cnt),
8538 tlen);
8539
8540 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8541 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8542 (char*) &(pStats->frm_dup_cnt),
8543 tlen);
8544
8545 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8546 (tANI_U8) sizeof (pStats->fail_cnt),
8547 (char*) &(pStats->fail_cnt[0]),
8548 tlen);
8549
8550 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8551 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8552 (char*) &(pStats->rts_fail_cnt),
8553 tlen);
8554
8555 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8556 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8557 (char*) &(pStats->ack_fail_cnt),
8558 tlen);
8559
8560 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8561 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8562 (char*) &(pStats->rts_succ_cnt),
8563 tlen);
8564
8565 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8566 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8567 (char*) &(pStats->rx_discard_cnt),
8568 tlen);
8569
8570 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8571 (tANI_U8) sizeof (pStats->rx_error_cnt),
8572 (char*) &(pStats->rx_error_cnt),
8573 tlen);
8574
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008575 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008576 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008577 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008578 tlen);
8579
8580 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8581 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8582 (char*) &(dStats->rx_byte_cnt),
8583 tlen);
8584
8585 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8586 (tANI_U8) sizeof (dStats->rx_rate),
8587 (char*) &(dStats->rx_rate),
8588 tlen);
8589
8590 /* Transmit rate, in units of 500 kbit/sec */
8591 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8592 (tANI_U8) sizeof (aStats->tx_rate),
8593 (char*) &(aStats->tx_rate),
8594 tlen);
8595
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008596 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8597 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8598 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008599 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008600 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8601 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8602 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008603 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008604 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8605 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8606 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008607 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008608 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8609 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8610 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008611 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008612 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8613 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8614 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008615 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008616 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8617 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8618 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008619 tlen);
8620
Jeff Johnson295189b2012-06-20 16:38:30 -07008621 wrqu->data.length = tlen;
8622
8623 }
8624
8625 EXIT();
8626
8627 return 0;
8628}
8629
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308630static int iw_get_statistics(struct net_device *dev,
8631 struct iw_request_info *info,
8632 union iwreq_data *wrqu, char *extra)
8633{
8634 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008635
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308636 vos_ssr_protect(__func__);
8637 ret = __iw_get_statistics(dev, info, wrqu, extra);
8638 vos_ssr_unprotect(__func__);
8639
8640 return ret;
8641}
Jeff Johnson295189b2012-06-20 16:38:30 -07008642#ifdef FEATURE_WLAN_SCAN_PNO
8643
8644/*Max Len for PNO notification*/
8645#define MAX_PNO_NOTIFY_LEN 100
8646void found_pref_network_cb (void *callbackContext,
8647 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8648{
8649 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8650 union iwreq_data wrqu;
8651 char buf[MAX_PNO_NOTIFY_LEN+1];
8652
8653 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8654 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8655
8656 // create the event
8657 memset(&wrqu, 0, sizeof(wrqu));
8658 memset(buf, 0, sizeof(buf));
8659
8660 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8661 pPrefNetworkFoundInd->ssId.ssId,
8662 (unsigned int)pPrefNetworkFoundInd->rssi);
8663
8664 wrqu.data.pointer = buf;
8665 wrqu.data.length = strlen(buf);
8666
8667 // send the event
8668
8669 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8670
8671}
8672
8673
8674/*string based input*/
8675VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8676 union iwreq_data *wrqu, char *extra, int nOffset)
8677{
8678 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308679 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008680 /* pnoRequest is a large struct, so we make it static to avoid stack
8681 overflow. This API is only invoked via ioctl, so it is
8682 serialized by the kernel rtnl_lock and hence does not need to be
8683 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308684 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008685 char *ptr;
8686 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308687 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8689
8690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8691 "PNO data len %d data %s",
8692 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008693 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008694
8695 if (wrqu->data.length <= nOffset )
8696 {
8697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8698 return VOS_STATUS_E_FAILURE;
8699 }
8700
8701 pnoRequest.enable = 0;
8702 pnoRequest.ucNetworksCount = 0;
8703 /*-----------------------------------------------------------------------
8704 Input is string based and expected to be like this:
8705
8706 <enabled> <netw_count>
8707 for each network:
8708 <ssid_len> <ssid> <authentication> <encryption>
8709 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8710 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8711
8712 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008713 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 -07008714
8715 this translates into:
8716 -----------------------------
8717 enable PNO
8718 look for 2 networks:
8719 test - with authentication type 0 and encryption type 0,
8720 that can be found on 3 channels: 1 6 and 11 ,
8721 SSID bcast type is unknown (directed probe will be sent if AP not found)
8722 and must meet -40dBm RSSI
8723
8724 test2 - with auth and enrytption type 4/4
8725 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
8726 bcast type is non-bcast (directed probe will be sent)
8727 and must not meet any RSSI threshold
8728
Jeff Johnson8301aa12013-03-28 14:27:29 -07008729 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08008731 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008732
Wilson Yang623f6592013-10-08 16:33:37 -07008733 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
8734 {
8735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8736 "PNO enable input is not valid %s",ptr);
8737 return VOS_STATUS_E_FAILURE;
8738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008739
8740 if ( 0 == pnoRequest.enable )
8741 {
8742 /*Disable PNO*/
8743 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05308744 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8745 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 pAdapter->sessionId,
8747 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308748 if (eHAL_STATUS_SUCCESS != status)
8749 {
8750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8751 "%s: failed to disable PNO", __func__);
8752 return VOS_STATUS_E_FAILURE;
8753 }
8754 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 return VOS_STATUS_SUCCESS;
8756 }
8757
c_hpothu37f21312014-04-09 21:49:54 +05308758 if (TRUE == pHddCtx->isPnoEnable)
8759 {
8760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8761 FL("already PNO is enabled"));
8762 return -EBUSY;
8763 }
8764 pHddCtx->isPnoEnable = TRUE;
8765
Jeff Johnson295189b2012-06-20 16:38:30 -07008766 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07008767
8768 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
8769 {
8770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8771 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308772 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008774
8775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8776 "PNO enable %d networks count %d offset %d",
8777 pnoRequest.enable,
8778 pnoRequest.ucNetworksCount,
8779 nOffset);
8780
8781 /* Parameters checking:
8782 ucNetworksCount has to be larger than 0*/
8783 if (( 0 == pnoRequest.ucNetworksCount ) ||
8784 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8785 {
8786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05308787 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008788 }
8789
8790 ptr += nOffset;
8791
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308792 pnoRequest.aNetworks =
8793 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8794 if (pnoRequest.aNetworks == NULL)
8795 {
8796 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8797 FL("failed to allocate memory aNetworks %u"),
8798 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8799 goto error;
8800 }
8801 vos_mem_zero(pnoRequest.aNetworks,
8802 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8803
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
8805 {
8806
8807 pnoRequest.aNetworks[i].ssId.length = 0;
8808
Wilson Yang623f6592013-10-08 16:33:37 -07008809 ucParams = sscanf(ptr,"%hhu %n",
8810 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
8811
8812 if (1 != ucParams)
8813 {
8814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8815 "PNO ssid length input is not valid %s",ptr);
8816 return VOS_STATUS_E_FAILURE;
8817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008818
8819 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
8820 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
8821 {
8822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8823 "SSID Len %d is not correct for network %d",
8824 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05308825 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008826 }
8827
8828 /*Advance to SSID*/
8829 ptr += nOffset;
8830
Jeff Johnson8301aa12013-03-28 14:27:29 -07008831 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08008832 pnoRequest.aNetworks[i].ssId.length);
8833 ptr += pnoRequest.aNetworks[i].ssId.length;
8834
Jeff Johnson02797792013-10-26 19:17:13 -07008835 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08008836 &(pnoRequest.aNetworks[i].authentication),
8837 &(pnoRequest.aNetworks[i].encryption),
8838 &(pnoRequest.aNetworks[i].ucChannelCount),
8839 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008840
Wilson Yang623f6592013-10-08 16:33:37 -07008841 if ( 3 != ucParams )
8842 {
8843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8844 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308845 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008846 }
8847
Jeff Johnson295189b2012-06-20 16:38:30 -07008848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008849 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08008850 "auth %d encry %d channel count %d offset %d",
8851 pnoRequest.aNetworks[i].ssId.length,
8852 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
8853 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
8854 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
8855 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
8856 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
8857 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
8858 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
8859 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
8860 pnoRequest.aNetworks[i].authentication,
8861 pnoRequest.aNetworks[i].encryption,
8862 pnoRequest.aNetworks[i].ucChannelCount,
8863 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07008864
Jeff Johnson295189b2012-06-20 16:38:30 -07008865 /*Advance to channel list*/
8866 ptr += nOffset;
8867
Wilson Yang623f6592013-10-08 16:33:37 -07008868 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 {
8870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8871 "Incorrect number of channels");
8872 return VOS_STATUS_E_FAILURE;
8873 }
8874
8875 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
8876 {
8877 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
8878 {
Wilson Yang623f6592013-10-08 16:33:37 -07008879 if (1 != sscanf(ptr,"%hhu %n",
8880 &(pnoRequest.aNetworks[i].aChannels[j]),
8881 &nOffset))
8882 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8883 "PNO network channel input is not valid %s",ptr);
8884 return VOS_STATUS_E_FAILURE;
8885 }
8886 /*Advance to next channel number*/
8887 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008888 }
8889 }
8890
Jeff Johnson02797792013-10-26 19:17:13 -07008891 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07008892 &(pnoRequest.aNetworks[i].bcastNetwType),
8893 &nOffset))
8894 {
8895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8896 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308897 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008899
8900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8901 "PNO bcastNetwType %d offset %d",
8902 pnoRequest.aNetworks[i].bcastNetwType,
8903 nOffset );
8904
8905 /*Advance to rssi Threshold*/
8906 ptr += nOffset;
8907
Wilson Yang623f6592013-10-08 16:33:37 -07008908 if (1 != sscanf(ptr,"%hhu %n",
8909 &(pnoRequest.aNetworks[i].rssiThreshold),
8910 &nOffset))
8911 {
8912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8913 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308914 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008916
8917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8918 "PNO rssi %d offset %d",
8919 pnoRequest.aNetworks[i].rssiThreshold,
8920 nOffset );
8921 /*Advance to next network*/
8922 ptr += nOffset;
8923 }/*For ucNetworkCount*/
8924
8925 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07008926 &(pnoRequest.scanTimers.ucScanTimersCount),
8927 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008928
8929 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07008930 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07008931 {
8932 ptr += nOffset;
8933
Jeff Johnson8301aa12013-03-28 14:27:29 -07008934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8935 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 pnoRequest.scanTimers.ucScanTimersCount,
8937 nOffset );
8938
8939 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
8940 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07008941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05308943 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 }
8945
8946 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
8947 {
Jeff Johnson02797792013-10-26 19:17:13 -07008948 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07008949 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
8950 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
8951 &nOffset);
8952
Wilson Yang623f6592013-10-08 16:33:37 -07008953 if (2 != ucParams)
8954 {
8955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8956 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05308957 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008958 }
8959
Jeff Johnson8301aa12013-03-28 14:27:29 -07008960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8961 "PNO Timer value %d Timer repeat %d offset %d",
8962 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07008963 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
8964 nOffset );
8965
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 ptr += nOffset;
8967 }
8968
8969 }
8970 else
8971 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07008972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8973 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008974 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
8975
8976 /*Scan timers defaults to 5 minutes*/
8977 pnoRequest.scanTimers.ucScanTimersCount = 1;
8978 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
8979 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
8980 }
8981
Wilson Yang623f6592013-10-08 16:33:37 -07008982 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008983
8984 pnoRequest.modePNO = ucMode;
8985 /*for LA we just expose suspend option*/
8986 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
8987 {
8988 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
8989 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308990 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
8991 if (pnoRequest.p24GProbeTemplate == NULL){
8992 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8993 FL("failed to allocate memory p24GProbeTemplate %u"),
8994 SIR_PNO_MAX_PB_REQ_SIZE);
8995 goto error;
8996 }
8997
8998 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
8999 if (pnoRequest.p5GProbeTemplate == NULL){
9000 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9001 FL("failed to allocate memory p5GProbeTemplate %u"),
9002 SIR_PNO_MAX_PB_REQ_SIZE);
9003 goto error;
9004 }
9005
9006 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9007 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009008
c_hpothu37f21312014-04-09 21:49:54 +05309009 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009010 pAdapter->sessionId,
9011 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309012 if (eHAL_STATUS_SUCCESS == status)
9013 {
9014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9015 "%s: PNO enabled", __func__);
9016 return VOS_STATUS_SUCCESS;
9017 }
9018error:
9019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9020 "%s: Failed to enable PNO", __func__);
9021 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309022 if (pnoRequest.aNetworks)
9023 vos_mem_free(pnoRequest.aNetworks);
9024 if (pnoRequest.p24GProbeTemplate)
9025 vos_mem_free(pnoRequest.p24GProbeTemplate);
9026 if (pnoRequest.p5GProbeTemplate)
9027 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309028 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009029}/*iw_set_pno*/
9030
9031VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9032 union iwreq_data *wrqu, char *extra, int nOffset)
9033{
9034 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9035 v_U8_t rssiThreshold = 0;
9036 v_U8_t nRead;
9037
Arif Hussain7adce1b2013-11-11 22:59:34 -08009038 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009039 &rssiThreshold);
9040
9041 if ( 1 != nRead )
9042 {
9043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9044 "Incorrect format");
9045 return VOS_STATUS_E_FAILURE;
9046 }
9047
9048 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9049 return VOS_STATUS_SUCCESS;
9050}
9051
9052
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309053static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009054 struct iw_request_info *info,
9055 union iwreq_data *wrqu, char *extra)
9056{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309057 hdd_adapter_t *pAdapter;
9058 hdd_context_t *pHddCtx;
9059 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309060 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309061
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309062 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309063 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9064 if (NULL == pAdapter)
9065 {
9066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9067 "%s: Adapter is NULL",__func__);
9068 return -EINVAL;
9069 }
9070
9071 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9072 ret = wlan_hdd_validate_context(pHddCtx);
9073 if (0 != ret)
9074 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309075 return ret;
9076 }
9077
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009078
9079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009081
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309082 status = iw_set_pno(dev,info,wrqu,extra,0);
9083
9084 EXIT();
9085 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009086}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309087
9088static int iw_set_pno_priv(struct net_device *dev,
9089 struct iw_request_info *info,
9090 union iwreq_data *wrqu, char *extra)
9091{
9092 int ret;
9093
9094 vos_ssr_protect(__func__);
9095 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9096 vos_ssr_unprotect(__func__);
9097
9098 return ret;
9099}
Jeff Johnson295189b2012-06-20 16:38:30 -07009100#endif /*FEATURE_WLAN_SCAN_PNO*/
9101
9102//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309103int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009104{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309105 hdd_adapter_t *pAdapter;
9106 tHalHandle hHal;
9107 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309108 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309109 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309110 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009111 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309112 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309113 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309114 tpAniSirGlobal pMac;
9115 int retval = 0;
9116
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309117 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309118 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9119 if (NULL == pAdapter)
9120 {
9121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9122 "%s: Adapter is NULL",__func__);
9123 return -EINVAL;
9124 }
9125 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9126 retval = wlan_hdd_validate_context(pHddCtx);
9127 if (0 != retval)
9128 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309129 return retval;
9130 }
9131 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9132 if (NULL == hHal)
9133 {
9134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9135 "%s: Hal Context is NULL",__func__);
9136 return -EINVAL;
9137 }
9138 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009139
Atul Mittal54378cb2014-04-02 16:51:50 +05309140 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 {
9142 case WLAN_HDD_UI_BAND_AUTO:
9143 band = eCSR_BAND_ALL;
9144 break;
9145 case WLAN_HDD_UI_BAND_5_GHZ:
9146 band = eCSR_BAND_5G;
9147 break;
9148 case WLAN_HDD_UI_BAND_2_4_GHZ:
9149 band = eCSR_BAND_24;
9150 break;
9151 default:
9152 band = eCSR_BAND_MAX;
9153 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309154 connectedBand =
9155 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009156
Atul Mittal54378cb2014-04-02 16:51:50 +05309157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009158 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009159
9160 if (band == eCSR_BAND_MAX)
9161 {
9162 /* Received change band request with invalid band value */
9163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309164 "%s: Invalid band value %u", __func__, ui_band);
9165 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009166 }
9167
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309168 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
9169 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
9170 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
9171 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009173 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009174 band, pHddCtx->cfg_ini->nBandCapability);
9175 return -EIO;
9176 }
9177
Jeff Johnson295189b2012-06-20 16:38:30 -07009178 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9179 {
9180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9181 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009182 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 return -EIO;
9184 }
9185
9186 if (currBand != band)
9187 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309188 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309189 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309190 /* Return failure if current country code is world regulatory domain*/
9191 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9192 pMac->scan.countryCodeCurrent[1] == '0') )
9193 {
9194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9195 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309196 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309197 return -EAGAIN;
9198 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309199 }
9200
Jeff Johnson295189b2012-06-20 16:38:30 -07009201 /* Change band request received.
9202 * Abort pending scan requests, flush the existing scan results,
9203 * and change the band capability
9204 */
9205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9206 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009207 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009208
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309209 /* We need to change the band and flush the scan results here itself
9210 * as we may get timeout for disconnection in which we will return
9211 * with out doing any of these
9212 */
9213 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9214 {
9215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9216 "%s: failed to set the band value to %u ",
9217 __func__, band);
9218 return -EINVAL;
9219 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309220 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9221 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309222 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309223 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9224 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309225 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309226 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9227 * information available in NV so to get the channel information from kernel
9228 * we need to send regulatory hint for the currunt country
9229 * And to set the same country again we need to set the dummy country
9230 * first and then the actual country.
9231 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309232#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9233 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9234#else
9235 regulatory_hint_user("00");
9236#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309237 wait_result = wait_for_completion_interruptible_timeout(
9238 &pHddCtx->linux_reg_req,
9239 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9240
9241 /* if the country information does not exist with the kernel,
9242 then the driver callback would not be called */
9243
9244 if (wait_result >= 0)
9245 {
9246 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9247 "runtime country code is found in kernel db");
9248 }
9249 else
9250 {
9251 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9252 "runtime country code is not found"
9253 " in kernel db");
9254 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309255
9256 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309257
9258 /*
9259 * Update 11dcountry and current country here as the hint
9260 * with 00 results in 11d and current country with 00
9261 */
9262 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9263 WNI_CFG_COUNTRY_CODE_LEN);
9264 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9265 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309266#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9267 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9268#else
9269 regulatory_hint_user(curr_country);
9270#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309271 wait_result = wait_for_completion_interruptible_timeout(
9272 &pHddCtx->linux_reg_req,
9273 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9274
9275 /* if the country information does not exist with the kernel,
9276 then the driver callback would not be called */
9277 if (wait_result >= 0)
9278 {
9279 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9280 "runtime country code is found in kernel db");
9281 }
9282 else
9283 {
9284 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9285 "runtime country code is not found"
9286 " in kernel db");
9287 }
9288
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309289 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
9290 }
9291 else
9292 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309293#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309294 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9295 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309296#else
9297 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9298#endif
9299
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309300 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309301 pScanInfo = &pHddCtx->scan_info;
9302 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9303 {
9304 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9305 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9306 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309307 sme_FilterScanResults(hHal, pAdapter->sessionId);
9308
9309 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309310 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9311 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009313 eHalStatus status = eHAL_STATUS_SUCCESS;
9314 long lrc;
9315
9316 /* STA already connected on current band, So issue disconnect first,
9317 * then change the band*/
9318
9319 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309320 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309321 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009322
Jeff Johnson295189b2012-06-20 16:38:30 -07009323 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9324
9325 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9326 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9327
Jeff Johnson43971f52012-07-17 12:26:56 -07009328 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009329 {
9330 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009331 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009332 __func__, (int)status );
9333 return -EINVAL;
9334 }
9335
9336 lrc = wait_for_completion_interruptible_timeout(
9337 &pAdapter->disconnect_comp_var,
9338 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9339
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309340 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009341
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009342 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009343 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009344
9345 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9346 }
9347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309349 EXIT();
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309350 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009351}
9352
Atul Mittal54378cb2014-04-02 16:51:50 +05309353int hdd_setBand_helper(struct net_device *dev, const char *command)
9354{
9355 u8 band;
9356
9357 /*convert the band value from ascii to integer*/
9358 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9359
9360 return hdd_setBand(dev, band);
9361
9362}
9363
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309364static int __iw_set_band_config(struct net_device *dev,
9365 struct iw_request_info *info,
9366 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009367{
Atul Mittal54378cb2014-04-02 16:51:50 +05309368 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009369
Arif Hussain0273cba2014-01-07 20:58:29 -08009370 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009371
Atul Mittal54378cb2014-04-02 16:51:50 +05309372 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009373}
9374
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309375static int iw_set_band_config(struct net_device *dev,
9376 struct iw_request_info *info,
9377 union iwreq_data *wrqu, char *extra)
9378{
9379 int ret;
9380
9381 vos_ssr_protect(__func__);
9382 ret = __iw_set_band_config(dev, info, wrqu, extra);
9383 vos_ssr_unprotect(__func__);
9384
9385 return ret;
9386}
9387
9388static int __iw_set_power_params_priv(struct net_device *dev,
9389 struct iw_request_info *info,
9390 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009391{
Arif Hussain0273cba2014-01-07 20:58:29 -08009392 int ret;
9393 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9395 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009396 /* ODD number is used for set, copy data using copy_from_user */
9397 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9398 wrqu->data.length);
9399 if (NULL == ptr)
9400 {
9401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9402 "mem_alloc_copy_from_user_helper fail");
9403 return -ENOMEM;
9404 }
9405
9406 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9407 kfree(ptr);
9408 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009409}
9410
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309411static int iw_set_power_params_priv(struct net_device *dev,
9412 struct iw_request_info *info,
9413 union iwreq_data *wrqu, char *extra)
9414{
9415 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009416
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309417 vos_ssr_protect(__func__);
9418 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9419 vos_ssr_unprotect(__func__);
9420
9421 return ret;
9422}
Jeff Johnson295189b2012-06-20 16:38:30 -07009423
9424/*string based input*/
9425VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9426 union iwreq_data *wrqu, char *extra, int nOffset)
9427{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309428 hdd_adapter_t *pAdapter;
9429 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009430 tSirSetPowerParamsReq powerRequest;
9431 char *ptr;
9432 v_U8_t ucType;
9433 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309434 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009435
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309436 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309437 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9438 if (NULL == pAdapter)
9439 {
9440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9441 "%s: Adapter is NULL",__func__);
9442 return -EINVAL;
9443 }
9444
9445 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9446 ret = wlan_hdd_validate_context(pHddCtx);
9447 if (0 != ret)
9448 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309449 return ret;
9450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9452 "Power Params data len %d data %s",
9453 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009454 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009455
9456 if (wrqu->data.length <= nOffset )
9457 {
9458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9459 return VOS_STATUS_E_FAILURE;
9460 }
9461
9462 uTotalSize = wrqu->data.length - nOffset;
9463
9464 /*-----------------------------------------------------------------------
9465 Input is string based and expected to be like this:
9466
9467 <param_type> <param_value> <param_type> <param_value> ...
9468
9469 e.g:
9470 1 2 2 3 3 0 4 1 5 1
9471
9472 e.g. setting just a few:
9473 1 2 4 1
9474
9475 parameter types:
9476 -----------------------------
9477 1 - Ignore DTIM
9478 2 - Listen Interval
9479 3 - Broadcast Multicas Filter
9480 4 - Beacon Early Termination
9481 5 - Beacon Early Termination Interval
9482 -----------------------------------------------------------------------*/
9483 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9484 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9485 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9486 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9487 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9488
Arif Hussain7adce1b2013-11-11 22:59:34 -08009489 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009490
9491 while ( uTotalSize )
9492 {
Wilson Yang6f971452013-10-08 15:00:00 -07009493 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9494 {
9495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9496 "Invalid input parameter type %s",ptr);
9497 return VOS_STATUS_E_FAILURE;
9498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009499
9500 uTotalSize -= nOffset;
9501
9502 if (!uTotalSize)
9503 {
9504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009505 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 ucType, nOffset);
9507 return VOS_STATUS_E_FAILURE;
9508 }
9509
9510 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009511
Jeff Johnson02797792013-10-26 19:17:13 -07009512 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009513 {
9514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9515 "Invalid input parameter value %s",ptr);
9516 return VOS_STATUS_E_FAILURE;
9517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009518
9519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9520 "Power request parameter %d value %d offset %d",
9521 ucType, uValue, nOffset);
9522
9523 switch (ucType)
9524 {
9525 case eSIR_IGNORE_DTIM:
9526 powerRequest.uIgnoreDTIM = uValue;
9527 break;
9528 case eSIR_LISTEN_INTERVAL:
9529 powerRequest.uListenInterval = uValue;
9530 break;
9531 case eSIR_MCAST_BCAST_FILTER:
9532 powerRequest.uBcastMcastFilter = uValue;
9533 break;
9534 case eSIR_ENABLE_BET:
9535 powerRequest.uEnableBET = uValue;
9536 break;
9537 case eSIR_BET_INTERVAL:
9538 powerRequest.uBETInterval = uValue;
9539 break;
9540 default:
9541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009542 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 ucType, uValue, nOffset);
9544 return VOS_STATUS_E_FAILURE;
9545 }
9546
9547 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9549 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009550 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009552 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009553 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009554 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9555 {
9556 uTotalSize = 0;
9557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009558
9559 }/*Go for as long as we have a valid string*/
9560
9561 /* put the device into full power*/
9562 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9563
9564 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009565 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009566
9567 /* put the device back to power save*/
9568 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9569
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309570 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009571 return VOS_STATUS_SUCCESS;
9572}/*iw_set_power_params*/
9573
Atul Mittalc0f739f2014-07-31 13:47:47 +05309574// tdlsoffchan
9575#ifdef FEATURE_WLAN_TDLS
9576
Atul Mittal87ec2422014-09-24 13:12:50 +05309577int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309578{
9579 if (offchannel < 0 || offchannel > 165)
9580 {
9581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9582 __func__, offchannel);
9583 return -1;
9584
9585 }
9586
9587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9588 __func__, tdlsOffCh, offchannel);
9589
9590 tdlsOffCh = offchannel;
9591 return 0;
9592}
9593
Atul Mittal87ec2422014-09-24 13:12:50 +05309594int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309595{
9596 if (offchanoffset == 0)
9597 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309598 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9600 __func__, tdlsOffChBwOffset);
9601
9602 return 0;
9603
9604 }
9605
9606 if ( offchanoffset == 40 )
9607 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309608 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9610 __func__, tdlsOffChBwOffset);
9611
9612 return 0;
9613
9614 }
9615 if (offchanoffset == -40)
9616 {
9617 tdlsOffChBwOffset = 3;
9618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9619 __func__, tdlsOffChBwOffset);
9620
9621 return 0;
9622
9623 }
9624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9625 __func__, offchanoffset);
9626 return -1;
9627}
9628
Atul Mittal87ec2422014-09-24 13:12:50 +05309629int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309630{
9631 hddTdlsPeer_t *connPeer = NULL;
9632 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9633 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9634
9635 if (offchanmode < 0 || offchanmode > 4)
9636 {
9637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9638 "%s: Invalid tdls off channel mode %d",
9639 __func__, offchanmode);
9640 return -1;
9641 }
9642
9643 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9644 {
9645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9646 "%s: tdls off channel mode req in not associated state %d",
9647 __func__, offchanmode);
9648 return -1;
9649 }
9650
9651 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9652 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9653 {
9654 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309655 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309656 if (NULL == connPeer) {
9657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9658 "%s: No TDLS Connected Peer", __func__);
9659 return -1;
9660 }
9661 }
9662 else
9663 {
9664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9665 "%s: TDLS Connection not supported", __func__);
9666 return -1;
9667 }
9668
9669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9670 ("%s: TDLS Channel Switch in swmode=%d"),
9671 __func__, offchanmode);
9672
9673 switch (offchanmode)
9674 {
9675 case 1:/*Enable*/
9676 case 2:/*Disable*/
9677 {
9678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9679 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9680 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9681 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9682 {
9683
9684 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9685 pAdapter->sessionId, connPeer->peerMac,
9686 tdlsOffCh, tdlsOffChBwOffset,
9687 offchanmode);
9688 }
9689 else
9690 {
9691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9692 "%s: TDLS Off Channel not supported", __func__);
9693 return -1;
9694 }
9695 break;
9696 }
9697 case 3:
9698 {
9699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9700 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
9701 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9702
9703 break;
9704 }
9705 case 4:
9706 {
9707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9708 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
9709 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9710 break;
9711 }
9712 default:
9713 {
9714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9715 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
9716 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9717 break;
9718 }
9719
9720 }
9721
9722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
9723 __func__, offchanmode);
9724 return 0;
9725}
Atul Mittalc0f739f2014-07-31 13:47:47 +05309726#endif
9727
Jeff Johnson295189b2012-06-20 16:38:30 -07009728
9729// Define the Wireless Extensions to the Linux Network Device structure
9730// A number of these routines are NULL (meaning they are not implemented.)
9731
9732static const iw_handler we_handler[] =
9733{
9734 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9735 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9736 (iw_handler) NULL, /* SIOCSIWNWID */
9737 (iw_handler) NULL, /* SIOCGIWNWID */
9738 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9739 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9740 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9741 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9742 (iw_handler) NULL, /* SIOCSIWSENS */
9743 (iw_handler) NULL, /* SIOCGIWSENS */
9744 (iw_handler) NULL, /* SIOCSIWRANGE */
9745 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9746 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
9747 (iw_handler) NULL, /* SIOCGIWPRIV */
9748 (iw_handler) NULL, /* SIOCSIWSTATS */
9749 (iw_handler) NULL, /* SIOCGIWSTATS */
9750 iw_handler_set_spy, /* SIOCSIWSPY */
9751 iw_handler_get_spy, /* SIOCGIWSPY */
9752 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
9753 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
9754 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9755 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9756 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9757 (iw_handler) NULL, /* SIOCGIWAPLIST */
9758 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9759 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9760 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9761 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9762 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9763 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9764 (iw_handler) NULL, /* -- hole -- */
9765 (iw_handler) NULL, /* -- hole -- */
9766 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9767 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9768 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
9769 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
9770 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9771 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9772 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9773 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9774 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9775 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9776 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9777 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9778 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9779 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9780 (iw_handler) NULL, /* -- hole -- */
9781 (iw_handler) NULL, /* -- hole -- */
9782 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9783 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9784 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9785 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9786 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9787 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9788 (iw_handler) NULL, /* SIOCSIWPMKSA */
9789};
9790
9791static const iw_handler we_private[] = {
9792
9793 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
9794 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
9795 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
9796 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
9797 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9798 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +05309799 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07009800 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9801 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9802 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07009803#ifdef FEATURE_OEM_DATA_SUPPORT
9804 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
9805 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
9806#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009807
Jeff Johnson295189b2012-06-20 16:38:30 -07009808#ifdef WLAN_FEATURE_VOWIFI_11R
9809 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
9810#endif
9811 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9812 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9813 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
9814#ifdef WLAN_FEATURE_PACKET_FILTERING
9815 ,
9816 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
9817#endif
9818#ifdef FEATURE_WLAN_SCAN_PNO
9819 ,
9820 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
9821#endif
9822 ,
9823 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9824 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
9825 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
9826 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07009827 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07009828};
9829
9830/*Maximum command length can be only 15 */
9831static const struct iw_priv_args we_private_args[] = {
9832
9833 /* handlers for main ioctl */
9834 { WLAN_PRIV_SET_INT_GET_NONE,
9835 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9836 0,
9837 "" },
9838
9839 /* handlers for sub-ioctl */
9840 { WE_SET_11D_STATE,
9841 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9842 0,
9843 "set11Dstate" },
9844
9845 { WE_WOWL,
9846 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9847 0,
9848 "wowl" },
9849
9850 { WE_SET_POWER,
9851 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9852 0,
9853 "setPower" },
9854
9855 { WE_SET_MAX_ASSOC,
9856 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9857 0,
9858 "setMaxAssoc" },
9859
9860 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
9861 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9862 0,
9863 "setAutoChannel" },
9864
9865 { WE_SET_DATA_INACTIVITY_TO,
9866 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9867 0,
9868 "inactivityTO" },
9869
9870 { WE_SET_MAX_TX_POWER,
9871 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9872 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07009873 "setMaxTxPower" },
9874
9875 { WE_SET_MAX_TX_POWER_2_4,
9876 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9877 0,
9878 "setTxMaxPower2G" },
9879
9880 { WE_SET_MAX_TX_POWER_5_0,
9881 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9882 0,
9883 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07009884
9885 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
9886 * as well to keep same syntax as in SAP. Now onwards, STA
9887 * will support both */
9888 { WE_SET_MAX_TX_POWER,
9889 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9890 0,
9891 "setTxMaxPower" },
9892
Jeff Johnson295189b2012-06-20 16:38:30 -07009893 /* set Higher DTIM Transition (DTIM1 to DTIM3)
9894 * 1 = enable and 0 = disable */
9895 {
9896 WE_SET_HIGHER_DTIM_TRANSITION,
9897 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9898 0,
9899 "setHDtimTransn" },
9900
9901 { WE_SET_TM_LEVEL,
9902 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009903 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 "setTmLevel" },
9905
Kiet Lam46b8e4e2013-11-06 21:49:53 +05309906 { WE_ENABLE_STRICT_FCC_REG,
9907 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9908 0,
9909 "setStrictFCCreg" },
9910
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08009911 { WE_SET_DEBUG_LOG,
9912 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9913 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +05309914#ifdef FEATURE_WLAN_TDLS
9915 {
9916 WE_SET_TDLS_OFF_CHAN,
9917 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9918 0,
9919 "tdlsoffchan" },
9920 {
9921 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
9922 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9923 0,
9924 "tdlsecchnoffst" },
9925 {
9926 WE_SET_TDLS_OFF_CHAN_MODE,
9927 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9928 0,
9929 "tdlsoffchnmode" },
9930#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08009931
Peng Xu2446a892014-09-05 17:21:18 +05309932 { WE_SET_SCAN_BAND_PREFERENCE,
9933 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9934 0, "set_scan_pref" },
9935
Abhishek Singh01c73d12015-03-12 15:13:44 +05309936 { WE_SET_MIRACAST_VENDOR_CONFIG,
9937 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9938 0, "setMiracstConf" },
9939
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 /* handlers for main ioctl */
9941 { WLAN_PRIV_SET_NONE_GET_INT,
9942 0,
9943 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9944 "" },
9945
9946 /* handlers for sub-ioctl */
9947 { WE_GET_11D_STATE,
9948 0,
9949 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9950 "get11Dstate" },
9951
9952 { WE_IBSS_STATUS,
9953 0,
9954 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9955 "getAdhocStatus" },
9956
9957 { WE_PMC_STATE,
9958 0,
9959 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9960 "pmcState" },
9961
9962 { WE_GET_WLAN_DBG,
9963 0,
9964 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9965 "getwlandbg" },
9966
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 { WE_GET_MAX_ASSOC,
9968 0,
9969 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9970 "getMaxAssoc" },
9971
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 { WE_GET_WDI_DBG,
9973 0,
9974 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9975 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009976
9977 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
9978 0,
9979 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9980 "getAutoChannel" },
9981
9982 { WE_GET_CONCURRENCY_MODE,
9983 0,
9984 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9985 "getconcurrency" },
9986
Peng Xu2446a892014-09-05 17:21:18 +05309987 { WE_GET_SCAN_BAND_PREFERENCE,
9988 0,
9989 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9990 "get_scan_pref"},
9991
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 /* handlers for main ioctl */
9993 { WLAN_PRIV_SET_CHAR_GET_NONE,
9994 IW_PRIV_TYPE_CHAR| 512,
9995 0,
9996 "" },
9997
9998 /* handlers for sub-ioctl */
9999 { WE_WOWL_ADD_PTRN,
10000 IW_PRIV_TYPE_CHAR| 512,
10001 0,
10002 "wowlAddPtrn" },
10003
10004 { WE_WOWL_DEL_PTRN,
10005 IW_PRIV_TYPE_CHAR| 512,
10006 0,
10007 "wowlDelPtrn" },
10008
10009#if defined WLAN_FEATURE_VOWIFI
10010 /* handlers for sub-ioctl */
10011 { WE_NEIGHBOR_REPORT_REQUEST,
10012 IW_PRIV_TYPE_CHAR | 512,
10013 0,
10014 "neighbor" },
10015#endif
10016 { WE_SET_AP_WPS_IE,
10017 IW_PRIV_TYPE_CHAR| 512,
10018 0,
10019 "set_ap_wps_ie" },
10020
10021 { WE_SET_CONFIG,
10022 IW_PRIV_TYPE_CHAR| 512,
10023 0,
10024 "setConfig" },
10025
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010026 { WE_SET_ENCRYPT_MSG,
10027 IW_PRIV_TYPE_CHAR| 512,
10028 0,
10029 "encryptMsg" },
10030
10031
Jeff Johnson295189b2012-06-20 16:38:30 -070010032 /* handlers for main ioctl */
10033 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10035 0,
10036 "" },
10037
10038 /* handlers for sub-ioctl */
10039 { WE_SET_WLAN_DBG,
10040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10041 0,
10042 "setwlandbg" },
10043
Jeff Johnson295189b2012-06-20 16:38:30 -070010044 { WE_SET_WDI_DBG,
10045 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10046 0,
10047 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010048
10049 { WE_SET_SAP_CHANNELS,
10050 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10051 0,
10052 "setsapchannels" },
10053
10054 /* handlers for main ioctl */
10055 { WLAN_PRIV_GET_CHAR_SET_NONE,
10056 0,
10057 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10058 "" },
10059
10060 /* handlers for sub-ioctl */
10061 { WE_WLAN_VERSION,
10062 0,
10063 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10064 "version" },
10065 { WE_GET_STATS,
10066 0,
10067 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10068 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010069 { WE_GET_STATES,
10070 0,
10071 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10072 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010073 { WE_GET_CFG,
10074 0,
10075 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10076 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010077#ifdef WLAN_FEATURE_11AC
10078 { WE_GET_RSSI,
10079 0,
10080 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10081 "getRSSI" },
10082#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010083#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010084 { WE_GET_ROAM_RSSI,
10085 0,
10086 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10087 "getRoamRSSI" },
10088#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 { WE_GET_WMM_STATUS,
10090 0,
10091 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10092 "getWmmStatus" },
10093 {
10094 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010095 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010096 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10097 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010098#ifdef FEATURE_WLAN_TDLS
10099 {
10100 WE_GET_TDLS_PEERS,
10101 0,
10102 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10103 "getTdlsPeers" },
10104#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010105#ifdef WLAN_FEATURE_11W
10106 {
10107 WE_GET_11W_INFO,
10108 0,
10109 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10110 "getPMFInfo" },
10111#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010112 { WE_GET_SNR,
10113 0,
10114 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10115 "getSNR" },
10116
Jeff Johnson295189b2012-06-20 16:38:30 -070010117 /* handlers for main ioctl */
10118 { WLAN_PRIV_SET_NONE_GET_NONE,
10119 0,
10120 0,
10121 "" },
10122
10123 /* handlers for sub-ioctl */
10124 { WE_CLEAR_STATS,
10125 0,
10126 0,
10127 "clearStats" },
10128 { WE_INIT_AP,
10129 0,
10130 0,
10131 "initAP" },
10132 { WE_STOP_AP,
10133 0,
10134 0,
10135 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010136#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010137 { WE_ENABLE_AMP,
10138 0,
10139 0,
10140 "enableAMP" },
10141 { WE_DISABLE_AMP,
10142 0,
10143 0,
10144 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010145#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010146 { WE_ENABLE_DXE_STALL_DETECT,
10147 0,
10148 0,
10149 "dxeStallDetect" },
10150 { WE_DISPLAY_DXE_SNAP_SHOT,
10151 0,
10152 0,
10153 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010154 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10155 0,
10156 0,
10157 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010158 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010159 WE_SET_REASSOC_TRIGGER,
10160 0,
10161 0,
10162 "reassoc" },
10163 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010164 WE_STOP_OBSS_SCAN,
10165 0,
10166 0,
10167 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010168 {
10169 WE_DUMP_ROAM_TIMER_LOG,
10170 0,
10171 0,
10172 "dumpRoamDelay" },
10173 {
10174 WE_RESET_ROAM_TIMER_LOG,
10175 0,
10176 0,
10177 "resetRoamDelay" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010178 /* handlers for main ioctl */
10179 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10180 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10181 0,
10182 "" },
10183
10184 /* handlers for sub-ioctl */
10185 { WE_LOG_DUMP_CMD,
10186 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10187 0,
10188 "dump" },
10189
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010190 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010191 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10192 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10193 0,
10194 "setdumplog" },
10195
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010196 { WE_MTRACE_DUMP_CMD,
10197 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10198 0,
10199 "dumplog" },
10200
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010201 /* handlers for sub ioctl */
10202 {
10203 WE_MCC_CONFIG_CREDENTIAL,
10204 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10205 0,
10206 "setMccCrdnl" },
10207
10208 /* handlers for sub ioctl */
10209 {
10210 WE_MCC_CONFIG_PARAMS,
10211 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10212 0,
10213 "setMccConfig" },
10214
Chilam NG571c65a2013-01-19 12:27:36 +053010215#ifdef FEATURE_WLAN_TDLS
10216 /* handlers for sub ioctl */
10217 {
10218 WE_TDLS_CONFIG_PARAMS,
10219 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10220 0,
10221 "setTdlsConfig" },
10222#endif
10223
Jeff Johnson295189b2012-06-20 16:38:30 -070010224 /* handlers for main ioctl */
10225 { WLAN_PRIV_ADD_TSPEC,
10226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10227 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10228 "addTspec" },
10229
10230 /* handlers for main ioctl */
10231 { WLAN_PRIV_DEL_TSPEC,
10232 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10233 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10234 "delTspec" },
10235
10236 /* handlers for main ioctl */
10237 { WLAN_PRIV_GET_TSPEC,
10238 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10239 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10240 "getTspec" },
10241
Jeff Johnsone7245742012-09-05 17:12:55 -070010242#ifdef FEATURE_OEM_DATA_SUPPORT
10243 /* handlers for main ioctl - OEM DATA */
10244 {
10245 WLAN_PRIV_SET_OEM_DATA_REQ,
10246 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10247 0,
10248 "set_oem_data_req" },
10249
10250 /* handlers for main ioctl - OEM DATA */
10251 {
10252 WLAN_PRIV_GET_OEM_DATA_RSP,
10253 0,
10254 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10255 "get_oem_data_rsp" },
10256#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010257
Jeff Johnson295189b2012-06-20 16:38:30 -070010258 /* handlers for main ioctl - host offload */
10259 {
10260 WLAN_PRIV_SET_HOST_OFFLOAD,
10261 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10262 0,
10263 "setHostOffload" },
10264
10265 {
10266 WLAN_GET_WLAN_STATISTICS,
10267 0,
10268 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10269 "getWlanStats" },
10270
10271 {
10272 WLAN_SET_KEEPALIVE_PARAMS,
10273 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10274 0,
10275 "setKeepAlive" },
10276#ifdef WLAN_FEATURE_PACKET_FILTERING
10277 {
10278 WLAN_SET_PACKET_FILTER_PARAMS,
10279 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10280 0,
10281 "setPktFilter" },
10282#endif
10283#ifdef FEATURE_WLAN_SCAN_PNO
10284 {
10285 WLAN_SET_PNO,
10286 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10287 0,
10288 "setpno" },
10289#endif
10290 {
10291 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010293 0,
10294 "SETBAND" },
10295 /* handlers for dynamic MC BC ioctl */
10296 {
10297 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010298 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010299 0,
10300 "setMCBCFilter" },
10301 {
10302 WLAN_PRIV_CLEAR_MCBC_FILTER,
10303 0,
10304 0,
10305 "clearMCBCFilter" },
10306 {
10307 WLAN_SET_POWER_PARAMS,
10308 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10309 0,
10310 "setpowerparams" },
10311 {
10312 WLAN_GET_LINK_SPEED,
10313 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010314 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010315};
10316
10317
10318
10319const struct iw_handler_def we_handler_def = {
10320 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10321 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10322 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10323
10324 .standard = (iw_handler *)we_handler,
10325 .private = (iw_handler *)we_private,
10326 .private_args = we_private_args,
10327 .get_wireless_stats = get_wireless_stats,
10328};
10329
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010330int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10331{
10332 v_U32_t cmd = 288; //Command to RIVA
10333 hdd_context_t *pHddCtx = NULL;
10334 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10335 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10336 /*
10337 *configMccParam : specify the bit which needs to be modified
10338 *allowed to update based on wlan_qcom_cfg.ini
10339 * configuration
10340 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10341 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10342 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10343 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10344 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10345 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10346 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10347 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10348 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10349 * Bit 9 : Reserved
10350 */
10351 switch (arg1)
10352 {
10353 //Update MCC SCHEDULE_TIME_SLICE parameter
10354 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10355 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10356 {
10357 if((arg2 >= 5) && (arg2 <= 20))
10358 {
10359 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10360 }
10361 else
10362 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010363 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010364 return 0;
10365 }
10366 }
10367 break;
10368
10369 //Update MCC MAX_NULL_SEND_TIME parameter
10370 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10371 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10372 {
10373 if((arg2 >= 1) && (arg2 <= 10))
10374 {
10375 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10376 }
10377 else
10378 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010379 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010380 return 0;
10381 }
10382 }
10383 break;
10384
10385 //Update MCC TX_EARLY_STOP_TIME parameter
10386 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10387 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10388 {
10389 if((arg2 >= 1) && (arg2 <= 10))
10390 {
10391 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10392 }
10393 else
10394 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010395 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010396 return 0;
10397 }
10398 }
10399 break;
10400
10401 //Update MCC RX_DRAIN_TIME parameter
10402 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10403 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10404 {
10405 if((arg2 >= 1) && (arg2 <= 10))
10406 {
10407 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10408 }
10409 else
10410 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010411 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010412 return 0;
10413 }
10414 }
10415 break;
10416
10417 //Update MCC CHANNEL_SWITCH_TIME parameter
10418 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10419 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10420 {
10421 if((arg2 >= 1) && (arg2 <= 20))
10422 {
10423 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10424 }
10425 else
10426 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010427 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010428 return 0;
10429 }
10430 }
10431 break;
10432
10433 //Update MCC MIN_CHANNEL_TIME parameter
10434 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10435 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10436 {
10437 if((arg2 >= 5) && (arg2 <= 20))
10438 {
10439 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10440 }
10441 else
10442 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010443 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010444 return 0;
10445 }
10446 }
10447 break;
10448
10449 //Update MCC PARK_BEFORE_TBTT parameter
10450 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10451 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10452 {
10453 if((arg2 >= 1) && (arg2 <= 5))
10454 {
10455 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10456 }
10457 else
10458 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010459 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010460 return 0;
10461 }
10462 }
10463 break;
10464
10465 //Update MCC MIN_AFTER_DTIM parameter
10466 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10467 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10468 {
10469 if((arg2 >= 5) && (arg2 <= 15))
10470 {
10471 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10472 }
10473 else
10474 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010475 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010476 return 0;
10477 }
10478 }
10479 break;
10480
10481 //Update MCC TOO_CLOSE_MARGIN parameter
10482 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10483 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10484 {
10485 if((arg2 >= 1) && (arg2 <= 3))
10486 {
10487 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10488 }
10489 else
10490 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010491 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010492 return 0;
10493 }
10494 }
10495 break;
10496
10497 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010498 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010499 __FUNCTION__,arg1);
10500 break;
10501 }
10502 return 0;
10503}
10504
Jeff Johnson295189b2012-06-20 16:38:30 -070010505int hdd_set_wext(hdd_adapter_t *pAdapter)
10506{
10507 hdd_wext_state_t *pwextBuf;
10508 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010509 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010510
10511 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10512
10513 // Now configure the roaming profile links. To SSID and bssid.
10514 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10515 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10516
10517 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10518 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10519
10520 /*Set the numOfChannels to zero to scan all the channels*/
10521 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10522 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10523
10524 /* Default is no encryption */
10525 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10526 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10527
10528 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10529 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10530
10531 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10532
10533 /* Default is no authentication */
10534 pwextBuf->roamProfile.AuthType.numEntries = 1;
10535 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10536
10537 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10538 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10539
10540 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010541 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010542
10543 hdd_clearRoamProfileIe(pAdapter);
10544
10545 return VOS_STATUS_SUCCESS;
10546
10547 }
10548
10549int hdd_register_wext(struct net_device *dev)
10550 {
10551 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10552 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10553 VOS_STATUS status;
10554
10555 ENTER();
10556
10557 // Zero the memory. This zeros the profile structure.
10558 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10559
10560 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10561
10562
10563 status = hdd_set_wext(pAdapter);
10564
10565 if(!VOS_IS_STATUS_SUCCESS(status)) {
10566
Arif Hussain6d2a3322013-11-17 19:50:10 -080010567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010568 return eHAL_STATUS_FAILURE;
10569 }
10570
10571 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10572 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 return eHAL_STATUS_FAILURE;
10575 }
10576
10577 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10578 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010580 return eHAL_STATUS_FAILURE;
10581 }
10582
10583 // Register as a wireless device
10584 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10585
10586 EXIT();
10587 return 0;
10588}
10589
10590int hdd_UnregisterWext(struct net_device *dev)
10591{
c_hpothu2a13bc32015-01-21 12:48:54 +053010592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10593 if (dev != NULL)
10594 {
10595 rtnl_lock();
10596 dev->wireless_handlers = NULL;
10597 rtnl_unlock();
10598 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010599
Jeff Johnson295189b2012-06-20 16:38:30 -070010600 return 0;
10601}
10602
10603