blob: db186c1918c4f7fa3b16d1ff0f538a4731dd4d6f [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{
544 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
545 v_U32_t threshold = 0,status = 0;
546
547 ENTER();
548
Agarwal Ashish971c2882013-10-30 20:11:12 +0530549 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
550 {
551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 "%s:LOGP in Progress. Ignore!!!",__func__);
553 return status;
554 }
555
556 if ( eHAL_STATUS_SUCCESS !=
557 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
558 {
c_hpothub8245442013-11-20 23:41:09 +0530559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
560 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 return -EIO;
562 }
563 wrqu->rts.value = threshold;
564
565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800566 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700567
568 EXIT();
569
570 return 0;
571}
572
573int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
574{
575 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
576 v_U32_t threshold = 0,status = 0;
577
578 ENTER();
579
Agarwal Ashish971c2882013-10-30 20:11:12 +0530580 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
581 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
583 "%s:LOGP in Progress. Ignore!!!",__func__);
584 return status;
585 }
586
587 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
588 != eHAL_STATUS_SUCCESS )
589 {
c_hpothub8245442013-11-20 23:41:09 +0530590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
591 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 return -EIO;
593 }
594 wrqu->frag.value = threshold;
595
596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800597 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700598
599 EXIT();
600
601 return 0;
602}
603
604int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
605{
Jeff Johnsone7245742012-09-05 17:12:55 -0700606 int i;
607 if (channel > 0)
608 {
609 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
610 {
611 if (channel == freq_chan_map[i].chan)
612 {
613 *pfreq = freq_chan_map[i].freq;
614 return 1;
615 }
616 }
617 }
618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800619 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700620 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700621}
622
623static v_BOOL_t
624hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
625{
626 v_BOOL_t rsnType = VOS_FALSE;
627 // is the authType supported?
628 switch (authType)
629 {
630 case eCSR_AUTH_TYPE_NONE: //never used
631 rsnType = eANI_BOOLEAN_FALSE;
632 break;
633 // MAC layer authentication types
634 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
635 rsnType = eANI_BOOLEAN_FALSE;
636 break;
637 case eCSR_AUTH_TYPE_SHARED_KEY:
638 rsnType = eANI_BOOLEAN_FALSE;
639 break;
640 case eCSR_AUTH_TYPE_AUTOSWITCH:
641 rsnType = eANI_BOOLEAN_FALSE;
642 break;
643
644 // Upper layer authentication types
645 case eCSR_AUTH_TYPE_WPA:
646 rsnType = eANI_BOOLEAN_TRUE;
647 break;
648 case eCSR_AUTH_TYPE_WPA_PSK:
649 rsnType = eANI_BOOLEAN_TRUE;
650 break;
651 case eCSR_AUTH_TYPE_WPA_NONE:
652 rsnType = eANI_BOOLEAN_TRUE;
653 break;
654#ifdef WLAN_FEATURE_VOWIFI_11R
655 case eCSR_AUTH_TYPE_FT_RSN:
656#endif
657 case eCSR_AUTH_TYPE_RSN:
658 rsnType = eANI_BOOLEAN_TRUE;
659 break;
660#ifdef WLAN_FEATURE_VOWIFI_11R
661 case eCSR_AUTH_TYPE_FT_RSN_PSK:
662#endif
663 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700664#ifdef WLAN_FEATURE_11W
665 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530666 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700667#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 rsnType = eANI_BOOLEAN_TRUE;
669 break;
670 //case eCSR_AUTH_TYPE_FAILED:
671 case eCSR_AUTH_TYPE_UNKNOWN:
672 rsnType = eANI_BOOLEAN_FALSE;
673 break;
674 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800675 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
676 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 rsnType = eANI_BOOLEAN_FALSE;
678 break;
679 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800680 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700681 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 return rsnType;
683}
684
685static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
686{
687 struct statsContext *pStatsContext;
688 hdd_adapter_t *pAdapter;
689
690 if (ioctl_debug)
691 {
692 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700693 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 }
695
696 if (NULL == pContext)
697 {
698 hddLog(VOS_TRACE_LEVEL_ERROR,
699 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700700 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 return;
702 }
703
Jeff Johnson295189b2012-06-20 16:38:30 -0700704 pStatsContext = pContext;
705 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800706
707 /* there is a race condition that exists between this callback
708 function and the caller since the caller could time out either
709 before or while this code is executing. we use a spinlock to
710 serialize these actions */
711 spin_lock(&hdd_context_lock);
712
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
714 {
715 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800716 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 hddLog(VOS_TRACE_LEVEL_WARN,
718 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700719 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 if (ioctl_debug)
721 {
722 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700723 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 }
725 return;
726 }
727
Jeff Johnson72a40512013-12-19 10:14:15 -0800728 /* context is valid so caller is still waiting */
729
730 /* paranoia: invalidate the magic */
731 pStatsContext->magic = 0;
732
733 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 pAdapter->rssi = rssi;
735
Jeff Johnson72a40512013-12-19 10:14:15 -0800736 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800738
739 /* serialization is complete */
740 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700741}
742
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530743static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
744{
745 struct statsContext *pStatsContext;
746 hdd_adapter_t *pAdapter;
747
748 if (ioctl_debug)
749 {
750 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
751 __func__, (int)snr, (int)staId, pContext);
752 }
753
754 if (NULL == pContext)
755 {
756 hddLog(VOS_TRACE_LEVEL_ERROR,
757 "%s: Bad param, pContext [%p]",
758 __func__, pContext);
759 return;
760 }
761
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530762 pStatsContext = pContext;
763 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800764
765 /* there is a race condition that exists between this callback
766 function and the caller since the caller could time out either
767 before or while this code is executing. we use a spinlock to
768 serialize these actions */
769 spin_lock(&hdd_context_lock);
770
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530771 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
772 {
773 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800774 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530775 hddLog(VOS_TRACE_LEVEL_WARN,
776 "%s: Invalid context, pAdapter [%p] magic [%08x]",
777 __func__, pAdapter, pStatsContext->magic);
778 if (ioctl_debug)
779 {
780 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
781 __func__, pAdapter, pStatsContext->magic);
782 }
783 return;
784 }
785
Jeff Johnson72a40512013-12-19 10:14:15 -0800786 /* context is valid so caller is still waiting */
787
788 /* paranoia: invalidate the magic */
789 pStatsContext->magic = 0;
790
791 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530792 pAdapter->snr = snr;
793
Jeff Johnson72a40512013-12-19 10:14:15 -0800794 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530795 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800796
797 /* serialization is complete */
798 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530799}
800
Jeff Johnson295189b2012-06-20 16:38:30 -0700801VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
802{
803 struct statsContext context;
804 hdd_context_t *pHddCtx;
805 hdd_station_ctx_t *pHddStaCtx;
806 eHalStatus hstatus;
807 long lrc;
808
809 if (NULL == pAdapter)
810 {
811 hddLog(VOS_TRACE_LEVEL_WARN,
812 "%s: Invalid context, pAdapter", __func__);
813 return VOS_STATUS_E_FAULT;
814 }
815 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
816 {
817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
818 /* return a cached value */
819 *rssi_value = pAdapter->rssi;
820 return VOS_STATUS_SUCCESS;
821 }
822
823 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
824 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
825
826 init_completion(&context.completion);
827 context.pAdapter = pAdapter;
828 context.magic = RSSI_CONTEXT_MAGIC;
829
830 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
831 pHddStaCtx->conn_info.staId[ 0 ],
832 pHddStaCtx->conn_info.bssId,
833 &context, pHddCtx->pvosContext);
834 if (eHAL_STATUS_SUCCESS != hstatus)
835 {
836 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700837 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 /* we'll returned a cached value below */
839 }
840 else
841 {
842 /* request was sent -- wait for the response */
843 lrc = wait_for_completion_interruptible_timeout(&context.completion,
844 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 if (lrc <= 0)
846 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800847 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700848 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 /* we'll now returned a cached value below */
850 }
851 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800852
853 /* either we never sent a request, we sent a request and received a
854 response or we sent a request and timed out. if we never sent a
855 request or if we sent a request and got a response, we want to
856 clear the magic out of paranoia. if we timed out there is a
857 race condition such that the callback function could be
858 executing at the same time we are. of primary concern is if the
859 callback function had already verified the "magic" but had not
860 yet set the completion variable when a timeout occurred. we
861 serialize these activities by invalidating the magic while
862 holding a shared spinlock which will cause us to block if the
863 callback is currently executing */
864 spin_lock(&hdd_context_lock);
865 context.magic = 0;
866 spin_unlock(&hdd_context_lock);
867
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 *rssi_value = pAdapter->rssi;
869
870 return VOS_STATUS_SUCCESS;
871}
872
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530873VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
874{
875 struct statsContext context;
876 hdd_context_t *pHddCtx;
877 hdd_station_ctx_t *pHddStaCtx;
878 eHalStatus hstatus;
879 long lrc;
880 int valid;
881
882 if (NULL == pAdapter)
883 {
884 hddLog(VOS_TRACE_LEVEL_ERROR,
885 "%s: Invalid context, pAdapter", __func__);
886 return VOS_STATUS_E_FAULT;
887 }
888
889 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
890
891 valid = wlan_hdd_validate_context(pHddCtx);
892 if (0 != valid)
893 {
894 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
895 return VOS_STATUS_E_FAULT;
896 }
897
898 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
899 if (NULL == pHddStaCtx)
900 {
901 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
902 return VOS_STATUS_E_FAULT;
903 }
904
905 init_completion(&context.completion);
906 context.pAdapter = pAdapter;
907 context.magic = SNR_CONTEXT_MAGIC;
908
909 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
910 pHddStaCtx->conn_info.staId[ 0 ],
911 pHddStaCtx->conn_info.bssId,
912 &context);
913 if (eHAL_STATUS_SUCCESS != hstatus)
914 {
915 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
916 __func__);
917 /* we'll returned a cached value below */
918 }
919 else
920 {
921 /* request was sent -- wait for the response */
922 lrc = wait_for_completion_interruptible_timeout(&context.completion,
923 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530924 if (lrc <= 0)
925 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800926 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530927 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530928 /* we'll now returned a cached value below */
929 }
930 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800931
932 /* either we never sent a request, we sent a request and received a
933 response or we sent a request and timed out. if we never sent a
934 request or if we sent a request and got a response, we want to
935 clear the magic out of paranoia. if we timed out there is a
936 race condition such that the callback function could be
937 executing at the same time we are. of primary concern is if the
938 callback function had already verified the "magic" but had not
939 yet set the completion variable when a timeout occurred. we
940 serialize these activities by invalidating the magic while
941 holding a shared spinlock which will cause us to block if the
942 callback is currently executing */
943 spin_lock(&hdd_context_lock);
944 context.magic = 0;
945 spin_unlock(&hdd_context_lock);
946
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530947 *snr = pAdapter->snr;
948
949 return VOS_STATUS_SUCCESS;
950}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800951#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800952
953static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
954{
955 struct statsContext *pStatsContext;
956 hdd_adapter_t *pAdapter;
957 if (ioctl_debug)
958 {
959 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
960 __func__, (int)rssi, (int)staId, pContext);
961 }
962
963 if (NULL == pContext)
964 {
965 hddLog(VOS_TRACE_LEVEL_ERROR,
966 "%s: Bad param, pContext [%p]",
967 __func__, pContext);
968 return;
969 }
970
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800971 pStatsContext = pContext;
972 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800973
974 /* there is a race condition that exists between this callback
975 function and the caller since the caller could time out either
976 before or while this code is executing. we use a spinlock to
977 serialize these actions */
978 spin_lock(&hdd_context_lock);
979
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800980 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
981 {
982 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800983 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800984 hddLog(VOS_TRACE_LEVEL_WARN,
985 "%s: Invalid context, pAdapter [%p] magic [%08x]",
986 __func__, pAdapter, pStatsContext->magic);
987 if (ioctl_debug)
988 {
989 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
990 __func__, pAdapter, pStatsContext->magic);
991 }
992 return;
993 }
994
Jeff Johnson72a40512013-12-19 10:14:15 -0800995 /* context is valid so caller is still waiting */
996
997 /* paranoia: invalidate the magic */
998 pStatsContext->magic = 0;
999
1000 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001001 pAdapter->rssi = rssi;
1002
Jeff Johnson72a40512013-12-19 10:14:15 -08001003 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001004 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001005
1006 /* serialization is complete */
1007 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001008}
1009
1010
1011
1012VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1013{
1014 struct statsContext context;
1015 hdd_context_t *pHddCtx = NULL;
1016 hdd_station_ctx_t *pHddStaCtx = NULL;
1017 eHalStatus hstatus;
1018 long lrc;
1019
1020 if (NULL == pAdapter)
1021 {
1022 hddLog(VOS_TRACE_LEVEL_WARN,
1023 "%s: Invalid context, pAdapter", __func__);
1024 return VOS_STATUS_E_FAULT;
1025 }
1026 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1027 {
1028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1029 /* return a cached value */
1030 *rssi_value = pAdapter->rssi;
1031 return VOS_STATUS_SUCCESS;
1032 }
1033
1034 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1035 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1036
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301037 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001038 {
1039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1040 /* return a cached value */
1041 *rssi_value = 0;
1042 return VOS_STATUS_SUCCESS;
1043 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301044
1045 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1046 {
1047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1048 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1049 *rssi_value = pAdapter->rssi;
1050 return VOS_STATUS_SUCCESS;
1051 }
1052
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001053 init_completion(&context.completion);
1054 context.pAdapter = pAdapter;
1055 context.magic = RSSI_CONTEXT_MAGIC;
1056
1057 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1058 pHddStaCtx->conn_info.staId[ 0 ],
1059 pHddStaCtx->conn_info.bssId,
1060 &context, pHddCtx->pvosContext);
1061 if (eHAL_STATUS_SUCCESS != hstatus)
1062 {
1063 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1064 __func__);
1065 /* we'll returned a cached value below */
1066 }
1067 else
1068 {
1069 /* request was sent -- wait for the response */
1070 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1071 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001072 if (lrc <= 0)
1073 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001074 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001075 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001076 /* we'll now returned a cached value below */
1077 }
1078 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001079
1080 /* either we never sent a request, we sent a request and received a
1081 response or we sent a request and timed out. if we never sent a
1082 request or if we sent a request and got a response, we want to
1083 clear the magic out of paranoia. if we timed out there is a
1084 race condition such that the callback function could be
1085 executing at the same time we are. of primary concern is if the
1086 callback function had already verified the "magic" but had not
1087 yet set the completion variable when a timeout occurred. we
1088 serialize these activities by invalidating the magic while
1089 holding a shared spinlock which will cause us to block if the
1090 callback is currently executing */
1091 spin_lock(&hdd_context_lock);
1092 context.magic = 0;
1093 spin_unlock(&hdd_context_lock);
1094
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001095 *rssi_value = pAdapter->rssi;
1096
1097 return VOS_STATUS_SUCCESS;
1098}
1099#endif
1100
1101
Jeff Johnson295189b2012-06-20 16:38:30 -07001102void hdd_StatisticsCB( void *pStats, void *pContext )
1103{
1104 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1105 hdd_stats_t *pStatsCache = NULL;
1106 hdd_wext_state_t *pWextState;
1107 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1108
1109 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1110 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1111 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1112 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1113 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1114 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1115
1116 if (pAdapter!= NULL)
1117 pStatsCache = &pAdapter->hdd_stats;
1118
1119
1120 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1121 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1122 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1123 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1124 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1125 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1126
1127 if (pStatsCache!=NULL)
1128 {
1129 // and copy the stats into the cache we keep in the adapter instance structure
1130 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1131 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1132 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1133 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1134 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1135 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1136 }
1137
1138 if(pAdapter)
1139 {
1140 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1141 if(pWextState)
1142 {
1143 vos_status = vos_event_set(&pWextState->vosevent);
1144 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1145 {
1146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001147 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 return;
1149 }
1150 }
1151 }
1152}
1153
1154void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1155{
1156 v_CONTEXT_t pVosContext;
1157 hdd_context_t *pHddCtx;
1158 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1159#if 0
1160 hdd_wext_state_t *pWextState;
1161 v_U32_t roamId;
1162#endif
1163
1164 ENTER();
1165
1166 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1167
1168 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1169 if (NULL == pHddCtx)
1170 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001171 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 return;
1173 }
1174#if 0
1175 pWextState = pAdapter->pWextState;
1176#endif
1177
1178 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1179 {
1180 //TODO Verify is this is really used. If yes need to fix it.
1181 hdd_reconnect_all_adapters( pHddCtx );
1182#if 0
1183 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1184 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1185 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1186
1187 if(VOS_STATUS_SUCCESS == vosStatus)
1188 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1189 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1190
1191 sme_RoamConnect(halHandle,
1192 pAdapter->sessionId, &(pWextState->roamProfile),
1193 &roamId);
1194#endif
1195 }
1196
1197 EXIT();
1198
1199}
1200
1201void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1202{
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1204
1205 /* clear WPA/RSN/WSC IE information in the profile */
1206 pWextState->roamProfile.nWPAReqIELength = 0;
1207 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1208 pWextState->roamProfile.nRSNReqIELength = 0;
1209 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1210
Chet Lanctot186b5732013-03-18 10:26:30 -07001211#ifdef FEATURE_WLAN_WAPI
1212 pWextState->roamProfile.nWAPIReqIELength = 0;
1213 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1214#endif
1215
Jeff Johnson295189b2012-06-20 16:38:30 -07001216 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001217 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301219 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1221 pWextState->roamProfile.nAddIEAssocLength = 0;
1222
1223 pWextState->roamProfile.EncryptionType.numEntries = 1;
1224 pWextState->roamProfile.EncryptionType.encryptionType[0]
1225 = eCSR_ENCRYPT_TYPE_NONE;
1226
1227 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1228 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1229 = eCSR_ENCRYPT_TYPE_NONE;
1230
1231 pWextState->roamProfile.AuthType.numEntries = 1;
1232 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1233
Chet Lanctot186b5732013-03-18 10:26:30 -07001234#ifdef WLAN_FEATURE_11W
1235 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1236 pWextState->roamProfile.MFPRequired = 0;
1237 pWextState->roamProfile.MFPCapable = 0;
1238#endif
1239
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 pWextState->authKeyMgmt = 0;
1241
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301242 vos_mem_zero(&pWextState->roamProfile.Keys,
1243 sizeof(pWextState->roamProfile.Keys));
1244
Jeff Johnson295189b2012-06-20 16:38:30 -07001245#ifdef FEATURE_WLAN_WAPI
1246 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1247 pAdapter->wapi_info.nWapiMode = 0;
1248#endif
1249
1250 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1251
1252}
1253
1254void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1255{
1256 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001257
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001258 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1259 {
1260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1261 "%s: Invalid pAdapter magic", __func__);
1262 }
1263 else
1264 {
1265 complete(&pAdapter->ula_complete);
1266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001267}
1268
1269VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1270{
1271 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001273 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001274
1275 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1276 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001277 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001278
1279 /*To avoid race condition between the set key and the last EAPOL
1280 packet, notify TL to finish upper layer authentication incase if the
1281 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001282 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001283
1284 if ( vos_status != VOS_STATUS_SUCCESS )
1285 {
1286 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1287 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1288 __LINE__, vos_status );
1289 return vos_status;
1290
1291 }
1292
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001293 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301295 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001296 {
1297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301298 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001299 /* we'll still fall through and return success since the
1300 * connection may still get established but is just taking
1301 * too long for us to wait */
1302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 }
1304 return VOS_STATUS_SUCCESS;
1305}
1306
1307v_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)
1308{
1309
1310 int left = ie_len;
1311 v_U8_t *ptr = ie;
1312 v_U8_t elem_id,elem_len;
1313 v_U8_t eid = 0xDD;
1314
1315 if ( NULL == ie || 0 == ie_len )
1316 return NULL;
1317
1318 while(left >= 2)
1319 {
1320 elem_id = ptr[0];
1321 elem_len = ptr[1];
1322 left -= 2;
1323 if(elem_len > left)
1324 {
1325 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001326 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 eid,elem_len,left);
1328 return NULL;
1329 }
1330 if (elem_id == eid)
1331 {
1332 if(memcmp( &ptr[2], oui, oui_size)==0)
1333 return ptr;
1334 }
1335
1336 left -= elem_len;
1337 ptr += (elem_len + 2);
1338 }
1339 return NULL;
1340}
1341
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301342static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 union iwreq_data *wrqu, char *extra)
1344{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001345 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 /* Do nothing for now */
1347 return 0;
1348}
1349
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301350static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1351 union iwreq_data *wrqu, char *extra)
1352{
1353 int ret;
1354
1355 vos_ssr_protect(__func__);
1356 ret = __iw_set_commit(dev, info, wrqu, extra);
1357 vos_ssr_unprotect(__func__);
1358
1359 return ret;
1360}
1361
1362static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 struct iw_request_info *info,
1364 char *wrqu, char *extra)
1365{
1366
1367 ENTER();
1368 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1369 EXIT();
1370 return 0;
1371}
1372
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301373static int iw_get_name(struct net_device *dev,
1374 struct iw_request_info *info,
1375 char *wrqu, char *extra)
1376{
1377 int ret;
1378
1379 vos_ssr_protect(__func__);
1380 ret = __iw_get_name(dev, info, wrqu, extra);
1381 vos_ssr_unprotect(__func__);
1382
1383 return ret;
1384}
1385
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301386static int __iw_set_mode(struct net_device *dev,
1387 struct iw_request_info *info,
1388 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001389{
1390 hdd_wext_state_t *pWextState;
1391 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1392 tCsrRoamProfile *pRoamProfile;
1393 eCsrRoamBssType LastBSSType;
1394 eMib_dot11DesiredBssType connectedBssType;
1395 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001397
1398 ENTER();
1399
1400 if (NULL == pAdapter)
1401 {
1402 hddLog(VOS_TRACE_LEVEL_WARN,
1403 "%s: Invalid context, pAdapter", __func__);
1404 return 0;
1405 }
1406
1407 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1409 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 return 0;
1411 }
1412
1413 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1414 if (pWextState == NULL)
1415 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301416 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 return -EINVAL;
1418 }
1419
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 pRoamProfile = &pWextState->roamProfile;
1422 LastBSSType = pRoamProfile->BSSType;
1423
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301424 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001425
1426 switch (wrqu->mode)
1427 {
1428 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301429 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1431 // Set the phymode correctly for IBSS.
1432 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1433 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001434 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 break;
1437 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301438 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 break;
1442 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301443 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1445 break;
1446 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301447 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 return -EOPNOTSUPP;
1449 }
1450
1451 if ( LastBSSType != pRoamProfile->BSSType )
1452 {
1453 //the BSS mode changed
1454 // We need to issue disconnect if connected or in IBSS disconnect state
1455 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1456 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1457 {
1458 VOS_STATUS vosStatus;
1459 // need to issue a disconnect to CSR.
1460 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1461 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1462 pAdapter->sessionId,
1463 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1464 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301465 {
1466 long ret;
1467 ret = wait_for_completion_interruptible_timeout(
1468 &pAdapter->disconnect_comp_var,
1469 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1470 if (ret <= 0)
1471 hddLog(VOS_TRACE_LEVEL_ERROR,
1472 FL("failed wait on disconnect_comp_var %ld"), ret);
1473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 }
1475 }
1476
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 EXIT();
1478 return 0;
1479}
1480
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301481static int iw_set_mode(struct net_device *dev,
1482 struct iw_request_info *info,
1483 union iwreq_data *wrqu, char *extra)
1484{
1485 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301487 vos_ssr_protect(__func__);
1488 ret = __iw_set_mode(dev, info, wrqu, extra);
1489 vos_ssr_unprotect(__func__);
1490
1491 return ret;
1492}
1493
1494static int __iw_get_mode(struct net_device *dev,
1495 struct iw_request_info *info,
1496 union iwreq_data *wrqu,
1497 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001498{
1499
1500 hdd_wext_state_t *pWextState;
1501 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1502
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301503 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001504
1505 if (NULL == pAdapter)
1506 {
1507 hddLog(VOS_TRACE_LEVEL_WARN,
1508 "%s: Invalid context, pAdapter", __func__);
1509 return 0;
1510 }
1511
1512 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1514 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 return 0;
1516 }
1517
1518 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1519 if (pWextState == NULL)
1520 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301521 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 return -EINVAL;
1523 }
1524
1525 switch (pWextState->roamProfile.BSSType)
1526 {
1527 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001528 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301529 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 break;
1531 case eCSR_BSS_TYPE_IBSS:
1532 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001533 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301534 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 break;
1536 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001537 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301538 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001539 break;
1540 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001541 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 break;
1543 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301544
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 return 0;
1546}
1547
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301548static int iw_get_mode(struct net_device *dev,
1549 struct iw_request_info *info,
1550 union iwreq_data *wrqu,
1551 char *extra)
1552{
1553 int ret;
1554
1555 vos_ssr_protect(__func__);
1556 ret = __iw_get_mode(dev, info, wrqu, extra);
1557 vos_ssr_unprotect(__func__);
1558
1559 return ret;
1560}
1561
1562static int __iw_set_freq(struct net_device *dev,
1563 struct iw_request_info *info,
1564 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001565{
1566 v_U32_t numChans = 0;
1567 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1568 v_U32_t indx = 0;
1569 v_U32_t status = 0;
1570
1571 hdd_wext_state_t *pWextState;
1572 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1573 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1574 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1575 tCsrRoamProfile * pRoamProfile;
1576 ENTER();
1577
1578 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1580 return status;
1581 }
1582
1583 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1584
1585 pRoamProfile = &pWextState->roamProfile;
1586
Arif Hussain6d2a3322013-11-17 19:50:10 -08001587 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001588
1589 /* Link is up then return cant set channel*/
1590 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1591 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1592 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001593 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 return -EOPNOTSUPP;
1595 }
1596
1597 /* Settings by Frequency as input */
1598 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1599 (wrqu->freq.m <= (tANI_U32)5.825e8))
1600 {
1601 tANI_U32 freq = wrqu->freq.m / 100000;
1602
1603 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1604 indx++;
1605 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1606 {
1607 return -EINVAL;
1608 }
1609 wrqu->freq.e = 0;
1610 wrqu->freq.m = freq_chan_map[indx].chan;
1611
1612 }
1613
1614 if (wrqu->freq.e == 0)
1615 {
1616 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1617 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1618 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001619 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001620 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1622 return -EINVAL;
1623 }
1624
1625 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1626
1627 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1628 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1630 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 return -EIO;
1632 }
1633
1634 for (indx = 0; indx < numChans; indx++) {
1635 if (wrqu->freq.m == validChan[indx]){
1636 break;
1637 }
1638 }
1639 }
1640 else{
1641
1642 return -EINVAL;
1643 }
1644
1645 if(indx >= numChans)
1646 {
1647 return -EINVAL;
1648 }
1649
1650 /* Set the Operational Channel */
1651 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1652 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1653 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1654
Arif Hussain6d2a3322013-11-17 19:50:10 -08001655 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001656
1657 EXIT();
1658
1659 return status;
1660}
1661
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301662static int iw_set_freq(struct net_device *dev,
1663 struct iw_request_info *info,
1664 union iwreq_data *wrqu, char *extra)
1665{
1666 int ret;
1667
1668 vos_ssr_protect(__func__);
1669 ret = __iw_set_freq(dev, info, wrqu, extra);
1670 vos_ssr_unprotect(__func__);
1671
1672 return ret;
1673}
1674
1675static int __iw_get_freq(struct net_device *dev,
1676 struct iw_request_info *info,
1677 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001678{
Jeff Johnsone7245742012-09-05 17:12:55 -07001679 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1681 tHalHandle hHal;
1682 hdd_wext_state_t *pWextState;
1683 tCsrRoamProfile * pRoamProfile;
1684 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1685
1686 ENTER();
1687
1688 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1690 return status;
1691 }
1692
1693 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1694 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1695
1696 pRoamProfile = &pWextState->roamProfile;
1697
1698 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1699 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001700 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 {
c_hpothub8245442013-11-20 23:41:09 +05301702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1703 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 return -EIO;
1705 }
1706 else
1707 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001708 status = hdd_wlan_get_freq(channel, &freq);
1709 if( TRUE == status )
1710 {
1711 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1712 * iwlist & iwconfig command shows frequency into proper
1713 * format (2.412 GHz instead of 246.2 MHz)*/
1714 fwrq->m = freq;
1715 fwrq->e = MHZ;
1716 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 }
1718 }
1719 else
1720 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001721 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1722 * iwlist & iwconfig command shows frequency into proper
1723 * format (2.412 GHz instead of 246.2 MHz)*/
1724 fwrq->m = 0;
1725 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001727 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001728}
1729
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301730static int iw_get_freq(struct net_device *dev,
1731 struct iw_request_info *info,
1732 struct iw_freq *fwrq, char *extra)
1733{
1734 int ret;
1735
1736 vos_ssr_protect(__func__);
1737 ret = __iw_get_freq(dev, info, fwrq, extra);
1738 vos_ssr_unprotect(__func__);
1739
1740 return ret;
1741}
1742
1743static int __iw_get_tx_power(struct net_device *dev,
1744 struct iw_request_info *info,
1745 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001746{
1747
1748 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1749 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1750 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1751
1752 if (pHddCtx->isLogpInProgress)
1753 {
1754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1755 "%s:LOGP in Progress. Ignore!!!",__func__);
1756 return -EBUSY;
1757 }
1758
1759 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1760 {
1761 wrqu->txpower.value = 0;
1762 return 0;
1763 }
1764 wlan_hdd_get_classAstats(pAdapter);
1765 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1766
1767 return 0;
1768}
1769
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301770static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001771 struct iw_request_info *info,
1772 union iwreq_data *wrqu, char *extra)
1773{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301774 int ret;
1775
1776 vos_ssr_protect(__func__);
1777 ret = __iw_get_tx_power(dev, info, wrqu, extra);
1778 vos_ssr_unprotect(__func__);
1779
1780 return ret;
1781}
1782
1783static int __iw_set_tx_power(struct net_device *dev,
1784 struct iw_request_info *info,
1785 union iwreq_data *wrqu, char *extra)
1786{
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1788 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1789
1790 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1791 {
1792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1793 return 0;
1794 }
1795
1796 ENTER();
1797
1798 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1799 {
c_hpothub8245442013-11-20 23:41:09 +05301800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1801 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 return -EIO;
1803 }
1804
1805 EXIT();
1806
1807 return 0;
1808}
1809
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301810static int iw_set_tx_power(struct net_device *dev,
1811 struct iw_request_info *info,
1812 union iwreq_data *wrqu, char *extra)
1813{
1814 int ret;
1815
1816 vos_ssr_protect(__func__);
1817 ret = __iw_set_tx_power(dev, info, wrqu, extra);
1818 vos_ssr_unprotect(__func__);
1819
1820 return ret;
1821}
1822
1823static int __iw_get_bitrate(struct net_device *dev,
1824 struct iw_request_info *info,
1825 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001826{
1827 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1828 eHalStatus status = eHAL_STATUS_SUCCESS;
1829 hdd_wext_state_t *pWextState;
1830 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1831 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1832
1833 ENTER();
1834
1835 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1837 return status;
1838 }
1839
1840 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1841 wrqu->bitrate.value = 0;
1842 }
1843 else {
1844 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1845 SME_SUMMARY_STATS |
1846 SME_GLOBAL_CLASSA_STATS |
1847 SME_GLOBAL_CLASSB_STATS |
1848 SME_GLOBAL_CLASSC_STATS |
1849 SME_GLOBAL_CLASSD_STATS |
1850 SME_PER_STA_STATS,
1851 hdd_StatisticsCB, 0, FALSE,
1852 pHddStaCtx->conn_info.staId[0], pAdapter );
1853
1854 if(eHAL_STATUS_SUCCESS != status)
1855 {
1856 hddLog(VOS_TRACE_LEVEL_ERROR,
1857 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001858 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 return status;
1860 }
1861
1862 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1863
1864 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1865
1866 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1867 {
1868 hddLog(VOS_TRACE_LEVEL_ERROR,
1869 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001870 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 return VOS_STATUS_E_FAILURE;
1872 }
1873
1874 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1875 }
1876
1877 EXIT();
1878
1879 return vos_status;
1880}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301881
1882static int iw_get_bitrate(struct net_device *dev,
1883 struct iw_request_info *info,
1884 union iwreq_data *wrqu, char *extra)
1885{
1886 int ret;
1887
1888 vos_ssr_protect(__func__);
1889 ret = __iw_get_bitrate(dev, info, wrqu, extra);
1890 vos_ssr_unprotect(__func__);
1891
1892 return ret;
1893}
1894
1895
Jeff Johnson295189b2012-06-20 16:38:30 -07001896/* ccm call back function */
1897
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301898static int __iw_set_bitrate(struct net_device *dev,
1899 struct iw_request_info *info,
1900 union iwreq_data *wrqu,
1901 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001902{
1903 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1904 hdd_wext_state_t *pWextState;
1905 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1906 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1907 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1908 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1909 v_U32_t i, rate;
1910 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1911
1912 ENTER();
1913
1914 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1916 return 0;
1917 }
1918
1919 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1920
1921 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1922 {
1923 return -ENXIO ;
1924 }
1925
1926 rate = wrqu->bitrate.value;
1927
1928 if (rate == -1)
1929 {
1930 rate = WNI_CFG_FIXED_RATE_AUTO;
1931 valid_rate = TRUE;
1932 }
1933 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1934 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1935 {
1936 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1937 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1938 {
1939 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1940 WNI_CFG_SUPPORTED_RATES_11A,
1941 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1942 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1943 WNI_CFG_SUPPORTED_RATES_11B,
1944 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1945 {
1946 for (i = 0; i < (b_len + a_len); ++i)
1947 {
1948 /* supported rates returned is double the actual rate so we divide it by 2 */
1949 if ((supp_rates[i]&0x7F)/2 == rate)
1950 {
1951 valid_rate = TRUE;
1952 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1953 break;
1954 }
1955 }
1956 }
1957 }
1958 }
1959 if (valid_rate != TRUE)
1960 {
1961 return -EINVAL;
1962 }
1963 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1964 WNI_CFG_FIXED_RATE, rate,
1965 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1966 {
c_hpothub8245442013-11-20 23:41:09 +05301967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1968 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 return -EIO;
1970 }
1971 return 0;
1972}
1973
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301974static int iw_set_bitrate(struct net_device *dev,
1975 struct iw_request_info *info,
1976 union iwreq_data *wrqu,
1977 char *extra)
1978{
1979 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001980
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301981 vos_ssr_protect(__func__);
1982 ret = __iw_set_bitrate(dev, info, wrqu, extra);
1983 vos_ssr_unprotect(__func__);
1984
1985 return ret;
1986}
1987
1988static int __iw_set_genie(struct net_device *dev,
1989 struct iw_request_info *info,
1990 union iwreq_data *wrqu,
1991 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001992{
1993 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1994 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001995 u_int8_t *genie = NULL;
1996 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 v_U16_t remLen;
1998
1999 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002000
2001 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08002002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2003 "%s:LOGP in Progress. Ignore!!!", __func__);
2004 return 0;
2005 }
2006
2007 if (!wrqu->data.length) {
2008 hdd_clearRoamProfileIe(pAdapter);
2009 EXIT();
2010 return 0;
2011 }
2012
2013 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2014 wrqu->data.length);
2015 if (NULL == base_genie)
2016 {
2017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2018 "mem_alloc_copy_from_user_helper fail");
2019 return -ENOMEM;
2020 }
2021
2022 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002023
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 remLen = wrqu->data.length;
2025
Arif Hussain6d2a3322013-11-17 19:50:10 -08002026 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002027
2028 /* clear any previous genIE before this call */
2029 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2030
2031 while (remLen >= 2)
2032 {
2033 v_U16_t eLen = 0;
2034 v_U8_t elementId;
2035 elementId = *genie++;
2036 eLen = *genie++;
2037 remLen -= 2;
2038
Arif Hussain6d2a3322013-11-17 19:50:10 -08002039 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002040 __func__, elementId, eLen);
2041
2042 switch ( elementId )
2043 {
2044 case IE_EID_VENDOR:
2045 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002046 {
2047 kfree(base_genie);
2048 return -EINVAL;
2049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002050
2051 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2052 {
2053 v_U16_t curGenIELen = pWextState->genIE.length;
2054 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2055 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2056
2057 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2058 {
2059 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002060 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002062 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 return -ENOMEM;
2064 }
2065 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2066 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2067 pWextState->genIE.length += eLen + 2;
2068 }
2069 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2070 {
2071 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2072 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2073 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2074 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2075 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2076 }
2077 else /* any vendorId except WPA IE should be accumulated to genIE */
2078 {
2079 v_U16_t curGenIELen = pWextState->genIE.length;
2080 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2081 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2082
2083 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2084 {
2085 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002086 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002088 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 return -ENOMEM;
2090 }
2091 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2092 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2093 pWextState->genIE.length += eLen + 2;
2094 }
2095 break;
2096 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002097 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2099 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2100 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2101 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2102 break;
2103
2104 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002105 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002106 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 return 0;
2108 }
2109 genie += eLen;
2110 remLen -= eLen;
2111 }
2112 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002113 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 return 0;
2115}
2116
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302117static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 struct iw_request_info *info,
2119 union iwreq_data *wrqu,
2120 char *extra)
2121{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302122 int ret;
2123
2124 vos_ssr_protect(__func__);
2125 ret = __iw_set_genie(dev, info, wrqu, extra);
2126 vos_ssr_unprotect(__func__);
2127
2128 return ret;
2129}
2130
2131static int __iw_get_genie(struct net_device *dev,
2132 struct iw_request_info *info,
2133 union iwreq_data *wrqu,
2134 char *extra)
2135{
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 hdd_wext_state_t *pWextState;
2137 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2138 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2139 eHalStatus status;
2140 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2141 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2142
2143 ENTER();
2144
2145 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2147 return 0;
2148 }
2149
2150
Arif Hussain6d2a3322013-11-17 19:50:10 -08002151 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07002152
2153 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2154
2155 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2156 {
2157 return -ENXIO;
2158 }
2159
2160 // Return something ONLY if we are associated with an RSN or WPA network
2161 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2162 pWextState->roamProfile.negotiatedAuthType))
2163 {
2164 return -ENXIO;
2165 }
2166
2167 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2168 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2169 pAdapter->sessionId,
2170 &length,
2171 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002172 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2173 if (wrqu->data.length < length)
2174 {
2175 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2176 return -EFAULT;
2177 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002178 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002179 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002180
Arif Hussain6d2a3322013-11-17 19:50:10 -08002181 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002182
2183 EXIT();
2184
2185 return 0;
2186}
2187
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302188static int iw_get_genie(struct net_device *dev,
2189 struct iw_request_info *info,
2190 union iwreq_data *wrqu,
2191 char *extra)
2192{
2193 int ret;
2194
2195 vos_ssr_protect(__func__);
2196 ret = __iw_get_genie(dev, info, wrqu, extra);
2197 vos_ssr_unprotect(__func__);
2198
2199 return ret;
2200}
2201
2202
2203static int __iw_get_encode(struct net_device *dev,
2204 struct iw_request_info *info,
2205 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002206{
2207 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2208 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2209 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2210 int keyId;
2211 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
2212 int i;
2213
2214 ENTER();
2215
2216 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2218 return 0;
2219 }
2220
2221 keyId = pRoamProfile->Keys.defaultIndex;
2222
2223 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2224 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002225 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 return -EINVAL;
2227 }
2228
2229 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2230 {
2231 dwrq->flags |= IW_ENCODE_ENABLED;
2232 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2233 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2234
2235 dwrq->flags |= (keyId + 1);
2236
2237 }
2238 else
2239 {
2240 dwrq->flags |= IW_ENCODE_DISABLED;
2241 }
2242
2243 for(i=0; i < MAX_WEP_KEYS; i++)
2244 {
2245 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2246 {
2247 continue;
2248 }
2249 else
2250 {
2251 break;
2252 }
2253 }
2254
2255 if(MAX_WEP_KEYS == i)
2256 {
2257 dwrq->flags |= IW_ENCODE_NOKEY;
2258 }
2259
2260 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2261
2262 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2263 {
2264 dwrq->flags |= IW_ENCODE_OPEN;
2265 }
2266 else
2267 {
2268 dwrq->flags |= IW_ENCODE_RESTRICTED;
2269 }
2270 EXIT();
2271 return 0;
2272}
2273
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302274static int iw_get_encode(struct net_device *dev,
2275 struct iw_request_info *info,
2276 struct iw_point *dwrq, char *extra)
2277{
2278 int ret;
2279
2280 vos_ssr_protect(__func__);
2281 ret = __iw_get_encode(dev, info, dwrq, extra);
2282 vos_ssr_unprotect(__func__);
2283
2284 return ret;
2285}
2286
Jeff Johnson295189b2012-06-20 16:38:30 -07002287#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2288#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2289
2290
2291/*
2292 * This function sends a single 'key' to LIM at all time.
2293 */
2294
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302295static int __iw_get_rts_threshold(struct net_device *dev,
2296 struct iw_request_info *info,
2297 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002298{
2299 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2300 v_U32_t status = 0;
2301
2302 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2303
2304 return status;
2305}
2306
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302307static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 struct iw_request_info *info,
2309 union iwreq_data *wrqu, char *extra)
2310{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302311 int ret;
2312
2313 vos_ssr_protect(__func__);
2314 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2315 vos_ssr_unprotect(__func__);
2316
2317 return ret;
2318}
2319
2320static int __iw_set_rts_threshold(struct net_device *dev,
2321 struct iw_request_info *info,
2322 union iwreq_data *wrqu, char *extra)
2323{
Jeff Johnson295189b2012-06-20 16:38:30 -07002324 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2325 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2326
2327 ENTER();
2328
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002329 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2330 {
2331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2332 "%s:LOGP in Progress. Ignore!!!", __func__);
2333 return -EAGAIN;
2334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002335 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2336 {
2337 return -EINVAL;
2338 }
2339
2340 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2341 {
c_hpothub8245442013-11-20 23:41:09 +05302342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2343 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 return -EIO;
2345 }
2346
2347 EXIT();
2348
2349 return 0;
2350}
2351
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302352static int iw_set_rts_threshold(struct net_device *dev,
2353 struct iw_request_info *info,
2354 union iwreq_data *wrqu, char *extra)
2355{
2356 int ret;
2357
2358 vos_ssr_protect(__func__);
2359 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2360 vos_ssr_unprotect(__func__);
2361
2362 return ret;
2363}
2364
2365static int __iw_get_frag_threshold(struct net_device *dev,
2366 struct iw_request_info *info,
2367 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002368{
2369 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2370 v_U32_t status = 0;
2371
2372 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2373
2374 return status;
2375}
2376
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302377static int iw_get_frag_threshold(struct net_device *dev,
2378 struct iw_request_info *info,
2379 union iwreq_data *wrqu, char *extra)
2380{
2381 int ret;
2382
2383 vos_ssr_protect(__func__);
2384 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2385 vos_ssr_unprotect(__func__);
2386
2387 return ret;
2388}
2389
2390static int __iw_set_frag_threshold(struct net_device *dev,
2391 struct iw_request_info *info,
2392 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002393{
2394 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2395 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2396
2397 ENTER();
2398
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002399 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2400 {
2401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2402 "%s:LOGP in Progress. Ignore!!!", __func__);
2403 return -EBUSY;
2404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2406 {
2407 return -EINVAL;
2408 }
2409
2410 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2411 {
c_hpothub8245442013-11-20 23:41:09 +05302412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2413 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 return -EIO;
2415 }
2416
2417 EXIT();
2418
2419 return 0;
2420}
2421
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302422static int iw_set_frag_threshold(struct net_device *dev,
2423 struct iw_request_info *info,
2424 union iwreq_data *wrqu, char *extra)
2425{
2426 int ret;
2427
2428 vos_ssr_protect(__func__);
2429 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2430 vos_ssr_unprotect(__func__);
2431
2432 return ret;
2433}
2434
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302435static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002436 struct iw_request_info *info,
2437 union iwreq_data *wrqu, char *extra)
2438{
2439 ENTER();
2440 return -EOPNOTSUPP;
2441}
2442
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302443static int iw_get_power_mode(struct net_device *dev,
2444 struct iw_request_info *info,
2445 union iwreq_data *wrqu, char *extra)
2446{
2447 int ret;
2448
2449 vos_ssr_protect(__func__);
2450 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2451 vos_ssr_unprotect(__func__);
2452
2453 return ret;
2454}
2455static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 struct iw_request_info *info,
2457 union iwreq_data *wrqu, char *extra)
2458{
2459 ENTER();
2460 return -EOPNOTSUPP;
2461}
2462
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302463static int iw_set_power_mode(struct net_device *dev,
2464 struct iw_request_info *info,
2465 union iwreq_data *wrqu, char *extra)
2466{
2467 int ret;
2468
2469 vos_ssr_protect(__func__);
2470 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2471 vos_ssr_unprotect(__func__);
2472
2473 return ret;
2474}
2475
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302476static int __iw_get_range(struct net_device *dev,
2477 struct iw_request_info *info,
2478 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002479{
2480 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2481 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2482 struct iw_range *range = (struct iw_range *) extra;
2483
2484 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2485
2486 v_U32_t num_channels = sizeof(channels);
2487 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2488 v_U32_t a_len;
2489 v_U32_t b_len;
2490 v_U32_t active_phy_mode = 0;
2491 v_U8_t index = 0, i;
2492
2493 ENTER();
2494
2495 wrqu->data.length = sizeof(struct iw_range);
2496 memset(range, 0, sizeof(struct iw_range));
2497
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002498 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2499 {
2500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2501 "%s:LOGP in Progress. Ignore!!!", __func__);
2502 return -EBUSY;
2503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002504
2505 /*Get the phy mode*/
2506 if (ccmCfgGetInt(hHal,
2507 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2508 {
2509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002510 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002511
2512 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2513 {
2514 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002515 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 if (ccmCfgGetStr(hHal,
2517 WNI_CFG_SUPPORTED_RATES_11A,
2518 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2519 {
2520 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2521 {
2522 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2523 }
2524 for (i = 0; i < a_len; i++)
2525 {
2526 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2527 }
2528 range->num_bitrates = a_len;
2529 }
2530 else
2531 {
2532 return -EIO;
2533 }
2534 }
2535 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2536 {
2537 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002538 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 if (ccmCfgGetStr(hHal,
2540 WNI_CFG_SUPPORTED_RATES_11B,
2541 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2542 {
2543 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2544 {
2545 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2546 }
2547 for (i = 0; i < b_len; i++)
2548 {
2549 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2550 }
2551 range->num_bitrates = b_len;
2552 }
2553 else
2554 {
2555 return -EIO;
2556 }
2557 }
2558 }
2559
2560 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2561 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2562 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2563
2564 range->encoding_size[0] = 5;
2565 range->encoding_size[1] = 13;
2566 range->num_encoding_sizes = 2;
2567 range->max_encoding_tokens = MAX_WEP_KEYS;
2568
2569 // we support through Wireless Extensions 22
2570 range->we_version_compiled = WIRELESS_EXT;
2571 range->we_version_source = 22;
2572
2573 /*Supported Channels and Frequencies*/
2574 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2575 {
c_hpothub8245442013-11-20 23:41:09 +05302576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2577 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 return -EIO;
2579 }
2580 if (num_channels > IW_MAX_FREQUENCIES)
2581 {
2582 num_channels = IW_MAX_FREQUENCIES;
2583 }
2584
2585 range->num_channels = num_channels;
2586 range->num_frequency = num_channels;
2587
2588 for (index=0; index < num_channels; index++)
2589 {
2590 v_U32_t frq_indx = 0;
2591
2592 range->freq[index].i = channels[index];
2593 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2594 {
2595 if(channels[index] == freq_chan_map[frq_indx].chan)
2596 {
2597 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2598 range->freq[index].e = 1;
2599 break;
2600 }
2601 frq_indx++;
2602 }
2603 }
2604
2605 /* Event capability (kernel + driver) */
2606 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2607 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2608 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2609 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2610
2611 /*Encryption capability*/
2612 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2613 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2614
2615 /* Txpower capability */
2616 range->txpower_capa = IW_TXPOW_MWATT;
2617
2618 /*Scanning capability*/
2619 #if WIRELESS_EXT >= 22
2620 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2621 #endif
2622
2623 EXIT();
2624 return 0;
2625}
2626
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302627static int iw_get_range(struct net_device *dev,
2628 struct iw_request_info *info,
2629 union iwreq_data *wrqu, char *extra)
2630{
2631 int ret;
2632
2633 vos_ssr_protect(__func__);
2634 ret = __iw_get_range(dev, info, wrqu, extra);
2635 vos_ssr_unprotect(__func__);
2636
2637 return ret;
2638}
2639
Jeff Johnson295189b2012-06-20 16:38:30 -07002640/* Callback function registered with PMC to know status of PMC request */
2641static void iw_power_callback_fn (void *pContext, eHalStatus status)
2642{
2643 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002644
2645 if (NULL == pContext)
2646 {
2647 hddLog(VOS_TRACE_LEVEL_ERROR,
2648 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002649 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 return;
2651 }
2652
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002654
Jeff Johnson72a40512013-12-19 10:14:15 -08002655 /* there is a race condition that exists between this callback
2656 function and the caller since the caller could time out either
2657 before or while this code is executing. we use a spinlock to
2658 serialize these actions */
2659 spin_lock(&hdd_context_lock);
2660
2661 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 {
2663 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002664 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002666 "%s: Invalid context, magic [%08x]",
2667 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002668
2669 if (ioctl_debug)
2670 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002671 pr_info("%s: Invalid context, magic [%08x]\n",
2672 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 }
2674 return;
2675 }
2676
Jeff Johnson72a40512013-12-19 10:14:15 -08002677 /* context is valid so caller is still waiting */
2678
2679 /* paranoia: invalidate the magic */
2680 pStatsContext->magic = 0;
2681
2682 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002684
2685 /* serialization is complete */
2686 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002687}
2688
2689/* Callback function for tx per hit */
2690void hdd_tx_per_hit_cb (void *pCallbackContext)
2691{
2692 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2693 unsigned char tx_fail[16];
2694 union iwreq_data wrqu;
2695
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05302696 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002698 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 return;
2700 }
2701 memset(&wrqu, 0, sizeof(wrqu));
2702 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2703 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2704}
2705
2706void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2707{
2708 struct statsContext *pStatsContext;
2709 tCsrGlobalClassAStatsInfo *pClassAStats;
2710 hdd_adapter_t *pAdapter;
2711
2712 if (ioctl_debug)
2713 {
2714 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002715 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 }
2717
2718 if ((NULL == pStats) || (NULL == pContext))
2719 {
2720 hddLog(VOS_TRACE_LEVEL_ERROR,
2721 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002722 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 return;
2724 }
2725
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 pClassAStats = pStats;
2727 pStatsContext = pContext;
2728 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002729
2730 /* there is a race condition that exists between this callback
2731 function and the caller since the caller could time out either
2732 before or while this code is executing. we use a spinlock to
2733 serialize these actions */
2734 spin_lock(&hdd_context_lock);
2735
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2737 {
2738 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002739 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 hddLog(VOS_TRACE_LEVEL_WARN,
2741 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002742 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 if (ioctl_debug)
2744 {
2745 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002746 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 }
2748 return;
2749 }
2750
Jeff Johnson72a40512013-12-19 10:14:15 -08002751 /* context is valid so caller is still waiting */
2752
2753 /* paranoia: invalidate the magic */
2754 pStatsContext->magic = 0;
2755
2756 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2758
Jeff Johnson72a40512013-12-19 10:14:15 -08002759 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002761
2762 /* serialization is complete */
2763 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002764}
2765
2766VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2767{
2768 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2769 eHalStatus hstatus;
2770 long lrc;
2771 struct statsContext context;
2772
2773 if (NULL == pAdapter)
2774 {
2775 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2776 return VOS_STATUS_E_FAULT;
2777 }
2778 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2779 {
2780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2781 return VOS_STATUS_SUCCESS;
2782 }
2783
2784 /* we are connected
2785 prepare our callback context */
2786 init_completion(&context.completion);
2787 context.pAdapter = pAdapter;
2788 context.magic = STATS_CONTEXT_MAGIC;
2789 /* query only for Class A statistics (which include link speed) */
2790 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2791 eCSR_HDD,
2792 SME_GLOBAL_CLASSA_STATS,
2793 hdd_GetClassA_statisticsCB,
2794 0, // not periodic
2795 FALSE, //non-cached results
2796 pHddStaCtx->conn_info.staId[0],
2797 &context);
2798 if (eHAL_STATUS_SUCCESS != hstatus)
2799 {
2800 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002801 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002802 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 /* we'll returned a cached value below */
2804 }
2805 else
2806 {
2807 /* request was sent -- wait for the response */
2808 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2809 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 if (lrc <= 0)
2811 {
2812 hddLog(VOS_TRACE_LEVEL_ERROR,
2813 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002814 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 }
2816 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002817
2818 /* either we never sent a request, we sent a request and received a
2819 response or we sent a request and timed out. if we never sent a
2820 request or if we sent a request and got a response, we want to
2821 clear the magic out of paranoia. if we timed out there is a
2822 race condition such that the callback function could be
2823 executing at the same time we are. of primary concern is if the
2824 callback function had already verified the "magic" but had not
2825 yet set the completion variable when a timeout occurred. we
2826 serialize these activities by invalidating the magic while
2827 holding a shared spinlock which will cause us to block if the
2828 callback is currently executing */
2829 spin_lock(&hdd_context_lock);
2830 context.magic = 0;
2831 spin_unlock(&hdd_context_lock);
2832
2833 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 return VOS_STATUS_SUCCESS;
2835}
2836
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002837static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2838{
2839 struct statsContext *pStatsContext;
2840 tCsrSummaryStatsInfo *pSummaryStats;
2841 tCsrGlobalClassAStatsInfo *pClassAStats;
2842 hdd_adapter_t *pAdapter;
2843
2844 if (ioctl_debug)
2845 {
2846 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002847 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002848 }
2849
2850 if ((NULL == pStats) || (NULL == pContext))
2851 {
2852 hddLog(VOS_TRACE_LEVEL_ERROR,
2853 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002854 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002855 return;
2856 }
2857
Jeff Johnson72a40512013-12-19 10:14:15 -08002858 /* there is a race condition that exists between this callback
2859 function and the caller since the caller could time out either
2860 before or while this code is executing. we use a spinlock to
2861 serialize these actions */
2862 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002863
2864 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2865 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2866 pStatsContext = pContext;
2867 pAdapter = pStatsContext->pAdapter;
2868 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2869 {
2870 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002871 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002872 hddLog(VOS_TRACE_LEVEL_WARN,
2873 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002874 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002875 if (ioctl_debug)
2876 {
2877 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002878 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002879 }
2880 return;
2881 }
2882
Jeff Johnson72a40512013-12-19 10:14:15 -08002883 /* context is valid so caller is still waiting */
2884
2885 /* paranoia: invalidate the magic */
2886 pStatsContext->magic = 0;
2887
2888 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002889 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2890 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2891
Jeff Johnson72a40512013-12-19 10:14:15 -08002892 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002893 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002894
2895 /* serialization is complete */
2896 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002897}
2898
2899VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2900{
2901 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2902 eHalStatus hstatus;
2903 long lrc;
2904 struct statsContext context;
2905
2906 if (NULL == pAdapter)
2907 {
2908 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2909 return VOS_STATUS_SUCCESS;
2910 }
2911
2912 /* we are connected
2913 prepare our callback context */
2914 init_completion(&context.completion);
2915 context.pAdapter = pAdapter;
2916 context.magic = STATS_CONTEXT_MAGIC;
2917
2918 /* query only for Summary & Class A statistics */
2919 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2920 eCSR_HDD,
2921 SME_SUMMARY_STATS |
2922 SME_GLOBAL_CLASSA_STATS,
2923 hdd_get_station_statisticsCB,
2924 0, // not periodic
2925 FALSE, //non-cached results
2926 pHddStaCtx->conn_info.staId[0],
2927 &context);
2928 if (eHAL_STATUS_SUCCESS != hstatus)
2929 {
2930 hddLog(VOS_TRACE_LEVEL_ERROR,
2931 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002932 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002933 /* we'll return with cached values */
2934 }
2935 else
2936 {
2937 /* request was sent -- wait for the response */
2938 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2939 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002940
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002941 if (lrc <= 0)
2942 {
2943 hddLog(VOS_TRACE_LEVEL_ERROR,
2944 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002945 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002946 }
2947 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002948
2949 /* either we never sent a request, we sent a request and received a
2950 response or we sent a request and timed out. if we never sent a
2951 request or if we sent a request and got a response, we want to
2952 clear the magic out of paranoia. if we timed out there is a
2953 race condition such that the callback function could be
2954 executing at the same time we are. of primary concern is if the
2955 callback function had already verified the "magic" but had not
2956 yet set the completion variable when a timeout occurred. we
2957 serialize these activities by invalidating the magic while
2958 holding a shared spinlock which will cause us to block if the
2959 callback is currently executing */
2960 spin_lock(&hdd_context_lock);
2961 context.magic = 0;
2962 spin_unlock(&hdd_context_lock);
2963
2964 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002965 return VOS_STATUS_SUCCESS;
2966}
2967
2968
Jeff Johnson295189b2012-06-20 16:38:30 -07002969/*
2970 * Support for the LINKSPEED private command
2971 * Per the WiFi framework the response must be of the form
2972 * "LinkSpeed xx"
2973 */
2974static int iw_get_linkspeed(struct net_device *dev,
2975 struct iw_request_info *info,
2976 union iwreq_data *wrqu, char *extra)
2977{
2978 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302979 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302981 int len = sizeof(v_U32_t) + 1;
2982 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302984 VOS_STATUS status;
2985 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002986
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302987 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2988
2989 valid = wlan_hdd_validate_context(pHddCtx);
2990
2991 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002992 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302993 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2994 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002995 }
2996
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2998 {
2999 /* we are not connected so we don't have a classAstats */
3000 link_speed = 0;
3001 }
3002 else
3003 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303004 status = wlan_hdd_get_classAstats(pAdapter);
3005
3006 if (!VOS_IS_STATUS_SUCCESS(status ))
3007 {
3008 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3009 return -EINVAL;
3010 }
3011
3012 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3013 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3014 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3015 &link_speed);
3016
3017 link_speed = link_speed / 10;
3018
3019 if (0 == link_speed)
3020 {
3021 /* The linkspeed returned by HAL is in units of 500kbps.
3022 * converting it to mbps.
3023 * This is required to support legacy firmware which does
3024 * not return link capacity.
3025 */
3026 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3027 }
3028
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 }
3030
3031 wrqu->data.length = len;
3032 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003033 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 if ((rc < 0) || (rc >= len))
3035 {
3036 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303037 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 return -EIO;
3039 }
3040
3041 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003042 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003043}
3044
Arif Hussain695279c2014-03-24 14:06:07 -07003045/*
3046 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3047 *
3048 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303049static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003050 struct iw_request_info *info,
3051 union iwreq_data *wrqu, char *extra)
3052{
3053 int rc;
3054
3055 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3056
3057 if (rc < 0)
3058 return rc;
3059
3060 /* a value is being successfully returned */
3061 return 0;
3062}
Jeff Johnson295189b2012-06-20 16:38:30 -07003063
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303064static int iw_get_linkspeed_priv(struct net_device *dev,
3065 struct iw_request_info *info,
3066 union iwreq_data *wrqu, char *extra)
3067{
3068 int ret;
3069
3070 vos_ssr_protect(__func__);
3071 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3072 vos_ssr_unprotect(__func__);
3073
3074 return ret;
3075}
3076
Jeff Johnson295189b2012-06-20 16:38:30 -07003077/*
3078 * Support for the RSSI & RSSI-APPROX private commands
3079 * Per the WiFi framework the response must be of the form
3080 * "<ssid> rssi <xx>"
3081 * unless we are not associated, in which case the response is
3082 * "OK"
3083 */
3084static int iw_get_rssi(struct net_device *dev,
3085 struct iw_request_info *info,
3086 union iwreq_data *wrqu, char *extra)
3087{
3088 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003089 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 int len = wrqu->data.length;
3091 v_S7_t s7Rssi = 0;
3092 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3093 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3094 VOS_STATUS vosStatus;
3095 int rc;
3096
3097 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3098 (0 == ssidlen) || (ssidlen >= len))
3099 {
3100 /* we are not connected or our SSID is too long
3101 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003102 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 }
3104 else
3105 {
3106 /* we are connected with a valid SSID
3107 so we can write the SSID into the return buffer
3108 (note that it is not NUL-terminated) */
3109 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3110
3111 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3112
3113 if (VOS_STATUS_SUCCESS == vosStatus)
3114 {
3115 /* append the rssi to the ssid in the format required by
3116 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003117 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303118 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 }
3120 else
3121 {
3122 rc = -1;
3123 }
3124 }
3125
3126 /* verify that we wrote a valid response */
3127 if ((rc < 0) || (rc >= len))
3128 {
3129 // encoding or length error?
3130 hddLog(VOS_TRACE_LEVEL_ERROR,
3131 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003132 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 return -EIO;
3134 }
3135
3136 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003137 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003138}
3139
3140/*
3141 * Support for SoftAP channel range private command
3142 */
3143static int iw_softap_set_channel_range( struct net_device *dev,
3144 int startChannel,
3145 int endChannel,
3146 int band)
3147{
Jeff Johnson43971f52012-07-17 12:26:56 -07003148 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 int ret = 0;
3150 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3151 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003152 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3153
Jeff Johnson295189b2012-06-20 16:38:30 -07003154
3155 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3156 if (VOS_STATUS_SUCCESS != status)
3157 {
3158 ret = -EINVAL;
3159 }
Yathish9f22e662012-12-10 14:21:35 -08003160 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 return ret;
3162}
3163
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303164static uint8 chartohex(char c)
3165{
3166 uint8 val = 0;
3167 if (c >= '0' && c <= '9')
3168 val = c - '0';
3169 else if (c >= 'a' && c <= 'f')
3170 val = c - 'a' + 10;
3171 else if (c >= 'A' && c <= 'F')
3172 val = c - 'A' + 10;
3173 else
3174 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3175
3176 return val;
3177}
3178
3179uint8 getByte(char **buf)
3180{
3181 uint8 byte = 0;
3182 char *temp = *buf;
3183 byte = chartohex(*temp) * 16;
3184 temp++;
3185 byte += chartohex(*temp);
3186 temp++;
3187 *buf = temp;
3188 return byte;
3189}
3190
3191static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3192{
3193 tSir80211Header *macHeader;
3194 int i = 0, j = 0, length = 0;
3195 uint8 byte = 0;
3196 char *temp = pBuffer;
3197 uint16 fragNum = 0;
3198
3199 macHeader = &pkt->macHeader;
3200
3201 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3202
3203 temp++;
3204
3205 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3206 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3207 pkt->encParams.keyParams.key[0].keyId);
3208
3209 for (i = 0; i< 16; i++) {
3210 pkt->encParams.keyParams.key[0].key[i]
3211 = getByte(&temp);
3212 }
3213
3214 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3215 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3216
3217 for (i = 0; i< 6; i++) {
3218 pkt->encParams.pn[i]
3219 = getByte(&temp);
3220 }
3221
3222 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3223 &pkt->encParams.pn[0], 6, 0);
3224
3225 for (i = 0, j= 5; i< 3; i++, j--) {
3226 byte = pkt->encParams.pn[i];
3227 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3228 pkt->encParams.pn[j] = byte;
3229 }
3230
3231 length = getByte(&temp);
3232
3233 byte = getByte(&temp);
3234
3235 macHeader->frameCtrl.protVer = byte & 0x3;
3236 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3237 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3238
3239 byte = getByte(&temp);
3240 macHeader->frameCtrl.toDS = (byte) & 0x1;
3241 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3242 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3243 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3244 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3245 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3246 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3247 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3248
3249 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3250 "macHeader->frameCtrl.type : %x "
3251 "macHeader->frameCtrl.subType : %x "
3252 "macHeader->frameCtrl.toDS : %x "
3253 "macHeader->frameCtrl.fromDS : %x "
3254 "macHeader->frameCtrl.moreFrag : %x "
3255 "macHeader->frameCtrl.retry : %x "
3256 "macHeader->frameCtrl.powerMgmt : %x "
3257 "macHeader->frameCtrl.MoreData : %x "
3258 "macHeader->frameCtrl.wep : %x "
3259 "macHeader->frameCtrl.order : %x "
3260 , macHeader->frameCtrl.protVer
3261 , macHeader->frameCtrl.type
3262 , macHeader->frameCtrl.subType
3263 , macHeader->frameCtrl.toDS
3264 , macHeader->frameCtrl.fromDS
3265 , macHeader->frameCtrl.moreFrag
3266 , macHeader->frameCtrl.retry
3267 , macHeader->frameCtrl.powerMgmt
3268 , macHeader->frameCtrl.moreData
3269 , macHeader->frameCtrl.wep
3270 , macHeader->frameCtrl.order);
3271
3272
3273 macHeader->usDurationId = getByte(&temp);
3274 macHeader->usDurationId += getByte(&temp) << 8;
3275
3276 macHeader->vA1[0] = getByte(&temp);
3277 macHeader->vA1[1] = getByte(&temp);
3278 macHeader->vA1[2] = getByte(&temp);
3279 macHeader->vA1[3] = getByte(&temp);
3280 macHeader->vA1[4] = getByte(&temp);
3281 macHeader->vA1[5] = getByte(&temp);
3282
3283 macHeader->vA2[0] = getByte(&temp);
3284 macHeader->vA2[1] = getByte(&temp);
3285 macHeader->vA2[2] = getByte(&temp);
3286 macHeader->vA2[3] = getByte(&temp);
3287 macHeader->vA2[4] = getByte(&temp);
3288 macHeader->vA2[5] = getByte(&temp);
3289
3290 macHeader->vA3[0] = getByte(&temp);
3291 macHeader->vA3[1] = getByte(&temp);
3292 macHeader->vA3[2] = getByte(&temp);
3293 macHeader->vA3[3] = getByte(&temp);
3294 macHeader->vA3[4] = getByte(&temp);
3295 macHeader->vA3[5] = getByte(&temp);
3296
3297 macHeader->sSeqCtrl = getByte(&temp);
3298 fragNum = macHeader->sSeqCtrl & 0xF;
3299 macHeader->sSeqCtrl >>= 4;
3300
3301 macHeader->sSeqCtrl += getByte(&temp) << 4;
3302
3303 macHeader->sSeqCtrl |= fragNum << 12;
3304
3305 if (length == 30 || length == 32) {
3306 macHeader->optvA4[0] = getByte(&temp);
3307 macHeader->optvA4[1] = getByte(&temp);
3308 macHeader->optvA4[2] = getByte(&temp);
3309 macHeader->optvA4[3] = getByte(&temp);
3310 macHeader->optvA4[4] = getByte(&temp);
3311 macHeader->optvA4[5] = getByte(&temp);
3312 }
3313
3314 if (length == 26 || length == 32) {
3315 macHeader->usQosCtrl = getByte(&temp);
3316 macHeader->usQosCtrl += getByte(&temp) << 8;
3317 }
3318
3319 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3320 (char *)&pkt->macHeader, sizeof(tSir80211Header), 0);
3321
3322 //parse payload
3323 length = getByte(&temp);
3324 length += getByte(&temp) << 8;
3325 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3326
3327 pkt->data.length = length;
3328
3329 for (i = 0; i< length; i++) {
3330 pkt->data.data[i] = getByte(&temp);
3331 }
3332
3333 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3334 &pkt->data.data[0], pkt->data.length, 0);
3335}
3336
3337/**---------------------------------------------------------------------------
3338
3339 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3340 encrypt message request
3341 This is an asynchronous callback function from SME when the encrypted data
3342 is received
3343
3344 \pEncInfoRsp -> Encrypted data info
3345
3346 \return - 0 for success non-zero for failure
3347 --------------------------------------------------------------------------*/
3348static void
3349hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3350{
3351 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3352
3353 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3354
3355 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3356 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3357 pEncryptedDataRsp->encryptedPayload.length);
3358 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3359 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3360 pEncryptedDataRsp->encryptedPayload.data,
3361 pEncryptedDataRsp->encryptedPayload.length, 0);
3362}
3363
Jeff Johnson295189b2012-06-20 16:38:30 -07003364VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3365{
3366 struct statsContext context;
3367 eHalStatus status;
3368 hdd_context_t *pHddCtx;
3369
3370 if (NULL == pAdapter)
3371 {
3372 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3373 return VOS_STATUS_E_FAULT;
3374 }
3375
3376 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3377 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303378 if (pHddCtx->isLogpInProgress) {
3379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3380 "%s:LOGP in Progress. Ignore!!!", __func__);
3381 return VOS_STATUS_E_FAILURE;
3382 }
3383
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 init_completion(&context.completion);
3385
3386 context.pAdapter = pAdapter;
3387 context.magic = POWER_CONTEXT_MAGIC;
3388
3389 if (DRIVER_POWER_MODE_ACTIVE == mode)
3390 {
3391 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3392 "Full Power", __func__);
3393 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3394 iw_power_callback_fn, &context,
3395 eSME_FULL_PWR_NEEDED_BY_HDD);
3396 // Enter Full power command received from GUI this means we are disconnected
3397 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3398 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3399 if (eHAL_STATUS_PMC_PENDING == status)
3400 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003401 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 int lrc = wait_for_completion_interruptible_timeout(
3403 &context.completion,
3404 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003405
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 if (lrc <= 0)
3407 {
3408 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003409 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 }
3411 }
3412 }
3413 else if (DRIVER_POWER_MODE_AUTO == mode)
3414 {
3415 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3416 {
3417 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3418 __func__);
3419 // Enter BMPS command received from GUI this means DHCP is completed
3420 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3421 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3422 FALSE);
3423 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3424 iw_power_callback_fn, &context);
3425 if (eHAL_STATUS_PMC_PENDING == status)
3426 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003427 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 int lrc = wait_for_completion_interruptible_timeout(
3429 &context.completion,
3430 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 if (lrc <= 0)
3432 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003433 hddLog(VOS_TRACE_LEVEL_ERROR,
3434 "%s: SME %s while requesting BMPS",
3435 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 }
3437 }
3438 }
3439 else
3440 {
3441 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3442 "enabled in the cfg");
3443 }
3444 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003445
3446 /* either we never sent a request, we sent a request and received a
3447 response or we sent a request and timed out. if we never sent a
3448 request or if we sent a request and got a response, we want to
3449 clear the magic out of paranoia. if we timed out there is a
3450 race condition such that the callback function could be
3451 executing at the same time we are. of primary concern is if the
3452 callback function had already verified the "magic" but had not
3453 yet set the completion variable when a timeout occurred. we
3454 serialize these activities by invalidating the magic while
3455 holding a shared spinlock which will cause us to block if the
3456 callback is currently executing */
3457 spin_lock(&hdd_context_lock);
3458 context.magic = 0;
3459 spin_unlock(&hdd_context_lock);
3460
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 return VOS_STATUS_SUCCESS;
3462}
3463
3464VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3465 hdd_adapter_t *pAdapter)
3466{
3467 VOS_STATUS vos_Status;
3468
3469 if ((NULL == pAdapter) || (NULL == pHddCtx))
3470 {
3471 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3472 return VOS_STATUS_E_FAULT;
3473 }
3474
3475 /**Exit from Deep sleep or standby if we get the driver
3476 START cmd from android GUI
3477 */
3478 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3479 {
3480 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3481 "from Stand by",__func__);
3482 vos_Status = hdd_exit_standby(pHddCtx);
3483 }
3484 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3485 {
3486 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3487 "from deep sleep",__func__);
3488 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3489 }
3490 else
3491 {
3492 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3493 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3494 vos_Status = VOS_STATUS_SUCCESS;
3495 }
3496
3497 return vos_Status;
3498}
3499
3500VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3501{
3502 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3503
3504 if (NULL == pHddCtx)
3505 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303506 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 return VOS_STATUS_E_FAULT;
3508 }
3509
3510 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3511 {
3512 //Execute standby procedure.
3513 //Executing standby procedure will cause the STA to
3514 //disassociate first and then the chip will be put into standby.
3515 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3516 vos_Status = hdd_enter_standby(pHddCtx);
3517 }
3518 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3519 pHddCtx->cfg_ini->nEnableDriverStop)
3520 {
3521 //Execute deep sleep procedure
3522 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003523 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 //Deep sleep not supported
3525 vos_Status = hdd_enter_standby(pHddCtx);
3526 }
3527 else
3528 {
3529 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3530 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3531 vos_Status = VOS_STATUS_SUCCESS;
3532 }
3533
3534 return vos_Status;
3535}
3536
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003537
3538void* wlan_hdd_change_country_code_callback(void *pAdapter)
3539{
3540
3541 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003542 complete(&call_back_pAdapter->change_country_code);
3543
3544 return NULL;
3545}
3546
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303547static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 struct iw_request_info *info,
3549 union iwreq_data *wrqu, char *extra)
3550{
3551 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08003552 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 int cmd_len = wrqu->data.length;
3554 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003555 int rc = 0;
3556 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3557
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3559
3560 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08003561 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3562 wrqu->data.length);
3563 if (NULL == cmd)
3564 {
3565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3566 "mem_alloc_copy_from_user_helper fail");
3567 return -ENOMEM;
3568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003569
3570 if (ioctl_debug)
3571 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003572 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 }
3574
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003575 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3576 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003577
3578 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003579 if (ioctl_debug)
3580 {
3581 pr_info("%s: RESTART in progress\n", __func__);
3582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003583
Arif Hussain24bfa702014-01-22 13:51:30 -08003584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003585 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003586 kfree(cmd);
3587 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 }
3589
Arif Hussain24bfa702014-01-22 13:51:30 -08003590 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003592 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3594 "%s: Error in iw_set_scan!", __func__);
3595 rc = -EINVAL;
3596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003597 }
3598 else if( strcasecmp(cmd, "start") == 0 ) {
3599
Arif Hussain6d2a3322013-11-17 19:50:10 -08003600 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003601 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003602
Arif Hussain24bfa702014-01-22 13:51:30 -08003603 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3604 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 {
3606 union iwreq_data wrqu;
3607 char buf[10];
3608
3609 memset(&wrqu, 0, sizeof(wrqu));
3610 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3611 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3612 }
3613 else
3614 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003615 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3616 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 }
3618 goto done;
3619 }
3620 else if( strcasecmp(cmd, "stop") == 0 )
3621 {
3622 union iwreq_data wrqu;
3623 char buf[10];
3624
Arif Hussain6d2a3322013-11-17 19:50:10 -08003625 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003626
3627 wlan_hdd_enter_lowpower(pHddCtx);
3628 memset(&wrqu, 0, sizeof(wrqu));
3629 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3630 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 goto done;
3632 }
3633 else if (strcasecmp(cmd, "macaddr") == 0)
3634 {
3635 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3636 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3637 }
3638 else if (strcasecmp(cmd, "scan-active") == 0)
3639 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303640 hddLog(VOS_TRACE_LEVEL_ERROR,
3641 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003642 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 ret = snprintf(cmd, cmd_len, "OK");
3644 }
3645 else if (strcasecmp(cmd, "scan-passive") == 0)
3646 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303647 hddLog(VOS_TRACE_LEVEL_ERROR,
3648 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003649 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 ret = snprintf(cmd, cmd_len, "OK");
3651 }
3652 else if( strcasecmp(cmd, "scan-mode") == 0 )
3653 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003654 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 }
3656 else if( strcasecmp(cmd, "linkspeed") == 0 )
3657 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003658 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 }
3660 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3661 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003662 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003663 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003664
3665 country_code = cmd + 8;
3666
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003667 init_completion(&pAdapter->change_country_code);
3668
Arif Hussain24bfa702014-01-22 13:51:30 -08003669 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003670 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 country_code,
3672 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303673 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303674 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303675 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003676
3677 /* Wait for completion */
3678 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3679 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3680
3681 if (lrc <= 0)
3682 {
3683 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003684 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003685 }
3686
Arif Hussain24bfa702014-01-22 13:51:30 -08003687 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003689 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003690 "%s: SME Change Country code fail", __func__);
3691 kfree(cmd);
3692 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 }
3694 }
3695 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3696 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003697 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 }
3699 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3700 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003701 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003702
Wilson Yang1be3e652013-10-09 15:18:31 -07003703 if (9 < cmd_len)
3704 {
3705 ptr = (char*)(cmd + 9);
3706
3707 }else{
3708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3709 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003710 kfree(cmd);
3711 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003712 }
3713
3714 if (1 != sscanf(ptr,"%d",&mode))
3715 {
3716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3717 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003718 kfree(cmd);
3719 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003720 }
3721
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 wlan_hdd_enter_bmps(pAdapter, mode);
3723 /*TODO:Set the power mode*/
3724 }
3725 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3726 v_U32_t pmc_state;
3727 v_U16_t value;
3728
3729 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3730 if(pmc_state == BMPS) {
3731 value = DRIVER_POWER_MODE_AUTO;
3732 }
3733 else {
3734 value = DRIVER_POWER_MODE_ACTIVE;
3735 }
3736 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3737 }
3738 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003739 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 /*TODO: set the btcoexmode*/
3741 }
3742 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3743
Arif Hussain6d2a3322013-11-17 19:50:10 -08003744 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 /*TODO: Return the btcoex status*/
3746 }
3747 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3748
Arif Hussain6d2a3322013-11-17 19:50:10 -08003749 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003750
3751 /*TODO: Enable Rx data Filter*/
3752 }
3753 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3754
Arif Hussain6d2a3322013-11-17 19:50:10 -08003755 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003756
3757 /*TODO: Disable Rx data Filter*/
3758 }
3759 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3760
Arif Hussain6d2a3322013-11-17 19:50:10 -08003761 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 /*TODO: rxfilter-statistics*/
3763 }
3764 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3765
Arif Hussain6d2a3322013-11-17 19:50:10 -08003766 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 /*TODO: rxfilter-add*/
3768 }
3769 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3770
Arif Hussain6d2a3322013-11-17 19:50:10 -08003771 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 /*TODO: rxfilter-remove*/
3773 }
3774#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003775 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3776 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3777 /*TODO: support pnosetup*/
3778 }
3779 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3780 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3781 /*TODO: support pnoforce*/
3782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3784
Arif Hussain6d2a3322013-11-17 19:50:10 -08003785 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003786 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3787 kfree(cmd);
3788 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 }
3790 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003791 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003792 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3793 kfree(cmd);
3794 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 }
3796#endif /*FEATURE_WLAN_SCAN_PNO*/
3797 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003798 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003799 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3800 kfree(cmd);
3801 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 }
3803 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3804 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003805 char *ptr;
3806
3807 if (18 < cmd_len)
3808 {
3809 ptr = (char*)(cmd + 18);
3810 }else{
3811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3812 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003813 kfree(cmd);
3814 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003815 }
3816
Jeff Johnson02797792013-10-26 19:17:13 -07003817 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003818 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3819 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3820 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3821 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3822 {
3823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3824 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003825 kfree(cmd);
3826 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003828
3829 // parameters checking
3830 // period has to be larger than 0
3831 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3832 {
3833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003834 kfree(cmd);
3835 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 }
3837
3838 // use default value 5 is the input is not reasonable. in unit of 10%
3839 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3840 {
3841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3842 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3843 }
3844
3845 // default is 5
3846 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3847 {
3848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3849 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3850 }
3851
Arif Hussain24bfa702014-01-22 13:51:30 -08003852 if (eHAL_STATUS_SUCCESS !=
3853 sme_SetTxPerTracking(pHddCtx->hHal,
3854 hdd_tx_per_hit_cb,
3855 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003857 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 }
3859 }
3860 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003861 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3862 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 }
3864done:
3865 /* many of the commands write information back into the command
3866 string using snprintf(). check the return value here in one
3867 place */
3868 if ((ret < 0) || (ret >= cmd_len))
3869 {
3870 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003871 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003873 else if (ret > 0)
3874 {
3875 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3876 {
3877 hddLog(VOS_TRACE_LEVEL_ERROR,
3878 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003879 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003880 return -EFAULT;
3881 }
3882 wrqu->data.length = ret;
3883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003884
3885 if (ioctl_debug)
3886 {
3887 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003888 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003890 kfree(cmd);
3891 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003892}
3893
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303894static int iw_set_priv(struct net_device *dev,
3895 struct iw_request_info *info,
3896 union iwreq_data *wrqu, char *extra)
3897{
3898 int ret;
3899 vos_ssr_protect(__func__);
3900 ret = __iw_set_priv(dev, info, wrqu, extra);
3901 vos_ssr_unprotect(__func__);
3902
3903 return ret;
3904}
3905
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303906static int __iw_set_nick(struct net_device *dev,
3907 struct iw_request_info *info,
3908 union iwreq_data *wrqu, char *extra)
3909{
3910 ENTER();
3911 return 0;
3912}
3913
Jeff Johnson295189b2012-06-20 16:38:30 -07003914static int iw_set_nick(struct net_device *dev,
3915 struct iw_request_info *info,
3916 union iwreq_data *wrqu, char *extra)
3917{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303918 int ret;
3919
3920 vos_ssr_protect(__func__);
3921 ret = __iw_set_nick(dev, info, wrqu, extra);
3922 vos_ssr_unprotect(__func__);
3923
3924 return ret;
3925}
3926
3927static int __iw_get_nick(struct net_device *dev,
3928 struct iw_request_info *info,
3929 union iwreq_data *wrqu, char *extra)
3930{
Jeff Johnson295189b2012-06-20 16:38:30 -07003931 ENTER();
3932 return 0;
3933}
3934
3935static int iw_get_nick(struct net_device *dev,
3936 struct iw_request_info *info,
3937 union iwreq_data *wrqu, char *extra)
3938{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303939 int ret;
3940
3941 vos_ssr_protect(__func__);
3942 ret = __iw_get_nick(dev, info, wrqu, extra);
3943 vos_ssr_unprotect(__func__);
3944
3945 return ret;
3946}
3947
3948static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
3949{
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303951 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003952}
3953
3954static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3955{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303956
3957 struct iw_statistics *stats;
3958
3959 vos_ssr_protect(__func__);
3960 stats = __get_wireless_stats(dev);
3961 vos_ssr_unprotect(__func__);
3962
3963 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07003964}
3965
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303966static int __iw_set_encode(struct net_device *dev,
3967 struct iw_request_info *info,
3968 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003969
3970{
3971 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3972 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3973 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3974 struct iw_point *encoderq = &(wrqu->encoding);
3975 v_U32_t keyId;
3976 v_U8_t key_length;
3977 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3978 v_BOOL_t fKeyPresent = 0;
3979 int i;
3980 eHalStatus status = eHAL_STATUS_SUCCESS;
3981
3982
3983 ENTER();
3984
3985 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3986 {
3987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3988 "%s:LOGP in Progress. Ignore!!!",__func__);
3989 return 0;
3990 }
3991
3992
3993 keyId = encoderq->flags & IW_ENCODE_INDEX;
3994
3995 if(keyId)
3996 {
3997 if(keyId > MAX_WEP_KEYS)
3998 {
3999 return -EINVAL;
4000 }
4001
4002 fKeyPresent = 1;
4003 keyId--;
4004 }
4005 else
4006 {
4007 fKeyPresent = 0;
4008 }
4009
4010
4011 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4012 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 if(!fKeyPresent) {
4015
4016 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4017
4018 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4019 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4020 }
4021 }
4022 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4023 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4024 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4025 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4026
4027 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4028 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4029
4030 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4031 {
4032 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4033 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004034 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304035 {
4036 long ret;
4037 ret = wait_for_completion_interruptible_timeout(
4038 &pAdapter->disconnect_comp_var,
4039 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4040 if (ret <= 0)
4041 hddLog(VOS_TRACE_LEVEL_ERROR,
4042 FL("failed wait on disconnect_comp_var %ld"), ret);
4043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 }
4045
4046 return status;
4047
4048 }
4049
4050 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4051 {
4052 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4053
4054 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4055
4056 }
4057
4058
4059 if(wrqu->data.length > 0)
4060 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004061 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004062
4063 key_length = wrqu->data.length;
4064
4065 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4066
4067 if(5 == key_length)
4068 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004069 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004070
4071 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4072 {
4073 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4074 }
4075 else
4076 {
4077 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4078 }
4079 }
4080 else if(13 == key_length)
4081 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004082 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004083
4084 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4085 {
4086 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4087 }
4088 else
4089 {
4090 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4091 }
4092 }
4093 else
4094 {
4095 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004096 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 return -EINVAL;
4098 }
4099
4100 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4101 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4102 pWextState->roamProfile.EncryptionType.numEntries = 1;
4103 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4104 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4105 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4106
4107 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4108 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4109 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4110 {
4111
4112 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4113
4114 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4115 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4116
4117 return status;
4118 }
4119 }
4120
4121 return 0;
4122}
4123
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304124static int iw_set_encode(struct net_device *dev,
4125 struct iw_request_info *info,
4126 union iwreq_data *wrqu,char *extra)
4127{
4128 int ret;
4129
4130 vos_ssr_protect(__func__);
4131 ret = __iw_set_encode(dev, info, wrqu, extra);
4132 vos_ssr_unprotect(__func__);
4133
4134 return ret;
4135}
4136
4137static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 struct iw_request_info *info,
4139 struct iw_point *dwrq,
4140 char *extra)
4141{
4142 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4143 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4144 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4145 int keyId;
4146 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4147 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4148 int i;
4149
4150 ENTER();
4151
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004152 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4153 {
4154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4155 "%s:LOGP in Progress. Ignore!!!", __func__);
4156 return -EBUSY;
4157 }
4158
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 keyId = pRoamProfile->Keys.defaultIndex;
4160
4161 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4162 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004163 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 return -EINVAL;
4165 }
4166
4167 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4168 {
4169 dwrq->flags |= IW_ENCODE_ENABLED;
4170 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304171 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4172 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 }
4174 else
4175 {
4176 dwrq->flags |= IW_ENCODE_DISABLED;
4177 }
4178
4179 for(i=0; i < MAX_WEP_KEYS; i++)
4180 {
4181 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4182 {
4183 continue;
4184 }
4185 else
4186 {
4187 break;
4188 }
4189 }
4190
4191 if(MAX_WEP_KEYS == i)
4192 {
4193 dwrq->flags |= IW_ENCODE_NOKEY;
4194 }
4195 else
4196 {
4197 dwrq->flags |= IW_ENCODE_ENABLED;
4198 }
4199
4200 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4201
4202 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4203 {
4204 dwrq->flags |= IW_ENCODE_DISABLED;
4205 }
4206
4207 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4208
4209 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4210 {
4211 dwrq->flags |= IW_ENCODE_OPEN;
4212 }
4213 else
4214 {
4215 dwrq->flags |= IW_ENCODE_RESTRICTED;
4216 }
4217 EXIT();
4218 return 0;
4219
4220}
4221
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304222static int iw_get_encodeext(struct net_device *dev,
4223 struct iw_request_info *info,
4224 struct iw_point *dwrq,
4225 char *extra)
4226{
4227 int ret;
4228 vos_ssr_protect(__func__);
4229 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4230 vos_ssr_unprotect(__func__);
4231
4232 return ret;
4233}
4234
4235static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 struct iw_request_info *info,
4237 union iwreq_data *wrqu, char *extra)
4238{
4239 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4240 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4241 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4242 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
4243
4244 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4245 v_U32_t status = 0;
4246
4247 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4248
4249 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4250
4251 int key_index;
4252 struct iw_point *encoding = &wrqu->encoding;
4253 tCsrRoamSetKey setKey;
4254 v_U32_t roamId= 0xFF;
4255 VOS_STATUS vos_status;
4256
4257 ENTER();
4258
4259 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4260 {
4261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4262 "%s:LOGP in Progress. Ignore!!!",__func__);
4263 return 0;
4264 }
4265
4266 key_index = encoding->flags & IW_ENCODE_INDEX;
4267
4268 if(key_index > 0) {
4269
4270 /*Convert from 1-based to 0-based keying*/
4271 key_index--;
4272 }
4273 if(!ext->key_len) {
4274
4275 /*Set the encrytion type to NONE*/
4276 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4277 return status;
4278 }
4279
4280 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4281 (IW_ENCODE_ALG_WEP == ext->alg))
4282 {
4283 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4284
Agarwal Ashish971c2882013-10-30 20:11:12 +05304285 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4286 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 return -EINVAL;
4288 }
4289 else {
4290 /*Static wep, update the roam profile with the keys */
4291 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4292 key_index < CSR_MAX_NUM_KEY) {
4293 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4294 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4295
4296 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4297 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4298
4299 }
4300 }
4301 return status;
4302 }
4303
4304 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4305
4306 setKey.keyId = key_index;
4307 setKey.keyLength = ext->key_len;
4308
4309 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4310 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4311 }
4312
4313 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4314 /*Key direction for group is RX only*/
4315 setKey.keyDirection = eSIR_RX_ONLY;
4316 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4317 }
4318 else {
4319
4320 setKey.keyDirection = eSIR_TX_RX;
4321 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4322 }
4323
4324 /*For supplicant pae role is zero*/
4325 setKey.paeRole = 0;
4326
4327 switch(ext->alg)
4328 {
4329 case IW_ENCODE_ALG_NONE:
4330 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4331 break;
4332
4333 case IW_ENCODE_ALG_WEP:
4334 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4335 break;
4336
4337 case IW_ENCODE_ALG_TKIP:
4338 {
4339 v_U8_t *pKey = &setKey.Key[0];
4340
4341 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4342
4343 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4344
4345 /*Supplicant sends the 32bytes key in this order
4346
4347 |--------------|----------|----------|
4348 | Tk1 |TX-MIC | RX Mic |
4349 |--------------|----------|----------|
4350 <---16bytes---><--8bytes--><--8bytes-->
4351
4352 */
4353 /*Sme expects the 32 bytes key to be in the below order
4354
4355 |--------------|----------|----------|
4356 | Tk1 |RX-MIC | TX Mic |
4357 |--------------|----------|----------|
4358 <---16bytes---><--8bytes--><--8bytes-->
4359 */
4360 /* Copy the Temporal Key 1 (TK1) */
4361 vos_mem_copy(pKey,ext->key,16);
4362
4363 /*Copy the rx mic first*/
4364 vos_mem_copy(&pKey[16],&ext->key[24],8);
4365
4366 /*Copy the tx mic */
4367 vos_mem_copy(&pKey[24],&ext->key[16],8);
4368
4369 }
4370 break;
4371
4372 case IW_ENCODE_ALG_CCMP:
4373 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4374 break;
4375
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004376#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004377#define IW_ENCODE_ALG_KRK 6
4378 case IW_ENCODE_ALG_KRK:
4379 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4380 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004381#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004382
4383 default:
4384 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4385 break;
4386 }
4387
4388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004389 ("%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 -07004390
4391#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304392 /* The supplicant may attempt to set the PTK once pre-authentication
4393 is done. Save the key in the UMAC and include it in the ADD
4394 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304396 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304398 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4399 "%s: Update PreAuth Key success", __func__);
4400 return 0;
4401 }
4402 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4403 {
4404 hddLog(VOS_TRACE_LEVEL_ERROR,
4405 "%s: Update PreAuth Key failed", __func__);
4406 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 }
4408#endif /* WLAN_FEATURE_VOWIFI_11R */
4409
4410 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4411
4412 vos_status = wlan_hdd_check_ula_done(pAdapter);
4413 if ( vos_status != VOS_STATUS_SUCCESS )
4414 {
4415 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4416 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
4417 __LINE__, vos_status );
4418
4419 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4420 }
4421
4422 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
4423
4424 if ( halStatus != eHAL_STATUS_SUCCESS )
4425 {
4426 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4427 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4428 __LINE__, halStatus );
4429
4430 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4431 }
4432
4433 return halStatus;
4434}
4435
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304436static int iw_set_encodeext(struct net_device *dev,
4437 struct iw_request_info *info,
4438 union iwreq_data *wrqu, char *extra)
4439{
4440 int ret;
4441
4442 vos_ssr_protect(__func__);
4443 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4444 vos_ssr_unprotect(__func__);
4445
4446 return ret;
4447}
4448
4449static int __iw_set_retry(struct net_device *dev,
4450 struct iw_request_info *info,
4451 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004452{
4453 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4454 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4455
4456 ENTER();
4457
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004458 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4459 {
4460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4461 "%s:LOGP in Progress. Ignore!!!", __func__);
4462 return -EBUSY;
4463 }
4464
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4466 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4467
Arif Hussain6d2a3322013-11-17 19:50:10 -08004468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004469
4470 return -EINVAL;
4471 }
4472
4473 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
4474
4475 if((wrqu->retry.flags & IW_RETRY_LONG))
4476 {
4477 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
4478 {
c_hpothub8245442013-11-20 23:41:09 +05304479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4480 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 return -EIO;
4482 }
4483 }
4484 else if((wrqu->retry.flags & IW_RETRY_SHORT))
4485 {
4486 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
4487 {
c_hpothub8245442013-11-20 23:41:09 +05304488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4489 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 return -EIO;
4491 }
4492 }
4493 }
4494 else
4495 {
4496 return -EOPNOTSUPP;
4497 }
4498
Arif Hussain6d2a3322013-11-17 19:50:10 -08004499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004500
4501 EXIT();
4502
4503 return 0;
4504
4505}
4506
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304507static int iw_set_retry(struct net_device *dev,
4508 struct iw_request_info *info,
4509 union iwreq_data *wrqu, char *extra)
4510{
4511 int ret;
4512
4513 vos_ssr_protect(__func__);
4514 ret = __iw_set_retry(dev, info, wrqu, extra);
4515 vos_ssr_unprotect(__func__);
4516
4517 return ret;
4518}
4519
4520static int __iw_get_retry(struct net_device *dev,
4521 struct iw_request_info *info,
4522 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004523{
4524 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4525 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4526 v_U32_t retry = 0;
4527
4528 ENTER();
4529
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004530 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4531 {
4532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4533 "%s:LOGP in Progress. Ignore!!!", __func__);
4534 return -EBUSY;
4535 }
4536
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 if((wrqu->retry.flags & IW_RETRY_LONG))
4538 {
4539 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
4540
4541 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
4542 {
c_hpothub8245442013-11-20 23:41:09 +05304543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4544 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 return -EIO;
4546 }
4547
4548 wrqu->retry.value = retry;
4549 }
4550 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
4551 {
4552 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
4553
4554 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
4555 {
c_hpothub8245442013-11-20 23:41:09 +05304556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4557 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 return -EIO;
4559 }
4560
4561 wrqu->retry.value = retry;
4562 }
4563 else {
4564 return -EOPNOTSUPP;
4565 }
4566
Arif Hussain6d2a3322013-11-17 19:50:10 -08004567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004568
4569 EXIT();
4570
4571 return 0;
4572}
4573
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304574static int iw_get_retry(struct net_device *dev,
4575 struct iw_request_info *info,
4576 union iwreq_data *wrqu, char *extra)
4577{
4578 int ret;
4579
4580 vos_ssr_protect(__func__);
4581 ret = __iw_get_retry(dev, info, wrqu, extra);
4582 vos_ssr_unprotect(__func__);
4583
4584 return ret;
4585}
4586
4587static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 struct iw_request_info *info,
4589 union iwreq_data *wrqu,
4590 char *extra)
4591{
4592 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4593 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4594 struct iw_mlme *mlme = (struct iw_mlme *)extra;
4595 eHalStatus status = eHAL_STATUS_SUCCESS;
4596
4597 ENTER();
4598
4599 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4600 {
4601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4602 "%s:LOGP in Progress. Ignore!!!",__func__);
4603 return 0;
4604 }
4605
4606 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
4607 switch (mlme->cmd) {
4608 case IW_MLME_DISASSOC:
4609 case IW_MLME_DEAUTH:
4610
4611 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
4612 {
4613 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4614
4615 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4616 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4617
4618 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4619 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
4620
Jeff Johnson43971f52012-07-17 12:26:56 -07004621 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304622 {
4623 long ret;
4624 ret = wait_for_completion_interruptible_timeout(
4625 &pAdapter->disconnect_comp_var,
4626 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4627 if (ret <= 0)
4628 hddLog(VOS_TRACE_LEVEL_ERROR,
4629 FL("failed wait on disconnect_comp_var %ld"), ret);
4630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08004632 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004633 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07004634
4635 /* Resetting authKeyMgmt */
4636 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
4637
4638 netif_tx_disable(dev);
4639 netif_carrier_off(dev);
4640
4641 }
4642 else
4643 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004644 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 -07004645 }
4646 break;
4647 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004648 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 return -EINVAL;
4650 }//end of switch
4651
4652 EXIT();
4653
4654 return status;
4655
4656}
4657
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304658static int iw_set_mlme(struct net_device *dev,
4659 struct iw_request_info *info,
4660 union iwreq_data *wrqu,
4661 char *extra)
4662{
4663 int ret;
4664
4665 vos_ssr_protect(__func__);
4666 ret = __iw_set_mlme(dev, info, wrqu, extra);
4667 vos_ssr_unprotect(__func__);
4668
4669 return ret;
4670}
4671
Jeff Johnson295189b2012-06-20 16:38:30 -07004672/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05304673static int __iw_setint_getnone(struct net_device *dev,
4674 struct iw_request_info *info,
4675 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004676{
4677 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4678 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4679 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
c_hpothu4a298be2014-12-22 21:12:51 +05304680 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 int *value = (int *)extra;
4682 int sub_cmd = value[0];
4683 int set_value = value[1];
4684 int ret = 0; /* success */
4685 int enable_pbm, enable_mp;
4686#ifdef CONFIG_HAS_EARLYSUSPEND
4687 v_U8_t nEnableSuspendOld;
4688#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004689
c_hpothu4a298be2014-12-22 21:12:51 +05304690 if (0 != wlan_hdd_validate_context(pHddCtx))
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004691 {
c_hpothu4a298be2014-12-22 21:12:51 +05304692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004693 return -EBUSY;
4694 }
4695
c_hpothu4a298be2014-12-22 21:12:51 +05304696 INIT_COMPLETION(pWextState->completion_var);
4697
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 switch(sub_cmd)
4699 {
4700 case WE_SET_11D_STATE:
4701 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004702 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004703 memset(&smeConfig, 0x00, sizeof(smeConfig));
4704
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4706
4707 sme_GetConfigParam(hHal,&smeConfig);
4708 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4709
Arif Hussain6d2a3322013-11-17 19:50:10 -08004710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004711
4712 sme_UpdateConfig(hHal,&smeConfig);
4713 }
4714 else {
4715 return -EINVAL;
4716 }
4717 break;
4718 }
4719
4720 case WE_WOWL:
4721 {
4722 switch (set_value)
4723 {
4724 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05304725 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 break;
4727 case 0x01:
4728 case 0x02:
4729 case 0x03:
4730 enable_mp = (set_value & 0x01) ? 1 : 0;
4731 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004732 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4734 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4735 break;
4736 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004737 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 ret = -EINVAL;
4739 break;
4740 }
4741
4742 break;
4743 }
4744 case WE_SET_POWER:
4745 {
4746 switch (set_value)
4747 {
4748 case 0: //Full Power
4749 {
4750 struct statsContext context;
4751 eHalStatus status;
4752
4753 init_completion(&context.completion);
4754
4755 context.pAdapter = pAdapter;
4756 context.magic = POWER_CONTEXT_MAGIC;
4757
4758 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4759 iw_power_callback_fn, &context,
4760 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004761 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 {
4763 int lrc = wait_for_completion_interruptible_timeout(
4764 &context.completion,
4765 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004766
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 if (lrc <= 0)
4768 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004769 hddLog(VOS_TRACE_LEVEL_ERROR,
4770 "%s: SME %s while requesting fullpower",
4771 __func__, (0 == lrc) ?
4772 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 }
4774 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004775 /* either we have a response or we timed out. if we timed
4776 out there is a race condition such that the callback
4777 function could be executing at the same time we are. of
4778 primary concern is if the callback function had already
4779 verified the "magic" but had not yet set the completion
4780 variable when a timeout occurred. we serialize these
4781 activities by invalidating the magic while holding a
4782 shared spinlock which will cause us to block if the
4783 callback is currently executing */
4784 spin_lock(&hdd_context_lock);
4785 context.magic = 0;
4786 spin_unlock(&hdd_context_lock);
4787
Arif Hussain6d2a3322013-11-17 19:50:10 -08004788 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 break;
4790 }
4791 case 1: //Enable BMPS
4792 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4793 break;
4794 case 2: //Disable BMPS
4795 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4796 break;
4797 case 3: //Request Bmps
4798 {
4799 struct statsContext context;
4800 eHalStatus status;
4801
4802 init_completion(&context.completion);
4803
4804 context.pAdapter = pAdapter;
4805 context.magic = POWER_CONTEXT_MAGIC;
4806
4807 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4808 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004809 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 {
4811 int lrc = wait_for_completion_interruptible_timeout(
4812 &context.completion,
4813 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 if (lrc <= 0)
4815 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004816 hddLog(VOS_TRACE_LEVEL_ERROR,
4817 "%s: SME %s while requesting BMPS",
4818 __func__, (0 == lrc) ? "timeout" :
4819 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 }
4821 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004822 /* either we have a response or we timed out. if we
4823 timed out there is a race condition such that the
4824 callback function could be executing at the same
4825 time we are. of primary concern is if the callback
4826 function had already verified the "magic" but had
4827 not yet set the completion variable when a timeout
4828 occurred. we serialize these activities by
4829 invalidating the magic while holding a shared
4830 spinlock which will cause us to block if the
4831 callback is currently executing */
4832 spin_lock(&hdd_context_lock);
4833 context.magic = 0;
4834 spin_unlock(&hdd_context_lock);
4835
Arif Hussain6d2a3322013-11-17 19:50:10 -08004836 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 break;
4838 }
4839 case 4: //Enable IMPS
4840 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4841 break;
4842 case 5: //Disable IMPS
4843 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4844 break;
4845 case 6: //Enable Standby
4846 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4847 break;
4848 case 7: //Disable Standby
4849 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4850 break;
4851 case 8: //Request Standby
4852#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004853#endif
4854 break;
4855 case 9: //Start Auto Bmps Timer
4856 sme_StartAutoBmpsTimer(hHal);
4857 break;
4858 case 10://Stop Auto BMPS Timer
4859 sme_StopAutoBmpsTimer(hHal);
4860 break;
4861#ifdef CONFIG_HAS_EARLYSUSPEND
4862 case 11://suspend to standby
4863#ifdef CONFIG_HAS_EARLYSUSPEND
4864 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4865 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4867#endif
4868 break;
4869 case 12://suspend to deep sleep
4870#ifdef CONFIG_HAS_EARLYSUSPEND
4871 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4872 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4874#endif
4875 break;
4876 case 13://resume from suspend
4877#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004878#endif
4879 break;
4880#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004882 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 ret = -EINVAL;
4884 break;
4885 }
4886 break;
4887 }
4888
4889 case WE_SET_MAX_ASSOC:
4890 {
4891 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4892 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4893 {
4894 ret = -EINVAL;
4895 }
4896 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4897 set_value, NULL, eANI_BOOLEAN_FALSE)
4898 != eHAL_STATUS_SUCCESS )
4899 {
c_hpothub8245442013-11-20 23:41:09 +05304900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4901 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 ret = -EIO;
4903 }
4904 break;
4905 }
4906
4907 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4908 {
4909 if( 0 == set_value )
4910 {
4911 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4912 }
4913 else if ( 1 == set_value )
4914 {
4915 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4916 }
4917 else
4918 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004919 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 ret = -EINVAL;
4921 }
4922 break;
4923 }
4924
4925 case WE_SET_DATA_INACTIVITY_TO:
4926 {
4927 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4928 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4929 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4930 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4931 set_value,
4932 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4933 {
4934 hddLog(LOGE,"Failure: Could not pass on "
4935 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004936 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 ret = -EINVAL;
4938 }
4939 break;
4940 }
4941 case WE_SET_MAX_TX_POWER:
4942 {
4943 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4944 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4945
4946 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4947 __func__, set_value);
4948 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4949 eHAL_STATUS_SUCCESS )
4950 {
4951 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4952 __func__);
4953 return -EIO;
4954 }
4955
4956 break;
4957 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004958 case WE_SET_MAX_TX_POWER_2_4:
4959 {
4960 hddLog(VOS_TRACE_LEVEL_INFO,
4961 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4962 __func__, set_value);
4963 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4964 eHAL_STATUS_SUCCESS)
4965 {
4966 hddLog(VOS_TRACE_LEVEL_ERROR,
4967 "%s: Setting maximum tx power failed for 2.4 GHz band",
4968 __func__);
4969 return -EIO;
4970 }
4971
4972 break;
4973 }
4974 case WE_SET_MAX_TX_POWER_5_0:
4975 {
4976 hddLog(VOS_TRACE_LEVEL_INFO,
4977 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4978 __func__, set_value);
4979 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4980 eHAL_STATUS_SUCCESS)
4981 {
4982 hddLog(VOS_TRACE_LEVEL_ERROR,
4983 "%s: Setting maximum tx power failed for 5.0 GHz band",
4984 __func__);
4985 return -EIO;
4986 }
4987
4988 break;
4989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 case WE_SET_HIGHER_DTIM_TRANSITION:
4991 {
4992 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4993 (set_value == eANI_BOOLEAN_TRUE)))
4994 {
4995 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4996 ret = -EINVAL;
4997 }
4998 else
4999 {
5000 if(pAdapter->higherDtimTransition != set_value)
5001 {
5002 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005003 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 }
5005 }
5006
5007 break;
5008 }
5009
5010 case WE_SET_TM_LEVEL:
5011 {
5012 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005013 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5015
5016 break;
5017 }
5018
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305019 case WE_ENABLE_STRICT_FCC_REG:
5020 {
5021 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5022 struct wiphy *wiphy = NULL;
5023 long lrc;
5024 int status;
5025
5026 wiphy = hddCtxt->wiphy;
5027 if(wiphy == NULL)
5028 {
5029 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5030 break;
5031 }
5032 init_completion(&hddCtxt->wiphy_channel_update_event);
5033
5034 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5035
5036 status = regulatory_hint(wiphy, "00");
5037 if(status < 0)
5038 {
5039 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5040 break;
5041 }
5042
5043 /* Wait for completion */
5044 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5045 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5046 if (lrc <= 0)
5047 {
5048 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5049 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5050 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5051 }
5052 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5053
5054 break;
5055 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005056 case WE_SET_DEBUG_LOG:
5057 {
5058 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5059 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5060 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5061 break;
5062 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305063#ifdef FEATURE_WLAN_TDLS
5064 case WE_SET_TDLS_OFF_CHAN:
5065 {
5066 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5068 __func__, set_value);
5069 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5070 break;
5071 }
5072 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5073 {
5074 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5076 __func__, set_value);
5077 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5078 break;
5079 }
5080 case WE_SET_TDLS_OFF_CHAN_MODE:
5081 {
5082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5083 __func__, set_value);
5084 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5085 break;
5086 }
5087#endif
Peng Xu2446a892014-09-05 17:21:18 +05305088 case WE_SET_SCAN_BAND_PREFERENCE:
5089 {
5090 tSmeConfigParams smeConfig;
5091 memset(&smeConfig, 0x00, sizeof(smeConfig));
5092 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5093 ret = -EINVAL;
5094 break;
5095 }
5096 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5097
5098 if (eCSR_BAND_ALL == set_value ||
5099 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5100 sme_GetConfigParam(hHal, &smeConfig);
5101 smeConfig.csrConfig.scanBandPreference = set_value;
5102
5103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5104 "set band scan preference = %d\n",
5105 smeConfig.csrConfig.scanBandPreference);
5106
5107 sme_UpdateConfig(hHal, &smeConfig);
5108 }
5109 else {
5110 ret = -EINVAL;
5111 }
5112 break;
5113 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305114
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 default:
5116 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005117 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 sub_cmd, set_value);
5119 break;
5120 }
5121 }
5122
5123 return ret;
5124}
5125
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305126static int iw_setint_getnone(struct net_device *dev,
5127 struct iw_request_info *info,
5128 union iwreq_data *wrqu, char *extra)
5129{
5130 int ret;
5131
5132 vos_ssr_protect(__func__);
5133 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5134 vos_ssr_unprotect(__func__);
5135
5136 return 0;
5137}
Jeff Johnson295189b2012-06-20 16:38:30 -07005138/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305139static int __iw_setchar_getnone(struct net_device *dev,
5140 struct iw_request_info *info,
5141 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005142{
5143 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305144 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005146 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 hdd_adapter_t *pAdapter = (netdev_priv(dev));
5148 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5149#ifdef WLAN_FEATURE_VOWIFI
5150 hdd_config_t *pConfig = pHddCtx->cfg_ini;
5151#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305152 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305153 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005154
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005155 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5156 {
5157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5158 "%s:LOGP in Progress. Ignore!!!", __func__);
5159 return -EBUSY;
5160 }
5161
Girish Gowli552fc072014-06-14 18:26:16 +05305162 /* helper function to get iwreq_data with compat handling. */
5163 if (hdd_priv_get_data(&s_priv_data, wrqu))
5164 {
5165 return -EINVAL;
5166 }
5167
5168 /* make sure all params are correctly passed to function */
5169 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5170 {
5171 return -EINVAL;
5172 }
5173
5174 sub_cmd = s_priv_data.flags;
5175
Arif Hussain0273cba2014-01-07 20:58:29 -08005176 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305177 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5178 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005179 if (NULL == pBuffer)
5180 {
5181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5182 "mem_alloc_copy_from_user_helper fail");
5183 return -ENOMEM;
5184 }
5185
5186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305187 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5189 "%s: Received data %s", __func__, pBuffer);
5190
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 switch(sub_cmd)
5192 {
5193 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005195 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 break;
5197 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005199 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 break;
5201#if defined WLAN_FEATURE_VOWIFI
5202 case WE_NEIGHBOR_REPORT_REQUEST:
5203 {
5204 tRrmNeighborReq neighborReq;
5205 tRrmNeighborRspCallbackInfo callbackInfo;
5206
5207 if (pConfig->fRrmEnable)
5208 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305210 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 if( !neighborReq.no_ssid )
5212 {
Girish Gowli552fc072014-06-14 18:26:16 +05305213 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005214 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 }
5216
5217 callbackInfo.neighborRspCallback = NULL;
5218 callbackInfo.neighborRspCallbackContext = NULL;
5219 callbackInfo.timeout = 5000; //5 seconds
5220 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5221 }
5222 else
5223 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005224 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 ret = -EINVAL;
5226 }
5227 }
5228 break;
5229#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005230 case WE_SET_AP_WPS_IE:
5231 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05305232 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08005235 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 if (VOS_STATUS_SUCCESS != vstatus)
5237 {
5238 ret = -EINVAL;
5239 }
5240 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305241 case WE_SET_ENCRYPT_MSG:
5242 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
5243 if (NULL == pkt)
5244 {
5245 hddLog(VOS_TRACE_LEVEL_ERROR,
5246 "%s: vos_mem_alloc failed", __func__);
5247 return -ENOMEM;
5248 }
5249
5250 memset(pkt, 0, sizeof(tSirpkt80211));
5251
5252 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
5253 hddLog(VOS_TRACE_LEVEL_ERROR,
5254 FL("Firmware is not DISA capable"));
5255 ret = -EINVAL;
5256 vos_mem_free(pkt);
5257 break;
5258 }
5259
5260 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
5261
5262 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
5263 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
5264 if (eHAL_STATUS_SUCCESS != ret) {
5265 hddLog(VOS_TRACE_LEVEL_ERROR,
5266 FL("SENDEncryptMSG: fail to post WDA cmd"));
5267 ret = -EINVAL;
5268 }
5269 vos_mem_free(pkt);
5270
5271 break;
5272
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 default:
5274 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005275 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 ret = -EINVAL;
5277 break;
5278 }
5279 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005280 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 return ret;
5282}
5283
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305284static int iw_setchar_getnone(struct net_device *dev,
5285 struct iw_request_info *info,
5286 union iwreq_data *wrqu, char *extra)
5287{
5288 int ret;
5289
5290 vos_ssr_protect(__func__);
5291 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
5292 vos_ssr_unprotect(__func__);
5293
5294 return ret;
5295}
5296
Jeff Johnson295189b2012-06-20 16:38:30 -07005297/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305298static int __iw_setnone_getint(struct net_device *dev,
5299 struct iw_request_info *info,
5300 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005301{
5302 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5303 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowli385be612014-09-18 11:17:20 +05305304 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 int *value = (int *)extra;
5306 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05305307 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005308
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005309 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5310 {
c_hpothuda3af912014-11-06 16:52:03 +05305311 if (__ratelimit(&hdd_ioctl_timeout_rs)) {
5312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005313 "%s:LOGP in Progress. Ignore!!!", __func__);
c_hpothuda3af912014-11-06 16:52:03 +05305314 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005315 return -EBUSY;
5316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005317
5318 switch (value[0])
5319 {
5320 case WE_GET_11D_STATE:
5321 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005322 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305324
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 *value = smeConfig.csrConfig.Is11dSupportEnabled;
5326
Arif Hussain6d2a3322013-11-17 19:50:10 -08005327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005328
5329 break;
5330 }
5331
5332 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 break;
5335
5336 case WE_PMC_STATE:
5337 {
5338 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 break;
5341 }
5342 case WE_GET_WLAN_DBG:
5343 {
5344 vos_trace_display();
5345 *value = 0;
5346 break;
5347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 case WE_GET_MAX_ASSOC:
5349 {
5350 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
5351 {
c_hpothub8245442013-11-20 23:41:09 +05305352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5353 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 ret = -EIO;
5355 }
Girish Gowli385be612014-09-18 11:17:20 +05305356#ifdef WLAN_SOFTAP_VSTA_FEATURE
5357 if (pHddCtx->cfg_ini->fEnableVSTASupport)
5358 {
5359 if (*value > VSTA_NUM_ASSOC_STA)
5360 {
5361 *value = VSTA_NUM_ASSOC_STA;
5362 }
5363 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
5364 (*value > (VSTA_NUM_ASSOC_STA -
5365 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
5366 {
5367 *value = (VSTA_NUM_ASSOC_STA -
5368 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
5369 }
5370 }
5371 else
5372#endif
5373 {
5374 if (*value > NUM_ASSOC_STA)
5375 {
5376 *value = NUM_ASSOC_STA;
5377 }
5378 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
5379 (*value > (NUM_ASSOC_STA -
5380 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
5381 {
5382 *value = (NUM_ASSOC_STA -
5383 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
5384 }
5385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 break;
5387 }
5388
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 case WE_GET_WDI_DBG:
5390 {
5391 wpalTraceDisplay();
5392 *value = 0;
5393 break;
5394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005395
5396 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
5397 {
5398 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
5399 break;
5400 }
5401 case WE_GET_CONCURRENCY_MODE:
5402 {
5403 *value = hdd_get_concurrency_mode ( );
5404
Arif Hussain6d2a3322013-11-17 19:50:10 -08005405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 break;
5407 }
5408
Peng Xu2446a892014-09-05 17:21:18 +05305409 case WE_GET_SCAN_BAND_PREFERENCE:
5410 {
5411 sme_GetConfigParam(hHal, &smeConfig);
5412 *value = smeConfig.csrConfig.scanBandPreference;
5413
5414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5415 "scanBandPreference = %d\n", *value);
5416 break;
5417 }
5418
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 default:
5420 {
5421 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
5422 break;
5423 }
5424 }
5425
5426 return ret;
5427}
5428
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305429static int iw_setnone_getint(struct net_device *dev,
5430 struct iw_request_info *info,
5431 union iwreq_data *wrqu, char *extra)
5432{
5433 int ret;
5434
5435 vos_ssr_protect(__func__);
5436 ret = __iw_setnone_getint(dev, info, wrqu, extra);
5437 vos_ssr_unprotect(__func__);
5438
5439 return ret;
5440
5441}
Jeff Johnson295189b2012-06-20 16:38:30 -07005442/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305443int __iw_set_three_ints_getnone(struct net_device *dev,
5444 struct iw_request_info *info,
5445 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005446{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005447 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 int *value = (int *)extra;
5449 int sub_cmd = value[0];
5450 int ret = 0;
5451
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005452 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5453 {
5454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5455 "%s:LOGP in Progress. Ignore!!!", __func__);
5456 return -EBUSY;
5457 }
5458
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 switch(sub_cmd)
5460 {
5461 case WE_SET_WLAN_DBG:
5462 {
5463 vos_trace_setValue( value[1], value[2], value[3]);
5464 break;
5465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 case WE_SET_WDI_DBG:
5467 {
5468 wpalTraceSetLevel( value[1], value[2], value[3]);
5469 break;
5470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 case WE_SET_SAP_CHANNELS:
5472 {
5473 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
5474 break;
5475 }
5476
5477 default:
5478 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005479 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 break;
5481 }
5482 }
5483 return ret;
5484}
5485
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305486int iw_set_three_ints_getnone(struct net_device *dev,
5487 struct iw_request_info *info,
5488 union iwreq_data *wrqu, char *extra)
5489{
5490 int ret;
5491
5492 vos_ssr_protect(__func__);
5493 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
5494 vos_ssr_unprotect(__func__);
5495
5496 return ret;
5497}
5498
5499static int __iw_get_char_setnone(struct net_device *dev,
5500 struct iw_request_info *info,
5501 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005502{
5503 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5504 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07005505#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005506 hdd_wext_state_t *pWextState;
5507#endif
5508
5509 if (pAdapter == NULL)
5510 {
5511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5512 "%s: pAdapter is NULL!", __func__);
5513 return -EINVAL;
5514 }
5515#ifdef WLAN_FEATURE_11W
5516 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07005517#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005518
Yue Ma3ede6052013-08-29 00:33:26 -07005519 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
5520 {
5521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5522 "%s: HDD Context is NULL!", __func__);
5523
5524 return -EINVAL;
5525 }
5526
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005527 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5528 {
5529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5530 "%s:LOGP in Progress. Ignore!!!", __func__);
5531 return -EBUSY;
5532 }
5533
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 switch(sub_cmd)
5535 {
5536 case WE_WLAN_VERSION:
5537 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08005538 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 break;
5540 }
5541
5542 case WE_GET_STATS:
5543 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305544 tHalHandle hHal = NULL;
5545 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5547 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
5548 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
5549
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305550
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 snprintf(extra, WE_MAX_STR_LEN,
5552 "\nTransmit"
5553 "\ncalled %u, dropped %u, backpressured %u, queued %u"
5554 "\n dropped BK %u, BE %u, VI %u, VO %u"
5555 "\n classified BK %u, BE %u, VI %u, VO %u"
5556 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
5557 "\n queued BK %u, BE %u, VI %u, VO %u"
5558 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07005559 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 "\n fetched BK %u, BE %u, VI %u, VO %u"
5561 "\n dequeued BK %u, BE %u, VI %u, VO %u"
5562 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07005563 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 "\n flushed BK %u, BE %u, VI %u, VO %u"
5565 "\n\nReceive"
5566 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
5567 "\n\nResetsStats"
5568 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
5569 "\n",
5570 pStats->txXmitCalled,
5571 pStats->txXmitDropped,
5572 pStats->txXmitBackPressured,
5573 pStats->txXmitQueued,
5574
5575 pStats->txXmitDroppedAC[WLANTL_AC_BK],
5576 pStats->txXmitDroppedAC[WLANTL_AC_BE],
5577 pStats->txXmitDroppedAC[WLANTL_AC_VI],
5578 pStats->txXmitDroppedAC[WLANTL_AC_VO],
5579
5580 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
5581 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
5582 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
5583 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
5584
5585 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
5586 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
5587 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
5588 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
5589
5590 pStats->txXmitQueuedAC[WLANTL_AC_BK],
5591 pStats->txXmitQueuedAC[WLANTL_AC_BE],
5592 pStats->txXmitQueuedAC[WLANTL_AC_VI],
5593 pStats->txXmitQueuedAC[WLANTL_AC_VO],
5594
5595 pStats->txFetched,
5596 pStats->txFetchEmpty,
5597 pStats->txFetchLowResources,
5598 pStats->txFetchDequeueError,
5599
5600 pStats->txFetchDequeued,
5601 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07005602 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 pStats->txCompleted,
5604 pStats->txFlushed,
5605
5606 pStats->txFetchedAC[WLANTL_AC_BK],
5607 pStats->txFetchedAC[WLANTL_AC_BE],
5608 pStats->txFetchedAC[WLANTL_AC_VI],
5609 pStats->txFetchedAC[WLANTL_AC_VO],
5610
5611 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
5612 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
5613 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
5614 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
5615
5616 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
5617 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
5618 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
5619 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
5620
Ravi Joshi41914632013-10-21 23:02:21 -07005621 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
5622 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
5623 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
5624 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
5625
Jeff Johnson295189b2012-06-20 16:38:30 -07005626 pStats->txFlushedAC[WLANTL_AC_BK],
5627 pStats->txFlushedAC[WLANTL_AC_BE],
5628 pStats->txFlushedAC[WLANTL_AC_VI],
5629 pStats->txFlushedAC[WLANTL_AC_VO],
5630
5631 pStats->rxChains,
5632 pStats->rxPackets,
5633 pStats->rxDropped,
5634 pStats->rxDelivered,
5635 pStats->rxRefused,
5636
5637 pResetStats->totalLogpResets,
5638 pResetStats->totalCMD53Failures,
5639 pResetStats->totalMutexReadFailures,
5640 pResetStats->totalMIFErrorFailures,
5641 pResetStats->totalFWHearbeatFailures,
5642 pResetStats->totalUnknownExceptions
5643 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305644 wrqu->data.length = strlen(extra);
5645
5646 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
5647
5648 if (hHal)
5649 pMac = PMAC_STRUCT( hHal );
5650
5651 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
5652 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
5653 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05305654 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
5655 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
5656 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
5657 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05305658 "\n",
5659 pMac->pmm.BmpscntSleep,
5660 pMac->pmm.BmpscntAwake,
5661 pMac->pmm.BmpsSleeReqFailCnt,
5662 pMac->pmm.BmpsWakeupReqFailCnt,
5663 pMac->pmm.ImpsCntSleep,
5664 pMac->pmm.ImpsCntAwake,
5665 pMac->pmm.ImpsSleepErrCnt,
5666 pMac->pmm.ImpsWakeupErrCnt,
5667 pMac->pmm.ImpsLastErr
5668 );
5669 }
5670
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 wrqu->data.length = strlen(extra)+1;
5672 break;
5673 }
5674
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305675/* The case prints the current state of the HDD, SME, CSR, PE, TL
5676 *it can be extended for WDI Global State as well.
5677 *And currently it only checks P2P_CLIENT adapter.
5678 *P2P_DEVICE and P2P_GO have not been added as of now.
5679*/
5680 case WE_GET_STATES:
5681 {
5682 int buf = 0, len = 0;
5683 int adapter_num = 0;
5684 int count = 0, check = 1;
5685
5686 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005687 tHalHandle hHal = NULL;
5688 tpAniSirGlobal pMac = NULL;
5689 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305690
5691 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5692 hdd_adapter_t *useAdapter = NULL;
5693
5694 /* Print wlan0 or p2p0 states based on the adapter_num
5695 *by using the correct adapter
5696 */
5697 while ( adapter_num < 2 )
5698 {
5699 if ( WLAN_ADAPTER == adapter_num )
5700 {
5701 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005702 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305703 "\n\n wlan0 States:-");
5704 len += buf;
5705 }
5706 else if ( P2P_ADAPTER == adapter_num )
5707 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005708 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305709 "\n\n p2p0 States:-");
5710 len += buf;
5711
5712 if( !pHddCtx )
5713 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005714 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305715 "\n pHddCtx is NULL");
5716 len += buf;
5717 break;
5718 }
5719
5720 /*Printing p2p0 states only in the case when the device is
5721 configured as a p2p_client*/
5722 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
5723 if ( !useAdapter )
5724 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005725 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305726 "\n Device not configured as P2P_CLIENT.");
5727 len += buf;
5728 break;
5729 }
5730 }
5731
5732 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005733 if (!hHal) {
5734 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5735 "\n pMac is NULL");
5736 len += buf;
5737 break;
5738 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305739 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005740 if (!pMac) {
5741 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5742 "\n pMac is NULL");
5743 len += buf;
5744 break;
5745 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305746 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
5747 if( !pHddStaCtx )
5748 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005749 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305750 "\n pHddStaCtx is NULL");
5751 len += buf;
5752 break;
5753 }
5754
5755 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
5756
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005757 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305758 "\n HDD Conn State - %s "
5759 "\n \n SME State:"
5760 "\n Neighbour Roam State - %s"
5761 "\n CSR State - %s"
5762 "\n CSR Substate - %s"
5763 "\n \n TL STA %d State: %s",
5764 macTraceGetHDDWlanConnState(
5765 pHddStaCtx->conn_info.connState),
5766 macTraceGetNeighbourRoamState(
5767 pMac->roam.neighborRoamInfo.neighborRoamState),
5768 macTraceGetcsrRoamState(
5769 pMac->roam.curState[useAdapter->sessionId]),
5770 macTraceGetcsrRoamSubState(
5771 pMac->roam.curSubState[useAdapter->sessionId]),
5772 pHddStaCtx->conn_info.staId[0],
5773 macTraceGetTLState(tlState)
5774 );
5775 len += buf;
5776 adapter_num++;
5777 }
5778
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005779 if (pMac) {
5780 /* Printing Lim State starting with global lim states */
5781 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5782 "\n \n LIM STATES:-"
5783 "\n Global Sme State - %s "\
5784 "\n Global mlm State - %s "\
5785 "\n",
5786 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
5787 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
5788 );
5789 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305790
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005791 /*printing the PE Sme and Mlm states for valid lim sessions*/
5792 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305793 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005794 if ( pMac->lim.gpSession[count].valid )
5795 {
5796 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5797 "\n Lim Valid Session %d:-"
5798 "\n PE Sme State - %s "
5799 "\n PE Mlm State - %s "
5800 "\n",
5801 check,
5802 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
5803 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
5804 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305805
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005806 len += buf;
5807 check++;
5808 }
5809 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305810 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305811 }
5812
5813 wrqu->data.length = strlen(extra)+1;
5814 break;
5815 }
5816
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 case WE_GET_CFG:
5818 {
5819 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
5820 wrqu->data.length = strlen(extra)+1;
5821 break;
5822 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005823#ifdef WLAN_FEATURE_11AC
5824 case WE_GET_RSSI:
5825 {
5826 v_S7_t s7Rssi = 0;
5827 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
5828 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
5829 wrqu->data.length = strlen(extra)+1;
5830 break;
5831 }
5832#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305833
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005834#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005835 case WE_GET_ROAM_RSSI:
5836 {
5837 v_S7_t s7Rssi = 0;
5838 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
5839 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
5840 wrqu->data.length = strlen(extra)+1;
5841 break;
5842 }
5843#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 case WE_GET_WMM_STATUS:
5845 {
5846 snprintf(extra, WE_MAX_STR_LEN,
5847 "\nDir: 0=up, 1=down, 3=both\n"
5848 "|------------------------|\n"
5849 "|AC | ACM |Admitted| Dir |\n"
5850 "|------------------------|\n"
5851 "|VO | %d | %3s | %d |\n"
5852 "|VI | %d | %3s | %d |\n"
5853 "|BE | %d | %3s | %d |\n"
5854 "|BK | %d | %3s | %d |\n"
5855 "|------------------------|\n",
5856 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
5857 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
5858 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
5859 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
5860 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
5861 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
5862 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
5863 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
5864 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
5865 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
5866 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
5867 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
5868
Jeff Johnsone7245742012-09-05 17:12:55 -07005869
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 wrqu->data.length = strlen(extra)+1;
5871 break;
5872 }
5873 case WE_GET_CHANNEL_LIST:
5874 {
5875 VOS_STATUS status;
5876 v_U8_t i, len;
5877 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05305878 tANI_U8 pBuf[COUNTRY_CODE_LEN];
5879 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
5880 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 tChannelListInfo channel_list;
5882
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005883 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005885 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005887 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005888 return -EINVAL;
5889 }
5890 buf = extra;
5891
5892 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005893 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
5894 * needed = 5 * number of channels. Check ifsufficient
5895 * buffer is available and then proceed to fill the buffer.
5896 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
5898 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005899 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005900 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005901 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 return -EINVAL;
5903 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005904 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
5905 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05305906 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
5907 {
5908 //Printing Country code in getChannelList
5909 for(i= 0; i < COUNTRY_CODE_LEN; i++)
5910 {
5911 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
5912 "%c ", pBuf[i]);
5913 }
5914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 for(i = 0 ; i < channel_list.num_channels; i++)
5916 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005917 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 }
5920 wrqu->data.length = strlen(extra)+1;
5921
5922 break;
5923 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005924#ifdef FEATURE_WLAN_TDLS
5925 case WE_GET_TDLS_PEERS:
5926 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005927 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005928 break;
5929 }
5930#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005931#ifdef WLAN_FEATURE_11W
5932 case WE_GET_11W_INFO:
5933 {
5934 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5935
5936 snprintf(extra, WE_MAX_STR_LEN,
5937 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5938 "\n Number of Unprotected Disassocs %d"
5939 "\n Number of Unprotected Deauths %d",
5940 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5941 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5942 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5943 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5944 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5945
5946 wrqu->data.length = strlen(extra)+1;
5947 break;
5948 }
5949#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05305950 case WE_GET_SNR:
5951 {
5952 v_S7_t s7snr = 0;
5953 int status = 0;
5954 hdd_context_t *pHddCtx;
5955 hdd_station_ctx_t *pHddStaCtx;
5956
5957 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5958 status = wlan_hdd_validate_context(pHddCtx);
5959 if (0 != status)
5960 {
5961 hddLog(LOGE, "%s: getSNR: HDD context is not valid", __func__);
5962 return status;
5963 }
5964
5965 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5966
5967 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
5968 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5969 {
5970 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
5971 " ConnectionState-%d", __func__,
5972 pHddCtx->cfg_ini->fEnableSNRMonitoring,
5973 pHddStaCtx->conn_info.connState);
5974 return -ENONET;
5975 }
5976
5977 /*update the stats in TL*/
5978 wlan_hdd_get_station_stats(pAdapter);
5979 wlan_hdd_get_snr(pAdapter, &s7snr);
5980 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
5981 wrqu->data.length = strlen(extra) + 1;
5982 break;
5983 }
5984
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305985 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005987 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 break;
5989 }
5990 }
5991
5992 return 0;
5993}
5994
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305995static int iw_get_char_setnone(struct net_device *dev,
5996 struct iw_request_info *info,
5997 union iwreq_data *wrqu, char *extra)
5998{
5999 int ret;
6000
6001 vos_ssr_protect(__func__);
6002 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6003 vos_ssr_unprotect(__func__);
6004
6005 return ret;
6006}
6007
Jeff Johnson295189b2012-06-20 16:38:30 -07006008/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306009static int __iw_setnone_getnone(struct net_device *dev,
6010 struct iw_request_info *info,
6011 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006012{
6013 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306014 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006015 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306016 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006017
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006018 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6019 {
6020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6021 "%s:LOGP in Progress. Ignore!!!", __func__);
6022 return -EBUSY;
6023 }
6024
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306025 /* helper function to get iwreq_data with compat handling. */
6026 if (hdd_priv_get_data(&s_priv_data, wrqu))
6027 {
6028 return -EINVAL;
6029 }
6030
6031 sub_cmd = s_priv_data.flags;
6032
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 switch (sub_cmd)
6034 {
6035 case WE_CLEAR_STATS:
6036 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6039 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6040 break;
6041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 case WE_INIT_AP:
6043 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306044 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6045
6046 /* As Soft AP mode might been changed to STA already with
6047 * killing of Hostapd, need to find the adpater by name
6048 * rather than mode */
6049 hdd_adapter_t* pAdapter_to_stop =
6050 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6051 if( pAdapter_to_stop )
6052 {
6053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6054 "Adapter with name softap.0 already "
6055 "exist, ignoring the request.\nRemove the "
6056 "adapter and try again\n");
6057 break;
6058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 pr_info("Init AP trigger\n");
6060 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6061 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6062 break;
6063 }
6064 case WE_STOP_AP:
6065 {
6066 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6067 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6068 * this is a dead code and need to find the adpater by name rather than mode */
6069 hdd_adapter_t* pAdapter_to_stop =
6070 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6071 if( pAdapter_to_stop )
6072 {
6073 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6074
6075 pr_info("Stopping AP mode\n");
6076
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306077 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6078 {
6079 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6080 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6081 }
6082
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306084 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
6086 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6087
6088 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6089 pAdapter_to_stop->macAddressCurrent.bytes);
6090 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6091 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306092
6093 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6094 {
6095 /* put the device back into BMPS */
6096 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 }
6099 else
6100 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006101 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 }
6103
6104 break;
6105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006106#ifdef WLAN_BTAMP_FEATURE
6107 case WE_ENABLE_AMP:
6108 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006110 WLANBAP_RegisterWithHCI(pAdapter);
6111 break;
6112 }
6113 case WE_DISABLE_AMP:
6114 {
6115 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6116 VOS_STATUS status;
6117
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006119
6120 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6121 status = WLANBAP_StopAmp();
6122 if(VOS_STATUS_SUCCESS != status )
6123 {
6124 pHddCtx->isAmpAllowed = VOS_TRUE;
6125 hddLog(VOS_TRACE_LEVEL_FATAL,
6126 "%s: Failed to stop AMP", __func__);
6127 }
6128 else
6129 {
6130 //a state m/c implementation in PAL is TBD to avoid this delay
6131 msleep(500);
6132 pHddCtx->isAmpAllowed = VOS_FALSE;
6133 WLANBAP_DeregisterFromHCI();
6134 }
6135
6136 break;
6137 }
6138#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006139 case WE_ENABLE_DXE_STALL_DETECT:
6140 {
schang6295e542013-03-12 15:31:23 -07006141 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6142 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006143 break;
6144 }
6145 case WE_DISPLAY_DXE_SNAP_SHOT:
6146 {
schang6295e542013-03-12 15:31:23 -07006147 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6148 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006149 break;
6150 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306151 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6152 {
6153 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6154 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306155 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306156 break;
6157 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306158
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306159 case WE_SET_REASSOC_TRIGGER:
6160 {
6161 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6162 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6163 v_U32_t roamId = 0;
6164 tCsrRoamModifyProfileFields modProfileFields;
6165 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6166 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6167 return 0;
6168 }
6169
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306170 case WE_STOP_OBSS_SCAN:
6171 {
6172 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6173 2.OBSS scan is stopped by Firmware during the disassociation
6174 3.OBSS stop comamnd is added for debugging purpose*/
6175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6176 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006177
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306178 if (pAdapter == NULL)
6179 {
6180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6181 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306182 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306183 }
6184 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6185 if (pMac == NULL)
6186 {
6187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6188 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306189 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306190 }
6191 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6192 }
6193 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306194#ifdef DEBUG_ROAM_DELAY
6195 case WE_DUMP_ROAM_TIMER_LOG:
6196 {
6197 vos_dump_roam_time_log_service();
6198 break;
6199 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306200
Mukul Sharma84f27252014-07-14 18:11:42 +05306201 case WE_RESET_ROAM_TIMER_LOG:
6202 {
6203 vos_reset_roam_timer_log();
6204 break;
6205 }
6206#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 default:
6208 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006209 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 break;
6211 }
6212 }
6213
6214 return ret;
6215}
6216
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306217static int iw_setnone_getnone(struct net_device *dev,
6218 struct iw_request_info *info,
6219 union iwreq_data *wrqu, char *extra)
6220{
6221 int ret;
6222
6223 vos_ssr_protect(__func__);
6224 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
6225 vos_ssr_unprotect(__func__);
6226
6227 return ret;
6228}
6229
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306230void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
6231{
6232 /*
6233 * Function to display HDD WMM information
6234 * for Tx Queues.
6235 * Prints globala as well as per client depending
6236 * whether the clients are registered or not.
6237 */
6238 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306239 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
6240 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
6241
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306242 for ( i=0; i< NUM_TX_QUEUES; i++)
6243 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05306244 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306245
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006246 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306247 i, pAdapter->wmm_tx_queue[i].count,
6248 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05306249 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306250 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306251 if(pSapCtx == NULL){
6252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6253 FL("psapCtx is NULL"));
6254 return;
6255 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306256
6257 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
6258 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306259 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306260 {
6261 hddLog(LOGE, "******STAIndex: %d*********", i);
6262 for ( j=0; j< NUM_TX_QUEUES; j++)
6263 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306264 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006265 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306266 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
6267 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
6268 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
6269 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306270 }
6271 }
6272 }
6273
6274}
Girish Gowlifb9758e2014-11-19 15:19:17 +05306275static int __iw_set_var_ints_getnone(struct net_device *dev,
6276 struct iw_request_info *info,
6277 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006278{
6279 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6280 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowlid4522fd2014-06-14 17:20:27 +05306281 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05306282 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006283 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306284 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006285 hdd_ap_ctx_t *pAPCtx = NULL;
6286 int cmd = 0;
6287 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306288 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006289
Girish Gowlifb9758e2014-11-19 15:19:17 +05306290 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05306291 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05306292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6293 "%s: NULL extra buffer pointer", __func__);
6294 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05306295 }
6296
Girish Gowlifb9758e2014-11-19 15:19:17 +05306297 sub_cmd = wrqu->data.flags;
Girish Gowlid4522fd2014-06-14 17:20:27 +05306298
Girish Gowlifb9758e2014-11-19 15:19:17 +05306299 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006300
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306301 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6302 ret = wlan_hdd_validate_context(pHddCtx);
6303 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006304 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306305 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6306 "%s: HDD context is Null", __func__);
6307 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006308 }
6309
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006310 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
6311 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
6312 {
6313 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
6314 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
6315 {
6316 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6317 staId = pStaCtx->conn_info.staId[0];
6318 }
6319 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
6320 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
6321 {
6322 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
6323 staId = pAPCtx->uBCStaId;
6324 }
6325 else
6326 {
6327 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
6328 return 0;
6329 }
6330 }
6331
Jeff Johnson295189b2012-06-20 16:38:30 -07006332 switch (sub_cmd)
6333 {
6334 case WE_LOG_DUMP_CMD:
6335 {
6336 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006337 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 apps_args[3], apps_args[4]);
6339
6340 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
6341 apps_args[3], apps_args[4]);
6342
6343 }
6344 break;
6345
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 case WE_P2P_NOA_CMD:
6347 {
6348 p2p_app_setP2pPs_t p2pNoA;
6349
6350 p2pNoA.opp_ps = apps_args[0];
6351 p2pNoA.ctWindow = apps_args[1];
6352 p2pNoA.duration = apps_args[2];
6353 p2pNoA.interval = apps_args[3];
6354 p2pNoA.count = apps_args[4];
6355 p2pNoA.single_noa_duration = apps_args[5];
6356 p2pNoA.psSelection = apps_args[6];
6357
6358 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
6359 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006360 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
6362
6363 hdd_setP2pPs(dev, &p2pNoA);
6364
6365 }
6366 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006367
Katya Nigamc2f29dc2014-01-20 19:29:30 +05306368 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
6369 {
6370 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
6371 __func__, apps_args[0], apps_args[1]);
6372 vosTraceEnable(apps_args[0], apps_args[1]);
6373 }
6374 break;
6375
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07006376 case WE_MTRACE_DUMP_CMD:
6377 {
6378 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
6379 "bitmask_of_module %d ",
6380 __func__, apps_args[0], apps_args[1], apps_args[2],
6381 apps_args[3]);
6382 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
6383 apps_args[2], apps_args[3]);
6384
6385 }
6386 break;
6387
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006388 case WE_MCC_CONFIG_CREDENTIAL :
6389 {
6390 cmd = 287; //Command should be updated if there is any change
6391 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08006392 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006393 {
6394 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
6395 }
6396 else
6397 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006398 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006399 return 0;
6400 }
6401 }
6402 break;
6403
6404 case WE_MCC_CONFIG_PARAMS :
6405 {
6406 cmd = 288; //command Should be updated if there is any change
6407 // in the Riva dump command
6408 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
6409 }
6410 break;
6411
Chilam NG571c65a2013-01-19 12:27:36 +05306412#ifdef FEATURE_WLAN_TDLS
6413 case WE_TDLS_CONFIG_PARAMS :
6414 {
6415 tdls_config_params_t tdlsParams;
6416
Chilam Ng01120412013-02-19 18:32:21 -08006417 tdlsParams.tdls = apps_args[0];
6418 tdlsParams.tx_period_t = apps_args[1];
6419 tdlsParams.tx_packet_n = apps_args[2];
6420 tdlsParams.discovery_period_t = apps_args[3];
6421 tdlsParams.discovery_tries_n = apps_args[4];
6422 tdlsParams.idle_timeout_t = apps_args[5];
6423 tdlsParams.idle_packet_n = apps_args[6];
6424 tdlsParams.rssi_hysteresis = apps_args[7];
6425 tdlsParams.rssi_trigger_threshold = apps_args[8];
6426 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05306427
Chilam Ng01120412013-02-19 18:32:21 -08006428 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05306429 }
6430 break;
6431#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 default:
6433 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006434 hddLog(LOGE, "%s: Invalid IOCTL command %d",
6435 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006436 }
6437 break;
6438 }
6439
6440 return 0;
6441}
6442
Girish Gowlifb9758e2014-11-19 15:19:17 +05306443static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
6444 struct iw_request_info *info,
6445 union iwreq_data *wrqu, char *extra)
6446{
6447 int ret;
6448 union iwreq_data u_priv_wrqu;
6449 int apps_args[MAX_VAR_ARGS] = {0};
6450 int num_args;
6451
6452 /* helper function to get iwreq_data with compat handling. */
6453 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
6454 {
6455 return -EINVAL;
6456 }
6457
6458 if (NULL == u_priv_wrqu.data.pointer)
6459 {
6460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6461 "%s: NULL data pointer", __func__);
6462 return -EINVAL;
6463 }
6464
6465 num_args = u_priv_wrqu.data.length;
6466 if (num_args > MAX_VAR_ARGS)
6467 {
6468 num_args = MAX_VAR_ARGS;
6469 }
6470
6471 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
6472 (sizeof(int)) * num_args))
6473 {
6474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6475 "%s: failed to copy data from user buffer", __func__);
6476 return -EFAULT;
6477 }
6478
6479 vos_ssr_protect(__func__);
6480 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
6481 (char *)&apps_args);
6482 vos_ssr_unprotect(__func__);
6483
6484 return ret;
6485}
6486
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306487int iw_set_var_ints_getnone(struct net_device *dev,
6488 struct iw_request_info *info,
6489 union iwreq_data *wrqu, char *extra)
6490{
6491 int ret;
6492 vos_ssr_protect(__func__);
6493 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
6494 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006495
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306496 return ret;
6497}
6498
6499static int __iw_add_tspec(struct net_device *dev,
6500 struct iw_request_info *info,
6501 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006502{
6503 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6504 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6505 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
6506 int params[HDD_WLAN_WMM_PARAM_COUNT];
6507 sme_QosWmmTspecInfo tSpec;
6508 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05306509 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006510
6511 // make sure the application is sufficiently priviledged
6512 // note that the kernel will do this for "set" ioctls, but since
6513 // this ioctl wants to return status to user space it must be
6514 // defined as a "get" ioctl
6515 if (!capable(CAP_NET_ADMIN))
6516 {
6517 return -EPERM;
6518 }
6519
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006520 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6521 {
6522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6523 "%s:LOGP in Progress. Ignore!!!", __func__);
6524 return -EBUSY;
6525 }
6526
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 // we must be associated in order to add a tspec
6528 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6529 {
6530 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6531 return 0;
6532 }
6533
6534 // since we are defined to be a "get" ioctl, and since the number
6535 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05306536 // will pass down in the iwreq_data, we must copy the "set" params.
6537 // We must handle the compat for iwreq_data in 32U/64K environment.
6538
6539 // helper fucntion to get iwreq_data with compat handling.
6540 if (hdd_priv_get_data(&s_priv_data, wrqu))
6541 {
6542 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6543 return 0;
6544 }
6545
6546 // make sure all params are correctly passed to function
6547 if ((NULL == s_priv_data.pointer) ||
6548 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
6549 {
6550 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6551 return 0;
6552 }
6553
Jeff Johnson295189b2012-06-20 16:38:30 -07006554 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05306555 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006556 {
6557 // hmmm, can't get them
6558 return -EIO;
6559 }
6560
6561 // clear the tspec
6562 memset(&tSpec, 0, sizeof(tSpec));
6563
6564 // validate the handle
6565 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
6566 if (HDD_WMM_HANDLE_IMPLICIT == handle)
6567 {
6568 // that one is reserved
6569 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6570 return 0;
6571 }
6572
6573 // validate the TID
6574 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
6575 {
6576 // out of range
6577 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6578 return 0;
6579 }
6580 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
6581
6582 // validate the direction
6583 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
6584 {
6585 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
6586 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
6587 break;
6588
6589 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
6590 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
6591 break;
6592
6593 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
6594 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
6595 break;
6596
6597 default:
6598 // unknown
6599 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6600 return 0;
6601 }
6602
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05306603 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
6604
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 // validate the user priority
6606 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
6607 {
6608 // out of range
6609 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6610 return 0;
6611 }
6612 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05306613 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
6614 {
6615 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
6616 return 0;
6617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006618
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05306619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6620 "%s:TS_INFO PSB %d UP %d !!!", __func__,
6621 tSpec.ts_info.psb, tSpec.ts_info.up);
6622
Jeff Johnson295189b2012-06-20 16:38:30 -07006623 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
6624 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
6625 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
6626 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
6627 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
6628 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
6629 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
6630 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
6631 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
6632 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
6633 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
6634 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
6635
6636 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
6637
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05306638 // Save the expected UAPSD settings by application, this will be needed
6639 // when re-negotiating UAPSD settings during BT Coex cases.
6640 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
6641
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 // validate the ts info ack policy
6643 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
6644 {
6645 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
6646 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
6647 break;
6648
6649 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
6650 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
6651 break;
6652
6653 default:
6654 // unknown
6655 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6656 return 0;
6657 }
6658
6659 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
6660 return 0;
6661}
6662
6663
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306664static int iw_add_tspec(struct net_device *dev,
6665 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006666 union iwreq_data *wrqu, char *extra)
6667{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306668 int ret;
6669
6670 vos_ssr_protect(__func__);
6671 ret = __iw_add_tspec(dev, info, wrqu, extra);
6672 vos_ssr_unprotect(__func__);
6673
6674 return ret;
6675}
6676
6677static int __iw_del_tspec(struct net_device *dev,
6678 struct iw_request_info *info,
6679 union iwreq_data *wrqu, char *extra)
6680{
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6682 int *params = (int *)extra;
6683 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
6684 v_U32_t handle;
6685
6686 // make sure the application is sufficiently priviledged
6687 // note that the kernel will do this for "set" ioctls, but since
6688 // this ioctl wants to return status to user space it must be
6689 // defined as a "get" ioctl
6690 if (!capable(CAP_NET_ADMIN))
6691 {
6692 return -EPERM;
6693 }
6694
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006695 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6696 {
6697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6698 "%s:LOGP in Progress. Ignore!!!", __func__);
6699 return -EBUSY;
6700 }
6701
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 // although we are defined to be a "get" ioctl, the params we require
6703 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
6704 // is no need to copy the params from user space
6705
6706 // validate the handle
6707 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
6708 if (HDD_WMM_HANDLE_IMPLICIT == handle)
6709 {
6710 // that one is reserved
6711 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6712 return 0;
6713 }
6714
6715 *pStatus = hdd_wmm_delts(pAdapter, handle);
6716 return 0;
6717}
6718
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306719static int iw_del_tspec(struct net_device *dev,
6720 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 union iwreq_data *wrqu, char *extra)
6722{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306723 int ret;
6724
6725 vos_ssr_protect(__func__);
6726 ret = __iw_del_tspec(dev, info, wrqu, extra);
6727 vos_ssr_unprotect(__func__);
6728
6729 return ret;
6730}
6731
6732
6733static int __iw_get_tspec(struct net_device *dev,
6734 struct iw_request_info *info,
6735 union iwreq_data *wrqu, char *extra)
6736{
Jeff Johnson295189b2012-06-20 16:38:30 -07006737 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6738 int *params = (int *)extra;
6739 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
6740 v_U32_t handle;
6741
6742 // although we are defined to be a "get" ioctl, the params we require
6743 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
6744 // is no need to copy the params from user space
6745
6746 // validate the handle
6747 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
6748 if (HDD_WMM_HANDLE_IMPLICIT == handle)
6749 {
6750 // that one is reserved
6751 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
6752 return 0;
6753 }
6754
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006755 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6756 {
6757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6758 "%s:LOGP in Progress. Ignore!!!", __func__);
6759 return -EBUSY;
6760 }
6761
Jeff Johnson295189b2012-06-20 16:38:30 -07006762 *pStatus = hdd_wmm_checkts(pAdapter, handle);
6763 return 0;
6764}
6765
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306766static int iw_get_tspec(struct net_device *dev,
6767 struct iw_request_info *info,
6768 union iwreq_data *wrqu, char *extra)
6769{
6770 int ret;
6771
6772 vos_ssr_protect(__func__);
6773 ret = __iw_get_tspec(dev, info, wrqu, extra);
6774 vos_ssr_unprotect(__func__);
6775
6776 return ret;
6777}
6778
Jeff Johnson295189b2012-06-20 16:38:30 -07006779#ifdef WLAN_FEATURE_VOWIFI_11R
6780//
6781//
6782// Each time the supplicant has the auth_request or reassoc request
6783// IEs ready. This is pushed to the driver. The driver will inturn use
6784// it to send out the auth req and reassoc req for 11r FT Assoc.
6785//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306786static int __iw_set_fties(struct net_device *dev,
6787 struct iw_request_info *info,
6788 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006789{
6790 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6791 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6792 //v_CONTEXT_t pVosContext;
6793
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006794 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6795 {
6796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6797 "%s:LOGP in Progress. Ignore!!!", __func__);
6798 return -EBUSY;
6799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 if (!wrqu->data.length)
6801 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006802 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006803 return -EINVAL;
6804 }
6805 if (wrqu->data.pointer == NULL)
6806 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006807 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 return -EINVAL;
6809 }
6810
6811 // Added for debug on reception of Re-assoc Req.
6812 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6813 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006814 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006815 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006816 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 }
6818
6819#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08006820 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07006821#endif
6822
6823 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08006824 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 wrqu->data.length);
6826
6827 return 0;
6828}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306829
6830static int iw_set_fties(struct net_device *dev,
6831 struct iw_request_info *info,
6832 union iwreq_data *wrqu, char *extra)
6833{
6834 int ret;
6835
6836 vos_ssr_protect(__func__);
6837 ret = __iw_set_fties(dev, info, wrqu, extra);
6838 vos_ssr_unprotect(__func__);
6839
6840 return ret;
6841}
Jeff Johnson295189b2012-06-20 16:38:30 -07006842#endif
6843
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306844static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006845 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08006847{
Jeff Johnson295189b2012-06-20 16:38:30 -07006848 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006849 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006851 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006852 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006853 tpSirRcvFltMcAddrList mc_addr_list_ptr;
6854 int idx;
6855 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07006856
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006857 if (pHddCtx->isLogpInProgress)
6858 {
6859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6860 "%s:LOGP in Progress. Ignore!!!", __func__);
6861 return -EBUSY;
6862 }
6863
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306864 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
6865 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306866#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07006867
Amar Singhalf3a6e762013-02-19 15:06:50 -08006868 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6869 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006870 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006871 hddLog(VOS_TRACE_LEVEL_ERROR,
6872 "%s: vos_mem_alloc failed", __func__);
6873 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006874 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006875
6876 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
6877
6878 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
6879 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
6880
6881 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
6882 mc_addr_list_ptr->ulMulticastAddrCnt);
6883
6884 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006885 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08006886 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
6887 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
6888
6889 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
6890 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006891 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006892
Amar Singhalf3a6e762013-02-19 15:06:50 -08006893 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
6894 vos_mem_free(mc_addr_list_ptr);
6895 if (eHAL_STATUS_SUCCESS != ret_val)
6896 {
6897 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
6898 __func__);
6899 return -EINVAL;
6900 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306901#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306902 }
6903 else
6904 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006905
Amar Singhalf3a6e762013-02-19 15:06:50 -08006906 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6907 "%s: Set MC BC Filter Config request: %d suspend %d",
6908 __func__, pRequest->mcastBcastFilterSetting,
6909 pHddCtx->hdd_wlan_suspended);
6910
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306911 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006912
6913 if (pHddCtx->hdd_wlan_suspended)
6914 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006915 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6916 if (NULL == wlanRxpFilterParam)
6917 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306918 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07006919 "%s: vos_mem_alloc failed", __func__);
6920 return -EINVAL;
6921 }
6922
Amar Singhalf3a6e762013-02-19 15:06:50 -08006923 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6924 pRequest->mcastBcastFilterSetting;
6925 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6926
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306927 hdd_conf_hostoffload(pAdapter, TRUE);
6928 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6929 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08006930
6931 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
6932 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306933 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08006934 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
6935 wlanRxpFilterParam->setMcstBcstFilter);
6936
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306937 if (eHAL_STATUS_SUCCESS !=
6938 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6939 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08006940 {
6941 hddLog(VOS_TRACE_LEVEL_ERROR,
6942 "%s: Failure to execute set HW MC/BC Filter request",
6943 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07006944 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08006945 return -EINVAL;
6946 }
6947
c_hpothud3ce76d2014-10-28 10:34:13 +05306948 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
6949 {
6950 pHddCtx->sus_res_mcastbcast_filter =
6951 pRequest->mcastBcastFilterSetting;
6952 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006953 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006955
6956 return 0;
6957}
6958
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306959static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
6960 struct iw_request_info *info,
6961 union iwreq_data *wrqu, char *extra)
6962{
6963 int ret;
6964
6965 vos_ssr_protect(__func__);
6966 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
6967 vos_ssr_unprotect(__func__);
6968
6969 return ret;
6970}
6971
6972static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
6973 struct iw_request_info *info,
6974 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006975{
6976 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6977 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306978 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006979 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006980
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306981 //Reset the filter to INI value as we have to clear the dynamic filter
6982 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006983
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306984 //Configure FW with new setting
6985 if (pHddCtx->hdd_wlan_suspended)
6986 {
6987 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6988 if (NULL == wlanRxpFilterParam)
6989 {
6990 hddLog(VOS_TRACE_LEVEL_ERROR,
6991 "%s: vos_mem_alloc failed", __func__);
6992 return -EINVAL;
6993 }
6994
6995 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6996 pHddCtx->configuredMcastBcastFilter;
6997 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6998
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306999 hdd_conf_hostoffload(pAdapter, TRUE);
7000 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7001 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307002
7003 if (eHAL_STATUS_SUCCESS !=
7004 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7005 wlanRxpFilterParam))
7006 {
7007 hddLog(VOS_TRACE_LEVEL_ERROR,
7008 "%s: Failure to execute set HW MC/BC Filter request",
7009 __func__);
7010 vos_mem_free(wlanRxpFilterParam);
7011 return -EINVAL;
7012 }
c_hpothud3ce76d2014-10-28 10:34:13 +05307013
7014 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7015 {
7016 pHddCtx->sus_res_mcastbcast_filter =
7017 pHddCtx->cfg_ini->mcastBcastFilterSetting;
7018 }
7019
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 return 0;
7022}
7023
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307024
7025static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7026 struct iw_request_info *info,
7027 union iwreq_data *wrqu, char *extra)
7028{
7029 int ret;
7030
7031 vos_ssr_protect(__func__);
7032 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
7033 vos_ssr_unprotect(__func__);
7034
7035 return ret;
7036}
7037
7038static int __iw_set_host_offload(struct net_device *dev,
7039 struct iw_request_info *info,
7040 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007041{
7042 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08007043 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 tSirHostOffloadReq offloadRequest;
7045
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007046 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7047 {
7048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7049 "%s:LOGP in Progress. Ignore!!!", __func__);
7050 return -EBUSY;
7051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 /* Debug display of request components. */
7053 switch (pRequest->offloadType)
7054 {
7055 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007056 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007057 switch (pRequest->enableOrDisable)
7058 {
7059 case WLAN_OFFLOAD_DISABLE:
7060 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
7061 break;
7062 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
7063 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
7064 case WLAN_OFFLOAD_ENABLE:
7065 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
7066 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
7067 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
7068 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
7069 }
7070 break;
7071
7072 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08007073 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007074 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007075 switch (pRequest->enableOrDisable)
7076 {
7077 case WLAN_OFFLOAD_DISABLE:
7078 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
7079 break;
7080 case WLAN_OFFLOAD_ENABLE:
7081 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
7082 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
7083 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
7084 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
7085 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
7086 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
7087 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
7088 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
7089 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
7090 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
7091 }
7092 }
7093
7094 /* Execute offload request. The reason that we can copy the request information
7095 from the ioctl structure to the SME structure is that they are laid out
7096 exactly the same. Otherwise, each piece of information would have to be
7097 copied individually. */
7098 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07007099 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
7100 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07007101 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007102 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 __func__);
7104 return -EINVAL;
7105 }
7106
7107 return 0;
7108}
7109
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307110static int iw_set_host_offload(struct net_device *dev,
7111 struct iw_request_info *info,
7112 union iwreq_data *wrqu, char *extra)
7113{
7114 int ret;
7115
7116 vos_ssr_protect(__func__);
7117 ret = __iw_set_host_offload(dev, info, wrqu, extra);
7118 vos_ssr_unprotect(__func__);
7119
7120 return ret;
7121}
7122
7123static int __iw_set_keepalive_params(struct net_device *dev,
7124 struct iw_request_info *info,
7125 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007126{
7127 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08007128 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 tSirKeepAliveReq keepaliveRequest;
7130
7131 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7132 {
7133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007134 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 return 0;
7136 }
7137
7138 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08007139 hddLog(VOS_TRACE_LEVEL_INFO,
7140 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
7141 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07007142
7143 switch (pRequest->packetType)
7144 {
7145 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007146 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 break;
7148
7149 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
7150
Arif Hussain6d2a3322013-11-17 19:50:10 -08007151 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007152 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007153
7154 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
7155 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
7156 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
7157
7158 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
7159 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
7160 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
7161
7162 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
7163 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
7164 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
7165 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
7166 break;
7167
7168 }
7169
7170 /* Execute keep alive request. The reason that we can copy the request information
7171 from the ioctl structure to the SME structure is that they are laid out
7172 exactly the same. Otherwise, each piece of information would have to be
7173 copied individually. */
7174 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
7175
Arif Hussain6d2a3322013-11-17 19:50:10 -08007176 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07007177
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007178 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07007179 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07007180 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007181 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07007182 __func__);
7183 return -EINVAL;
7184 }
7185
7186 return 0;
7187}
7188
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307189static int iw_set_keepalive_params(struct net_device *dev,
7190 struct iw_request_info *info,
7191 union iwreq_data *wrqu, char *extra)
7192{
7193 int ret;
7194 vos_ssr_protect(__func__);
7195 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
7196 vos_ssr_unprotect(__func__);
7197
7198 return ret;
7199}
7200
Jeff Johnson295189b2012-06-20 16:38:30 -07007201#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007202int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07007203 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007204{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007205 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
7206 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 int i=0;
7208
7209 if (pHddCtx->cfg_ini->disablePacketFilter)
7210 {
7211 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007212 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 return 0;
7214 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007215 if (pHddCtx->isLogpInProgress)
7216 {
7217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7218 "%s:LOGP in Progress. Ignore!!!", __func__);
7219 return -EBUSY;
7220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 /* Debug display of request components. */
7222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007223 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007224
7225 switch (pRequest->filterAction)
7226 {
7227 case HDD_RCV_FILTER_SET:
7228 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007229 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007230
7231 packetFilterSetReq.filterId = pRequest->filterId;
7232 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
7233 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007234 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007235 __func__, pRequest->numParams);
7236 return -EINVAL;
7237 }
7238 packetFilterSetReq.numFieldParams = pRequest->numParams;
7239 packetFilterSetReq.coalesceTime = 0;
7240 packetFilterSetReq.filterType = 1;
7241 for (i=0; i < pRequest->numParams; i++)
7242 {
7243 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
7244 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
7245 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
7246 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
7247 packetFilterSetReq.paramsData[i].reserved = 0;
7248
Arif Hussain6d2a3322013-11-17 19:50:10 -08007249 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
7251 packetFilterSetReq.filterType);
7252
Arif Hussain6d2a3322013-11-17 19:50:10 -08007253 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
7255
7256 memcpy(&packetFilterSetReq.paramsData[i].compareData,
7257 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
7258 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
7259 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
7260
Arif Hussain6d2a3322013-11-17 19:50:10 -08007261 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
7263 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
7264 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
7265
Arif Hussain6d2a3322013-11-17 19:50:10 -08007266 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
7268 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
7269 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
7270 }
7271
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07007272 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07007273 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007274 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 __func__);
7276 return -EINVAL;
7277 }
7278
7279 break;
7280
7281 case HDD_RCV_FILTER_CLEAR:
7282
Arif Hussain6d2a3322013-11-17 19:50:10 -08007283 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007284 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007285 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07007286 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007288 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 __func__);
7290 return -EINVAL;
7291 }
7292 break;
7293
7294 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08007295 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007296 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07007297 return -EINVAL;
7298 }
7299 return 0;
7300}
7301
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05307302int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
7303 tANI_U8 sessionId)
7304{
7305 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
7306 tSirRcvFltPktClearParam packetFilterClrReq = {0};
7307
7308 if (NULL == pHddCtx)
7309 {
7310 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
7311 return -EINVAL;
7312 }
7313
7314 if (pHddCtx->isLogpInProgress)
7315 {
7316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7317 "%s:LOGP in Progress. Ignore!!!", __func__);
7318 return -EBUSY;
7319 }
7320
7321 if (pHddCtx->cfg_ini->disablePacketFilter)
7322 {
7323 hddLog(VOS_TRACE_LEVEL_ERROR,
7324 "%s: Packet Filtering Disabled. Returning ",
7325 __func__ );
7326 return -EINVAL;
7327 }
7328
7329 switch (filterType)
7330 {
7331 /* For setting IPV6 MC and UC Filter we need to configure
7332 * 2 filters, one for MC and one for UC.
7333 * The Filter ID shouldn't be swapped, which results in making
7334 * UC Filter ineffective.
7335 * We have Hardcode all the values
7336 *
7337 * Reason for a seperate UC filter is because, driver need to
7338 * specify the FW that the specific filter is for unicast
7339 * otherwise FW will not pass the unicast frames by default
7340 * through the filter. This is required to avoid any performance
7341 * hits when no unicast filter is set and only MC/BC are set.
7342 * The way driver informs host is by using the MAC protocol
7343 * layer, CMP flag set to MAX, CMP Data set to 1.
7344 */
7345
7346 case HDD_FILTER_IPV6_MC_UC:
7347 /* Setting IPV6 MC Filter below
7348 */
7349 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
7350 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
7351 packetFilterSetReq.numFieldParams = 2;
7352 packetFilterSetReq.paramsData[0].protocolLayer =
7353 HDD_FILTER_PROTO_TYPE_MAC;
7354 packetFilterSetReq.paramsData[0].cmpFlag =
7355 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
7356 packetFilterSetReq.paramsData[0].dataOffset =
7357 WLAN_HDD_80211_FRM_DA_OFFSET;
7358 packetFilterSetReq.paramsData[0].dataLength = 1;
7359 packetFilterSetReq.paramsData[0].compareData[0] =
7360 HDD_IPV6_MC_CMP_DATA;
7361
7362 packetFilterSetReq.paramsData[1].protocolLayer =
7363 HDD_FILTER_PROTO_TYPE_ARP;
7364 packetFilterSetReq.paramsData[1].cmpFlag =
7365 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
7366 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
7367 packetFilterSetReq.paramsData[1].dataLength = 2;
7368 packetFilterSetReq.paramsData[1].compareData[0] =
7369 HDD_IPV6_CMP_DATA_0;
7370 packetFilterSetReq.paramsData[1].compareData[1] =
7371 HDD_IPV6_CMP_DATA_1;
7372
7373
7374 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
7375 &packetFilterSetReq, sessionId))
7376 {
7377 hddLog(VOS_TRACE_LEVEL_ERROR,
7378 "%s: Failure to execute Set IPv6 Mulicast Filter",
7379 __func__);
7380 return -EINVAL;
7381 }
7382
7383 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
7384
7385 /*
7386 * Setting IPV6 UC Filter below
7387 */
7388 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
7389 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
7390 packetFilterSetReq.numFieldParams = 2;
7391 packetFilterSetReq.paramsData[0].protocolLayer =
7392 HDD_FILTER_PROTO_TYPE_MAC;
7393 packetFilterSetReq.paramsData[0].cmpFlag =
7394 HDD_FILTER_CMP_TYPE_MAX;
7395 packetFilterSetReq.paramsData[0].dataOffset = 0;
7396 packetFilterSetReq.paramsData[0].dataLength = 1;
7397 packetFilterSetReq.paramsData[0].compareData[0] =
7398 HDD_IPV6_UC_CMP_DATA;
7399
7400 packetFilterSetReq.paramsData[1].protocolLayer =
7401 HDD_FILTER_PROTO_TYPE_ARP;
7402 packetFilterSetReq.paramsData[1].cmpFlag =
7403 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
7404 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
7405 packetFilterSetReq.paramsData[1].dataLength = 2;
7406 packetFilterSetReq.paramsData[1].compareData[0] =
7407 HDD_IPV6_CMP_DATA_0;
7408 packetFilterSetReq.paramsData[1].compareData[1] =
7409 HDD_IPV6_CMP_DATA_1;
7410
7411 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
7412 &packetFilterSetReq, sessionId))
7413 {
7414 hddLog(VOS_TRACE_LEVEL_ERROR,
7415 "%s: Failure to execute Set IPv6 Unicast Filter",
7416 __func__);
7417 return -EINVAL;
7418 }
7419
7420 break;
7421
7422 case HDD_FILTER_IPV6_MC:
7423 /*
7424 * IPV6 UC Filter might be already set,
7425 * clear the UC Filter. As the Filter
7426 * IDs are static, we can directly clear it.
7427 */
7428 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
7429 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
7430 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
7431 &packetFilterClrReq, sessionId))
7432 {
7433 hddLog(VOS_TRACE_LEVEL_ERROR,
7434 "%s: Failure to execute Clear IPv6 Unicast Filter",
7435 __func__);
7436 return -EINVAL;
7437 }
7438
7439 /*
7440 * Setting IPV6 MC Filter below
7441 */
7442 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
7443 packetFilterSetReq.numFieldParams = 2;
7444 packetFilterSetReq.paramsData[0].protocolLayer =
7445 HDD_FILTER_PROTO_TYPE_MAC;
7446 packetFilterSetReq.paramsData[0].cmpFlag =
7447 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
7448 packetFilterSetReq.paramsData[0].dataOffset =
7449 WLAN_HDD_80211_FRM_DA_OFFSET;
7450 packetFilterSetReq.paramsData[0].dataLength = 1;
7451 packetFilterSetReq.paramsData[0].compareData[0] =
7452 HDD_IPV6_MC_CMP_DATA;
7453
7454 packetFilterSetReq.paramsData[1].protocolLayer =
7455 HDD_FILTER_PROTO_TYPE_ARP;
7456 packetFilterSetReq.paramsData[1].cmpFlag =
7457 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
7458 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
7459 packetFilterSetReq.paramsData[1].dataLength = 2;
7460 packetFilterSetReq.paramsData[1].compareData[0] =
7461 HDD_IPV6_CMP_DATA_0;
7462 packetFilterSetReq.paramsData[1].compareData[1] =
7463 HDD_IPV6_CMP_DATA_1;
7464
7465
7466 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
7467 &packetFilterSetReq, sessionId))
7468 {
7469 hddLog(VOS_TRACE_LEVEL_ERROR,
7470 "%s: Failure to execute Set IPv6 Multicast Filter",
7471 __func__);
7472 return -EINVAL;
7473 }
7474 break;
7475
7476 default :
7477 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7478 "%s: Packet Filter Request: Invalid",
7479 __func__);
7480 return -EINVAL;
7481 }
7482 return 0;
7483}
7484
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307485void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07007486{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05307487 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307488 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07007489 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307490 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007491
Yue Ma3ede6052013-08-29 00:33:26 -07007492 if (NULL == pHddCtx)
7493 {
7494 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
7495 return;
7496 }
7497
7498 hHal = pHddCtx->hHal;
7499
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307500 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307502 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
7503 return;
7504 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307505
7506 /* Check if INI is enabled or not, other wise just return
7507 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05307508 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307509 {
7510 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7511 if (NULL == pMulticastAddrs)
7512 {
7513 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
7514 return;
7515 }
7516
Jeff Johnson295189b2012-06-20 16:38:30 -07007517 if (set)
7518 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307519 /* Following pre-conditions should be satisfied before wei
7520 * configure the MC address list.
7521 */
7522 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
7523 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
7524 && pAdapter->mc_addr_list.mc_cnt
7525 && (eConnectionState_Associated ==
7526 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7527 {
7528 pMulticastAddrs->ulMulticastAddrCnt =
7529 pAdapter->mc_addr_list.mc_cnt;
7530 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
7531 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007532 memcpy(pMulticastAddrs->multicastAddr[i],
7533 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307534 sizeof(pAdapter->mc_addr_list.addr[i]));
7535 hddLog(VOS_TRACE_LEVEL_INFO,
7536 "%s: %s multicast filter: addr ="
7537 MAC_ADDRESS_STR,
7538 __func__, set ? "setting" : "clearing",
7539 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
7540 }
7541 /* Set multicast filter */
7542 sme_8023MulticastList(hHal, pAdapter->sessionId,
7543 pMulticastAddrs);
7544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307546 else
7547 {
7548 /* Need to clear only if it was previously configured
7549 */
7550 if (pAdapter->mc_addr_list.isFilterApplied)
7551 {
7552 pMulticastAddrs->ulMulticastAddrCnt = 0;
7553 sme_8023MulticastList(hHal, pAdapter->sessionId,
7554 pMulticastAddrs);
7555 }
7556
7557 }
7558 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07007559 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07007560 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307561 else
7562 {
7563 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05307564 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307565 }
7566 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007567}
7568
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307569static int __iw_set_packet_filter_params(struct net_device *dev,
7570 struct iw_request_info *info,
7571 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05307572{
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08007574 tpPacketFilterCfg pRequest = NULL;
7575 int ret;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05307576 struct iw_point s_priv_data;
7577
7578 if (hdd_priv_get_data(&s_priv_data, wrqu))
7579 {
7580 return -EINVAL;
7581 }
7582
7583 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
7584 {
7585 return -EINVAL;
7586 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007587
Arif Hussain0273cba2014-01-07 20:58:29 -08007588 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05307589 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
7590 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08007591 if (NULL == pRequest)
7592 {
7593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7594 "mem_alloc_copy_from_user_helper fail");
7595 return -ENOMEM;
7596 }
7597
7598 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
7599 kfree(pRequest);
7600
7601 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007602}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307603
7604static int iw_set_packet_filter_params(struct net_device *dev,
7605 struct iw_request_info *info,
7606 union iwreq_data *wrqu, char *extra)
7607{
7608 int ret;
7609
7610 vos_ssr_protect(__func__);
7611 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
7612 vos_ssr_unprotect(__func__);
7613
7614 return ret;
7615}
Jeff Johnson295189b2012-06-20 16:38:30 -07007616#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307617static int __iw_get_statistics(struct net_device *dev,
7618 struct iw_request_info *info,
7619 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007620{
7621
7622 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
7623 eHalStatus status = eHAL_STATUS_SUCCESS;
7624 hdd_wext_state_t *pWextState;
7625 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7626 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7627 char *p = extra;
7628 int tlen = 0;
7629 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
7630
7631 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
7632 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
7633
7634 ENTER();
7635
7636 if (pHddCtx->isLogpInProgress) {
7637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
7638 return -EINVAL;
7639 }
7640
7641 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
7642
7643 wrqu->txpower.value = 0;
7644 }
7645 else {
7646 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
7647 SME_SUMMARY_STATS |
7648 SME_GLOBAL_CLASSA_STATS |
7649 SME_GLOBAL_CLASSB_STATS |
7650 SME_GLOBAL_CLASSC_STATS |
7651 SME_GLOBAL_CLASSD_STATS |
7652 SME_PER_STA_STATS,
7653 hdd_StatisticsCB, 0, FALSE,
7654 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
7655
7656 if (eHAL_STATUS_SUCCESS != status)
7657 {
7658 hddLog(VOS_TRACE_LEVEL_ERROR,
7659 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007660 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 return -EINVAL;
7662 }
7663
7664 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7665
7666 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
7667 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7668 {
7669 hddLog(VOS_TRACE_LEVEL_ERROR,
7670 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007671 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 /*Remove the SME statistics list by passing NULL in callback argument*/
7673 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
7674 SME_SUMMARY_STATS |
7675 SME_GLOBAL_CLASSA_STATS |
7676 SME_GLOBAL_CLASSB_STATS |
7677 SME_GLOBAL_CLASSC_STATS |
7678 SME_GLOBAL_CLASSD_STATS |
7679 SME_PER_STA_STATS,
7680 NULL, 0, FALSE,
7681 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
7682
7683 return -EINVAL;
7684 }
7685 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
7686 (tANI_U8) sizeof (pStats->retry_cnt),
7687 (char*) &(pStats->retry_cnt[0]),
7688 tlen);
7689
7690 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
7691 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
7692 (char*) &(pStats->multiple_retry_cnt[0]),
7693 tlen);
7694
7695 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
7696 (tANI_U8) sizeof (pStats->tx_frm_cnt),
7697 (char*) &(pStats->tx_frm_cnt[0]),
7698 tlen);
7699
7700 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
7701 (tANI_U8) sizeof (pStats->rx_frm_cnt),
7702 (char*) &(pStats->rx_frm_cnt),
7703 tlen);
7704
7705 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
7706 (tANI_U8) sizeof (pStats->frm_dup_cnt),
7707 (char*) &(pStats->frm_dup_cnt),
7708 tlen);
7709
7710 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
7711 (tANI_U8) sizeof (pStats->fail_cnt),
7712 (char*) &(pStats->fail_cnt[0]),
7713 tlen);
7714
7715 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
7716 (tANI_U8) sizeof (pStats->rts_fail_cnt),
7717 (char*) &(pStats->rts_fail_cnt),
7718 tlen);
7719
7720 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
7721 (tANI_U8) sizeof (pStats->ack_fail_cnt),
7722 (char*) &(pStats->ack_fail_cnt),
7723 tlen);
7724
7725 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
7726 (tANI_U8) sizeof (pStats->rts_succ_cnt),
7727 (char*) &(pStats->rts_succ_cnt),
7728 tlen);
7729
7730 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
7731 (tANI_U8) sizeof (pStats->rx_discard_cnt),
7732 (char*) &(pStats->rx_discard_cnt),
7733 tlen);
7734
7735 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
7736 (tANI_U8) sizeof (pStats->rx_error_cnt),
7737 (char*) &(pStats->rx_error_cnt),
7738 tlen);
7739
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007740 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07007741 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007742 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 tlen);
7744
7745 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
7746 (tANI_U8) sizeof (dStats->rx_byte_cnt),
7747 (char*) &(dStats->rx_byte_cnt),
7748 tlen);
7749
7750 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
7751 (tANI_U8) sizeof (dStats->rx_rate),
7752 (char*) &(dStats->rx_rate),
7753 tlen);
7754
7755 /* Transmit rate, in units of 500 kbit/sec */
7756 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
7757 (tANI_U8) sizeof (aStats->tx_rate),
7758 (char*) &(aStats->tx_rate),
7759 tlen);
7760
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007761 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
7762 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
7763 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07007764 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007765 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
7766 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
7767 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007768 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007769 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
7770 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
7771 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007772 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007773 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
7774 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
7775 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07007776 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007777 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
7778 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
7779 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007780 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007781 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
7782 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
7783 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07007784 tlen);
7785
Jeff Johnson295189b2012-06-20 16:38:30 -07007786 wrqu->data.length = tlen;
7787
7788 }
7789
7790 EXIT();
7791
7792 return 0;
7793}
7794
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307795static int iw_get_statistics(struct net_device *dev,
7796 struct iw_request_info *info,
7797 union iwreq_data *wrqu, char *extra)
7798{
7799 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007800
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307801 vos_ssr_protect(__func__);
7802 ret = __iw_get_statistics(dev, info, wrqu, extra);
7803 vos_ssr_unprotect(__func__);
7804
7805 return ret;
7806}
Jeff Johnson295189b2012-06-20 16:38:30 -07007807#ifdef FEATURE_WLAN_SCAN_PNO
7808
7809/*Max Len for PNO notification*/
7810#define MAX_PNO_NOTIFY_LEN 100
7811void found_pref_network_cb (void *callbackContext,
7812 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7813{
7814 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7815 union iwreq_data wrqu;
7816 char buf[MAX_PNO_NOTIFY_LEN+1];
7817
7818 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
7819 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
7820
7821 // create the event
7822 memset(&wrqu, 0, sizeof(wrqu));
7823 memset(buf, 0, sizeof(buf));
7824
7825 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
7826 pPrefNetworkFoundInd->ssId.ssId,
7827 (unsigned int)pPrefNetworkFoundInd->rssi);
7828
7829 wrqu.data.pointer = buf;
7830 wrqu.data.length = strlen(buf);
7831
7832 // send the event
7833
7834 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
7835
7836}
7837
7838
7839/*string based input*/
7840VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
7841 union iwreq_data *wrqu, char *extra, int nOffset)
7842{
7843 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05307844 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07007845 /* pnoRequest is a large struct, so we make it static to avoid stack
7846 overflow. This API is only invoked via ioctl, so it is
7847 serialized by the kernel rtnl_lock and hence does not need to be
7848 reentrant */
7849 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 char *ptr;
7851 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05307852 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007853 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7854
7855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7856 "PNO data len %d data %s",
7857 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007858 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007859
7860 if (wrqu->data.length <= nOffset )
7861 {
7862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
7863 return VOS_STATUS_E_FAILURE;
7864 }
7865
7866 pnoRequest.enable = 0;
7867 pnoRequest.ucNetworksCount = 0;
7868 /*-----------------------------------------------------------------------
7869 Input is string based and expected to be like this:
7870
7871 <enabled> <netw_count>
7872 for each network:
7873 <ssid_len> <ssid> <authentication> <encryption>
7874 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
7875 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
7876
7877 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07007878 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 -07007879
7880 this translates into:
7881 -----------------------------
7882 enable PNO
7883 look for 2 networks:
7884 test - with authentication type 0 and encryption type 0,
7885 that can be found on 3 channels: 1 6 and 11 ,
7886 SSID bcast type is unknown (directed probe will be sent if AP not found)
7887 and must meet -40dBm RSSI
7888
7889 test2 - with auth and enrytption type 4/4
7890 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
7891 bcast type is non-bcast (directed probe will be sent)
7892 and must not meet any RSSI threshold
7893
Jeff Johnson8301aa12013-03-28 14:27:29 -07007894 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07007895 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08007896 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007897
Wilson Yang623f6592013-10-08 16:33:37 -07007898 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
7899 {
7900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7901 "PNO enable input is not valid %s",ptr);
7902 return VOS_STATUS_E_FAILURE;
7903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007904
7905 if ( 0 == pnoRequest.enable )
7906 {
7907 /*Disable PNO*/
7908 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05307909 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7910 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 pAdapter->sessionId,
7912 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307913 if (eHAL_STATUS_SUCCESS != status)
7914 {
7915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7916 "%s: failed to disable PNO", __func__);
7917 return VOS_STATUS_E_FAILURE;
7918 }
7919 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 return VOS_STATUS_SUCCESS;
7921 }
7922
c_hpothu37f21312014-04-09 21:49:54 +05307923 if (TRUE == pHddCtx->isPnoEnable)
7924 {
7925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7926 FL("already PNO is enabled"));
7927 return -EBUSY;
7928 }
7929 pHddCtx->isPnoEnable = TRUE;
7930
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07007932
7933 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
7934 {
7935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7936 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307937 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007939
7940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7941 "PNO enable %d networks count %d offset %d",
7942 pnoRequest.enable,
7943 pnoRequest.ucNetworksCount,
7944 nOffset);
7945
7946 /* Parameters checking:
7947 ucNetworksCount has to be larger than 0*/
7948 if (( 0 == pnoRequest.ucNetworksCount ) ||
7949 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7950 {
7951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05307952 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 }
7954
7955 ptr += nOffset;
7956
7957 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
7958 {
7959
7960 pnoRequest.aNetworks[i].ssId.length = 0;
7961
Wilson Yang623f6592013-10-08 16:33:37 -07007962 ucParams = sscanf(ptr,"%hhu %n",
7963 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
7964
7965 if (1 != ucParams)
7966 {
7967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7968 "PNO ssid length input is not valid %s",ptr);
7969 return VOS_STATUS_E_FAILURE;
7970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007971
7972 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
7973 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
7974 {
7975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7976 "SSID Len %d is not correct for network %d",
7977 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05307978 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007979 }
7980
7981 /*Advance to SSID*/
7982 ptr += nOffset;
7983
Jeff Johnson8301aa12013-03-28 14:27:29 -07007984 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08007985 pnoRequest.aNetworks[i].ssId.length);
7986 ptr += pnoRequest.aNetworks[i].ssId.length;
7987
Jeff Johnson02797792013-10-26 19:17:13 -07007988 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08007989 &(pnoRequest.aNetworks[i].authentication),
7990 &(pnoRequest.aNetworks[i].encryption),
7991 &(pnoRequest.aNetworks[i].ucChannelCount),
7992 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007993
Wilson Yang623f6592013-10-08 16:33:37 -07007994 if ( 3 != ucParams )
7995 {
7996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7997 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307998 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007999 }
8000
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008002 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08008003 "auth %d encry %d channel count %d offset %d",
8004 pnoRequest.aNetworks[i].ssId.length,
8005 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
8006 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
8007 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
8008 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
8009 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
8010 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
8011 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
8012 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
8013 pnoRequest.aNetworks[i].authentication,
8014 pnoRequest.aNetworks[i].encryption,
8015 pnoRequest.aNetworks[i].ucChannelCount,
8016 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07008017
Jeff Johnson295189b2012-06-20 16:38:30 -07008018 /*Advance to channel list*/
8019 ptr += nOffset;
8020
Wilson Yang623f6592013-10-08 16:33:37 -07008021 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07008022 {
8023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8024 "Incorrect number of channels");
8025 return VOS_STATUS_E_FAILURE;
8026 }
8027
8028 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
8029 {
8030 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
8031 {
Wilson Yang623f6592013-10-08 16:33:37 -07008032 if (1 != sscanf(ptr,"%hhu %n",
8033 &(pnoRequest.aNetworks[i].aChannels[j]),
8034 &nOffset))
8035 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8036 "PNO network channel input is not valid %s",ptr);
8037 return VOS_STATUS_E_FAILURE;
8038 }
8039 /*Advance to next channel number*/
8040 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 }
8042 }
8043
Jeff Johnson02797792013-10-26 19:17:13 -07008044 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07008045 &(pnoRequest.aNetworks[i].bcastNetwType),
8046 &nOffset))
8047 {
8048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8049 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308050 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008052
8053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8054 "PNO bcastNetwType %d offset %d",
8055 pnoRequest.aNetworks[i].bcastNetwType,
8056 nOffset );
8057
8058 /*Advance to rssi Threshold*/
8059 ptr += nOffset;
8060
Wilson Yang623f6592013-10-08 16:33:37 -07008061 if (1 != sscanf(ptr,"%hhu %n",
8062 &(pnoRequest.aNetworks[i].rssiThreshold),
8063 &nOffset))
8064 {
8065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8066 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308067 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008069
8070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8071 "PNO rssi %d offset %d",
8072 pnoRequest.aNetworks[i].rssiThreshold,
8073 nOffset );
8074 /*Advance to next network*/
8075 ptr += nOffset;
8076 }/*For ucNetworkCount*/
8077
8078 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07008079 &(pnoRequest.scanTimers.ucScanTimersCount),
8080 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008081
8082 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07008083 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07008084 {
8085 ptr += nOffset;
8086
Jeff Johnson8301aa12013-03-28 14:27:29 -07008087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8088 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 pnoRequest.scanTimers.ucScanTimersCount,
8090 nOffset );
8091
8092 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
8093 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07008094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008095 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05308096 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 }
8098
8099 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
8100 {
Jeff Johnson02797792013-10-26 19:17:13 -07008101 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
8103 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
8104 &nOffset);
8105
Wilson Yang623f6592013-10-08 16:33:37 -07008106 if (2 != ucParams)
8107 {
8108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8109 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05308110 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008111 }
8112
Jeff Johnson8301aa12013-03-28 14:27:29 -07008113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8114 "PNO Timer value %d Timer repeat %d offset %d",
8115 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07008116 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
8117 nOffset );
8118
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 ptr += nOffset;
8120 }
8121
8122 }
8123 else
8124 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07008125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8126 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
8128
8129 /*Scan timers defaults to 5 minutes*/
8130 pnoRequest.scanTimers.ucScanTimersCount = 1;
8131 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
8132 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
8133 }
8134
Wilson Yang623f6592013-10-08 16:33:37 -07008135 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008136
8137 pnoRequest.modePNO = ucMode;
8138 /*for LA we just expose suspend option*/
8139 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
8140 {
8141 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
8142 }
8143
c_hpothu37f21312014-04-09 21:49:54 +05308144 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 pAdapter->sessionId,
8146 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308147 if (eHAL_STATUS_SUCCESS == status)
8148 {
8149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8150 "%s: PNO enabled", __func__);
8151 return VOS_STATUS_SUCCESS;
8152 }
8153error:
8154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8155 "%s: Failed to enable PNO", __func__);
8156 pHddCtx->isPnoEnable = FALSE;
8157 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008158}/*iw_set_pno*/
8159
8160VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
8161 union iwreq_data *wrqu, char *extra, int nOffset)
8162{
8163 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8164 v_U8_t rssiThreshold = 0;
8165 v_U8_t nRead;
8166
Arif Hussain7adce1b2013-11-11 22:59:34 -08008167 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008168 &rssiThreshold);
8169
8170 if ( 1 != nRead )
8171 {
8172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8173 "Incorrect format");
8174 return VOS_STATUS_E_FAILURE;
8175 }
8176
8177 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
8178 return VOS_STATUS_SUCCESS;
8179}
8180
8181
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308182static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 struct iw_request_info *info,
8184 union iwreq_data *wrqu, char *extra)
8185{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008186 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8187
8188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008190
8191 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
8192 {
8193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8194 "%s:LOGP in Progress. Ignore!!!", __func__);
8195 return -EBUSY;
8196 }
8197 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008198}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308199
8200static int iw_set_pno_priv(struct net_device *dev,
8201 struct iw_request_info *info,
8202 union iwreq_data *wrqu, char *extra)
8203{
8204 int ret;
8205
8206 vos_ssr_protect(__func__);
8207 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
8208 vos_ssr_unprotect(__func__);
8209
8210 return ret;
8211}
Jeff Johnson295189b2012-06-20 16:38:30 -07008212#endif /*FEATURE_WLAN_SCAN_PNO*/
8213
8214//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05308215int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07008216{
8217 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8218 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8219 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308220 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05308221 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07008222 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05308223 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05308224 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
8225 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07008226
Atul Mittal54378cb2014-04-02 16:51:50 +05308227 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 {
8229 case WLAN_HDD_UI_BAND_AUTO:
8230 band = eCSR_BAND_ALL;
8231 break;
8232 case WLAN_HDD_UI_BAND_5_GHZ:
8233 band = eCSR_BAND_5G;
8234 break;
8235 case WLAN_HDD_UI_BAND_2_4_GHZ:
8236 band = eCSR_BAND_24;
8237 break;
8238 default:
8239 band = eCSR_BAND_MAX;
8240 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05308241 connectedBand =
8242 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07008243
Atul Mittal54378cb2014-04-02 16:51:50 +05308244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008245 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07008246
8247 if (band == eCSR_BAND_MAX)
8248 {
8249 /* Received change band request with invalid band value */
8250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05308251 "%s: Invalid band value %u", __func__, ui_band);
8252 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008253 }
8254
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05308255 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
8256 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
8257 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
8258 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05308259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008260 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008261 band, pHddCtx->cfg_ini->nBandCapability);
8262 return -EIO;
8263 }
8264
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
8266 {
8267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8268 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008269 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008270 return -EIO;
8271 }
8272
8273 if (currBand != band)
8274 {
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05308275 /* Return failure if current country code is world regulatory domain*/
8276 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
8277 pMac->scan.countryCodeCurrent[1] == '0') )
8278 {
8279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8280 "%s: failed to set the band value to %u as country code is 00",
8281 __func__, band);
8282 return -EAGAIN;
8283 }
8284
Jeff Johnson295189b2012-06-20 16:38:30 -07008285 /* Change band request received.
8286 * Abort pending scan requests, flush the existing scan results,
8287 * and change the band capability
8288 */
8289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8290 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008291 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07008292
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05308293 /* We need to change the band and flush the scan results here itself
8294 * as we may get timeout for disconnection in which we will return
8295 * with out doing any of these
8296 */
8297 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
8298 {
8299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8300 "%s: failed to set the band value to %u ",
8301 __func__, band);
8302 return -EINVAL;
8303 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05308304 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
8305 {
8306 v_COUNTRYCODE_t curr_country;
8307 curr_country[0]=pMac->scan.countryCodeCurrent[0];
8308 curr_country[1]=pMac->scan.countryCodeCurrent[1];
8309
8310 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
8311 * information available in NV so to get the channel information from kernel
8312 * we need to send regulatory hint for the currunt country
8313 * And to set the same country again we need to set the dummy country
8314 * first and then the actual country.
8315 */
8316
8317#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
8318 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
8319#else
8320 regulatory_hint_user("00");
8321#endif
8322
8323 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
8324#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
8325 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
8326#else
8327 regulatory_hint_user(curr_country);
8328#endif
8329 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
8330 }
8331 else
8332 {
Abhishek Singh678227a2014-11-04 10:52:38 +05308333#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05308334 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
8335 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05308336#else
8337 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
8338#endif
8339
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05308340 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05308341 pScanInfo = &pHddCtx->scan_info;
8342 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
8343 {
8344 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
8345 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
8346 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05308347 sme_FilterScanResults(hHal, pAdapter->sessionId);
8348
8349 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05308350 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
8351 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008353 eHalStatus status = eHAL_STATUS_SUCCESS;
8354 long lrc;
8355
8356 /* STA already connected on current band, So issue disconnect first,
8357 * then change the band*/
8358
8359 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05308360 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05308361 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07008362
Jeff Johnson295189b2012-06-20 16:38:30 -07008363 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8364
8365 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8366 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
8367
Jeff Johnson43971f52012-07-17 12:26:56 -07008368 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 {
8370 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008371 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 __func__, (int)status );
8373 return -EINVAL;
8374 }
8375
8376 lrc = wait_for_completion_interruptible_timeout(
8377 &pAdapter->disconnect_comp_var,
8378 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8379
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05308380 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07008381
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07008382 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008383 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07008384
8385 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
8386 }
8387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008388 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05308389 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008390}
8391
Atul Mittal54378cb2014-04-02 16:51:50 +05308392int hdd_setBand_helper(struct net_device *dev, const char *command)
8393{
8394 u8 band;
8395
8396 /*convert the band value from ascii to integer*/
8397 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
8398
8399 return hdd_setBand(dev, band);
8400
8401}
8402
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308403static int __iw_set_band_config(struct net_device *dev,
8404 struct iw_request_info *info,
8405 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008406{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008407 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05308408 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008409
Arif Hussain0273cba2014-01-07 20:58:29 -08008410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008411
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008412 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
8413 {
8414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8415 "%s:LOGP in Progress. Ignore!!!", __func__);
8416 return -EBUSY;
8417 }
8418
Atul Mittal54378cb2014-04-02 16:51:50 +05308419 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008420}
8421
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308422static int iw_set_band_config(struct net_device *dev,
8423 struct iw_request_info *info,
8424 union iwreq_data *wrqu, char *extra)
8425{
8426 int ret;
8427
8428 vos_ssr_protect(__func__);
8429 ret = __iw_set_band_config(dev, info, wrqu, extra);
8430 vos_ssr_unprotect(__func__);
8431
8432 return ret;
8433}
8434
8435static int __iw_set_power_params_priv(struct net_device *dev,
8436 struct iw_request_info *info,
8437 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008438{
Arif Hussain0273cba2014-01-07 20:58:29 -08008439 int ret;
8440 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07008441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8442 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08008443 /* ODD number is used for set, copy data using copy_from_user */
8444 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
8445 wrqu->data.length);
8446 if (NULL == ptr)
8447 {
8448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8449 "mem_alloc_copy_from_user_helper fail");
8450 return -ENOMEM;
8451 }
8452
8453 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
8454 kfree(ptr);
8455 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008456}
8457
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308458static int iw_set_power_params_priv(struct net_device *dev,
8459 struct iw_request_info *info,
8460 union iwreq_data *wrqu, char *extra)
8461{
8462 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008463
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308464 vos_ssr_protect(__func__);
8465 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
8466 vos_ssr_unprotect(__func__);
8467
8468 return ret;
8469}
Jeff Johnson295189b2012-06-20 16:38:30 -07008470
8471/*string based input*/
8472VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
8473 union iwreq_data *wrqu, char *extra, int nOffset)
8474{
8475 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8476 tSirSetPowerParamsReq powerRequest;
8477 char *ptr;
8478 v_U8_t ucType;
8479 v_U32_t uTotalSize, uValue;
8480 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8481
8482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8483 "Power Params data len %d data %s",
8484 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008485 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008486
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008487 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
8488 {
8489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8490 "%s:LOGP in Progress. Ignore!!!", __func__);
8491 return -EBUSY;
8492 }
8493
Jeff Johnson295189b2012-06-20 16:38:30 -07008494 if (wrqu->data.length <= nOffset )
8495 {
8496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
8497 return VOS_STATUS_E_FAILURE;
8498 }
8499
8500 uTotalSize = wrqu->data.length - nOffset;
8501
8502 /*-----------------------------------------------------------------------
8503 Input is string based and expected to be like this:
8504
8505 <param_type> <param_value> <param_type> <param_value> ...
8506
8507 e.g:
8508 1 2 2 3 3 0 4 1 5 1
8509
8510 e.g. setting just a few:
8511 1 2 4 1
8512
8513 parameter types:
8514 -----------------------------
8515 1 - Ignore DTIM
8516 2 - Listen Interval
8517 3 - Broadcast Multicas Filter
8518 4 - Beacon Early Termination
8519 5 - Beacon Early Termination Interval
8520 -----------------------------------------------------------------------*/
8521 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
8522 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
8523 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
8524 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
8525 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
8526
Arif Hussain7adce1b2013-11-11 22:59:34 -08008527 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008528
8529 while ( uTotalSize )
8530 {
Wilson Yang6f971452013-10-08 15:00:00 -07008531 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
8532 {
8533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8534 "Invalid input parameter type %s",ptr);
8535 return VOS_STATUS_E_FAILURE;
8536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008537
8538 uTotalSize -= nOffset;
8539
8540 if (!uTotalSize)
8541 {
8542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08008543 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008544 ucType, nOffset);
8545 return VOS_STATUS_E_FAILURE;
8546 }
8547
8548 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07008549
Jeff Johnson02797792013-10-26 19:17:13 -07008550 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07008551 {
8552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8553 "Invalid input parameter value %s",ptr);
8554 return VOS_STATUS_E_FAILURE;
8555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008556
8557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8558 "Power request parameter %d value %d offset %d",
8559 ucType, uValue, nOffset);
8560
8561 switch (ucType)
8562 {
8563 case eSIR_IGNORE_DTIM:
8564 powerRequest.uIgnoreDTIM = uValue;
8565 break;
8566 case eSIR_LISTEN_INTERVAL:
8567 powerRequest.uListenInterval = uValue;
8568 break;
8569 case eSIR_MCAST_BCAST_FILTER:
8570 powerRequest.uBcastMcastFilter = uValue;
8571 break;
8572 case eSIR_ENABLE_BET:
8573 powerRequest.uEnableBET = uValue;
8574 break;
8575 case eSIR_BET_INTERVAL:
8576 powerRequest.uBETInterval = uValue;
8577 break;
8578 default:
8579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08008580 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008581 ucType, uValue, nOffset);
8582 return VOS_STATUS_E_FAILURE;
8583 }
8584
8585 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008586 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8587 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07008588 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07008589 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07008590 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008591 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07008592 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
8593 {
8594 uTotalSize = 0;
8595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008596
8597 }/*Go for as long as we have a valid string*/
8598
8599 /* put the device into full power*/
8600 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
8601
8602 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08008603 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008604
8605 /* put the device back to power save*/
8606 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
8607
8608 return VOS_STATUS_SUCCESS;
8609}/*iw_set_power_params*/
8610
Atul Mittalc0f739f2014-07-31 13:47:47 +05308611// tdlsoffchan
8612#ifdef FEATURE_WLAN_TDLS
8613
Atul Mittal87ec2422014-09-24 13:12:50 +05308614int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05308615{
8616 if (offchannel < 0 || offchannel > 165)
8617 {
8618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
8619 __func__, offchannel);
8620 return -1;
8621
8622 }
8623
8624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
8625 __func__, tdlsOffCh, offchannel);
8626
8627 tdlsOffCh = offchannel;
8628 return 0;
8629}
8630
Atul Mittal87ec2422014-09-24 13:12:50 +05308631int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05308632{
8633 if (offchanoffset == 0)
8634 {
8635 tdlsOffChBwOffset = 0;
8636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
8637 __func__, tdlsOffChBwOffset);
8638
8639 return 0;
8640
8641 }
8642
8643 if ( offchanoffset == 40 )
8644 {
8645 tdlsOffChBwOffset = 1;
8646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
8647 __func__, tdlsOffChBwOffset);
8648
8649 return 0;
8650
8651 }
8652 if (offchanoffset == -40)
8653 {
8654 tdlsOffChBwOffset = 3;
8655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
8656 __func__, tdlsOffChBwOffset);
8657
8658 return 0;
8659
8660 }
8661 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
8662 __func__, offchanoffset);
8663 return -1;
8664}
8665
Atul Mittal87ec2422014-09-24 13:12:50 +05308666int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05308667{
8668 hddTdlsPeer_t *connPeer = NULL;
8669 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8670 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8671
8672 if (offchanmode < 0 || offchanmode > 4)
8673 {
8674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8675 "%s: Invalid tdls off channel mode %d",
8676 __func__, offchanmode);
8677 return -1;
8678 }
8679
8680 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
8681 {
8682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8683 "%s: tdls off channel mode req in not associated state %d",
8684 __func__, offchanmode);
8685 return -1;
8686 }
8687
8688 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
8689 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
8690 {
8691 /* Send TDLS Channel Switch Request to connected peer */
8692 connPeer = wlan_hdd_tdls_get_first_connected_peer(pAdapter);
8693 if (NULL == connPeer) {
8694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8695 "%s: No TDLS Connected Peer", __func__);
8696 return -1;
8697 }
8698 }
8699 else
8700 {
8701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8702 "%s: TDLS Connection not supported", __func__);
8703 return -1;
8704 }
8705
8706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8707 ("%s: TDLS Channel Switch in swmode=%d"),
8708 __func__, offchanmode);
8709
8710 switch (offchanmode)
8711 {
8712 case 1:/*Enable*/
8713 case 2:/*Disable*/
8714 {
8715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8716 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
8717 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8718 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
8719 {
8720
8721 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
8722 pAdapter->sessionId, connPeer->peerMac,
8723 tdlsOffCh, tdlsOffChBwOffset,
8724 offchanmode);
8725 }
8726 else
8727 {
8728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8729 "%s: TDLS Off Channel not supported", __func__);
8730 return -1;
8731 }
8732 break;
8733 }
8734 case 3:
8735 {
8736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8737 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
8738 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8739
8740 break;
8741 }
8742 case 4:
8743 {
8744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8745 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
8746 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8747 break;
8748 }
8749 default:
8750 {
8751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8752 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
8753 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
8754 break;
8755 }
8756
8757 }
8758
8759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
8760 __func__, offchanmode);
8761 return 0;
8762}
Atul Mittalc0f739f2014-07-31 13:47:47 +05308763#endif
8764
Jeff Johnson295189b2012-06-20 16:38:30 -07008765
8766// Define the Wireless Extensions to the Linux Network Device structure
8767// A number of these routines are NULL (meaning they are not implemented.)
8768
8769static const iw_handler we_handler[] =
8770{
8771 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
8772 (iw_handler) iw_get_name, /* SIOCGIWNAME */
8773 (iw_handler) NULL, /* SIOCSIWNWID */
8774 (iw_handler) NULL, /* SIOCGIWNWID */
8775 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
8776 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
8777 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
8778 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
8779 (iw_handler) NULL, /* SIOCSIWSENS */
8780 (iw_handler) NULL, /* SIOCGIWSENS */
8781 (iw_handler) NULL, /* SIOCSIWRANGE */
8782 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
8783 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
8784 (iw_handler) NULL, /* SIOCGIWPRIV */
8785 (iw_handler) NULL, /* SIOCSIWSTATS */
8786 (iw_handler) NULL, /* SIOCGIWSTATS */
8787 iw_handler_set_spy, /* SIOCSIWSPY */
8788 iw_handler_get_spy, /* SIOCGIWSPY */
8789 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
8790 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
8791 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
8792 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
8793 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
8794 (iw_handler) NULL, /* SIOCGIWAPLIST */
8795 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
8796 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
8797 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
8798 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
8799 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
8800 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
8801 (iw_handler) NULL, /* -- hole -- */
8802 (iw_handler) NULL, /* -- hole -- */
8803 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
8804 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
8805 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
8806 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
8807 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
8808 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
8809 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
8810 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
8811 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
8812 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
8813 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
8814 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
8815 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
8816 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
8817 (iw_handler) NULL, /* -- hole -- */
8818 (iw_handler) NULL, /* -- hole -- */
8819 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
8820 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
8821 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
8822 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
8823 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
8824 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
8825 (iw_handler) NULL, /* SIOCSIWPMKSA */
8826};
8827
8828static const iw_handler we_private[] = {
8829
8830 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
8831 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
8832 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
8833 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
8834 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
8835 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +05308836 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
8838 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
8839 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07008840#ifdef FEATURE_OEM_DATA_SUPPORT
8841 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
8842 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
8843#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008844
Jeff Johnson295189b2012-06-20 16:38:30 -07008845#ifdef WLAN_FEATURE_VOWIFI_11R
8846 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
8847#endif
8848 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
8849 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
8850 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
8851#ifdef WLAN_FEATURE_PACKET_FILTERING
8852 ,
8853 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
8854#endif
8855#ifdef FEATURE_WLAN_SCAN_PNO
8856 ,
8857 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
8858#endif
8859 ,
8860 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
8861 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
8862 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
8863 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07008864 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07008865};
8866
8867/*Maximum command length can be only 15 */
8868static const struct iw_priv_args we_private_args[] = {
8869
8870 /* handlers for main ioctl */
8871 { WLAN_PRIV_SET_INT_GET_NONE,
8872 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8873 0,
8874 "" },
8875
8876 /* handlers for sub-ioctl */
8877 { WE_SET_11D_STATE,
8878 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8879 0,
8880 "set11Dstate" },
8881
8882 { WE_WOWL,
8883 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8884 0,
8885 "wowl" },
8886
8887 { WE_SET_POWER,
8888 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8889 0,
8890 "setPower" },
8891
8892 { WE_SET_MAX_ASSOC,
8893 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8894 0,
8895 "setMaxAssoc" },
8896
8897 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
8898 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8899 0,
8900 "setAutoChannel" },
8901
8902 { WE_SET_DATA_INACTIVITY_TO,
8903 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8904 0,
8905 "inactivityTO" },
8906
8907 { WE_SET_MAX_TX_POWER,
8908 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8909 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07008910 "setMaxTxPower" },
8911
8912 { WE_SET_MAX_TX_POWER_2_4,
8913 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8914 0,
8915 "setTxMaxPower2G" },
8916
8917 { WE_SET_MAX_TX_POWER_5_0,
8918 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8919 0,
8920 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07008921
8922 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
8923 * as well to keep same syntax as in SAP. Now onwards, STA
8924 * will support both */
8925 { WE_SET_MAX_TX_POWER,
8926 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8927 0,
8928 "setTxMaxPower" },
8929
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 /* set Higher DTIM Transition (DTIM1 to DTIM3)
8931 * 1 = enable and 0 = disable */
8932 {
8933 WE_SET_HIGHER_DTIM_TRANSITION,
8934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8935 0,
8936 "setHDtimTransn" },
8937
8938 { WE_SET_TM_LEVEL,
8939 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008940 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 "setTmLevel" },
8942
Kiet Lam46b8e4e2013-11-06 21:49:53 +05308943 { WE_ENABLE_STRICT_FCC_REG,
8944 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8945 0,
8946 "setStrictFCCreg" },
8947
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08008948 { WE_SET_DEBUG_LOG,
8949 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8950 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +05308951#ifdef FEATURE_WLAN_TDLS
8952 {
8953 WE_SET_TDLS_OFF_CHAN,
8954 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8955 0,
8956 "tdlsoffchan" },
8957 {
8958 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
8959 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8960 0,
8961 "tdlsecchnoffst" },
8962 {
8963 WE_SET_TDLS_OFF_CHAN_MODE,
8964 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8965 0,
8966 "tdlsoffchnmode" },
8967#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08008968
Peng Xu2446a892014-09-05 17:21:18 +05308969 { WE_SET_SCAN_BAND_PREFERENCE,
8970 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8971 0, "set_scan_pref" },
8972
Jeff Johnson295189b2012-06-20 16:38:30 -07008973 /* handlers for main ioctl */
8974 { WLAN_PRIV_SET_NONE_GET_INT,
8975 0,
8976 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8977 "" },
8978
8979 /* handlers for sub-ioctl */
8980 { WE_GET_11D_STATE,
8981 0,
8982 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8983 "get11Dstate" },
8984
8985 { WE_IBSS_STATUS,
8986 0,
8987 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8988 "getAdhocStatus" },
8989
8990 { WE_PMC_STATE,
8991 0,
8992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8993 "pmcState" },
8994
8995 { WE_GET_WLAN_DBG,
8996 0,
8997 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8998 "getwlandbg" },
8999
Jeff Johnson295189b2012-06-20 16:38:30 -07009000 { WE_GET_MAX_ASSOC,
9001 0,
9002 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9003 "getMaxAssoc" },
9004
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 { WE_GET_WDI_DBG,
9006 0,
9007 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9008 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009009
9010 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
9011 0,
9012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9013 "getAutoChannel" },
9014
9015 { WE_GET_CONCURRENCY_MODE,
9016 0,
9017 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9018 "getconcurrency" },
9019
Peng Xu2446a892014-09-05 17:21:18 +05309020 { WE_GET_SCAN_BAND_PREFERENCE,
9021 0,
9022 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9023 "get_scan_pref"},
9024
Jeff Johnson295189b2012-06-20 16:38:30 -07009025 /* handlers for main ioctl */
9026 { WLAN_PRIV_SET_CHAR_GET_NONE,
9027 IW_PRIV_TYPE_CHAR| 512,
9028 0,
9029 "" },
9030
9031 /* handlers for sub-ioctl */
9032 { WE_WOWL_ADD_PTRN,
9033 IW_PRIV_TYPE_CHAR| 512,
9034 0,
9035 "wowlAddPtrn" },
9036
9037 { WE_WOWL_DEL_PTRN,
9038 IW_PRIV_TYPE_CHAR| 512,
9039 0,
9040 "wowlDelPtrn" },
9041
9042#if defined WLAN_FEATURE_VOWIFI
9043 /* handlers for sub-ioctl */
9044 { WE_NEIGHBOR_REPORT_REQUEST,
9045 IW_PRIV_TYPE_CHAR | 512,
9046 0,
9047 "neighbor" },
9048#endif
9049 { WE_SET_AP_WPS_IE,
9050 IW_PRIV_TYPE_CHAR| 512,
9051 0,
9052 "set_ap_wps_ie" },
9053
9054 { WE_SET_CONFIG,
9055 IW_PRIV_TYPE_CHAR| 512,
9056 0,
9057 "setConfig" },
9058
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05309059 { WE_SET_ENCRYPT_MSG,
9060 IW_PRIV_TYPE_CHAR| 512,
9061 0,
9062 "encryptMsg" },
9063
9064
Jeff Johnson295189b2012-06-20 16:38:30 -07009065 /* handlers for main ioctl */
9066 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
9067 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9068 0,
9069 "" },
9070
9071 /* handlers for sub-ioctl */
9072 { WE_SET_WLAN_DBG,
9073 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9074 0,
9075 "setwlandbg" },
9076
Jeff Johnson295189b2012-06-20 16:38:30 -07009077 { WE_SET_WDI_DBG,
9078 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9079 0,
9080 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009081
9082 { WE_SET_SAP_CHANNELS,
9083 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9084 0,
9085 "setsapchannels" },
9086
9087 /* handlers for main ioctl */
9088 { WLAN_PRIV_GET_CHAR_SET_NONE,
9089 0,
9090 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9091 "" },
9092
9093 /* handlers for sub-ioctl */
9094 { WE_WLAN_VERSION,
9095 0,
9096 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9097 "version" },
9098 { WE_GET_STATS,
9099 0,
9100 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9101 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309102 { WE_GET_STATES,
9103 0,
9104 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9105 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009106 { WE_GET_CFG,
9107 0,
9108 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9109 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07009110#ifdef WLAN_FEATURE_11AC
9111 { WE_GET_RSSI,
9112 0,
9113 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9114 "getRSSI" },
9115#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009116#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009117 { WE_GET_ROAM_RSSI,
9118 0,
9119 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9120 "getRoamRSSI" },
9121#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009122 { WE_GET_WMM_STATUS,
9123 0,
9124 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9125 "getWmmStatus" },
9126 {
9127 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309128 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9130 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08009131#ifdef FEATURE_WLAN_TDLS
9132 {
9133 WE_GET_TDLS_PEERS,
9134 0,
9135 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9136 "getTdlsPeers" },
9137#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009138#ifdef WLAN_FEATURE_11W
9139 {
9140 WE_GET_11W_INFO,
9141 0,
9142 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9143 "getPMFInfo" },
9144#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05309145 { WE_GET_SNR,
9146 0,
9147 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9148 "getSNR" },
9149
Jeff Johnson295189b2012-06-20 16:38:30 -07009150 /* handlers for main ioctl */
9151 { WLAN_PRIV_SET_NONE_GET_NONE,
9152 0,
9153 0,
9154 "" },
9155
9156 /* handlers for sub-ioctl */
9157 { WE_CLEAR_STATS,
9158 0,
9159 0,
9160 "clearStats" },
9161 { WE_INIT_AP,
9162 0,
9163 0,
9164 "initAP" },
9165 { WE_STOP_AP,
9166 0,
9167 0,
9168 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +05309169#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 { WE_ENABLE_AMP,
9171 0,
9172 0,
9173 "enableAMP" },
9174 { WE_DISABLE_AMP,
9175 0,
9176 0,
9177 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +05309178#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07009179 { WE_ENABLE_DXE_STALL_DETECT,
9180 0,
9181 0,
9182 "dxeStallDetect" },
9183 { WE_DISPLAY_DXE_SNAP_SHOT,
9184 0,
9185 0,
9186 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05309187 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
9188 0,
9189 0,
9190 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07009191 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05309192 WE_SET_REASSOC_TRIGGER,
9193 0,
9194 0,
9195 "reassoc" },
9196 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05309197 WE_STOP_OBSS_SCAN,
9198 0,
9199 0,
9200 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +05309201#ifdef DEBUG_ROAM_DELAY
9202 {
9203 WE_DUMP_ROAM_TIMER_LOG,
9204 0,
9205 0,
9206 "dumpRoamDelay" },
9207 {
9208 WE_RESET_ROAM_TIMER_LOG,
9209 0,
9210 0,
9211 "resetRoamDelay" },
9212#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 /* handlers for main ioctl */
9214 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
9215 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9216 0,
9217 "" },
9218
9219 /* handlers for sub-ioctl */
9220 { WE_LOG_DUMP_CMD,
9221 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9222 0,
9223 "dump" },
9224
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07009225 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05309226 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
9227 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9228 0,
9229 "setdumplog" },
9230
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07009231 { WE_MTRACE_DUMP_CMD,
9232 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9233 0,
9234 "dumplog" },
9235
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009236 /* handlers for sub ioctl */
9237 {
9238 WE_MCC_CONFIG_CREDENTIAL,
9239 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9240 0,
9241 "setMccCrdnl" },
9242
9243 /* handlers for sub ioctl */
9244 {
9245 WE_MCC_CONFIG_PARAMS,
9246 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9247 0,
9248 "setMccConfig" },
9249
Chilam NG571c65a2013-01-19 12:27:36 +05309250#ifdef FEATURE_WLAN_TDLS
9251 /* handlers for sub ioctl */
9252 {
9253 WE_TDLS_CONFIG_PARAMS,
9254 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9255 0,
9256 "setTdlsConfig" },
9257#endif
9258
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 /* handlers for main ioctl */
9260 { WLAN_PRIV_ADD_TSPEC,
9261 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
9262 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9263 "addTspec" },
9264
9265 /* handlers for main ioctl */
9266 { WLAN_PRIV_DEL_TSPEC,
9267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9268 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9269 "delTspec" },
9270
9271 /* handlers for main ioctl */
9272 { WLAN_PRIV_GET_TSPEC,
9273 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9274 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9275 "getTspec" },
9276
Jeff Johnsone7245742012-09-05 17:12:55 -07009277#ifdef FEATURE_OEM_DATA_SUPPORT
9278 /* handlers for main ioctl - OEM DATA */
9279 {
9280 WLAN_PRIV_SET_OEM_DATA_REQ,
9281 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
9282 0,
9283 "set_oem_data_req" },
9284
9285 /* handlers for main ioctl - OEM DATA */
9286 {
9287 WLAN_PRIV_GET_OEM_DATA_RSP,
9288 0,
9289 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
9290 "get_oem_data_rsp" },
9291#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009292
Jeff Johnson295189b2012-06-20 16:38:30 -07009293 /* handlers for main ioctl - host offload */
9294 {
9295 WLAN_PRIV_SET_HOST_OFFLOAD,
9296 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
9297 0,
9298 "setHostOffload" },
9299
9300 {
9301 WLAN_GET_WLAN_STATISTICS,
9302 0,
9303 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
9304 "getWlanStats" },
9305
9306 {
9307 WLAN_SET_KEEPALIVE_PARAMS,
9308 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
9309 0,
9310 "setKeepAlive" },
9311#ifdef WLAN_FEATURE_PACKET_FILTERING
9312 {
9313 WLAN_SET_PACKET_FILTER_PARAMS,
9314 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
9315 0,
9316 "setPktFilter" },
9317#endif
9318#ifdef FEATURE_WLAN_SCAN_PNO
9319 {
9320 WLAN_SET_PNO,
9321 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9322 0,
9323 "setpno" },
9324#endif
9325 {
9326 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05309327 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 0,
9329 "SETBAND" },
9330 /* handlers for dynamic MC BC ioctl */
9331 {
9332 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08009333 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 0,
9335 "setMCBCFilter" },
9336 {
9337 WLAN_PRIV_CLEAR_MCBC_FILTER,
9338 0,
9339 0,
9340 "clearMCBCFilter" },
9341 {
9342 WLAN_SET_POWER_PARAMS,
9343 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9344 0,
9345 "setpowerparams" },
9346 {
9347 WLAN_GET_LINK_SPEED,
9348 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05309349 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009350};
9351
9352
9353
9354const struct iw_handler_def we_handler_def = {
9355 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
9356 .num_private = sizeof(we_private) / sizeof(we_private[0]),
9357 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
9358
9359 .standard = (iw_handler *)we_handler,
9360 .private = (iw_handler *)we_private,
9361 .private_args = we_private_args,
9362 .get_wireless_stats = get_wireless_stats,
9363};
9364
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009365int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
9366{
9367 v_U32_t cmd = 288; //Command to RIVA
9368 hdd_context_t *pHddCtx = NULL;
9369 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9370 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9371 /*
9372 *configMccParam : specify the bit which needs to be modified
9373 *allowed to update based on wlan_qcom_cfg.ini
9374 * configuration
9375 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
9376 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
9377 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
9378 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
9379 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
9380 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
9381 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
9382 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
9383 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
9384 * Bit 9 : Reserved
9385 */
9386 switch (arg1)
9387 {
9388 //Update MCC SCHEDULE_TIME_SLICE parameter
9389 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
9390 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
9391 {
9392 if((arg2 >= 5) && (arg2 <= 20))
9393 {
9394 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9395 }
9396 else
9397 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009398 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009399 return 0;
9400 }
9401 }
9402 break;
9403
9404 //Update MCC MAX_NULL_SEND_TIME parameter
9405 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
9406 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
9407 {
9408 if((arg2 >= 1) && (arg2 <= 10))
9409 {
9410 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9411 }
9412 else
9413 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009414 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009415 return 0;
9416 }
9417 }
9418 break;
9419
9420 //Update MCC TX_EARLY_STOP_TIME parameter
9421 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
9422 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
9423 {
9424 if((arg2 >= 1) && (arg2 <= 10))
9425 {
9426 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9427 }
9428 else
9429 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009430 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009431 return 0;
9432 }
9433 }
9434 break;
9435
9436 //Update MCC RX_DRAIN_TIME parameter
9437 case MCC_RX_DRAIN_TIME_CFG_PARAM :
9438 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
9439 {
9440 if((arg2 >= 1) && (arg2 <= 10))
9441 {
9442 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9443 }
9444 else
9445 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009446 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009447 return 0;
9448 }
9449 }
9450 break;
9451
9452 //Update MCC CHANNEL_SWITCH_TIME parameter
9453 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
9454 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
9455 {
9456 if((arg2 >= 1) && (arg2 <= 20))
9457 {
9458 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9459 }
9460 else
9461 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009462 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009463 return 0;
9464 }
9465 }
9466 break;
9467
9468 //Update MCC MIN_CHANNEL_TIME parameter
9469 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
9470 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
9471 {
9472 if((arg2 >= 5) && (arg2 <= 20))
9473 {
9474 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9475 }
9476 else
9477 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009478 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009479 return 0;
9480 }
9481 }
9482 break;
9483
9484 //Update MCC PARK_BEFORE_TBTT parameter
9485 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
9486 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
9487 {
9488 if((arg2 >= 1) && (arg2 <= 5))
9489 {
9490 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9491 }
9492 else
9493 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009494 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009495 return 0;
9496 }
9497 }
9498 break;
9499
9500 //Update MCC MIN_AFTER_DTIM parameter
9501 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
9502 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
9503 {
9504 if((arg2 >= 5) && (arg2 <= 15))
9505 {
9506 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9507 }
9508 else
9509 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009510 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009511 return 0;
9512 }
9513 }
9514 break;
9515
9516 //Update MCC TOO_CLOSE_MARGIN parameter
9517 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
9518 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
9519 {
9520 if((arg2 >= 1) && (arg2 <= 3))
9521 {
9522 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
9523 }
9524 else
9525 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009526 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009527 return 0;
9528 }
9529 }
9530 break;
9531
9532 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08009533 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08009534 __FUNCTION__,arg1);
9535 break;
9536 }
9537 return 0;
9538}
9539
Jeff Johnson295189b2012-06-20 16:38:30 -07009540int hdd_set_wext(hdd_adapter_t *pAdapter)
9541{
9542 hdd_wext_state_t *pwextBuf;
9543 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009544 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009545
9546 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9547
9548 // Now configure the roaming profile links. To SSID and bssid.
9549 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
9550 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
9551
9552 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
9553 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
9554
9555 /*Set the numOfChannels to zero to scan all the channels*/
9556 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
9557 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
9558
9559 /* Default is no encryption */
9560 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
9561 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
9562
9563 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
9564 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
9565
9566 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
9567
9568 /* Default is no authentication */
9569 pwextBuf->roamProfile.AuthType.numEntries = 1;
9570 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
9571
9572 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
9573 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
9574
9575 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07009576 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009577
9578 hdd_clearRoamProfileIe(pAdapter);
9579
9580 return VOS_STATUS_SUCCESS;
9581
9582 }
9583
9584int hdd_register_wext(struct net_device *dev)
9585 {
9586 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9587 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9588 VOS_STATUS status;
9589
9590 ENTER();
9591
9592 // Zero the memory. This zeros the profile structure.
9593 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
9594
9595 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
9596
9597
9598 status = hdd_set_wext(pAdapter);
9599
9600 if(!VOS_IS_STATUS_SUCCESS(status)) {
9601
Arif Hussain6d2a3322013-11-17 19:50:10 -08009602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009603 return eHAL_STATUS_FAILURE;
9604 }
9605
9606 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
9607 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 return eHAL_STATUS_FAILURE;
9610 }
9611
9612 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
9613 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009615 return eHAL_STATUS_FAILURE;
9616 }
9617
9618 // Register as a wireless device
9619 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
9620
9621 EXIT();
9622 return 0;
9623}
9624
9625int hdd_UnregisterWext(struct net_device *dev)
9626{
9627#if 0
9628 hdd_wext_state_t *wextBuf;
9629 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9630
9631 ENTER();
9632 // Set up the pointer to the Wireless Extensions state structure
9633 wextBuf = pAdapter->pWextState;
9634
9635 // De-allocate the Wireless Extensions state structure
9636 kfree(wextBuf);
9637
9638 // Clear out the pointer to the Wireless Extensions state structure
9639 pAdapter->pWextState = NULL;
9640
9641 EXIT();
9642#endif
c_hpothu5f0b6eb2014-09-15 13:36:50 +05309643
9644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s", __func__);
9645 rtnl_lock();
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 dev->wireless_handlers = NULL;
c_hpothu5f0b6eb2014-09-15 13:36:50 +05309647 rtnl_unlock();
9648
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 return 0;
9650}
9651
9652