blob: e8e8037e769926da81d57cee4ec9137358608f6d [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
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#ifdef DEBUG_ROAM_DELAY
106#include "vos_utils.h"
107#endif
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530108#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530109
Jeff Johnson295189b2012-06-20 16:38:30 -0700110#ifdef CONFIG_HAS_EARLYSUSPEND
111extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
112extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
113#endif
114
Jeff Johnsone7245742012-09-05 17:12:55 -0700115#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800116#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
119#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530120#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122
Atul Mittalc0f739f2014-07-31 13:47:47 +0530123// tdlsoffchan
124#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530125static int tdlsOffCh = 1;
126static int tdlsOffChBwOffset = 0;
127#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530128
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700129static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700130module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
131
Jeff Johnson295189b2012-06-20 16:38:30 -0700132/* To Validate Channel against the Frequency and Vice-Versa */
133static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
134 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
135 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
136 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
137 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
138 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
139 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
140 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800141 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
142 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700143
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800144#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700145
146/* Private ioctls and their sub-ioctls */
147#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
148#define WE_SET_11D_STATE 1
149#define WE_WOWL 2
150#define WE_SET_POWER 3
151#define WE_SET_MAX_ASSOC 4
152#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
153#define WE_SET_DATA_INACTIVITY_TO 6
154#define WE_SET_MAX_TX_POWER 7
155#define WE_SET_HIGHER_DTIM_TRANSITION 8
156#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530157#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700158#define WE_SET_MAX_TX_POWER_2_4 11
159#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800160/* Private IOCTL for debug connection issues */
161#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530162// tdlsoffchan
163#ifdef FEATURE_WLAN_TDLS
164#define WE_SET_TDLS_OFF_CHAN 14
165#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
166#define WE_SET_TDLS_OFF_CHAN_MODE 16
167#endif
Peng Xu2446a892014-09-05 17:21:18 +0530168#define WE_SET_SCAN_BAND_PREFERENCE 17
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
Jeff Johnson295189b2012-06-20 16:38:30 -0700235
Mukul Sharma84f27252014-07-14 18:11:42 +0530236#ifdef DEBUG_ROAM_DELAY
237#define WE_DUMP_ROAM_TIMER_LOG 12
238#define WE_RESET_ROAM_TIMER_LOG 13
239#endif
240
Jeff Johnson295189b2012-06-20 16:38:30 -0700241/* Private ioctls and their sub-ioctls */
242#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
243#define WE_LOG_DUMP_CMD 1
244
Jeff Johnson295189b2012-06-20 16:38:30 -0700245#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800246//IOCTL to configure MCC params
247#define WE_MCC_CONFIG_CREDENTIAL 3
248#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700249
Chilam NG571c65a2013-01-19 12:27:36 +0530250#ifdef FEATURE_WLAN_TDLS
251#define WE_TDLS_CONFIG_PARAMS 5
252#endif
253
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700254#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530255#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700256
Chilam Ng01120412013-02-19 18:32:21 -0800257#ifdef FEATURE_WLAN_TDLS
258#undef MAX_VAR_ARGS
259#define MAX_VAR_ARGS 10
260#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700261#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800262#endif
263
Jeff Johnson295189b2012-06-20 16:38:30 -0700264/* Private ioctls (with no sub-ioctls) */
265/* note that they must be odd so that they have "get" semantics */
266#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
267#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
268#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
269
Girish Gowli464c9c82014-06-09 19:47:53 +0530270/* (SIOCIWFIRSTPRIV + 8) is currently unused */
271/* (SIOCIWFIRSTPRIV + 16) is currently unused */
272/* (SIOCIWFIRSTPRIV + 10) is currently unused */
273/* (SIOCIWFIRSTPRIV + 12) is currently unused */
274/* (SIOCIWFIRSTPRIV + 14) is currently unused */
275/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700276
Jeff Johnsone7245742012-09-05 17:12:55 -0700277#ifdef FEATURE_OEM_DATA_SUPPORT
278/* Private ioctls for setting the measurement configuration */
279#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
280#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700282
283#ifdef WLAN_FEATURE_VOWIFI_11R
284#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
285#endif
286
287/* Private ioctl for setting the host offload feature */
288#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
289
290/* Private ioctl to get the statistics */
291#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
292
293/* Private ioctl to set the Keep Alive Params */
294#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
295#ifdef WLAN_FEATURE_PACKET_FILTERING
296/* Private ioctl to set the Packet Filtering Params */
297#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
298#endif
299
300#ifdef FEATURE_WLAN_SCAN_PNO
301/* Private ioctl to get the statistics */
302#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
303#endif
304
305#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
306
307#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
308#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700309/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
312#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
313
314#define WLAN_STATS_INVALID 0
315#define WLAN_STATS_RETRY_CNT 1
316#define WLAN_STATS_MUL_RETRY_CNT 2
317#define WLAN_STATS_TX_FRM_CNT 3
318#define WLAN_STATS_RX_FRM_CNT 4
319#define WLAN_STATS_FRM_DUP_CNT 5
320#define WLAN_STATS_FAIL_CNT 6
321#define WLAN_STATS_RTS_FAIL_CNT 7
322#define WLAN_STATS_ACK_FAIL_CNT 8
323#define WLAN_STATS_RTS_SUC_CNT 9
324#define WLAN_STATS_RX_DISCARD_CNT 10
325#define WLAN_STATS_RX_ERROR_CNT 11
326#define WLAN_STATS_TX_BYTE_CNT 12
327
328#define WLAN_STATS_RX_BYTE_CNT 13
329#define WLAN_STATS_RX_RATE 14
330#define WLAN_STATS_TX_RATE 15
331
Jeff Johnsone7245742012-09-05 17:12:55 -0700332#define WLAN_STATS_RX_UC_BYTE_CNT 16
333#define WLAN_STATS_RX_MC_BYTE_CNT 17
334#define WLAN_STATS_RX_BC_BYTE_CNT 18
335#define WLAN_STATS_TX_UC_BYTE_CNT 19
336#define WLAN_STATS_TX_MC_BYTE_CNT 20
337#define WLAN_STATS_TX_BC_BYTE_CNT 21
338
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800339#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
340 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
341 { \
342 *__p++ = __type; \
343 *__p++ = __size; \
344 memcpy(__p, __val, __size); \
345 __p += __size; \
346 __tlen += __size + 2; \
347 } \
348 else \
349 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800350 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800351 } \
352 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700353
354#define VERSION_VALUE_MAX_LEN 32
355
356#define TX_PER_TRACKING_DEFAULT_RATIO 5
357#define TX_PER_TRACKING_MAX_RATIO 10
358#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
359
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530360#define WLAN_ADAPTER 0
361#define P2P_ADAPTER 1
362
c_hpothuda3af912014-11-06 16:52:03 +0530363#define HDD_IOCTL_RATELIMIT_INTERVAL 20*HZ
364#define HDD_IOCTL_RATELIMIT_BURST 1
365
366static DEFINE_RATELIMIT_STATE(hdd_ioctl_timeout_rs, \
367 HDD_IOCTL_RATELIMIT_INTERVAL, \
368 HDD_IOCTL_RATELIMIT_BURST);
369
Abhishek Singh2ec36ab2014-08-07 16:14:25 +0530370/*
371 * When supplicant sends SETBAND ioctl it queries for channels from
372 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
373 * This is not required if the return type from ioctl is
374 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
375 * event as part of regulatory_hint.
376 */
377enum {
378 SEND_CHANNEL_CHANGE_EVENT = 0,
379 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
380};
381
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800382/*MCC Configuration parameters */
383enum {
384 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
385 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
386 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
387 MCC_RX_DRAIN_TIME_CFG_PARAM,
388 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
389 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
390 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
391 MCC_MIN_AFTER_DTIM_CFG_PARAM,
392 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
393};
394
395int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
396 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
397
Jeff Johnson295189b2012-06-20 16:38:30 -0700398#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800399int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700400 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700401#endif
402
Jeff Johnson295189b2012-06-20 16:38:30 -0700403/**---------------------------------------------------------------------------
404
Arif Hussain0273cba2014-01-07 20:58:29 -0800405 \brief mem_alloc_copy_from_user_helper -
406
407 Helper function to allocate buffer and copy user data.
408
409 \param - wrqu - Pointer to IOCTL Data.
410 len - size
411
412 \return - On Success pointer to buffer, On failure NULL
413
414 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530415void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800416{
417 u8 *ptr = NULL;
418
419 /* in order to protect the code, an extra byte is post appended to the buffer
420 * and the null termination is added. However, when allocating (len+1) byte
421 * of memory, we need to make sure that there is no uint overflow when doing
422 * addition. In theory check len < UINT_MAX protects the uint overflow. For
423 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
424 * guess, now, it is assumed that the private command buffer size is no
425 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
426 */
427 if (len > MAX_USER_COMMAND_SIZE)
428 {
429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
430 "Invalid length");
431 return NULL;
432 }
433
434 ptr = kmalloc(len + 1, GFP_KERNEL);
435 if (NULL == ptr)
436 {
437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
438 "unable to allocate memory");
439 return NULL;
440 }
441
442 if (copy_from_user(ptr, wrqu_data, len))
443 {
444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
445 "%s: failed to copy data to user buffer", __func__);
446 kfree(ptr);
447 return NULL;
448 }
449 ptr[len] = '\0';
450 return ptr;
451}
452
Girish Gowli488ef492014-06-12 18:44:33 +0530453// Function to handle and get compatible struct iw_point passed to ioctl.
454int hdd_priv_get_data(struct iw_point *p_priv_data,
455 union iwreq_data *wrqu)
456{
457 if ((NULL == p_priv_data) || (NULL == wrqu))
458 {
459 return -EINVAL;
460 }
461
462#ifdef CONFIG_COMPAT
463 if (is_compat_task())
464 {
465 struct compat_iw_point *p_compat_priv_data;
466
467 // Compat task: typecast to campat structure and copy the members.
468 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
469
470 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
471 p_priv_data->length = p_compat_priv_data->length;
472 p_priv_data->flags = p_compat_priv_data->flags;
473 }//if(is_compat_task())
474 else
475 {
476#endif //#ifdef CONFIG_COMPAT
477
478 // Non compat task: directly copy the structure.
479 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
480
481#ifdef CONFIG_COMPAT
482 }//else of - if(is_compat_task())
483#endif //#ifdef CONFIG_COMPAT
484
485 return 0;
486}
487
Arif Hussain0273cba2014-01-07 20:58:29 -0800488/**---------------------------------------------------------------------------
489
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 \brief hdd_wlan_get_version() -
491
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800492 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
494 \param - pAdapter Pointer to the adapter.
495 wrqu - Pointer to IOCTL REQUEST Data.
496 extra - Pointer to char
497
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800498 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700499
500 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800501void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
502 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700503{
504 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800505 tSirVersionString wcnss_SW_version;
506 tSirVersionString wcnss_HW_version;
507 char *pSWversion;
508 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800511 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
512 sizeof(wcnss_SW_version));
513 if (VOS_IS_STATUS_SUCCESS(status))
514 {
515 pSWversion = wcnss_SW_version;
516 }
517 else
518 {
519 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700520 }
521
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800522 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
523 sizeof(wcnss_HW_version));
524 if (VOS_IS_STATUS_SUCCESS(status))
525 {
526 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800528 else
529 {
530 pHWversion = "Unknown";
531 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700532
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700533 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800534 "Host SW:%s, FW:%s, HW:%s",
535 QWLAN_VERSIONSTR,
536 pSWversion,
537 pHWversion);
538
539 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700540}
541
Jeff Johnson295189b2012-06-20 16:38:30 -0700542int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
543{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530544 tHalHandle hHal;
545 hdd_context_t *pHddCtx;
546 v_U32_t threshold = 0;
547 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700548
549 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530550 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530551 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
553 "%s: Adapter is NULL",__func__);
554 return -EINVAL;
555 }
556
557 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
558 ret = wlan_hdd_validate_context(pHddCtx);
559 if (0 != ret)
560 {
561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
562 "%s: HDD context is not valid",__func__);
563 return ret;
564 }
565
566 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
567 if (NULL == hHal)
568 {
569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
570 "%s: Hal Context is NULL",__func__);
571 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 }
573
574 if ( eHAL_STATUS_SUCCESS !=
575 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
576 {
c_hpothub8245442013-11-20 23:41:09 +0530577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
578 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 return -EIO;
580 }
581 wrqu->rts.value = threshold;
582
583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800584 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585
586 EXIT();
587
588 return 0;
589}
590
591int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
592{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530593 tHalHandle hHal;
594 hdd_context_t *pHddCtx;
595 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700596
597 ENTER();
598
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530599 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530600 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
602 "%s: Adapter is NULL",__func__);
603 return -EINVAL;
604 }
605
606 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
607 status = wlan_hdd_validate_context(pHddCtx);
608 if (0 != status)
609 {
610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
611 "%s: HDD context is not valid",__func__);
612 return status;
613 }
614
615 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
616 if (NULL == hHal)
617 {
618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
619 "%s: Hal Context is NULL",__func__);
620 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 }
622
623 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
624 != eHAL_STATUS_SUCCESS )
625 {
c_hpothub8245442013-11-20 23:41:09 +0530626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
627 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 return -EIO;
629 }
630 wrqu->frag.value = threshold;
631
632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800633 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700634
635 EXIT();
636
637 return 0;
638}
639
640int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
641{
Jeff Johnsone7245742012-09-05 17:12:55 -0700642 int i;
643 if (channel > 0)
644 {
645 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
646 {
647 if (channel == freq_chan_map[i].chan)
648 {
649 *pfreq = freq_chan_map[i].freq;
650 return 1;
651 }
652 }
653 }
654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800655 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700656 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700657}
658
659static v_BOOL_t
660hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
661{
662 v_BOOL_t rsnType = VOS_FALSE;
663 // is the authType supported?
664 switch (authType)
665 {
666 case eCSR_AUTH_TYPE_NONE: //never used
667 rsnType = eANI_BOOLEAN_FALSE;
668 break;
669 // MAC layer authentication types
670 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
671 rsnType = eANI_BOOLEAN_FALSE;
672 break;
673 case eCSR_AUTH_TYPE_SHARED_KEY:
674 rsnType = eANI_BOOLEAN_FALSE;
675 break;
676 case eCSR_AUTH_TYPE_AUTOSWITCH:
677 rsnType = eANI_BOOLEAN_FALSE;
678 break;
679
680 // Upper layer authentication types
681 case eCSR_AUTH_TYPE_WPA:
682 rsnType = eANI_BOOLEAN_TRUE;
683 break;
684 case eCSR_AUTH_TYPE_WPA_PSK:
685 rsnType = eANI_BOOLEAN_TRUE;
686 break;
687 case eCSR_AUTH_TYPE_WPA_NONE:
688 rsnType = eANI_BOOLEAN_TRUE;
689 break;
690#ifdef WLAN_FEATURE_VOWIFI_11R
691 case eCSR_AUTH_TYPE_FT_RSN:
692#endif
693 case eCSR_AUTH_TYPE_RSN:
694 rsnType = eANI_BOOLEAN_TRUE;
695 break;
696#ifdef WLAN_FEATURE_VOWIFI_11R
697 case eCSR_AUTH_TYPE_FT_RSN_PSK:
698#endif
699 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700700#ifdef WLAN_FEATURE_11W
701 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530702 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700703#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700704 rsnType = eANI_BOOLEAN_TRUE;
705 break;
706 //case eCSR_AUTH_TYPE_FAILED:
707 case eCSR_AUTH_TYPE_UNKNOWN:
708 rsnType = eANI_BOOLEAN_FALSE;
709 break;
710 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800711 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
712 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 rsnType = eANI_BOOLEAN_FALSE;
714 break;
715 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800716 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700717 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 return rsnType;
719}
720
721static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
722{
723 struct statsContext *pStatsContext;
724 hdd_adapter_t *pAdapter;
725
726 if (ioctl_debug)
727 {
728 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700729 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 }
731
732 if (NULL == pContext)
733 {
734 hddLog(VOS_TRACE_LEVEL_ERROR,
735 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700736 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 return;
738 }
739
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 pStatsContext = pContext;
741 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800742
743 /* there is a race condition that exists between this callback
744 function and the caller since the caller could time out either
745 before or while this code is executing. we use a spinlock to
746 serialize these actions */
747 spin_lock(&hdd_context_lock);
748
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
750 {
751 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800752 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 hddLog(VOS_TRACE_LEVEL_WARN,
754 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700755 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 if (ioctl_debug)
757 {
758 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700759 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 }
761 return;
762 }
763
Jeff Johnson72a40512013-12-19 10:14:15 -0800764 /* context is valid so caller is still waiting */
765
766 /* paranoia: invalidate the magic */
767 pStatsContext->magic = 0;
768
769 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 pAdapter->rssi = rssi;
771
Jeff Johnson72a40512013-12-19 10:14:15 -0800772 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800774
775 /* serialization is complete */
776 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700777}
778
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530779static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
780{
781 struct statsContext *pStatsContext;
782 hdd_adapter_t *pAdapter;
783
784 if (ioctl_debug)
785 {
786 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
787 __func__, (int)snr, (int)staId, pContext);
788 }
789
790 if (NULL == pContext)
791 {
792 hddLog(VOS_TRACE_LEVEL_ERROR,
793 "%s: Bad param, pContext [%p]",
794 __func__, pContext);
795 return;
796 }
797
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530798 pStatsContext = pContext;
799 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800800
801 /* there is a race condition that exists between this callback
802 function and the caller since the caller could time out either
803 before or while this code is executing. we use a spinlock to
804 serialize these actions */
805 spin_lock(&hdd_context_lock);
806
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530807 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
808 {
809 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800810 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530811 hddLog(VOS_TRACE_LEVEL_WARN,
812 "%s: Invalid context, pAdapter [%p] magic [%08x]",
813 __func__, pAdapter, pStatsContext->magic);
814 if (ioctl_debug)
815 {
816 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
817 __func__, pAdapter, pStatsContext->magic);
818 }
819 return;
820 }
821
Jeff Johnson72a40512013-12-19 10:14:15 -0800822 /* context is valid so caller is still waiting */
823
824 /* paranoia: invalidate the magic */
825 pStatsContext->magic = 0;
826
827 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530828 pAdapter->snr = snr;
829
Jeff Johnson72a40512013-12-19 10:14:15 -0800830 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530831 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800832
833 /* serialization is complete */
834 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530835}
836
Jeff Johnson295189b2012-06-20 16:38:30 -0700837VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
838{
839 struct statsContext context;
840 hdd_context_t *pHddCtx;
841 hdd_station_ctx_t *pHddStaCtx;
842 eHalStatus hstatus;
843 long lrc;
844
845 if (NULL == pAdapter)
846 {
847 hddLog(VOS_TRACE_LEVEL_WARN,
848 "%s: Invalid context, pAdapter", __func__);
849 return VOS_STATUS_E_FAULT;
850 }
851 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
852 {
853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
854 /* return a cached value */
855 *rssi_value = pAdapter->rssi;
856 return VOS_STATUS_SUCCESS;
857 }
858
859 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
860 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
861
862 init_completion(&context.completion);
863 context.pAdapter = pAdapter;
864 context.magic = RSSI_CONTEXT_MAGIC;
865
866 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
867 pHddStaCtx->conn_info.staId[ 0 ],
868 pHddStaCtx->conn_info.bssId,
869 &context, pHddCtx->pvosContext);
870 if (eHAL_STATUS_SUCCESS != hstatus)
871 {
872 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700873 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 /* we'll returned a cached value below */
875 }
876 else
877 {
878 /* request was sent -- wait for the response */
879 lrc = wait_for_completion_interruptible_timeout(&context.completion,
880 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 if (lrc <= 0)
882 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800883 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700884 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 /* we'll now returned a cached value below */
886 }
887 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800888
889 /* either we never sent a request, we sent a request and received a
890 response or we sent a request and timed out. if we never sent a
891 request or if we sent a request and got a response, we want to
892 clear the magic out of paranoia. if we timed out there is a
893 race condition such that the callback function could be
894 executing at the same time we are. of primary concern is if the
895 callback function had already verified the "magic" but had not
896 yet set the completion variable when a timeout occurred. we
897 serialize these activities by invalidating the magic while
898 holding a shared spinlock which will cause us to block if the
899 callback is currently executing */
900 spin_lock(&hdd_context_lock);
901 context.magic = 0;
902 spin_unlock(&hdd_context_lock);
903
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 *rssi_value = pAdapter->rssi;
905
906 return VOS_STATUS_SUCCESS;
907}
908
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530909VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
910{
911 struct statsContext context;
912 hdd_context_t *pHddCtx;
913 hdd_station_ctx_t *pHddStaCtx;
914 eHalStatus hstatus;
915 long lrc;
916 int valid;
917
918 if (NULL == pAdapter)
919 {
920 hddLog(VOS_TRACE_LEVEL_ERROR,
921 "%s: Invalid context, pAdapter", __func__);
922 return VOS_STATUS_E_FAULT;
923 }
924
925 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
926
927 valid = wlan_hdd_validate_context(pHddCtx);
928 if (0 != valid)
929 {
930 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
931 return VOS_STATUS_E_FAULT;
932 }
933
934 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
935 if (NULL == pHddStaCtx)
936 {
937 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
938 return VOS_STATUS_E_FAULT;
939 }
940
941 init_completion(&context.completion);
942 context.pAdapter = pAdapter;
943 context.magic = SNR_CONTEXT_MAGIC;
944
945 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
946 pHddStaCtx->conn_info.staId[ 0 ],
947 pHddStaCtx->conn_info.bssId,
948 &context);
949 if (eHAL_STATUS_SUCCESS != hstatus)
950 {
951 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
952 __func__);
953 /* we'll returned a cached value below */
954 }
955 else
956 {
957 /* request was sent -- wait for the response */
958 lrc = wait_for_completion_interruptible_timeout(&context.completion,
959 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530960 if (lrc <= 0)
961 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800962 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530963 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530964 /* we'll now returned a cached value below */
965 }
966 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800967
968 /* either we never sent a request, we sent a request and received a
969 response or we sent a request and timed out. if we never sent a
970 request or if we sent a request and got a response, we want to
971 clear the magic out of paranoia. if we timed out there is a
972 race condition such that the callback function could be
973 executing at the same time we are. of primary concern is if the
974 callback function had already verified the "magic" but had not
975 yet set the completion variable when a timeout occurred. we
976 serialize these activities by invalidating the magic while
977 holding a shared spinlock which will cause us to block if the
978 callback is currently executing */
979 spin_lock(&hdd_context_lock);
980 context.magic = 0;
981 spin_unlock(&hdd_context_lock);
982
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530983 *snr = pAdapter->snr;
984
985 return VOS_STATUS_SUCCESS;
986}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800987#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800988
989static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
990{
991 struct statsContext *pStatsContext;
992 hdd_adapter_t *pAdapter;
993 if (ioctl_debug)
994 {
995 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
996 __func__, (int)rssi, (int)staId, pContext);
997 }
998
999 if (NULL == pContext)
1000 {
1001 hddLog(VOS_TRACE_LEVEL_ERROR,
1002 "%s: Bad param, pContext [%p]",
1003 __func__, pContext);
1004 return;
1005 }
1006
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001007 pStatsContext = pContext;
1008 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001009
1010 /* there is a race condition that exists between this callback
1011 function and the caller since the caller could time out either
1012 before or while this code is executing. we use a spinlock to
1013 serialize these actions */
1014 spin_lock(&hdd_context_lock);
1015
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001016 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1017 {
1018 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001019 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001020 hddLog(VOS_TRACE_LEVEL_WARN,
1021 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1022 __func__, pAdapter, pStatsContext->magic);
1023 if (ioctl_debug)
1024 {
1025 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1026 __func__, pAdapter, pStatsContext->magic);
1027 }
1028 return;
1029 }
1030
Jeff Johnson72a40512013-12-19 10:14:15 -08001031 /* context is valid so caller is still waiting */
1032
1033 /* paranoia: invalidate the magic */
1034 pStatsContext->magic = 0;
1035
1036 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001037 pAdapter->rssi = rssi;
1038
Jeff Johnson72a40512013-12-19 10:14:15 -08001039 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001040 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001041
1042 /* serialization is complete */
1043 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001044}
1045
1046
1047
1048VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1049{
1050 struct statsContext context;
1051 hdd_context_t *pHddCtx = NULL;
1052 hdd_station_ctx_t *pHddStaCtx = NULL;
1053 eHalStatus hstatus;
1054 long lrc;
1055
1056 if (NULL == pAdapter)
1057 {
1058 hddLog(VOS_TRACE_LEVEL_WARN,
1059 "%s: Invalid context, pAdapter", __func__);
1060 return VOS_STATUS_E_FAULT;
1061 }
1062 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1063 {
1064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1065 /* return a cached value */
1066 *rssi_value = pAdapter->rssi;
1067 return VOS_STATUS_SUCCESS;
1068 }
1069
1070 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1071 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1072
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301073 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001074 {
1075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1076 /* return a cached value */
1077 *rssi_value = 0;
1078 return VOS_STATUS_SUCCESS;
1079 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301080
1081 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1082 {
1083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1084 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1085 *rssi_value = pAdapter->rssi;
1086 return VOS_STATUS_SUCCESS;
1087 }
1088
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001089 init_completion(&context.completion);
1090 context.pAdapter = pAdapter;
1091 context.magic = RSSI_CONTEXT_MAGIC;
1092
1093 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1094 pHddStaCtx->conn_info.staId[ 0 ],
1095 pHddStaCtx->conn_info.bssId,
1096 &context, pHddCtx->pvosContext);
1097 if (eHAL_STATUS_SUCCESS != hstatus)
1098 {
1099 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1100 __func__);
1101 /* we'll returned a cached value below */
1102 }
1103 else
1104 {
1105 /* request was sent -- wait for the response */
1106 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1107 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001108 if (lrc <= 0)
1109 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001110 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001111 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001112 /* we'll now returned a cached value below */
1113 }
1114 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001115
1116 /* either we never sent a request, we sent a request and received a
1117 response or we sent a request and timed out. if we never sent a
1118 request or if we sent a request and got a response, we want to
1119 clear the magic out of paranoia. if we timed out there is a
1120 race condition such that the callback function could be
1121 executing at the same time we are. of primary concern is if the
1122 callback function had already verified the "magic" but had not
1123 yet set the completion variable when a timeout occurred. we
1124 serialize these activities by invalidating the magic while
1125 holding a shared spinlock which will cause us to block if the
1126 callback is currently executing */
1127 spin_lock(&hdd_context_lock);
1128 context.magic = 0;
1129 spin_unlock(&hdd_context_lock);
1130
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001131 *rssi_value = pAdapter->rssi;
1132
1133 return VOS_STATUS_SUCCESS;
1134}
1135#endif
1136
1137
Jeff Johnson295189b2012-06-20 16:38:30 -07001138void hdd_StatisticsCB( void *pStats, void *pContext )
1139{
1140 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1141 hdd_stats_t *pStatsCache = NULL;
1142 hdd_wext_state_t *pWextState;
1143 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1144
1145 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1146 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1147 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1148 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1149 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1150 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1151
1152 if (pAdapter!= NULL)
1153 pStatsCache = &pAdapter->hdd_stats;
1154
1155
1156 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1157 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1158 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1159 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1160 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1161 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1162
1163 if (pStatsCache!=NULL)
1164 {
1165 // and copy the stats into the cache we keep in the adapter instance structure
1166 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1167 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1168 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1169 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1170 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1171 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1172 }
1173
1174 if(pAdapter)
1175 {
1176 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1177 if(pWextState)
1178 {
1179 vos_status = vos_event_set(&pWextState->vosevent);
1180 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1181 {
1182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001183 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 return;
1185 }
1186 }
1187 }
1188}
1189
1190void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1191{
1192 v_CONTEXT_t pVosContext;
1193 hdd_context_t *pHddCtx;
1194 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1195#if 0
1196 hdd_wext_state_t *pWextState;
1197 v_U32_t roamId;
1198#endif
1199
1200 ENTER();
1201
1202 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1203
1204 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1205 if (NULL == pHddCtx)
1206 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001207 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 return;
1209 }
1210#if 0
1211 pWextState = pAdapter->pWextState;
1212#endif
1213
1214 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1215 {
1216 //TODO Verify is this is really used. If yes need to fix it.
1217 hdd_reconnect_all_adapters( pHddCtx );
1218#if 0
1219 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1220 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1221 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1222
1223 if(VOS_STATUS_SUCCESS == vosStatus)
1224 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1225 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1226
1227 sme_RoamConnect(halHandle,
1228 pAdapter->sessionId, &(pWextState->roamProfile),
1229 &roamId);
1230#endif
1231 }
1232
1233 EXIT();
1234
1235}
1236
1237void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1238{
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1240
1241 /* clear WPA/RSN/WSC IE information in the profile */
1242 pWextState->roamProfile.nWPAReqIELength = 0;
1243 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1244 pWextState->roamProfile.nRSNReqIELength = 0;
1245 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1246
Chet Lanctot186b5732013-03-18 10:26:30 -07001247#ifdef FEATURE_WLAN_WAPI
1248 pWextState->roamProfile.nWAPIReqIELength = 0;
1249 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1250#endif
1251
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001253 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301255 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1257 pWextState->roamProfile.nAddIEAssocLength = 0;
1258
1259 pWextState->roamProfile.EncryptionType.numEntries = 1;
1260 pWextState->roamProfile.EncryptionType.encryptionType[0]
1261 = eCSR_ENCRYPT_TYPE_NONE;
1262
1263 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1264 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1265 = eCSR_ENCRYPT_TYPE_NONE;
1266
1267 pWextState->roamProfile.AuthType.numEntries = 1;
1268 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1269
Chet Lanctot186b5732013-03-18 10:26:30 -07001270#ifdef WLAN_FEATURE_11W
1271 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1272 pWextState->roamProfile.MFPRequired = 0;
1273 pWextState->roamProfile.MFPCapable = 0;
1274#endif
1275
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 pWextState->authKeyMgmt = 0;
1277
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301278 vos_mem_zero(&pWextState->roamProfile.Keys,
1279 sizeof(pWextState->roamProfile.Keys));
1280
Jeff Johnson295189b2012-06-20 16:38:30 -07001281#ifdef FEATURE_WLAN_WAPI
1282 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1283 pAdapter->wapi_info.nWapiMode = 0;
1284#endif
1285
1286 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1287
1288}
1289
1290void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1291{
1292 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001293
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001294 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1295 {
1296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1297 "%s: Invalid pAdapter magic", __func__);
1298 }
1299 else
1300 {
1301 complete(&pAdapter->ula_complete);
1302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001303}
1304
1305VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1306{
1307 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001309 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001310
1311 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1312 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001313 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001314
1315 /*To avoid race condition between the set key and the last EAPOL
1316 packet, notify TL to finish upper layer authentication incase if the
1317 last EAPOL packet pending in the TL queue.*/
Nirav Shah4f765af2015-01-21 19:51:30 +05301318 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter,
1319 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1320 pHddStaCtx->conn_info.staId[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001321
Nirav Shah4f765af2015-01-21 19:51:30 +05301322 if ( vos_status == VOS_STATUS_E_ALREADY )
1323 {
1324 return VOS_STATUS_SUCCESS;
1325 }
1326 else if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 {
1328 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1329 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1330 __LINE__, vos_status );
1331 return vos_status;
1332
1333 }
1334
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001335 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301337 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001338 {
1339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301340 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001341 /* we'll still fall through and return success since the
1342 * connection may still get established but is just taking
1343 * too long for us to wait */
1344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 }
1346 return VOS_STATUS_SUCCESS;
1347}
1348
1349v_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)
1350{
1351
1352 int left = ie_len;
1353 v_U8_t *ptr = ie;
1354 v_U8_t elem_id,elem_len;
1355 v_U8_t eid = 0xDD;
1356
1357 if ( NULL == ie || 0 == ie_len )
1358 return NULL;
1359
1360 while(left >= 2)
1361 {
1362 elem_id = ptr[0];
1363 elem_len = ptr[1];
1364 left -= 2;
1365 if(elem_len > left)
1366 {
1367 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001368 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001369 eid,elem_len,left);
1370 return NULL;
1371 }
1372 if (elem_id == eid)
1373 {
1374 if(memcmp( &ptr[2], oui, oui_size)==0)
1375 return ptr;
1376 }
1377
1378 left -= elem_len;
1379 ptr += (elem_len + 2);
1380 }
1381 return NULL;
1382}
1383
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301384static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 union iwreq_data *wrqu, char *extra)
1386{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301387 hdd_adapter_t *pAdapter;
1388 hdd_context_t *pHddCtx;
1389 int ret = 0;
1390 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1391 if (NULL == pAdapter)
1392 {
1393 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1394 "%s: pAdapter is NULL\n", __func__);
1395 return -EINVAL;
1396 }
1397 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1398 ret = wlan_hdd_validate_context(pHddCtx);
1399 if (0 != ret)
1400 {
1401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1402 "%s: HDD context is Null", __func__);
1403 return ret;
1404 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08001405 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 /* Do nothing for now */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301407 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001408}
1409
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301410static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1411 union iwreq_data *wrqu, char *extra)
1412{
1413 int ret;
1414
1415 vos_ssr_protect(__func__);
1416 ret = __iw_set_commit(dev, info, wrqu, extra);
1417 vos_ssr_unprotect(__func__);
1418
1419 return ret;
1420}
1421
1422static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 struct iw_request_info *info,
1424 char *wrqu, char *extra)
1425{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301426 hdd_adapter_t *pAdapter;
1427 hdd_context_t *pHddCtx;
1428 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301430 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1431 if (NULL == pAdapter)
1432 {
1433 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1434 "%s: pAdapter is NULL\n", __func__);
1435 return -EINVAL;
1436 }
1437 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1438 ret = wlan_hdd_validate_context(pHddCtx);
1439 if (0 != ret)
1440 {
1441 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1442 "%s: HDD context is Null", __func__);
1443 return ret;
1444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001445 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1446 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301447 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001448}
1449
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301450static int iw_get_name(struct net_device *dev,
1451 struct iw_request_info *info,
1452 char *wrqu, char *extra)
1453{
1454 int ret;
1455
1456 vos_ssr_protect(__func__);
1457 ret = __iw_get_name(dev, info, wrqu, extra);
1458 vos_ssr_unprotect(__func__);
1459
1460 return ret;
1461}
1462
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301463static int __iw_set_mode(struct net_device *dev,
1464 struct iw_request_info *info,
1465 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001466{
1467 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301468 hdd_adapter_t *pAdapter;
1469 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 tCsrRoamProfile *pRoamProfile;
1471 eCsrRoamBssType LastBSSType;
1472 eMib_dot11DesiredBssType connectedBssType;
1473 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301475 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001476
1477 ENTER();
1478
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301479 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 if (NULL == pAdapter)
1481 {
1482 hddLog(VOS_TRACE_LEVEL_WARN,
1483 "%s: Invalid context, pAdapter", __func__);
1484 return 0;
1485 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301486 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1487 status = wlan_hdd_validate_context(pHddCtx);
1488 if (0 != status)
1489 {
1490 hddLog(VOS_TRACE_LEVEL_WARN,
1491 "%s: HddCtx is Invalid", __func__);
1492 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 }
1494
1495 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1496 if (pWextState == NULL)
1497 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301498 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 return -EINVAL;
1500 }
1501
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 pRoamProfile = &pWextState->roamProfile;
1504 LastBSSType = pRoamProfile->BSSType;
1505
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301506 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001507
1508 switch (wrqu->mode)
1509 {
1510 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301511 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1513 // Set the phymode correctly for IBSS.
1514 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1515 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001516 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 break;
1519 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301520 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001521 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 break;
1524 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301525 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1527 break;
1528 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301529 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 return -EOPNOTSUPP;
1531 }
1532
1533 if ( LastBSSType != pRoamProfile->BSSType )
1534 {
1535 //the BSS mode changed
1536 // We need to issue disconnect if connected or in IBSS disconnect state
1537 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1538 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1539 {
1540 VOS_STATUS vosStatus;
1541 // need to issue a disconnect to CSR.
1542 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1543 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1544 pAdapter->sessionId,
1545 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1546 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301547 {
1548 long ret;
1549 ret = wait_for_completion_interruptible_timeout(
1550 &pAdapter->disconnect_comp_var,
1551 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1552 if (ret <= 0)
1553 hddLog(VOS_TRACE_LEVEL_ERROR,
1554 FL("failed wait on disconnect_comp_var %ld"), ret);
1555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 }
1557 }
1558
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 EXIT();
1560 return 0;
1561}
1562
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301563static int iw_set_mode(struct net_device *dev,
1564 struct iw_request_info *info,
1565 union iwreq_data *wrqu, char *extra)
1566{
1567 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001568
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301569 vos_ssr_protect(__func__);
1570 ret = __iw_set_mode(dev, info, wrqu, extra);
1571 vos_ssr_unprotect(__func__);
1572
1573 return ret;
1574}
1575
1576static int __iw_get_mode(struct net_device *dev,
1577 struct iw_request_info *info,
1578 union iwreq_data *wrqu,
1579 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001580{
1581
1582 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301583 hdd_adapter_t *pAdapter;
1584 hdd_context_t *pHddCtx;
1585 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001586
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301587 hddLog(LOG1, "In %s", __func__);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301588 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 if (NULL == pAdapter)
1590 {
1591 hddLog(VOS_TRACE_LEVEL_WARN,
1592 "%s: Invalid context, pAdapter", __func__);
1593 return 0;
1594 }
1595
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301596 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1597 ret = wlan_hdd_validate_context(pHddCtx);
1598 if (0 != ret)
1599 {
1600 hddLog(VOS_TRACE_LEVEL_ERROR,
1601 "%s: HDD context is not valid",__func__);
1602 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1605 if (pWextState == NULL)
1606 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301607 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 return -EINVAL;
1609 }
1610
1611 switch (pWextState->roamProfile.BSSType)
1612 {
1613 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001614 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301615 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 break;
1617 case eCSR_BSS_TYPE_IBSS:
1618 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001619 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301620 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 break;
1622 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001623 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301624 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 break;
1626 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001627 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 break;
1629 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301630
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 return 0;
1632}
1633
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301634static int iw_get_mode(struct net_device *dev,
1635 struct iw_request_info *info,
1636 union iwreq_data *wrqu,
1637 char *extra)
1638{
1639 int ret;
1640
1641 vos_ssr_protect(__func__);
1642 ret = __iw_get_mode(dev, info, wrqu, extra);
1643 vos_ssr_unprotect(__func__);
1644
1645 return ret;
1646}
1647
1648static int __iw_set_freq(struct net_device *dev,
1649 struct iw_request_info *info,
1650 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001651{
1652 v_U32_t numChans = 0;
1653 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1654 v_U32_t indx = 0;
1655 v_U32_t status = 0;
1656
1657 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301658 hdd_adapter_t *pAdapter;
1659 hdd_context_t *pHddCtx;
1660 tHalHandle hHal;
1661 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 tCsrRoamProfile * pRoamProfile;
1663 ENTER();
1664
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301665 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1666 if (NULL == pAdapter)
1667 {
1668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1669 "%s:Invalid Adapter",__func__);
1670 return -EINVAL;
1671 }
1672
1673 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1674 status = wlan_hdd_validate_context(pHddCtx);
1675 if (0 != status)
1676 {
1677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1678 "%s:HDD context is NULL",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 return status;
1680 }
1681
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301682 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1683 if (NULL == hHal)
1684 {
1685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1686 "%s: Hal Context is NULL",__func__);
1687 return -EINVAL;
1688 }
1689
1690 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1691 if (NULL == pHddStaCtx)
1692 {
1693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1694 "%s:STA context is NULL",__func__);
1695 return -EINVAL;
1696 }
1697
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301699 if (NULL == pWextState)
1700 {
1701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1702 "%s: pWextState is NULL",__func__);
1703 return -EINVAL;
1704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001705
1706 pRoamProfile = &pWextState->roamProfile;
1707
Arif Hussain6d2a3322013-11-17 19:50:10 -08001708 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001709
1710 /* Link is up then return cant set channel*/
1711 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1712 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1713 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001714 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 return -EOPNOTSUPP;
1716 }
1717
1718 /* Settings by Frequency as input */
1719 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1720 (wrqu->freq.m <= (tANI_U32)5.825e8))
1721 {
1722 tANI_U32 freq = wrqu->freq.m / 100000;
1723
1724 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1725 indx++;
1726 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1727 {
1728 return -EINVAL;
1729 }
1730 wrqu->freq.e = 0;
1731 wrqu->freq.m = freq_chan_map[indx].chan;
1732
1733 }
1734
1735 if (wrqu->freq.e == 0)
1736 {
1737 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1738 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1739 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001740 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001741 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1743 return -EINVAL;
1744 }
1745
1746 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1747
1748 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1749 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1751 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 return -EIO;
1753 }
1754
1755 for (indx = 0; indx < numChans; indx++) {
1756 if (wrqu->freq.m == validChan[indx]){
1757 break;
1758 }
1759 }
1760 }
1761 else{
1762
1763 return -EINVAL;
1764 }
1765
1766 if(indx >= numChans)
1767 {
1768 return -EINVAL;
1769 }
1770
1771 /* Set the Operational Channel */
1772 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1773 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1774 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1775
Arif Hussain6d2a3322013-11-17 19:50:10 -08001776 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001777
1778 EXIT();
1779
1780 return status;
1781}
1782
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301783static int iw_set_freq(struct net_device *dev,
1784 struct iw_request_info *info,
1785 union iwreq_data *wrqu, char *extra)
1786{
1787 int ret;
1788
1789 vos_ssr_protect(__func__);
1790 ret = __iw_set_freq(dev, info, wrqu, extra);
1791 vos_ssr_unprotect(__func__);
1792
1793 return ret;
1794}
1795
1796static int __iw_get_freq(struct net_device *dev,
1797 struct iw_request_info *info,
1798 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001799{
Jeff Johnsone7245742012-09-05 17:12:55 -07001800 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301801 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 tHalHandle hHal;
1803 hdd_wext_state_t *pWextState;
1804 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301805 hdd_station_ctx_t *pHddStaCtx;
1806 hdd_context_t *pHddCtx;
1807 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001808
1809 ENTER();
1810
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301811 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1812 if (NULL == pAdapter)
1813 {
1814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1815 "%s: Adapter is NULL", __func__);
1816 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001817 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301818 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1819 ret = wlan_hdd_validate_context(pHddCtx);
1820 if (0 != ret)
1821 {
1822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1823 "%s: HddCtx is NULL", __func__);
1824 return ret;
1825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301827 if (NULL == hHal)
1828 {
1829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1830 "%s: Hal Context is NULL",__func__);
1831 return -EINVAL;
1832 }
1833 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1834 if (NULL == pHddStaCtx)
1835 {
1836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1837 "%s: HddStaCtx is NULL", __func__);
1838 return -EINVAL;
1839 }
1840 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1841 if (NULL == pWextState)
1842 {
1843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1844 "%s: pWextState is NULL",__func__);
1845 return -EINVAL;
1846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 pRoamProfile = &pWextState->roamProfile;
1848
1849 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1850 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001851 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 {
c_hpothub8245442013-11-20 23:41:09 +05301853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1854 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 return -EIO;
1856 }
1857 else
1858 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001859 status = hdd_wlan_get_freq(channel, &freq);
1860 if( TRUE == status )
1861 {
1862 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1863 * iwlist & iwconfig command shows frequency into proper
1864 * format (2.412 GHz instead of 246.2 MHz)*/
1865 fwrq->m = freq;
1866 fwrq->e = MHZ;
1867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 }
1869 }
1870 else
1871 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001872 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1873 * iwlist & iwconfig command shows frequency into proper
1874 * format (2.412 GHz instead of 246.2 MHz)*/
1875 fwrq->m = 0;
1876 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301878 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001879}
1880
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301881static int iw_get_freq(struct net_device *dev,
1882 struct iw_request_info *info,
1883 struct iw_freq *fwrq, char *extra)
1884{
1885 int ret;
1886
1887 vos_ssr_protect(__func__);
1888 ret = __iw_get_freq(dev, info, fwrq, extra);
1889 vos_ssr_unprotect(__func__);
1890
1891 return ret;
1892}
1893
1894static int __iw_get_tx_power(struct net_device *dev,
1895 struct iw_request_info *info,
1896 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001897{
1898
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301899 hdd_adapter_t *pAdapter;
1900 hdd_context_t *pHddCtx;
1901 hdd_station_ctx_t *pHddStaCtx;
1902 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001903
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301904 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1905 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1908 "%s: Adapter is NULL",__func__);
1909 return -EINVAL;
1910 }
1911 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1912 ret = wlan_hdd_validate_context(pHddCtx);
1913 if (0 != ret)
1914 {
1915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1916 "%s: HDD context is not valid",__func__);
1917 return ret;
1918 }
1919
1920 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1921 if (NULL == pHddStaCtx)
1922 {
1923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1924 "%s: STA Context is NULL",__func__);
1925 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 }
1927
1928 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1929 {
1930 wrqu->txpower.value = 0;
1931 return 0;
1932 }
1933 wlan_hdd_get_classAstats(pAdapter);
1934 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1935
1936 return 0;
1937}
1938
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301939static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 struct iw_request_info *info,
1941 union iwreq_data *wrqu, char *extra)
1942{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301943 int ret;
1944
1945 vos_ssr_protect(__func__);
1946 ret = __iw_get_tx_power(dev, info, wrqu, extra);
1947 vos_ssr_unprotect(__func__);
1948
1949 return ret;
1950}
1951
1952static int __iw_set_tx_power(struct net_device *dev,
1953 struct iw_request_info *info,
1954 union iwreq_data *wrqu, char *extra)
1955{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301956 hdd_adapter_t *pAdapter;
1957 tHalHandle hHal;
1958 hdd_context_t *pHddCtx;
1959 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001960
1961 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301962 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1963 if (NULL == pAdapter)
1964 {
1965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1966 "%s: Adapter is NULL",__func__);
1967 return -EINVAL;
1968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001969
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301970 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1971 ret = wlan_hdd_validate_context(pHddCtx);
1972 if (0 != ret)
1973 {
1974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1975 "%s: HDD context is not valid",__func__);
1976 return ret;
1977 }
1978
1979 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1980 if (NULL == hHal)
1981 {
1982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1983 "%s: Hal Context is NULL",__func__);
1984 return -EINVAL;
1985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1987 {
c_hpothub8245442013-11-20 23:41:09 +05301988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1989 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001990 return -EIO;
1991 }
1992
1993 EXIT();
1994
1995 return 0;
1996}
1997
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301998static int iw_set_tx_power(struct net_device *dev,
1999 struct iw_request_info *info,
2000 union iwreq_data *wrqu, char *extra)
2001{
2002 int ret;
2003
2004 vos_ssr_protect(__func__);
2005 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2006 vos_ssr_unprotect(__func__);
2007
2008 return ret;
2009}
2010
2011static int __iw_get_bitrate(struct net_device *dev,
2012 struct iw_request_info *info,
2013 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002014{
2015 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2016 eHalStatus status = eHAL_STATUS_SUCCESS;
2017 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302018 hdd_adapter_t *pAdapter;
2019 hdd_context_t *pHddCtx;
2020 hdd_station_ctx_t *pHddStaCtx;
2021 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002022
2023 ENTER();
2024
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302025 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2026 if (NULL == pAdapter)
2027 {
2028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2029 "%s: Adapter is NULL",__func__);
2030 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 }
2032
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302033 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2034 ret = wlan_hdd_validate_context(pHddCtx);
2035 if (0 != ret)
2036 {
2037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2038 "%s: HDD context is not valid",__func__);
2039 return ret;
2040 }
2041
2042 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2043 if (NULL == pHddStaCtx)
2044 {
2045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2046 "%s: STA Context is NULL",__func__);
2047 return -EINVAL;
2048 }
2049
2050 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 wrqu->bitrate.value = 0;
2052 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302053 else
2054 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2056 SME_SUMMARY_STATS |
2057 SME_GLOBAL_CLASSA_STATS |
2058 SME_GLOBAL_CLASSB_STATS |
2059 SME_GLOBAL_CLASSC_STATS |
2060 SME_GLOBAL_CLASSD_STATS |
2061 SME_PER_STA_STATS,
2062 hdd_StatisticsCB, 0, FALSE,
2063 pHddStaCtx->conn_info.staId[0], pAdapter );
2064
2065 if(eHAL_STATUS_SUCCESS != status)
2066 {
2067 hddLog(VOS_TRACE_LEVEL_ERROR,
2068 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002069 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 return status;
2071 }
2072
2073 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302074 if (NULL == pWextState)
2075 {
2076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2077 "%s: pWextState is NULL",__func__);
2078 return -EINVAL;
2079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002080
2081 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2082
2083 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2084 {
2085 hddLog(VOS_TRACE_LEVEL_ERROR,
2086 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002087 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 return VOS_STATUS_E_FAILURE;
2089 }
2090
2091 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2092 }
2093
2094 EXIT();
2095
2096 return vos_status;
2097}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302098
2099static int iw_get_bitrate(struct net_device *dev,
2100 struct iw_request_info *info,
2101 union iwreq_data *wrqu, char *extra)
2102{
2103 int ret;
2104
2105 vos_ssr_protect(__func__);
2106 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2107 vos_ssr_unprotect(__func__);
2108
2109 return ret;
2110}
2111
2112
Jeff Johnson295189b2012-06-20 16:38:30 -07002113/* ccm call back function */
2114
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302115static int __iw_set_bitrate(struct net_device *dev,
2116 struct iw_request_info *info,
2117 union iwreq_data *wrqu,
2118 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002119{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302120 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302122 hdd_station_ctx_t *pHddStaCtx;
2123 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2125 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2126 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2127 v_U32_t i, rate;
2128 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302129 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002130
2131 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302132 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2133 if (NULL == pAdapter)
2134 {
2135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2136 "%s: Adapter is NULL",__func__);
2137 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 }
2139
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302140 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2141 ret = wlan_hdd_validate_context(pHddCtx);
2142 if (0 != ret)
2143 {
2144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2145 "%s: HDD context is not valid",__func__);
2146 return ret;
2147 }
2148
2149 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2150 if (NULL == pHddStaCtx)
2151 {
2152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2153 "%s: STA Context is NULL",__func__);
2154 return -EINVAL;
2155 }
2156
2157
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302159 if (NULL == pWextState)
2160 {
2161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2162 "%s: pWextState is NULL",__func__);
2163 return -EINVAL;
2164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002165
2166 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2167 {
2168 return -ENXIO ;
2169 }
2170
2171 rate = wrqu->bitrate.value;
2172
2173 if (rate == -1)
2174 {
2175 rate = WNI_CFG_FIXED_RATE_AUTO;
2176 valid_rate = TRUE;
2177 }
2178 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2179 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2180 {
2181 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2182 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2183 {
2184 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2185 WNI_CFG_SUPPORTED_RATES_11A,
2186 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2187 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2188 WNI_CFG_SUPPORTED_RATES_11B,
2189 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2190 {
2191 for (i = 0; i < (b_len + a_len); ++i)
2192 {
2193 /* supported rates returned is double the actual rate so we divide it by 2 */
2194 if ((supp_rates[i]&0x7F)/2 == rate)
2195 {
2196 valid_rate = TRUE;
2197 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2198 break;
2199 }
2200 }
2201 }
2202 }
2203 }
2204 if (valid_rate != TRUE)
2205 {
2206 return -EINVAL;
2207 }
2208 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2209 WNI_CFG_FIXED_RATE, rate,
2210 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2211 {
c_hpothub8245442013-11-20 23:41:09 +05302212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2213 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 return -EIO;
2215 }
2216 return 0;
2217}
2218
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302219static int iw_set_bitrate(struct net_device *dev,
2220 struct iw_request_info *info,
2221 union iwreq_data *wrqu,
2222 char *extra)
2223{
2224 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302226 vos_ssr_protect(__func__);
2227 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2228 vos_ssr_unprotect(__func__);
2229
2230 return ret;
2231}
2232
2233static int __iw_set_genie(struct net_device *dev,
2234 struct iw_request_info *info,
2235 union iwreq_data *wrqu,
2236 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002237{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302238 hdd_adapter_t *pAdapter;
2239 hdd_context_t *pHddCtx;
2240 hdd_wext_state_t *pWextState;
2241 u_int8_t *genie = NULL;
2242 u_int8_t *base_genie = NULL;
2243 v_U16_t remLen;
2244 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002245
2246 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002247
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302248 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2249 if (NULL == pAdapter)
2250 {
2251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2252 "%s: Adapter is NULL",__func__);
2253 return -EINVAL;
2254 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002255
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302256 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2257 ret = wlan_hdd_validate_context(pHddCtx);
2258 if (0 != ret)
2259 {
2260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2261 "%s: HDD context is not valid",__func__);
2262 return ret;
2263 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002264
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302265 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2266 if (NULL == pWextState)
2267 {
2268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2269 "%s: pWextState is NULL",__func__);
2270 return -EINVAL;
2271 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002272
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302273 if (!wrqu->data.length) {
2274 hdd_clearRoamProfileIe(pAdapter);
2275 EXIT();
2276 return 0;
2277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002278
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302279 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2280 wrqu->data.length);
2281 if (NULL == base_genie)
2282 {
2283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2284 "mem_alloc_copy_from_user_helper fail");
2285 return -ENOMEM;
2286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002287
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302288 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002289
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302290 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002291
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302292 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2293
2294 /* clear any previous genIE before this call */
2295 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2296
2297 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 {
2299 v_U16_t eLen = 0;
2300 v_U8_t elementId;
2301 elementId = *genie++;
2302 eLen = *genie++;
2303 remLen -= 2;
2304
Arif Hussain6d2a3322013-11-17 19:50:10 -08002305 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 __func__, elementId, eLen);
2307
2308 switch ( elementId )
2309 {
2310 case IE_EID_VENDOR:
2311 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002312 {
2313 kfree(base_genie);
2314 return -EINVAL;
2315 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002316
2317 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2318 {
2319 v_U16_t curGenIELen = pWextState->genIE.length;
2320 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2321 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2322
2323 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2324 {
2325 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002326 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002328 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 return -ENOMEM;
2330 }
2331 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2332 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2333 pWextState->genIE.length += eLen + 2;
2334 }
2335 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2336 {
2337 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2338 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2339 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2340 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2341 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2342 }
2343 else /* any vendorId except WPA IE should be accumulated to genIE */
2344 {
2345 v_U16_t curGenIELen = pWextState->genIE.length;
2346 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2347 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2348
2349 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2350 {
2351 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002352 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002354 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 return -ENOMEM;
2356 }
2357 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2358 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2359 pWextState->genIE.length += eLen + 2;
2360 }
2361 break;
2362 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002363 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2365 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2366 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2367 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2368 break;
2369
2370 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002371 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002372 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 return 0;
2374 }
2375 genie += eLen;
2376 remLen -= eLen;
2377 }
2378 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002379 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 return 0;
2381}
2382
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302383static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 struct iw_request_info *info,
2385 union iwreq_data *wrqu,
2386 char *extra)
2387{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302388 int ret;
2389
2390 vos_ssr_protect(__func__);
2391 ret = __iw_set_genie(dev, info, wrqu, extra);
2392 vos_ssr_unprotect(__func__);
2393
2394 return ret;
2395}
2396
2397static int __iw_get_genie(struct net_device *dev,
2398 struct iw_request_info *info,
2399 union iwreq_data *wrqu,
2400 char *extra)
2401{
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302403 hdd_context_t *pHddCtx;
2404 hdd_adapter_t *pAdapter;
2405 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 eHalStatus status;
2407 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2408 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2409
2410 ENTER();
2411
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302412 hddLog(LOG1,"getGEN_IE ioctl");
2413 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2414 if (NULL == pAdapter)
2415 {
2416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2417 "%s: Adapter is NULL",__func__);
2418 return -EINVAL;
2419 }
2420 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2421 status = wlan_hdd_validate_context(pHddCtx);
2422 if (0 != status)
2423 {
2424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2425 "%s: HDD context is not valid",__func__);
2426 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 }
2428
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302430 if (NULL == pWextState)
2431 {
2432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2433 "%s: pWextState is NULL",__func__);
2434 return -EINVAL;
2435 }
2436
2437 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2438 if (NULL == pHddStaCtx)
2439 {
2440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2441 "%s: STA Context is NULL",__func__);
2442 return -EINVAL;
2443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002444
2445 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2446 {
2447 return -ENXIO;
2448 }
2449
2450 // Return something ONLY if we are associated with an RSN or WPA network
2451 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2452 pWextState->roamProfile.negotiatedAuthType))
2453 {
2454 return -ENXIO;
2455 }
2456
2457 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2458 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2459 pAdapter->sessionId,
2460 &length,
2461 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002462 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2463 if (wrqu->data.length < length)
2464 {
2465 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2466 return -EFAULT;
2467 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002468 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002469 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002470
Arif Hussain6d2a3322013-11-17 19:50:10 -08002471 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002472
2473 EXIT();
2474
2475 return 0;
2476}
2477
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302478static int iw_get_genie(struct net_device *dev,
2479 struct iw_request_info *info,
2480 union iwreq_data *wrqu,
2481 char *extra)
2482{
2483 int ret;
2484
2485 vos_ssr_protect(__func__);
2486 ret = __iw_get_genie(dev, info, wrqu, extra);
2487 vos_ssr_unprotect(__func__);
2488
2489 return ret;
2490}
2491
2492
2493static int __iw_get_encode(struct net_device *dev,
2494 struct iw_request_info *info,
2495 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002496{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302497 hdd_adapter_t *pAdapter;
2498 hdd_context_t *pHddCtx;
2499 hdd_wext_state_t *pWextState;
2500 tCsrRoamProfile *pRoamProfile;
2501 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002503
2504 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302505 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2506 if (NULL == pAdapter)
2507 {
2508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2509 "%s: Adapter is NULL",__func__);
2510 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 }
2512
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302513 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2514 ret = wlan_hdd_validate_context(pHddCtx);
2515 if (0 != ret)
2516 {
2517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2518 "%s: HDD context is not valid",__func__);
2519 return ret;
2520 }
2521 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2522 if (NULL == pWextState)
2523 {
2524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2525 "%s: pWextState is NULL",__func__);
2526 return -EINVAL;
2527 }
2528
2529 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 keyId = pRoamProfile->Keys.defaultIndex;
2531
2532 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2533 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002534 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 return -EINVAL;
2536 }
2537
2538 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2539 {
2540 dwrq->flags |= IW_ENCODE_ENABLED;
2541 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2542 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2543
2544 dwrq->flags |= (keyId + 1);
2545
2546 }
2547 else
2548 {
2549 dwrq->flags |= IW_ENCODE_DISABLED;
2550 }
2551
2552 for(i=0; i < MAX_WEP_KEYS; i++)
2553 {
2554 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2555 {
2556 continue;
2557 }
2558 else
2559 {
2560 break;
2561 }
2562 }
2563
2564 if(MAX_WEP_KEYS == i)
2565 {
2566 dwrq->flags |= IW_ENCODE_NOKEY;
2567 }
2568
2569 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2570
2571 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2572 {
2573 dwrq->flags |= IW_ENCODE_OPEN;
2574 }
2575 else
2576 {
2577 dwrq->flags |= IW_ENCODE_RESTRICTED;
2578 }
2579 EXIT();
2580 return 0;
2581}
2582
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302583static int iw_get_encode(struct net_device *dev,
2584 struct iw_request_info *info,
2585 struct iw_point *dwrq, char *extra)
2586{
2587 int ret;
2588
2589 vos_ssr_protect(__func__);
2590 ret = __iw_get_encode(dev, info, dwrq, extra);
2591 vos_ssr_unprotect(__func__);
2592
2593 return ret;
2594}
2595
Jeff Johnson295189b2012-06-20 16:38:30 -07002596#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2597#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2598
2599
2600/*
2601 * This function sends a single 'key' to LIM at all time.
2602 */
2603
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302604static int __iw_get_rts_threshold(struct net_device *dev,
2605 struct iw_request_info *info,
2606 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002607{
2608 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2609 v_U32_t status = 0;
2610
2611 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2612
2613 return status;
2614}
2615
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302616static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 struct iw_request_info *info,
2618 union iwreq_data *wrqu, char *extra)
2619{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302620 int ret;
2621
2622 vos_ssr_protect(__func__);
2623 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2624 vos_ssr_unprotect(__func__);
2625
2626 return ret;
2627}
2628
2629static int __iw_set_rts_threshold(struct net_device *dev,
2630 struct iw_request_info *info,
2631 union iwreq_data *wrqu, char *extra)
2632{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302633 hdd_adapter_t *pAdapter;
2634 hdd_context_t *pHddCtx;
2635 tHalHandle hHal;
2636 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002637
2638 ENTER();
2639
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302640 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2641 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002642 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2644 "%s: Adapter is NULL",__func__);
2645 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002646 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302647
2648 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2649 ret = wlan_hdd_validate_context(pHddCtx);
2650 if (0 != ret)
2651 {
2652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2653 "%s: HDD context is not valid",__func__);
2654 return ret;
2655 }
2656
2657 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2658 if (NULL == hHal)
2659 {
2660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2661 "%s: Hal Context is NULL",__func__);
2662 return -EINVAL;
2663 }
2664
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2666 {
2667 return -EINVAL;
2668 }
2669
2670 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2671 {
c_hpothub8245442013-11-20 23:41:09 +05302672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2673 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 return -EIO;
2675 }
2676
2677 EXIT();
2678
2679 return 0;
2680}
2681
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302682static int iw_set_rts_threshold(struct net_device *dev,
2683 struct iw_request_info *info,
2684 union iwreq_data *wrqu, char *extra)
2685{
2686 int ret;
2687
2688 vos_ssr_protect(__func__);
2689 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2690 vos_ssr_unprotect(__func__);
2691
2692 return ret;
2693}
2694
2695static int __iw_get_frag_threshold(struct net_device *dev,
2696 struct iw_request_info *info,
2697 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002698{
2699 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2700 v_U32_t status = 0;
2701
2702 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2703
2704 return status;
2705}
2706
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302707static int iw_get_frag_threshold(struct net_device *dev,
2708 struct iw_request_info *info,
2709 union iwreq_data *wrqu, char *extra)
2710{
2711 int ret;
2712
2713 vos_ssr_protect(__func__);
2714 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2715 vos_ssr_unprotect(__func__);
2716
2717 return ret;
2718}
2719
2720static int __iw_set_frag_threshold(struct net_device *dev,
2721 struct iw_request_info *info,
2722 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002723{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302724 hdd_adapter_t *pAdapter;
2725 hdd_context_t *pHddCtx;
2726 tHalHandle hHal;
2727 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002728
2729 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302730 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2731 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002732 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2734 "%s: Adapter is NULL",__func__);
2735 return -EINVAL;
2736 }
2737
2738 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2739 ret = wlan_hdd_validate_context(pHddCtx);
2740 if (0 != ret)
2741 {
2742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2743 "%s: HDD context is not valid",__func__);
2744 return ret;
2745 }
2746
2747 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2748 if (NULL == hHal)
2749 {
2750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2751 "%s: Hal Context is NULL",__func__);
2752 return -EINVAL;
2753 }
2754
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2756 {
2757 return -EINVAL;
2758 }
2759
2760 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2761 {
c_hpothub8245442013-11-20 23:41:09 +05302762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2763 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 return -EIO;
2765 }
2766
2767 EXIT();
2768
2769 return 0;
2770}
2771
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302772static int iw_set_frag_threshold(struct net_device *dev,
2773 struct iw_request_info *info,
2774 union iwreq_data *wrqu, char *extra)
2775{
2776 int ret;
2777
2778 vos_ssr_protect(__func__);
2779 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2780 vos_ssr_unprotect(__func__);
2781
2782 return ret;
2783}
2784
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302785static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 struct iw_request_info *info,
2787 union iwreq_data *wrqu, char *extra)
2788{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302789 hdd_adapter_t *pAdapter;
2790 hdd_context_t *pHddCtx;
2791 int ret = 0;
2792
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302794 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2795 if (NULL == pAdapter)
2796 {
2797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2798 "%s: Adapter is NULL",__func__);
2799 return -EINVAL;
2800 }
2801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2802 ret = wlan_hdd_validate_context(pHddCtx);
2803 if (0 != ret)
2804 {
2805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2806 "%s: HDD context is not valid",__func__);
2807 return ret;
2808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 return -EOPNOTSUPP;
2810}
2811
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302812static int iw_get_power_mode(struct net_device *dev,
2813 struct iw_request_info *info,
2814 union iwreq_data *wrqu, char *extra)
2815{
2816 int ret;
2817
2818 vos_ssr_protect(__func__);
2819 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2820 vos_ssr_unprotect(__func__);
2821
2822 return ret;
2823}
2824static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 struct iw_request_info *info,
2826 union iwreq_data *wrqu, char *extra)
2827{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302828 hdd_adapter_t *pAdapter;
2829 hdd_context_t *pHddCtx;
2830 int ret = 0;
2831
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302833 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2834 if (NULL == pAdapter)
2835 {
2836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2837 "%s: Adapter is NULL",__func__);
2838 return -EINVAL;
2839 }
2840 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2841 ret = wlan_hdd_validate_context(pHddCtx);
2842 if (0 != ret)
2843 {
2844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2845 "%s: HDD context is not valid",__func__);
2846 return ret;
2847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 return -EOPNOTSUPP;
2849}
2850
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302851static int iw_set_power_mode(struct net_device *dev,
2852 struct iw_request_info *info,
2853 union iwreq_data *wrqu, char *extra)
2854{
2855 int ret;
2856
2857 vos_ssr_protect(__func__);
2858 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2859 vos_ssr_unprotect(__func__);
2860
2861 return ret;
2862}
2863
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302864static int __iw_get_range(struct net_device *dev,
2865 struct iw_request_info *info,
2866 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002867{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302868 hdd_adapter_t *pAdapter;
2869 tHalHandle hHal;
2870 hdd_context_t *pHddCtx;
2871 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 struct iw_range *range = (struct iw_range *) extra;
2873
2874 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2875
2876 v_U32_t num_channels = sizeof(channels);
2877 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2878 v_U32_t a_len;
2879 v_U32_t b_len;
2880 v_U32_t active_phy_mode = 0;
2881 v_U8_t index = 0, i;
2882
2883 ENTER();
2884
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302885 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2886 if (NULL == pAdapter)
2887 {
2888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2889 "%s: pAdapter is NULL", __func__);
2890 return -EINVAL;
2891 }
2892 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2893 ret = wlan_hdd_validate_context(pHddCtx);
2894 if (0 != ret)
2895 {
2896 hddLog(VOS_TRACE_LEVEL_ERROR,
2897 "%s: HDD context is not valid",__func__);
2898 return ret;
2899 }
2900 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2901 if (NULL == hHal)
2902 {
2903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2904 "%s: pAdapter is NULL", __func__);
2905 return -EINVAL;
2906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 wrqu->data.length = sizeof(struct iw_range);
2908 memset(range, 0, sizeof(struct iw_range));
2909
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 /*Get the phy mode*/
2911 if (ccmCfgGetInt(hHal,
2912 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2913 {
2914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002915 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002916
2917 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2918 {
2919 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002920 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 if (ccmCfgGetStr(hHal,
2922 WNI_CFG_SUPPORTED_RATES_11A,
2923 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2924 {
2925 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2926 {
2927 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2928 }
2929 for (i = 0; i < a_len; i++)
2930 {
2931 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2932 }
2933 range->num_bitrates = a_len;
2934 }
2935 else
2936 {
2937 return -EIO;
2938 }
2939 }
2940 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2941 {
2942 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002943 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 if (ccmCfgGetStr(hHal,
2945 WNI_CFG_SUPPORTED_RATES_11B,
2946 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2947 {
2948 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2949 {
2950 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2951 }
2952 for (i = 0; i < b_len; i++)
2953 {
2954 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2955 }
2956 range->num_bitrates = b_len;
2957 }
2958 else
2959 {
2960 return -EIO;
2961 }
2962 }
2963 }
2964
2965 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2966 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2967 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2968
2969 range->encoding_size[0] = 5;
2970 range->encoding_size[1] = 13;
2971 range->num_encoding_sizes = 2;
2972 range->max_encoding_tokens = MAX_WEP_KEYS;
2973
2974 // we support through Wireless Extensions 22
2975 range->we_version_compiled = WIRELESS_EXT;
2976 range->we_version_source = 22;
2977
2978 /*Supported Channels and Frequencies*/
2979 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2980 {
c_hpothub8245442013-11-20 23:41:09 +05302981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2982 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 return -EIO;
2984 }
2985 if (num_channels > IW_MAX_FREQUENCIES)
2986 {
2987 num_channels = IW_MAX_FREQUENCIES;
2988 }
2989
2990 range->num_channels = num_channels;
2991 range->num_frequency = num_channels;
2992
2993 for (index=0; index < num_channels; index++)
2994 {
2995 v_U32_t frq_indx = 0;
2996
2997 range->freq[index].i = channels[index];
2998 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2999 {
3000 if(channels[index] == freq_chan_map[frq_indx].chan)
3001 {
3002 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3003 range->freq[index].e = 1;
3004 break;
3005 }
3006 frq_indx++;
3007 }
3008 }
3009
3010 /* Event capability (kernel + driver) */
3011 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3012 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3013 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3014 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3015
3016 /*Encryption capability*/
3017 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3018 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3019
3020 /* Txpower capability */
3021 range->txpower_capa = IW_TXPOW_MWATT;
3022
3023 /*Scanning capability*/
3024 #if WIRELESS_EXT >= 22
3025 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3026 #endif
3027
3028 EXIT();
3029 return 0;
3030}
3031
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303032static int iw_get_range(struct net_device *dev,
3033 struct iw_request_info *info,
3034 union iwreq_data *wrqu, char *extra)
3035{
3036 int ret;
3037
3038 vos_ssr_protect(__func__);
3039 ret = __iw_get_range(dev, info, wrqu, extra);
3040 vos_ssr_unprotect(__func__);
3041
3042 return ret;
3043}
3044
Jeff Johnson295189b2012-06-20 16:38:30 -07003045/* Callback function registered with PMC to know status of PMC request */
3046static void iw_power_callback_fn (void *pContext, eHalStatus status)
3047{
3048 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003049
3050 if (NULL == pContext)
3051 {
3052 hddLog(VOS_TRACE_LEVEL_ERROR,
3053 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003054 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003055 return;
3056 }
3057
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003059
Jeff Johnson72a40512013-12-19 10:14:15 -08003060 /* there is a race condition that exists between this callback
3061 function and the caller since the caller could time out either
3062 before or while this code is executing. we use a spinlock to
3063 serialize these actions */
3064 spin_lock(&hdd_context_lock);
3065
3066 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 {
3068 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003069 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003071 "%s: Invalid context, magic [%08x]",
3072 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003073
3074 if (ioctl_debug)
3075 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003076 pr_info("%s: Invalid context, magic [%08x]\n",
3077 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 }
3079 return;
3080 }
3081
Jeff Johnson72a40512013-12-19 10:14:15 -08003082 /* context is valid so caller is still waiting */
3083
3084 /* paranoia: invalidate the magic */
3085 pStatsContext->magic = 0;
3086
3087 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003089
3090 /* serialization is complete */
3091 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003092}
3093
3094/* Callback function for tx per hit */
3095void hdd_tx_per_hit_cb (void *pCallbackContext)
3096{
3097 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3098 unsigned char tx_fail[16];
3099 union iwreq_data wrqu;
3100
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303101 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003103 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 return;
3105 }
3106 memset(&wrqu, 0, sizeof(wrqu));
3107 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3108 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3109}
3110
3111void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3112{
3113 struct statsContext *pStatsContext;
3114 tCsrGlobalClassAStatsInfo *pClassAStats;
3115 hdd_adapter_t *pAdapter;
3116
3117 if (ioctl_debug)
3118 {
3119 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003120 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 }
3122
3123 if ((NULL == pStats) || (NULL == pContext))
3124 {
3125 hddLog(VOS_TRACE_LEVEL_ERROR,
3126 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003127 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 return;
3129 }
3130
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 pClassAStats = pStats;
3132 pStatsContext = pContext;
3133 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003134
3135 /* there is a race condition that exists between this callback
3136 function and the caller since the caller could time out either
3137 before or while this code is executing. we use a spinlock to
3138 serialize these actions */
3139 spin_lock(&hdd_context_lock);
3140
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3142 {
3143 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003144 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 hddLog(VOS_TRACE_LEVEL_WARN,
3146 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003147 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 if (ioctl_debug)
3149 {
3150 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003151 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 }
3153 return;
3154 }
3155
Jeff Johnson72a40512013-12-19 10:14:15 -08003156 /* context is valid so caller is still waiting */
3157
3158 /* paranoia: invalidate the magic */
3159 pStatsContext->magic = 0;
3160
3161 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3163
Jeff Johnson72a40512013-12-19 10:14:15 -08003164 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003166
3167 /* serialization is complete */
3168 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003169}
3170
3171VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3172{
3173 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3174 eHalStatus hstatus;
3175 long lrc;
3176 struct statsContext context;
3177
3178 if (NULL == pAdapter)
3179 {
3180 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3181 return VOS_STATUS_E_FAULT;
3182 }
3183 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3184 {
3185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3186 return VOS_STATUS_SUCCESS;
3187 }
3188
3189 /* we are connected
3190 prepare our callback context */
3191 init_completion(&context.completion);
3192 context.pAdapter = pAdapter;
3193 context.magic = STATS_CONTEXT_MAGIC;
3194 /* query only for Class A statistics (which include link speed) */
3195 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3196 eCSR_HDD,
3197 SME_GLOBAL_CLASSA_STATS,
3198 hdd_GetClassA_statisticsCB,
3199 0, // not periodic
3200 FALSE, //non-cached results
3201 pHddStaCtx->conn_info.staId[0],
3202 &context);
3203 if (eHAL_STATUS_SUCCESS != hstatus)
3204 {
3205 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003206 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003207 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 /* we'll returned a cached value below */
3209 }
3210 else
3211 {
3212 /* request was sent -- wait for the response */
3213 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3214 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 if (lrc <= 0)
3216 {
3217 hddLog(VOS_TRACE_LEVEL_ERROR,
3218 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003219 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 }
3221 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003222
3223 /* either we never sent a request, we sent a request and received a
3224 response or we sent a request and timed out. if we never sent a
3225 request or if we sent a request and got a response, we want to
3226 clear the magic out of paranoia. if we timed out there is a
3227 race condition such that the callback function could be
3228 executing at the same time we are. of primary concern is if the
3229 callback function had already verified the "magic" but had not
3230 yet set the completion variable when a timeout occurred. we
3231 serialize these activities by invalidating the magic while
3232 holding a shared spinlock which will cause us to block if the
3233 callback is currently executing */
3234 spin_lock(&hdd_context_lock);
3235 context.magic = 0;
3236 spin_unlock(&hdd_context_lock);
3237
3238 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 return VOS_STATUS_SUCCESS;
3240}
3241
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003242static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3243{
3244 struct statsContext *pStatsContext;
3245 tCsrSummaryStatsInfo *pSummaryStats;
3246 tCsrGlobalClassAStatsInfo *pClassAStats;
3247 hdd_adapter_t *pAdapter;
3248
3249 if (ioctl_debug)
3250 {
3251 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003252 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003253 }
3254
3255 if ((NULL == pStats) || (NULL == pContext))
3256 {
3257 hddLog(VOS_TRACE_LEVEL_ERROR,
3258 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003259 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003260 return;
3261 }
3262
Jeff Johnson72a40512013-12-19 10:14:15 -08003263 /* there is a race condition that exists between this callback
3264 function and the caller since the caller could time out either
3265 before or while this code is executing. we use a spinlock to
3266 serialize these actions */
3267 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003268
3269 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3270 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3271 pStatsContext = pContext;
3272 pAdapter = pStatsContext->pAdapter;
3273 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3274 {
3275 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003276 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003277 hddLog(VOS_TRACE_LEVEL_WARN,
3278 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003279 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003280 if (ioctl_debug)
3281 {
3282 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003283 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003284 }
3285 return;
3286 }
3287
Jeff Johnson72a40512013-12-19 10:14:15 -08003288 /* context is valid so caller is still waiting */
3289
3290 /* paranoia: invalidate the magic */
3291 pStatsContext->magic = 0;
3292
3293 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003294 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3295 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3296
Jeff Johnson72a40512013-12-19 10:14:15 -08003297 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003298 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003299
3300 /* serialization is complete */
3301 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003302}
3303
3304VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3305{
3306 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3307 eHalStatus hstatus;
3308 long lrc;
3309 struct statsContext context;
3310
3311 if (NULL == pAdapter)
3312 {
3313 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3314 return VOS_STATUS_SUCCESS;
3315 }
3316
3317 /* we are connected
3318 prepare our callback context */
3319 init_completion(&context.completion);
3320 context.pAdapter = pAdapter;
3321 context.magic = STATS_CONTEXT_MAGIC;
3322
3323 /* query only for Summary & Class A statistics */
3324 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3325 eCSR_HDD,
3326 SME_SUMMARY_STATS |
3327 SME_GLOBAL_CLASSA_STATS,
3328 hdd_get_station_statisticsCB,
3329 0, // not periodic
3330 FALSE, //non-cached results
3331 pHddStaCtx->conn_info.staId[0],
3332 &context);
3333 if (eHAL_STATUS_SUCCESS != hstatus)
3334 {
3335 hddLog(VOS_TRACE_LEVEL_ERROR,
3336 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003337 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003338 /* we'll return with cached values */
3339 }
3340 else
3341 {
3342 /* request was sent -- wait for the response */
3343 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3344 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003345
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003346 if (lrc <= 0)
3347 {
3348 hddLog(VOS_TRACE_LEVEL_ERROR,
3349 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003350 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003351 }
3352 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003353
3354 /* either we never sent a request, we sent a request and received a
3355 response or we sent a request and timed out. if we never sent a
3356 request or if we sent a request and got a response, we want to
3357 clear the magic out of paranoia. if we timed out there is a
3358 race condition such that the callback function could be
3359 executing at the same time we are. of primary concern is if the
3360 callback function had already verified the "magic" but had not
3361 yet set the completion variable when a timeout occurred. we
3362 serialize these activities by invalidating the magic while
3363 holding a shared spinlock which will cause us to block if the
3364 callback is currently executing */
3365 spin_lock(&hdd_context_lock);
3366 context.magic = 0;
3367 spin_unlock(&hdd_context_lock);
3368
3369 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003370 return VOS_STATUS_SUCCESS;
3371}
3372
3373
Jeff Johnson295189b2012-06-20 16:38:30 -07003374/*
3375 * Support for the LINKSPEED private command
3376 * Per the WiFi framework the response must be of the form
3377 * "LinkSpeed xx"
3378 */
3379static int iw_get_linkspeed(struct net_device *dev,
3380 struct iw_request_info *info,
3381 union iwreq_data *wrqu, char *extra)
3382{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303383 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303384 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303386 int len = sizeof(v_U32_t) + 1;
3387 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303388 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303389 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303390 int rc, valid = 0;
3391
3392 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3393 if (NULL == pAdapter)
3394 {
3395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3396 "%s: Adapter is NULL",__func__);
3397 return -EINVAL;
3398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003399
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303400 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303401 valid = wlan_hdd_validate_context(pHddCtx);
3402
3403 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003404 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303405 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid %d"), valid);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303406 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003407 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303408 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3409 if (NULL == pHddStaCtx)
3410 {
3411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3412 "%s: STA Context is NULL",__func__);
3413 return -EINVAL;
3414 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3416 {
3417 /* we are not connected so we don't have a classAstats */
3418 link_speed = 0;
3419 }
3420 else
3421 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303422 status = wlan_hdd_get_classAstats(pAdapter);
3423
3424 if (!VOS_IS_STATUS_SUCCESS(status ))
3425 {
3426 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3427 return -EINVAL;
3428 }
3429
3430 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3431 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3432 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3433 &link_speed);
3434
3435 link_speed = link_speed / 10;
3436
3437 if (0 == link_speed)
3438 {
3439 /* The linkspeed returned by HAL is in units of 500kbps.
3440 * converting it to mbps.
3441 * This is required to support legacy firmware which does
3442 * not return link capacity.
3443 */
3444 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3445 }
3446
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 }
3448
3449 wrqu->data.length = len;
3450 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003451 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 if ((rc < 0) || (rc >= len))
3453 {
3454 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303455 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 return -EIO;
3457 }
3458
3459 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003460 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003461}
3462
Arif Hussain695279c2014-03-24 14:06:07 -07003463/*
3464 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3465 *
3466 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303467static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003468 struct iw_request_info *info,
3469 union iwreq_data *wrqu, char *extra)
3470{
3471 int rc;
3472
3473 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3474
3475 if (rc < 0)
3476 return rc;
3477
3478 /* a value is being successfully returned */
3479 return 0;
3480}
Jeff Johnson295189b2012-06-20 16:38:30 -07003481
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303482static int iw_get_linkspeed_priv(struct net_device *dev,
3483 struct iw_request_info *info,
3484 union iwreq_data *wrqu, char *extra)
3485{
3486 int ret;
3487
3488 vos_ssr_protect(__func__);
3489 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3490 vos_ssr_unprotect(__func__);
3491
3492 return ret;
3493}
3494
Jeff Johnson295189b2012-06-20 16:38:30 -07003495/*
3496 * Support for the RSSI & RSSI-APPROX private commands
3497 * Per the WiFi framework the response must be of the form
3498 * "<ssid> rssi <xx>"
3499 * unless we are not associated, in which case the response is
3500 * "OK"
3501 */
3502static int iw_get_rssi(struct net_device *dev,
3503 struct iw_request_info *info,
3504 union iwreq_data *wrqu, char *extra)
3505{
3506 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003507 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 int len = wrqu->data.length;
3509 v_S7_t s7Rssi = 0;
3510 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3511 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3512 VOS_STATUS vosStatus;
3513 int rc;
3514
3515 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3516 (0 == ssidlen) || (ssidlen >= len))
3517 {
3518 /* we are not connected or our SSID is too long
3519 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003520 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 }
3522 else
3523 {
3524 /* we are connected with a valid SSID
3525 so we can write the SSID into the return buffer
3526 (note that it is not NUL-terminated) */
3527 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3528
3529 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3530
3531 if (VOS_STATUS_SUCCESS == vosStatus)
3532 {
3533 /* append the rssi to the ssid in the format required by
3534 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003535 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303536 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003537 }
3538 else
3539 {
3540 rc = -1;
3541 }
3542 }
3543
3544 /* verify that we wrote a valid response */
3545 if ((rc < 0) || (rc >= len))
3546 {
3547 // encoding or length error?
3548 hddLog(VOS_TRACE_LEVEL_ERROR,
3549 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003550 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 return -EIO;
3552 }
3553
3554 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003555 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003556}
3557
3558/*
3559 * Support for SoftAP channel range private command
3560 */
3561static int iw_softap_set_channel_range( struct net_device *dev,
3562 int startChannel,
3563 int endChannel,
3564 int band)
3565{
Jeff Johnson43971f52012-07-17 12:26:56 -07003566 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 int ret = 0;
3568 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3569 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003570 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3571
Jeff Johnson295189b2012-06-20 16:38:30 -07003572
3573 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3574 if (VOS_STATUS_SUCCESS != status)
3575 {
3576 ret = -EINVAL;
3577 }
Yathish9f22e662012-12-10 14:21:35 -08003578 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 return ret;
3580}
3581
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303582static uint8 chartohex(char c)
3583{
3584 uint8 val = 0;
3585 if (c >= '0' && c <= '9')
3586 val = c - '0';
3587 else if (c >= 'a' && c <= 'f')
3588 val = c - 'a' + 10;
3589 else if (c >= 'A' && c <= 'F')
3590 val = c - 'A' + 10;
3591 else
3592 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3593
3594 return val;
3595}
3596
3597uint8 getByte(char **buf)
3598{
3599 uint8 byte = 0;
3600 char *temp = *buf;
3601 byte = chartohex(*temp) * 16;
3602 temp++;
3603 byte += chartohex(*temp);
3604 temp++;
3605 *buf = temp;
3606 return byte;
3607}
3608
3609static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3610{
3611 tSir80211Header *macHeader;
3612 int i = 0, j = 0, length = 0;
3613 uint8 byte = 0;
3614 char *temp = pBuffer;
3615 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303616 char *pHeader;
3617 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303618
3619 macHeader = &pkt->macHeader;
3620
3621 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3622
3623 temp++;
3624
3625 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3626 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3627 pkt->encParams.keyParams.key[0].keyId);
3628
3629 for (i = 0; i< 16; i++) {
3630 pkt->encParams.keyParams.key[0].key[i]
3631 = getByte(&temp);
3632 }
3633
3634 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3635 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3636
3637 for (i = 0; i< 6; i++) {
3638 pkt->encParams.pn[i]
3639 = getByte(&temp);
3640 }
3641
3642 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3643 &pkt->encParams.pn[0], 6, 0);
3644
3645 for (i = 0, j= 5; i< 3; i++, j--) {
3646 byte = pkt->encParams.pn[i];
3647 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3648 pkt->encParams.pn[j] = byte;
3649 }
3650
3651 length = getByte(&temp);
3652
Srinivas Dasari2382de62015-01-22 15:00:04 +05303653 pHeader = temp;
3654 vos_mem_zero(&header, sizeof(tSir80211Header));
3655 for (i = 0; i < length; i++) {
3656 *((uint8 *)&header + i) = getByte(&pHeader);
3657 }
3658
3659 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3660 (char *)&header, length, 0);
3661
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303662 byte = getByte(&temp);
3663
3664 macHeader->frameCtrl.protVer = byte & 0x3;
3665 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3666 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3667
3668 byte = getByte(&temp);
3669 macHeader->frameCtrl.toDS = (byte) & 0x1;
3670 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3671 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3672 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3673 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3674 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3675 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3676 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3677
3678 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3679 "macHeader->frameCtrl.type : %x "
3680 "macHeader->frameCtrl.subType : %x "
3681 "macHeader->frameCtrl.toDS : %x "
3682 "macHeader->frameCtrl.fromDS : %x "
3683 "macHeader->frameCtrl.moreFrag : %x "
3684 "macHeader->frameCtrl.retry : %x "
3685 "macHeader->frameCtrl.powerMgmt : %x "
3686 "macHeader->frameCtrl.MoreData : %x "
3687 "macHeader->frameCtrl.wep : %x "
3688 "macHeader->frameCtrl.order : %x "
3689 , macHeader->frameCtrl.protVer
3690 , macHeader->frameCtrl.type
3691 , macHeader->frameCtrl.subType
3692 , macHeader->frameCtrl.toDS
3693 , macHeader->frameCtrl.fromDS
3694 , macHeader->frameCtrl.moreFrag
3695 , macHeader->frameCtrl.retry
3696 , macHeader->frameCtrl.powerMgmt
3697 , macHeader->frameCtrl.moreData
3698 , macHeader->frameCtrl.wep
3699 , macHeader->frameCtrl.order);
3700
3701
3702 macHeader->usDurationId = getByte(&temp);
3703 macHeader->usDurationId += getByte(&temp) << 8;
3704
3705 macHeader->vA1[0] = getByte(&temp);
3706 macHeader->vA1[1] = getByte(&temp);
3707 macHeader->vA1[2] = getByte(&temp);
3708 macHeader->vA1[3] = getByte(&temp);
3709 macHeader->vA1[4] = getByte(&temp);
3710 macHeader->vA1[5] = getByte(&temp);
3711
3712 macHeader->vA2[0] = getByte(&temp);
3713 macHeader->vA2[1] = getByte(&temp);
3714 macHeader->vA2[2] = getByte(&temp);
3715 macHeader->vA2[3] = getByte(&temp);
3716 macHeader->vA2[4] = getByte(&temp);
3717 macHeader->vA2[5] = getByte(&temp);
3718
3719 macHeader->vA3[0] = getByte(&temp);
3720 macHeader->vA3[1] = getByte(&temp);
3721 macHeader->vA3[2] = getByte(&temp);
3722 macHeader->vA3[3] = getByte(&temp);
3723 macHeader->vA3[4] = getByte(&temp);
3724 macHeader->vA3[5] = getByte(&temp);
3725
3726 macHeader->sSeqCtrl = getByte(&temp);
3727 fragNum = macHeader->sSeqCtrl & 0xF;
3728 macHeader->sSeqCtrl >>= 4;
3729
3730 macHeader->sSeqCtrl += getByte(&temp) << 4;
3731
3732 macHeader->sSeqCtrl |= fragNum << 12;
3733
3734 if (length == 30 || length == 32) {
3735 macHeader->optvA4[0] = getByte(&temp);
3736 macHeader->optvA4[1] = getByte(&temp);
3737 macHeader->optvA4[2] = getByte(&temp);
3738 macHeader->optvA4[3] = getByte(&temp);
3739 macHeader->optvA4[4] = getByte(&temp);
3740 macHeader->optvA4[5] = getByte(&temp);
3741 }
3742
3743 if (length == 26 || length == 32) {
3744 macHeader->usQosCtrl = getByte(&temp);
3745 macHeader->usQosCtrl += getByte(&temp) << 8;
3746 }
3747
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303748 //parse payload
3749 length = getByte(&temp);
3750 length += getByte(&temp) << 8;
3751 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3752
3753 pkt->data.length = length;
3754
3755 for (i = 0; i< length; i++) {
3756 pkt->data.data[i] = getByte(&temp);
3757 }
3758
3759 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3760 &pkt->data.data[0], pkt->data.length, 0);
3761}
3762
3763/**---------------------------------------------------------------------------
3764
3765 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3766 encrypt message request
3767 This is an asynchronous callback function from SME when the encrypted data
3768 is received
3769
3770 \pEncInfoRsp -> Encrypted data info
3771
3772 \return - 0 for success non-zero for failure
3773 --------------------------------------------------------------------------*/
3774static void
3775hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3776{
3777 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3778
3779 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3780
3781 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3782 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3783 pEncryptedDataRsp->encryptedPayload.length);
3784 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3785 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3786 pEncryptedDataRsp->encryptedPayload.data,
3787 pEncryptedDataRsp->encryptedPayload.length, 0);
3788}
3789
Jeff Johnson295189b2012-06-20 16:38:30 -07003790VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3791{
3792 struct statsContext context;
3793 eHalStatus status;
3794 hdd_context_t *pHddCtx;
3795
3796 if (NULL == pAdapter)
3797 {
3798 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3799 return VOS_STATUS_E_FAULT;
3800 }
3801
3802 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3803 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303804 if (pHddCtx->isLogpInProgress) {
3805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3806 "%s:LOGP in Progress. Ignore!!!", __func__);
3807 return VOS_STATUS_E_FAILURE;
3808 }
3809
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 init_completion(&context.completion);
3811
3812 context.pAdapter = pAdapter;
3813 context.magic = POWER_CONTEXT_MAGIC;
3814
3815 if (DRIVER_POWER_MODE_ACTIVE == mode)
3816 {
3817 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3818 "Full Power", __func__);
3819 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3820 iw_power_callback_fn, &context,
3821 eSME_FULL_PWR_NEEDED_BY_HDD);
3822 // Enter Full power command received from GUI this means we are disconnected
3823 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3824 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
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 Johnson72a40512013-12-19 10:14:15 -08003831
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 if (lrc <= 0)
3833 {
3834 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003835 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 }
3837 }
3838 }
3839 else if (DRIVER_POWER_MODE_AUTO == mode)
3840 {
3841 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3842 {
3843 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3844 __func__);
3845 // Enter BMPS command received from GUI this means DHCP is completed
3846 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3847 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3848 FALSE);
3849 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3850 iw_power_callback_fn, &context);
3851 if (eHAL_STATUS_PMC_PENDING == status)
3852 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003853 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 int lrc = wait_for_completion_interruptible_timeout(
3855 &context.completion,
3856 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 if (lrc <= 0)
3858 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003859 hddLog(VOS_TRACE_LEVEL_ERROR,
3860 "%s: SME %s while requesting BMPS",
3861 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 }
3863 }
3864 }
3865 else
3866 {
3867 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3868 "enabled in the cfg");
3869 }
3870 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003871
3872 /* either we never sent a request, we sent a request and received a
3873 response or we sent a request and timed out. if we never sent a
3874 request or if we sent a request and got a response, we want to
3875 clear the magic out of paranoia. if we timed out there is a
3876 race condition such that the callback function could be
3877 executing at the same time we are. of primary concern is if the
3878 callback function had already verified the "magic" but had not
3879 yet set the completion variable when a timeout occurred. we
3880 serialize these activities by invalidating the magic while
3881 holding a shared spinlock which will cause us to block if the
3882 callback is currently executing */
3883 spin_lock(&hdd_context_lock);
3884 context.magic = 0;
3885 spin_unlock(&hdd_context_lock);
3886
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 return VOS_STATUS_SUCCESS;
3888}
3889
3890VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3891 hdd_adapter_t *pAdapter)
3892{
3893 VOS_STATUS vos_Status;
3894
3895 if ((NULL == pAdapter) || (NULL == pHddCtx))
3896 {
3897 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3898 return VOS_STATUS_E_FAULT;
3899 }
3900
3901 /**Exit from Deep sleep or standby if we get the driver
3902 START cmd from android GUI
3903 */
3904 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3905 {
3906 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3907 "from Stand by",__func__);
3908 vos_Status = hdd_exit_standby(pHddCtx);
3909 }
3910 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3911 {
3912 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3913 "from deep sleep",__func__);
3914 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3915 }
3916 else
3917 {
3918 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3919 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3920 vos_Status = VOS_STATUS_SUCCESS;
3921 }
3922
3923 return vos_Status;
3924}
3925
3926VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3927{
3928 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3929
3930 if (NULL == pHddCtx)
3931 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303932 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 return VOS_STATUS_E_FAULT;
3934 }
3935
3936 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3937 {
3938 //Execute standby procedure.
3939 //Executing standby procedure will cause the STA to
3940 //disassociate first and then the chip will be put into standby.
3941 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3942 vos_Status = hdd_enter_standby(pHddCtx);
3943 }
3944 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3945 pHddCtx->cfg_ini->nEnableDriverStop)
3946 {
3947 //Execute deep sleep procedure
3948 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003949 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 //Deep sleep not supported
3951 vos_Status = hdd_enter_standby(pHddCtx);
3952 }
3953 else
3954 {
3955 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3956 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3957 vos_Status = VOS_STATUS_SUCCESS;
3958 }
3959
3960 return vos_Status;
3961}
3962
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003963
3964void* wlan_hdd_change_country_code_callback(void *pAdapter)
3965{
3966
3967 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003968 complete(&call_back_pAdapter->change_country_code);
3969
3970 return NULL;
3971}
3972
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303973static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 struct iw_request_info *info,
3975 union iwreq_data *wrqu, char *extra)
3976{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303977 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08003978 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303980 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003981 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3982
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303983 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003984
3985 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303986
3987 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3988 if (NULL == pAdapter)
3989 {
3990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3991 "mem_alloc_copy_from_user_helper fail");
3992 return -EINVAL;
3993 }
3994 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3995 rc = wlan_hdd_validate_context(pHddCtx);
3996 if (0 != rc)
3997 {
3998 hddLog(VOS_TRACE_LEVEL_ERROR,
3999 "%s: HDD context is not valid", __func__);
4000 return rc;
4001 }
4002
Arif Hussain24bfa702014-01-22 13:51:30 -08004003 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4004 wrqu->data.length);
4005 if (NULL == cmd)
4006 {
4007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4008 "mem_alloc_copy_from_user_helper fail");
4009 return -ENOMEM;
4010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004011
4012 if (ioctl_debug)
4013 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004014 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 }
4016
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004017 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4018 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004019
Arif Hussain24bfa702014-01-22 13:51:30 -08004020 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004022 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4024 "%s: Error in iw_set_scan!", __func__);
4025 rc = -EINVAL;
4026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 }
4028 else if( strcasecmp(cmd, "start") == 0 ) {
4029
Arif Hussain6d2a3322013-11-17 19:50:10 -08004030 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004032
Arif Hussain24bfa702014-01-22 13:51:30 -08004033 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4034 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 {
4036 union iwreq_data wrqu;
4037 char buf[10];
4038
4039 memset(&wrqu, 0, sizeof(wrqu));
4040 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4041 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4042 }
4043 else
4044 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004045 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4046 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 }
4048 goto done;
4049 }
4050 else if( strcasecmp(cmd, "stop") == 0 )
4051 {
4052 union iwreq_data wrqu;
4053 char buf[10];
4054
Arif Hussain6d2a3322013-11-17 19:50:10 -08004055 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004056
4057 wlan_hdd_enter_lowpower(pHddCtx);
4058 memset(&wrqu, 0, sizeof(wrqu));
4059 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4060 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 goto done;
4062 }
4063 else if (strcasecmp(cmd, "macaddr") == 0)
4064 {
4065 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4066 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4067 }
4068 else if (strcasecmp(cmd, "scan-active") == 0)
4069 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304070 hddLog(VOS_TRACE_LEVEL_ERROR,
4071 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004072 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 ret = snprintf(cmd, cmd_len, "OK");
4074 }
4075 else if (strcasecmp(cmd, "scan-passive") == 0)
4076 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304077 hddLog(VOS_TRACE_LEVEL_ERROR,
4078 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004079 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 ret = snprintf(cmd, cmd_len, "OK");
4081 }
4082 else if( strcasecmp(cmd, "scan-mode") == 0 )
4083 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004084 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 }
4086 else if( strcasecmp(cmd, "linkspeed") == 0 )
4087 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004088 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 }
4090 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4091 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004092 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004093 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004094
4095 country_code = cmd + 8;
4096
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004097 init_completion(&pAdapter->change_country_code);
4098
Arif Hussain24bfa702014-01-22 13:51:30 -08004099 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004100 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 country_code,
4102 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304103 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304104 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304105 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004106
4107 /* Wait for completion */
4108 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4109 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4110
4111 if (lrc <= 0)
4112 {
4113 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004114 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004115 }
4116
Arif Hussain24bfa702014-01-22 13:51:30 -08004117 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004119 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004120 "%s: SME Change Country code fail", __func__);
4121 kfree(cmd);
4122 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 }
4124 }
4125 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4126 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004127 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 }
4129 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4130 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004131 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004132
Wilson Yang1be3e652013-10-09 15:18:31 -07004133 if (9 < cmd_len)
4134 {
4135 ptr = (char*)(cmd + 9);
4136
4137 }else{
4138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4139 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004140 kfree(cmd);
4141 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004142 }
4143
4144 if (1 != sscanf(ptr,"%d",&mode))
4145 {
4146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4147 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004148 kfree(cmd);
4149 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004150 }
4151
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 wlan_hdd_enter_bmps(pAdapter, mode);
4153 /*TODO:Set the power mode*/
4154 }
4155 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4156 v_U32_t pmc_state;
4157 v_U16_t value;
4158
4159 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4160 if(pmc_state == BMPS) {
4161 value = DRIVER_POWER_MODE_AUTO;
4162 }
4163 else {
4164 value = DRIVER_POWER_MODE_ACTIVE;
4165 }
4166 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4167 }
4168 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004169 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 /*TODO: set the btcoexmode*/
4171 }
4172 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4173
Arif Hussain6d2a3322013-11-17 19:50:10 -08004174 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 /*TODO: Return the btcoex status*/
4176 }
4177 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4178
Arif Hussain6d2a3322013-11-17 19:50:10 -08004179 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004180
4181 /*TODO: Enable Rx data Filter*/
4182 }
4183 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4184
Arif Hussain6d2a3322013-11-17 19:50:10 -08004185 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004186
4187 /*TODO: Disable Rx data Filter*/
4188 }
4189 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4190
Arif Hussain6d2a3322013-11-17 19:50:10 -08004191 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 /*TODO: rxfilter-statistics*/
4193 }
4194 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4195
Arif Hussain6d2a3322013-11-17 19:50:10 -08004196 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 /*TODO: rxfilter-add*/
4198 }
4199 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4200
Arif Hussain6d2a3322013-11-17 19:50:10 -08004201 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 /*TODO: rxfilter-remove*/
4203 }
4204#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004205 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4206 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4207 /*TODO: support pnosetup*/
4208 }
4209 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4210 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4211 /*TODO: support pnoforce*/
4212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4214
Arif Hussain6d2a3322013-11-17 19:50:10 -08004215 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004216 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4217 kfree(cmd);
4218 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 }
4220 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004221 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004222 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4223 kfree(cmd);
4224 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 }
4226#endif /*FEATURE_WLAN_SCAN_PNO*/
4227 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004228 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004229 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4230 kfree(cmd);
4231 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 }
4233 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4234 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004235 char *ptr;
4236
4237 if (18 < cmd_len)
4238 {
4239 ptr = (char*)(cmd + 18);
4240 }else{
4241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4242 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004243 kfree(cmd);
4244 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004245 }
4246
Jeff Johnson02797792013-10-26 19:17:13 -07004247 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004248 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4249 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4250 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4251 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4252 {
4253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4254 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004255 kfree(cmd);
4256 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004258
4259 // parameters checking
4260 // period has to be larger than 0
4261 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4262 {
4263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004264 kfree(cmd);
4265 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 }
4267
4268 // use default value 5 is the input is not reasonable. in unit of 10%
4269 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4270 {
4271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4272 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4273 }
4274
4275 // default is 5
4276 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4277 {
4278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4279 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4280 }
4281
Arif Hussain24bfa702014-01-22 13:51:30 -08004282 if (eHAL_STATUS_SUCCESS !=
4283 sme_SetTxPerTracking(pHddCtx->hHal,
4284 hdd_tx_per_hit_cb,
4285 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004287 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 }
4289 }
4290 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004291 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4292 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 }
4294done:
4295 /* many of the commands write information back into the command
4296 string using snprintf(). check the return value here in one
4297 place */
4298 if ((ret < 0) || (ret >= cmd_len))
4299 {
4300 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004301 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004303 else if (ret > 0)
4304 {
4305 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4306 {
4307 hddLog(VOS_TRACE_LEVEL_ERROR,
4308 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004309 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004310 return -EFAULT;
4311 }
4312 wrqu->data.length = ret;
4313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004314
4315 if (ioctl_debug)
4316 {
4317 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004318 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004320 kfree(cmd);
4321 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004322}
4323
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304324static int iw_set_priv(struct net_device *dev,
4325 struct iw_request_info *info,
4326 union iwreq_data *wrqu, char *extra)
4327{
4328 int ret;
4329 vos_ssr_protect(__func__);
4330 ret = __iw_set_priv(dev, info, wrqu, extra);
4331 vos_ssr_unprotect(__func__);
4332
4333 return ret;
4334}
4335
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304336static int __iw_set_nick(struct net_device *dev,
4337 struct iw_request_info *info,
4338 union iwreq_data *wrqu, char *extra)
4339{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304340 hdd_adapter_t *pAdapter;
4341 hdd_context_t *pHddCtx;
4342 int ret = 0;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304343 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304344
4345 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4346 if (NULL == pAdapter)
4347 {
4348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4349 "%s: Adapter is NULL",__func__);
4350 return -EINVAL;
4351 }
4352
4353 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4354 ret = wlan_hdd_validate_context(pHddCtx);
4355 if (0 != ret)
4356 {
4357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4358 "%s: HDD context is not valid",__func__);
4359 return ret;
4360 }
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304361 return 0;
4362}
4363
Jeff Johnson295189b2012-06-20 16:38:30 -07004364static int iw_set_nick(struct net_device *dev,
4365 struct iw_request_info *info,
4366 union iwreq_data *wrqu, char *extra)
4367{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304368 int ret;
4369
4370 vos_ssr_protect(__func__);
4371 ret = __iw_set_nick(dev, info, wrqu, extra);
4372 vos_ssr_unprotect(__func__);
4373
4374 return ret;
4375}
4376
4377static int __iw_get_nick(struct net_device *dev,
4378 struct iw_request_info *info,
4379 union iwreq_data *wrqu, char *extra)
4380{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304381 hdd_adapter_t *pAdapter;
4382 hdd_context_t *pHddCtx;
4383 int ret = 0;
4384
Jeff Johnson295189b2012-06-20 16:38:30 -07004385 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304386
4387 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4388 if (NULL == pAdapter)
4389 {
4390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4391 "%s: Adapter is NULL",__func__);
4392 return -EINVAL;
4393 }
4394
4395 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4396 ret = wlan_hdd_validate_context(pHddCtx);
4397 if (0 != ret)
4398 {
4399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4400 "%s: HDD context is not valid",__func__);
4401 return ret;
4402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 return 0;
4404}
4405
4406static int iw_get_nick(struct net_device *dev,
4407 struct iw_request_info *info,
4408 union iwreq_data *wrqu, char *extra)
4409{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304410 int ret;
4411
4412 vos_ssr_protect(__func__);
4413 ret = __iw_get_nick(dev, info, wrqu, extra);
4414 vos_ssr_unprotect(__func__);
4415
4416 return ret;
4417}
4418
4419static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4420{
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304422 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004423}
4424
4425static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4426{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304427
4428 struct iw_statistics *stats;
4429
4430 vos_ssr_protect(__func__);
4431 stats = __get_wireless_stats(dev);
4432 vos_ssr_unprotect(__func__);
4433
4434 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004435}
4436
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304437static int __iw_set_encode(struct net_device *dev,
4438 struct iw_request_info *info,
4439 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004440
4441{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304442 hdd_adapter_t *pAdapter;
4443 hdd_station_ctx_t *pHddStaCtx;
4444 hdd_wext_state_t *pWextState;
4445 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 struct iw_point *encoderq = &(wrqu->encoding);
4447 v_U32_t keyId;
4448 v_U8_t key_length;
4449 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4450 v_BOOL_t fKeyPresent = 0;
4451 int i;
4452 eHalStatus status = eHAL_STATUS_SUCCESS;
4453
4454
4455 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304456 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4457 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004458 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4460 "%s: Adapter is NULL",__func__);
4461 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 }
4463
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304464 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4465 status = wlan_hdd_validate_context(pHddCtx);
4466 if (0 != status)
4467 {
4468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4469 "%s: HDD context is not valid",__func__);
4470 return status;
4471 }
4472 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4473 if (NULL == pWextState)
4474 {
4475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4476 "%s: pWextState is NULL ",__func__);
4477 return -EINVAL;
4478 }
4479 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4480 if (NULL == pHddStaCtx)
4481 {
4482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4483 "%s: STA Context is NULL",__func__);
4484 return -EINVAL;
4485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004486
4487 keyId = encoderq->flags & IW_ENCODE_INDEX;
4488
4489 if(keyId)
4490 {
4491 if(keyId > MAX_WEP_KEYS)
4492 {
4493 return -EINVAL;
4494 }
4495
4496 fKeyPresent = 1;
4497 keyId--;
4498 }
4499 else
4500 {
4501 fKeyPresent = 0;
4502 }
4503
4504
4505 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4506 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 if(!fKeyPresent) {
4509
4510 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4511
4512 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4513 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4514 }
4515 }
4516 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4517 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4518 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4519 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4520
4521 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4522 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4523
4524 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4525 {
4526 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4527 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004528 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304529 {
4530 long ret;
4531 ret = wait_for_completion_interruptible_timeout(
4532 &pAdapter->disconnect_comp_var,
4533 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4534 if (ret <= 0)
4535 hddLog(VOS_TRACE_LEVEL_ERROR,
4536 FL("failed wait on disconnect_comp_var %ld"), ret);
4537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 }
4539
4540 return status;
4541
4542 }
4543
4544 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4545 {
4546 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4547
4548 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4549
4550 }
4551
4552
4553 if(wrqu->data.length > 0)
4554 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004555 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004556
4557 key_length = wrqu->data.length;
4558
4559 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4560
4561 if(5 == key_length)
4562 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004563 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004564
4565 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4566 {
4567 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4568 }
4569 else
4570 {
4571 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4572 }
4573 }
4574 else if(13 == key_length)
4575 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004576 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004577
4578 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4579 {
4580 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4581 }
4582 else
4583 {
4584 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4585 }
4586 }
4587 else
4588 {
4589 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004590 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 return -EINVAL;
4592 }
4593
4594 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4595 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4596 pWextState->roamProfile.EncryptionType.numEntries = 1;
4597 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4598 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4599 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4600
4601 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4602 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4603 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4604 {
4605
4606 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4607
4608 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4609 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4610
4611 return status;
4612 }
4613 }
4614
4615 return 0;
4616}
4617
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304618static int iw_set_encode(struct net_device *dev,
4619 struct iw_request_info *info,
4620 union iwreq_data *wrqu,char *extra)
4621{
4622 int ret;
4623
4624 vos_ssr_protect(__func__);
4625 ret = __iw_set_encode(dev, info, wrqu, extra);
4626 vos_ssr_unprotect(__func__);
4627
4628 return ret;
4629}
4630
4631static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 struct iw_request_info *info,
4633 struct iw_point *dwrq,
4634 char *extra)
4635{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304636 hdd_adapter_t *pAdapter;
4637 hdd_wext_state_t *pWextState;
4638 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 int keyId;
4640 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4641 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304642 int i, ret = 0;
4643 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004644
4645 ENTER();
4646
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304647 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4648 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004649 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4651 "%s: Adapter is NULL",__func__);
4652 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004653 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304654 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4655 ret = wlan_hdd_validate_context(pHddCtx);
4656 if (0 != ret)
4657 {
4658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4659 "%s: HDD context is not valid",__func__);
4660 return ret;
4661 }
4662 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4663 if (NULL == pWextState)
4664 {
4665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4666 "%s: pWextState is NULL",__func__);
4667 return -EINVAL;
4668 }
4669 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004670
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 keyId = pRoamProfile->Keys.defaultIndex;
4672
4673 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4674 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004675 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 return -EINVAL;
4677 }
4678
4679 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4680 {
4681 dwrq->flags |= IW_ENCODE_ENABLED;
4682 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304683 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4684 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 }
4686 else
4687 {
4688 dwrq->flags |= IW_ENCODE_DISABLED;
4689 }
4690
4691 for(i=0; i < MAX_WEP_KEYS; i++)
4692 {
4693 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4694 {
4695 continue;
4696 }
4697 else
4698 {
4699 break;
4700 }
4701 }
4702
4703 if(MAX_WEP_KEYS == i)
4704 {
4705 dwrq->flags |= IW_ENCODE_NOKEY;
4706 }
4707 else
4708 {
4709 dwrq->flags |= IW_ENCODE_ENABLED;
4710 }
4711
4712 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4713
4714 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4715 {
4716 dwrq->flags |= IW_ENCODE_DISABLED;
4717 }
4718
4719 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4720
4721 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4722 {
4723 dwrq->flags |= IW_ENCODE_OPEN;
4724 }
4725 else
4726 {
4727 dwrq->flags |= IW_ENCODE_RESTRICTED;
4728 }
4729 EXIT();
4730 return 0;
4731
4732}
4733
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304734static int iw_get_encodeext(struct net_device *dev,
4735 struct iw_request_info *info,
4736 struct iw_point *dwrq,
4737 char *extra)
4738{
4739 int ret;
4740 vos_ssr_protect(__func__);
4741 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4742 vos_ssr_unprotect(__func__);
4743
4744 return ret;
4745}
4746
4747static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 struct iw_request_info *info,
4749 union iwreq_data *wrqu, char *extra)
4750{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304751 hdd_adapter_t *pAdapter;
4752 hdd_station_ctx_t *pHddStaCtx;
4753 hdd_wext_state_t *pWextState;
4754 hdd_context_t *pHddCtx;
4755 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004756
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304757 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 v_U32_t status = 0;
4759
4760 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4761
4762 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4763
4764 int key_index;
4765 struct iw_point *encoding = &wrqu->encoding;
4766 tCsrRoamSetKey setKey;
4767 v_U32_t roamId= 0xFF;
4768 VOS_STATUS vos_status;
4769
4770 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304771 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4772 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4775 "%s: Adapter is NULL",__func__);
4776 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304778 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4779 status = wlan_hdd_validate_context(pHddCtx);
4780 if (0 != status)
4781 {
4782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4783 "%s: HDD context is not valid",__func__);
4784 return status;
4785 }
4786 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4787 if (NULL == pHddStaCtx)
4788 {
4789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4790 "%s: STA Context is NULL",__func__);
4791 return -EINVAL;
4792 }
4793 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4794 if (NULL == pWextState)
4795 {
4796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4797 "%s: pWextState is NULL",__func__);
4798 return -EINVAL;
4799 }
4800 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 key_index = encoding->flags & IW_ENCODE_INDEX;
4802
4803 if(key_index > 0) {
4804
4805 /*Convert from 1-based to 0-based keying*/
4806 key_index--;
4807 }
4808 if(!ext->key_len) {
4809
4810 /*Set the encrytion type to NONE*/
4811 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4812 return status;
4813 }
4814
4815 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4816 (IW_ENCODE_ALG_WEP == ext->alg))
4817 {
4818 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4819
Agarwal Ashish971c2882013-10-30 20:11:12 +05304820 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4821 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 return -EINVAL;
4823 }
4824 else {
4825 /*Static wep, update the roam profile with the keys */
4826 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4827 key_index < CSR_MAX_NUM_KEY) {
4828 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4829 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4830
4831 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4832 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4833
4834 }
4835 }
4836 return status;
4837 }
4838
4839 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4840
4841 setKey.keyId = key_index;
4842 setKey.keyLength = ext->key_len;
4843
4844 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4845 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4846 }
4847
4848 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4849 /*Key direction for group is RX only*/
4850 setKey.keyDirection = eSIR_RX_ONLY;
4851 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4852 }
4853 else {
4854
4855 setKey.keyDirection = eSIR_TX_RX;
4856 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4857 }
4858
4859 /*For supplicant pae role is zero*/
4860 setKey.paeRole = 0;
4861
4862 switch(ext->alg)
4863 {
4864 case IW_ENCODE_ALG_NONE:
4865 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4866 break;
4867
4868 case IW_ENCODE_ALG_WEP:
4869 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4870 break;
4871
4872 case IW_ENCODE_ALG_TKIP:
4873 {
4874 v_U8_t *pKey = &setKey.Key[0];
4875
4876 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4877
4878 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4879
4880 /*Supplicant sends the 32bytes key in this order
4881
4882 |--------------|----------|----------|
4883 | Tk1 |TX-MIC | RX Mic |
4884 |--------------|----------|----------|
4885 <---16bytes---><--8bytes--><--8bytes-->
4886
4887 */
4888 /*Sme expects the 32 bytes key to be in the below order
4889
4890 |--------------|----------|----------|
4891 | Tk1 |RX-MIC | TX Mic |
4892 |--------------|----------|----------|
4893 <---16bytes---><--8bytes--><--8bytes-->
4894 */
4895 /* Copy the Temporal Key 1 (TK1) */
4896 vos_mem_copy(pKey,ext->key,16);
4897
4898 /*Copy the rx mic first*/
4899 vos_mem_copy(&pKey[16],&ext->key[24],8);
4900
4901 /*Copy the tx mic */
4902 vos_mem_copy(&pKey[24],&ext->key[16],8);
4903
4904 }
4905 break;
4906
4907 case IW_ENCODE_ALG_CCMP:
4908 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4909 break;
4910
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004911#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004912#define IW_ENCODE_ALG_KRK 6
4913 case IW_ENCODE_ALG_KRK:
4914 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4915 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004916#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004917
4918 default:
4919 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4920 break;
4921 }
4922
4923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004924 ("%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 -07004925
4926#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304927 /* The supplicant may attempt to set the PTK once pre-authentication
4928 is done. Save the key in the UMAC and include it in the ADD
4929 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304931 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304933 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4934 "%s: Update PreAuth Key success", __func__);
4935 return 0;
4936 }
4937 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4938 {
4939 hddLog(VOS_TRACE_LEVEL_ERROR,
4940 "%s: Update PreAuth Key failed", __func__);
4941 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 }
4943#endif /* WLAN_FEATURE_VOWIFI_11R */
4944
4945 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4946
4947 vos_status = wlan_hdd_check_ula_done(pAdapter);
4948 if ( vos_status != VOS_STATUS_SUCCESS )
4949 {
4950 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4951 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
4952 __LINE__, vos_status );
4953
4954 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4955 }
4956
4957 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
4958
4959 if ( halStatus != eHAL_STATUS_SUCCESS )
4960 {
4961 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4962 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4963 __LINE__, halStatus );
4964
4965 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4966 }
4967
4968 return halStatus;
4969}
4970
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304971static int iw_set_encodeext(struct net_device *dev,
4972 struct iw_request_info *info,
4973 union iwreq_data *wrqu, char *extra)
4974{
4975 int ret;
4976
4977 vos_ssr_protect(__func__);
4978 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4979 vos_ssr_unprotect(__func__);
4980
4981 return ret;
4982}
4983
4984static int __iw_set_retry(struct net_device *dev,
4985 struct iw_request_info *info,
4986 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004987{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304988 hdd_adapter_t *pAdapter;
4989 tHalHandle hHal;
4990 hdd_context_t *pHddCtx;
4991 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004992
4993 ENTER();
4994
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304995 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4996 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004997 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4999 "%s: Adapter is NULL",__func__);
5000 return -EINVAL;
5001 }
5002
5003 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5004 ret = wlan_hdd_validate_context(pHddCtx);
5005 if (0 != ret)
5006 {
5007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5008 "%s: HDD context is not valid",__func__);
5009 return ret;
5010 }
5011
5012 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5013 if (NULL == hHal)
5014 {
5015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5016 "%s: Hal Context is NULL",__func__);
5017 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005018 }
5019
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5021 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5022
Arif Hussain6d2a3322013-11-17 19:50:10 -08005023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005024
5025 return -EINVAL;
5026 }
5027
5028 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5029
5030 if((wrqu->retry.flags & IW_RETRY_LONG))
5031 {
5032 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5033 {
c_hpothub8245442013-11-20 23:41:09 +05305034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5035 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 return -EIO;
5037 }
5038 }
5039 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5040 {
5041 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5042 {
c_hpothub8245442013-11-20 23:41:09 +05305043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5044 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 return -EIO;
5046 }
5047 }
5048 }
5049 else
5050 {
5051 return -EOPNOTSUPP;
5052 }
5053
Arif Hussain6d2a3322013-11-17 19:50:10 -08005054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005055
5056 EXIT();
5057
5058 return 0;
5059
5060}
5061
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305062static int iw_set_retry(struct net_device *dev,
5063 struct iw_request_info *info,
5064 union iwreq_data *wrqu, char *extra)
5065{
5066 int ret;
5067
5068 vos_ssr_protect(__func__);
5069 ret = __iw_set_retry(dev, info, wrqu, extra);
5070 vos_ssr_unprotect(__func__);
5071
5072 return ret;
5073}
5074
5075static int __iw_get_retry(struct net_device *dev,
5076 struct iw_request_info *info,
5077 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005078{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305079 hdd_adapter_t *pAdapter;
5080 hdd_context_t *pHddCtx;
5081 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305083 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005084
5085 ENTER();
5086
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305087 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5088 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005089 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5091 "%s: Adapter is NULL",__func__);
5092 return -EINVAL;
5093 }
5094
5095 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5096 ret = wlan_hdd_validate_context(pHddCtx);
5097 if (0 != ret)
5098 {
5099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5100 "%s: HDD context is not valid",__func__);
5101 return ret;
5102 }
5103
5104 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5105 if (NULL == hHal)
5106 {
5107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5108 "%s: Hal Context is NULL",__func__);
5109 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005110 }
5111
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 if((wrqu->retry.flags & IW_RETRY_LONG))
5113 {
5114 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5115
5116 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5117 {
c_hpothub8245442013-11-20 23:41:09 +05305118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5119 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005120 return -EIO;
5121 }
5122
5123 wrqu->retry.value = retry;
5124 }
5125 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5126 {
5127 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5128
5129 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5130 {
c_hpothub8245442013-11-20 23:41:09 +05305131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5132 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 return -EIO;
5134 }
5135
5136 wrqu->retry.value = retry;
5137 }
5138 else {
5139 return -EOPNOTSUPP;
5140 }
5141
Arif Hussain6d2a3322013-11-17 19:50:10 -08005142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005143
5144 EXIT();
5145
5146 return 0;
5147}
5148
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305149static int iw_get_retry(struct net_device *dev,
5150 struct iw_request_info *info,
5151 union iwreq_data *wrqu, char *extra)
5152{
5153 int ret;
5154
5155 vos_ssr_protect(__func__);
5156 ret = __iw_get_retry(dev, info, wrqu, extra);
5157 vos_ssr_unprotect(__func__);
5158
5159 return ret;
5160}
5161
5162static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005163 struct iw_request_info *info,
5164 union iwreq_data *wrqu,
5165 char *extra)
5166{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305167 hdd_adapter_t *pAdapter;
5168 hdd_context_t *pHddCtx;
5169 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5171 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305172 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005173
5174 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305175 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5176 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005177 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5179 "%s:Adapter is NULL",__func__);
5180 return -EINVAL;
5181 }
5182 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5183 ret = wlan_hdd_validate_context(pHddCtx);
5184 if (0 != ret)
5185 {
5186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5187 "%s HDD context is not valid",__func__);
5188 return ret;
5189 }
5190 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5191 if (NULL == pHddStaCtx)
5192 {
5193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5194 "%s:STA context is NULL",__func__);
5195 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 }
5197
5198 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5199 switch (mlme->cmd) {
5200 case IW_MLME_DISASSOC:
5201 case IW_MLME_DEAUTH:
5202
5203 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5204 {
5205 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5206
5207 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5208 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5209
5210 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5211 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5212
Jeff Johnson43971f52012-07-17 12:26:56 -07005213 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305214 {
5215 long ret;
5216 ret = wait_for_completion_interruptible_timeout(
5217 &pAdapter->disconnect_comp_var,
5218 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5219 if (ret <= 0)
5220 hddLog(VOS_TRACE_LEVEL_ERROR,
5221 FL("failed wait on disconnect_comp_var %ld"), ret);
5222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005224 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005225 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005226
5227 /* Resetting authKeyMgmt */
5228 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5229
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305230 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 netif_tx_disable(dev);
5232 netif_carrier_off(dev);
5233
5234 }
5235 else
5236 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005237 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 -07005238 }
5239 break;
5240 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005241 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005242 return -EINVAL;
5243 }//end of switch
5244
5245 EXIT();
5246
5247 return status;
5248
5249}
5250
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305251static int iw_set_mlme(struct net_device *dev,
5252 struct iw_request_info *info,
5253 union iwreq_data *wrqu,
5254 char *extra)
5255{
5256 int ret;
5257
5258 vos_ssr_protect(__func__);
5259 ret = __iw_set_mlme(dev, info, wrqu, extra);
5260 vos_ssr_unprotect(__func__);
5261
5262 return ret;
5263}
5264
Jeff Johnson295189b2012-06-20 16:38:30 -07005265/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305266static int __iw_setint_getnone(struct net_device *dev,
5267 struct iw_request_info *info,
5268 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005269{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305270 hdd_adapter_t *pAdapter;
5271 tHalHandle hHal;
5272 hdd_wext_state_t *pWextState;
5273 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 int *value = (int *)extra;
5275 int sub_cmd = value[0];
5276 int set_value = value[1];
5277 int ret = 0; /* success */
5278 int enable_pbm, enable_mp;
5279#ifdef CONFIG_HAS_EARLYSUSPEND
5280 v_U8_t nEnableSuspendOld;
5281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005282
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305283 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5284 if (NULL == pAdapter)
5285 {
5286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5287 "%s: Adapter is NULL",__func__);
5288 return -EINVAL;
5289 }
5290 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5291 ret = wlan_hdd_validate_context(pHddCtx);
5292 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005293 {
c_hpothu4a298be2014-12-22 21:12:51 +05305294 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305295 return ret;
5296 }
5297 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5298 if (NULL == hHal)
5299 {
5300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5301 "%s: Hal Context is NULL",__func__);
5302 return -EINVAL;
5303 }
5304 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5305 if (NULL == pWextState)
5306 {
5307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5308 "%s: pWextState is NULL",__func__);
5309 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005310 }
5311
c_hpothu4a298be2014-12-22 21:12:51 +05305312 INIT_COMPLETION(pWextState->completion_var);
5313
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 switch(sub_cmd)
5315 {
5316 case WE_SET_11D_STATE:
5317 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005318 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005319 memset(&smeConfig, 0x00, sizeof(smeConfig));
5320
Jeff Johnson295189b2012-06-20 16:38:30 -07005321 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5322
5323 sme_GetConfigParam(hHal,&smeConfig);
5324 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5325
Arif Hussain6d2a3322013-11-17 19:50:10 -08005326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005327
5328 sme_UpdateConfig(hHal,&smeConfig);
5329 }
5330 else {
5331 return -EINVAL;
5332 }
5333 break;
5334 }
5335
5336 case WE_WOWL:
5337 {
5338 switch (set_value)
5339 {
5340 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305341 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005342 break;
5343 case 0x01:
5344 case 0x02:
5345 case 0x03:
5346 enable_mp = (set_value & 0x01) ? 1 : 0;
5347 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005348 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5350 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5351 break;
5352 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005353 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 ret = -EINVAL;
5355 break;
5356 }
5357
5358 break;
5359 }
5360 case WE_SET_POWER:
5361 {
5362 switch (set_value)
5363 {
5364 case 0: //Full Power
5365 {
5366 struct statsContext context;
5367 eHalStatus status;
5368
5369 init_completion(&context.completion);
5370
5371 context.pAdapter = pAdapter;
5372 context.magic = POWER_CONTEXT_MAGIC;
5373
5374 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5375 iw_power_callback_fn, &context,
5376 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005377 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 {
5379 int lrc = wait_for_completion_interruptible_timeout(
5380 &context.completion,
5381 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005382
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 if (lrc <= 0)
5384 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005385 hddLog(VOS_TRACE_LEVEL_ERROR,
5386 "%s: SME %s while requesting fullpower",
5387 __func__, (0 == lrc) ?
5388 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 }
5390 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005391 /* either we have a response or we timed out. if we timed
5392 out there is a race condition such that the callback
5393 function could be executing at the same time we are. of
5394 primary concern is if the callback function had already
5395 verified the "magic" but had not yet set the completion
5396 variable when a timeout occurred. we serialize these
5397 activities by invalidating the magic while holding a
5398 shared spinlock which will cause us to block if the
5399 callback is currently executing */
5400 spin_lock(&hdd_context_lock);
5401 context.magic = 0;
5402 spin_unlock(&hdd_context_lock);
5403
Arif Hussain6d2a3322013-11-17 19:50:10 -08005404 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 break;
5406 }
5407 case 1: //Enable BMPS
5408 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5409 break;
5410 case 2: //Disable BMPS
5411 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5412 break;
5413 case 3: //Request Bmps
5414 {
5415 struct statsContext context;
5416 eHalStatus status;
5417
5418 init_completion(&context.completion);
5419
5420 context.pAdapter = pAdapter;
5421 context.magic = POWER_CONTEXT_MAGIC;
5422
5423 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5424 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005425 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 {
5427 int lrc = wait_for_completion_interruptible_timeout(
5428 &context.completion,
5429 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 if (lrc <= 0)
5431 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005432 hddLog(VOS_TRACE_LEVEL_ERROR,
5433 "%s: SME %s while requesting BMPS",
5434 __func__, (0 == lrc) ? "timeout" :
5435 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 }
5437 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005438 /* either we have a response or we timed out. if we
5439 timed out there is a race condition such that the
5440 callback function could be executing at the same
5441 time we are. of primary concern is if the callback
5442 function had already verified the "magic" but had
5443 not yet set the completion variable when a timeout
5444 occurred. we serialize these activities by
5445 invalidating the magic while holding a shared
5446 spinlock which will cause us to block if the
5447 callback is currently executing */
5448 spin_lock(&hdd_context_lock);
5449 context.magic = 0;
5450 spin_unlock(&hdd_context_lock);
5451
Arif Hussain6d2a3322013-11-17 19:50:10 -08005452 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 break;
5454 }
5455 case 4: //Enable IMPS
5456 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5457 break;
5458 case 5: //Disable IMPS
5459 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5460 break;
5461 case 6: //Enable Standby
5462 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5463 break;
5464 case 7: //Disable Standby
5465 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5466 break;
5467 case 8: //Request Standby
5468#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005469#endif
5470 break;
5471 case 9: //Start Auto Bmps Timer
5472 sme_StartAutoBmpsTimer(hHal);
5473 break;
5474 case 10://Stop Auto BMPS Timer
5475 sme_StopAutoBmpsTimer(hHal);
5476 break;
5477#ifdef CONFIG_HAS_EARLYSUSPEND
5478 case 11://suspend to standby
5479#ifdef CONFIG_HAS_EARLYSUSPEND
5480 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5481 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5483#endif
5484 break;
5485 case 12://suspend to deep sleep
5486#ifdef CONFIG_HAS_EARLYSUSPEND
5487 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5488 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5490#endif
5491 break;
5492 case 13://resume from suspend
5493#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005494#endif
5495 break;
5496#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005498 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 ret = -EINVAL;
5500 break;
5501 }
5502 break;
5503 }
5504
5505 case WE_SET_MAX_ASSOC:
5506 {
5507 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5508 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5509 {
5510 ret = -EINVAL;
5511 }
5512 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5513 set_value, NULL, eANI_BOOLEAN_FALSE)
5514 != eHAL_STATUS_SUCCESS )
5515 {
c_hpothub8245442013-11-20 23:41:09 +05305516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5517 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 ret = -EIO;
5519 }
5520 break;
5521 }
5522
5523 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5524 {
5525 if( 0 == set_value )
5526 {
5527 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5528 }
5529 else if ( 1 == set_value )
5530 {
5531 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5532 }
5533 else
5534 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005535 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 ret = -EINVAL;
5537 }
5538 break;
5539 }
5540
5541 case WE_SET_DATA_INACTIVITY_TO:
5542 {
5543 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5544 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5545 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5546 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5547 set_value,
5548 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5549 {
5550 hddLog(LOGE,"Failure: Could not pass on "
5551 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005552 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 ret = -EINVAL;
5554 }
5555 break;
5556 }
5557 case WE_SET_MAX_TX_POWER:
5558 {
5559 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5560 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5561
5562 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5563 __func__, set_value);
5564 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5565 eHAL_STATUS_SUCCESS )
5566 {
5567 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5568 __func__);
5569 return -EIO;
5570 }
5571
5572 break;
5573 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005574 case WE_SET_MAX_TX_POWER_2_4:
5575 {
5576 hddLog(VOS_TRACE_LEVEL_INFO,
5577 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5578 __func__, set_value);
5579 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5580 eHAL_STATUS_SUCCESS)
5581 {
5582 hddLog(VOS_TRACE_LEVEL_ERROR,
5583 "%s: Setting maximum tx power failed for 2.4 GHz band",
5584 __func__);
5585 return -EIO;
5586 }
5587
5588 break;
5589 }
5590 case WE_SET_MAX_TX_POWER_5_0:
5591 {
5592 hddLog(VOS_TRACE_LEVEL_INFO,
5593 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5594 __func__, set_value);
5595 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5596 eHAL_STATUS_SUCCESS)
5597 {
5598 hddLog(VOS_TRACE_LEVEL_ERROR,
5599 "%s: Setting maximum tx power failed for 5.0 GHz band",
5600 __func__);
5601 return -EIO;
5602 }
5603
5604 break;
5605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 case WE_SET_HIGHER_DTIM_TRANSITION:
5607 {
5608 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5609 (set_value == eANI_BOOLEAN_TRUE)))
5610 {
5611 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5612 ret = -EINVAL;
5613 }
5614 else
5615 {
5616 if(pAdapter->higherDtimTransition != set_value)
5617 {
5618 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005619 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 }
5621 }
5622
5623 break;
5624 }
5625
5626 case WE_SET_TM_LEVEL:
5627 {
5628 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005629 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5631
5632 break;
5633 }
5634
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305635 case WE_ENABLE_STRICT_FCC_REG:
5636 {
5637 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5638 struct wiphy *wiphy = NULL;
5639 long lrc;
5640 int status;
5641
5642 wiphy = hddCtxt->wiphy;
5643 if(wiphy == NULL)
5644 {
5645 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5646 break;
5647 }
5648 init_completion(&hddCtxt->wiphy_channel_update_event);
5649
5650 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5651
5652 status = regulatory_hint(wiphy, "00");
5653 if(status < 0)
5654 {
5655 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5656 break;
5657 }
5658
5659 /* Wait for completion */
5660 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5661 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5662 if (lrc <= 0)
5663 {
5664 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5665 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5666 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5667 }
5668 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5669
5670 break;
5671 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005672 case WE_SET_DEBUG_LOG:
5673 {
5674 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5675 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5676 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5677 break;
5678 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305679#ifdef FEATURE_WLAN_TDLS
5680 case WE_SET_TDLS_OFF_CHAN:
5681 {
5682 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5684 __func__, set_value);
5685 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5686 break;
5687 }
5688 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5689 {
5690 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5692 __func__, set_value);
5693 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5694 break;
5695 }
5696 case WE_SET_TDLS_OFF_CHAN_MODE:
5697 {
5698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5699 __func__, set_value);
5700 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5701 break;
5702 }
5703#endif
Peng Xu2446a892014-09-05 17:21:18 +05305704 case WE_SET_SCAN_BAND_PREFERENCE:
5705 {
5706 tSmeConfigParams smeConfig;
5707 memset(&smeConfig, 0x00, sizeof(smeConfig));
5708 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5709 ret = -EINVAL;
5710 break;
5711 }
5712 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5713
5714 if (eCSR_BAND_ALL == set_value ||
5715 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5716 sme_GetConfigParam(hHal, &smeConfig);
5717 smeConfig.csrConfig.scanBandPreference = set_value;
5718
5719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5720 "set band scan preference = %d\n",
5721 smeConfig.csrConfig.scanBandPreference);
5722
5723 sme_UpdateConfig(hHal, &smeConfig);
5724 }
5725 else {
5726 ret = -EINVAL;
5727 }
5728 break;
5729 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305730
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 default:
5732 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005733 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005734 sub_cmd, set_value);
5735 break;
5736 }
5737 }
5738
5739 return ret;
5740}
5741
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305742static int iw_setint_getnone(struct net_device *dev,
5743 struct iw_request_info *info,
5744 union iwreq_data *wrqu, char *extra)
5745{
5746 int ret;
5747
5748 vos_ssr_protect(__func__);
5749 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5750 vos_ssr_unprotect(__func__);
5751
5752 return 0;
5753}
Jeff Johnson295189b2012-06-20 16:38:30 -07005754/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305755static int __iw_setchar_getnone(struct net_device *dev,
5756 struct iw_request_info *info,
5757 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005758{
5759 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305760 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005762 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305763 hdd_adapter_t *pAdapter;
5764 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005765#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305766 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005767#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305768 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305769 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005770
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305771 pAdapter = (netdev_priv(dev));
5772 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005773 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5775 "%s: Adapter is NULL",__func__);
5776 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005777 }
5778
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305779 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5780 ret = wlan_hdd_validate_context(pHddCtx);
5781 if (0 != ret)
5782 {
5783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5784 "%s: HDD context is not valid",__func__);
5785 return ret;
5786 }
5787#ifdef WLAN_FEATURE_VOWIFI
5788 pConfig = pHddCtx->cfg_ini;
5789#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305790 /* helper function to get iwreq_data with compat handling. */
5791 if (hdd_priv_get_data(&s_priv_data, wrqu))
5792 {
5793 return -EINVAL;
5794 }
5795
5796 /* make sure all params are correctly passed to function */
5797 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5798 {
5799 return -EINVAL;
5800 }
5801
5802 sub_cmd = s_priv_data.flags;
5803
Arif Hussain0273cba2014-01-07 20:58:29 -08005804 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305805 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5806 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005807 if (NULL == pBuffer)
5808 {
5809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5810 "mem_alloc_copy_from_user_helper fail");
5811 return -ENOMEM;
5812 }
5813
5814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305815 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5817 "%s: Received data %s", __func__, pBuffer);
5818
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 switch(sub_cmd)
5820 {
5821 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005823 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 break;
5825 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005827 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 break;
5829#if defined WLAN_FEATURE_VOWIFI
5830 case WE_NEIGHBOR_REPORT_REQUEST:
5831 {
5832 tRrmNeighborReq neighborReq;
5833 tRrmNeighborRspCallbackInfo callbackInfo;
5834
5835 if (pConfig->fRrmEnable)
5836 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305838 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 if( !neighborReq.no_ssid )
5840 {
Girish Gowli552fc072014-06-14 18:26:16 +05305841 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005842 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 }
5844
5845 callbackInfo.neighborRspCallback = NULL;
5846 callbackInfo.neighborRspCallbackContext = NULL;
5847 callbackInfo.timeout = 5000; //5 seconds
5848 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5849 }
5850 else
5851 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005852 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 ret = -EINVAL;
5854 }
5855 }
5856 break;
5857#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 case WE_SET_AP_WPS_IE:
5859 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05305860 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08005863 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 if (VOS_STATUS_SUCCESS != vstatus)
5865 {
5866 ret = -EINVAL;
5867 }
5868 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305869 case WE_SET_ENCRYPT_MSG:
5870 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
5871 if (NULL == pkt)
5872 {
5873 hddLog(VOS_TRACE_LEVEL_ERROR,
5874 "%s: vos_mem_alloc failed", __func__);
5875 return -ENOMEM;
5876 }
5877
5878 memset(pkt, 0, sizeof(tSirpkt80211));
5879
5880 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
5881 hddLog(VOS_TRACE_LEVEL_ERROR,
5882 FL("Firmware is not DISA capable"));
5883 ret = -EINVAL;
5884 vos_mem_free(pkt);
5885 break;
5886 }
5887
5888 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
5889
5890 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
5891 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
5892 if (eHAL_STATUS_SUCCESS != ret) {
5893 hddLog(VOS_TRACE_LEVEL_ERROR,
5894 FL("SENDEncryptMSG: fail to post WDA cmd"));
5895 ret = -EINVAL;
5896 }
5897 vos_mem_free(pkt);
5898
5899 break;
5900
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 default:
5902 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005903 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005904 ret = -EINVAL;
5905 break;
5906 }
5907 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005908 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 return ret;
5910}
5911
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305912static int iw_setchar_getnone(struct net_device *dev,
5913 struct iw_request_info *info,
5914 union iwreq_data *wrqu, char *extra)
5915{
5916 int ret;
5917
5918 vos_ssr_protect(__func__);
5919 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
5920 vos_ssr_unprotect(__func__);
5921
5922 return ret;
5923}
5924
Jeff Johnson295189b2012-06-20 16:38:30 -07005925/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305926static int __iw_setnone_getint(struct net_device *dev,
5927 struct iw_request_info *info,
5928 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005929{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305930 hdd_adapter_t *pAdapter;
5931 tHalHandle hHal;
5932 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 int *value = (int *)extra;
5934 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05305935 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005936
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305937 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5938 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005939 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5941 "%s: Adapter is NULL",__func__);
5942 return -EINVAL;
5943 }
5944 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5945 ret = wlan_hdd_validate_context(pHddCtx);
5946 if (0 != ret)
5947 {
5948 if (__ratelimit(&hdd_ioctl_timeout_rs))
5949 {
c_hpothuda3af912014-11-06 16:52:03 +05305950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305951 "%s:Hdd context is not valid", __func__);
c_hpothuda3af912014-11-06 16:52:03 +05305952 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305953 return ret;
5954 }
5955 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5956 if (NULL == hHal)
5957 {
5958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5959 "%s: Hal Context is NULL",__func__);
5960 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005962
5963 switch (value[0])
5964 {
5965 case WE_GET_11D_STATE:
5966 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005967 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305969
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 *value = smeConfig.csrConfig.Is11dSupportEnabled;
5971
Arif Hussain6d2a3322013-11-17 19:50:10 -08005972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005973
5974 break;
5975 }
5976
5977 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 break;
5980
5981 case WE_PMC_STATE:
5982 {
5983 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 break;
5986 }
5987 case WE_GET_WLAN_DBG:
5988 {
5989 vos_trace_display();
5990 *value = 0;
5991 break;
5992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 case WE_GET_MAX_ASSOC:
5994 {
5995 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
5996 {
c_hpothub8245442013-11-20 23:41:09 +05305997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5998 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 ret = -EIO;
6000 }
Girish Gowli385be612014-09-18 11:17:20 +05306001#ifdef WLAN_SOFTAP_VSTA_FEATURE
6002 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6003 {
6004 if (*value > VSTA_NUM_ASSOC_STA)
6005 {
6006 *value = VSTA_NUM_ASSOC_STA;
6007 }
6008 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6009 (*value > (VSTA_NUM_ASSOC_STA -
6010 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6011 {
6012 *value = (VSTA_NUM_ASSOC_STA -
6013 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6014 }
6015 }
6016 else
6017#endif
6018 {
6019 if (*value > NUM_ASSOC_STA)
6020 {
6021 *value = NUM_ASSOC_STA;
6022 }
6023 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6024 (*value > (NUM_ASSOC_STA -
6025 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6026 {
6027 *value = (NUM_ASSOC_STA -
6028 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6029 }
6030 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 break;
6032 }
6033
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 case WE_GET_WDI_DBG:
6035 {
6036 wpalTraceDisplay();
6037 *value = 0;
6038 break;
6039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006040
6041 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6042 {
6043 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6044 break;
6045 }
6046 case WE_GET_CONCURRENCY_MODE:
6047 {
6048 *value = hdd_get_concurrency_mode ( );
6049
Arif Hussain6d2a3322013-11-17 19:50:10 -08006050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 break;
6052 }
6053
Peng Xu2446a892014-09-05 17:21:18 +05306054 case WE_GET_SCAN_BAND_PREFERENCE:
6055 {
6056 sme_GetConfigParam(hHal, &smeConfig);
6057 *value = smeConfig.csrConfig.scanBandPreference;
6058
6059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6060 "scanBandPreference = %d\n", *value);
6061 break;
6062 }
6063
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 default:
6065 {
6066 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6067 break;
6068 }
6069 }
6070
6071 return ret;
6072}
6073
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306074static int iw_setnone_getint(struct net_device *dev,
6075 struct iw_request_info *info,
6076 union iwreq_data *wrqu, char *extra)
6077{
6078 int ret;
6079
6080 vos_ssr_protect(__func__);
6081 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6082 vos_ssr_unprotect(__func__);
6083
6084 return ret;
6085
6086}
Jeff Johnson295189b2012-06-20 16:38:30 -07006087/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306088int __iw_set_three_ints_getnone(struct net_device *dev,
6089 struct iw_request_info *info,
6090 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006091{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306092 hdd_adapter_t *pAdapter;
6093 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 int *value = (int *)extra;
6095 int sub_cmd = value[0];
6096 int ret = 0;
6097
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306098 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6099 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006100 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6102 "%s: Adapter is NULL",__func__);
6103 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006104 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306105 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6106 ret = wlan_hdd_validate_context(pHddCtx);
6107 if (0 != ret)
6108 {
6109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6110 "%s: HDD context is not valid",__func__);
6111 return ret;
6112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 switch(sub_cmd)
6114 {
6115 case WE_SET_WLAN_DBG:
6116 {
6117 vos_trace_setValue( value[1], value[2], value[3]);
6118 break;
6119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 case WE_SET_WDI_DBG:
6121 {
6122 wpalTraceSetLevel( value[1], value[2], value[3]);
6123 break;
6124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 case WE_SET_SAP_CHANNELS:
6126 {
6127 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6128 break;
6129 }
6130
6131 default:
6132 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006133 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 break;
6135 }
6136 }
6137 return ret;
6138}
6139
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306140int iw_set_three_ints_getnone(struct net_device *dev,
6141 struct iw_request_info *info,
6142 union iwreq_data *wrqu, char *extra)
6143{
6144 int ret;
6145
6146 vos_ssr_protect(__func__);
6147 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6148 vos_ssr_unprotect(__func__);
6149
6150 return ret;
6151}
6152
6153static int __iw_get_char_setnone(struct net_device *dev,
6154 struct iw_request_info *info,
6155 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006156{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306157 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006158 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306159 hdd_context_t *pHddCtx;
6160 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006161#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006162 hdd_wext_state_t *pWextState;
6163#endif
6164
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306165 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006166 if (pAdapter == NULL)
6167 {
6168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6169 "%s: pAdapter is NULL!", __func__);
6170 return -EINVAL;
6171 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306172 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6173 ret = wlan_hdd_validate_context(pHddCtx);
6174 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006175 {
6176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306177 "%s: HDD context is not valid",__func__);
6178 return ret;
6179 }
6180#ifdef WLAN_FEATURE_11W
6181 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6182 if (NULL == pWextState)
6183 {
6184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6185 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006186 return -EINVAL;
6187 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306188#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006189
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 switch(sub_cmd)
6191 {
6192 case WE_WLAN_VERSION:
6193 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006194 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 break;
6196 }
6197
6198 case WE_GET_STATS:
6199 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306200 tHalHandle hHal = NULL;
6201 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6203 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6204 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6205
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306206
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 snprintf(extra, WE_MAX_STR_LEN,
6208 "\nTransmit"
6209 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6210 "\n dropped BK %u, BE %u, VI %u, VO %u"
6211 "\n classified BK %u, BE %u, VI %u, VO %u"
6212 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6213 "\n queued BK %u, BE %u, VI %u, VO %u"
6214 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006215 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 "\n fetched BK %u, BE %u, VI %u, VO %u"
6217 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6218 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006219 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 "\n flushed BK %u, BE %u, VI %u, VO %u"
6221 "\n\nReceive"
6222 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6223 "\n\nResetsStats"
6224 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6225 "\n",
6226 pStats->txXmitCalled,
6227 pStats->txXmitDropped,
6228 pStats->txXmitBackPressured,
6229 pStats->txXmitQueued,
6230
6231 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6232 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6233 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6234 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6235
6236 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6237 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6238 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6239 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6240
6241 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6242 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6243 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6244 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6245
6246 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6247 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6248 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6249 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6250
6251 pStats->txFetched,
6252 pStats->txFetchEmpty,
6253 pStats->txFetchLowResources,
6254 pStats->txFetchDequeueError,
6255
6256 pStats->txFetchDequeued,
6257 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006258 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006259 pStats->txCompleted,
6260 pStats->txFlushed,
6261
6262 pStats->txFetchedAC[WLANTL_AC_BK],
6263 pStats->txFetchedAC[WLANTL_AC_BE],
6264 pStats->txFetchedAC[WLANTL_AC_VI],
6265 pStats->txFetchedAC[WLANTL_AC_VO],
6266
6267 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6268 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6269 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6270 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6271
6272 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6273 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6274 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6275 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6276
Ravi Joshi41914632013-10-21 23:02:21 -07006277 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6278 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6279 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6280 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6281
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 pStats->txFlushedAC[WLANTL_AC_BK],
6283 pStats->txFlushedAC[WLANTL_AC_BE],
6284 pStats->txFlushedAC[WLANTL_AC_VI],
6285 pStats->txFlushedAC[WLANTL_AC_VO],
6286
6287 pStats->rxChains,
6288 pStats->rxPackets,
6289 pStats->rxDropped,
6290 pStats->rxDelivered,
6291 pStats->rxRefused,
6292
6293 pResetStats->totalLogpResets,
6294 pResetStats->totalCMD53Failures,
6295 pResetStats->totalMutexReadFailures,
6296 pResetStats->totalMIFErrorFailures,
6297 pResetStats->totalFWHearbeatFailures,
6298 pResetStats->totalUnknownExceptions
6299 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306300 wrqu->data.length = strlen(extra);
6301
6302 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6303
6304 if (hHal)
6305 pMac = PMAC_STRUCT( hHal );
6306
6307 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6308 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6309 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306310 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6311 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6312 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6313 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306314 "\n",
6315 pMac->pmm.BmpscntSleep,
6316 pMac->pmm.BmpscntAwake,
6317 pMac->pmm.BmpsSleeReqFailCnt,
6318 pMac->pmm.BmpsWakeupReqFailCnt,
6319 pMac->pmm.ImpsCntSleep,
6320 pMac->pmm.ImpsCntAwake,
6321 pMac->pmm.ImpsSleepErrCnt,
6322 pMac->pmm.ImpsWakeupErrCnt,
6323 pMac->pmm.ImpsLastErr
6324 );
6325 }
6326
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 wrqu->data.length = strlen(extra)+1;
6328 break;
6329 }
6330
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306331/* The case prints the current state of the HDD, SME, CSR, PE, TL
6332 *it can be extended for WDI Global State as well.
6333 *And currently it only checks P2P_CLIENT adapter.
6334 *P2P_DEVICE and P2P_GO have not been added as of now.
6335*/
6336 case WE_GET_STATES:
6337 {
6338 int buf = 0, len = 0;
6339 int adapter_num = 0;
6340 int count = 0, check = 1;
6341
6342 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006343 tHalHandle hHal = NULL;
6344 tpAniSirGlobal pMac = NULL;
6345 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306346
6347 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6348 hdd_adapter_t *useAdapter = NULL;
6349
6350 /* Print wlan0 or p2p0 states based on the adapter_num
6351 *by using the correct adapter
6352 */
6353 while ( adapter_num < 2 )
6354 {
6355 if ( WLAN_ADAPTER == adapter_num )
6356 {
6357 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006358 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306359 "\n\n wlan0 States:-");
6360 len += buf;
6361 }
6362 else if ( P2P_ADAPTER == adapter_num )
6363 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006364 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306365 "\n\n p2p0 States:-");
6366 len += buf;
6367
6368 if( !pHddCtx )
6369 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006370 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306371 "\n pHddCtx is NULL");
6372 len += buf;
6373 break;
6374 }
6375
6376 /*Printing p2p0 states only in the case when the device is
6377 configured as a p2p_client*/
6378 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6379 if ( !useAdapter )
6380 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006381 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306382 "\n Device not configured as P2P_CLIENT.");
6383 len += buf;
6384 break;
6385 }
6386 }
6387
6388 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006389 if (!hHal) {
6390 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6391 "\n pMac is NULL");
6392 len += buf;
6393 break;
6394 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306395 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006396 if (!pMac) {
6397 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6398 "\n pMac is NULL");
6399 len += buf;
6400 break;
6401 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306402 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6403 if( !pHddStaCtx )
6404 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006405 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306406 "\n pHddStaCtx is NULL");
6407 len += buf;
6408 break;
6409 }
6410
6411 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6412
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006413 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306414 "\n HDD Conn State - %s "
6415 "\n \n SME State:"
6416 "\n Neighbour Roam State - %s"
6417 "\n CSR State - %s"
6418 "\n CSR Substate - %s"
6419 "\n \n TL STA %d State: %s",
6420 macTraceGetHDDWlanConnState(
6421 pHddStaCtx->conn_info.connState),
6422 macTraceGetNeighbourRoamState(
6423 pMac->roam.neighborRoamInfo.neighborRoamState),
6424 macTraceGetcsrRoamState(
6425 pMac->roam.curState[useAdapter->sessionId]),
6426 macTraceGetcsrRoamSubState(
6427 pMac->roam.curSubState[useAdapter->sessionId]),
6428 pHddStaCtx->conn_info.staId[0],
6429 macTraceGetTLState(tlState)
6430 );
6431 len += buf;
6432 adapter_num++;
6433 }
6434
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006435 if (pMac) {
6436 /* Printing Lim State starting with global lim states */
6437 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6438 "\n \n LIM STATES:-"
6439 "\n Global Sme State - %s "\
6440 "\n Global mlm State - %s "\
6441 "\n",
6442 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6443 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6444 );
6445 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306446
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006447 /*printing the PE Sme and Mlm states for valid lim sessions*/
6448 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306449 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006450 if ( pMac->lim.gpSession[count].valid )
6451 {
6452 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6453 "\n Lim Valid Session %d:-"
6454 "\n PE Sme State - %s "
6455 "\n PE Mlm State - %s "
6456 "\n",
6457 check,
6458 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6459 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6460 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306461
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006462 len += buf;
6463 check++;
6464 }
6465 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306466 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306467 }
6468
6469 wrqu->data.length = strlen(extra)+1;
6470 break;
6471 }
6472
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 case WE_GET_CFG:
6474 {
6475 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6476 wrqu->data.length = strlen(extra)+1;
6477 break;
6478 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006479#ifdef WLAN_FEATURE_11AC
6480 case WE_GET_RSSI:
6481 {
6482 v_S7_t s7Rssi = 0;
6483 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6484 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6485 wrqu->data.length = strlen(extra)+1;
6486 break;
6487 }
6488#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306489
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006490#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006491 case WE_GET_ROAM_RSSI:
6492 {
6493 v_S7_t s7Rssi = 0;
6494 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6495 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6496 wrqu->data.length = strlen(extra)+1;
6497 break;
6498 }
6499#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 case WE_GET_WMM_STATUS:
6501 {
6502 snprintf(extra, WE_MAX_STR_LEN,
6503 "\nDir: 0=up, 1=down, 3=both\n"
6504 "|------------------------|\n"
6505 "|AC | ACM |Admitted| Dir |\n"
6506 "|------------------------|\n"
6507 "|VO | %d | %3s | %d |\n"
6508 "|VI | %d | %3s | %d |\n"
6509 "|BE | %d | %3s | %d |\n"
6510 "|BK | %d | %3s | %d |\n"
6511 "|------------------------|\n",
6512 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6513 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6514 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6515 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6516 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6517 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6518 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6519 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6520 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6521 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6522 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6523 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6524
Jeff Johnsone7245742012-09-05 17:12:55 -07006525
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 wrqu->data.length = strlen(extra)+1;
6527 break;
6528 }
6529 case WE_GET_CHANNEL_LIST:
6530 {
6531 VOS_STATUS status;
6532 v_U8_t i, len;
6533 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306534 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6535 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6536 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006537 tChannelListInfo channel_list;
6538
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006539 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006540 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006541 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006542 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006543 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 return -EINVAL;
6545 }
6546 buf = extra;
6547
6548 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006549 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6550 * needed = 5 * number of channels. Check ifsufficient
6551 * buffer is available and then proceed to fill the buffer.
6552 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006553 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6554 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006555 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006556 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006557 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006558 return -EINVAL;
6559 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006560 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6561 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306562 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6563 {
6564 //Printing Country code in getChannelList
6565 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6566 {
6567 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6568 "%c ", pBuf[i]);
6569 }
6570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 for(i = 0 ; i < channel_list.num_channels; i++)
6572 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006573 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006574 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 }
6576 wrqu->data.length = strlen(extra)+1;
6577
6578 break;
6579 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006580#ifdef FEATURE_WLAN_TDLS
6581 case WE_GET_TDLS_PEERS:
6582 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006583 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006584 break;
6585 }
6586#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006587#ifdef WLAN_FEATURE_11W
6588 case WE_GET_11W_INFO:
6589 {
6590 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6591
6592 snprintf(extra, WE_MAX_STR_LEN,
6593 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6594 "\n Number of Unprotected Disassocs %d"
6595 "\n Number of Unprotected Deauths %d",
6596 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6597 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6598 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6599 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6600 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6601
6602 wrqu->data.length = strlen(extra)+1;
6603 break;
6604 }
6605#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306606 case WE_GET_SNR:
6607 {
6608 v_S7_t s7snr = 0;
6609 int status = 0;
6610 hdd_context_t *pHddCtx;
6611 hdd_station_ctx_t *pHddStaCtx;
6612
6613 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6614 status = wlan_hdd_validate_context(pHddCtx);
6615 if (0 != status)
6616 {
6617 hddLog(LOGE, "%s: getSNR: HDD context is not valid", __func__);
6618 return status;
6619 }
6620
6621 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6622
6623 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6624 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6625 {
6626 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6627 " ConnectionState-%d", __func__,
6628 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6629 pHddStaCtx->conn_info.connState);
6630 return -ENONET;
6631 }
6632
6633 /*update the stats in TL*/
6634 wlan_hdd_get_station_stats(pAdapter);
6635 wlan_hdd_get_snr(pAdapter, &s7snr);
6636 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6637 wrqu->data.length = strlen(extra) + 1;
6638 break;
6639 }
6640
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306641 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006643 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 break;
6645 }
6646 }
6647
6648 return 0;
6649}
6650
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306651static int iw_get_char_setnone(struct net_device *dev,
6652 struct iw_request_info *info,
6653 union iwreq_data *wrqu, char *extra)
6654{
6655 int ret;
6656
6657 vos_ssr_protect(__func__);
6658 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6659 vos_ssr_unprotect(__func__);
6660
6661 return ret;
6662}
6663
Jeff Johnson295189b2012-06-20 16:38:30 -07006664/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306665static int __iw_setnone_getnone(struct net_device *dev,
6666 struct iw_request_info *info,
6667 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006668{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306669 hdd_adapter_t *pAdapter;
6670 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306671 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006672 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306673 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006674
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306675 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6676 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006677 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6679 "%s: Adapter is NULL",__func__);
6680 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006681 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306682 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6683 ret = wlan_hdd_validate_context(pHddCtx);
6684 if (0 != ret)
6685 {
6686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6687 "%s: HDD context is not valid",__func__);
6688 return ret;
6689 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306690 /* helper function to get iwreq_data with compat handling. */
6691 if (hdd_priv_get_data(&s_priv_data, wrqu))
6692 {
6693 return -EINVAL;
6694 }
6695
6696 sub_cmd = s_priv_data.flags;
6697
Jeff Johnson295189b2012-06-20 16:38:30 -07006698 switch (sub_cmd)
6699 {
6700 case WE_CLEAR_STATS:
6701 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6704 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6705 break;
6706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 case WE_INIT_AP:
6708 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306709 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6710
6711 /* As Soft AP mode might been changed to STA already with
6712 * killing of Hostapd, need to find the adpater by name
6713 * rather than mode */
6714 hdd_adapter_t* pAdapter_to_stop =
6715 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6716 if( pAdapter_to_stop )
6717 {
6718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6719 "Adapter with name softap.0 already "
6720 "exist, ignoring the request.\nRemove the "
6721 "adapter and try again\n");
6722 break;
6723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 pr_info("Init AP trigger\n");
6725 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6726 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6727 break;
6728 }
6729 case WE_STOP_AP:
6730 {
6731 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6732 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6733 * this is a dead code and need to find the adpater by name rather than mode */
6734 hdd_adapter_t* pAdapter_to_stop =
6735 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6736 if( pAdapter_to_stop )
6737 {
6738 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6739
6740 pr_info("Stopping AP mode\n");
6741
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306742 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6743 {
6744 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6745 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6746 }
6747
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306749 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006750 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
6751 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6752
6753 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6754 pAdapter_to_stop->macAddressCurrent.bytes);
6755 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6756 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306757
6758 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6759 {
6760 /* put the device back into BMPS */
6761 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 }
6764 else
6765 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006766 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 }
6768
6769 break;
6770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006771#ifdef WLAN_BTAMP_FEATURE
6772 case WE_ENABLE_AMP:
6773 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 WLANBAP_RegisterWithHCI(pAdapter);
6776 break;
6777 }
6778 case WE_DISABLE_AMP:
6779 {
6780 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6781 VOS_STATUS status;
6782
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006784
6785 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6786 status = WLANBAP_StopAmp();
6787 if(VOS_STATUS_SUCCESS != status )
6788 {
6789 pHddCtx->isAmpAllowed = VOS_TRUE;
6790 hddLog(VOS_TRACE_LEVEL_FATAL,
6791 "%s: Failed to stop AMP", __func__);
6792 }
6793 else
6794 {
6795 //a state m/c implementation in PAL is TBD to avoid this delay
6796 msleep(500);
6797 pHddCtx->isAmpAllowed = VOS_FALSE;
6798 WLANBAP_DeregisterFromHCI();
6799 }
6800
6801 break;
6802 }
6803#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006804 case WE_ENABLE_DXE_STALL_DETECT:
6805 {
schang6295e542013-03-12 15:31:23 -07006806 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6807 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006808 break;
6809 }
6810 case WE_DISPLAY_DXE_SNAP_SHOT:
6811 {
schang6295e542013-03-12 15:31:23 -07006812 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6813 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006814 break;
6815 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306816 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6817 {
6818 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6819 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306820 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306821 break;
6822 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306823
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306824 case WE_SET_REASSOC_TRIGGER:
6825 {
6826 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6827 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6828 v_U32_t roamId = 0;
6829 tCsrRoamModifyProfileFields modProfileFields;
6830 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6831 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6832 return 0;
6833 }
6834
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306835 case WE_STOP_OBSS_SCAN:
6836 {
6837 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6838 2.OBSS scan is stopped by Firmware during the disassociation
6839 3.OBSS stop comamnd is added for debugging purpose*/
6840 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6841 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006842
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306843 if (pAdapter == NULL)
6844 {
6845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6846 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306847 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306848 }
6849 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6850 if (pMac == NULL)
6851 {
6852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6853 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306854 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306855 }
6856 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6857 }
6858 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306859#ifdef DEBUG_ROAM_DELAY
6860 case WE_DUMP_ROAM_TIMER_LOG:
6861 {
6862 vos_dump_roam_time_log_service();
6863 break;
6864 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306865
Mukul Sharma84f27252014-07-14 18:11:42 +05306866 case WE_RESET_ROAM_TIMER_LOG:
6867 {
6868 vos_reset_roam_timer_log();
6869 break;
6870 }
6871#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 default:
6873 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006874 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006875 break;
6876 }
6877 }
6878
6879 return ret;
6880}
6881
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306882static int iw_setnone_getnone(struct net_device *dev,
6883 struct iw_request_info *info,
6884 union iwreq_data *wrqu, char *extra)
6885{
6886 int ret;
6887
6888 vos_ssr_protect(__func__);
6889 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
6890 vos_ssr_unprotect(__func__);
6891
6892 return ret;
6893}
6894
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306895void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
6896{
6897 /*
6898 * Function to display HDD WMM information
6899 * for Tx Queues.
6900 * Prints globala as well as per client depending
6901 * whether the clients are registered or not.
6902 */
6903 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306904 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
6905 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
6906
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306907 for ( i=0; i< NUM_TX_QUEUES; i++)
6908 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05306909 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306910
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006911 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306912 i, pAdapter->wmm_tx_queue[i].count,
6913 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05306914 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306915 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306916 if(pSapCtx == NULL){
6917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6918 FL("psapCtx is NULL"));
6919 return;
6920 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306921
6922 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
6923 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306924 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306925 {
6926 hddLog(LOGE, "******STAIndex: %d*********", i);
6927 for ( j=0; j< NUM_TX_QUEUES; j++)
6928 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306929 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006930 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306931 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
6932 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
6933 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
6934 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306935 }
6936 }
6937 }
6938
6939}
Girish Gowlifb9758e2014-11-19 15:19:17 +05306940static int __iw_set_var_ints_getnone(struct net_device *dev,
6941 struct iw_request_info *info,
6942 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006943{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306944 hdd_adapter_t *pAdapter;
6945 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05306946 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05306947 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006948 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306949 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006950 hdd_ap_ctx_t *pAPCtx = NULL;
6951 int cmd = 0;
6952 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306953 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006954
Girish Gowlifb9758e2014-11-19 15:19:17 +05306955 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05306956 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05306957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6958 "%s: NULL extra buffer pointer", __func__);
6959 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05306960 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306961 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6962 if (NULL == pAdapter)
6963 {
6964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6965 "%s: Adapter is NULL",__func__);
6966 return -EINVAL;
6967 }
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306968 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6969 ret = wlan_hdd_validate_context(pHddCtx);
6970 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006971 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6973 "%s: HDD context is Null", __func__);
6974 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006975 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306976 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6977 if (NULL == hHal)
6978 {
6979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6980 "%s: Hal Context is NULL",__func__);
6981 return -EINVAL;
6982 }
6983 sub_cmd = wrqu->data.flags;
6984
6985 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
6986
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006987
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006988 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
6989 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
6990 {
6991 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
6992 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
6993 {
6994 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6995 staId = pStaCtx->conn_info.staId[0];
6996 }
6997 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
6998 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
6999 {
7000 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7001 staId = pAPCtx->uBCStaId;
7002 }
7003 else
7004 {
7005 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7006 return 0;
7007 }
7008 }
7009
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 switch (sub_cmd)
7011 {
7012 case WE_LOG_DUMP_CMD:
7013 {
7014 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007015 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 apps_args[3], apps_args[4]);
7017
7018 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7019 apps_args[3], apps_args[4]);
7020
7021 }
7022 break;
7023
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 case WE_P2P_NOA_CMD:
7025 {
7026 p2p_app_setP2pPs_t p2pNoA;
7027
7028 p2pNoA.opp_ps = apps_args[0];
7029 p2pNoA.ctWindow = apps_args[1];
7030 p2pNoA.duration = apps_args[2];
7031 p2pNoA.interval = apps_args[3];
7032 p2pNoA.count = apps_args[4];
7033 p2pNoA.single_noa_duration = apps_args[5];
7034 p2pNoA.psSelection = apps_args[6];
7035
7036 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7037 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007038 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7040
7041 hdd_setP2pPs(dev, &p2pNoA);
7042
7043 }
7044 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007045
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307046 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7047 {
7048 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7049 __func__, apps_args[0], apps_args[1]);
7050 vosTraceEnable(apps_args[0], apps_args[1]);
7051 }
7052 break;
7053
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007054 case WE_MTRACE_DUMP_CMD:
7055 {
7056 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7057 "bitmask_of_module %d ",
7058 __func__, apps_args[0], apps_args[1], apps_args[2],
7059 apps_args[3]);
7060 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7061 apps_args[2], apps_args[3]);
7062
7063 }
7064 break;
7065
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007066 case WE_MCC_CONFIG_CREDENTIAL :
7067 {
7068 cmd = 287; //Command should be updated if there is any change
7069 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007070 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007071 {
7072 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7073 }
7074 else
7075 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007076 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007077 return 0;
7078 }
7079 }
7080 break;
7081
7082 case WE_MCC_CONFIG_PARAMS :
7083 {
7084 cmd = 288; //command Should be updated if there is any change
7085 // in the Riva dump command
7086 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7087 }
7088 break;
7089
Chilam NG571c65a2013-01-19 12:27:36 +05307090#ifdef FEATURE_WLAN_TDLS
7091 case WE_TDLS_CONFIG_PARAMS :
7092 {
7093 tdls_config_params_t tdlsParams;
7094
Chilam Ng01120412013-02-19 18:32:21 -08007095 tdlsParams.tdls = apps_args[0];
7096 tdlsParams.tx_period_t = apps_args[1];
7097 tdlsParams.tx_packet_n = apps_args[2];
7098 tdlsParams.discovery_period_t = apps_args[3];
7099 tdlsParams.discovery_tries_n = apps_args[4];
7100 tdlsParams.idle_timeout_t = apps_args[5];
7101 tdlsParams.idle_packet_n = apps_args[6];
7102 tdlsParams.rssi_hysteresis = apps_args[7];
7103 tdlsParams.rssi_trigger_threshold = apps_args[8];
7104 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307105
Chilam Ng01120412013-02-19 18:32:21 -08007106 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307107 }
7108 break;
7109#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 default:
7111 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007112 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7113 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007114 }
7115 break;
7116 }
7117
7118 return 0;
7119}
7120
Girish Gowlifb9758e2014-11-19 15:19:17 +05307121static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7122 struct iw_request_info *info,
7123 union iwreq_data *wrqu, char *extra)
7124{
7125 int ret;
7126 union iwreq_data u_priv_wrqu;
7127 int apps_args[MAX_VAR_ARGS] = {0};
7128 int num_args;
7129
7130 /* helper function to get iwreq_data with compat handling. */
7131 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7132 {
7133 return -EINVAL;
7134 }
7135
7136 if (NULL == u_priv_wrqu.data.pointer)
7137 {
7138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7139 "%s: NULL data pointer", __func__);
7140 return -EINVAL;
7141 }
7142
7143 num_args = u_priv_wrqu.data.length;
7144 if (num_args > MAX_VAR_ARGS)
7145 {
7146 num_args = MAX_VAR_ARGS;
7147 }
7148
7149 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7150 (sizeof(int)) * num_args))
7151 {
7152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7153 "%s: failed to copy data from user buffer", __func__);
7154 return -EFAULT;
7155 }
7156
7157 vos_ssr_protect(__func__);
7158 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7159 (char *)&apps_args);
7160 vos_ssr_unprotect(__func__);
7161
7162 return ret;
7163}
7164
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307165int iw_set_var_ints_getnone(struct net_device *dev,
7166 struct iw_request_info *info,
7167 union iwreq_data *wrqu, char *extra)
7168{
7169 int ret;
7170 vos_ssr_protect(__func__);
7171 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7172 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007173
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307174 return ret;
7175}
7176
7177static int __iw_add_tspec(struct net_device *dev,
7178 struct iw_request_info *info,
7179 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007180{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307181 hdd_adapter_t *pAdapter;
7182 hdd_station_ctx_t *pHddStaCtx;
7183 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7185 int params[HDD_WLAN_WMM_PARAM_COUNT];
7186 sme_QosWmmTspecInfo tSpec;
7187 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307188 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307189 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007190
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307191 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7192 if (NULL == pAdapter)
7193 {
7194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7195 "%s: Adapter is NULL",__func__);
7196 return -EINVAL;
7197 }
7198 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7199 ret = wlan_hdd_validate_context(pHddCtx);
7200 if (0 != ret)
7201 {
7202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7203 "%s: HDD context is not valid",__func__);
7204 return ret;
7205 }
7206 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7207 if (NULL == pHddStaCtx)
7208 {
7209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7210 "%s: STA Context is NULL",__func__);
7211 return -EINVAL;
7212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 // make sure the application is sufficiently priviledged
7214 // note that the kernel will do this for "set" ioctls, but since
7215 // this ioctl wants to return status to user space it must be
7216 // defined as a "get" ioctl
7217 if (!capable(CAP_NET_ADMIN))
7218 {
7219 return -EPERM;
7220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 // we must be associated in order to add a tspec
7222 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7223 {
7224 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7225 return 0;
7226 }
7227
7228 // since we are defined to be a "get" ioctl, and since the number
7229 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307230 // will pass down in the iwreq_data, we must copy the "set" params.
7231 // We must handle the compat for iwreq_data in 32U/64K environment.
7232
7233 // helper fucntion to get iwreq_data with compat handling.
7234 if (hdd_priv_get_data(&s_priv_data, wrqu))
7235 {
7236 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7237 return 0;
7238 }
7239
7240 // make sure all params are correctly passed to function
7241 if ((NULL == s_priv_data.pointer) ||
7242 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7243 {
7244 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7245 return 0;
7246 }
7247
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307249 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 {
7251 // hmmm, can't get them
7252 return -EIO;
7253 }
7254
7255 // clear the tspec
7256 memset(&tSpec, 0, sizeof(tSpec));
7257
7258 // validate the handle
7259 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7260 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7261 {
7262 // that one is reserved
7263 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7264 return 0;
7265 }
7266
7267 // validate the TID
7268 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7269 {
7270 // out of range
7271 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7272 return 0;
7273 }
7274 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7275
7276 // validate the direction
7277 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7278 {
7279 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7280 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7281 break;
7282
7283 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7284 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7285 break;
7286
7287 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7288 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7289 break;
7290
7291 default:
7292 // unknown
7293 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7294 return 0;
7295 }
7296
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307297 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7298
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 // validate the user priority
7300 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7301 {
7302 // out of range
7303 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7304 return 0;
7305 }
7306 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307307 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7308 {
7309 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7310 return 0;
7311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007312
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7314 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7315 tSpec.ts_info.psb, tSpec.ts_info.up);
7316
Jeff Johnson295189b2012-06-20 16:38:30 -07007317 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7318 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7319 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7320 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7321 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7322 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7323 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7324 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7325 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7326 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7327 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7328 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7329
7330 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7331
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307332 // Save the expected UAPSD settings by application, this will be needed
7333 // when re-negotiating UAPSD settings during BT Coex cases.
7334 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7335
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 // validate the ts info ack policy
7337 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7338 {
7339 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7340 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7341 break;
7342
7343 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7344 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7345 break;
7346
7347 default:
7348 // unknown
7349 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7350 return 0;
7351 }
7352
7353 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
7354 return 0;
7355}
7356
7357
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307358static int iw_add_tspec(struct net_device *dev,
7359 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 union iwreq_data *wrqu, char *extra)
7361{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307362 int ret;
7363
7364 vos_ssr_protect(__func__);
7365 ret = __iw_add_tspec(dev, info, wrqu, extra);
7366 vos_ssr_unprotect(__func__);
7367
7368 return ret;
7369}
7370
7371static int __iw_del_tspec(struct net_device *dev,
7372 struct iw_request_info *info,
7373 union iwreq_data *wrqu, char *extra)
7374{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307375 hdd_adapter_t *pAdapter;
7376 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 int *params = (int *)extra;
7378 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7379 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307380 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007381
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307382 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7383 if (NULL == pAdapter)
7384 {
7385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7386 "%s: Adapter is NULL",__func__);
7387 return -EINVAL;
7388 }
7389
7390 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7391 ret = wlan_hdd_validate_context(pHddCtx);
7392 if (0 != ret)
7393 {
7394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7395 "%s: HDD context is not valid",__func__);
7396 return ret;
7397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007398 // make sure the application is sufficiently priviledged
7399 // note that the kernel will do this for "set" ioctls, but since
7400 // this ioctl wants to return status to user space it must be
7401 // defined as a "get" ioctl
7402 if (!capable(CAP_NET_ADMIN))
7403 {
7404 return -EPERM;
7405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 // although we are defined to be a "get" ioctl, the params we require
7407 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7408 // is no need to copy the params from user space
7409
7410 // validate the handle
7411 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7412 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7413 {
7414 // that one is reserved
7415 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7416 return 0;
7417 }
7418
7419 *pStatus = hdd_wmm_delts(pAdapter, handle);
7420 return 0;
7421}
7422
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307423static int iw_del_tspec(struct net_device *dev,
7424 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007425 union iwreq_data *wrqu, char *extra)
7426{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307427 int ret;
7428
7429 vos_ssr_protect(__func__);
7430 ret = __iw_del_tspec(dev, info, wrqu, extra);
7431 vos_ssr_unprotect(__func__);
7432
7433 return ret;
7434}
7435
7436
7437static int __iw_get_tspec(struct net_device *dev,
7438 struct iw_request_info *info,
7439 union iwreq_data *wrqu, char *extra)
7440{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307441 hdd_adapter_t *pAdapter;
7442 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007443 int *params = (int *)extra;
7444 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7445 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307446 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007447
7448 // although we are defined to be a "get" ioctl, the params we require
7449 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7450 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307451 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7452 if (NULL == pAdapter)
7453 {
7454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7455 "%s: Adapter is NULL",__func__);
7456 return -EINVAL;
7457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007458
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307459 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7460 ret = wlan_hdd_validate_context(pHddCtx);
7461 if (0 != ret)
7462 {
7463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7464 "%s: HDD context is not valid",__func__);
7465 return ret;
7466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007467 // validate the handle
7468 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7469 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7470 {
7471 // that one is reserved
7472 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7473 return 0;
7474 }
7475
7476 *pStatus = hdd_wmm_checkts(pAdapter, handle);
7477 return 0;
7478}
7479
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307480static int iw_get_tspec(struct net_device *dev,
7481 struct iw_request_info *info,
7482 union iwreq_data *wrqu, char *extra)
7483{
7484 int ret;
7485
7486 vos_ssr_protect(__func__);
7487 ret = __iw_get_tspec(dev, info, wrqu, extra);
7488 vos_ssr_unprotect(__func__);
7489
7490 return ret;
7491}
7492
Jeff Johnson295189b2012-06-20 16:38:30 -07007493#ifdef WLAN_FEATURE_VOWIFI_11R
7494//
7495//
7496// Each time the supplicant has the auth_request or reassoc request
7497// IEs ready. This is pushed to the driver. The driver will inturn use
7498// it to send out the auth req and reassoc req for 11r FT Assoc.
7499//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307500static int __iw_set_fties(struct net_device *dev,
7501 struct iw_request_info *info,
7502 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007503{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307504 hdd_adapter_t *pAdapter;
7505 hdd_station_ctx_t *pHddStaCtx;
7506 hdd_context_t *pHddCtx;
7507 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007508 //v_CONTEXT_t pVosContext;
7509
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307510 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7511 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007512 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7514 "%s: Adapter is NULL",__func__);
7515 return -EINVAL;
7516 }
7517 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7518 ret = wlan_hdd_validate_context(pHddCtx);
7519 if (0 != ret)
7520 {
7521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7522 "%s: HDD context is not valid",__func__);
7523 return ret;
7524 }
7525 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7526 if (NULL == pHddStaCtx)
7527 {
7528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7529 "%s: STA Context is NULL",__func__);
7530 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007532 if (!wrqu->data.length)
7533 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007534 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 return -EINVAL;
7536 }
7537 if (wrqu->data.pointer == NULL)
7538 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007539 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 return -EINVAL;
7541 }
7542
7543 // Added for debug on reception of Re-assoc Req.
7544 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7545 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007546 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007547 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007548 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 }
7550
7551#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007552 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007553#endif
7554
7555 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007556 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 wrqu->data.length);
7558
7559 return 0;
7560}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307561
7562static int iw_set_fties(struct net_device *dev,
7563 struct iw_request_info *info,
7564 union iwreq_data *wrqu, char *extra)
7565{
7566 int ret;
7567
7568 vos_ssr_protect(__func__);
7569 ret = __iw_set_fties(dev, info, wrqu, extra);
7570 vos_ssr_unprotect(__func__);
7571
7572 return ret;
7573}
Jeff Johnson295189b2012-06-20 16:38:30 -07007574#endif
7575
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307576static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007577 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007579{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307580 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007581 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307582 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007583 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307584 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007585 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7586 int idx;
7587 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007588
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307589 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7590 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007591 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7593 "%s: Adapter is NULL",__func__);
7594 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007595 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307596 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7597 ret_val = wlan_hdd_validate_context(pHddCtx);
7598 if (0 != ret_val)
7599 {
7600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7601 "%s: HDD context is not valid",__func__);
7602 return ret_val;
7603 }
7604 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7605 if (NULL == hHal)
7606 {
7607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7608 "%s: Hal Context is NULL",__func__);
7609 return -EINVAL;
7610 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307611 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7612 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307613#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007614
Amar Singhalf3a6e762013-02-19 15:06:50 -08007615 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7616 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007617 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007618 hddLog(VOS_TRACE_LEVEL_ERROR,
7619 "%s: vos_mem_alloc failed", __func__);
7620 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007621 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007622
7623 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7624
7625 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7626 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7627
7628 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7629 mc_addr_list_ptr->ulMulticastAddrCnt);
7630
7631 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007632 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007633 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7634 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7635
7636 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7637 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007638 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007639
Amar Singhalf3a6e762013-02-19 15:06:50 -08007640 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7641 vos_mem_free(mc_addr_list_ptr);
7642 if (eHAL_STATUS_SUCCESS != ret_val)
7643 {
7644 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7645 __func__);
7646 return -EINVAL;
7647 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307648#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307649 }
7650 else
7651 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007652
Amar Singhalf3a6e762013-02-19 15:06:50 -08007653 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7654 "%s: Set MC BC Filter Config request: %d suspend %d",
7655 __func__, pRequest->mcastBcastFilterSetting,
7656 pHddCtx->hdd_wlan_suspended);
7657
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307658 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007659
7660 if (pHddCtx->hdd_wlan_suspended)
7661 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007662 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7663 if (NULL == wlanRxpFilterParam)
7664 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307665 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007666 "%s: vos_mem_alloc failed", __func__);
7667 return -EINVAL;
7668 }
7669
Amar Singhalf3a6e762013-02-19 15:06:50 -08007670 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7671 pRequest->mcastBcastFilterSetting;
7672 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7673
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307674 hdd_conf_hostoffload(pAdapter, TRUE);
7675 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7676 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007677
7678 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7679 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307680 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007681 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7682 wlanRxpFilterParam->setMcstBcstFilter);
7683
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307684 if (eHAL_STATUS_SUCCESS !=
7685 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7686 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007687 {
7688 hddLog(VOS_TRACE_LEVEL_ERROR,
7689 "%s: Failure to execute set HW MC/BC Filter request",
7690 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007691 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007692 return -EINVAL;
7693 }
7694
c_hpothud3ce76d2014-10-28 10:34:13 +05307695 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7696 {
7697 pHddCtx->sus_res_mcastbcast_filter =
7698 pRequest->mcastBcastFilterSetting;
7699 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007700 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007702
7703 return 0;
7704}
7705
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307706static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7707 struct iw_request_info *info,
7708 union iwreq_data *wrqu, char *extra)
7709{
7710 int ret;
7711
7712 vos_ssr_protect(__func__);
7713 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
7714 vos_ssr_unprotect(__func__);
7715
7716 return ret;
7717}
7718
7719static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7720 struct iw_request_info *info,
7721 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007722{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307723 hdd_adapter_t *pAdapter;
7724 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307725 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307726 int ret = 0;
7727
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007728 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007729
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307730 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7731 if (NULL == pAdapter)
7732 {
7733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7734 "%s: Adapter is NULL",__func__);
7735 return -EINVAL;
7736 }
7737
7738 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7739 ret = wlan_hdd_validate_context(pHddCtx);
7740 if (0 != ret)
7741 {
7742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7743 "%s: HDD context is not valid",__func__);
7744 return ret;
7745 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307746 //Reset the filter to INI value as we have to clear the dynamic filter
7747 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07007748
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307749 //Configure FW with new setting
7750 if (pHddCtx->hdd_wlan_suspended)
7751 {
7752 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7753 if (NULL == wlanRxpFilterParam)
7754 {
7755 hddLog(VOS_TRACE_LEVEL_ERROR,
7756 "%s: vos_mem_alloc failed", __func__);
7757 return -EINVAL;
7758 }
7759
7760 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7761 pHddCtx->configuredMcastBcastFilter;
7762 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7763
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307764 hdd_conf_hostoffload(pAdapter, TRUE);
7765 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7766 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307767
7768 if (eHAL_STATUS_SUCCESS !=
7769 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7770 wlanRxpFilterParam))
7771 {
7772 hddLog(VOS_TRACE_LEVEL_ERROR,
7773 "%s: Failure to execute set HW MC/BC Filter request",
7774 __func__);
7775 vos_mem_free(wlanRxpFilterParam);
7776 return -EINVAL;
7777 }
c_hpothud3ce76d2014-10-28 10:34:13 +05307778
7779 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7780 {
7781 pHddCtx->sus_res_mcastbcast_filter =
7782 pHddCtx->cfg_ini->mcastBcastFilterSetting;
7783 }
7784
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307785 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007786 return 0;
7787}
7788
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307789
7790static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7791 struct iw_request_info *info,
7792 union iwreq_data *wrqu, char *extra)
7793{
7794 int ret;
7795
7796 vos_ssr_protect(__func__);
7797 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
7798 vos_ssr_unprotect(__func__);
7799
7800 return ret;
7801}
7802
7803static int __iw_set_host_offload(struct net_device *dev,
7804 struct iw_request_info *info,
7805 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007806{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307807 hdd_adapter_t *pAdapter;
7808 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007809 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307811 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007812
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307813 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7814 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007815 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7817 "%s: Adapter is NULL",__func__);
7818 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007819 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307820 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7821 ret = wlan_hdd_validate_context(pHddCtx);
7822 if (0 != ret)
7823 {
7824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7825 "%s: HDD context is not valid",__func__);
7826 return ret;
7827 }
7828
Jeff Johnson295189b2012-06-20 16:38:30 -07007829 /* Debug display of request components. */
7830 switch (pRequest->offloadType)
7831 {
7832 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007833 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007834 switch (pRequest->enableOrDisable)
7835 {
7836 case WLAN_OFFLOAD_DISABLE:
7837 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
7838 break;
7839 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
7840 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
7841 case WLAN_OFFLOAD_ENABLE:
7842 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
7843 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
7844 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
7845 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
7846 }
7847 break;
7848
7849 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08007850 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007851 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007852 switch (pRequest->enableOrDisable)
7853 {
7854 case WLAN_OFFLOAD_DISABLE:
7855 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
7856 break;
7857 case WLAN_OFFLOAD_ENABLE:
7858 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
7859 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
7860 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
7861 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
7862 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
7863 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
7864 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
7865 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
7866 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
7867 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
7868 }
7869 }
7870
7871 /* Execute offload request. The reason that we can copy the request information
7872 from the ioctl structure to the SME structure is that they are laid out
7873 exactly the same. Otherwise, each piece of information would have to be
7874 copied individually. */
7875 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07007876 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
7877 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007879 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07007880 __func__);
7881 return -EINVAL;
7882 }
7883
7884 return 0;
7885}
7886
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307887static int iw_set_host_offload(struct net_device *dev,
7888 struct iw_request_info *info,
7889 union iwreq_data *wrqu, char *extra)
7890{
7891 int ret;
7892
7893 vos_ssr_protect(__func__);
7894 ret = __iw_set_host_offload(dev, info, wrqu, extra);
7895 vos_ssr_unprotect(__func__);
7896
7897 return ret;
7898}
7899
7900static int __iw_set_keepalive_params(struct net_device *dev,
7901 struct iw_request_info *info,
7902 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007903{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307904 hdd_adapter_t *pAdapter;
7905 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007906 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307908 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007909
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307910 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7911 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07007912 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7914 "%s: Adapter is NULL",__func__);
7915 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307917 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7918 ret = wlan_hdd_validate_context(pHddCtx);
7919 if (0 != ret)
7920 {
7921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7922 "%s: HDD context is not valid",__func__);
7923 return ret;
7924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007925 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08007926 hddLog(VOS_TRACE_LEVEL_INFO,
7927 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
7928 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07007929
7930 switch (pRequest->packetType)
7931 {
7932 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007933 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007934 break;
7935
7936 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
7937
Arif Hussain6d2a3322013-11-17 19:50:10 -08007938 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007939 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007940
7941 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
7942 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
7943 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
7944
7945 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
7946 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
7947 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
7948
7949 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
7950 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
7951 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
7952 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
7953 break;
7954
7955 }
7956
7957 /* Execute keep alive request. The reason that we can copy the request information
7958 from the ioctl structure to the SME structure is that they are laid out
7959 exactly the same. Otherwise, each piece of information would have to be
7960 copied individually. */
7961 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
7962
Arif Hussain6d2a3322013-11-17 19:50:10 -08007963 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07007964
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007965 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07007966 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007968 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 __func__);
7970 return -EINVAL;
7971 }
7972
7973 return 0;
7974}
7975
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307976static int iw_set_keepalive_params(struct net_device *dev,
7977 struct iw_request_info *info,
7978 union iwreq_data *wrqu, char *extra)
7979{
7980 int ret;
7981 vos_ssr_protect(__func__);
7982 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
7983 vos_ssr_unprotect(__func__);
7984
7985 return ret;
7986}
7987
Jeff Johnson295189b2012-06-20 16:38:30 -07007988#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007989int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07007990 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007991{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007992 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
7993 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07007994 int i=0;
7995
7996 if (pHddCtx->cfg_ini->disablePacketFilter)
7997 {
7998 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007999 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008000 return 0;
8001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008002 /* Debug display of request components. */
8003 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008004 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008005
8006 switch (pRequest->filterAction)
8007 {
8008 case HDD_RCV_FILTER_SET:
8009 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008010 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008011
8012 packetFilterSetReq.filterId = pRequest->filterId;
8013 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8014 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008015 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008016 __func__, pRequest->numParams);
8017 return -EINVAL;
8018 }
8019 packetFilterSetReq.numFieldParams = pRequest->numParams;
8020 packetFilterSetReq.coalesceTime = 0;
8021 packetFilterSetReq.filterType = 1;
8022 for (i=0; i < pRequest->numParams; i++)
8023 {
8024 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8025 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8026 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8027 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8028 packetFilterSetReq.paramsData[i].reserved = 0;
8029
Arif Hussain6d2a3322013-11-17 19:50:10 -08008030 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008031 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8032 packetFilterSetReq.filterType);
8033
Arif Hussain6d2a3322013-11-17 19:50:10 -08008034 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008035 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8036
8037 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8038 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8039 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8040 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8041
Arif Hussain6d2a3322013-11-17 19:50:10 -08008042 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8044 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8045 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8046
Arif Hussain6d2a3322013-11-17 19:50:10 -08008047 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8049 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8050 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8051 }
8052
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008053 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008054 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008055 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 __func__);
8057 return -EINVAL;
8058 }
8059
8060 break;
8061
8062 case HDD_RCV_FILTER_CLEAR:
8063
Arif Hussain6d2a3322013-11-17 19:50:10 -08008064 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008065 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008066 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008067 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008068 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008069 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008070 __func__);
8071 return -EINVAL;
8072 }
8073 break;
8074
8075 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008076 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008077 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 return -EINVAL;
8079 }
8080 return 0;
8081}
8082
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308083int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8084 tANI_U8 sessionId)
8085{
8086 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8087 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8088
8089 if (NULL == pHddCtx)
8090 {
8091 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8092 return -EINVAL;
8093 }
8094
8095 if (pHddCtx->isLogpInProgress)
8096 {
8097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8098 "%s:LOGP in Progress. Ignore!!!", __func__);
8099 return -EBUSY;
8100 }
8101
8102 if (pHddCtx->cfg_ini->disablePacketFilter)
8103 {
8104 hddLog(VOS_TRACE_LEVEL_ERROR,
8105 "%s: Packet Filtering Disabled. Returning ",
8106 __func__ );
8107 return -EINVAL;
8108 }
8109
8110 switch (filterType)
8111 {
8112 /* For setting IPV6 MC and UC Filter we need to configure
8113 * 2 filters, one for MC and one for UC.
8114 * The Filter ID shouldn't be swapped, which results in making
8115 * UC Filter ineffective.
8116 * We have Hardcode all the values
8117 *
8118 * Reason for a seperate UC filter is because, driver need to
8119 * specify the FW that the specific filter is for unicast
8120 * otherwise FW will not pass the unicast frames by default
8121 * through the filter. This is required to avoid any performance
8122 * hits when no unicast filter is set and only MC/BC are set.
8123 * The way driver informs host is by using the MAC protocol
8124 * layer, CMP flag set to MAX, CMP Data set to 1.
8125 */
8126
8127 case HDD_FILTER_IPV6_MC_UC:
8128 /* Setting IPV6 MC Filter below
8129 */
8130 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8131 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8132 packetFilterSetReq.numFieldParams = 2;
8133 packetFilterSetReq.paramsData[0].protocolLayer =
8134 HDD_FILTER_PROTO_TYPE_MAC;
8135 packetFilterSetReq.paramsData[0].cmpFlag =
8136 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8137 packetFilterSetReq.paramsData[0].dataOffset =
8138 WLAN_HDD_80211_FRM_DA_OFFSET;
8139 packetFilterSetReq.paramsData[0].dataLength = 1;
8140 packetFilterSetReq.paramsData[0].compareData[0] =
8141 HDD_IPV6_MC_CMP_DATA;
8142
8143 packetFilterSetReq.paramsData[1].protocolLayer =
8144 HDD_FILTER_PROTO_TYPE_ARP;
8145 packetFilterSetReq.paramsData[1].cmpFlag =
8146 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8147 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8148 packetFilterSetReq.paramsData[1].dataLength = 2;
8149 packetFilterSetReq.paramsData[1].compareData[0] =
8150 HDD_IPV6_CMP_DATA_0;
8151 packetFilterSetReq.paramsData[1].compareData[1] =
8152 HDD_IPV6_CMP_DATA_1;
8153
8154
8155 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8156 &packetFilterSetReq, sessionId))
8157 {
8158 hddLog(VOS_TRACE_LEVEL_ERROR,
8159 "%s: Failure to execute Set IPv6 Mulicast Filter",
8160 __func__);
8161 return -EINVAL;
8162 }
8163
8164 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8165
8166 /*
8167 * Setting IPV6 UC Filter below
8168 */
8169 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8170 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8171 packetFilterSetReq.numFieldParams = 2;
8172 packetFilterSetReq.paramsData[0].protocolLayer =
8173 HDD_FILTER_PROTO_TYPE_MAC;
8174 packetFilterSetReq.paramsData[0].cmpFlag =
8175 HDD_FILTER_CMP_TYPE_MAX;
8176 packetFilterSetReq.paramsData[0].dataOffset = 0;
8177 packetFilterSetReq.paramsData[0].dataLength = 1;
8178 packetFilterSetReq.paramsData[0].compareData[0] =
8179 HDD_IPV6_UC_CMP_DATA;
8180
8181 packetFilterSetReq.paramsData[1].protocolLayer =
8182 HDD_FILTER_PROTO_TYPE_ARP;
8183 packetFilterSetReq.paramsData[1].cmpFlag =
8184 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8185 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8186 packetFilterSetReq.paramsData[1].dataLength = 2;
8187 packetFilterSetReq.paramsData[1].compareData[0] =
8188 HDD_IPV6_CMP_DATA_0;
8189 packetFilterSetReq.paramsData[1].compareData[1] =
8190 HDD_IPV6_CMP_DATA_1;
8191
8192 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8193 &packetFilterSetReq, sessionId))
8194 {
8195 hddLog(VOS_TRACE_LEVEL_ERROR,
8196 "%s: Failure to execute Set IPv6 Unicast Filter",
8197 __func__);
8198 return -EINVAL;
8199 }
8200
8201 break;
8202
8203 case HDD_FILTER_IPV6_MC:
8204 /*
8205 * IPV6 UC Filter might be already set,
8206 * clear the UC Filter. As the Filter
8207 * IDs are static, we can directly clear it.
8208 */
8209 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8210 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8211 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8212 &packetFilterClrReq, sessionId))
8213 {
8214 hddLog(VOS_TRACE_LEVEL_ERROR,
8215 "%s: Failure to execute Clear IPv6 Unicast Filter",
8216 __func__);
8217 return -EINVAL;
8218 }
8219
8220 /*
8221 * Setting IPV6 MC Filter below
8222 */
8223 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8224 packetFilterSetReq.numFieldParams = 2;
8225 packetFilterSetReq.paramsData[0].protocolLayer =
8226 HDD_FILTER_PROTO_TYPE_MAC;
8227 packetFilterSetReq.paramsData[0].cmpFlag =
8228 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8229 packetFilterSetReq.paramsData[0].dataOffset =
8230 WLAN_HDD_80211_FRM_DA_OFFSET;
8231 packetFilterSetReq.paramsData[0].dataLength = 1;
8232 packetFilterSetReq.paramsData[0].compareData[0] =
8233 HDD_IPV6_MC_CMP_DATA;
8234
8235 packetFilterSetReq.paramsData[1].protocolLayer =
8236 HDD_FILTER_PROTO_TYPE_ARP;
8237 packetFilterSetReq.paramsData[1].cmpFlag =
8238 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8239 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8240 packetFilterSetReq.paramsData[1].dataLength = 2;
8241 packetFilterSetReq.paramsData[1].compareData[0] =
8242 HDD_IPV6_CMP_DATA_0;
8243 packetFilterSetReq.paramsData[1].compareData[1] =
8244 HDD_IPV6_CMP_DATA_1;
8245
8246
8247 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8248 &packetFilterSetReq, sessionId))
8249 {
8250 hddLog(VOS_TRACE_LEVEL_ERROR,
8251 "%s: Failure to execute Set IPv6 Multicast Filter",
8252 __func__);
8253 return -EINVAL;
8254 }
8255 break;
8256
8257 default :
8258 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8259 "%s: Packet Filter Request: Invalid",
8260 __func__);
8261 return -EINVAL;
8262 }
8263 return 0;
8264}
8265
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308266void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008267{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308268 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308269 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008270 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308271 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008272
Yue Ma3ede6052013-08-29 00:33:26 -07008273 if (NULL == pHddCtx)
8274 {
8275 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8276 return;
8277 }
8278
8279 hHal = pHddCtx->hHal;
8280
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308281 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008282 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308283 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8284 return;
8285 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308286
8287 /* Check if INI is enabled or not, other wise just return
8288 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308289 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308290 {
8291 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8292 if (NULL == pMulticastAddrs)
8293 {
8294 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8295 return;
8296 }
8297
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 if (set)
8299 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308300 /* Following pre-conditions should be satisfied before wei
8301 * configure the MC address list.
8302 */
8303 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8304 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8305 && pAdapter->mc_addr_list.mc_cnt
8306 && (eConnectionState_Associated ==
8307 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8308 {
8309 pMulticastAddrs->ulMulticastAddrCnt =
8310 pAdapter->mc_addr_list.mc_cnt;
8311 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8312 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008313 memcpy(pMulticastAddrs->multicastAddr[i],
8314 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308315 sizeof(pAdapter->mc_addr_list.addr[i]));
8316 hddLog(VOS_TRACE_LEVEL_INFO,
8317 "%s: %s multicast filter: addr ="
8318 MAC_ADDRESS_STR,
8319 __func__, set ? "setting" : "clearing",
8320 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8321 }
8322 /* Set multicast filter */
8323 sme_8023MulticastList(hHal, pAdapter->sessionId,
8324 pMulticastAddrs);
8325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308327 else
8328 {
8329 /* Need to clear only if it was previously configured
8330 */
8331 if (pAdapter->mc_addr_list.isFilterApplied)
8332 {
8333 pMulticastAddrs->ulMulticastAddrCnt = 0;
8334 sme_8023MulticastList(hHal, pAdapter->sessionId,
8335 pMulticastAddrs);
8336 }
8337
8338 }
8339 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008340 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308342 else
8343 {
8344 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308345 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308346 }
8347 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008348}
8349
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308350static int __iw_set_packet_filter_params(struct net_device *dev,
8351 struct iw_request_info *info,
8352 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308353{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308354 hdd_adapter_t *pAdapter;
8355 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008356 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308357 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308358 struct iw_point s_priv_data;
8359
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308360 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8361 if (NULL == pAdapter)
8362 {
8363 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8364 "%s: Adapter is NULL",__func__);
8365 return -EINVAL;
8366 }
8367 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8368 ret = wlan_hdd_validate_context(pHddCtx);
8369 if (0 != ret)
8370 {
8371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8372 "%s: HDD context is not valid",__func__);
8373 return ret;
8374 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308375 if (hdd_priv_get_data(&s_priv_data, wrqu))
8376 {
8377 return -EINVAL;
8378 }
8379
8380 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8381 {
8382 return -EINVAL;
8383 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008384
Arif Hussain0273cba2014-01-07 20:58:29 -08008385 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308386 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8387 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008388 if (NULL == pRequest)
8389 {
8390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8391 "mem_alloc_copy_from_user_helper fail");
8392 return -ENOMEM;
8393 }
8394
8395 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8396 kfree(pRequest);
8397
8398 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008399}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308400
8401static int iw_set_packet_filter_params(struct net_device *dev,
8402 struct iw_request_info *info,
8403 union iwreq_data *wrqu, char *extra)
8404{
8405 int ret;
8406
8407 vos_ssr_protect(__func__);
8408 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8409 vos_ssr_unprotect(__func__);
8410
8411 return ret;
8412}
Jeff Johnson295189b2012-06-20 16:38:30 -07008413#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308414static int __iw_get_statistics(struct net_device *dev,
8415 struct iw_request_info *info,
8416 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008417{
8418
8419 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8420 eHalStatus status = eHAL_STATUS_SUCCESS;
8421 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308422 hdd_adapter_t *pAdapter;
8423 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308425 int tlen = 0, ret = 0;
8426 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008427
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308428 tCsrGlobalClassAStatsInfo *aStats;
8429 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008430
8431 ENTER();
8432
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308433 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8434 if (NULL == pAdapter)
8435 {
8436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8437 "%s: Adapter is NULL",__func__);
8438 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308440 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8441 ret = wlan_hdd_validate_context(pHddCtx);
8442 if (0 != ret)
8443 {
8444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8445 "%s: HDD context is not valid",__func__);
8446 return ret;
8447 }
8448 pStats = &(pAdapter->hdd_stats.summary_stat);
8449 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8450 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8452
8453 wrqu->txpower.value = 0;
8454 }
8455 else {
8456 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8457 SME_SUMMARY_STATS |
8458 SME_GLOBAL_CLASSA_STATS |
8459 SME_GLOBAL_CLASSB_STATS |
8460 SME_GLOBAL_CLASSC_STATS |
8461 SME_GLOBAL_CLASSD_STATS |
8462 SME_PER_STA_STATS,
8463 hdd_StatisticsCB, 0, FALSE,
8464 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8465
8466 if (eHAL_STATUS_SUCCESS != status)
8467 {
8468 hddLog(VOS_TRACE_LEVEL_ERROR,
8469 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008470 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008471 return -EINVAL;
8472 }
8473
8474 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308475 if (NULL == pWextState)
8476 {
8477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8478 "%s: pWextState is NULL",__func__);
8479 return -EINVAL;
8480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008481
8482 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8483 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8484 {
8485 hddLog(VOS_TRACE_LEVEL_ERROR,
8486 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008487 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 /*Remove the SME statistics list by passing NULL in callback argument*/
8489 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8490 SME_SUMMARY_STATS |
8491 SME_GLOBAL_CLASSA_STATS |
8492 SME_GLOBAL_CLASSB_STATS |
8493 SME_GLOBAL_CLASSC_STATS |
8494 SME_GLOBAL_CLASSD_STATS |
8495 SME_PER_STA_STATS,
8496 NULL, 0, FALSE,
8497 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8498
8499 return -EINVAL;
8500 }
8501 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8502 (tANI_U8) sizeof (pStats->retry_cnt),
8503 (char*) &(pStats->retry_cnt[0]),
8504 tlen);
8505
8506 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8507 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8508 (char*) &(pStats->multiple_retry_cnt[0]),
8509 tlen);
8510
8511 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8512 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8513 (char*) &(pStats->tx_frm_cnt[0]),
8514 tlen);
8515
8516 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8517 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8518 (char*) &(pStats->rx_frm_cnt),
8519 tlen);
8520
8521 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8522 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8523 (char*) &(pStats->frm_dup_cnt),
8524 tlen);
8525
8526 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8527 (tANI_U8) sizeof (pStats->fail_cnt),
8528 (char*) &(pStats->fail_cnt[0]),
8529 tlen);
8530
8531 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8532 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8533 (char*) &(pStats->rts_fail_cnt),
8534 tlen);
8535
8536 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8537 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8538 (char*) &(pStats->ack_fail_cnt),
8539 tlen);
8540
8541 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8542 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8543 (char*) &(pStats->rts_succ_cnt),
8544 tlen);
8545
8546 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8547 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8548 (char*) &(pStats->rx_discard_cnt),
8549 tlen);
8550
8551 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8552 (tANI_U8) sizeof (pStats->rx_error_cnt),
8553 (char*) &(pStats->rx_error_cnt),
8554 tlen);
8555
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008556 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008557 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008558 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008559 tlen);
8560
8561 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8562 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8563 (char*) &(dStats->rx_byte_cnt),
8564 tlen);
8565
8566 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8567 (tANI_U8) sizeof (dStats->rx_rate),
8568 (char*) &(dStats->rx_rate),
8569 tlen);
8570
8571 /* Transmit rate, in units of 500 kbit/sec */
8572 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8573 (tANI_U8) sizeof (aStats->tx_rate),
8574 (char*) &(aStats->tx_rate),
8575 tlen);
8576
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008577 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8578 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8579 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008580 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008581 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8582 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8583 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008584 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008585 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8586 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8587 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008588 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008589 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8590 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8591 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008592 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008593 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8594 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8595 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008596 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008597 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8598 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8599 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008600 tlen);
8601
Jeff Johnson295189b2012-06-20 16:38:30 -07008602 wrqu->data.length = tlen;
8603
8604 }
8605
8606 EXIT();
8607
8608 return 0;
8609}
8610
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308611static int iw_get_statistics(struct net_device *dev,
8612 struct iw_request_info *info,
8613 union iwreq_data *wrqu, char *extra)
8614{
8615 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008616
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308617 vos_ssr_protect(__func__);
8618 ret = __iw_get_statistics(dev, info, wrqu, extra);
8619 vos_ssr_unprotect(__func__);
8620
8621 return ret;
8622}
Jeff Johnson295189b2012-06-20 16:38:30 -07008623#ifdef FEATURE_WLAN_SCAN_PNO
8624
8625/*Max Len for PNO notification*/
8626#define MAX_PNO_NOTIFY_LEN 100
8627void found_pref_network_cb (void *callbackContext,
8628 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8629{
8630 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8631 union iwreq_data wrqu;
8632 char buf[MAX_PNO_NOTIFY_LEN+1];
8633
8634 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8635 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8636
8637 // create the event
8638 memset(&wrqu, 0, sizeof(wrqu));
8639 memset(buf, 0, sizeof(buf));
8640
8641 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8642 pPrefNetworkFoundInd->ssId.ssId,
8643 (unsigned int)pPrefNetworkFoundInd->rssi);
8644
8645 wrqu.data.pointer = buf;
8646 wrqu.data.length = strlen(buf);
8647
8648 // send the event
8649
8650 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8651
8652}
8653
8654
8655/*string based input*/
8656VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8657 union iwreq_data *wrqu, char *extra, int nOffset)
8658{
8659 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308660 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008661 /* pnoRequest is a large struct, so we make it static to avoid stack
8662 overflow. This API is only invoked via ioctl, so it is
8663 serialized by the kernel rtnl_lock and hence does not need to be
8664 reentrant */
8665 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 char *ptr;
8667 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308668 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008669 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8670
8671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8672 "PNO data len %d data %s",
8673 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008674 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008675
8676 if (wrqu->data.length <= nOffset )
8677 {
8678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8679 return VOS_STATUS_E_FAILURE;
8680 }
8681
8682 pnoRequest.enable = 0;
8683 pnoRequest.ucNetworksCount = 0;
8684 /*-----------------------------------------------------------------------
8685 Input is string based and expected to be like this:
8686
8687 <enabled> <netw_count>
8688 for each network:
8689 <ssid_len> <ssid> <authentication> <encryption>
8690 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8691 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8692
8693 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008694 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 -07008695
8696 this translates into:
8697 -----------------------------
8698 enable PNO
8699 look for 2 networks:
8700 test - with authentication type 0 and encryption type 0,
8701 that can be found on 3 channels: 1 6 and 11 ,
8702 SSID bcast type is unknown (directed probe will be sent if AP not found)
8703 and must meet -40dBm RSSI
8704
8705 test2 - with auth and enrytption type 4/4
8706 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
8707 bcast type is non-bcast (directed probe will be sent)
8708 and must not meet any RSSI threshold
8709
Jeff Johnson8301aa12013-03-28 14:27:29 -07008710 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08008712 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008713
Wilson Yang623f6592013-10-08 16:33:37 -07008714 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
8715 {
8716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8717 "PNO enable input is not valid %s",ptr);
8718 return VOS_STATUS_E_FAILURE;
8719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008720
8721 if ( 0 == pnoRequest.enable )
8722 {
8723 /*Disable PNO*/
8724 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05308725 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8726 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 pAdapter->sessionId,
8728 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308729 if (eHAL_STATUS_SUCCESS != status)
8730 {
8731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8732 "%s: failed to disable PNO", __func__);
8733 return VOS_STATUS_E_FAILURE;
8734 }
8735 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008736 return VOS_STATUS_SUCCESS;
8737 }
8738
c_hpothu37f21312014-04-09 21:49:54 +05308739 if (TRUE == pHddCtx->isPnoEnable)
8740 {
8741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8742 FL("already PNO is enabled"));
8743 return -EBUSY;
8744 }
8745 pHddCtx->isPnoEnable = TRUE;
8746
Jeff Johnson295189b2012-06-20 16:38:30 -07008747 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07008748
8749 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
8750 {
8751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8752 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308753 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008755
8756 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8757 "PNO enable %d networks count %d offset %d",
8758 pnoRequest.enable,
8759 pnoRequest.ucNetworksCount,
8760 nOffset);
8761
8762 /* Parameters checking:
8763 ucNetworksCount has to be larger than 0*/
8764 if (( 0 == pnoRequest.ucNetworksCount ) ||
8765 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8766 {
8767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05308768 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 }
8770
8771 ptr += nOffset;
8772
8773 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
8774 {
8775
8776 pnoRequest.aNetworks[i].ssId.length = 0;
8777
Wilson Yang623f6592013-10-08 16:33:37 -07008778 ucParams = sscanf(ptr,"%hhu %n",
8779 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
8780
8781 if (1 != ucParams)
8782 {
8783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8784 "PNO ssid length input is not valid %s",ptr);
8785 return VOS_STATUS_E_FAILURE;
8786 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008787
8788 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
8789 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
8790 {
8791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8792 "SSID Len %d is not correct for network %d",
8793 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05308794 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 }
8796
8797 /*Advance to SSID*/
8798 ptr += nOffset;
8799
Jeff Johnson8301aa12013-03-28 14:27:29 -07008800 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08008801 pnoRequest.aNetworks[i].ssId.length);
8802 ptr += pnoRequest.aNetworks[i].ssId.length;
8803
Jeff Johnson02797792013-10-26 19:17:13 -07008804 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08008805 &(pnoRequest.aNetworks[i].authentication),
8806 &(pnoRequest.aNetworks[i].encryption),
8807 &(pnoRequest.aNetworks[i].ucChannelCount),
8808 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008809
Wilson Yang623f6592013-10-08 16:33:37 -07008810 if ( 3 != ucParams )
8811 {
8812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8813 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308814 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008815 }
8816
Jeff Johnson295189b2012-06-20 16:38:30 -07008817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008818 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08008819 "auth %d encry %d channel count %d offset %d",
8820 pnoRequest.aNetworks[i].ssId.length,
8821 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
8822 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
8823 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
8824 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
8825 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
8826 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
8827 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
8828 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
8829 pnoRequest.aNetworks[i].authentication,
8830 pnoRequest.aNetworks[i].encryption,
8831 pnoRequest.aNetworks[i].ucChannelCount,
8832 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07008833
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 /*Advance to channel list*/
8835 ptr += nOffset;
8836
Wilson Yang623f6592013-10-08 16:33:37 -07008837 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07008838 {
8839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8840 "Incorrect number of channels");
8841 return VOS_STATUS_E_FAILURE;
8842 }
8843
8844 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
8845 {
8846 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
8847 {
Wilson Yang623f6592013-10-08 16:33:37 -07008848 if (1 != sscanf(ptr,"%hhu %n",
8849 &(pnoRequest.aNetworks[i].aChannels[j]),
8850 &nOffset))
8851 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8852 "PNO network channel input is not valid %s",ptr);
8853 return VOS_STATUS_E_FAILURE;
8854 }
8855 /*Advance to next channel number*/
8856 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 }
8858 }
8859
Jeff Johnson02797792013-10-26 19:17:13 -07008860 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07008861 &(pnoRequest.aNetworks[i].bcastNetwType),
8862 &nOffset))
8863 {
8864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8865 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308866 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008868
8869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8870 "PNO bcastNetwType %d offset %d",
8871 pnoRequest.aNetworks[i].bcastNetwType,
8872 nOffset );
8873
8874 /*Advance to rssi Threshold*/
8875 ptr += nOffset;
8876
Wilson Yang623f6592013-10-08 16:33:37 -07008877 if (1 != sscanf(ptr,"%hhu %n",
8878 &(pnoRequest.aNetworks[i].rssiThreshold),
8879 &nOffset))
8880 {
8881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8882 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308883 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008885
8886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8887 "PNO rssi %d offset %d",
8888 pnoRequest.aNetworks[i].rssiThreshold,
8889 nOffset );
8890 /*Advance to next network*/
8891 ptr += nOffset;
8892 }/*For ucNetworkCount*/
8893
8894 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07008895 &(pnoRequest.scanTimers.ucScanTimersCount),
8896 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008897
8898 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07008899 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 {
8901 ptr += nOffset;
8902
Jeff Johnson8301aa12013-03-28 14:27:29 -07008903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8904 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008905 pnoRequest.scanTimers.ucScanTimersCount,
8906 nOffset );
8907
8908 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
8909 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07008910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05308912 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 }
8914
8915 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
8916 {
Jeff Johnson02797792013-10-26 19:17:13 -07008917 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07008918 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
8919 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
8920 &nOffset);
8921
Wilson Yang623f6592013-10-08 16:33:37 -07008922 if (2 != ucParams)
8923 {
8924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8925 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05308926 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008927 }
8928
Jeff Johnson8301aa12013-03-28 14:27:29 -07008929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8930 "PNO Timer value %d Timer repeat %d offset %d",
8931 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
8933 nOffset );
8934
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 ptr += nOffset;
8936 }
8937
8938 }
8939 else
8940 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07008941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8942 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
8944
8945 /*Scan timers defaults to 5 minutes*/
8946 pnoRequest.scanTimers.ucScanTimersCount = 1;
8947 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
8948 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
8949 }
8950
Wilson Yang623f6592013-10-08 16:33:37 -07008951 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008952
8953 pnoRequest.modePNO = ucMode;
8954 /*for LA we just expose suspend option*/
8955 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
8956 {
8957 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
8958 }
8959
c_hpothu37f21312014-04-09 21:49:54 +05308960 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008961 pAdapter->sessionId,
8962 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308963 if (eHAL_STATUS_SUCCESS == status)
8964 {
8965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8966 "%s: PNO enabled", __func__);
8967 return VOS_STATUS_SUCCESS;
8968 }
8969error:
8970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8971 "%s: Failed to enable PNO", __func__);
8972 pHddCtx->isPnoEnable = FALSE;
8973 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008974}/*iw_set_pno*/
8975
8976VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
8977 union iwreq_data *wrqu, char *extra, int nOffset)
8978{
8979 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8980 v_U8_t rssiThreshold = 0;
8981 v_U8_t nRead;
8982
Arif Hussain7adce1b2013-11-11 22:59:34 -08008983 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 &rssiThreshold);
8985
8986 if ( 1 != nRead )
8987 {
8988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8989 "Incorrect format");
8990 return VOS_STATUS_E_FAILURE;
8991 }
8992
8993 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
8994 return VOS_STATUS_SUCCESS;
8995}
8996
8997
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308998static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07008999 struct iw_request_info *info,
9000 union iwreq_data *wrqu, char *extra)
9001{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309002 hdd_adapter_t *pAdapter;
9003 hdd_context_t *pHddCtx;
9004 int ret = 0;
9005
9006 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9007 if (NULL == pAdapter)
9008 {
9009 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9010 "%s: Adapter is NULL",__func__);
9011 return -EINVAL;
9012 }
9013
9014 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9015 ret = wlan_hdd_validate_context(pHddCtx);
9016 if (0 != ret)
9017 {
9018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9019 "%s: HDD context is not valid",__func__);
9020 return ret;
9021 }
9022
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009023
9024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009025 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009026
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009027 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009028}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309029
9030static int iw_set_pno_priv(struct net_device *dev,
9031 struct iw_request_info *info,
9032 union iwreq_data *wrqu, char *extra)
9033{
9034 int ret;
9035
9036 vos_ssr_protect(__func__);
9037 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9038 vos_ssr_unprotect(__func__);
9039
9040 return ret;
9041}
Jeff Johnson295189b2012-06-20 16:38:30 -07009042#endif /*FEATURE_WLAN_SCAN_PNO*/
9043
9044//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309045int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009046{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309047 hdd_adapter_t *pAdapter;
9048 tHalHandle hHal;
9049 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309050 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309051 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07009052 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309053 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309054 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309055 tpAniSirGlobal pMac;
9056 int retval = 0;
9057
9058 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9059 if (NULL == pAdapter)
9060 {
9061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9062 "%s: Adapter is NULL",__func__);
9063 return -EINVAL;
9064 }
9065 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9066 retval = wlan_hdd_validate_context(pHddCtx);
9067 if (0 != retval)
9068 {
9069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9070 "%s: HDD context is not valid",__func__);
9071 return retval;
9072 }
9073 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9074 if (NULL == hHal)
9075 {
9076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9077 "%s: Hal Context is NULL",__func__);
9078 return -EINVAL;
9079 }
9080 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009081
Atul Mittal54378cb2014-04-02 16:51:50 +05309082 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 {
9084 case WLAN_HDD_UI_BAND_AUTO:
9085 band = eCSR_BAND_ALL;
9086 break;
9087 case WLAN_HDD_UI_BAND_5_GHZ:
9088 band = eCSR_BAND_5G;
9089 break;
9090 case WLAN_HDD_UI_BAND_2_4_GHZ:
9091 band = eCSR_BAND_24;
9092 break;
9093 default:
9094 band = eCSR_BAND_MAX;
9095 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309096 connectedBand =
9097 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009098
Atul Mittal54378cb2014-04-02 16:51:50 +05309099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009100 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009101
9102 if (band == eCSR_BAND_MAX)
9103 {
9104 /* Received change band request with invalid band value */
9105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309106 "%s: Invalid band value %u", __func__, ui_band);
9107 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009108 }
9109
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309110 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
9111 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
9112 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
9113 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009115 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009116 band, pHddCtx->cfg_ini->nBandCapability);
9117 return -EIO;
9118 }
9119
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9121 {
9122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9123 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009124 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009125 return -EIO;
9126 }
9127
9128 if (currBand != band)
9129 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309130 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309131 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309132 /* Return failure if current country code is world regulatory domain*/
9133 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9134 pMac->scan.countryCodeCurrent[1] == '0') )
9135 {
9136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9137 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309138 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309139 return -EAGAIN;
9140 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309141 }
9142
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 /* Change band request received.
9144 * Abort pending scan requests, flush the existing scan results,
9145 * and change the band capability
9146 */
9147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9148 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009149 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009150
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309151 /* We need to change the band and flush the scan results here itself
9152 * as we may get timeout for disconnection in which we will return
9153 * with out doing any of these
9154 */
9155 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9156 {
9157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9158 "%s: failed to set the band value to %u ",
9159 __func__, band);
9160 return -EINVAL;
9161 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309162 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9163 {
9164 v_COUNTRYCODE_t curr_country;
9165 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9166 curr_country[1]=pMac->scan.countryCodeCurrent[1];
9167
9168 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9169 * information available in NV so to get the channel information from kernel
9170 * we need to send regulatory hint for the currunt country
9171 * And to set the same country again we need to set the dummy country
9172 * first and then the actual country.
9173 */
9174
9175#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9176 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9177#else
9178 regulatory_hint_user("00");
9179#endif
9180
9181 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
9182#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9183 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9184#else
9185 regulatory_hint_user(curr_country);
9186#endif
9187 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
9188 }
9189 else
9190 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309191#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309192 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9193 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309194#else
9195 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9196#endif
9197
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309198 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309199 pScanInfo = &pHddCtx->scan_info;
9200 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9201 {
9202 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9203 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9204 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309205 sme_FilterScanResults(hHal, pAdapter->sessionId);
9206
9207 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309208 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9209 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009211 eHalStatus status = eHAL_STATUS_SUCCESS;
9212 long lrc;
9213
9214 /* STA already connected on current band, So issue disconnect first,
9215 * then change the band*/
9216
9217 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309218 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309219 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009220
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9222
9223 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9224 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9225
Jeff Johnson43971f52012-07-17 12:26:56 -07009226 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 {
9228 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009229 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 __func__, (int)status );
9231 return -EINVAL;
9232 }
9233
9234 lrc = wait_for_completion_interruptible_timeout(
9235 &pAdapter->disconnect_comp_var,
9236 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9237
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309238 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009239
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009240 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009241 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009242
9243 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9244 }
9245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309247 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009248}
9249
Atul Mittal54378cb2014-04-02 16:51:50 +05309250int hdd_setBand_helper(struct net_device *dev, const char *command)
9251{
9252 u8 band;
9253
9254 /*convert the band value from ascii to integer*/
9255 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9256
9257 return hdd_setBand(dev, band);
9258
9259}
9260
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309261static int __iw_set_band_config(struct net_device *dev,
9262 struct iw_request_info *info,
9263 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009264{
Atul Mittal54378cb2014-04-02 16:51:50 +05309265 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009266
Arif Hussain0273cba2014-01-07 20:58:29 -08009267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009268
Atul Mittal54378cb2014-04-02 16:51:50 +05309269 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009270}
9271
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309272static int iw_set_band_config(struct net_device *dev,
9273 struct iw_request_info *info,
9274 union iwreq_data *wrqu, char *extra)
9275{
9276 int ret;
9277
9278 vos_ssr_protect(__func__);
9279 ret = __iw_set_band_config(dev, info, wrqu, extra);
9280 vos_ssr_unprotect(__func__);
9281
9282 return ret;
9283}
9284
9285static int __iw_set_power_params_priv(struct net_device *dev,
9286 struct iw_request_info *info,
9287 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009288{
Arif Hussain0273cba2014-01-07 20:58:29 -08009289 int ret;
9290 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9292 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009293 /* ODD number is used for set, copy data using copy_from_user */
9294 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9295 wrqu->data.length);
9296 if (NULL == ptr)
9297 {
9298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9299 "mem_alloc_copy_from_user_helper fail");
9300 return -ENOMEM;
9301 }
9302
9303 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9304 kfree(ptr);
9305 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009306}
9307
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309308static int iw_set_power_params_priv(struct net_device *dev,
9309 struct iw_request_info *info,
9310 union iwreq_data *wrqu, char *extra)
9311{
9312 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009313
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309314 vos_ssr_protect(__func__);
9315 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9316 vos_ssr_unprotect(__func__);
9317
9318 return ret;
9319}
Jeff Johnson295189b2012-06-20 16:38:30 -07009320
9321/*string based input*/
9322VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9323 union iwreq_data *wrqu, char *extra, int nOffset)
9324{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309325 hdd_adapter_t *pAdapter;
9326 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 tSirSetPowerParamsReq powerRequest;
9328 char *ptr;
9329 v_U8_t ucType;
9330 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309331 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009332 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9333
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309334 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9335 if (NULL == pAdapter)
9336 {
9337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9338 "%s: Adapter is NULL",__func__);
9339 return -EINVAL;
9340 }
9341
9342 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9343 ret = wlan_hdd_validate_context(pHddCtx);
9344 if (0 != ret)
9345 {
9346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9347 "%s: HDD context is not valid",__func__);
9348 return ret;
9349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9351 "Power Params data len %d data %s",
9352 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009353 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009354
9355 if (wrqu->data.length <= nOffset )
9356 {
9357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9358 return VOS_STATUS_E_FAILURE;
9359 }
9360
9361 uTotalSize = wrqu->data.length - nOffset;
9362
9363 /*-----------------------------------------------------------------------
9364 Input is string based and expected to be like this:
9365
9366 <param_type> <param_value> <param_type> <param_value> ...
9367
9368 e.g:
9369 1 2 2 3 3 0 4 1 5 1
9370
9371 e.g. setting just a few:
9372 1 2 4 1
9373
9374 parameter types:
9375 -----------------------------
9376 1 - Ignore DTIM
9377 2 - Listen Interval
9378 3 - Broadcast Multicas Filter
9379 4 - Beacon Early Termination
9380 5 - Beacon Early Termination Interval
9381 -----------------------------------------------------------------------*/
9382 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9383 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9384 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9385 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9386 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9387
Arif Hussain7adce1b2013-11-11 22:59:34 -08009388 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009389
9390 while ( uTotalSize )
9391 {
Wilson Yang6f971452013-10-08 15:00:00 -07009392 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9393 {
9394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9395 "Invalid input parameter type %s",ptr);
9396 return VOS_STATUS_E_FAILURE;
9397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009398
9399 uTotalSize -= nOffset;
9400
9401 if (!uTotalSize)
9402 {
9403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009404 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 ucType, nOffset);
9406 return VOS_STATUS_E_FAILURE;
9407 }
9408
9409 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009410
Jeff Johnson02797792013-10-26 19:17:13 -07009411 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009412 {
9413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9414 "Invalid input parameter value %s",ptr);
9415 return VOS_STATUS_E_FAILURE;
9416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009417
9418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9419 "Power request parameter %d value %d offset %d",
9420 ucType, uValue, nOffset);
9421
9422 switch (ucType)
9423 {
9424 case eSIR_IGNORE_DTIM:
9425 powerRequest.uIgnoreDTIM = uValue;
9426 break;
9427 case eSIR_LISTEN_INTERVAL:
9428 powerRequest.uListenInterval = uValue;
9429 break;
9430 case eSIR_MCAST_BCAST_FILTER:
9431 powerRequest.uBcastMcastFilter = uValue;
9432 break;
9433 case eSIR_ENABLE_BET:
9434 powerRequest.uEnableBET = uValue;
9435 break;
9436 case eSIR_BET_INTERVAL:
9437 powerRequest.uBETInterval = uValue;
9438 break;
9439 default:
9440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009441 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009442 ucType, uValue, nOffset);
9443 return VOS_STATUS_E_FAILURE;
9444 }
9445
9446 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9448 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009449 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009450 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009451 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009452 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009453 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9454 {
9455 uTotalSize = 0;
9456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009457
9458 }/*Go for as long as we have a valid string*/
9459
9460 /* put the device into full power*/
9461 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9462
9463 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009464 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009465
9466 /* put the device back to power save*/
9467 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9468
9469 return VOS_STATUS_SUCCESS;
9470}/*iw_set_power_params*/
9471
Atul Mittalc0f739f2014-07-31 13:47:47 +05309472// tdlsoffchan
9473#ifdef FEATURE_WLAN_TDLS
9474
Atul Mittal87ec2422014-09-24 13:12:50 +05309475int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309476{
9477 if (offchannel < 0 || offchannel > 165)
9478 {
9479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9480 __func__, offchannel);
9481 return -1;
9482
9483 }
9484
9485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9486 __func__, tdlsOffCh, offchannel);
9487
9488 tdlsOffCh = offchannel;
9489 return 0;
9490}
9491
Atul Mittal87ec2422014-09-24 13:12:50 +05309492int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309493{
9494 if (offchanoffset == 0)
9495 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309496 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9498 __func__, tdlsOffChBwOffset);
9499
9500 return 0;
9501
9502 }
9503
9504 if ( offchanoffset == 40 )
9505 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309506 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9508 __func__, tdlsOffChBwOffset);
9509
9510 return 0;
9511
9512 }
9513 if (offchanoffset == -40)
9514 {
9515 tdlsOffChBwOffset = 3;
9516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9517 __func__, tdlsOffChBwOffset);
9518
9519 return 0;
9520
9521 }
9522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9523 __func__, offchanoffset);
9524 return -1;
9525}
9526
Atul Mittal87ec2422014-09-24 13:12:50 +05309527int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309528{
9529 hddTdlsPeer_t *connPeer = NULL;
9530 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9531 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9532
9533 if (offchanmode < 0 || offchanmode > 4)
9534 {
9535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9536 "%s: Invalid tdls off channel mode %d",
9537 __func__, offchanmode);
9538 return -1;
9539 }
9540
9541 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9542 {
9543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9544 "%s: tdls off channel mode req in not associated state %d",
9545 __func__, offchanmode);
9546 return -1;
9547 }
9548
9549 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9550 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9551 {
9552 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309553 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309554 if (NULL == connPeer) {
9555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9556 "%s: No TDLS Connected Peer", __func__);
9557 return -1;
9558 }
9559 }
9560 else
9561 {
9562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9563 "%s: TDLS Connection not supported", __func__);
9564 return -1;
9565 }
9566
9567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9568 ("%s: TDLS Channel Switch in swmode=%d"),
9569 __func__, offchanmode);
9570
9571 switch (offchanmode)
9572 {
9573 case 1:/*Enable*/
9574 case 2:/*Disable*/
9575 {
9576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9577 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9578 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9579 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9580 {
9581
9582 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9583 pAdapter->sessionId, connPeer->peerMac,
9584 tdlsOffCh, tdlsOffChBwOffset,
9585 offchanmode);
9586 }
9587 else
9588 {
9589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9590 "%s: TDLS Off Channel not supported", __func__);
9591 return -1;
9592 }
9593 break;
9594 }
9595 case 3:
9596 {
9597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9598 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
9599 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9600
9601 break;
9602 }
9603 case 4:
9604 {
9605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9606 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
9607 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9608 break;
9609 }
9610 default:
9611 {
9612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9613 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
9614 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9615 break;
9616 }
9617
9618 }
9619
9620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
9621 __func__, offchanmode);
9622 return 0;
9623}
Atul Mittalc0f739f2014-07-31 13:47:47 +05309624#endif
9625
Jeff Johnson295189b2012-06-20 16:38:30 -07009626
9627// Define the Wireless Extensions to the Linux Network Device structure
9628// A number of these routines are NULL (meaning they are not implemented.)
9629
9630static const iw_handler we_handler[] =
9631{
9632 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9633 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9634 (iw_handler) NULL, /* SIOCSIWNWID */
9635 (iw_handler) NULL, /* SIOCGIWNWID */
9636 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9637 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9638 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9639 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9640 (iw_handler) NULL, /* SIOCSIWSENS */
9641 (iw_handler) NULL, /* SIOCGIWSENS */
9642 (iw_handler) NULL, /* SIOCSIWRANGE */
9643 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9644 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
9645 (iw_handler) NULL, /* SIOCGIWPRIV */
9646 (iw_handler) NULL, /* SIOCSIWSTATS */
9647 (iw_handler) NULL, /* SIOCGIWSTATS */
9648 iw_handler_set_spy, /* SIOCSIWSPY */
9649 iw_handler_get_spy, /* SIOCGIWSPY */
9650 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
9651 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
9652 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9653 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9654 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9655 (iw_handler) NULL, /* SIOCGIWAPLIST */
9656 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9657 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9658 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9659 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9660 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9661 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9662 (iw_handler) NULL, /* -- hole -- */
9663 (iw_handler) NULL, /* -- hole -- */
9664 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9665 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9666 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
9667 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
9668 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9669 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9670 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9671 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9672 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9673 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9674 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9675 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9676 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9677 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9678 (iw_handler) NULL, /* -- hole -- */
9679 (iw_handler) NULL, /* -- hole -- */
9680 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9681 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9682 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9683 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9684 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9685 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9686 (iw_handler) NULL, /* SIOCSIWPMKSA */
9687};
9688
9689static const iw_handler we_private[] = {
9690
9691 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
9692 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
9693 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
9694 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
9695 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9696 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +05309697 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07009698 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9699 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9700 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07009701#ifdef FEATURE_OEM_DATA_SUPPORT
9702 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
9703 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
9704#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009705
Jeff Johnson295189b2012-06-20 16:38:30 -07009706#ifdef WLAN_FEATURE_VOWIFI_11R
9707 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
9708#endif
9709 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9710 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9711 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
9712#ifdef WLAN_FEATURE_PACKET_FILTERING
9713 ,
9714 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
9715#endif
9716#ifdef FEATURE_WLAN_SCAN_PNO
9717 ,
9718 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
9719#endif
9720 ,
9721 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9722 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
9723 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
9724 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07009725 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07009726};
9727
9728/*Maximum command length can be only 15 */
9729static const struct iw_priv_args we_private_args[] = {
9730
9731 /* handlers for main ioctl */
9732 { WLAN_PRIV_SET_INT_GET_NONE,
9733 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9734 0,
9735 "" },
9736
9737 /* handlers for sub-ioctl */
9738 { WE_SET_11D_STATE,
9739 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9740 0,
9741 "set11Dstate" },
9742
9743 { WE_WOWL,
9744 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9745 0,
9746 "wowl" },
9747
9748 { WE_SET_POWER,
9749 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9750 0,
9751 "setPower" },
9752
9753 { WE_SET_MAX_ASSOC,
9754 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9755 0,
9756 "setMaxAssoc" },
9757
9758 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
9759 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9760 0,
9761 "setAutoChannel" },
9762
9763 { WE_SET_DATA_INACTIVITY_TO,
9764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9765 0,
9766 "inactivityTO" },
9767
9768 { WE_SET_MAX_TX_POWER,
9769 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9770 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07009771 "setMaxTxPower" },
9772
9773 { WE_SET_MAX_TX_POWER_2_4,
9774 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9775 0,
9776 "setTxMaxPower2G" },
9777
9778 { WE_SET_MAX_TX_POWER_5_0,
9779 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9780 0,
9781 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07009782
9783 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
9784 * as well to keep same syntax as in SAP. Now onwards, STA
9785 * will support both */
9786 { WE_SET_MAX_TX_POWER,
9787 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9788 0,
9789 "setTxMaxPower" },
9790
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 /* set Higher DTIM Transition (DTIM1 to DTIM3)
9792 * 1 = enable and 0 = disable */
9793 {
9794 WE_SET_HIGHER_DTIM_TRANSITION,
9795 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9796 0,
9797 "setHDtimTransn" },
9798
9799 { WE_SET_TM_LEVEL,
9800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009801 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07009802 "setTmLevel" },
9803
Kiet Lam46b8e4e2013-11-06 21:49:53 +05309804 { WE_ENABLE_STRICT_FCC_REG,
9805 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9806 0,
9807 "setStrictFCCreg" },
9808
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08009809 { WE_SET_DEBUG_LOG,
9810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9811 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +05309812#ifdef FEATURE_WLAN_TDLS
9813 {
9814 WE_SET_TDLS_OFF_CHAN,
9815 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9816 0,
9817 "tdlsoffchan" },
9818 {
9819 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
9820 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9821 0,
9822 "tdlsecchnoffst" },
9823 {
9824 WE_SET_TDLS_OFF_CHAN_MODE,
9825 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9826 0,
9827 "tdlsoffchnmode" },
9828#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08009829
Peng Xu2446a892014-09-05 17:21:18 +05309830 { WE_SET_SCAN_BAND_PREFERENCE,
9831 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9832 0, "set_scan_pref" },
9833
Jeff Johnson295189b2012-06-20 16:38:30 -07009834 /* handlers for main ioctl */
9835 { WLAN_PRIV_SET_NONE_GET_INT,
9836 0,
9837 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9838 "" },
9839
9840 /* handlers for sub-ioctl */
9841 { WE_GET_11D_STATE,
9842 0,
9843 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9844 "get11Dstate" },
9845
9846 { WE_IBSS_STATUS,
9847 0,
9848 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9849 "getAdhocStatus" },
9850
9851 { WE_PMC_STATE,
9852 0,
9853 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9854 "pmcState" },
9855
9856 { WE_GET_WLAN_DBG,
9857 0,
9858 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9859 "getwlandbg" },
9860
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 { WE_GET_MAX_ASSOC,
9862 0,
9863 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9864 "getMaxAssoc" },
9865
Jeff Johnson295189b2012-06-20 16:38:30 -07009866 { WE_GET_WDI_DBG,
9867 0,
9868 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9869 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009870
9871 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
9872 0,
9873 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9874 "getAutoChannel" },
9875
9876 { WE_GET_CONCURRENCY_MODE,
9877 0,
9878 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9879 "getconcurrency" },
9880
Peng Xu2446a892014-09-05 17:21:18 +05309881 { WE_GET_SCAN_BAND_PREFERENCE,
9882 0,
9883 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9884 "get_scan_pref"},
9885
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 /* handlers for main ioctl */
9887 { WLAN_PRIV_SET_CHAR_GET_NONE,
9888 IW_PRIV_TYPE_CHAR| 512,
9889 0,
9890 "" },
9891
9892 /* handlers for sub-ioctl */
9893 { WE_WOWL_ADD_PTRN,
9894 IW_PRIV_TYPE_CHAR| 512,
9895 0,
9896 "wowlAddPtrn" },
9897
9898 { WE_WOWL_DEL_PTRN,
9899 IW_PRIV_TYPE_CHAR| 512,
9900 0,
9901 "wowlDelPtrn" },
9902
9903#if defined WLAN_FEATURE_VOWIFI
9904 /* handlers for sub-ioctl */
9905 { WE_NEIGHBOR_REPORT_REQUEST,
9906 IW_PRIV_TYPE_CHAR | 512,
9907 0,
9908 "neighbor" },
9909#endif
9910 { WE_SET_AP_WPS_IE,
9911 IW_PRIV_TYPE_CHAR| 512,
9912 0,
9913 "set_ap_wps_ie" },
9914
9915 { WE_SET_CONFIG,
9916 IW_PRIV_TYPE_CHAR| 512,
9917 0,
9918 "setConfig" },
9919
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05309920 { WE_SET_ENCRYPT_MSG,
9921 IW_PRIV_TYPE_CHAR| 512,
9922 0,
9923 "encryptMsg" },
9924
9925
Jeff Johnson295189b2012-06-20 16:38:30 -07009926 /* handlers for main ioctl */
9927 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
9928 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9929 0,
9930 "" },
9931
9932 /* handlers for sub-ioctl */
9933 { WE_SET_WLAN_DBG,
9934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9935 0,
9936 "setwlandbg" },
9937
Jeff Johnson295189b2012-06-20 16:38:30 -07009938 { WE_SET_WDI_DBG,
9939 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9940 0,
9941 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009942
9943 { WE_SET_SAP_CHANNELS,
9944 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9945 0,
9946 "setsapchannels" },
9947
9948 /* handlers for main ioctl */
9949 { WLAN_PRIV_GET_CHAR_SET_NONE,
9950 0,
9951 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9952 "" },
9953
9954 /* handlers for sub-ioctl */
9955 { WE_WLAN_VERSION,
9956 0,
9957 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9958 "version" },
9959 { WE_GET_STATS,
9960 0,
9961 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9962 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309963 { WE_GET_STATES,
9964 0,
9965 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9966 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 { WE_GET_CFG,
9968 0,
9969 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9970 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07009971#ifdef WLAN_FEATURE_11AC
9972 { WE_GET_RSSI,
9973 0,
9974 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9975 "getRSSI" },
9976#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009977#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009978 { WE_GET_ROAM_RSSI,
9979 0,
9980 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9981 "getRoamRSSI" },
9982#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 { WE_GET_WMM_STATUS,
9984 0,
9985 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9986 "getWmmStatus" },
9987 {
9988 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309989 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07009990 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9991 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08009992#ifdef FEATURE_WLAN_TDLS
9993 {
9994 WE_GET_TDLS_PEERS,
9995 0,
9996 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9997 "getTdlsPeers" },
9998#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009999#ifdef WLAN_FEATURE_11W
10000 {
10001 WE_GET_11W_INFO,
10002 0,
10003 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10004 "getPMFInfo" },
10005#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010006 { WE_GET_SNR,
10007 0,
10008 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10009 "getSNR" },
10010
Jeff Johnson295189b2012-06-20 16:38:30 -070010011 /* handlers for main ioctl */
10012 { WLAN_PRIV_SET_NONE_GET_NONE,
10013 0,
10014 0,
10015 "" },
10016
10017 /* handlers for sub-ioctl */
10018 { WE_CLEAR_STATS,
10019 0,
10020 0,
10021 "clearStats" },
10022 { WE_INIT_AP,
10023 0,
10024 0,
10025 "initAP" },
10026 { WE_STOP_AP,
10027 0,
10028 0,
10029 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010030#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 { WE_ENABLE_AMP,
10032 0,
10033 0,
10034 "enableAMP" },
10035 { WE_DISABLE_AMP,
10036 0,
10037 0,
10038 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010039#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010040 { WE_ENABLE_DXE_STALL_DETECT,
10041 0,
10042 0,
10043 "dxeStallDetect" },
10044 { WE_DISPLAY_DXE_SNAP_SHOT,
10045 0,
10046 0,
10047 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010048 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10049 0,
10050 0,
10051 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010052 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010053 WE_SET_REASSOC_TRIGGER,
10054 0,
10055 0,
10056 "reassoc" },
10057 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010058 WE_STOP_OBSS_SCAN,
10059 0,
10060 0,
10061 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010062#ifdef DEBUG_ROAM_DELAY
10063 {
10064 WE_DUMP_ROAM_TIMER_LOG,
10065 0,
10066 0,
10067 "dumpRoamDelay" },
10068 {
10069 WE_RESET_ROAM_TIMER_LOG,
10070 0,
10071 0,
10072 "resetRoamDelay" },
10073#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010074 /* handlers for main ioctl */
10075 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10076 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10077 0,
10078 "" },
10079
10080 /* handlers for sub-ioctl */
10081 { WE_LOG_DUMP_CMD,
10082 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10083 0,
10084 "dump" },
10085
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010086 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010087 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10088 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10089 0,
10090 "setdumplog" },
10091
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010092 { WE_MTRACE_DUMP_CMD,
10093 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10094 0,
10095 "dumplog" },
10096
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010097 /* handlers for sub ioctl */
10098 {
10099 WE_MCC_CONFIG_CREDENTIAL,
10100 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10101 0,
10102 "setMccCrdnl" },
10103
10104 /* handlers for sub ioctl */
10105 {
10106 WE_MCC_CONFIG_PARAMS,
10107 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10108 0,
10109 "setMccConfig" },
10110
Chilam NG571c65a2013-01-19 12:27:36 +053010111#ifdef FEATURE_WLAN_TDLS
10112 /* handlers for sub ioctl */
10113 {
10114 WE_TDLS_CONFIG_PARAMS,
10115 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10116 0,
10117 "setTdlsConfig" },
10118#endif
10119
Jeff Johnson295189b2012-06-20 16:38:30 -070010120 /* handlers for main ioctl */
10121 { WLAN_PRIV_ADD_TSPEC,
10122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10123 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10124 "addTspec" },
10125
10126 /* handlers for main ioctl */
10127 { WLAN_PRIV_DEL_TSPEC,
10128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10130 "delTspec" },
10131
10132 /* handlers for main ioctl */
10133 { WLAN_PRIV_GET_TSPEC,
10134 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10135 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10136 "getTspec" },
10137
Jeff Johnsone7245742012-09-05 17:12:55 -070010138#ifdef FEATURE_OEM_DATA_SUPPORT
10139 /* handlers for main ioctl - OEM DATA */
10140 {
10141 WLAN_PRIV_SET_OEM_DATA_REQ,
10142 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10143 0,
10144 "set_oem_data_req" },
10145
10146 /* handlers for main ioctl - OEM DATA */
10147 {
10148 WLAN_PRIV_GET_OEM_DATA_RSP,
10149 0,
10150 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10151 "get_oem_data_rsp" },
10152#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010153
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 /* handlers for main ioctl - host offload */
10155 {
10156 WLAN_PRIV_SET_HOST_OFFLOAD,
10157 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10158 0,
10159 "setHostOffload" },
10160
10161 {
10162 WLAN_GET_WLAN_STATISTICS,
10163 0,
10164 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10165 "getWlanStats" },
10166
10167 {
10168 WLAN_SET_KEEPALIVE_PARAMS,
10169 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10170 0,
10171 "setKeepAlive" },
10172#ifdef WLAN_FEATURE_PACKET_FILTERING
10173 {
10174 WLAN_SET_PACKET_FILTER_PARAMS,
10175 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10176 0,
10177 "setPktFilter" },
10178#endif
10179#ifdef FEATURE_WLAN_SCAN_PNO
10180 {
10181 WLAN_SET_PNO,
10182 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10183 0,
10184 "setpno" },
10185#endif
10186 {
10187 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010189 0,
10190 "SETBAND" },
10191 /* handlers for dynamic MC BC ioctl */
10192 {
10193 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010194 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010195 0,
10196 "setMCBCFilter" },
10197 {
10198 WLAN_PRIV_CLEAR_MCBC_FILTER,
10199 0,
10200 0,
10201 "clearMCBCFilter" },
10202 {
10203 WLAN_SET_POWER_PARAMS,
10204 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10205 0,
10206 "setpowerparams" },
10207 {
10208 WLAN_GET_LINK_SPEED,
10209 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010210 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010211};
10212
10213
10214
10215const struct iw_handler_def we_handler_def = {
10216 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10217 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10218 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10219
10220 .standard = (iw_handler *)we_handler,
10221 .private = (iw_handler *)we_private,
10222 .private_args = we_private_args,
10223 .get_wireless_stats = get_wireless_stats,
10224};
10225
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010226int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10227{
10228 v_U32_t cmd = 288; //Command to RIVA
10229 hdd_context_t *pHddCtx = NULL;
10230 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10231 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10232 /*
10233 *configMccParam : specify the bit which needs to be modified
10234 *allowed to update based on wlan_qcom_cfg.ini
10235 * configuration
10236 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10237 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10238 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10239 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10240 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10241 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10242 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10243 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10244 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10245 * Bit 9 : Reserved
10246 */
10247 switch (arg1)
10248 {
10249 //Update MCC SCHEDULE_TIME_SLICE parameter
10250 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10251 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10252 {
10253 if((arg2 >= 5) && (arg2 <= 20))
10254 {
10255 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10256 }
10257 else
10258 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010259 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010260 return 0;
10261 }
10262 }
10263 break;
10264
10265 //Update MCC MAX_NULL_SEND_TIME parameter
10266 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10267 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10268 {
10269 if((arg2 >= 1) && (arg2 <= 10))
10270 {
10271 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10272 }
10273 else
10274 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010275 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010276 return 0;
10277 }
10278 }
10279 break;
10280
10281 //Update MCC TX_EARLY_STOP_TIME parameter
10282 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10283 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10284 {
10285 if((arg2 >= 1) && (arg2 <= 10))
10286 {
10287 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10288 }
10289 else
10290 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010291 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010292 return 0;
10293 }
10294 }
10295 break;
10296
10297 //Update MCC RX_DRAIN_TIME parameter
10298 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10299 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10300 {
10301 if((arg2 >= 1) && (arg2 <= 10))
10302 {
10303 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10304 }
10305 else
10306 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010307 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010308 return 0;
10309 }
10310 }
10311 break;
10312
10313 //Update MCC CHANNEL_SWITCH_TIME parameter
10314 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10315 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10316 {
10317 if((arg2 >= 1) && (arg2 <= 20))
10318 {
10319 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10320 }
10321 else
10322 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010323 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010324 return 0;
10325 }
10326 }
10327 break;
10328
10329 //Update MCC MIN_CHANNEL_TIME parameter
10330 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10331 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10332 {
10333 if((arg2 >= 5) && (arg2 <= 20))
10334 {
10335 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10336 }
10337 else
10338 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010339 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010340 return 0;
10341 }
10342 }
10343 break;
10344
10345 //Update MCC PARK_BEFORE_TBTT parameter
10346 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10347 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10348 {
10349 if((arg2 >= 1) && (arg2 <= 5))
10350 {
10351 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10352 }
10353 else
10354 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010355 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010356 return 0;
10357 }
10358 }
10359 break;
10360
10361 //Update MCC MIN_AFTER_DTIM parameter
10362 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10363 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10364 {
10365 if((arg2 >= 5) && (arg2 <= 15))
10366 {
10367 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10368 }
10369 else
10370 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010371 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010372 return 0;
10373 }
10374 }
10375 break;
10376
10377 //Update MCC TOO_CLOSE_MARGIN parameter
10378 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10379 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10380 {
10381 if((arg2 >= 1) && (arg2 <= 3))
10382 {
10383 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10384 }
10385 else
10386 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010387 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010388 return 0;
10389 }
10390 }
10391 break;
10392
10393 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010394 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010395 __FUNCTION__,arg1);
10396 break;
10397 }
10398 return 0;
10399}
10400
Jeff Johnson295189b2012-06-20 16:38:30 -070010401int hdd_set_wext(hdd_adapter_t *pAdapter)
10402{
10403 hdd_wext_state_t *pwextBuf;
10404 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010405 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010406
10407 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10408
10409 // Now configure the roaming profile links. To SSID and bssid.
10410 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10411 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10412
10413 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10414 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10415
10416 /*Set the numOfChannels to zero to scan all the channels*/
10417 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10418 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10419
10420 /* Default is no encryption */
10421 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10422 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10423
10424 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10425 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10426
10427 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10428
10429 /* Default is no authentication */
10430 pwextBuf->roamProfile.AuthType.numEntries = 1;
10431 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10432
10433 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10434 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10435
10436 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010437 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010438
10439 hdd_clearRoamProfileIe(pAdapter);
10440
10441 return VOS_STATUS_SUCCESS;
10442
10443 }
10444
10445int hdd_register_wext(struct net_device *dev)
10446 {
10447 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10448 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10449 VOS_STATUS status;
10450
10451 ENTER();
10452
10453 // Zero the memory. This zeros the profile structure.
10454 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10455
10456 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10457
10458
10459 status = hdd_set_wext(pAdapter);
10460
10461 if(!VOS_IS_STATUS_SUCCESS(status)) {
10462
Arif Hussain6d2a3322013-11-17 19:50:10 -080010463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010464 return eHAL_STATUS_FAILURE;
10465 }
10466
10467 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10468 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010470 return eHAL_STATUS_FAILURE;
10471 }
10472
10473 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10474 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010476 return eHAL_STATUS_FAILURE;
10477 }
10478
10479 // Register as a wireless device
10480 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10481
10482 EXIT();
10483 return 0;
10484}
10485
10486int hdd_UnregisterWext(struct net_device *dev)
10487{
c_hpothu2a13bc32015-01-21 12:48:54 +053010488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10489 if (dev != NULL)
10490 {
10491 rtnl_lock();
10492 dev->wireless_handlers = NULL;
10493 rtnl_unlock();
10494 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010495
Jeff Johnson295189b2012-06-20 16:38:30 -070010496 return 0;
10497}
10498
10499