blob: 4f4ee05e990300c87e41ea5e69a141be54f84ac0 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
c_hpothu002231a2015-02-05 14:58:51 +05302 * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053053#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include <wlan_hdd_includes.h>
55#include <wlan_btc_svc.h>
56#include <wlan_nlink_common.h>
57#ifdef WLAN_BTAMP_FEATURE
58#include <bap_hdd_main.h>
59#endif
60#include <vos_api.h>
61#include <net/arp.h>
62#include "ccmApi.h"
63#include "sirParams.h"
64#include "csrApi.h"
65#include "csrInsideApi.h"
66#if defined WLAN_FEATURE_VOWIFI
67#include "smeRrmInternal.h"
68#endif
69#include <aniGlobal.h>
70#include "dot11f.h"
71#include <wlan_hdd_wowl.h>
72#include <wlan_hdd_cfg.h>
73#include <wlan_hdd_wmm.h>
74#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070075#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053076#ifdef FEATURE_WLAN_TDLS
77#include "wlan_hdd_tdls.h"
78#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070079
80#ifdef CONFIG_HAS_EARLYSUSPEND
81#include <linux/earlysuspend.h>
82#endif
83#include "wlan_hdd_power.h"
84#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070085#include "wlan_hdd_host_offload.h"
86#include "wlan_hdd_keep_alive.h"
87#ifdef WLAN_FEATURE_PACKET_FILTERING
88#include "wlan_hdd_packet_filtering.h"
89#endif
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091#include <linux/wireless.h>
92#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053094#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96#include "wlan_hdd_misc.h"
97#include "bap_hdd_misc.h"
98
99#include "wlan_hdd_dev_pwr.h"
100#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530101#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700102#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530103#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
Mukul Sharma84f27252014-07-14 18:11:42 +0530105#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530106#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#ifdef CONFIG_HAS_EARLYSUSPEND
109extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
110extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
111#endif
112
Jeff Johnsone7245742012-09-05 17:12:55 -0700113#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800114#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700115#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700116
117#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530118#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700119
Jeff Johnson295189b2012-06-20 16:38:30 -0700120
Atul Mittalc0f739f2014-07-31 13:47:47 +0530121// tdlsoffchan
122#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530123static int tdlsOffCh = 1;
124static int tdlsOffChBwOffset = 0;
125#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530126
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700127static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
129
Jeff Johnson295189b2012-06-20 16:38:30 -0700130/* To Validate Channel against the Frequency and Vice-Versa */
131static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
132 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
133 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
134 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
135 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
136 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
137 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
138 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800139 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
140 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700141
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800142#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700143
144/* Private ioctls and their sub-ioctls */
145#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
146#define WE_SET_11D_STATE 1
147#define WE_WOWL 2
148#define WE_SET_POWER 3
149#define WE_SET_MAX_ASSOC 4
150#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
151#define WE_SET_DATA_INACTIVITY_TO 6
152#define WE_SET_MAX_TX_POWER 7
153#define WE_SET_HIGHER_DTIM_TRANSITION 8
154#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530155#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700156#define WE_SET_MAX_TX_POWER_2_4 11
157#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800158/* Private IOCTL for debug connection issues */
159#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530160// tdlsoffchan
161#ifdef FEATURE_WLAN_TDLS
162#define WE_SET_TDLS_OFF_CHAN 14
163#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
164#define WE_SET_TDLS_OFF_CHAN_MODE 16
165#endif
Peng Xu2446a892014-09-05 17:21:18 +0530166#define WE_SET_SCAN_BAND_PREFERENCE 17
Jeff Johnson295189b2012-06-20 16:38:30 -0700167
168/* Private ioctls and their sub-ioctls */
169#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
170#define WE_GET_11D_STATE 1
171#define WE_IBSS_STATUS 2
172#define WE_PMC_STATE 3
173#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700174#define WE_GET_MAX_ASSOC 6
175#define WE_GET_WDI_DBG 7
176#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
177#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530178#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700179/* Private ioctls and their sub-ioctls */
180#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
181
182/* Private ioctls and their sub-ioctls */
183#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
184#define WE_WOWL_ADD_PTRN 1
185#define WE_WOWL_DEL_PTRN 2
186#if defined WLAN_FEATURE_VOWIFI
187#define WE_NEIGHBOR_REPORT_REQUEST 3
188#endif
189#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
190#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530191#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700192
193/* Private ioctls and their sub-ioctls */
194#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
195#define WE_SET_WLAN_DBG 1
196#define WE_SET_WDI_DBG 2
197#define WE_SET_SAP_CHANNELS 3
198
199/* Private ioctls and their sub-ioctls */
200#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
201#define WE_WLAN_VERSION 1
202#define WE_GET_STATS 2
203#define WE_GET_CFG 3
204#define WE_GET_WMM_STATUS 4
205#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700206#ifdef WLAN_FEATURE_11AC
207#define WE_GET_RSSI 6
208#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800209#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800210#ifdef FEATURE_WLAN_TDLS
211#define WE_GET_TDLS_PEERS 8
212#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700213#ifdef WLAN_FEATURE_11W
214#define WE_GET_11W_INFO 9
215#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530216#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530217#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700218
219/* Private ioctls and their sub-ioctls */
220#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
221#define WE_CLEAR_STATS 1
222#define WE_INIT_AP 2
223#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530224#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700225#define WE_ENABLE_AMP 4
226#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530227#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700228#define WE_ENABLE_DXE_STALL_DETECT 6
229#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700230#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530231#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530232#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530233#define WE_DUMP_ROAM_TIMER_LOG 12
234#define WE_RESET_ROAM_TIMER_LOG 13
Mukul Sharma84f27252014-07-14 18:11:42 +0530235
Jeff Johnson295189b2012-06-20 16:38:30 -0700236/* Private ioctls and their sub-ioctls */
237#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
238#define WE_LOG_DUMP_CMD 1
239
Jeff Johnson295189b2012-06-20 16:38:30 -0700240#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800241//IOCTL to configure MCC params
242#define WE_MCC_CONFIG_CREDENTIAL 3
243#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700244
Chilam NG571c65a2013-01-19 12:27:36 +0530245#ifdef FEATURE_WLAN_TDLS
246#define WE_TDLS_CONFIG_PARAMS 5
247#endif
248
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700249#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530250#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700251
Chilam Ng01120412013-02-19 18:32:21 -0800252#ifdef FEATURE_WLAN_TDLS
253#undef MAX_VAR_ARGS
254#define MAX_VAR_ARGS 10
255#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700256#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800257#endif
258
Jeff Johnson295189b2012-06-20 16:38:30 -0700259/* Private ioctls (with no sub-ioctls) */
260/* note that they must be odd so that they have "get" semantics */
261#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
262#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
263#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
264
Girish Gowli464c9c82014-06-09 19:47:53 +0530265/* (SIOCIWFIRSTPRIV + 8) is currently unused */
266/* (SIOCIWFIRSTPRIV + 16) is currently unused */
267/* (SIOCIWFIRSTPRIV + 10) is currently unused */
268/* (SIOCIWFIRSTPRIV + 12) is currently unused */
269/* (SIOCIWFIRSTPRIV + 14) is currently unused */
270/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700271
Jeff Johnsone7245742012-09-05 17:12:55 -0700272#ifdef FEATURE_OEM_DATA_SUPPORT
273/* Private ioctls for setting the measurement configuration */
274#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
275#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
276#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278#ifdef WLAN_FEATURE_VOWIFI_11R
279#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
280#endif
281
282/* Private ioctl for setting the host offload feature */
283#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
284
285/* Private ioctl to get the statistics */
286#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
287
288/* Private ioctl to set the Keep Alive Params */
289#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
290#ifdef WLAN_FEATURE_PACKET_FILTERING
291/* Private ioctl to set the Packet Filtering Params */
292#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
293#endif
294
295#ifdef FEATURE_WLAN_SCAN_PNO
296/* Private ioctl to get the statistics */
297#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
298#endif
299
300#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
301
302#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
303#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700304/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700305
Jeff Johnson295189b2012-06-20 16:38:30 -0700306#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
307#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
308
309#define WLAN_STATS_INVALID 0
310#define WLAN_STATS_RETRY_CNT 1
311#define WLAN_STATS_MUL_RETRY_CNT 2
312#define WLAN_STATS_TX_FRM_CNT 3
313#define WLAN_STATS_RX_FRM_CNT 4
314#define WLAN_STATS_FRM_DUP_CNT 5
315#define WLAN_STATS_FAIL_CNT 6
316#define WLAN_STATS_RTS_FAIL_CNT 7
317#define WLAN_STATS_ACK_FAIL_CNT 8
318#define WLAN_STATS_RTS_SUC_CNT 9
319#define WLAN_STATS_RX_DISCARD_CNT 10
320#define WLAN_STATS_RX_ERROR_CNT 11
321#define WLAN_STATS_TX_BYTE_CNT 12
322
323#define WLAN_STATS_RX_BYTE_CNT 13
324#define WLAN_STATS_RX_RATE 14
325#define WLAN_STATS_TX_RATE 15
326
Jeff Johnsone7245742012-09-05 17:12:55 -0700327#define WLAN_STATS_RX_UC_BYTE_CNT 16
328#define WLAN_STATS_RX_MC_BYTE_CNT 17
329#define WLAN_STATS_RX_BC_BYTE_CNT 18
330#define WLAN_STATS_TX_UC_BYTE_CNT 19
331#define WLAN_STATS_TX_MC_BYTE_CNT 20
332#define WLAN_STATS_TX_BC_BYTE_CNT 21
333
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800334#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
335 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
336 { \
337 *__p++ = __type; \
338 *__p++ = __size; \
339 memcpy(__p, __val, __size); \
340 __p += __size; \
341 __tlen += __size + 2; \
342 } \
343 else \
344 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800345 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800346 } \
347 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700348
349#define VERSION_VALUE_MAX_LEN 32
350
351#define TX_PER_TRACKING_DEFAULT_RATIO 5
352#define TX_PER_TRACKING_MAX_RATIO 10
353#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
354
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530355#define WLAN_ADAPTER 0
356#define P2P_ADAPTER 1
357
c_hpothuda3af912014-11-06 16:52:03 +0530358#define HDD_IOCTL_RATELIMIT_INTERVAL 20*HZ
359#define HDD_IOCTL_RATELIMIT_BURST 1
360
361static DEFINE_RATELIMIT_STATE(hdd_ioctl_timeout_rs, \
362 HDD_IOCTL_RATELIMIT_INTERVAL, \
363 HDD_IOCTL_RATELIMIT_BURST);
364
Abhishek Singh2ec36ab2014-08-07 16:14:25 +0530365/*
366 * When supplicant sends SETBAND ioctl it queries for channels from
367 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
368 * This is not required if the return type from ioctl is
369 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
370 * event as part of regulatory_hint.
371 */
372enum {
373 SEND_CHANNEL_CHANGE_EVENT = 0,
374 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
375};
376
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800377/*MCC Configuration parameters */
378enum {
379 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
380 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
381 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
382 MCC_RX_DRAIN_TIME_CFG_PARAM,
383 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
384 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
385 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
386 MCC_MIN_AFTER_DTIM_CFG_PARAM,
387 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
388};
389
390int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
391 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
392
Jeff Johnson295189b2012-06-20 16:38:30 -0700393#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800394int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700395 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700396#endif
397
Jeff Johnson295189b2012-06-20 16:38:30 -0700398/**---------------------------------------------------------------------------
399
Arif Hussain0273cba2014-01-07 20:58:29 -0800400 \brief mem_alloc_copy_from_user_helper -
401
402 Helper function to allocate buffer and copy user data.
403
404 \param - wrqu - Pointer to IOCTL Data.
405 len - size
406
407 \return - On Success pointer to buffer, On failure NULL
408
409 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530410void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800411{
412 u8 *ptr = NULL;
413
414 /* in order to protect the code, an extra byte is post appended to the buffer
415 * and the null termination is added. However, when allocating (len+1) byte
416 * of memory, we need to make sure that there is no uint overflow when doing
417 * addition. In theory check len < UINT_MAX protects the uint overflow. For
418 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
419 * guess, now, it is assumed that the private command buffer size is no
420 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
421 */
422 if (len > MAX_USER_COMMAND_SIZE)
423 {
424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
425 "Invalid length");
426 return NULL;
427 }
428
429 ptr = kmalloc(len + 1, GFP_KERNEL);
430 if (NULL == ptr)
431 {
432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
433 "unable to allocate memory");
434 return NULL;
435 }
436
437 if (copy_from_user(ptr, wrqu_data, len))
438 {
439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
440 "%s: failed to copy data to user buffer", __func__);
441 kfree(ptr);
442 return NULL;
443 }
444 ptr[len] = '\0';
445 return ptr;
446}
447
Girish Gowli488ef492014-06-12 18:44:33 +0530448// Function to handle and get compatible struct iw_point passed to ioctl.
449int hdd_priv_get_data(struct iw_point *p_priv_data,
450 union iwreq_data *wrqu)
451{
452 if ((NULL == p_priv_data) || (NULL == wrqu))
453 {
454 return -EINVAL;
455 }
456
457#ifdef CONFIG_COMPAT
458 if (is_compat_task())
459 {
460 struct compat_iw_point *p_compat_priv_data;
461
462 // Compat task: typecast to campat structure and copy the members.
463 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
464
465 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
466 p_priv_data->length = p_compat_priv_data->length;
467 p_priv_data->flags = p_compat_priv_data->flags;
468 }//if(is_compat_task())
469 else
470 {
471#endif //#ifdef CONFIG_COMPAT
472
473 // Non compat task: directly copy the structure.
474 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
475
476#ifdef CONFIG_COMPAT
477 }//else of - if(is_compat_task())
478#endif //#ifdef CONFIG_COMPAT
479
480 return 0;
481}
482
Arif Hussain0273cba2014-01-07 20:58:29 -0800483/**---------------------------------------------------------------------------
484
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 \brief hdd_wlan_get_version() -
486
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800487 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700488
489 \param - pAdapter Pointer to the adapter.
490 wrqu - Pointer to IOCTL REQUEST Data.
491 extra - Pointer to char
492
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800493 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700494
495 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800496void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
497 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700498{
499 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800500 tSirVersionString wcnss_SW_version;
501 tSirVersionString wcnss_HW_version;
502 char *pSWversion;
503 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700505
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800506 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
507 sizeof(wcnss_SW_version));
508 if (VOS_IS_STATUS_SUCCESS(status))
509 {
510 pSWversion = wcnss_SW_version;
511 }
512 else
513 {
514 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 }
516
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800517 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
518 sizeof(wcnss_HW_version));
519 if (VOS_IS_STATUS_SUCCESS(status))
520 {
521 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800523 else
524 {
525 pHWversion = "Unknown";
526 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700527
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700528 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800529 "Host SW:%s, FW:%s, HW:%s",
530 QWLAN_VERSIONSTR,
531 pSWversion,
532 pHWversion);
533
534 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700535}
536
Jeff Johnson295189b2012-06-20 16:38:30 -0700537int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
538{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530539 tHalHandle hHal;
540 hdd_context_t *pHddCtx;
541 v_U32_t threshold = 0;
542 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700543
544 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530545 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530546 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
548 "%s: Adapter is NULL",__func__);
549 return -EINVAL;
550 }
551
552 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
553 ret = wlan_hdd_validate_context(pHddCtx);
554 if (0 != ret)
555 {
556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
557 "%s: HDD context is not valid",__func__);
558 return ret;
559 }
560
561 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
562 if (NULL == hHal)
563 {
564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
565 "%s: Hal Context is NULL",__func__);
566 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700567 }
568
569 if ( eHAL_STATUS_SUCCESS !=
570 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
571 {
c_hpothub8245442013-11-20 23:41:09 +0530572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
573 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 return -EIO;
575 }
576 wrqu->rts.value = threshold;
577
578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800579 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700580
581 EXIT();
582
583 return 0;
584}
585
586int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
587{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530588 tHalHandle hHal;
589 hdd_context_t *pHddCtx;
590 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700591
592 ENTER();
593
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530594 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530595 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
597 "%s: Adapter is NULL",__func__);
598 return -EINVAL;
599 }
600
601 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
602 status = wlan_hdd_validate_context(pHddCtx);
603 if (0 != status)
604 {
605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
606 "%s: HDD context is not valid",__func__);
607 return status;
608 }
609
610 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
611 if (NULL == hHal)
612 {
613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
614 "%s: Hal Context is NULL",__func__);
615 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 }
617
618 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
619 != eHAL_STATUS_SUCCESS )
620 {
c_hpothub8245442013-11-20 23:41:09 +0530621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
622 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700623 return -EIO;
624 }
625 wrqu->frag.value = threshold;
626
627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800628 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700629
630 EXIT();
631
632 return 0;
633}
634
635int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
636{
Jeff Johnsone7245742012-09-05 17:12:55 -0700637 int i;
638 if (channel > 0)
639 {
640 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
641 {
642 if (channel == freq_chan_map[i].chan)
643 {
644 *pfreq = freq_chan_map[i].freq;
645 return 1;
646 }
647 }
648 }
649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800650 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700651 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700652}
653
654static v_BOOL_t
655hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
656{
657 v_BOOL_t rsnType = VOS_FALSE;
658 // is the authType supported?
659 switch (authType)
660 {
661 case eCSR_AUTH_TYPE_NONE: //never used
662 rsnType = eANI_BOOLEAN_FALSE;
663 break;
664 // MAC layer authentication types
665 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
666 rsnType = eANI_BOOLEAN_FALSE;
667 break;
668 case eCSR_AUTH_TYPE_SHARED_KEY:
669 rsnType = eANI_BOOLEAN_FALSE;
670 break;
671 case eCSR_AUTH_TYPE_AUTOSWITCH:
672 rsnType = eANI_BOOLEAN_FALSE;
673 break;
674
675 // Upper layer authentication types
676 case eCSR_AUTH_TYPE_WPA:
677 rsnType = eANI_BOOLEAN_TRUE;
678 break;
679 case eCSR_AUTH_TYPE_WPA_PSK:
680 rsnType = eANI_BOOLEAN_TRUE;
681 break;
682 case eCSR_AUTH_TYPE_WPA_NONE:
683 rsnType = eANI_BOOLEAN_TRUE;
684 break;
685#ifdef WLAN_FEATURE_VOWIFI_11R
686 case eCSR_AUTH_TYPE_FT_RSN:
687#endif
688 case eCSR_AUTH_TYPE_RSN:
689 rsnType = eANI_BOOLEAN_TRUE;
690 break;
691#ifdef WLAN_FEATURE_VOWIFI_11R
692 case eCSR_AUTH_TYPE_FT_RSN_PSK:
693#endif
694 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700695#ifdef WLAN_FEATURE_11W
696 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530697 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700698#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 rsnType = eANI_BOOLEAN_TRUE;
700 break;
701 //case eCSR_AUTH_TYPE_FAILED:
702 case eCSR_AUTH_TYPE_UNKNOWN:
703 rsnType = eANI_BOOLEAN_FALSE;
704 break;
705 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800706 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
707 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 rsnType = eANI_BOOLEAN_FALSE;
709 break;
710 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800711 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700712 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 return rsnType;
714}
715
716static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
717{
718 struct statsContext *pStatsContext;
719 hdd_adapter_t *pAdapter;
720
721 if (ioctl_debug)
722 {
723 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700724 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 }
726
727 if (NULL == pContext)
728 {
729 hddLog(VOS_TRACE_LEVEL_ERROR,
730 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700731 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 return;
733 }
734
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 pStatsContext = pContext;
736 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800737
738 /* there is a race condition that exists between this callback
739 function and the caller since the caller could time out either
740 before or while this code is executing. we use a spinlock to
741 serialize these actions */
742 spin_lock(&hdd_context_lock);
743
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
745 {
746 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800747 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 hddLog(VOS_TRACE_LEVEL_WARN,
749 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700750 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 if (ioctl_debug)
752 {
753 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700754 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 }
756 return;
757 }
758
Jeff Johnson72a40512013-12-19 10:14:15 -0800759 /* context is valid so caller is still waiting */
760
761 /* paranoia: invalidate the magic */
762 pStatsContext->magic = 0;
763
764 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 pAdapter->rssi = rssi;
766
Jeff Johnson72a40512013-12-19 10:14:15 -0800767 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800769
770 /* serialization is complete */
771 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700772}
773
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530774static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
775{
776 struct statsContext *pStatsContext;
777 hdd_adapter_t *pAdapter;
778
779 if (ioctl_debug)
780 {
781 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
782 __func__, (int)snr, (int)staId, pContext);
783 }
784
785 if (NULL == pContext)
786 {
787 hddLog(VOS_TRACE_LEVEL_ERROR,
788 "%s: Bad param, pContext [%p]",
789 __func__, pContext);
790 return;
791 }
792
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530793 pStatsContext = pContext;
794 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800795
796 /* there is a race condition that exists between this callback
797 function and the caller since the caller could time out either
798 before or while this code is executing. we use a spinlock to
799 serialize these actions */
800 spin_lock(&hdd_context_lock);
801
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530802 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
803 {
804 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800805 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530806 hddLog(VOS_TRACE_LEVEL_WARN,
807 "%s: Invalid context, pAdapter [%p] magic [%08x]",
808 __func__, pAdapter, pStatsContext->magic);
809 if (ioctl_debug)
810 {
811 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
812 __func__, pAdapter, pStatsContext->magic);
813 }
814 return;
815 }
816
Jeff Johnson72a40512013-12-19 10:14:15 -0800817 /* context is valid so caller is still waiting */
818
819 /* paranoia: invalidate the magic */
820 pStatsContext->magic = 0;
821
822 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530823 pAdapter->snr = snr;
824
Jeff Johnson72a40512013-12-19 10:14:15 -0800825 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530826 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800827
828 /* serialization is complete */
829 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530830}
831
Jeff Johnson295189b2012-06-20 16:38:30 -0700832VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
833{
834 struct statsContext context;
835 hdd_context_t *pHddCtx;
836 hdd_station_ctx_t *pHddStaCtx;
837 eHalStatus hstatus;
838 long lrc;
839
840 if (NULL == pAdapter)
841 {
842 hddLog(VOS_TRACE_LEVEL_WARN,
843 "%s: Invalid context, pAdapter", __func__);
844 return VOS_STATUS_E_FAULT;
845 }
846 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
847 {
848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
849 /* return a cached value */
850 *rssi_value = pAdapter->rssi;
851 return VOS_STATUS_SUCCESS;
852 }
853
854 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
855 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
856
857 init_completion(&context.completion);
858 context.pAdapter = pAdapter;
859 context.magic = RSSI_CONTEXT_MAGIC;
860
861 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
862 pHddStaCtx->conn_info.staId[ 0 ],
863 pHddStaCtx->conn_info.bssId,
864 &context, pHddCtx->pvosContext);
865 if (eHAL_STATUS_SUCCESS != hstatus)
866 {
867 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700868 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 /* we'll returned a cached value below */
870 }
871 else
872 {
873 /* request was sent -- wait for the response */
874 lrc = wait_for_completion_interruptible_timeout(&context.completion,
875 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 if (lrc <= 0)
877 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800878 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700879 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 /* we'll now returned a cached value below */
881 }
882 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800883
884 /* either we never sent a request, we sent a request and received a
885 response or we sent a request and timed out. if we never sent a
886 request or if we sent a request and got a response, we want to
887 clear the magic out of paranoia. if we timed out there is a
888 race condition such that the callback function could be
889 executing at the same time we are. of primary concern is if the
890 callback function had already verified the "magic" but had not
891 yet set the completion variable when a timeout occurred. we
892 serialize these activities by invalidating the magic while
893 holding a shared spinlock which will cause us to block if the
894 callback is currently executing */
895 spin_lock(&hdd_context_lock);
896 context.magic = 0;
897 spin_unlock(&hdd_context_lock);
898
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 *rssi_value = pAdapter->rssi;
900
901 return VOS_STATUS_SUCCESS;
902}
903
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530904VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
905{
906 struct statsContext context;
907 hdd_context_t *pHddCtx;
908 hdd_station_ctx_t *pHddStaCtx;
909 eHalStatus hstatus;
910 long lrc;
911 int valid;
912
913 if (NULL == pAdapter)
914 {
915 hddLog(VOS_TRACE_LEVEL_ERROR,
916 "%s: Invalid context, pAdapter", __func__);
917 return VOS_STATUS_E_FAULT;
918 }
919
920 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
921
922 valid = wlan_hdd_validate_context(pHddCtx);
923 if (0 != valid)
924 {
925 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
926 return VOS_STATUS_E_FAULT;
927 }
928
929 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
930 if (NULL == pHddStaCtx)
931 {
932 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
933 return VOS_STATUS_E_FAULT;
934 }
935
936 init_completion(&context.completion);
937 context.pAdapter = pAdapter;
938 context.magic = SNR_CONTEXT_MAGIC;
939
940 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
941 pHddStaCtx->conn_info.staId[ 0 ],
942 pHddStaCtx->conn_info.bssId,
943 &context);
944 if (eHAL_STATUS_SUCCESS != hstatus)
945 {
946 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
947 __func__);
948 /* we'll returned a cached value below */
949 }
950 else
951 {
952 /* request was sent -- wait for the response */
953 lrc = wait_for_completion_interruptible_timeout(&context.completion,
954 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530955 if (lrc <= 0)
956 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800957 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530958 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530959 /* we'll now returned a cached value below */
960 }
961 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800962
963 /* either we never sent a request, we sent a request and received a
964 response or we sent a request and timed out. if we never sent a
965 request or if we sent a request and got a response, we want to
966 clear the magic out of paranoia. if we timed out there is a
967 race condition such that the callback function could be
968 executing at the same time we are. of primary concern is if the
969 callback function had already verified the "magic" but had not
970 yet set the completion variable when a timeout occurred. we
971 serialize these activities by invalidating the magic while
972 holding a shared spinlock which will cause us to block if the
973 callback is currently executing */
974 spin_lock(&hdd_context_lock);
975 context.magic = 0;
976 spin_unlock(&hdd_context_lock);
977
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530978 *snr = pAdapter->snr;
979
980 return VOS_STATUS_SUCCESS;
981}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800982#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800983
984static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
985{
986 struct statsContext *pStatsContext;
987 hdd_adapter_t *pAdapter;
988 if (ioctl_debug)
989 {
990 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
991 __func__, (int)rssi, (int)staId, pContext);
992 }
993
994 if (NULL == pContext)
995 {
996 hddLog(VOS_TRACE_LEVEL_ERROR,
997 "%s: Bad param, pContext [%p]",
998 __func__, pContext);
999 return;
1000 }
1001
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001002 pStatsContext = pContext;
1003 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001004
1005 /* there is a race condition that exists between this callback
1006 function and the caller since the caller could time out either
1007 before or while this code is executing. we use a spinlock to
1008 serialize these actions */
1009 spin_lock(&hdd_context_lock);
1010
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001011 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1012 {
1013 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001014 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001015 hddLog(VOS_TRACE_LEVEL_WARN,
1016 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1017 __func__, pAdapter, pStatsContext->magic);
1018 if (ioctl_debug)
1019 {
1020 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1021 __func__, pAdapter, pStatsContext->magic);
1022 }
1023 return;
1024 }
1025
Jeff Johnson72a40512013-12-19 10:14:15 -08001026 /* context is valid so caller is still waiting */
1027
1028 /* paranoia: invalidate the magic */
1029 pStatsContext->magic = 0;
1030
1031 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001032 pAdapter->rssi = rssi;
1033
Jeff Johnson72a40512013-12-19 10:14:15 -08001034 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001035 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001036
1037 /* serialization is complete */
1038 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001039}
1040
1041
1042
1043VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1044{
1045 struct statsContext context;
1046 hdd_context_t *pHddCtx = NULL;
1047 hdd_station_ctx_t *pHddStaCtx = NULL;
1048 eHalStatus hstatus;
1049 long lrc;
1050
1051 if (NULL == pAdapter)
1052 {
1053 hddLog(VOS_TRACE_LEVEL_WARN,
1054 "%s: Invalid context, pAdapter", __func__);
1055 return VOS_STATUS_E_FAULT;
1056 }
1057 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1058 {
1059 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1060 /* return a cached value */
1061 *rssi_value = pAdapter->rssi;
1062 return VOS_STATUS_SUCCESS;
1063 }
1064
1065 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1066 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1067
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301068 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001069 {
1070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1071 /* return a cached value */
1072 *rssi_value = 0;
1073 return VOS_STATUS_SUCCESS;
1074 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301075
1076 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1077 {
1078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1079 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1080 *rssi_value = pAdapter->rssi;
1081 return VOS_STATUS_SUCCESS;
1082 }
1083
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001084 init_completion(&context.completion);
1085 context.pAdapter = pAdapter;
1086 context.magic = RSSI_CONTEXT_MAGIC;
1087
1088 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1089 pHddStaCtx->conn_info.staId[ 0 ],
1090 pHddStaCtx->conn_info.bssId,
1091 &context, pHddCtx->pvosContext);
1092 if (eHAL_STATUS_SUCCESS != hstatus)
1093 {
1094 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1095 __func__);
1096 /* we'll returned a cached value below */
1097 }
1098 else
1099 {
1100 /* request was sent -- wait for the response */
1101 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1102 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001103 if (lrc <= 0)
1104 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001105 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001106 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001107 /* we'll now returned a cached value below */
1108 }
1109 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001110
1111 /* either we never sent a request, we sent a request and received a
1112 response or we sent a request and timed out. if we never sent a
1113 request or if we sent a request and got a response, we want to
1114 clear the magic out of paranoia. if we timed out there is a
1115 race condition such that the callback function could be
1116 executing at the same time we are. of primary concern is if the
1117 callback function had already verified the "magic" but had not
1118 yet set the completion variable when a timeout occurred. we
1119 serialize these activities by invalidating the magic while
1120 holding a shared spinlock which will cause us to block if the
1121 callback is currently executing */
1122 spin_lock(&hdd_context_lock);
1123 context.magic = 0;
1124 spin_unlock(&hdd_context_lock);
1125
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001126 *rssi_value = pAdapter->rssi;
1127
1128 return VOS_STATUS_SUCCESS;
1129}
1130#endif
1131
1132
Jeff Johnson295189b2012-06-20 16:38:30 -07001133void hdd_StatisticsCB( void *pStats, void *pContext )
1134{
1135 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1136 hdd_stats_t *pStatsCache = NULL;
1137 hdd_wext_state_t *pWextState;
1138 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1139
1140 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1141 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1142 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1143 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1144 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1145 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1146
1147 if (pAdapter!= NULL)
1148 pStatsCache = &pAdapter->hdd_stats;
1149
1150
1151 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1152 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1153 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1154 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1155 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1156 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1157
1158 if (pStatsCache!=NULL)
1159 {
1160 // and copy the stats into the cache we keep in the adapter instance structure
1161 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1162 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1163 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1164 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1165 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1166 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1167 }
1168
1169 if(pAdapter)
1170 {
1171 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1172 if(pWextState)
1173 {
1174 vos_status = vos_event_set(&pWextState->vosevent);
1175 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1176 {
1177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001178 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 return;
1180 }
1181 }
1182 }
1183}
1184
1185void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1186{
1187 v_CONTEXT_t pVosContext;
1188 hdd_context_t *pHddCtx;
1189 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1190#if 0
1191 hdd_wext_state_t *pWextState;
1192 v_U32_t roamId;
1193#endif
1194
1195 ENTER();
1196
1197 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1198
1199 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1200 if (NULL == pHddCtx)
1201 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001202 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 return;
1204 }
1205#if 0
1206 pWextState = pAdapter->pWextState;
1207#endif
1208
1209 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1210 {
1211 //TODO Verify is this is really used. If yes need to fix it.
1212 hdd_reconnect_all_adapters( pHddCtx );
1213#if 0
1214 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1215 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1216 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1217
1218 if(VOS_STATUS_SUCCESS == vosStatus)
1219 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1220 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1221
1222 sme_RoamConnect(halHandle,
1223 pAdapter->sessionId, &(pWextState->roamProfile),
1224 &roamId);
1225#endif
1226 }
1227
1228 EXIT();
1229
1230}
1231
1232void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1233{
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1235
1236 /* clear WPA/RSN/WSC IE information in the profile */
1237 pWextState->roamProfile.nWPAReqIELength = 0;
1238 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1239 pWextState->roamProfile.nRSNReqIELength = 0;
1240 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1241
Chet Lanctot186b5732013-03-18 10:26:30 -07001242#ifdef FEATURE_WLAN_WAPI
1243 pWextState->roamProfile.nWAPIReqIELength = 0;
1244 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1245#endif
1246
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001248 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301250 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001251 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1252 pWextState->roamProfile.nAddIEAssocLength = 0;
1253
1254 pWextState->roamProfile.EncryptionType.numEntries = 1;
1255 pWextState->roamProfile.EncryptionType.encryptionType[0]
1256 = eCSR_ENCRYPT_TYPE_NONE;
1257
1258 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1259 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1260 = eCSR_ENCRYPT_TYPE_NONE;
1261
1262 pWextState->roamProfile.AuthType.numEntries = 1;
1263 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1264
Chet Lanctot186b5732013-03-18 10:26:30 -07001265#ifdef WLAN_FEATURE_11W
1266 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1267 pWextState->roamProfile.MFPRequired = 0;
1268 pWextState->roamProfile.MFPCapable = 0;
1269#endif
1270
Jeff Johnson295189b2012-06-20 16:38:30 -07001271 pWextState->authKeyMgmt = 0;
1272
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301273 vos_mem_zero(&pWextState->roamProfile.Keys,
1274 sizeof(pWextState->roamProfile.Keys));
1275
Jeff Johnson295189b2012-06-20 16:38:30 -07001276#ifdef FEATURE_WLAN_WAPI
1277 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1278 pAdapter->wapi_info.nWapiMode = 0;
1279#endif
1280
1281 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1282
1283}
1284
1285void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1286{
1287 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001288
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001289 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1290 {
1291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1292 "%s: Invalid pAdapter magic", __func__);
1293 }
1294 else
1295 {
1296 complete(&pAdapter->ula_complete);
1297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001298}
1299
1300VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1301{
1302 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001304 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001305
1306 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1307 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001308 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001309
1310 /*To avoid race condition between the set key and the last EAPOL
1311 packet, notify TL to finish upper layer authentication incase if the
1312 last EAPOL packet pending in the TL queue.*/
Nirav Shah4f765af2015-01-21 19:51:30 +05301313 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter,
1314 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1315 pHddStaCtx->conn_info.staId[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001316
Nirav Shah4f765af2015-01-21 19:51:30 +05301317 if ( vos_status == VOS_STATUS_E_ALREADY )
1318 {
1319 return VOS_STATUS_SUCCESS;
1320 }
1321 else if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 {
1323 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1324 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1325 __LINE__, vos_status );
1326 return vos_status;
1327
1328 }
1329
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001330 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301332 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001333 {
1334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301335 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001336 /* we'll still fall through and return success since the
1337 * connection may still get established but is just taking
1338 * too long for us to wait */
1339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 }
1341 return VOS_STATUS_SUCCESS;
1342}
1343
1344v_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)
1345{
1346
1347 int left = ie_len;
1348 v_U8_t *ptr = ie;
1349 v_U8_t elem_id,elem_len;
1350 v_U8_t eid = 0xDD;
1351
1352 if ( NULL == ie || 0 == ie_len )
1353 return NULL;
1354
1355 while(left >= 2)
1356 {
1357 elem_id = ptr[0];
1358 elem_len = ptr[1];
1359 left -= 2;
1360 if(elem_len > left)
1361 {
1362 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001363 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 eid,elem_len,left);
1365 return NULL;
1366 }
1367 if (elem_id == eid)
1368 {
1369 if(memcmp( &ptr[2], oui, oui_size)==0)
1370 return ptr;
1371 }
1372
1373 left -= elem_len;
1374 ptr += (elem_len + 2);
1375 }
1376 return NULL;
1377}
1378
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301379static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 union iwreq_data *wrqu, char *extra)
1381{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301382 hdd_adapter_t *pAdapter;
1383 hdd_context_t *pHddCtx;
1384 int ret = 0;
1385 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1386 if (NULL == pAdapter)
1387 {
1388 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1389 "%s: pAdapter is NULL\n", __func__);
1390 return -EINVAL;
1391 }
1392 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1393 ret = wlan_hdd_validate_context(pHddCtx);
1394 if (0 != ret)
1395 {
1396 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1397 "%s: HDD context is Null", __func__);
1398 return ret;
1399 }
Arif Hussain6d2a3322013-11-17 19:50:10 -08001400 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 /* Do nothing for now */
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301402 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001403}
1404
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301405static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1406 union iwreq_data *wrqu, char *extra)
1407{
1408 int ret;
1409
1410 vos_ssr_protect(__func__);
1411 ret = __iw_set_commit(dev, info, wrqu, extra);
1412 vos_ssr_unprotect(__func__);
1413
1414 return ret;
1415}
1416
1417static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 struct iw_request_info *info,
1419 char *wrqu, char *extra)
1420{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301421 hdd_adapter_t *pAdapter;
1422 hdd_context_t *pHddCtx;
1423 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301425 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1426 if (NULL == pAdapter)
1427 {
1428 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1429 "%s: pAdapter is NULL\n", __func__);
1430 return -EINVAL;
1431 }
1432 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1433 ret = wlan_hdd_validate_context(pHddCtx);
1434 if (0 != ret)
1435 {
1436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1437 "%s: HDD context is Null", __func__);
1438 return ret;
1439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1441 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301442 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001443}
1444
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301445static int iw_get_name(struct net_device *dev,
1446 struct iw_request_info *info,
1447 char *wrqu, char *extra)
1448{
1449 int ret;
1450
1451 vos_ssr_protect(__func__);
1452 ret = __iw_get_name(dev, info, wrqu, extra);
1453 vos_ssr_unprotect(__func__);
1454
1455 return ret;
1456}
1457
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301458static int __iw_set_mode(struct net_device *dev,
1459 struct iw_request_info *info,
1460 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001461{
1462 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301463 hdd_adapter_t *pAdapter;
1464 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 tCsrRoamProfile *pRoamProfile;
1466 eCsrRoamBssType LastBSSType;
1467 eMib_dot11DesiredBssType connectedBssType;
1468 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301470 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001471
1472 ENTER();
1473
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301474 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 if (NULL == pAdapter)
1476 {
1477 hddLog(VOS_TRACE_LEVEL_WARN,
1478 "%s: Invalid context, pAdapter", __func__);
1479 return 0;
1480 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301481 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1482 status = wlan_hdd_validate_context(pHddCtx);
1483 if (0 != status)
1484 {
1485 hddLog(VOS_TRACE_LEVEL_WARN,
1486 "%s: HddCtx is Invalid", __func__);
1487 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 }
1489
1490 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1491 if (pWextState == NULL)
1492 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301493 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 return -EINVAL;
1495 }
1496
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 pRoamProfile = &pWextState->roamProfile;
1499 LastBSSType = pRoamProfile->BSSType;
1500
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301501 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001502
1503 switch (wrqu->mode)
1504 {
1505 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301506 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1508 // Set the phymode correctly for IBSS.
1509 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1510 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001511 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 break;
1514 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301515 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 break;
1519 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301520 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001521 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1522 break;
1523 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301524 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001525 return -EOPNOTSUPP;
1526 }
1527
1528 if ( LastBSSType != pRoamProfile->BSSType )
1529 {
1530 //the BSS mode changed
1531 // We need to issue disconnect if connected or in IBSS disconnect state
1532 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1533 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1534 {
1535 VOS_STATUS vosStatus;
1536 // need to issue a disconnect to CSR.
1537 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1538 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1539 pAdapter->sessionId,
1540 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1541 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301542 {
1543 long ret;
1544 ret = wait_for_completion_interruptible_timeout(
1545 &pAdapter->disconnect_comp_var,
1546 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1547 if (ret <= 0)
1548 hddLog(VOS_TRACE_LEVEL_ERROR,
1549 FL("failed wait on disconnect_comp_var %ld"), ret);
1550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001551 }
1552 }
1553
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 EXIT();
1555 return 0;
1556}
1557
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301558static int iw_set_mode(struct net_device *dev,
1559 struct iw_request_info *info,
1560 union iwreq_data *wrqu, char *extra)
1561{
1562 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001563
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301564 vos_ssr_protect(__func__);
1565 ret = __iw_set_mode(dev, info, wrqu, extra);
1566 vos_ssr_unprotect(__func__);
1567
1568 return ret;
1569}
1570
1571static int __iw_get_mode(struct net_device *dev,
1572 struct iw_request_info *info,
1573 union iwreq_data *wrqu,
1574 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001575{
1576
1577 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301578 hdd_adapter_t *pAdapter;
1579 hdd_context_t *pHddCtx;
1580 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001581
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301582 hddLog(LOG1, "In %s", __func__);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301583 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 if (NULL == pAdapter)
1585 {
1586 hddLog(VOS_TRACE_LEVEL_WARN,
1587 "%s: Invalid context, pAdapter", __func__);
1588 return 0;
1589 }
1590
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301591 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1592 ret = wlan_hdd_validate_context(pHddCtx);
1593 if (0 != ret)
1594 {
1595 hddLog(VOS_TRACE_LEVEL_ERROR,
1596 "%s: HDD context is not valid",__func__);
1597 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1600 if (pWextState == NULL)
1601 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301602 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 return -EINVAL;
1604 }
1605
1606 switch (pWextState->roamProfile.BSSType)
1607 {
1608 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001609 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301610 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 break;
1612 case eCSR_BSS_TYPE_IBSS:
1613 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001614 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301615 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 break;
1617 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001618 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301619 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 break;
1621 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001622 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 break;
1624 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301625
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 return 0;
1627}
1628
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301629static int iw_get_mode(struct net_device *dev,
1630 struct iw_request_info *info,
1631 union iwreq_data *wrqu,
1632 char *extra)
1633{
1634 int ret;
1635
1636 vos_ssr_protect(__func__);
1637 ret = __iw_get_mode(dev, info, wrqu, extra);
1638 vos_ssr_unprotect(__func__);
1639
1640 return ret;
1641}
1642
1643static int __iw_set_freq(struct net_device *dev,
1644 struct iw_request_info *info,
1645 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001646{
1647 v_U32_t numChans = 0;
1648 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1649 v_U32_t indx = 0;
1650 v_U32_t status = 0;
1651
1652 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301653 hdd_adapter_t *pAdapter;
1654 hdd_context_t *pHddCtx;
1655 tHalHandle hHal;
1656 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 tCsrRoamProfile * pRoamProfile;
1658 ENTER();
1659
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301660 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1661 if (NULL == pAdapter)
1662 {
1663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1664 "%s:Invalid Adapter",__func__);
1665 return -EINVAL;
1666 }
1667
1668 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1669 status = wlan_hdd_validate_context(pHddCtx);
1670 if (0 != status)
1671 {
1672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1673 "%s:HDD context is NULL",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 return status;
1675 }
1676
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301677 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1678 if (NULL == hHal)
1679 {
1680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1681 "%s: Hal Context is NULL",__func__);
1682 return -EINVAL;
1683 }
1684
1685 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1686 if (NULL == pHddStaCtx)
1687 {
1688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1689 "%s:STA context is NULL",__func__);
1690 return -EINVAL;
1691 }
1692
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301694 if (NULL == pWextState)
1695 {
1696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1697 "%s: pWextState is NULL",__func__);
1698 return -EINVAL;
1699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001700
1701 pRoamProfile = &pWextState->roamProfile;
1702
Arif Hussain6d2a3322013-11-17 19:50:10 -08001703 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001704
1705 /* Link is up then return cant set channel*/
1706 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1707 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1708 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001709 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 return -EOPNOTSUPP;
1711 }
1712
1713 /* Settings by Frequency as input */
1714 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1715 (wrqu->freq.m <= (tANI_U32)5.825e8))
1716 {
1717 tANI_U32 freq = wrqu->freq.m / 100000;
1718
1719 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1720 indx++;
1721 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1722 {
1723 return -EINVAL;
1724 }
1725 wrqu->freq.e = 0;
1726 wrqu->freq.m = freq_chan_map[indx].chan;
1727
1728 }
1729
1730 if (wrqu->freq.e == 0)
1731 {
1732 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1733 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1734 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001735 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001736 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1738 return -EINVAL;
1739 }
1740
1741 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1742
1743 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1744 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1746 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 return -EIO;
1748 }
1749
1750 for (indx = 0; indx < numChans; indx++) {
1751 if (wrqu->freq.m == validChan[indx]){
1752 break;
1753 }
1754 }
1755 }
1756 else{
1757
1758 return -EINVAL;
1759 }
1760
1761 if(indx >= numChans)
1762 {
1763 return -EINVAL;
1764 }
1765
1766 /* Set the Operational Channel */
1767 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1768 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1769 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1770
Arif Hussain6d2a3322013-11-17 19:50:10 -08001771 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001772
1773 EXIT();
1774
1775 return status;
1776}
1777
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301778static int iw_set_freq(struct net_device *dev,
1779 struct iw_request_info *info,
1780 union iwreq_data *wrqu, char *extra)
1781{
1782 int ret;
1783
1784 vos_ssr_protect(__func__);
1785 ret = __iw_set_freq(dev, info, wrqu, extra);
1786 vos_ssr_unprotect(__func__);
1787
1788 return ret;
1789}
1790
1791static int __iw_get_freq(struct net_device *dev,
1792 struct iw_request_info *info,
1793 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001794{
Jeff Johnsone7245742012-09-05 17:12:55 -07001795 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301796 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 tHalHandle hHal;
1798 hdd_wext_state_t *pWextState;
1799 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301800 hdd_station_ctx_t *pHddStaCtx;
1801 hdd_context_t *pHddCtx;
1802 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001803
1804 ENTER();
1805
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301806 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1807 if (NULL == pAdapter)
1808 {
1809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1810 "%s: Adapter is NULL", __func__);
1811 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301813 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1814 ret = wlan_hdd_validate_context(pHddCtx);
1815 if (0 != ret)
1816 {
1817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1818 "%s: HddCtx is NULL", __func__);
1819 return ret;
1820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301822 if (NULL == hHal)
1823 {
1824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1825 "%s: Hal Context is NULL",__func__);
1826 return -EINVAL;
1827 }
1828 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1829 if (NULL == pHddStaCtx)
1830 {
1831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1832 "%s: HddStaCtx is NULL", __func__);
1833 return -EINVAL;
1834 }
1835 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1836 if (NULL == pWextState)
1837 {
1838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1839 "%s: pWextState is NULL",__func__);
1840 return -EINVAL;
1841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 pRoamProfile = &pWextState->roamProfile;
1843
1844 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1845 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001846 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 {
c_hpothub8245442013-11-20 23:41:09 +05301848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1849 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 return -EIO;
1851 }
1852 else
1853 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001854 status = hdd_wlan_get_freq(channel, &freq);
1855 if( TRUE == status )
1856 {
1857 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1858 * iwlist & iwconfig command shows frequency into proper
1859 * format (2.412 GHz instead of 246.2 MHz)*/
1860 fwrq->m = freq;
1861 fwrq->e = MHZ;
1862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 }
1864 }
1865 else
1866 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001867 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1868 * iwlist & iwconfig command shows frequency into proper
1869 * format (2.412 GHz instead of 246.2 MHz)*/
1870 fwrq->m = 0;
1871 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001872 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301873 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001874}
1875
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301876static int iw_get_freq(struct net_device *dev,
1877 struct iw_request_info *info,
1878 struct iw_freq *fwrq, char *extra)
1879{
1880 int ret;
1881
1882 vos_ssr_protect(__func__);
1883 ret = __iw_get_freq(dev, info, fwrq, extra);
1884 vos_ssr_unprotect(__func__);
1885
1886 return ret;
1887}
1888
1889static int __iw_get_tx_power(struct net_device *dev,
1890 struct iw_request_info *info,
1891 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001892{
1893
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301894 hdd_adapter_t *pAdapter;
1895 hdd_context_t *pHddCtx;
1896 hdd_station_ctx_t *pHddStaCtx;
1897 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001898
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301899 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1900 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1903 "%s: Adapter is NULL",__func__);
1904 return -EINVAL;
1905 }
1906 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1907 ret = wlan_hdd_validate_context(pHddCtx);
1908 if (0 != ret)
1909 {
1910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1911 "%s: HDD context is not valid",__func__);
1912 return ret;
1913 }
1914
1915 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1916 if (NULL == pHddStaCtx)
1917 {
1918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1919 "%s: STA Context is NULL",__func__);
1920 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 }
1922
1923 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1924 {
1925 wrqu->txpower.value = 0;
1926 return 0;
1927 }
1928 wlan_hdd_get_classAstats(pAdapter);
1929 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1930
1931 return 0;
1932}
1933
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301934static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 struct iw_request_info *info,
1936 union iwreq_data *wrqu, char *extra)
1937{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301938 int ret;
1939
1940 vos_ssr_protect(__func__);
1941 ret = __iw_get_tx_power(dev, info, wrqu, extra);
1942 vos_ssr_unprotect(__func__);
1943
1944 return ret;
1945}
1946
1947static int __iw_set_tx_power(struct net_device *dev,
1948 struct iw_request_info *info,
1949 union iwreq_data *wrqu, char *extra)
1950{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301951 hdd_adapter_t *pAdapter;
1952 tHalHandle hHal;
1953 hdd_context_t *pHddCtx;
1954 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001955
1956 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301957 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1958 if (NULL == pAdapter)
1959 {
1960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1961 "%s: Adapter is NULL",__func__);
1962 return -EINVAL;
1963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001964
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301965 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1966 ret = wlan_hdd_validate_context(pHddCtx);
1967 if (0 != ret)
1968 {
1969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1970 "%s: HDD context is not valid",__func__);
1971 return ret;
1972 }
1973
1974 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1975 if (NULL == hHal)
1976 {
1977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1978 "%s: Hal Context is NULL",__func__);
1979 return -EINVAL;
1980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1982 {
c_hpothub8245442013-11-20 23:41:09 +05301983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1984 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 return -EIO;
1986 }
1987
1988 EXIT();
1989
1990 return 0;
1991}
1992
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301993static int iw_set_tx_power(struct net_device *dev,
1994 struct iw_request_info *info,
1995 union iwreq_data *wrqu, char *extra)
1996{
1997 int ret;
1998
1999 vos_ssr_protect(__func__);
2000 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2001 vos_ssr_unprotect(__func__);
2002
2003 return ret;
2004}
2005
2006static int __iw_get_bitrate(struct net_device *dev,
2007 struct iw_request_info *info,
2008 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002009{
2010 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2011 eHalStatus status = eHAL_STATUS_SUCCESS;
2012 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302013 hdd_adapter_t *pAdapter;
2014 hdd_context_t *pHddCtx;
2015 hdd_station_ctx_t *pHddStaCtx;
2016 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002017
2018 ENTER();
2019
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302020 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2021 if (NULL == pAdapter)
2022 {
2023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2024 "%s: Adapter is NULL",__func__);
2025 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 }
2027
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302028 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2029 ret = wlan_hdd_validate_context(pHddCtx);
2030 if (0 != ret)
2031 {
2032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2033 "%s: HDD context is not valid",__func__);
2034 return ret;
2035 }
2036
2037 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2038 if (NULL == pHddStaCtx)
2039 {
2040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2041 "%s: STA Context is NULL",__func__);
2042 return -EINVAL;
2043 }
2044
2045 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 wrqu->bitrate.value = 0;
2047 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302048 else
2049 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2051 SME_SUMMARY_STATS |
2052 SME_GLOBAL_CLASSA_STATS |
2053 SME_GLOBAL_CLASSB_STATS |
2054 SME_GLOBAL_CLASSC_STATS |
2055 SME_GLOBAL_CLASSD_STATS |
2056 SME_PER_STA_STATS,
2057 hdd_StatisticsCB, 0, FALSE,
2058 pHddStaCtx->conn_info.staId[0], pAdapter );
2059
2060 if(eHAL_STATUS_SUCCESS != status)
2061 {
2062 hddLog(VOS_TRACE_LEVEL_ERROR,
2063 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002064 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 return status;
2066 }
2067
2068 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302069 if (NULL == pWextState)
2070 {
2071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2072 "%s: pWextState is NULL",__func__);
2073 return -EINVAL;
2074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002075
2076 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2077
2078 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2079 {
2080 hddLog(VOS_TRACE_LEVEL_ERROR,
2081 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002082 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 return VOS_STATUS_E_FAILURE;
2084 }
2085
2086 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2087 }
2088
2089 EXIT();
2090
2091 return vos_status;
2092}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302093
2094static int iw_get_bitrate(struct net_device *dev,
2095 struct iw_request_info *info,
2096 union iwreq_data *wrqu, char *extra)
2097{
2098 int ret;
2099
2100 vos_ssr_protect(__func__);
2101 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2102 vos_ssr_unprotect(__func__);
2103
2104 return ret;
2105}
2106
2107
Jeff Johnson295189b2012-06-20 16:38:30 -07002108/* ccm call back function */
2109
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302110static int __iw_set_bitrate(struct net_device *dev,
2111 struct iw_request_info *info,
2112 union iwreq_data *wrqu,
2113 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002114{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302115 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302117 hdd_station_ctx_t *pHddStaCtx;
2118 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2120 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2121 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2122 v_U32_t i, rate;
2123 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302124 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002125
2126 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302127 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2128 if (NULL == pAdapter)
2129 {
2130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2131 "%s: Adapter is NULL",__func__);
2132 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 }
2134
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302135 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2136 ret = wlan_hdd_validate_context(pHddCtx);
2137 if (0 != ret)
2138 {
2139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2140 "%s: HDD context is not valid",__func__);
2141 return ret;
2142 }
2143
2144 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2145 if (NULL == pHddStaCtx)
2146 {
2147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2148 "%s: STA Context is NULL",__func__);
2149 return -EINVAL;
2150 }
2151
2152
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302154 if (NULL == pWextState)
2155 {
2156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2157 "%s: pWextState is NULL",__func__);
2158 return -EINVAL;
2159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002160
2161 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2162 {
2163 return -ENXIO ;
2164 }
2165
2166 rate = wrqu->bitrate.value;
2167
2168 if (rate == -1)
2169 {
2170 rate = WNI_CFG_FIXED_RATE_AUTO;
2171 valid_rate = TRUE;
2172 }
2173 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2174 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2175 {
2176 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2177 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2178 {
2179 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2180 WNI_CFG_SUPPORTED_RATES_11A,
2181 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2182 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2183 WNI_CFG_SUPPORTED_RATES_11B,
2184 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2185 {
2186 for (i = 0; i < (b_len + a_len); ++i)
2187 {
2188 /* supported rates returned is double the actual rate so we divide it by 2 */
2189 if ((supp_rates[i]&0x7F)/2 == rate)
2190 {
2191 valid_rate = TRUE;
2192 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2193 break;
2194 }
2195 }
2196 }
2197 }
2198 }
2199 if (valid_rate != TRUE)
2200 {
2201 return -EINVAL;
2202 }
2203 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2204 WNI_CFG_FIXED_RATE, rate,
2205 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2206 {
c_hpothub8245442013-11-20 23:41:09 +05302207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2208 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 return -EIO;
2210 }
2211 return 0;
2212}
2213
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302214static int iw_set_bitrate(struct net_device *dev,
2215 struct iw_request_info *info,
2216 union iwreq_data *wrqu,
2217 char *extra)
2218{
2219 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002220
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302221 vos_ssr_protect(__func__);
2222 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2223 vos_ssr_unprotect(__func__);
2224
2225 return ret;
2226}
2227
2228static int __iw_set_genie(struct net_device *dev,
2229 struct iw_request_info *info,
2230 union iwreq_data *wrqu,
2231 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002232{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302233 hdd_adapter_t *pAdapter;
2234 hdd_context_t *pHddCtx;
2235 hdd_wext_state_t *pWextState;
2236 u_int8_t *genie = NULL;
2237 u_int8_t *base_genie = NULL;
2238 v_U16_t remLen;
2239 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002240
2241 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002242
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302243 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2244 if (NULL == pAdapter)
2245 {
2246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2247 "%s: Adapter is NULL",__func__);
2248 return -EINVAL;
2249 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002250
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302251 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2252 ret = wlan_hdd_validate_context(pHddCtx);
2253 if (0 != ret)
2254 {
2255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2256 "%s: HDD context is not valid",__func__);
2257 return ret;
2258 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002259
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302260 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2261 if (NULL == pWextState)
2262 {
2263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2264 "%s: pWextState is NULL",__func__);
2265 return -EINVAL;
2266 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002267
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302268 if (!wrqu->data.length) {
2269 hdd_clearRoamProfileIe(pAdapter);
2270 EXIT();
2271 return 0;
2272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002273
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302274 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2275 wrqu->data.length);
2276 if (NULL == base_genie)
2277 {
2278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2279 "mem_alloc_copy_from_user_helper fail");
2280 return -ENOMEM;
2281 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002282
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302283 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002284
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302285 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002286
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302287 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2288
2289 /* clear any previous genIE before this call */
2290 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2291
2292 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 {
2294 v_U16_t eLen = 0;
2295 v_U8_t elementId;
2296 elementId = *genie++;
2297 eLen = *genie++;
2298 remLen -= 2;
2299
Arif Hussain6d2a3322013-11-17 19:50:10 -08002300 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002301 __func__, elementId, eLen);
2302
2303 switch ( elementId )
2304 {
2305 case IE_EID_VENDOR:
2306 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002307 {
2308 kfree(base_genie);
2309 return -EINVAL;
2310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002311
2312 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2313 {
2314 v_U16_t curGenIELen = pWextState->genIE.length;
2315 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2316 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2317
2318 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2319 {
2320 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002321 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002323 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002324 return -ENOMEM;
2325 }
2326 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2327 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2328 pWextState->genIE.length += eLen + 2;
2329 }
2330 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2331 {
2332 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2333 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2334 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2335 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2336 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2337 }
2338 else /* any vendorId except WPA IE should be accumulated to genIE */
2339 {
2340 v_U16_t curGenIELen = pWextState->genIE.length;
2341 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2342 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2343
2344 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2345 {
2346 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002347 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002349 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 return -ENOMEM;
2351 }
2352 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2353 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2354 pWextState->genIE.length += eLen + 2;
2355 }
2356 break;
2357 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002358 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2360 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2361 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2362 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2363 break;
2364
2365 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002366 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002367 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 return 0;
2369 }
2370 genie += eLen;
2371 remLen -= eLen;
2372 }
2373 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002374 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 return 0;
2376}
2377
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302378static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 struct iw_request_info *info,
2380 union iwreq_data *wrqu,
2381 char *extra)
2382{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302383 int ret;
2384
2385 vos_ssr_protect(__func__);
2386 ret = __iw_set_genie(dev, info, wrqu, extra);
2387 vos_ssr_unprotect(__func__);
2388
2389 return ret;
2390}
2391
2392static int __iw_get_genie(struct net_device *dev,
2393 struct iw_request_info *info,
2394 union iwreq_data *wrqu,
2395 char *extra)
2396{
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302398 hdd_context_t *pHddCtx;
2399 hdd_adapter_t *pAdapter;
2400 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 eHalStatus status;
2402 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2403 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2404
2405 ENTER();
2406
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302407 hddLog(LOG1,"getGEN_IE ioctl");
2408 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2409 if (NULL == pAdapter)
2410 {
2411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2412 "%s: Adapter is NULL",__func__);
2413 return -EINVAL;
2414 }
2415 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2416 status = wlan_hdd_validate_context(pHddCtx);
2417 if (0 != status)
2418 {
2419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2420 "%s: HDD context is not valid",__func__);
2421 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 }
2423
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302425 if (NULL == pWextState)
2426 {
2427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2428 "%s: pWextState is NULL",__func__);
2429 return -EINVAL;
2430 }
2431
2432 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2433 if (NULL == pHddStaCtx)
2434 {
2435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2436 "%s: STA Context is NULL",__func__);
2437 return -EINVAL;
2438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002439
2440 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2441 {
2442 return -ENXIO;
2443 }
2444
2445 // Return something ONLY if we are associated with an RSN or WPA network
2446 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2447 pWextState->roamProfile.negotiatedAuthType))
2448 {
2449 return -ENXIO;
2450 }
2451
2452 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2453 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2454 pAdapter->sessionId,
2455 &length,
2456 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002457 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2458 if (wrqu->data.length < length)
2459 {
2460 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2461 return -EFAULT;
2462 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002463 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002464 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002465
Arif Hussain6d2a3322013-11-17 19:50:10 -08002466 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002467
2468 EXIT();
2469
2470 return 0;
2471}
2472
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302473static int iw_get_genie(struct net_device *dev,
2474 struct iw_request_info *info,
2475 union iwreq_data *wrqu,
2476 char *extra)
2477{
2478 int ret;
2479
2480 vos_ssr_protect(__func__);
2481 ret = __iw_get_genie(dev, info, wrqu, extra);
2482 vos_ssr_unprotect(__func__);
2483
2484 return ret;
2485}
2486
2487
2488static int __iw_get_encode(struct net_device *dev,
2489 struct iw_request_info *info,
2490 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002491{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302492 hdd_adapter_t *pAdapter;
2493 hdd_context_t *pHddCtx;
2494 hdd_wext_state_t *pWextState;
2495 tCsrRoamProfile *pRoamProfile;
2496 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002498
2499 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302500 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2501 if (NULL == pAdapter)
2502 {
2503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2504 "%s: Adapter is NULL",__func__);
2505 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 }
2507
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302508 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2509 ret = wlan_hdd_validate_context(pHddCtx);
2510 if (0 != ret)
2511 {
2512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2513 "%s: HDD context is not valid",__func__);
2514 return ret;
2515 }
2516 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2517 if (NULL == pWextState)
2518 {
2519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2520 "%s: pWextState is NULL",__func__);
2521 return -EINVAL;
2522 }
2523
2524 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 keyId = pRoamProfile->Keys.defaultIndex;
2526
2527 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2528 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002529 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 return -EINVAL;
2531 }
2532
2533 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2534 {
2535 dwrq->flags |= IW_ENCODE_ENABLED;
2536 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2537 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2538
2539 dwrq->flags |= (keyId + 1);
2540
2541 }
2542 else
2543 {
2544 dwrq->flags |= IW_ENCODE_DISABLED;
2545 }
2546
2547 for(i=0; i < MAX_WEP_KEYS; i++)
2548 {
2549 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2550 {
2551 continue;
2552 }
2553 else
2554 {
2555 break;
2556 }
2557 }
2558
2559 if(MAX_WEP_KEYS == i)
2560 {
2561 dwrq->flags |= IW_ENCODE_NOKEY;
2562 }
2563
2564 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2565
2566 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2567 {
2568 dwrq->flags |= IW_ENCODE_OPEN;
2569 }
2570 else
2571 {
2572 dwrq->flags |= IW_ENCODE_RESTRICTED;
2573 }
2574 EXIT();
2575 return 0;
2576}
2577
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302578static int iw_get_encode(struct net_device *dev,
2579 struct iw_request_info *info,
2580 struct iw_point *dwrq, char *extra)
2581{
2582 int ret;
2583
2584 vos_ssr_protect(__func__);
2585 ret = __iw_get_encode(dev, info, dwrq, extra);
2586 vos_ssr_unprotect(__func__);
2587
2588 return ret;
2589}
2590
Jeff Johnson295189b2012-06-20 16:38:30 -07002591#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2592#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2593
2594
2595/*
2596 * This function sends a single 'key' to LIM at all time.
2597 */
2598
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302599static int __iw_get_rts_threshold(struct net_device *dev,
2600 struct iw_request_info *info,
2601 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002602{
2603 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2604 v_U32_t status = 0;
2605
2606 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2607
2608 return status;
2609}
2610
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302611static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 struct iw_request_info *info,
2613 union iwreq_data *wrqu, char *extra)
2614{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302615 int ret;
2616
2617 vos_ssr_protect(__func__);
2618 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2619 vos_ssr_unprotect(__func__);
2620
2621 return ret;
2622}
2623
2624static int __iw_set_rts_threshold(struct net_device *dev,
2625 struct iw_request_info *info,
2626 union iwreq_data *wrqu, char *extra)
2627{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302628 hdd_adapter_t *pAdapter;
2629 hdd_context_t *pHddCtx;
2630 tHalHandle hHal;
2631 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002632
2633 ENTER();
2634
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302635 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2636 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002637 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2639 "%s: Adapter is NULL",__func__);
2640 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002641 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302642
2643 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2644 ret = wlan_hdd_validate_context(pHddCtx);
2645 if (0 != ret)
2646 {
2647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2648 "%s: HDD context is not valid",__func__);
2649 return ret;
2650 }
2651
2652 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2653 if (NULL == hHal)
2654 {
2655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2656 "%s: Hal Context is NULL",__func__);
2657 return -EINVAL;
2658 }
2659
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2661 {
2662 return -EINVAL;
2663 }
2664
2665 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2666 {
c_hpothub8245442013-11-20 23:41:09 +05302667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2668 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 return -EIO;
2670 }
2671
2672 EXIT();
2673
2674 return 0;
2675}
2676
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302677static int iw_set_rts_threshold(struct net_device *dev,
2678 struct iw_request_info *info,
2679 union iwreq_data *wrqu, char *extra)
2680{
2681 int ret;
2682
2683 vos_ssr_protect(__func__);
2684 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2685 vos_ssr_unprotect(__func__);
2686
2687 return ret;
2688}
2689
2690static int __iw_get_frag_threshold(struct net_device *dev,
2691 struct iw_request_info *info,
2692 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002693{
2694 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2695 v_U32_t status = 0;
2696
2697 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2698
2699 return status;
2700}
2701
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302702static int iw_get_frag_threshold(struct net_device *dev,
2703 struct iw_request_info *info,
2704 union iwreq_data *wrqu, char *extra)
2705{
2706 int ret;
2707
2708 vos_ssr_protect(__func__);
2709 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2710 vos_ssr_unprotect(__func__);
2711
2712 return ret;
2713}
2714
2715static int __iw_set_frag_threshold(struct net_device *dev,
2716 struct iw_request_info *info,
2717 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002718{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302719 hdd_adapter_t *pAdapter;
2720 hdd_context_t *pHddCtx;
2721 tHalHandle hHal;
2722 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002723
2724 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302725 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2726 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002727 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2729 "%s: Adapter is NULL",__func__);
2730 return -EINVAL;
2731 }
2732
2733 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2734 ret = wlan_hdd_validate_context(pHddCtx);
2735 if (0 != ret)
2736 {
2737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2738 "%s: HDD context is not valid",__func__);
2739 return ret;
2740 }
2741
2742 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2743 if (NULL == hHal)
2744 {
2745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2746 "%s: Hal Context is NULL",__func__);
2747 return -EINVAL;
2748 }
2749
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2751 {
2752 return -EINVAL;
2753 }
2754
2755 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2756 {
c_hpothub8245442013-11-20 23:41:09 +05302757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2758 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 return -EIO;
2760 }
2761
2762 EXIT();
2763
2764 return 0;
2765}
2766
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302767static int iw_set_frag_threshold(struct net_device *dev,
2768 struct iw_request_info *info,
2769 union iwreq_data *wrqu, char *extra)
2770{
2771 int ret;
2772
2773 vos_ssr_protect(__func__);
2774 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2775 vos_ssr_unprotect(__func__);
2776
2777 return ret;
2778}
2779
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302780static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 struct iw_request_info *info,
2782 union iwreq_data *wrqu, char *extra)
2783{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302784 hdd_adapter_t *pAdapter;
2785 hdd_context_t *pHddCtx;
2786 int ret = 0;
2787
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302789 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2790 if (NULL == pAdapter)
2791 {
2792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2793 "%s: Adapter is NULL",__func__);
2794 return -EINVAL;
2795 }
2796 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2797 ret = wlan_hdd_validate_context(pHddCtx);
2798 if (0 != ret)
2799 {
2800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2801 "%s: HDD context is not valid",__func__);
2802 return ret;
2803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 return -EOPNOTSUPP;
2805}
2806
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302807static int iw_get_power_mode(struct net_device *dev,
2808 struct iw_request_info *info,
2809 union iwreq_data *wrqu, char *extra)
2810{
2811 int ret;
2812
2813 vos_ssr_protect(__func__);
2814 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2815 vos_ssr_unprotect(__func__);
2816
2817 return ret;
2818}
2819static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 struct iw_request_info *info,
2821 union iwreq_data *wrqu, char *extra)
2822{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302823 hdd_adapter_t *pAdapter;
2824 hdd_context_t *pHddCtx;
2825 int ret = 0;
2826
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302828 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2829 if (NULL == pAdapter)
2830 {
2831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2832 "%s: Adapter is NULL",__func__);
2833 return -EINVAL;
2834 }
2835 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2836 ret = wlan_hdd_validate_context(pHddCtx);
2837 if (0 != ret)
2838 {
2839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2840 "%s: HDD context is not valid",__func__);
2841 return ret;
2842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002843 return -EOPNOTSUPP;
2844}
2845
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302846static int iw_set_power_mode(struct net_device *dev,
2847 struct iw_request_info *info,
2848 union iwreq_data *wrqu, char *extra)
2849{
2850 int ret;
2851
2852 vos_ssr_protect(__func__);
2853 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2854 vos_ssr_unprotect(__func__);
2855
2856 return ret;
2857}
2858
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302859static int __iw_get_range(struct net_device *dev,
2860 struct iw_request_info *info,
2861 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002862{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302863 hdd_adapter_t *pAdapter;
2864 tHalHandle hHal;
2865 hdd_context_t *pHddCtx;
2866 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 struct iw_range *range = (struct iw_range *) extra;
2868
2869 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2870
2871 v_U32_t num_channels = sizeof(channels);
2872 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2873 v_U32_t a_len;
2874 v_U32_t b_len;
2875 v_U32_t active_phy_mode = 0;
2876 v_U8_t index = 0, i;
2877
2878 ENTER();
2879
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302880 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2881 if (NULL == pAdapter)
2882 {
2883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2884 "%s: pAdapter is NULL", __func__);
2885 return -EINVAL;
2886 }
2887 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2888 ret = wlan_hdd_validate_context(pHddCtx);
2889 if (0 != ret)
2890 {
2891 hddLog(VOS_TRACE_LEVEL_ERROR,
2892 "%s: HDD context is not valid",__func__);
2893 return ret;
2894 }
2895 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2896 if (NULL == hHal)
2897 {
2898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2899 "%s: pAdapter is NULL", __func__);
2900 return -EINVAL;
2901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 wrqu->data.length = sizeof(struct iw_range);
2903 memset(range, 0, sizeof(struct iw_range));
2904
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 /*Get the phy mode*/
2906 if (ccmCfgGetInt(hHal,
2907 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2908 {
2909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002910 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002911
2912 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2913 {
2914 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002915 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 if (ccmCfgGetStr(hHal,
2917 WNI_CFG_SUPPORTED_RATES_11A,
2918 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2919 {
2920 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2921 {
2922 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2923 }
2924 for (i = 0; i < a_len; i++)
2925 {
2926 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2927 }
2928 range->num_bitrates = a_len;
2929 }
2930 else
2931 {
2932 return -EIO;
2933 }
2934 }
2935 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2936 {
2937 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002938 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 if (ccmCfgGetStr(hHal,
2940 WNI_CFG_SUPPORTED_RATES_11B,
2941 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2942 {
2943 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2944 {
2945 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2946 }
2947 for (i = 0; i < b_len; i++)
2948 {
2949 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2950 }
2951 range->num_bitrates = b_len;
2952 }
2953 else
2954 {
2955 return -EIO;
2956 }
2957 }
2958 }
2959
2960 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2961 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2962 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2963
2964 range->encoding_size[0] = 5;
2965 range->encoding_size[1] = 13;
2966 range->num_encoding_sizes = 2;
2967 range->max_encoding_tokens = MAX_WEP_KEYS;
2968
2969 // we support through Wireless Extensions 22
2970 range->we_version_compiled = WIRELESS_EXT;
2971 range->we_version_source = 22;
2972
2973 /*Supported Channels and Frequencies*/
2974 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2975 {
c_hpothub8245442013-11-20 23:41:09 +05302976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2977 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 return -EIO;
2979 }
2980 if (num_channels > IW_MAX_FREQUENCIES)
2981 {
2982 num_channels = IW_MAX_FREQUENCIES;
2983 }
2984
2985 range->num_channels = num_channels;
2986 range->num_frequency = num_channels;
2987
2988 for (index=0; index < num_channels; index++)
2989 {
2990 v_U32_t frq_indx = 0;
2991
2992 range->freq[index].i = channels[index];
2993 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2994 {
2995 if(channels[index] == freq_chan_map[frq_indx].chan)
2996 {
2997 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2998 range->freq[index].e = 1;
2999 break;
3000 }
3001 frq_indx++;
3002 }
3003 }
3004
3005 /* Event capability (kernel + driver) */
3006 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3007 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3008 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3009 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3010
3011 /*Encryption capability*/
3012 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3013 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3014
3015 /* Txpower capability */
3016 range->txpower_capa = IW_TXPOW_MWATT;
3017
3018 /*Scanning capability*/
3019 #if WIRELESS_EXT >= 22
3020 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3021 #endif
3022
3023 EXIT();
3024 return 0;
3025}
3026
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303027static int iw_get_range(struct net_device *dev,
3028 struct iw_request_info *info,
3029 union iwreq_data *wrqu, char *extra)
3030{
3031 int ret;
3032
3033 vos_ssr_protect(__func__);
3034 ret = __iw_get_range(dev, info, wrqu, extra);
3035 vos_ssr_unprotect(__func__);
3036
3037 return ret;
3038}
3039
Jeff Johnson295189b2012-06-20 16:38:30 -07003040/* Callback function registered with PMC to know status of PMC request */
3041static void iw_power_callback_fn (void *pContext, eHalStatus status)
3042{
3043 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003044
3045 if (NULL == pContext)
3046 {
3047 hddLog(VOS_TRACE_LEVEL_ERROR,
3048 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003049 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 return;
3051 }
3052
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003054
Jeff Johnson72a40512013-12-19 10:14:15 -08003055 /* there is a race condition that exists between this callback
3056 function and the caller since the caller could time out either
3057 before or while this code is executing. we use a spinlock to
3058 serialize these actions */
3059 spin_lock(&hdd_context_lock);
3060
3061 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 {
3063 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003064 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003066 "%s: Invalid context, magic [%08x]",
3067 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003068
3069 if (ioctl_debug)
3070 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003071 pr_info("%s: Invalid context, magic [%08x]\n",
3072 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 }
3074 return;
3075 }
3076
Jeff Johnson72a40512013-12-19 10:14:15 -08003077 /* context is valid so caller is still waiting */
3078
3079 /* paranoia: invalidate the magic */
3080 pStatsContext->magic = 0;
3081
3082 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003084
3085 /* serialization is complete */
3086 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003087}
3088
3089/* Callback function for tx per hit */
3090void hdd_tx_per_hit_cb (void *pCallbackContext)
3091{
3092 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3093 unsigned char tx_fail[16];
3094 union iwreq_data wrqu;
3095
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303096 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003098 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 return;
3100 }
3101 memset(&wrqu, 0, sizeof(wrqu));
3102 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3103 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3104}
3105
3106void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3107{
3108 struct statsContext *pStatsContext;
3109 tCsrGlobalClassAStatsInfo *pClassAStats;
3110 hdd_adapter_t *pAdapter;
3111
3112 if (ioctl_debug)
3113 {
3114 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003115 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 }
3117
3118 if ((NULL == pStats) || (NULL == pContext))
3119 {
3120 hddLog(VOS_TRACE_LEVEL_ERROR,
3121 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003122 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 return;
3124 }
3125
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 pClassAStats = pStats;
3127 pStatsContext = pContext;
3128 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003129
3130 /* there is a race condition that exists between this callback
3131 function and the caller since the caller could time out either
3132 before or while this code is executing. we use a spinlock to
3133 serialize these actions */
3134 spin_lock(&hdd_context_lock);
3135
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3137 {
3138 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003139 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 hddLog(VOS_TRACE_LEVEL_WARN,
3141 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003142 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 if (ioctl_debug)
3144 {
3145 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003146 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 }
3148 return;
3149 }
3150
Jeff Johnson72a40512013-12-19 10:14:15 -08003151 /* context is valid so caller is still waiting */
3152
3153 /* paranoia: invalidate the magic */
3154 pStatsContext->magic = 0;
3155
3156 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3158
Jeff Johnson72a40512013-12-19 10:14:15 -08003159 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003161
3162 /* serialization is complete */
3163 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003164}
3165
3166VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3167{
3168 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3169 eHalStatus hstatus;
3170 long lrc;
3171 struct statsContext context;
3172
3173 if (NULL == pAdapter)
3174 {
3175 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3176 return VOS_STATUS_E_FAULT;
3177 }
3178 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3179 {
3180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3181 return VOS_STATUS_SUCCESS;
3182 }
3183
3184 /* we are connected
3185 prepare our callback context */
3186 init_completion(&context.completion);
3187 context.pAdapter = pAdapter;
3188 context.magic = STATS_CONTEXT_MAGIC;
3189 /* query only for Class A statistics (which include link speed) */
3190 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3191 eCSR_HDD,
3192 SME_GLOBAL_CLASSA_STATS,
3193 hdd_GetClassA_statisticsCB,
3194 0, // not periodic
3195 FALSE, //non-cached results
3196 pHddStaCtx->conn_info.staId[0],
3197 &context);
3198 if (eHAL_STATUS_SUCCESS != hstatus)
3199 {
3200 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003201 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003202 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 /* we'll returned a cached value below */
3204 }
3205 else
3206 {
3207 /* request was sent -- wait for the response */
3208 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3209 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 if (lrc <= 0)
3211 {
3212 hddLog(VOS_TRACE_LEVEL_ERROR,
3213 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003214 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 }
3216 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003217
3218 /* either we never sent a request, we sent a request and received a
3219 response or we sent a request and timed out. if we never sent a
3220 request or if we sent a request and got a response, we want to
3221 clear the magic out of paranoia. if we timed out there is a
3222 race condition such that the callback function could be
3223 executing at the same time we are. of primary concern is if the
3224 callback function had already verified the "magic" but had not
3225 yet set the completion variable when a timeout occurred. we
3226 serialize these activities by invalidating the magic while
3227 holding a shared spinlock which will cause us to block if the
3228 callback is currently executing */
3229 spin_lock(&hdd_context_lock);
3230 context.magic = 0;
3231 spin_unlock(&hdd_context_lock);
3232
3233 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 return VOS_STATUS_SUCCESS;
3235}
3236
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003237static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3238{
3239 struct statsContext *pStatsContext;
3240 tCsrSummaryStatsInfo *pSummaryStats;
3241 tCsrGlobalClassAStatsInfo *pClassAStats;
3242 hdd_adapter_t *pAdapter;
3243
3244 if (ioctl_debug)
3245 {
3246 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003247 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003248 }
3249
3250 if ((NULL == pStats) || (NULL == pContext))
3251 {
3252 hddLog(VOS_TRACE_LEVEL_ERROR,
3253 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003254 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003255 return;
3256 }
3257
Jeff Johnson72a40512013-12-19 10:14:15 -08003258 /* there is a race condition that exists between this callback
3259 function and the caller since the caller could time out either
3260 before or while this code is executing. we use a spinlock to
3261 serialize these actions */
3262 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003263
3264 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3265 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3266 pStatsContext = pContext;
3267 pAdapter = pStatsContext->pAdapter;
3268 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3269 {
3270 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003271 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003272 hddLog(VOS_TRACE_LEVEL_WARN,
3273 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003274 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003275 if (ioctl_debug)
3276 {
3277 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003278 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003279 }
3280 return;
3281 }
3282
Jeff Johnson72a40512013-12-19 10:14:15 -08003283 /* context is valid so caller is still waiting */
3284
3285 /* paranoia: invalidate the magic */
3286 pStatsContext->magic = 0;
3287
3288 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003289 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3290 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3291
Jeff Johnson72a40512013-12-19 10:14:15 -08003292 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003293 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003294
3295 /* serialization is complete */
3296 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003297}
3298
3299VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3300{
3301 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3302 eHalStatus hstatus;
3303 long lrc;
3304 struct statsContext context;
3305
3306 if (NULL == pAdapter)
3307 {
3308 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3309 return VOS_STATUS_SUCCESS;
3310 }
3311
3312 /* we are connected
3313 prepare our callback context */
3314 init_completion(&context.completion);
3315 context.pAdapter = pAdapter;
3316 context.magic = STATS_CONTEXT_MAGIC;
3317
3318 /* query only for Summary & Class A statistics */
3319 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3320 eCSR_HDD,
3321 SME_SUMMARY_STATS |
3322 SME_GLOBAL_CLASSA_STATS,
3323 hdd_get_station_statisticsCB,
3324 0, // not periodic
3325 FALSE, //non-cached results
3326 pHddStaCtx->conn_info.staId[0],
3327 &context);
3328 if (eHAL_STATUS_SUCCESS != hstatus)
3329 {
3330 hddLog(VOS_TRACE_LEVEL_ERROR,
3331 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003332 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003333 /* we'll return with cached values */
3334 }
3335 else
3336 {
3337 /* request was sent -- wait for the response */
3338 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3339 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003340
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003341 if (lrc <= 0)
3342 {
3343 hddLog(VOS_TRACE_LEVEL_ERROR,
3344 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003345 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003346 }
3347 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003348
3349 /* either we never sent a request, we sent a request and received a
3350 response or we sent a request and timed out. if we never sent a
3351 request or if we sent a request and got a response, we want to
3352 clear the magic out of paranoia. if we timed out there is a
3353 race condition such that the callback function could be
3354 executing at the same time we are. of primary concern is if the
3355 callback function had already verified the "magic" but had not
3356 yet set the completion variable when a timeout occurred. we
3357 serialize these activities by invalidating the magic while
3358 holding a shared spinlock which will cause us to block if the
3359 callback is currently executing */
3360 spin_lock(&hdd_context_lock);
3361 context.magic = 0;
3362 spin_unlock(&hdd_context_lock);
3363
3364 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003365 return VOS_STATUS_SUCCESS;
3366}
3367
3368
Jeff Johnson295189b2012-06-20 16:38:30 -07003369/*
3370 * Support for the LINKSPEED private command
3371 * Per the WiFi framework the response must be of the form
3372 * "LinkSpeed xx"
3373 */
3374static int iw_get_linkspeed(struct net_device *dev,
3375 struct iw_request_info *info,
3376 union iwreq_data *wrqu, char *extra)
3377{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303378 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303379 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303381 int len = sizeof(v_U32_t) + 1;
3382 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303383 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303384 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303385 int rc, valid = 0;
3386
3387 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3388 if (NULL == pAdapter)
3389 {
3390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3391 "%s: Adapter is NULL",__func__);
3392 return -EINVAL;
3393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003394
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303395 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303396 valid = wlan_hdd_validate_context(pHddCtx);
3397
3398 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003399 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303400 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid %d"), valid);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303401 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003402 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303403 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3404 if (NULL == pHddStaCtx)
3405 {
3406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3407 "%s: STA Context is NULL",__func__);
3408 return -EINVAL;
3409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3411 {
3412 /* we are not connected so we don't have a classAstats */
3413 link_speed = 0;
3414 }
3415 else
3416 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303417 status = wlan_hdd_get_classAstats(pAdapter);
3418
3419 if (!VOS_IS_STATUS_SUCCESS(status ))
3420 {
3421 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3422 return -EINVAL;
3423 }
3424
3425 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3426 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3427 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3428 &link_speed);
3429
3430 link_speed = link_speed / 10;
3431
3432 if (0 == link_speed)
3433 {
3434 /* The linkspeed returned by HAL is in units of 500kbps.
3435 * converting it to mbps.
3436 * This is required to support legacy firmware which does
3437 * not return link capacity.
3438 */
3439 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3440 }
3441
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 }
3443
3444 wrqu->data.length = len;
3445 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003446 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 if ((rc < 0) || (rc >= len))
3448 {
3449 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303450 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 return -EIO;
3452 }
3453
3454 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003455 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003456}
3457
Arif Hussain695279c2014-03-24 14:06:07 -07003458/*
3459 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3460 *
3461 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303462static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003463 struct iw_request_info *info,
3464 union iwreq_data *wrqu, char *extra)
3465{
3466 int rc;
3467
3468 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3469
3470 if (rc < 0)
3471 return rc;
3472
3473 /* a value is being successfully returned */
3474 return 0;
3475}
Jeff Johnson295189b2012-06-20 16:38:30 -07003476
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303477static int iw_get_linkspeed_priv(struct net_device *dev,
3478 struct iw_request_info *info,
3479 union iwreq_data *wrqu, char *extra)
3480{
3481 int ret;
3482
3483 vos_ssr_protect(__func__);
3484 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3485 vos_ssr_unprotect(__func__);
3486
3487 return ret;
3488}
3489
Jeff Johnson295189b2012-06-20 16:38:30 -07003490/*
3491 * Support for the RSSI & RSSI-APPROX private commands
3492 * Per the WiFi framework the response must be of the form
3493 * "<ssid> rssi <xx>"
3494 * unless we are not associated, in which case the response is
3495 * "OK"
3496 */
3497static int iw_get_rssi(struct net_device *dev,
3498 struct iw_request_info *info,
3499 union iwreq_data *wrqu, char *extra)
3500{
3501 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003502 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 int len = wrqu->data.length;
3504 v_S7_t s7Rssi = 0;
3505 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3506 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3507 VOS_STATUS vosStatus;
3508 int rc;
3509
3510 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3511 (0 == ssidlen) || (ssidlen >= len))
3512 {
3513 /* we are not connected or our SSID is too long
3514 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003515 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 }
3517 else
3518 {
3519 /* we are connected with a valid SSID
3520 so we can write the SSID into the return buffer
3521 (note that it is not NUL-terminated) */
3522 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3523
3524 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3525
3526 if (VOS_STATUS_SUCCESS == vosStatus)
3527 {
3528 /* append the rssi to the ssid in the format required by
3529 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003530 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303531 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 }
3533 else
3534 {
3535 rc = -1;
3536 }
3537 }
3538
3539 /* verify that we wrote a valid response */
3540 if ((rc < 0) || (rc >= len))
3541 {
3542 // encoding or length error?
3543 hddLog(VOS_TRACE_LEVEL_ERROR,
3544 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003545 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 return -EIO;
3547 }
3548
3549 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003550 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003551}
3552
3553/*
3554 * Support for SoftAP channel range private command
3555 */
3556static int iw_softap_set_channel_range( struct net_device *dev,
3557 int startChannel,
3558 int endChannel,
3559 int band)
3560{
Jeff Johnson43971f52012-07-17 12:26:56 -07003561 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 int ret = 0;
3563 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3564 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003565 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3566
Jeff Johnson295189b2012-06-20 16:38:30 -07003567
3568 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3569 if (VOS_STATUS_SUCCESS != status)
3570 {
3571 ret = -EINVAL;
3572 }
Yathish9f22e662012-12-10 14:21:35 -08003573 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 return ret;
3575}
3576
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303577static uint8 chartohex(char c)
3578{
3579 uint8 val = 0;
3580 if (c >= '0' && c <= '9')
3581 val = c - '0';
3582 else if (c >= 'a' && c <= 'f')
3583 val = c - 'a' + 10;
3584 else if (c >= 'A' && c <= 'F')
3585 val = c - 'A' + 10;
3586 else
3587 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3588
3589 return val;
3590}
3591
3592uint8 getByte(char **buf)
3593{
3594 uint8 byte = 0;
3595 char *temp = *buf;
3596 byte = chartohex(*temp) * 16;
3597 temp++;
3598 byte += chartohex(*temp);
3599 temp++;
3600 *buf = temp;
3601 return byte;
3602}
3603
3604static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3605{
3606 tSir80211Header *macHeader;
3607 int i = 0, j = 0, length = 0;
3608 uint8 byte = 0;
3609 char *temp = pBuffer;
3610 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303611 char *pHeader;
3612 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303613
3614 macHeader = &pkt->macHeader;
3615
3616 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3617
3618 temp++;
3619
3620 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3621 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3622 pkt->encParams.keyParams.key[0].keyId);
3623
3624 for (i = 0; i< 16; i++) {
3625 pkt->encParams.keyParams.key[0].key[i]
3626 = getByte(&temp);
3627 }
3628
3629 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3630 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3631
3632 for (i = 0; i< 6; i++) {
3633 pkt->encParams.pn[i]
3634 = getByte(&temp);
3635 }
3636
3637 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3638 &pkt->encParams.pn[0], 6, 0);
3639
3640 for (i = 0, j= 5; i< 3; i++, j--) {
3641 byte = pkt->encParams.pn[i];
3642 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3643 pkt->encParams.pn[j] = byte;
3644 }
3645
3646 length = getByte(&temp);
3647
Srinivas Dasari2382de62015-01-22 15:00:04 +05303648 pHeader = temp;
3649 vos_mem_zero(&header, sizeof(tSir80211Header));
3650 for (i = 0; i < length; i++) {
3651 *((uint8 *)&header + i) = getByte(&pHeader);
3652 }
3653
3654 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3655 (char *)&header, length, 0);
3656
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303657 byte = getByte(&temp);
3658
3659 macHeader->frameCtrl.protVer = byte & 0x3;
3660 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3661 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3662
3663 byte = getByte(&temp);
3664 macHeader->frameCtrl.toDS = (byte) & 0x1;
3665 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3666 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3667 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3668 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3669 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3670 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3671 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3672
3673 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3674 "macHeader->frameCtrl.type : %x "
3675 "macHeader->frameCtrl.subType : %x "
3676 "macHeader->frameCtrl.toDS : %x "
3677 "macHeader->frameCtrl.fromDS : %x "
3678 "macHeader->frameCtrl.moreFrag : %x "
3679 "macHeader->frameCtrl.retry : %x "
3680 "macHeader->frameCtrl.powerMgmt : %x "
3681 "macHeader->frameCtrl.MoreData : %x "
3682 "macHeader->frameCtrl.wep : %x "
3683 "macHeader->frameCtrl.order : %x "
3684 , macHeader->frameCtrl.protVer
3685 , macHeader->frameCtrl.type
3686 , macHeader->frameCtrl.subType
3687 , macHeader->frameCtrl.toDS
3688 , macHeader->frameCtrl.fromDS
3689 , macHeader->frameCtrl.moreFrag
3690 , macHeader->frameCtrl.retry
3691 , macHeader->frameCtrl.powerMgmt
3692 , macHeader->frameCtrl.moreData
3693 , macHeader->frameCtrl.wep
3694 , macHeader->frameCtrl.order);
3695
3696
3697 macHeader->usDurationId = getByte(&temp);
3698 macHeader->usDurationId += getByte(&temp) << 8;
3699
3700 macHeader->vA1[0] = getByte(&temp);
3701 macHeader->vA1[1] = getByte(&temp);
3702 macHeader->vA1[2] = getByte(&temp);
3703 macHeader->vA1[3] = getByte(&temp);
3704 macHeader->vA1[4] = getByte(&temp);
3705 macHeader->vA1[5] = getByte(&temp);
3706
3707 macHeader->vA2[0] = getByte(&temp);
3708 macHeader->vA2[1] = getByte(&temp);
3709 macHeader->vA2[2] = getByte(&temp);
3710 macHeader->vA2[3] = getByte(&temp);
3711 macHeader->vA2[4] = getByte(&temp);
3712 macHeader->vA2[5] = getByte(&temp);
3713
3714 macHeader->vA3[0] = getByte(&temp);
3715 macHeader->vA3[1] = getByte(&temp);
3716 macHeader->vA3[2] = getByte(&temp);
3717 macHeader->vA3[3] = getByte(&temp);
3718 macHeader->vA3[4] = getByte(&temp);
3719 macHeader->vA3[5] = getByte(&temp);
3720
3721 macHeader->sSeqCtrl = getByte(&temp);
3722 fragNum = macHeader->sSeqCtrl & 0xF;
3723 macHeader->sSeqCtrl >>= 4;
3724
3725 macHeader->sSeqCtrl += getByte(&temp) << 4;
3726
3727 macHeader->sSeqCtrl |= fragNum << 12;
3728
3729 if (length == 30 || length == 32) {
3730 macHeader->optvA4[0] = getByte(&temp);
3731 macHeader->optvA4[1] = getByte(&temp);
3732 macHeader->optvA4[2] = getByte(&temp);
3733 macHeader->optvA4[3] = getByte(&temp);
3734 macHeader->optvA4[4] = getByte(&temp);
3735 macHeader->optvA4[5] = getByte(&temp);
3736 }
3737
3738 if (length == 26 || length == 32) {
3739 macHeader->usQosCtrl = getByte(&temp);
3740 macHeader->usQosCtrl += getByte(&temp) << 8;
3741 }
3742
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303743 //parse payload
3744 length = getByte(&temp);
3745 length += getByte(&temp) << 8;
3746 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3747
3748 pkt->data.length = length;
3749
3750 for (i = 0; i< length; i++) {
3751 pkt->data.data[i] = getByte(&temp);
3752 }
3753
3754 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3755 &pkt->data.data[0], pkt->data.length, 0);
3756}
3757
3758/**---------------------------------------------------------------------------
3759
3760 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3761 encrypt message request
3762 This is an asynchronous callback function from SME when the encrypted data
3763 is received
3764
3765 \pEncInfoRsp -> Encrypted data info
3766
3767 \return - 0 for success non-zero for failure
3768 --------------------------------------------------------------------------*/
3769static void
3770hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3771{
3772 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3773
3774 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3775
3776 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3777 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3778 pEncryptedDataRsp->encryptedPayload.length);
3779 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3780 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3781 pEncryptedDataRsp->encryptedPayload.data,
3782 pEncryptedDataRsp->encryptedPayload.length, 0);
3783}
3784
Jeff Johnson295189b2012-06-20 16:38:30 -07003785VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3786{
3787 struct statsContext context;
3788 eHalStatus status;
3789 hdd_context_t *pHddCtx;
3790
3791 if (NULL == pAdapter)
3792 {
3793 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3794 return VOS_STATUS_E_FAULT;
3795 }
3796
3797 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3798 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303799 if (pHddCtx->isLogpInProgress) {
3800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3801 "%s:LOGP in Progress. Ignore!!!", __func__);
3802 return VOS_STATUS_E_FAILURE;
3803 }
3804
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 init_completion(&context.completion);
3806
3807 context.pAdapter = pAdapter;
3808 context.magic = POWER_CONTEXT_MAGIC;
3809
3810 if (DRIVER_POWER_MODE_ACTIVE == mode)
3811 {
3812 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3813 "Full Power", __func__);
3814 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3815 iw_power_callback_fn, &context,
3816 eSME_FULL_PWR_NEEDED_BY_HDD);
3817 // Enter Full power command received from GUI this means we are disconnected
3818 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3819 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3820 if (eHAL_STATUS_PMC_PENDING == status)
3821 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003822 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 int lrc = wait_for_completion_interruptible_timeout(
3824 &context.completion,
3825 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003826
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 if (lrc <= 0)
3828 {
3829 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003830 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 }
3832 }
3833 }
3834 else if (DRIVER_POWER_MODE_AUTO == mode)
3835 {
3836 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3837 {
3838 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3839 __func__);
3840 // Enter BMPS command received from GUI this means DHCP is completed
3841 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3842 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3843 FALSE);
3844 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3845 iw_power_callback_fn, &context);
3846 if (eHAL_STATUS_PMC_PENDING == status)
3847 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003848 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003849 int lrc = wait_for_completion_interruptible_timeout(
3850 &context.completion,
3851 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 if (lrc <= 0)
3853 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003854 hddLog(VOS_TRACE_LEVEL_ERROR,
3855 "%s: SME %s while requesting BMPS",
3856 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 }
3858 }
3859 }
3860 else
3861 {
3862 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3863 "enabled in the cfg");
3864 }
3865 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003866
3867 /* either we never sent a request, we sent a request and received a
3868 response or we sent a request and timed out. if we never sent a
3869 request or if we sent a request and got a response, we want to
3870 clear the magic out of paranoia. if we timed out there is a
3871 race condition such that the callback function could be
3872 executing at the same time we are. of primary concern is if the
3873 callback function had already verified the "magic" but had not
3874 yet set the completion variable when a timeout occurred. we
3875 serialize these activities by invalidating the magic while
3876 holding a shared spinlock which will cause us to block if the
3877 callback is currently executing */
3878 spin_lock(&hdd_context_lock);
3879 context.magic = 0;
3880 spin_unlock(&hdd_context_lock);
3881
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 return VOS_STATUS_SUCCESS;
3883}
3884
3885VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3886 hdd_adapter_t *pAdapter)
3887{
3888 VOS_STATUS vos_Status;
3889
3890 if ((NULL == pAdapter) || (NULL == pHddCtx))
3891 {
3892 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3893 return VOS_STATUS_E_FAULT;
3894 }
3895
3896 /**Exit from Deep sleep or standby if we get the driver
3897 START cmd from android GUI
3898 */
3899 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3900 {
3901 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3902 "from Stand by",__func__);
3903 vos_Status = hdd_exit_standby(pHddCtx);
3904 }
3905 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3906 {
3907 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3908 "from deep sleep",__func__);
3909 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3910 }
3911 else
3912 {
3913 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3914 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3915 vos_Status = VOS_STATUS_SUCCESS;
3916 }
3917
3918 return vos_Status;
3919}
3920
3921VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3922{
3923 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3924
3925 if (NULL == pHddCtx)
3926 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303927 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 return VOS_STATUS_E_FAULT;
3929 }
3930
3931 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3932 {
3933 //Execute standby procedure.
3934 //Executing standby procedure will cause the STA to
3935 //disassociate first and then the chip will be put into standby.
3936 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3937 vos_Status = hdd_enter_standby(pHddCtx);
3938 }
3939 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3940 pHddCtx->cfg_ini->nEnableDriverStop)
3941 {
3942 //Execute deep sleep procedure
3943 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003944 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 //Deep sleep not supported
3946 vos_Status = hdd_enter_standby(pHddCtx);
3947 }
3948 else
3949 {
3950 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3951 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3952 vos_Status = VOS_STATUS_SUCCESS;
3953 }
3954
3955 return vos_Status;
3956}
3957
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003958
3959void* wlan_hdd_change_country_code_callback(void *pAdapter)
3960{
3961
3962 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003963 complete(&call_back_pAdapter->change_country_code);
3964
3965 return NULL;
3966}
3967
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303968static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 struct iw_request_info *info,
3970 union iwreq_data *wrqu, char *extra)
3971{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303972 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08003973 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303975 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003976 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3977
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303978 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003979
3980 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303981
3982 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3983 if (NULL == pAdapter)
3984 {
3985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3986 "mem_alloc_copy_from_user_helper fail");
3987 return -EINVAL;
3988 }
3989 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3990 rc = wlan_hdd_validate_context(pHddCtx);
3991 if (0 != rc)
3992 {
3993 hddLog(VOS_TRACE_LEVEL_ERROR,
3994 "%s: HDD context is not valid", __func__);
3995 return rc;
3996 }
3997
Arif Hussain24bfa702014-01-22 13:51:30 -08003998 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3999 wrqu->data.length);
4000 if (NULL == cmd)
4001 {
4002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4003 "mem_alloc_copy_from_user_helper fail");
4004 return -ENOMEM;
4005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004006
4007 if (ioctl_debug)
4008 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004009 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 }
4011
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004012 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4013 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004014
Arif Hussain24bfa702014-01-22 13:51:30 -08004015 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004017 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4019 "%s: Error in iw_set_scan!", __func__);
4020 rc = -EINVAL;
4021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004022 }
4023 else if( strcasecmp(cmd, "start") == 0 ) {
4024
Arif Hussain6d2a3322013-11-17 19:50:10 -08004025 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004027
Arif Hussain24bfa702014-01-22 13:51:30 -08004028 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4029 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 {
4031 union iwreq_data wrqu;
4032 char buf[10];
4033
4034 memset(&wrqu, 0, sizeof(wrqu));
4035 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4036 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4037 }
4038 else
4039 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004040 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4041 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 }
4043 goto done;
4044 }
4045 else if( strcasecmp(cmd, "stop") == 0 )
4046 {
4047 union iwreq_data wrqu;
4048 char buf[10];
4049
Arif Hussain6d2a3322013-11-17 19:50:10 -08004050 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004051
4052 wlan_hdd_enter_lowpower(pHddCtx);
4053 memset(&wrqu, 0, sizeof(wrqu));
4054 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4055 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 goto done;
4057 }
4058 else if (strcasecmp(cmd, "macaddr") == 0)
4059 {
4060 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4061 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4062 }
4063 else if (strcasecmp(cmd, "scan-active") == 0)
4064 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304065 hddLog(VOS_TRACE_LEVEL_ERROR,
4066 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004067 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 ret = snprintf(cmd, cmd_len, "OK");
4069 }
4070 else if (strcasecmp(cmd, "scan-passive") == 0)
4071 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304072 hddLog(VOS_TRACE_LEVEL_ERROR,
4073 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004074 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 ret = snprintf(cmd, cmd_len, "OK");
4076 }
4077 else if( strcasecmp(cmd, "scan-mode") == 0 )
4078 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004079 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 }
4081 else if( strcasecmp(cmd, "linkspeed") == 0 )
4082 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004083 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 }
4085 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4086 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004087 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004088 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004089
4090 country_code = cmd + 8;
4091
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004092 init_completion(&pAdapter->change_country_code);
4093
Arif Hussain24bfa702014-01-22 13:51:30 -08004094 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004095 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 country_code,
4097 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304098 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304099 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304100 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004101
4102 /* Wait for completion */
4103 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4104 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4105
4106 if (lrc <= 0)
4107 {
4108 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004109 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004110 }
4111
Arif Hussain24bfa702014-01-22 13:51:30 -08004112 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004114 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004115 "%s: SME Change Country code fail", __func__);
4116 kfree(cmd);
4117 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 }
4119 }
4120 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4121 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004122 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 }
4124 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4125 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004126 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004127
Wilson Yang1be3e652013-10-09 15:18:31 -07004128 if (9 < cmd_len)
4129 {
4130 ptr = (char*)(cmd + 9);
4131
4132 }else{
4133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4134 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004135 kfree(cmd);
4136 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004137 }
4138
4139 if (1 != sscanf(ptr,"%d",&mode))
4140 {
4141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4142 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004143 kfree(cmd);
4144 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004145 }
4146
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 wlan_hdd_enter_bmps(pAdapter, mode);
4148 /*TODO:Set the power mode*/
4149 }
4150 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4151 v_U32_t pmc_state;
4152 v_U16_t value;
4153
4154 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4155 if(pmc_state == BMPS) {
4156 value = DRIVER_POWER_MODE_AUTO;
4157 }
4158 else {
4159 value = DRIVER_POWER_MODE_ACTIVE;
4160 }
4161 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4162 }
4163 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004164 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 /*TODO: set the btcoexmode*/
4166 }
4167 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4168
Arif Hussain6d2a3322013-11-17 19:50:10 -08004169 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 /*TODO: Return the btcoex status*/
4171 }
4172 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4173
Arif Hussain6d2a3322013-11-17 19:50:10 -08004174 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004175
4176 /*TODO: Enable Rx data Filter*/
4177 }
4178 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4179
Arif Hussain6d2a3322013-11-17 19:50:10 -08004180 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004181
4182 /*TODO: Disable Rx data Filter*/
4183 }
4184 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4185
Arif Hussain6d2a3322013-11-17 19:50:10 -08004186 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 /*TODO: rxfilter-statistics*/
4188 }
4189 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4190
Arif Hussain6d2a3322013-11-17 19:50:10 -08004191 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 /*TODO: rxfilter-add*/
4193 }
4194 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4195
Arif Hussain6d2a3322013-11-17 19:50:10 -08004196 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 /*TODO: rxfilter-remove*/
4198 }
4199#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004200 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4201 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4202 /*TODO: support pnosetup*/
4203 }
4204 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4205 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4206 /*TODO: support pnoforce*/
4207 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4209
Arif Hussain6d2a3322013-11-17 19:50:10 -08004210 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004211 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4212 kfree(cmd);
4213 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 }
4215 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004216 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004217 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4218 kfree(cmd);
4219 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 }
4221#endif /*FEATURE_WLAN_SCAN_PNO*/
4222 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004223 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004224 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4225 kfree(cmd);
4226 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 }
4228 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4229 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004230 char *ptr;
4231
4232 if (18 < cmd_len)
4233 {
4234 ptr = (char*)(cmd + 18);
4235 }else{
4236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4237 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004238 kfree(cmd);
4239 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004240 }
4241
Jeff Johnson02797792013-10-26 19:17:13 -07004242 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004243 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4244 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4245 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4246 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4247 {
4248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4249 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004250 kfree(cmd);
4251 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004253
4254 // parameters checking
4255 // period has to be larger than 0
4256 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4257 {
4258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004259 kfree(cmd);
4260 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 }
4262
4263 // use default value 5 is the input is not reasonable. in unit of 10%
4264 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4265 {
4266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4267 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4268 }
4269
4270 // default is 5
4271 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4272 {
4273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4274 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4275 }
4276
Arif Hussain24bfa702014-01-22 13:51:30 -08004277 if (eHAL_STATUS_SUCCESS !=
4278 sme_SetTxPerTracking(pHddCtx->hHal,
4279 hdd_tx_per_hit_cb,
4280 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004282 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 }
4284 }
4285 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004286 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4287 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 }
4289done:
4290 /* many of the commands write information back into the command
4291 string using snprintf(). check the return value here in one
4292 place */
4293 if ((ret < 0) || (ret >= cmd_len))
4294 {
4295 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004296 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004298 else if (ret > 0)
4299 {
4300 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4301 {
4302 hddLog(VOS_TRACE_LEVEL_ERROR,
4303 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004304 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004305 return -EFAULT;
4306 }
4307 wrqu->data.length = ret;
4308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004309
4310 if (ioctl_debug)
4311 {
4312 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004313 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004315 kfree(cmd);
4316 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004317}
4318
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304319static int iw_set_priv(struct net_device *dev,
4320 struct iw_request_info *info,
4321 union iwreq_data *wrqu, char *extra)
4322{
4323 int ret;
4324 vos_ssr_protect(__func__);
4325 ret = __iw_set_priv(dev, info, wrqu, extra);
4326 vos_ssr_unprotect(__func__);
4327
4328 return ret;
4329}
4330
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304331static int __iw_set_nick(struct net_device *dev,
4332 struct iw_request_info *info,
4333 union iwreq_data *wrqu, char *extra)
4334{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304335 hdd_adapter_t *pAdapter;
4336 hdd_context_t *pHddCtx;
4337 int ret = 0;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304338 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304339
4340 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4341 if (NULL == pAdapter)
4342 {
4343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4344 "%s: Adapter is NULL",__func__);
4345 return -EINVAL;
4346 }
4347
4348 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4349 ret = wlan_hdd_validate_context(pHddCtx);
4350 if (0 != ret)
4351 {
4352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4353 "%s: HDD context is not valid",__func__);
4354 return ret;
4355 }
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304356 return 0;
4357}
4358
Jeff Johnson295189b2012-06-20 16:38:30 -07004359static int iw_set_nick(struct net_device *dev,
4360 struct iw_request_info *info,
4361 union iwreq_data *wrqu, char *extra)
4362{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304363 int ret;
4364
4365 vos_ssr_protect(__func__);
4366 ret = __iw_set_nick(dev, info, wrqu, extra);
4367 vos_ssr_unprotect(__func__);
4368
4369 return ret;
4370}
4371
4372static int __iw_get_nick(struct net_device *dev,
4373 struct iw_request_info *info,
4374 union iwreq_data *wrqu, char *extra)
4375{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304376 hdd_adapter_t *pAdapter;
4377 hdd_context_t *pHddCtx;
4378 int ret = 0;
4379
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304381
4382 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4383 if (NULL == pAdapter)
4384 {
4385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4386 "%s: Adapter is NULL",__func__);
4387 return -EINVAL;
4388 }
4389
4390 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4391 ret = wlan_hdd_validate_context(pHddCtx);
4392 if (0 != ret)
4393 {
4394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4395 "%s: HDD context is not valid",__func__);
4396 return ret;
4397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 return 0;
4399}
4400
4401static int iw_get_nick(struct net_device *dev,
4402 struct iw_request_info *info,
4403 union iwreq_data *wrqu, char *extra)
4404{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304405 int ret;
4406
4407 vos_ssr_protect(__func__);
4408 ret = __iw_get_nick(dev, info, wrqu, extra);
4409 vos_ssr_unprotect(__func__);
4410
4411 return ret;
4412}
4413
4414static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4415{
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304417 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004418}
4419
4420static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4421{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304422
4423 struct iw_statistics *stats;
4424
4425 vos_ssr_protect(__func__);
4426 stats = __get_wireless_stats(dev);
4427 vos_ssr_unprotect(__func__);
4428
4429 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004430}
4431
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304432static int __iw_set_encode(struct net_device *dev,
4433 struct iw_request_info *info,
4434 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004435
4436{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304437 hdd_adapter_t *pAdapter;
4438 hdd_station_ctx_t *pHddStaCtx;
4439 hdd_wext_state_t *pWextState;
4440 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 struct iw_point *encoderq = &(wrqu->encoding);
4442 v_U32_t keyId;
4443 v_U8_t key_length;
4444 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4445 v_BOOL_t fKeyPresent = 0;
4446 int i;
4447 eHalStatus status = eHAL_STATUS_SUCCESS;
4448
4449
4450 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304451 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4452 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4455 "%s: Adapter is NULL",__func__);
4456 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 }
4458
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304459 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4460 status = wlan_hdd_validate_context(pHddCtx);
4461 if (0 != status)
4462 {
4463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4464 "%s: HDD context is not valid",__func__);
4465 return status;
4466 }
4467 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4468 if (NULL == pWextState)
4469 {
4470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4471 "%s: pWextState is NULL ",__func__);
4472 return -EINVAL;
4473 }
4474 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4475 if (NULL == pHddStaCtx)
4476 {
4477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4478 "%s: STA Context is NULL",__func__);
4479 return -EINVAL;
4480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004481
4482 keyId = encoderq->flags & IW_ENCODE_INDEX;
4483
4484 if(keyId)
4485 {
4486 if(keyId > MAX_WEP_KEYS)
4487 {
4488 return -EINVAL;
4489 }
4490
4491 fKeyPresent = 1;
4492 keyId--;
4493 }
4494 else
4495 {
4496 fKeyPresent = 0;
4497 }
4498
4499
4500 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4501 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 if(!fKeyPresent) {
4504
4505 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4506
4507 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4508 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4509 }
4510 }
4511 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4512 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4513 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4514 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4515
4516 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4517 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4518
4519 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4520 {
4521 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4522 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004523 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304524 {
4525 long ret;
4526 ret = wait_for_completion_interruptible_timeout(
4527 &pAdapter->disconnect_comp_var,
4528 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4529 if (ret <= 0)
4530 hddLog(VOS_TRACE_LEVEL_ERROR,
4531 FL("failed wait on disconnect_comp_var %ld"), ret);
4532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 }
4534
4535 return status;
4536
4537 }
4538
4539 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4540 {
4541 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4542
4543 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4544
4545 }
4546
4547
4548 if(wrqu->data.length > 0)
4549 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004550 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004551
4552 key_length = wrqu->data.length;
4553
4554 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4555
4556 if(5 == key_length)
4557 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004558 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004559
4560 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4561 {
4562 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4563 }
4564 else
4565 {
4566 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4567 }
4568 }
4569 else if(13 == key_length)
4570 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004571 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004572
4573 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4574 {
4575 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4576 }
4577 else
4578 {
4579 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4580 }
4581 }
4582 else
4583 {
4584 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004585 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 return -EINVAL;
4587 }
4588
4589 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4590 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4591 pWextState->roamProfile.EncryptionType.numEntries = 1;
4592 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4593 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4594 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4595
4596 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4597 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4598 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4599 {
4600
4601 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4602
4603 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4604 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4605
4606 return status;
4607 }
4608 }
4609
4610 return 0;
4611}
4612
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304613static int iw_set_encode(struct net_device *dev,
4614 struct iw_request_info *info,
4615 union iwreq_data *wrqu,char *extra)
4616{
4617 int ret;
4618
4619 vos_ssr_protect(__func__);
4620 ret = __iw_set_encode(dev, info, wrqu, extra);
4621 vos_ssr_unprotect(__func__);
4622
4623 return ret;
4624}
4625
4626static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 struct iw_request_info *info,
4628 struct iw_point *dwrq,
4629 char *extra)
4630{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304631 hdd_adapter_t *pAdapter;
4632 hdd_wext_state_t *pWextState;
4633 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 int keyId;
4635 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4636 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304637 int i, ret = 0;
4638 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004639
4640 ENTER();
4641
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304642 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4643 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004644 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4646 "%s: Adapter is NULL",__func__);
4647 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004648 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304649 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4650 ret = wlan_hdd_validate_context(pHddCtx);
4651 if (0 != ret)
4652 {
4653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4654 "%s: HDD context is not valid",__func__);
4655 return ret;
4656 }
4657 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4658 if (NULL == pWextState)
4659 {
4660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4661 "%s: pWextState is NULL",__func__);
4662 return -EINVAL;
4663 }
4664 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004665
Jeff Johnson295189b2012-06-20 16:38:30 -07004666 keyId = pRoamProfile->Keys.defaultIndex;
4667
4668 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4669 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004670 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 return -EINVAL;
4672 }
4673
4674 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4675 {
4676 dwrq->flags |= IW_ENCODE_ENABLED;
4677 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304678 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4679 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 }
4681 else
4682 {
4683 dwrq->flags |= IW_ENCODE_DISABLED;
4684 }
4685
4686 for(i=0; i < MAX_WEP_KEYS; i++)
4687 {
4688 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4689 {
4690 continue;
4691 }
4692 else
4693 {
4694 break;
4695 }
4696 }
4697
4698 if(MAX_WEP_KEYS == i)
4699 {
4700 dwrq->flags |= IW_ENCODE_NOKEY;
4701 }
4702 else
4703 {
4704 dwrq->flags |= IW_ENCODE_ENABLED;
4705 }
4706
4707 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4708
4709 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4710 {
4711 dwrq->flags |= IW_ENCODE_DISABLED;
4712 }
4713
4714 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4715
4716 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4717 {
4718 dwrq->flags |= IW_ENCODE_OPEN;
4719 }
4720 else
4721 {
4722 dwrq->flags |= IW_ENCODE_RESTRICTED;
4723 }
4724 EXIT();
4725 return 0;
4726
4727}
4728
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304729static int iw_get_encodeext(struct net_device *dev,
4730 struct iw_request_info *info,
4731 struct iw_point *dwrq,
4732 char *extra)
4733{
4734 int ret;
4735 vos_ssr_protect(__func__);
4736 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4737 vos_ssr_unprotect(__func__);
4738
4739 return ret;
4740}
4741
4742static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 struct iw_request_info *info,
4744 union iwreq_data *wrqu, char *extra)
4745{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304746 hdd_adapter_t *pAdapter;
4747 hdd_station_ctx_t *pHddStaCtx;
4748 hdd_wext_state_t *pWextState;
4749 hdd_context_t *pHddCtx;
4750 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004751
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304752 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 v_U32_t status = 0;
4754
4755 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4756
4757 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4758
4759 int key_index;
4760 struct iw_point *encoding = &wrqu->encoding;
4761 tCsrRoamSetKey setKey;
4762 v_U32_t roamId= 0xFF;
4763 VOS_STATUS vos_status;
4764
4765 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304766 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4767 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4770 "%s: Adapter is NULL",__func__);
4771 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304773 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4774 status = wlan_hdd_validate_context(pHddCtx);
4775 if (0 != status)
4776 {
4777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4778 "%s: HDD context is not valid",__func__);
4779 return status;
4780 }
4781 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4782 if (NULL == pHddStaCtx)
4783 {
4784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4785 "%s: STA Context is NULL",__func__);
4786 return -EINVAL;
4787 }
4788 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4789 if (NULL == pWextState)
4790 {
4791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4792 "%s: pWextState is NULL",__func__);
4793 return -EINVAL;
4794 }
4795 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 key_index = encoding->flags & IW_ENCODE_INDEX;
4797
4798 if(key_index > 0) {
4799
4800 /*Convert from 1-based to 0-based keying*/
4801 key_index--;
4802 }
4803 if(!ext->key_len) {
4804
4805 /*Set the encrytion type to NONE*/
4806 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4807 return status;
4808 }
4809
4810 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4811 (IW_ENCODE_ALG_WEP == ext->alg))
4812 {
4813 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4814
Agarwal Ashish971c2882013-10-30 20:11:12 +05304815 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4816 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 return -EINVAL;
4818 }
4819 else {
4820 /*Static wep, update the roam profile with the keys */
4821 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4822 key_index < CSR_MAX_NUM_KEY) {
4823 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4824 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4825
4826 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4827 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4828
4829 }
4830 }
4831 return status;
4832 }
4833
4834 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4835
4836 setKey.keyId = key_index;
4837 setKey.keyLength = ext->key_len;
4838
4839 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4840 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4841 }
4842
4843 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4844 /*Key direction for group is RX only*/
4845 setKey.keyDirection = eSIR_RX_ONLY;
4846 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4847 }
4848 else {
4849
4850 setKey.keyDirection = eSIR_TX_RX;
4851 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4852 }
4853
4854 /*For supplicant pae role is zero*/
4855 setKey.paeRole = 0;
4856
4857 switch(ext->alg)
4858 {
4859 case IW_ENCODE_ALG_NONE:
4860 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4861 break;
4862
4863 case IW_ENCODE_ALG_WEP:
4864 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4865 break;
4866
4867 case IW_ENCODE_ALG_TKIP:
4868 {
4869 v_U8_t *pKey = &setKey.Key[0];
4870
4871 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4872
4873 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4874
4875 /*Supplicant sends the 32bytes key in this order
4876
4877 |--------------|----------|----------|
4878 | Tk1 |TX-MIC | RX Mic |
4879 |--------------|----------|----------|
4880 <---16bytes---><--8bytes--><--8bytes-->
4881
4882 */
4883 /*Sme expects the 32 bytes key to be in the below order
4884
4885 |--------------|----------|----------|
4886 | Tk1 |RX-MIC | TX Mic |
4887 |--------------|----------|----------|
4888 <---16bytes---><--8bytes--><--8bytes-->
4889 */
4890 /* Copy the Temporal Key 1 (TK1) */
4891 vos_mem_copy(pKey,ext->key,16);
4892
4893 /*Copy the rx mic first*/
4894 vos_mem_copy(&pKey[16],&ext->key[24],8);
4895
4896 /*Copy the tx mic */
4897 vos_mem_copy(&pKey[24],&ext->key[16],8);
4898
4899 }
4900 break;
4901
4902 case IW_ENCODE_ALG_CCMP:
4903 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4904 break;
4905
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004906#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004907#define IW_ENCODE_ALG_KRK 6
4908 case IW_ENCODE_ALG_KRK:
4909 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4910 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004911#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004912
4913 default:
4914 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4915 break;
4916 }
4917
4918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004919 ("%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 -07004920
4921#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304922 /* The supplicant may attempt to set the PTK once pre-authentication
4923 is done. Save the key in the UMAC and include it in the ADD
4924 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304926 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304928 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4929 "%s: Update PreAuth Key success", __func__);
4930 return 0;
4931 }
4932 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4933 {
4934 hddLog(VOS_TRACE_LEVEL_ERROR,
4935 "%s: Update PreAuth Key failed", __func__);
4936 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 }
4938#endif /* WLAN_FEATURE_VOWIFI_11R */
4939
4940 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4941
4942 vos_status = wlan_hdd_check_ula_done(pAdapter);
4943 if ( vos_status != VOS_STATUS_SUCCESS )
4944 {
4945 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4946 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
4947 __LINE__, vos_status );
4948
4949 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4950 }
4951
4952 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
4953
4954 if ( halStatus != eHAL_STATUS_SUCCESS )
4955 {
4956 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4957 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4958 __LINE__, halStatus );
4959
4960 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4961 }
4962
4963 return halStatus;
4964}
4965
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304966static int iw_set_encodeext(struct net_device *dev,
4967 struct iw_request_info *info,
4968 union iwreq_data *wrqu, char *extra)
4969{
4970 int ret;
4971
4972 vos_ssr_protect(__func__);
4973 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4974 vos_ssr_unprotect(__func__);
4975
4976 return ret;
4977}
4978
4979static int __iw_set_retry(struct net_device *dev,
4980 struct iw_request_info *info,
4981 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004982{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304983 hdd_adapter_t *pAdapter;
4984 tHalHandle hHal;
4985 hdd_context_t *pHddCtx;
4986 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004987
4988 ENTER();
4989
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304990 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4991 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004992 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4994 "%s: Adapter is NULL",__func__);
4995 return -EINVAL;
4996 }
4997
4998 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4999 ret = wlan_hdd_validate_context(pHddCtx);
5000 if (0 != ret)
5001 {
5002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5003 "%s: HDD context is not valid",__func__);
5004 return ret;
5005 }
5006
5007 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5008 if (NULL == hHal)
5009 {
5010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5011 "%s: Hal Context is NULL",__func__);
5012 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005013 }
5014
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5016 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5017
Arif Hussain6d2a3322013-11-17 19:50:10 -08005018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005019
5020 return -EINVAL;
5021 }
5022
5023 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5024
5025 if((wrqu->retry.flags & IW_RETRY_LONG))
5026 {
5027 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5028 {
c_hpothub8245442013-11-20 23:41:09 +05305029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5030 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 return -EIO;
5032 }
5033 }
5034 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5035 {
5036 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5037 {
c_hpothub8245442013-11-20 23:41:09 +05305038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5039 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 return -EIO;
5041 }
5042 }
5043 }
5044 else
5045 {
5046 return -EOPNOTSUPP;
5047 }
5048
Arif Hussain6d2a3322013-11-17 19:50:10 -08005049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005050
5051 EXIT();
5052
5053 return 0;
5054
5055}
5056
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305057static int iw_set_retry(struct net_device *dev,
5058 struct iw_request_info *info,
5059 union iwreq_data *wrqu, char *extra)
5060{
5061 int ret;
5062
5063 vos_ssr_protect(__func__);
5064 ret = __iw_set_retry(dev, info, wrqu, extra);
5065 vos_ssr_unprotect(__func__);
5066
5067 return ret;
5068}
5069
5070static int __iw_get_retry(struct net_device *dev,
5071 struct iw_request_info *info,
5072 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005073{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305074 hdd_adapter_t *pAdapter;
5075 hdd_context_t *pHddCtx;
5076 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305078 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005079
5080 ENTER();
5081
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305082 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5083 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005084 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5086 "%s: Adapter is NULL",__func__);
5087 return -EINVAL;
5088 }
5089
5090 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5091 ret = wlan_hdd_validate_context(pHddCtx);
5092 if (0 != ret)
5093 {
5094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5095 "%s: HDD context is not valid",__func__);
5096 return ret;
5097 }
5098
5099 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5100 if (NULL == hHal)
5101 {
5102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5103 "%s: Hal Context is NULL",__func__);
5104 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005105 }
5106
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 if((wrqu->retry.flags & IW_RETRY_LONG))
5108 {
5109 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5110
5111 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5112 {
c_hpothub8245442013-11-20 23:41:09 +05305113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5114 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 return -EIO;
5116 }
5117
5118 wrqu->retry.value = retry;
5119 }
5120 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5121 {
5122 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5123
5124 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5125 {
c_hpothub8245442013-11-20 23:41:09 +05305126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5127 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 return -EIO;
5129 }
5130
5131 wrqu->retry.value = retry;
5132 }
5133 else {
5134 return -EOPNOTSUPP;
5135 }
5136
Arif Hussain6d2a3322013-11-17 19:50:10 -08005137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005138
5139 EXIT();
5140
5141 return 0;
5142}
5143
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305144static int iw_get_retry(struct net_device *dev,
5145 struct iw_request_info *info,
5146 union iwreq_data *wrqu, char *extra)
5147{
5148 int ret;
5149
5150 vos_ssr_protect(__func__);
5151 ret = __iw_get_retry(dev, info, wrqu, extra);
5152 vos_ssr_unprotect(__func__);
5153
5154 return ret;
5155}
5156
5157static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 struct iw_request_info *info,
5159 union iwreq_data *wrqu,
5160 char *extra)
5161{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305162 hdd_adapter_t *pAdapter;
5163 hdd_context_t *pHddCtx;
5164 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5166 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305167 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005168
5169 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305170 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5171 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005172 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5174 "%s:Adapter is NULL",__func__);
5175 return -EINVAL;
5176 }
5177 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5178 ret = wlan_hdd_validate_context(pHddCtx);
5179 if (0 != ret)
5180 {
5181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5182 "%s HDD context is not valid",__func__);
5183 return ret;
5184 }
5185 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5186 if (NULL == pHddStaCtx)
5187 {
5188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5189 "%s:STA context is NULL",__func__);
5190 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 }
5192
5193 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5194 switch (mlme->cmd) {
5195 case IW_MLME_DISASSOC:
5196 case IW_MLME_DEAUTH:
5197
5198 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5199 {
5200 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5201
5202 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5203 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5204
5205 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5206 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5207
Jeff Johnson43971f52012-07-17 12:26:56 -07005208 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305209 {
5210 long ret;
5211 ret = wait_for_completion_interruptible_timeout(
5212 &pAdapter->disconnect_comp_var,
5213 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5214 if (ret <= 0)
5215 hddLog(VOS_TRACE_LEVEL_ERROR,
5216 FL("failed wait on disconnect_comp_var %ld"), ret);
5217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005219 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005220 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005221
5222 /* Resetting authKeyMgmt */
5223 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5224
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305225 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 netif_tx_disable(dev);
5227 netif_carrier_off(dev);
5228
5229 }
5230 else
5231 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005232 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 -07005233 }
5234 break;
5235 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005236 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 return -EINVAL;
5238 }//end of switch
5239
5240 EXIT();
5241
5242 return status;
5243
5244}
5245
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305246static int iw_set_mlme(struct net_device *dev,
5247 struct iw_request_info *info,
5248 union iwreq_data *wrqu,
5249 char *extra)
5250{
5251 int ret;
5252
5253 vos_ssr_protect(__func__);
5254 ret = __iw_set_mlme(dev, info, wrqu, extra);
5255 vos_ssr_unprotect(__func__);
5256
5257 return ret;
5258}
5259
Jeff Johnson295189b2012-06-20 16:38:30 -07005260/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305261static int __iw_setint_getnone(struct net_device *dev,
5262 struct iw_request_info *info,
5263 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005264{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305265 hdd_adapter_t *pAdapter;
5266 tHalHandle hHal;
5267 hdd_wext_state_t *pWextState;
5268 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 int *value = (int *)extra;
5270 int sub_cmd = value[0];
5271 int set_value = value[1];
5272 int ret = 0; /* success */
5273 int enable_pbm, enable_mp;
5274#ifdef CONFIG_HAS_EARLYSUSPEND
5275 v_U8_t nEnableSuspendOld;
5276#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005277
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305278 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5279 if (NULL == pAdapter)
5280 {
5281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5282 "%s: Adapter is NULL",__func__);
5283 return -EINVAL;
5284 }
5285 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5286 ret = wlan_hdd_validate_context(pHddCtx);
5287 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005288 {
c_hpothu4a298be2014-12-22 21:12:51 +05305289 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305290 return ret;
5291 }
5292 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5293 if (NULL == hHal)
5294 {
5295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5296 "%s: Hal Context is NULL",__func__);
5297 return -EINVAL;
5298 }
5299 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5300 if (NULL == pWextState)
5301 {
5302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5303 "%s: pWextState is NULL",__func__);
5304 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005305 }
5306
c_hpothu4a298be2014-12-22 21:12:51 +05305307 INIT_COMPLETION(pWextState->completion_var);
5308
Jeff Johnson295189b2012-06-20 16:38:30 -07005309 switch(sub_cmd)
5310 {
5311 case WE_SET_11D_STATE:
5312 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005313 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005314 memset(&smeConfig, 0x00, sizeof(smeConfig));
5315
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5317
5318 sme_GetConfigParam(hHal,&smeConfig);
5319 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5320
Arif Hussain6d2a3322013-11-17 19:50:10 -08005321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005322
5323 sme_UpdateConfig(hHal,&smeConfig);
5324 }
5325 else {
5326 return -EINVAL;
5327 }
5328 break;
5329 }
5330
5331 case WE_WOWL:
5332 {
5333 switch (set_value)
5334 {
5335 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305336 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 break;
5338 case 0x01:
5339 case 0x02:
5340 case 0x03:
5341 enable_mp = (set_value & 0x01) ? 1 : 0;
5342 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005343 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5345 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5346 break;
5347 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005348 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 ret = -EINVAL;
5350 break;
5351 }
5352
5353 break;
5354 }
5355 case WE_SET_POWER:
5356 {
5357 switch (set_value)
5358 {
5359 case 0: //Full Power
5360 {
5361 struct statsContext context;
5362 eHalStatus status;
5363
5364 init_completion(&context.completion);
5365
5366 context.pAdapter = pAdapter;
5367 context.magic = POWER_CONTEXT_MAGIC;
5368
5369 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5370 iw_power_callback_fn, &context,
5371 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005372 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 {
5374 int lrc = wait_for_completion_interruptible_timeout(
5375 &context.completion,
5376 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005377
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 if (lrc <= 0)
5379 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005380 hddLog(VOS_TRACE_LEVEL_ERROR,
5381 "%s: SME %s while requesting fullpower",
5382 __func__, (0 == lrc) ?
5383 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 }
5385 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005386 /* either we have a response or we timed out. if we timed
5387 out there is a race condition such that the callback
5388 function could be executing at the same time we are. of
5389 primary concern is if the callback function had already
5390 verified the "magic" but had not yet set the completion
5391 variable when a timeout occurred. we serialize these
5392 activities by invalidating the magic while holding a
5393 shared spinlock which will cause us to block if the
5394 callback is currently executing */
5395 spin_lock(&hdd_context_lock);
5396 context.magic = 0;
5397 spin_unlock(&hdd_context_lock);
5398
Arif Hussain6d2a3322013-11-17 19:50:10 -08005399 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 break;
5401 }
5402 case 1: //Enable BMPS
5403 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5404 break;
5405 case 2: //Disable BMPS
5406 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5407 break;
5408 case 3: //Request Bmps
5409 {
5410 struct statsContext context;
5411 eHalStatus status;
5412
5413 init_completion(&context.completion);
5414
5415 context.pAdapter = pAdapter;
5416 context.magic = POWER_CONTEXT_MAGIC;
5417
5418 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5419 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005420 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 {
5422 int lrc = wait_for_completion_interruptible_timeout(
5423 &context.completion,
5424 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 if (lrc <= 0)
5426 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005427 hddLog(VOS_TRACE_LEVEL_ERROR,
5428 "%s: SME %s while requesting BMPS",
5429 __func__, (0 == lrc) ? "timeout" :
5430 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 }
5432 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005433 /* either we have a response or we timed out. if we
5434 timed out there is a race condition such that the
5435 callback function could be executing at the same
5436 time we are. of primary concern is if the callback
5437 function had already verified the "magic" but had
5438 not yet set the completion variable when a timeout
5439 occurred. we serialize these activities by
5440 invalidating the magic while holding a shared
5441 spinlock which will cause us to block if the
5442 callback is currently executing */
5443 spin_lock(&hdd_context_lock);
5444 context.magic = 0;
5445 spin_unlock(&hdd_context_lock);
5446
Arif Hussain6d2a3322013-11-17 19:50:10 -08005447 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 break;
5449 }
5450 case 4: //Enable IMPS
5451 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5452 break;
5453 case 5: //Disable IMPS
5454 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5455 break;
5456 case 6: //Enable Standby
5457 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5458 break;
5459 case 7: //Disable Standby
5460 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5461 break;
5462 case 8: //Request Standby
5463#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005464#endif
5465 break;
5466 case 9: //Start Auto Bmps Timer
5467 sme_StartAutoBmpsTimer(hHal);
5468 break;
5469 case 10://Stop Auto BMPS Timer
5470 sme_StopAutoBmpsTimer(hHal);
5471 break;
5472#ifdef CONFIG_HAS_EARLYSUSPEND
5473 case 11://suspend to standby
5474#ifdef CONFIG_HAS_EARLYSUSPEND
5475 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5476 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5478#endif
5479 break;
5480 case 12://suspend to deep sleep
5481#ifdef CONFIG_HAS_EARLYSUSPEND
5482 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5483 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5485#endif
5486 break;
5487 case 13://resume from suspend
5488#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005489#endif
5490 break;
5491#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005493 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 ret = -EINVAL;
5495 break;
5496 }
5497 break;
5498 }
5499
5500 case WE_SET_MAX_ASSOC:
5501 {
5502 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5503 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5504 {
5505 ret = -EINVAL;
5506 }
5507 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5508 set_value, NULL, eANI_BOOLEAN_FALSE)
5509 != eHAL_STATUS_SUCCESS )
5510 {
c_hpothub8245442013-11-20 23:41:09 +05305511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5512 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 ret = -EIO;
5514 }
5515 break;
5516 }
5517
5518 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5519 {
5520 if( 0 == set_value )
5521 {
5522 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5523 }
5524 else if ( 1 == set_value )
5525 {
5526 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5527 }
5528 else
5529 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005530 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 ret = -EINVAL;
5532 }
5533 break;
5534 }
5535
5536 case WE_SET_DATA_INACTIVITY_TO:
5537 {
5538 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5539 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5540 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5541 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5542 set_value,
5543 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5544 {
5545 hddLog(LOGE,"Failure: Could not pass on "
5546 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005547 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 ret = -EINVAL;
5549 }
5550 break;
5551 }
5552 case WE_SET_MAX_TX_POWER:
5553 {
5554 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5555 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5556
5557 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5558 __func__, set_value);
5559 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5560 eHAL_STATUS_SUCCESS )
5561 {
5562 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5563 __func__);
5564 return -EIO;
5565 }
5566
5567 break;
5568 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005569 case WE_SET_MAX_TX_POWER_2_4:
5570 {
5571 hddLog(VOS_TRACE_LEVEL_INFO,
5572 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5573 __func__, set_value);
5574 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5575 eHAL_STATUS_SUCCESS)
5576 {
5577 hddLog(VOS_TRACE_LEVEL_ERROR,
5578 "%s: Setting maximum tx power failed for 2.4 GHz band",
5579 __func__);
5580 return -EIO;
5581 }
5582
5583 break;
5584 }
5585 case WE_SET_MAX_TX_POWER_5_0:
5586 {
5587 hddLog(VOS_TRACE_LEVEL_INFO,
5588 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5589 __func__, set_value);
5590 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5591 eHAL_STATUS_SUCCESS)
5592 {
5593 hddLog(VOS_TRACE_LEVEL_ERROR,
5594 "%s: Setting maximum tx power failed for 5.0 GHz band",
5595 __func__);
5596 return -EIO;
5597 }
5598
5599 break;
5600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 case WE_SET_HIGHER_DTIM_TRANSITION:
5602 {
5603 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5604 (set_value == eANI_BOOLEAN_TRUE)))
5605 {
5606 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5607 ret = -EINVAL;
5608 }
5609 else
5610 {
5611 if(pAdapter->higherDtimTransition != set_value)
5612 {
5613 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005614 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 }
5616 }
5617
5618 break;
5619 }
5620
5621 case WE_SET_TM_LEVEL:
5622 {
5623 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005624 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5626
5627 break;
5628 }
5629
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305630 case WE_ENABLE_STRICT_FCC_REG:
5631 {
5632 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5633 struct wiphy *wiphy = NULL;
5634 long lrc;
5635 int status;
5636
5637 wiphy = hddCtxt->wiphy;
5638 if(wiphy == NULL)
5639 {
5640 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5641 break;
5642 }
5643 init_completion(&hddCtxt->wiphy_channel_update_event);
5644
5645 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5646
5647 status = regulatory_hint(wiphy, "00");
5648 if(status < 0)
5649 {
5650 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5651 break;
5652 }
5653
5654 /* Wait for completion */
5655 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5656 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5657 if (lrc <= 0)
5658 {
5659 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5660 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5661 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5662 }
5663 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5664
5665 break;
5666 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005667 case WE_SET_DEBUG_LOG:
5668 {
5669 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5670 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5671 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5672 break;
5673 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305674#ifdef FEATURE_WLAN_TDLS
5675 case WE_SET_TDLS_OFF_CHAN:
5676 {
5677 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5679 __func__, set_value);
5680 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5681 break;
5682 }
5683 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5684 {
5685 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5687 __func__, set_value);
5688 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5689 break;
5690 }
5691 case WE_SET_TDLS_OFF_CHAN_MODE:
5692 {
5693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5694 __func__, set_value);
5695 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5696 break;
5697 }
5698#endif
Peng Xu2446a892014-09-05 17:21:18 +05305699 case WE_SET_SCAN_BAND_PREFERENCE:
5700 {
5701 tSmeConfigParams smeConfig;
5702 memset(&smeConfig, 0x00, sizeof(smeConfig));
5703 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5704 ret = -EINVAL;
5705 break;
5706 }
5707 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5708
5709 if (eCSR_BAND_ALL == set_value ||
5710 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5711 sme_GetConfigParam(hHal, &smeConfig);
5712 smeConfig.csrConfig.scanBandPreference = set_value;
5713
5714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5715 "set band scan preference = %d\n",
5716 smeConfig.csrConfig.scanBandPreference);
5717
5718 sme_UpdateConfig(hHal, &smeConfig);
5719 }
5720 else {
5721 ret = -EINVAL;
5722 }
5723 break;
5724 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305725
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 default:
5727 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005728 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005729 sub_cmd, set_value);
5730 break;
5731 }
5732 }
5733
5734 return ret;
5735}
5736
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305737static int iw_setint_getnone(struct net_device *dev,
5738 struct iw_request_info *info,
5739 union iwreq_data *wrqu, char *extra)
5740{
5741 int ret;
5742
5743 vos_ssr_protect(__func__);
5744 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5745 vos_ssr_unprotect(__func__);
5746
5747 return 0;
5748}
Jeff Johnson295189b2012-06-20 16:38:30 -07005749/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305750static int __iw_setchar_getnone(struct net_device *dev,
5751 struct iw_request_info *info,
5752 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005753{
5754 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305755 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005757 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305758 hdd_adapter_t *pAdapter;
5759 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005760#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305761 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005762#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305763 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305764 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005765
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305766 pAdapter = (netdev_priv(dev));
5767 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005768 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5770 "%s: Adapter is NULL",__func__);
5771 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005772 }
5773
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305774 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5775 ret = wlan_hdd_validate_context(pHddCtx);
5776 if (0 != ret)
5777 {
5778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5779 "%s: HDD context is not valid",__func__);
5780 return ret;
5781 }
5782#ifdef WLAN_FEATURE_VOWIFI
5783 pConfig = pHddCtx->cfg_ini;
5784#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305785 /* helper function to get iwreq_data with compat handling. */
5786 if (hdd_priv_get_data(&s_priv_data, wrqu))
5787 {
5788 return -EINVAL;
5789 }
5790
5791 /* make sure all params are correctly passed to function */
5792 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5793 {
5794 return -EINVAL;
5795 }
5796
5797 sub_cmd = s_priv_data.flags;
5798
Arif Hussain0273cba2014-01-07 20:58:29 -08005799 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305800 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5801 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005802 if (NULL == pBuffer)
5803 {
5804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5805 "mem_alloc_copy_from_user_helper fail");
5806 return -ENOMEM;
5807 }
5808
5809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305810 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5812 "%s: Received data %s", __func__, pBuffer);
5813
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 switch(sub_cmd)
5815 {
5816 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005818 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 break;
5820 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005822 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 break;
5824#if defined WLAN_FEATURE_VOWIFI
5825 case WE_NEIGHBOR_REPORT_REQUEST:
5826 {
5827 tRrmNeighborReq neighborReq;
5828 tRrmNeighborRspCallbackInfo callbackInfo;
5829
5830 if (pConfig->fRrmEnable)
5831 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305833 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 if( !neighborReq.no_ssid )
5835 {
Girish Gowli552fc072014-06-14 18:26:16 +05305836 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005837 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 }
5839
5840 callbackInfo.neighborRspCallback = NULL;
5841 callbackInfo.neighborRspCallbackContext = NULL;
5842 callbackInfo.timeout = 5000; //5 seconds
5843 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5844 }
5845 else
5846 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005847 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 ret = -EINVAL;
5849 }
5850 }
5851 break;
5852#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 case WE_SET_AP_WPS_IE:
5854 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05305855 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08005858 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 if (VOS_STATUS_SUCCESS != vstatus)
5860 {
5861 ret = -EINVAL;
5862 }
5863 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305864 case WE_SET_ENCRYPT_MSG:
5865 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
5866 if (NULL == pkt)
5867 {
5868 hddLog(VOS_TRACE_LEVEL_ERROR,
5869 "%s: vos_mem_alloc failed", __func__);
5870 return -ENOMEM;
5871 }
5872
5873 memset(pkt, 0, sizeof(tSirpkt80211));
5874
5875 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
5876 hddLog(VOS_TRACE_LEVEL_ERROR,
5877 FL("Firmware is not DISA capable"));
5878 ret = -EINVAL;
5879 vos_mem_free(pkt);
5880 break;
5881 }
5882
5883 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
5884
5885 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
5886 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
5887 if (eHAL_STATUS_SUCCESS != ret) {
5888 hddLog(VOS_TRACE_LEVEL_ERROR,
5889 FL("SENDEncryptMSG: fail to post WDA cmd"));
5890 ret = -EINVAL;
5891 }
5892 vos_mem_free(pkt);
5893
5894 break;
5895
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 default:
5897 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005898 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 ret = -EINVAL;
5900 break;
5901 }
5902 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005903 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005904 return ret;
5905}
5906
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305907static int iw_setchar_getnone(struct net_device *dev,
5908 struct iw_request_info *info,
5909 union iwreq_data *wrqu, char *extra)
5910{
5911 int ret;
5912
5913 vos_ssr_protect(__func__);
5914 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
5915 vos_ssr_unprotect(__func__);
5916
5917 return ret;
5918}
5919
Jeff Johnson295189b2012-06-20 16:38:30 -07005920/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305921static int __iw_setnone_getint(struct net_device *dev,
5922 struct iw_request_info *info,
5923 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005924{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305925 hdd_adapter_t *pAdapter;
5926 tHalHandle hHal;
5927 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 int *value = (int *)extra;
5929 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05305930 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005931
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305932 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5933 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005934 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5936 "%s: Adapter is NULL",__func__);
5937 return -EINVAL;
5938 }
5939 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5940 ret = wlan_hdd_validate_context(pHddCtx);
5941 if (0 != ret)
5942 {
5943 if (__ratelimit(&hdd_ioctl_timeout_rs))
5944 {
c_hpothuda3af912014-11-06 16:52:03 +05305945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305946 "%s:Hdd context is not valid", __func__);
c_hpothuda3af912014-11-06 16:52:03 +05305947 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305948 return ret;
5949 }
5950 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5951 if (NULL == hHal)
5952 {
5953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5954 "%s: Hal Context is NULL",__func__);
5955 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005957
5958 switch (value[0])
5959 {
5960 case WE_GET_11D_STATE:
5961 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005962 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305964
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 *value = smeConfig.csrConfig.Is11dSupportEnabled;
5966
Arif Hussain6d2a3322013-11-17 19:50:10 -08005967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005968
5969 break;
5970 }
5971
5972 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 break;
5975
5976 case WE_PMC_STATE:
5977 {
5978 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 break;
5981 }
5982 case WE_GET_WLAN_DBG:
5983 {
5984 vos_trace_display();
5985 *value = 0;
5986 break;
5987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 case WE_GET_MAX_ASSOC:
5989 {
5990 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
5991 {
c_hpothub8245442013-11-20 23:41:09 +05305992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5993 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 ret = -EIO;
5995 }
Girish Gowli385be612014-09-18 11:17:20 +05305996#ifdef WLAN_SOFTAP_VSTA_FEATURE
5997 if (pHddCtx->cfg_ini->fEnableVSTASupport)
5998 {
5999 if (*value > VSTA_NUM_ASSOC_STA)
6000 {
6001 *value = VSTA_NUM_ASSOC_STA;
6002 }
6003 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6004 (*value > (VSTA_NUM_ASSOC_STA -
6005 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6006 {
6007 *value = (VSTA_NUM_ASSOC_STA -
6008 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6009 }
6010 }
6011 else
6012#endif
6013 {
6014 if (*value > NUM_ASSOC_STA)
6015 {
6016 *value = NUM_ASSOC_STA;
6017 }
6018 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6019 (*value > (NUM_ASSOC_STA -
6020 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6021 {
6022 *value = (NUM_ASSOC_STA -
6023 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6024 }
6025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 break;
6027 }
6028
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 case WE_GET_WDI_DBG:
6030 {
6031 wpalTraceDisplay();
6032 *value = 0;
6033 break;
6034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006035
6036 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6037 {
6038 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6039 break;
6040 }
6041 case WE_GET_CONCURRENCY_MODE:
6042 {
6043 *value = hdd_get_concurrency_mode ( );
6044
Arif Hussain6d2a3322013-11-17 19:50:10 -08006045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 break;
6047 }
6048
Peng Xu2446a892014-09-05 17:21:18 +05306049 case WE_GET_SCAN_BAND_PREFERENCE:
6050 {
6051 sme_GetConfigParam(hHal, &smeConfig);
6052 *value = smeConfig.csrConfig.scanBandPreference;
6053
6054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6055 "scanBandPreference = %d\n", *value);
6056 break;
6057 }
6058
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 default:
6060 {
6061 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6062 break;
6063 }
6064 }
6065
6066 return ret;
6067}
6068
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306069static int iw_setnone_getint(struct net_device *dev,
6070 struct iw_request_info *info,
6071 union iwreq_data *wrqu, char *extra)
6072{
6073 int ret;
6074
6075 vos_ssr_protect(__func__);
6076 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6077 vos_ssr_unprotect(__func__);
6078
6079 return ret;
6080
6081}
Jeff Johnson295189b2012-06-20 16:38:30 -07006082/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306083int __iw_set_three_ints_getnone(struct net_device *dev,
6084 struct iw_request_info *info,
6085 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006086{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306087 hdd_adapter_t *pAdapter;
6088 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 int *value = (int *)extra;
6090 int sub_cmd = value[0];
6091 int ret = 0;
6092
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306093 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6094 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006095 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6097 "%s: Adapter is NULL",__func__);
6098 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006099 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306100 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6101 ret = wlan_hdd_validate_context(pHddCtx);
6102 if (0 != ret)
6103 {
6104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6105 "%s: HDD context is not valid",__func__);
6106 return ret;
6107 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 switch(sub_cmd)
6109 {
6110 case WE_SET_WLAN_DBG:
6111 {
6112 vos_trace_setValue( value[1], value[2], value[3]);
6113 break;
6114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 case WE_SET_WDI_DBG:
6116 {
6117 wpalTraceSetLevel( value[1], value[2], value[3]);
6118 break;
6119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 case WE_SET_SAP_CHANNELS:
6121 {
6122 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6123 break;
6124 }
6125
6126 default:
6127 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006128 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 break;
6130 }
6131 }
6132 return ret;
6133}
6134
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306135int iw_set_three_ints_getnone(struct net_device *dev,
6136 struct iw_request_info *info,
6137 union iwreq_data *wrqu, char *extra)
6138{
6139 int ret;
6140
6141 vos_ssr_protect(__func__);
6142 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6143 vos_ssr_unprotect(__func__);
6144
6145 return ret;
6146}
6147
6148static int __iw_get_char_setnone(struct net_device *dev,
6149 struct iw_request_info *info,
6150 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006151{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306152 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306154 hdd_context_t *pHddCtx;
6155 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006156#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006157 hdd_wext_state_t *pWextState;
6158#endif
6159
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306160 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006161 if (pAdapter == NULL)
6162 {
6163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6164 "%s: pAdapter is NULL!", __func__);
6165 return -EINVAL;
6166 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306167 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6168 ret = wlan_hdd_validate_context(pHddCtx);
6169 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006170 {
6171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306172 "%s: HDD context is not valid",__func__);
6173 return ret;
6174 }
6175#ifdef WLAN_FEATURE_11W
6176 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6177 if (NULL == pWextState)
6178 {
6179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6180 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006181 return -EINVAL;
6182 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306183#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006184
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 switch(sub_cmd)
6186 {
6187 case WE_WLAN_VERSION:
6188 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006189 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 break;
6191 }
6192
6193 case WE_GET_STATS:
6194 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306195 tHalHandle hHal = NULL;
6196 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6198 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6199 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6200
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306201
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 snprintf(extra, WE_MAX_STR_LEN,
6203 "\nTransmit"
6204 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6205 "\n dropped BK %u, BE %u, VI %u, VO %u"
6206 "\n classified BK %u, BE %u, VI %u, VO %u"
6207 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6208 "\n queued BK %u, BE %u, VI %u, VO %u"
6209 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006210 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 "\n fetched BK %u, BE %u, VI %u, VO %u"
6212 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6213 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006214 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 "\n flushed BK %u, BE %u, VI %u, VO %u"
6216 "\n\nReceive"
6217 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6218 "\n\nResetsStats"
6219 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6220 "\n",
6221 pStats->txXmitCalled,
6222 pStats->txXmitDropped,
6223 pStats->txXmitBackPressured,
6224 pStats->txXmitQueued,
6225
6226 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6227 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6228 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6229 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6230
6231 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6232 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6233 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6234 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6235
6236 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6237 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6238 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6239 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6240
6241 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6242 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6243 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6244 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6245
6246 pStats->txFetched,
6247 pStats->txFetchEmpty,
6248 pStats->txFetchLowResources,
6249 pStats->txFetchDequeueError,
6250
6251 pStats->txFetchDequeued,
6252 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006253 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 pStats->txCompleted,
6255 pStats->txFlushed,
6256
6257 pStats->txFetchedAC[WLANTL_AC_BK],
6258 pStats->txFetchedAC[WLANTL_AC_BE],
6259 pStats->txFetchedAC[WLANTL_AC_VI],
6260 pStats->txFetchedAC[WLANTL_AC_VO],
6261
6262 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6263 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6264 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6265 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6266
6267 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6268 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6269 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6270 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6271
Ravi Joshi41914632013-10-21 23:02:21 -07006272 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6273 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6274 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6275 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6276
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 pStats->txFlushedAC[WLANTL_AC_BK],
6278 pStats->txFlushedAC[WLANTL_AC_BE],
6279 pStats->txFlushedAC[WLANTL_AC_VI],
6280 pStats->txFlushedAC[WLANTL_AC_VO],
6281
6282 pStats->rxChains,
6283 pStats->rxPackets,
6284 pStats->rxDropped,
6285 pStats->rxDelivered,
6286 pStats->rxRefused,
6287
6288 pResetStats->totalLogpResets,
6289 pResetStats->totalCMD53Failures,
6290 pResetStats->totalMutexReadFailures,
6291 pResetStats->totalMIFErrorFailures,
6292 pResetStats->totalFWHearbeatFailures,
6293 pResetStats->totalUnknownExceptions
6294 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306295 wrqu->data.length = strlen(extra);
6296
6297 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6298
6299 if (hHal)
6300 pMac = PMAC_STRUCT( hHal );
6301
6302 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6303 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6304 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306305 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6306 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6307 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6308 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306309 "\n",
6310 pMac->pmm.BmpscntSleep,
6311 pMac->pmm.BmpscntAwake,
6312 pMac->pmm.BmpsSleeReqFailCnt,
6313 pMac->pmm.BmpsWakeupReqFailCnt,
6314 pMac->pmm.ImpsCntSleep,
6315 pMac->pmm.ImpsCntAwake,
6316 pMac->pmm.ImpsSleepErrCnt,
6317 pMac->pmm.ImpsWakeupErrCnt,
6318 pMac->pmm.ImpsLastErr
6319 );
6320 }
6321
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 wrqu->data.length = strlen(extra)+1;
6323 break;
6324 }
6325
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306326/* The case prints the current state of the HDD, SME, CSR, PE, TL
6327 *it can be extended for WDI Global State as well.
6328 *And currently it only checks P2P_CLIENT adapter.
6329 *P2P_DEVICE and P2P_GO have not been added as of now.
6330*/
6331 case WE_GET_STATES:
6332 {
6333 int buf = 0, len = 0;
6334 int adapter_num = 0;
6335 int count = 0, check = 1;
6336
6337 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006338 tHalHandle hHal = NULL;
6339 tpAniSirGlobal pMac = NULL;
6340 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306341
6342 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6343 hdd_adapter_t *useAdapter = NULL;
6344
6345 /* Print wlan0 or p2p0 states based on the adapter_num
6346 *by using the correct adapter
6347 */
6348 while ( adapter_num < 2 )
6349 {
6350 if ( WLAN_ADAPTER == adapter_num )
6351 {
6352 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006353 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306354 "\n\n wlan0 States:-");
6355 len += buf;
6356 }
6357 else if ( P2P_ADAPTER == adapter_num )
6358 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006359 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306360 "\n\n p2p0 States:-");
6361 len += buf;
6362
6363 if( !pHddCtx )
6364 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006365 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306366 "\n pHddCtx is NULL");
6367 len += buf;
6368 break;
6369 }
6370
6371 /*Printing p2p0 states only in the case when the device is
6372 configured as a p2p_client*/
6373 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6374 if ( !useAdapter )
6375 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006376 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306377 "\n Device not configured as P2P_CLIENT.");
6378 len += buf;
6379 break;
6380 }
6381 }
6382
6383 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006384 if (!hHal) {
6385 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6386 "\n pMac is NULL");
6387 len += buf;
6388 break;
6389 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306390 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006391 if (!pMac) {
6392 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6393 "\n pMac is NULL");
6394 len += buf;
6395 break;
6396 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306397 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6398 if( !pHddStaCtx )
6399 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006400 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306401 "\n pHddStaCtx is NULL");
6402 len += buf;
6403 break;
6404 }
6405
6406 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6407
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006408 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306409 "\n HDD Conn State - %s "
6410 "\n \n SME State:"
6411 "\n Neighbour Roam State - %s"
6412 "\n CSR State - %s"
6413 "\n CSR Substate - %s"
6414 "\n \n TL STA %d State: %s",
6415 macTraceGetHDDWlanConnState(
6416 pHddStaCtx->conn_info.connState),
6417 macTraceGetNeighbourRoamState(
6418 pMac->roam.neighborRoamInfo.neighborRoamState),
6419 macTraceGetcsrRoamState(
6420 pMac->roam.curState[useAdapter->sessionId]),
6421 macTraceGetcsrRoamSubState(
6422 pMac->roam.curSubState[useAdapter->sessionId]),
6423 pHddStaCtx->conn_info.staId[0],
6424 macTraceGetTLState(tlState)
6425 );
6426 len += buf;
6427 adapter_num++;
6428 }
6429
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006430 if (pMac) {
6431 /* Printing Lim State starting with global lim states */
6432 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6433 "\n \n LIM STATES:-"
6434 "\n Global Sme State - %s "\
6435 "\n Global mlm State - %s "\
6436 "\n",
6437 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6438 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6439 );
6440 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306441
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006442 /*printing the PE Sme and Mlm states for valid lim sessions*/
6443 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306444 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006445 if ( pMac->lim.gpSession[count].valid )
6446 {
6447 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6448 "\n Lim Valid Session %d:-"
6449 "\n PE Sme State - %s "
6450 "\n PE Mlm State - %s "
6451 "\n",
6452 check,
6453 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6454 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6455 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306456
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006457 len += buf;
6458 check++;
6459 }
6460 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306461 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306462 }
6463
6464 wrqu->data.length = strlen(extra)+1;
6465 break;
6466 }
6467
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 case WE_GET_CFG:
6469 {
6470 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6471 wrqu->data.length = strlen(extra)+1;
6472 break;
6473 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006474#ifdef WLAN_FEATURE_11AC
6475 case WE_GET_RSSI:
6476 {
6477 v_S7_t s7Rssi = 0;
6478 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6479 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6480 wrqu->data.length = strlen(extra)+1;
6481 break;
6482 }
6483#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306484
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006485#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006486 case WE_GET_ROAM_RSSI:
6487 {
6488 v_S7_t s7Rssi = 0;
6489 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6490 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6491 wrqu->data.length = strlen(extra)+1;
6492 break;
6493 }
6494#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 case WE_GET_WMM_STATUS:
6496 {
6497 snprintf(extra, WE_MAX_STR_LEN,
6498 "\nDir: 0=up, 1=down, 3=both\n"
6499 "|------------------------|\n"
6500 "|AC | ACM |Admitted| Dir |\n"
6501 "|------------------------|\n"
6502 "|VO | %d | %3s | %d |\n"
6503 "|VI | %d | %3s | %d |\n"
6504 "|BE | %d | %3s | %d |\n"
6505 "|BK | %d | %3s | %d |\n"
6506 "|------------------------|\n",
6507 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6508 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6509 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6510 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6511 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6512 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6513 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6514 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6515 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6516 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6517 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6518 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6519
Jeff Johnsone7245742012-09-05 17:12:55 -07006520
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 wrqu->data.length = strlen(extra)+1;
6522 break;
6523 }
6524 case WE_GET_CHANNEL_LIST:
6525 {
6526 VOS_STATUS status;
6527 v_U8_t i, len;
6528 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306529 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6530 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6531 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 tChannelListInfo channel_list;
6533
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006534 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006536 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006537 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006538 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 return -EINVAL;
6540 }
6541 buf = extra;
6542
6543 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006544 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6545 * needed = 5 * number of channels. Check ifsufficient
6546 * buffer is available and then proceed to fill the buffer.
6547 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6549 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006550 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006551 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006552 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006553 return -EINVAL;
6554 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006555 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6556 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306557 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6558 {
6559 //Printing Country code in getChannelList
6560 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6561 {
6562 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6563 "%c ", pBuf[i]);
6564 }
6565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006566 for(i = 0 ; i < channel_list.num_channels; i++)
6567 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006568 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006569 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 }
6571 wrqu->data.length = strlen(extra)+1;
6572
6573 break;
6574 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006575#ifdef FEATURE_WLAN_TDLS
6576 case WE_GET_TDLS_PEERS:
6577 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006578 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006579 break;
6580 }
6581#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006582#ifdef WLAN_FEATURE_11W
6583 case WE_GET_11W_INFO:
6584 {
6585 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6586
6587 snprintf(extra, WE_MAX_STR_LEN,
6588 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6589 "\n Number of Unprotected Disassocs %d"
6590 "\n Number of Unprotected Deauths %d",
6591 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6592 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6593 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6594 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6595 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6596
6597 wrqu->data.length = strlen(extra)+1;
6598 break;
6599 }
6600#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306601 case WE_GET_SNR:
6602 {
6603 v_S7_t s7snr = 0;
6604 int status = 0;
6605 hdd_context_t *pHddCtx;
6606 hdd_station_ctx_t *pHddStaCtx;
6607
6608 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6609 status = wlan_hdd_validate_context(pHddCtx);
6610 if (0 != status)
6611 {
6612 hddLog(LOGE, "%s: getSNR: HDD context is not valid", __func__);
6613 return status;
6614 }
6615
6616 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6617
6618 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6619 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6620 {
6621 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6622 " ConnectionState-%d", __func__,
6623 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6624 pHddStaCtx->conn_info.connState);
6625 return -ENONET;
6626 }
6627
6628 /*update the stats in TL*/
6629 wlan_hdd_get_station_stats(pAdapter);
6630 wlan_hdd_get_snr(pAdapter, &s7snr);
6631 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6632 wrqu->data.length = strlen(extra) + 1;
6633 break;
6634 }
6635
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306636 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006638 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 break;
6640 }
6641 }
6642
6643 return 0;
6644}
6645
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306646static int iw_get_char_setnone(struct net_device *dev,
6647 struct iw_request_info *info,
6648 union iwreq_data *wrqu, char *extra)
6649{
6650 int ret;
6651
6652 vos_ssr_protect(__func__);
6653 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6654 vos_ssr_unprotect(__func__);
6655
6656 return ret;
6657}
6658
Jeff Johnson295189b2012-06-20 16:38:30 -07006659/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306660static int __iw_setnone_getnone(struct net_device *dev,
6661 struct iw_request_info *info,
6662 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006663{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306664 hdd_adapter_t *pAdapter;
6665 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306666 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006667 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306668 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006669
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306670 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6671 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006672 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6674 "%s: Adapter is NULL",__func__);
6675 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006676 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306677 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6678 ret = wlan_hdd_validate_context(pHddCtx);
6679 if (0 != ret)
6680 {
6681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6682 "%s: HDD context is not valid",__func__);
6683 return ret;
6684 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306685 /* helper function to get iwreq_data with compat handling. */
6686 if (hdd_priv_get_data(&s_priv_data, wrqu))
6687 {
6688 return -EINVAL;
6689 }
6690
6691 sub_cmd = s_priv_data.flags;
6692
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 switch (sub_cmd)
6694 {
6695 case WE_CLEAR_STATS:
6696 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006698 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6699 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6700 break;
6701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 case WE_INIT_AP:
6703 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306704 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6705
6706 /* As Soft AP mode might been changed to STA already with
6707 * killing of Hostapd, need to find the adpater by name
6708 * rather than mode */
6709 hdd_adapter_t* pAdapter_to_stop =
6710 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6711 if( pAdapter_to_stop )
6712 {
6713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6714 "Adapter with name softap.0 already "
6715 "exist, ignoring the request.\nRemove the "
6716 "adapter and try again\n");
6717 break;
6718 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 pr_info("Init AP trigger\n");
6720 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6721 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6722 break;
6723 }
6724 case WE_STOP_AP:
6725 {
6726 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6727 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6728 * this is a dead code and need to find the adpater by name rather than mode */
6729 hdd_adapter_t* pAdapter_to_stop =
6730 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6731 if( pAdapter_to_stop )
6732 {
6733 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6734
6735 pr_info("Stopping AP mode\n");
6736
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306737 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6738 {
6739 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6740 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6741 }
6742
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306744 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306745 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6747
6748 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6749 pAdapter_to_stop->macAddressCurrent.bytes);
6750 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6751 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306752
6753 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6754 {
6755 /* put the device back into BMPS */
6756 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 }
6759 else
6760 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006761 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006762 }
6763
6764 break;
6765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006766#ifdef WLAN_BTAMP_FEATURE
6767 case WE_ENABLE_AMP:
6768 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 WLANBAP_RegisterWithHCI(pAdapter);
6771 break;
6772 }
6773 case WE_DISABLE_AMP:
6774 {
6775 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6776 VOS_STATUS status;
6777
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006779
6780 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6781 status = WLANBAP_StopAmp();
6782 if(VOS_STATUS_SUCCESS != status )
6783 {
6784 pHddCtx->isAmpAllowed = VOS_TRUE;
6785 hddLog(VOS_TRACE_LEVEL_FATAL,
6786 "%s: Failed to stop AMP", __func__);
6787 }
6788 else
6789 {
6790 //a state m/c implementation in PAL is TBD to avoid this delay
6791 msleep(500);
6792 pHddCtx->isAmpAllowed = VOS_FALSE;
6793 WLANBAP_DeregisterFromHCI();
6794 }
6795
6796 break;
6797 }
6798#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006799 case WE_ENABLE_DXE_STALL_DETECT:
6800 {
schang6295e542013-03-12 15:31:23 -07006801 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6802 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006803 break;
6804 }
6805 case WE_DISPLAY_DXE_SNAP_SHOT:
6806 {
schang6295e542013-03-12 15:31:23 -07006807 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6808 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006809 break;
6810 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306811 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6812 {
6813 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6814 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306815 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306816 break;
6817 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306818
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306819 case WE_SET_REASSOC_TRIGGER:
6820 {
6821 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6822 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6823 v_U32_t roamId = 0;
6824 tCsrRoamModifyProfileFields modProfileFields;
6825 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6826 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6827 return 0;
6828 }
6829
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306830 case WE_STOP_OBSS_SCAN:
6831 {
6832 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6833 2.OBSS scan is stopped by Firmware during the disassociation
6834 3.OBSS stop comamnd is added for debugging purpose*/
6835 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6836 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006837
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306838 if (pAdapter == NULL)
6839 {
6840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6841 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306842 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306843 }
6844 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6845 if (pMac == NULL)
6846 {
6847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6848 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306849 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306850 }
6851 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6852 }
6853 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306854 case WE_DUMP_ROAM_TIMER_LOG:
6855 {
6856 vos_dump_roam_time_log_service();
6857 break;
6858 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306859
Mukul Sharma84f27252014-07-14 18:11:42 +05306860 case WE_RESET_ROAM_TIMER_LOG:
6861 {
6862 vos_reset_roam_timer_log();
6863 break;
6864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 default:
6866 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006867 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 break;
6869 }
6870 }
6871
6872 return ret;
6873}
6874
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306875static int iw_setnone_getnone(struct net_device *dev,
6876 struct iw_request_info *info,
6877 union iwreq_data *wrqu, char *extra)
6878{
6879 int ret;
6880
6881 vos_ssr_protect(__func__);
6882 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
6883 vos_ssr_unprotect(__func__);
6884
6885 return ret;
6886}
6887
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306888void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
6889{
6890 /*
6891 * Function to display HDD WMM information
6892 * for Tx Queues.
6893 * Prints globala as well as per client depending
6894 * whether the clients are registered or not.
6895 */
6896 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306897 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
6898 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
6899
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306900 for ( i=0; i< NUM_TX_QUEUES; i++)
6901 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05306902 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306903
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006904 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306905 i, pAdapter->wmm_tx_queue[i].count,
6906 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05306907 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306908 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306909 if(pSapCtx == NULL){
6910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6911 FL("psapCtx is NULL"));
6912 return;
6913 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306914
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05306915 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306916 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
6917 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306918 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306919 {
6920 hddLog(LOGE, "******STAIndex: %d*********", i);
6921 for ( j=0; j< NUM_TX_QUEUES; j++)
6922 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306923 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006924 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306925 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
6926 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
6927 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
6928 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306929 }
6930 }
6931 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05306932 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306933
6934}
Girish Gowlifb9758e2014-11-19 15:19:17 +05306935static int __iw_set_var_ints_getnone(struct net_device *dev,
6936 struct iw_request_info *info,
6937 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006938{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306939 hdd_adapter_t *pAdapter;
6940 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05306941 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05306942 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006943 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306944 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006945 hdd_ap_ctx_t *pAPCtx = NULL;
6946 int cmd = 0;
6947 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306948 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006949
Girish Gowlifb9758e2014-11-19 15:19:17 +05306950 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05306951 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05306952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6953 "%s: NULL extra buffer pointer", __func__);
6954 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05306955 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306956 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6957 if (NULL == pAdapter)
6958 {
6959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6960 "%s: Adapter is NULL",__func__);
6961 return -EINVAL;
6962 }
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306963 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6964 ret = wlan_hdd_validate_context(pHddCtx);
6965 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006966 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306967 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6968 "%s: HDD context is Null", __func__);
6969 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006970 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306971 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6972 if (NULL == hHal)
6973 {
6974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6975 "%s: Hal Context is NULL",__func__);
6976 return -EINVAL;
6977 }
6978 sub_cmd = wrqu->data.flags;
6979
6980 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
6981
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006982
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006983 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
6984 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
6985 {
6986 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
6987 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
6988 {
6989 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6990 staId = pStaCtx->conn_info.staId[0];
6991 }
6992 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
6993 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
6994 {
6995 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
6996 staId = pAPCtx->uBCStaId;
6997 }
6998 else
6999 {
7000 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7001 return 0;
7002 }
7003 }
7004
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 switch (sub_cmd)
7006 {
7007 case WE_LOG_DUMP_CMD:
7008 {
7009 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007010 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 apps_args[3], apps_args[4]);
7012
7013 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7014 apps_args[3], apps_args[4]);
7015
7016 }
7017 break;
7018
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 case WE_P2P_NOA_CMD:
7020 {
7021 p2p_app_setP2pPs_t p2pNoA;
7022
7023 p2pNoA.opp_ps = apps_args[0];
7024 p2pNoA.ctWindow = apps_args[1];
7025 p2pNoA.duration = apps_args[2];
7026 p2pNoA.interval = apps_args[3];
7027 p2pNoA.count = apps_args[4];
7028 p2pNoA.single_noa_duration = apps_args[5];
7029 p2pNoA.psSelection = apps_args[6];
7030
7031 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7032 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007033 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7035
7036 hdd_setP2pPs(dev, &p2pNoA);
7037
7038 }
7039 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007040
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307041 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7042 {
7043 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7044 __func__, apps_args[0], apps_args[1]);
7045 vosTraceEnable(apps_args[0], apps_args[1]);
7046 }
7047 break;
7048
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007049 case WE_MTRACE_DUMP_CMD:
7050 {
7051 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7052 "bitmask_of_module %d ",
7053 __func__, apps_args[0], apps_args[1], apps_args[2],
7054 apps_args[3]);
7055 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7056 apps_args[2], apps_args[3]);
7057
7058 }
7059 break;
7060
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007061 case WE_MCC_CONFIG_CREDENTIAL :
7062 {
7063 cmd = 287; //Command should be updated if there is any change
7064 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007065 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007066 {
7067 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7068 }
7069 else
7070 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007071 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007072 return 0;
7073 }
7074 }
7075 break;
7076
7077 case WE_MCC_CONFIG_PARAMS :
7078 {
7079 cmd = 288; //command Should be updated if there is any change
7080 // in the Riva dump command
7081 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7082 }
7083 break;
7084
Chilam NG571c65a2013-01-19 12:27:36 +05307085#ifdef FEATURE_WLAN_TDLS
7086 case WE_TDLS_CONFIG_PARAMS :
7087 {
7088 tdls_config_params_t tdlsParams;
7089
Chilam Ng01120412013-02-19 18:32:21 -08007090 tdlsParams.tdls = apps_args[0];
7091 tdlsParams.tx_period_t = apps_args[1];
7092 tdlsParams.tx_packet_n = apps_args[2];
7093 tdlsParams.discovery_period_t = apps_args[3];
7094 tdlsParams.discovery_tries_n = apps_args[4];
7095 tdlsParams.idle_timeout_t = apps_args[5];
7096 tdlsParams.idle_packet_n = apps_args[6];
7097 tdlsParams.rssi_hysteresis = apps_args[7];
7098 tdlsParams.rssi_trigger_threshold = apps_args[8];
7099 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307100
Chilam Ng01120412013-02-19 18:32:21 -08007101 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307102 }
7103 break;
7104#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 default:
7106 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007107 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7108 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 }
7110 break;
7111 }
7112
7113 return 0;
7114}
7115
Girish Gowlifb9758e2014-11-19 15:19:17 +05307116static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7117 struct iw_request_info *info,
7118 union iwreq_data *wrqu, char *extra)
7119{
7120 int ret;
7121 union iwreq_data u_priv_wrqu;
7122 int apps_args[MAX_VAR_ARGS] = {0};
7123 int num_args;
7124
7125 /* helper function to get iwreq_data with compat handling. */
7126 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7127 {
7128 return -EINVAL;
7129 }
7130
7131 if (NULL == u_priv_wrqu.data.pointer)
7132 {
7133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7134 "%s: NULL data pointer", __func__);
7135 return -EINVAL;
7136 }
7137
7138 num_args = u_priv_wrqu.data.length;
7139 if (num_args > MAX_VAR_ARGS)
7140 {
7141 num_args = MAX_VAR_ARGS;
7142 }
7143
7144 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7145 (sizeof(int)) * num_args))
7146 {
7147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7148 "%s: failed to copy data from user buffer", __func__);
7149 return -EFAULT;
7150 }
7151
7152 vos_ssr_protect(__func__);
7153 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7154 (char *)&apps_args);
7155 vos_ssr_unprotect(__func__);
7156
7157 return ret;
7158}
7159
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307160int iw_set_var_ints_getnone(struct net_device *dev,
7161 struct iw_request_info *info,
7162 union iwreq_data *wrqu, char *extra)
7163{
7164 int ret;
7165 vos_ssr_protect(__func__);
7166 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7167 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007168
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307169 return ret;
7170}
7171
7172static int __iw_add_tspec(struct net_device *dev,
7173 struct iw_request_info *info,
7174 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007175{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307176 hdd_adapter_t *pAdapter;
7177 hdd_station_ctx_t *pHddStaCtx;
7178 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7180 int params[HDD_WLAN_WMM_PARAM_COUNT];
7181 sme_QosWmmTspecInfo tSpec;
7182 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307183 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307184 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007185
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307186 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7187 if (NULL == pAdapter)
7188 {
7189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7190 "%s: Adapter is NULL",__func__);
7191 return -EINVAL;
7192 }
7193 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7194 ret = wlan_hdd_validate_context(pHddCtx);
7195 if (0 != ret)
7196 {
7197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7198 "%s: HDD context is not valid",__func__);
7199 return ret;
7200 }
7201 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7202 if (NULL == pHddStaCtx)
7203 {
7204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7205 "%s: STA Context is NULL",__func__);
7206 return -EINVAL;
7207 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 // make sure the application is sufficiently priviledged
7209 // note that the kernel will do this for "set" ioctls, but since
7210 // this ioctl wants to return status to user space it must be
7211 // defined as a "get" ioctl
7212 if (!capable(CAP_NET_ADMIN))
7213 {
7214 return -EPERM;
7215 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 // we must be associated in order to add a tspec
7217 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7218 {
7219 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7220 return 0;
7221 }
7222
7223 // since we are defined to be a "get" ioctl, and since the number
7224 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307225 // will pass down in the iwreq_data, we must copy the "set" params.
7226 // We must handle the compat for iwreq_data in 32U/64K environment.
7227
7228 // helper fucntion to get iwreq_data with compat handling.
7229 if (hdd_priv_get_data(&s_priv_data, wrqu))
7230 {
7231 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7232 return 0;
7233 }
7234
7235 // make sure all params are correctly passed to function
7236 if ((NULL == s_priv_data.pointer) ||
7237 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7238 {
7239 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7240 return 0;
7241 }
7242
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307244 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007245 {
7246 // hmmm, can't get them
7247 return -EIO;
7248 }
7249
7250 // clear the tspec
7251 memset(&tSpec, 0, sizeof(tSpec));
7252
7253 // validate the handle
7254 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7255 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7256 {
7257 // that one is reserved
7258 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7259 return 0;
7260 }
7261
7262 // validate the TID
7263 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7264 {
7265 // out of range
7266 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7267 return 0;
7268 }
7269 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7270
7271 // validate the direction
7272 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7273 {
7274 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7275 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7276 break;
7277
7278 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7279 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7280 break;
7281
7282 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7283 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7284 break;
7285
7286 default:
7287 // unknown
7288 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7289 return 0;
7290 }
7291
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307292 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7293
Jeff Johnson295189b2012-06-20 16:38:30 -07007294 // validate the user priority
7295 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7296 {
7297 // out of range
7298 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7299 return 0;
7300 }
7301 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307302 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7303 {
7304 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7305 return 0;
7306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007307
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7309 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7310 tSpec.ts_info.psb, tSpec.ts_info.up);
7311
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7313 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7314 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7315 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7316 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7317 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7318 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7319 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7320 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7321 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7322 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7323 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7324
7325 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7326
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307327 // Save the expected UAPSD settings by application, this will be needed
7328 // when re-negotiating UAPSD settings during BT Coex cases.
7329 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7330
Jeff Johnson295189b2012-06-20 16:38:30 -07007331 // validate the ts info ack policy
7332 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7333 {
7334 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7335 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7336 break;
7337
7338 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7339 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7340 break;
7341
7342 default:
7343 // unknown
7344 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7345 return 0;
7346 }
7347
7348 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
7349 return 0;
7350}
7351
7352
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307353static int iw_add_tspec(struct net_device *dev,
7354 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 union iwreq_data *wrqu, char *extra)
7356{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307357 int ret;
7358
7359 vos_ssr_protect(__func__);
7360 ret = __iw_add_tspec(dev, info, wrqu, extra);
7361 vos_ssr_unprotect(__func__);
7362
7363 return ret;
7364}
7365
7366static int __iw_del_tspec(struct net_device *dev,
7367 struct iw_request_info *info,
7368 union iwreq_data *wrqu, char *extra)
7369{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307370 hdd_adapter_t *pAdapter;
7371 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007372 int *params = (int *)extra;
7373 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7374 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307375 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007376
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307377 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7378 if (NULL == pAdapter)
7379 {
7380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7381 "%s: Adapter is NULL",__func__);
7382 return -EINVAL;
7383 }
7384
7385 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7386 ret = wlan_hdd_validate_context(pHddCtx);
7387 if (0 != ret)
7388 {
7389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7390 "%s: HDD context is not valid",__func__);
7391 return ret;
7392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 // make sure the application is sufficiently priviledged
7394 // note that the kernel will do this for "set" ioctls, but since
7395 // this ioctl wants to return status to user space it must be
7396 // defined as a "get" ioctl
7397 if (!capable(CAP_NET_ADMIN))
7398 {
7399 return -EPERM;
7400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007401 // although we are defined to be a "get" ioctl, the params we require
7402 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7403 // is no need to copy the params from user space
7404
7405 // validate the handle
7406 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7407 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7408 {
7409 // that one is reserved
7410 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7411 return 0;
7412 }
7413
7414 *pStatus = hdd_wmm_delts(pAdapter, handle);
7415 return 0;
7416}
7417
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307418static int iw_del_tspec(struct net_device *dev,
7419 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007420 union iwreq_data *wrqu, char *extra)
7421{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307422 int ret;
7423
7424 vos_ssr_protect(__func__);
7425 ret = __iw_del_tspec(dev, info, wrqu, extra);
7426 vos_ssr_unprotect(__func__);
7427
7428 return ret;
7429}
7430
7431
7432static int __iw_get_tspec(struct net_device *dev,
7433 struct iw_request_info *info,
7434 union iwreq_data *wrqu, char *extra)
7435{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307436 hdd_adapter_t *pAdapter;
7437 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 int *params = (int *)extra;
7439 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7440 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307441 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007442
7443 // although we are defined to be a "get" ioctl, the params we require
7444 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7445 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307446 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7447 if (NULL == pAdapter)
7448 {
7449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7450 "%s: Adapter is NULL",__func__);
7451 return -EINVAL;
7452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007453
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307454 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7455 ret = wlan_hdd_validate_context(pHddCtx);
7456 if (0 != ret)
7457 {
7458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7459 "%s: HDD context is not valid",__func__);
7460 return ret;
7461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007462 // validate the handle
7463 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7464 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7465 {
7466 // that one is reserved
7467 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7468 return 0;
7469 }
7470
7471 *pStatus = hdd_wmm_checkts(pAdapter, handle);
7472 return 0;
7473}
7474
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307475static int iw_get_tspec(struct net_device *dev,
7476 struct iw_request_info *info,
7477 union iwreq_data *wrqu, char *extra)
7478{
7479 int ret;
7480
7481 vos_ssr_protect(__func__);
7482 ret = __iw_get_tspec(dev, info, wrqu, extra);
7483 vos_ssr_unprotect(__func__);
7484
7485 return ret;
7486}
7487
Jeff Johnson295189b2012-06-20 16:38:30 -07007488#ifdef WLAN_FEATURE_VOWIFI_11R
7489//
7490//
7491// Each time the supplicant has the auth_request or reassoc request
7492// IEs ready. This is pushed to the driver. The driver will inturn use
7493// it to send out the auth req and reassoc req for 11r FT Assoc.
7494//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307495static int __iw_set_fties(struct net_device *dev,
7496 struct iw_request_info *info,
7497 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007498{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307499 hdd_adapter_t *pAdapter;
7500 hdd_station_ctx_t *pHddStaCtx;
7501 hdd_context_t *pHddCtx;
7502 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007503 //v_CONTEXT_t pVosContext;
7504
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307505 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7506 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007507 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7509 "%s: Adapter is NULL",__func__);
7510 return -EINVAL;
7511 }
7512 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7513 ret = wlan_hdd_validate_context(pHddCtx);
7514 if (0 != ret)
7515 {
7516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7517 "%s: HDD context is not valid",__func__);
7518 return ret;
7519 }
7520 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7521 if (NULL == pHddStaCtx)
7522 {
7523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7524 "%s: STA Context is NULL",__func__);
7525 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007526 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007527 if (!wrqu->data.length)
7528 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007529 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007530 return -EINVAL;
7531 }
7532 if (wrqu->data.pointer == NULL)
7533 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007534 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 return -EINVAL;
7536 }
7537
7538 // Added for debug on reception of Re-assoc Req.
7539 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7540 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007541 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007543 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007544 }
7545
7546#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007547 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007548#endif
7549
7550 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007551 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007552 wrqu->data.length);
7553
7554 return 0;
7555}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307556
7557static int iw_set_fties(struct net_device *dev,
7558 struct iw_request_info *info,
7559 union iwreq_data *wrqu, char *extra)
7560{
7561 int ret;
7562
7563 vos_ssr_protect(__func__);
7564 ret = __iw_set_fties(dev, info, wrqu, extra);
7565 vos_ssr_unprotect(__func__);
7566
7567 return ret;
7568}
Jeff Johnson295189b2012-06-20 16:38:30 -07007569#endif
7570
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307571static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007572 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007574{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307575 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007576 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307577 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007578 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307579 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007580 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7581 int idx;
7582 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007583
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307584 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7585 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007586 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7588 "%s: Adapter is NULL",__func__);
7589 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007590 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307591 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7592 ret_val = wlan_hdd_validate_context(pHddCtx);
7593 if (0 != ret_val)
7594 {
7595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7596 "%s: HDD context is not valid",__func__);
7597 return ret_val;
7598 }
7599 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7600 if (NULL == hHal)
7601 {
7602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7603 "%s: Hal Context is NULL",__func__);
7604 return -EINVAL;
7605 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307606 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7607 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307608#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007609
Amar Singhalf3a6e762013-02-19 15:06:50 -08007610 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7611 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007612 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007613 hddLog(VOS_TRACE_LEVEL_ERROR,
7614 "%s: vos_mem_alloc failed", __func__);
7615 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007616 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007617
7618 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7619
7620 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7621 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7622
7623 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7624 mc_addr_list_ptr->ulMulticastAddrCnt);
7625
7626 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007627 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007628 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7629 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7630
7631 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7632 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007633 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007634
Amar Singhalf3a6e762013-02-19 15:06:50 -08007635 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7636 vos_mem_free(mc_addr_list_ptr);
7637 if (eHAL_STATUS_SUCCESS != ret_val)
7638 {
7639 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7640 __func__);
7641 return -EINVAL;
7642 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307643#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307644 }
7645 else
7646 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007647
Amar Singhalf3a6e762013-02-19 15:06:50 -08007648 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7649 "%s: Set MC BC Filter Config request: %d suspend %d",
7650 __func__, pRequest->mcastBcastFilterSetting,
7651 pHddCtx->hdd_wlan_suspended);
7652
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307653 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007654
7655 if (pHddCtx->hdd_wlan_suspended)
7656 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007657 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7658 if (NULL == wlanRxpFilterParam)
7659 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307660 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007661 "%s: vos_mem_alloc failed", __func__);
7662 return -EINVAL;
7663 }
7664
Amar Singhalf3a6e762013-02-19 15:06:50 -08007665 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7666 pRequest->mcastBcastFilterSetting;
7667 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7668
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307669 hdd_conf_hostoffload(pAdapter, TRUE);
7670 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7671 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007672
7673 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7674 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307675 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007676 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7677 wlanRxpFilterParam->setMcstBcstFilter);
7678
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307679 if (eHAL_STATUS_SUCCESS !=
7680 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7681 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007682 {
7683 hddLog(VOS_TRACE_LEVEL_ERROR,
7684 "%s: Failure to execute set HW MC/BC Filter request",
7685 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007686 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007687 return -EINVAL;
7688 }
7689
c_hpothud3ce76d2014-10-28 10:34:13 +05307690 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7691 {
7692 pHddCtx->sus_res_mcastbcast_filter =
7693 pRequest->mcastBcastFilterSetting;
7694 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007695 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007697
7698 return 0;
7699}
7700
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307701static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7702 struct iw_request_info *info,
7703 union iwreq_data *wrqu, char *extra)
7704{
7705 int ret;
7706
7707 vos_ssr_protect(__func__);
7708 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
7709 vos_ssr_unprotect(__func__);
7710
7711 return ret;
7712}
7713
7714static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7715 struct iw_request_info *info,
7716 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007717{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307718 hdd_adapter_t *pAdapter;
7719 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307720 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307721 int ret = 0;
7722
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007723 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007724
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307725 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7726 if (NULL == pAdapter)
7727 {
7728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7729 "%s: Adapter is NULL",__func__);
7730 return -EINVAL;
7731 }
7732
7733 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7734 ret = wlan_hdd_validate_context(pHddCtx);
7735 if (0 != ret)
7736 {
7737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7738 "%s: HDD context is not valid",__func__);
7739 return ret;
7740 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307741 //Reset the filter to INI value as we have to clear the dynamic filter
7742 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07007743
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307744 //Configure FW with new setting
7745 if (pHddCtx->hdd_wlan_suspended)
7746 {
7747 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7748 if (NULL == wlanRxpFilterParam)
7749 {
7750 hddLog(VOS_TRACE_LEVEL_ERROR,
7751 "%s: vos_mem_alloc failed", __func__);
7752 return -EINVAL;
7753 }
7754
7755 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7756 pHddCtx->configuredMcastBcastFilter;
7757 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7758
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307759 hdd_conf_hostoffload(pAdapter, TRUE);
7760 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7761 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307762
7763 if (eHAL_STATUS_SUCCESS !=
7764 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7765 wlanRxpFilterParam))
7766 {
7767 hddLog(VOS_TRACE_LEVEL_ERROR,
7768 "%s: Failure to execute set HW MC/BC Filter request",
7769 __func__);
7770 vos_mem_free(wlanRxpFilterParam);
7771 return -EINVAL;
7772 }
c_hpothud3ce76d2014-10-28 10:34:13 +05307773
7774 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7775 {
7776 pHddCtx->sus_res_mcastbcast_filter =
7777 pHddCtx->cfg_ini->mcastBcastFilterSetting;
7778 }
7779
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007781 return 0;
7782}
7783
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307784
7785static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7786 struct iw_request_info *info,
7787 union iwreq_data *wrqu, char *extra)
7788{
7789 int ret;
7790
7791 vos_ssr_protect(__func__);
7792 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
7793 vos_ssr_unprotect(__func__);
7794
7795 return ret;
7796}
7797
7798static int __iw_set_host_offload(struct net_device *dev,
7799 struct iw_request_info *info,
7800 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007801{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307802 hdd_adapter_t *pAdapter;
7803 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007804 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007805 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307806 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007807
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307808 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7809 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007810 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307811 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7812 "%s: Adapter is NULL",__func__);
7813 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007814 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307815 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7816 ret = wlan_hdd_validate_context(pHddCtx);
7817 if (0 != ret)
7818 {
7819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7820 "%s: HDD context is not valid",__func__);
7821 return ret;
7822 }
7823
Jeff Johnson295189b2012-06-20 16:38:30 -07007824 /* Debug display of request components. */
7825 switch (pRequest->offloadType)
7826 {
7827 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007828 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007829 switch (pRequest->enableOrDisable)
7830 {
7831 case WLAN_OFFLOAD_DISABLE:
7832 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
7833 break;
7834 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
7835 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
7836 case WLAN_OFFLOAD_ENABLE:
7837 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
7838 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
7839 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
7840 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
7841 }
7842 break;
7843
7844 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08007845 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007846 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007847 switch (pRequest->enableOrDisable)
7848 {
7849 case WLAN_OFFLOAD_DISABLE:
7850 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
7851 break;
7852 case WLAN_OFFLOAD_ENABLE:
7853 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
7854 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
7855 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
7856 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
7857 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
7858 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
7859 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
7860 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
7861 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
7862 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
7863 }
7864 }
7865
7866 /* Execute offload request. The reason that we can copy the request information
7867 from the ioctl structure to the SME structure is that they are laid out
7868 exactly the same. Otherwise, each piece of information would have to be
7869 copied individually. */
7870 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07007871 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
7872 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007874 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 __func__);
7876 return -EINVAL;
7877 }
7878
7879 return 0;
7880}
7881
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307882static int iw_set_host_offload(struct net_device *dev,
7883 struct iw_request_info *info,
7884 union iwreq_data *wrqu, char *extra)
7885{
7886 int ret;
7887
7888 vos_ssr_protect(__func__);
7889 ret = __iw_set_host_offload(dev, info, wrqu, extra);
7890 vos_ssr_unprotect(__func__);
7891
7892 return ret;
7893}
7894
7895static int __iw_set_keepalive_params(struct net_device *dev,
7896 struct iw_request_info *info,
7897 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007898{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307899 hdd_adapter_t *pAdapter;
7900 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007901 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007902 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307903 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007904
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307905 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7906 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7909 "%s: Adapter is NULL",__func__);
7910 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307912 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7913 ret = wlan_hdd_validate_context(pHddCtx);
7914 if (0 != ret)
7915 {
7916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7917 "%s: HDD context is not valid",__func__);
7918 return ret;
7919 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08007921 hddLog(VOS_TRACE_LEVEL_INFO,
7922 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
7923 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07007924
7925 switch (pRequest->packetType)
7926 {
7927 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007928 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007929 break;
7930
7931 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
7932
Arif Hussain6d2a3322013-11-17 19:50:10 -08007933 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007934 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007935
7936 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
7937 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
7938 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
7939
7940 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
7941 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
7942 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
7943
7944 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
7945 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
7946 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
7947 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
7948 break;
7949
7950 }
7951
7952 /* Execute keep alive request. The reason that we can copy the request information
7953 from the ioctl structure to the SME structure is that they are laid out
7954 exactly the same. Otherwise, each piece of information would have to be
7955 copied individually. */
7956 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
7957
Arif Hussain6d2a3322013-11-17 19:50:10 -08007958 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07007959
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007960 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07007961 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007963 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07007964 __func__);
7965 return -EINVAL;
7966 }
7967
7968 return 0;
7969}
7970
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307971static int iw_set_keepalive_params(struct net_device *dev,
7972 struct iw_request_info *info,
7973 union iwreq_data *wrqu, char *extra)
7974{
7975 int ret;
7976 vos_ssr_protect(__func__);
7977 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
7978 vos_ssr_unprotect(__func__);
7979
7980 return ret;
7981}
7982
Jeff Johnson295189b2012-06-20 16:38:30 -07007983#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007984int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07007985 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007986{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007987 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
7988 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07007989 int i=0;
7990
7991 if (pHddCtx->cfg_ini->disablePacketFilter)
7992 {
7993 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007994 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007995 return 0;
7996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 /* Debug display of request components. */
7998 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007999 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008000
8001 switch (pRequest->filterAction)
8002 {
8003 case HDD_RCV_FILTER_SET:
8004 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008005 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008006
8007 packetFilterSetReq.filterId = pRequest->filterId;
8008 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8009 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008010 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008011 __func__, pRequest->numParams);
8012 return -EINVAL;
8013 }
8014 packetFilterSetReq.numFieldParams = pRequest->numParams;
8015 packetFilterSetReq.coalesceTime = 0;
8016 packetFilterSetReq.filterType = 1;
8017 for (i=0; i < pRequest->numParams; i++)
8018 {
8019 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8020 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8021 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8022 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8023 packetFilterSetReq.paramsData[i].reserved = 0;
8024
Arif Hussain6d2a3322013-11-17 19:50:10 -08008025 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008026 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8027 packetFilterSetReq.filterType);
8028
Arif Hussain6d2a3322013-11-17 19:50:10 -08008029 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008030 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8031
8032 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8033 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8034 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8035 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8036
Arif Hussain6d2a3322013-11-17 19:50:10 -08008037 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008038 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8039 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8040 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8041
Arif Hussain6d2a3322013-11-17 19:50:10 -08008042 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8044 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8045 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8046 }
8047
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008048 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008050 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008051 __func__);
8052 return -EINVAL;
8053 }
8054
8055 break;
8056
8057 case HDD_RCV_FILTER_CLEAR:
8058
Arif Hussain6d2a3322013-11-17 19:50:10 -08008059 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008060 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008062 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008063 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008064 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 __func__);
8066 return -EINVAL;
8067 }
8068 break;
8069
8070 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008071 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008072 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 return -EINVAL;
8074 }
8075 return 0;
8076}
8077
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308078int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8079 tANI_U8 sessionId)
8080{
8081 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8082 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8083
8084 if (NULL == pHddCtx)
8085 {
8086 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8087 return -EINVAL;
8088 }
8089
8090 if (pHddCtx->isLogpInProgress)
8091 {
8092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8093 "%s:LOGP in Progress. Ignore!!!", __func__);
8094 return -EBUSY;
8095 }
8096
8097 if (pHddCtx->cfg_ini->disablePacketFilter)
8098 {
8099 hddLog(VOS_TRACE_LEVEL_ERROR,
8100 "%s: Packet Filtering Disabled. Returning ",
8101 __func__ );
8102 return -EINVAL;
8103 }
8104
8105 switch (filterType)
8106 {
8107 /* For setting IPV6 MC and UC Filter we need to configure
8108 * 2 filters, one for MC and one for UC.
8109 * The Filter ID shouldn't be swapped, which results in making
8110 * UC Filter ineffective.
8111 * We have Hardcode all the values
8112 *
8113 * Reason for a seperate UC filter is because, driver need to
8114 * specify the FW that the specific filter is for unicast
8115 * otherwise FW will not pass the unicast frames by default
8116 * through the filter. This is required to avoid any performance
8117 * hits when no unicast filter is set and only MC/BC are set.
8118 * The way driver informs host is by using the MAC protocol
8119 * layer, CMP flag set to MAX, CMP Data set to 1.
8120 */
8121
8122 case HDD_FILTER_IPV6_MC_UC:
8123 /* Setting IPV6 MC Filter below
8124 */
8125 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8126 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8127 packetFilterSetReq.numFieldParams = 2;
8128 packetFilterSetReq.paramsData[0].protocolLayer =
8129 HDD_FILTER_PROTO_TYPE_MAC;
8130 packetFilterSetReq.paramsData[0].cmpFlag =
8131 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8132 packetFilterSetReq.paramsData[0].dataOffset =
8133 WLAN_HDD_80211_FRM_DA_OFFSET;
8134 packetFilterSetReq.paramsData[0].dataLength = 1;
8135 packetFilterSetReq.paramsData[0].compareData[0] =
8136 HDD_IPV6_MC_CMP_DATA;
8137
8138 packetFilterSetReq.paramsData[1].protocolLayer =
8139 HDD_FILTER_PROTO_TYPE_ARP;
8140 packetFilterSetReq.paramsData[1].cmpFlag =
8141 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8142 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8143 packetFilterSetReq.paramsData[1].dataLength = 2;
8144 packetFilterSetReq.paramsData[1].compareData[0] =
8145 HDD_IPV6_CMP_DATA_0;
8146 packetFilterSetReq.paramsData[1].compareData[1] =
8147 HDD_IPV6_CMP_DATA_1;
8148
8149
8150 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8151 &packetFilterSetReq, sessionId))
8152 {
8153 hddLog(VOS_TRACE_LEVEL_ERROR,
8154 "%s: Failure to execute Set IPv6 Mulicast Filter",
8155 __func__);
8156 return -EINVAL;
8157 }
8158
8159 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8160
8161 /*
8162 * Setting IPV6 UC Filter below
8163 */
8164 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8165 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8166 packetFilterSetReq.numFieldParams = 2;
8167 packetFilterSetReq.paramsData[0].protocolLayer =
8168 HDD_FILTER_PROTO_TYPE_MAC;
8169 packetFilterSetReq.paramsData[0].cmpFlag =
8170 HDD_FILTER_CMP_TYPE_MAX;
8171 packetFilterSetReq.paramsData[0].dataOffset = 0;
8172 packetFilterSetReq.paramsData[0].dataLength = 1;
8173 packetFilterSetReq.paramsData[0].compareData[0] =
8174 HDD_IPV6_UC_CMP_DATA;
8175
8176 packetFilterSetReq.paramsData[1].protocolLayer =
8177 HDD_FILTER_PROTO_TYPE_ARP;
8178 packetFilterSetReq.paramsData[1].cmpFlag =
8179 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8180 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8181 packetFilterSetReq.paramsData[1].dataLength = 2;
8182 packetFilterSetReq.paramsData[1].compareData[0] =
8183 HDD_IPV6_CMP_DATA_0;
8184 packetFilterSetReq.paramsData[1].compareData[1] =
8185 HDD_IPV6_CMP_DATA_1;
8186
8187 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8188 &packetFilterSetReq, sessionId))
8189 {
8190 hddLog(VOS_TRACE_LEVEL_ERROR,
8191 "%s: Failure to execute Set IPv6 Unicast Filter",
8192 __func__);
8193 return -EINVAL;
8194 }
8195
8196 break;
8197
8198 case HDD_FILTER_IPV6_MC:
8199 /*
8200 * IPV6 UC Filter might be already set,
8201 * clear the UC Filter. As the Filter
8202 * IDs are static, we can directly clear it.
8203 */
8204 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8205 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8206 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8207 &packetFilterClrReq, sessionId))
8208 {
8209 hddLog(VOS_TRACE_LEVEL_ERROR,
8210 "%s: Failure to execute Clear IPv6 Unicast Filter",
8211 __func__);
8212 return -EINVAL;
8213 }
8214
8215 /*
8216 * Setting IPV6 MC Filter below
8217 */
8218 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8219 packetFilterSetReq.numFieldParams = 2;
8220 packetFilterSetReq.paramsData[0].protocolLayer =
8221 HDD_FILTER_PROTO_TYPE_MAC;
8222 packetFilterSetReq.paramsData[0].cmpFlag =
8223 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8224 packetFilterSetReq.paramsData[0].dataOffset =
8225 WLAN_HDD_80211_FRM_DA_OFFSET;
8226 packetFilterSetReq.paramsData[0].dataLength = 1;
8227 packetFilterSetReq.paramsData[0].compareData[0] =
8228 HDD_IPV6_MC_CMP_DATA;
8229
8230 packetFilterSetReq.paramsData[1].protocolLayer =
8231 HDD_FILTER_PROTO_TYPE_ARP;
8232 packetFilterSetReq.paramsData[1].cmpFlag =
8233 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8234 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8235 packetFilterSetReq.paramsData[1].dataLength = 2;
8236 packetFilterSetReq.paramsData[1].compareData[0] =
8237 HDD_IPV6_CMP_DATA_0;
8238 packetFilterSetReq.paramsData[1].compareData[1] =
8239 HDD_IPV6_CMP_DATA_1;
8240
8241
8242 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8243 &packetFilterSetReq, sessionId))
8244 {
8245 hddLog(VOS_TRACE_LEVEL_ERROR,
8246 "%s: Failure to execute Set IPv6 Multicast Filter",
8247 __func__);
8248 return -EINVAL;
8249 }
8250 break;
8251
8252 default :
8253 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8254 "%s: Packet Filter Request: Invalid",
8255 __func__);
8256 return -EINVAL;
8257 }
8258 return 0;
8259}
8260
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308261void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008262{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308263 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308264 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008265 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308266 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008267
Yue Ma3ede6052013-08-29 00:33:26 -07008268 if (NULL == pHddCtx)
8269 {
8270 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8271 return;
8272 }
8273
8274 hHal = pHddCtx->hHal;
8275
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308276 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008277 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308278 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8279 return;
8280 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308281
8282 /* Check if INI is enabled or not, other wise just return
8283 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308284 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308285 {
8286 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8287 if (NULL == pMulticastAddrs)
8288 {
8289 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8290 return;
8291 }
8292
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 if (set)
8294 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308295 /* Following pre-conditions should be satisfied before wei
8296 * configure the MC address list.
8297 */
8298 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8299 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8300 && pAdapter->mc_addr_list.mc_cnt
8301 && (eConnectionState_Associated ==
8302 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8303 {
8304 pMulticastAddrs->ulMulticastAddrCnt =
8305 pAdapter->mc_addr_list.mc_cnt;
8306 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8307 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008308 memcpy(pMulticastAddrs->multicastAddr[i],
8309 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308310 sizeof(pAdapter->mc_addr_list.addr[i]));
8311 hddLog(VOS_TRACE_LEVEL_INFO,
8312 "%s: %s multicast filter: addr ="
8313 MAC_ADDRESS_STR,
8314 __func__, set ? "setting" : "clearing",
8315 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8316 }
8317 /* Set multicast filter */
8318 sme_8023MulticastList(hHal, pAdapter->sessionId,
8319 pMulticastAddrs);
8320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008321 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308322 else
8323 {
8324 /* Need to clear only if it was previously configured
8325 */
8326 if (pAdapter->mc_addr_list.isFilterApplied)
8327 {
8328 pMulticastAddrs->ulMulticastAddrCnt = 0;
8329 sme_8023MulticastList(hHal, pAdapter->sessionId,
8330 pMulticastAddrs);
8331 }
8332
8333 }
8334 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008335 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008336 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308337 else
8338 {
8339 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308340 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308341 }
8342 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008343}
8344
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308345static int __iw_set_packet_filter_params(struct net_device *dev,
8346 struct iw_request_info *info,
8347 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308348{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308349 hdd_adapter_t *pAdapter;
8350 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008351 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308352 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308353 struct iw_point s_priv_data;
8354
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308355 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8356 if (NULL == pAdapter)
8357 {
8358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8359 "%s: Adapter is NULL",__func__);
8360 return -EINVAL;
8361 }
8362 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8363 ret = wlan_hdd_validate_context(pHddCtx);
8364 if (0 != ret)
8365 {
8366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8367 "%s: HDD context is not valid",__func__);
8368 return ret;
8369 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308370 if (hdd_priv_get_data(&s_priv_data, wrqu))
8371 {
8372 return -EINVAL;
8373 }
8374
8375 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8376 {
8377 return -EINVAL;
8378 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008379
Arif Hussain0273cba2014-01-07 20:58:29 -08008380 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308381 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8382 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008383 if (NULL == pRequest)
8384 {
8385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8386 "mem_alloc_copy_from_user_helper fail");
8387 return -ENOMEM;
8388 }
8389
8390 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8391 kfree(pRequest);
8392
8393 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008394}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308395
8396static int iw_set_packet_filter_params(struct net_device *dev,
8397 struct iw_request_info *info,
8398 union iwreq_data *wrqu, char *extra)
8399{
8400 int ret;
8401
8402 vos_ssr_protect(__func__);
8403 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8404 vos_ssr_unprotect(__func__);
8405
8406 return ret;
8407}
Jeff Johnson295189b2012-06-20 16:38:30 -07008408#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308409static int __iw_get_statistics(struct net_device *dev,
8410 struct iw_request_info *info,
8411 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008412{
8413
8414 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8415 eHalStatus status = eHAL_STATUS_SUCCESS;
8416 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308417 hdd_adapter_t *pAdapter;
8418 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308420 int tlen = 0, ret = 0;
8421 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008422
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308423 tCsrGlobalClassAStatsInfo *aStats;
8424 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008425
8426 ENTER();
8427
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308428 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8429 if (NULL == pAdapter)
8430 {
8431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8432 "%s: Adapter is NULL",__func__);
8433 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308435 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8436 ret = wlan_hdd_validate_context(pHddCtx);
8437 if (0 != ret)
8438 {
8439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8440 "%s: HDD context is not valid",__func__);
8441 return ret;
8442 }
8443 pStats = &(pAdapter->hdd_stats.summary_stat);
8444 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8445 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8447
8448 wrqu->txpower.value = 0;
8449 }
8450 else {
8451 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8452 SME_SUMMARY_STATS |
8453 SME_GLOBAL_CLASSA_STATS |
8454 SME_GLOBAL_CLASSB_STATS |
8455 SME_GLOBAL_CLASSC_STATS |
8456 SME_GLOBAL_CLASSD_STATS |
8457 SME_PER_STA_STATS,
8458 hdd_StatisticsCB, 0, FALSE,
8459 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8460
8461 if (eHAL_STATUS_SUCCESS != status)
8462 {
8463 hddLog(VOS_TRACE_LEVEL_ERROR,
8464 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008465 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 return -EINVAL;
8467 }
8468
8469 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308470 if (NULL == pWextState)
8471 {
8472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8473 "%s: pWextState is NULL",__func__);
8474 return -EINVAL;
8475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008476
8477 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8478 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8479 {
8480 hddLog(VOS_TRACE_LEVEL_ERROR,
8481 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008482 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 /*Remove the SME statistics list by passing NULL in callback argument*/
8484 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8485 SME_SUMMARY_STATS |
8486 SME_GLOBAL_CLASSA_STATS |
8487 SME_GLOBAL_CLASSB_STATS |
8488 SME_GLOBAL_CLASSC_STATS |
8489 SME_GLOBAL_CLASSD_STATS |
8490 SME_PER_STA_STATS,
8491 NULL, 0, FALSE,
8492 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8493
8494 return -EINVAL;
8495 }
8496 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8497 (tANI_U8) sizeof (pStats->retry_cnt),
8498 (char*) &(pStats->retry_cnt[0]),
8499 tlen);
8500
8501 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8502 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8503 (char*) &(pStats->multiple_retry_cnt[0]),
8504 tlen);
8505
8506 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8507 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8508 (char*) &(pStats->tx_frm_cnt[0]),
8509 tlen);
8510
8511 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8512 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8513 (char*) &(pStats->rx_frm_cnt),
8514 tlen);
8515
8516 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8517 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8518 (char*) &(pStats->frm_dup_cnt),
8519 tlen);
8520
8521 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8522 (tANI_U8) sizeof (pStats->fail_cnt),
8523 (char*) &(pStats->fail_cnt[0]),
8524 tlen);
8525
8526 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8527 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8528 (char*) &(pStats->rts_fail_cnt),
8529 tlen);
8530
8531 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8532 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8533 (char*) &(pStats->ack_fail_cnt),
8534 tlen);
8535
8536 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8537 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8538 (char*) &(pStats->rts_succ_cnt),
8539 tlen);
8540
8541 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8542 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8543 (char*) &(pStats->rx_discard_cnt),
8544 tlen);
8545
8546 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8547 (tANI_U8) sizeof (pStats->rx_error_cnt),
8548 (char*) &(pStats->rx_error_cnt),
8549 tlen);
8550
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008551 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008552 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008553 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008554 tlen);
8555
8556 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8557 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8558 (char*) &(dStats->rx_byte_cnt),
8559 tlen);
8560
8561 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8562 (tANI_U8) sizeof (dStats->rx_rate),
8563 (char*) &(dStats->rx_rate),
8564 tlen);
8565
8566 /* Transmit rate, in units of 500 kbit/sec */
8567 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8568 (tANI_U8) sizeof (aStats->tx_rate),
8569 (char*) &(aStats->tx_rate),
8570 tlen);
8571
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008572 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8573 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8574 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008575 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008576 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8577 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8578 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008579 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008580 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8581 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8582 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008583 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008584 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8585 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8586 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008587 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008588 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8589 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8590 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008591 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008592 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8593 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8594 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008595 tlen);
8596
Jeff Johnson295189b2012-06-20 16:38:30 -07008597 wrqu->data.length = tlen;
8598
8599 }
8600
8601 EXIT();
8602
8603 return 0;
8604}
8605
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308606static int iw_get_statistics(struct net_device *dev,
8607 struct iw_request_info *info,
8608 union iwreq_data *wrqu, char *extra)
8609{
8610 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008611
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308612 vos_ssr_protect(__func__);
8613 ret = __iw_get_statistics(dev, info, wrqu, extra);
8614 vos_ssr_unprotect(__func__);
8615
8616 return ret;
8617}
Jeff Johnson295189b2012-06-20 16:38:30 -07008618#ifdef FEATURE_WLAN_SCAN_PNO
8619
8620/*Max Len for PNO notification*/
8621#define MAX_PNO_NOTIFY_LEN 100
8622void found_pref_network_cb (void *callbackContext,
8623 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8624{
8625 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8626 union iwreq_data wrqu;
8627 char buf[MAX_PNO_NOTIFY_LEN+1];
8628
8629 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8630 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8631
8632 // create the event
8633 memset(&wrqu, 0, sizeof(wrqu));
8634 memset(buf, 0, sizeof(buf));
8635
8636 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8637 pPrefNetworkFoundInd->ssId.ssId,
8638 (unsigned int)pPrefNetworkFoundInd->rssi);
8639
8640 wrqu.data.pointer = buf;
8641 wrqu.data.length = strlen(buf);
8642
8643 // send the event
8644
8645 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8646
8647}
8648
8649
8650/*string based input*/
8651VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8652 union iwreq_data *wrqu, char *extra, int nOffset)
8653{
8654 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308655 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008656 /* pnoRequest is a large struct, so we make it static to avoid stack
8657 overflow. This API is only invoked via ioctl, so it is
8658 serialized by the kernel rtnl_lock and hence does not need to be
8659 reentrant */
8660 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07008661 char *ptr;
8662 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308663 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008664 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8665
8666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8667 "PNO data len %d data %s",
8668 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008669 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008670
8671 if (wrqu->data.length <= nOffset )
8672 {
8673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8674 return VOS_STATUS_E_FAILURE;
8675 }
8676
8677 pnoRequest.enable = 0;
8678 pnoRequest.ucNetworksCount = 0;
8679 /*-----------------------------------------------------------------------
8680 Input is string based and expected to be like this:
8681
8682 <enabled> <netw_count>
8683 for each network:
8684 <ssid_len> <ssid> <authentication> <encryption>
8685 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8686 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8687
8688 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008689 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 -07008690
8691 this translates into:
8692 -----------------------------
8693 enable PNO
8694 look for 2 networks:
8695 test - with authentication type 0 and encryption type 0,
8696 that can be found on 3 channels: 1 6 and 11 ,
8697 SSID bcast type is unknown (directed probe will be sent if AP not found)
8698 and must meet -40dBm RSSI
8699
8700 test2 - with auth and enrytption type 4/4
8701 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
8702 bcast type is non-bcast (directed probe will be sent)
8703 and must not meet any RSSI threshold
8704
Jeff Johnson8301aa12013-03-28 14:27:29 -07008705 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07008706 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08008707 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008708
Wilson Yang623f6592013-10-08 16:33:37 -07008709 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
8710 {
8711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8712 "PNO enable input is not valid %s",ptr);
8713 return VOS_STATUS_E_FAILURE;
8714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008715
8716 if ( 0 == pnoRequest.enable )
8717 {
8718 /*Disable PNO*/
8719 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05308720 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8721 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 pAdapter->sessionId,
8723 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308724 if (eHAL_STATUS_SUCCESS != status)
8725 {
8726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8727 "%s: failed to disable PNO", __func__);
8728 return VOS_STATUS_E_FAILURE;
8729 }
8730 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008731 return VOS_STATUS_SUCCESS;
8732 }
8733
c_hpothu37f21312014-04-09 21:49:54 +05308734 if (TRUE == pHddCtx->isPnoEnable)
8735 {
8736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8737 FL("already PNO is enabled"));
8738 return -EBUSY;
8739 }
8740 pHddCtx->isPnoEnable = TRUE;
8741
Jeff Johnson295189b2012-06-20 16:38:30 -07008742 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07008743
8744 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
8745 {
8746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8747 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308748 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008750
8751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8752 "PNO enable %d networks count %d offset %d",
8753 pnoRequest.enable,
8754 pnoRequest.ucNetworksCount,
8755 nOffset);
8756
8757 /* Parameters checking:
8758 ucNetworksCount has to be larger than 0*/
8759 if (( 0 == pnoRequest.ucNetworksCount ) ||
8760 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8761 {
8762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05308763 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 }
8765
8766 ptr += nOffset;
8767
8768 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
8769 {
8770
8771 pnoRequest.aNetworks[i].ssId.length = 0;
8772
Wilson Yang623f6592013-10-08 16:33:37 -07008773 ucParams = sscanf(ptr,"%hhu %n",
8774 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
8775
8776 if (1 != ucParams)
8777 {
8778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8779 "PNO ssid length input is not valid %s",ptr);
8780 return VOS_STATUS_E_FAILURE;
8781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008782
8783 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
8784 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
8785 {
8786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8787 "SSID Len %d is not correct for network %d",
8788 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05308789 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 }
8791
8792 /*Advance to SSID*/
8793 ptr += nOffset;
8794
Jeff Johnson8301aa12013-03-28 14:27:29 -07008795 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08008796 pnoRequest.aNetworks[i].ssId.length);
8797 ptr += pnoRequest.aNetworks[i].ssId.length;
8798
Jeff Johnson02797792013-10-26 19:17:13 -07008799 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08008800 &(pnoRequest.aNetworks[i].authentication),
8801 &(pnoRequest.aNetworks[i].encryption),
8802 &(pnoRequest.aNetworks[i].ucChannelCount),
8803 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008804
Wilson Yang623f6592013-10-08 16:33:37 -07008805 if ( 3 != ucParams )
8806 {
8807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8808 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308809 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008810 }
8811
Jeff Johnson295189b2012-06-20 16:38:30 -07008812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008813 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08008814 "auth %d encry %d channel count %d offset %d",
8815 pnoRequest.aNetworks[i].ssId.length,
8816 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
8817 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
8818 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
8819 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
8820 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
8821 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
8822 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
8823 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
8824 pnoRequest.aNetworks[i].authentication,
8825 pnoRequest.aNetworks[i].encryption,
8826 pnoRequest.aNetworks[i].ucChannelCount,
8827 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07008828
Jeff Johnson295189b2012-06-20 16:38:30 -07008829 /*Advance to channel list*/
8830 ptr += nOffset;
8831
Wilson Yang623f6592013-10-08 16:33:37 -07008832 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 {
8834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8835 "Incorrect number of channels");
8836 return VOS_STATUS_E_FAILURE;
8837 }
8838
8839 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
8840 {
8841 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
8842 {
Wilson Yang623f6592013-10-08 16:33:37 -07008843 if (1 != sscanf(ptr,"%hhu %n",
8844 &(pnoRequest.aNetworks[i].aChannels[j]),
8845 &nOffset))
8846 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8847 "PNO network channel input is not valid %s",ptr);
8848 return VOS_STATUS_E_FAILURE;
8849 }
8850 /*Advance to next channel number*/
8851 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008852 }
8853 }
8854
Jeff Johnson02797792013-10-26 19:17:13 -07008855 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07008856 &(pnoRequest.aNetworks[i].bcastNetwType),
8857 &nOffset))
8858 {
8859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8860 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308861 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008863
8864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8865 "PNO bcastNetwType %d offset %d",
8866 pnoRequest.aNetworks[i].bcastNetwType,
8867 nOffset );
8868
8869 /*Advance to rssi Threshold*/
8870 ptr += nOffset;
8871
Wilson Yang623f6592013-10-08 16:33:37 -07008872 if (1 != sscanf(ptr,"%hhu %n",
8873 &(pnoRequest.aNetworks[i].rssiThreshold),
8874 &nOffset))
8875 {
8876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8877 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308878 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008880
8881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8882 "PNO rssi %d offset %d",
8883 pnoRequest.aNetworks[i].rssiThreshold,
8884 nOffset );
8885 /*Advance to next network*/
8886 ptr += nOffset;
8887 }/*For ucNetworkCount*/
8888
8889 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07008890 &(pnoRequest.scanTimers.ucScanTimersCount),
8891 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008892
8893 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07008894 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 {
8896 ptr += nOffset;
8897
Jeff Johnson8301aa12013-03-28 14:27:29 -07008898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8899 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 pnoRequest.scanTimers.ucScanTimersCount,
8901 nOffset );
8902
8903 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
8904 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07008905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008906 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05308907 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008908 }
8909
8910 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
8911 {
Jeff Johnson02797792013-10-26 19:17:13 -07008912 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
8914 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
8915 &nOffset);
8916
Wilson Yang623f6592013-10-08 16:33:37 -07008917 if (2 != ucParams)
8918 {
8919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8920 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05308921 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008922 }
8923
Jeff Johnson8301aa12013-03-28 14:27:29 -07008924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8925 "PNO Timer value %d Timer repeat %d offset %d",
8926 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07008927 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
8928 nOffset );
8929
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 ptr += nOffset;
8931 }
8932
8933 }
8934 else
8935 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07008936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8937 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
8939
8940 /*Scan timers defaults to 5 minutes*/
8941 pnoRequest.scanTimers.ucScanTimersCount = 1;
8942 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
8943 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
8944 }
8945
Wilson Yang623f6592013-10-08 16:33:37 -07008946 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008947
8948 pnoRequest.modePNO = ucMode;
8949 /*for LA we just expose suspend option*/
8950 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
8951 {
8952 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
8953 }
8954
c_hpothu37f21312014-04-09 21:49:54 +05308955 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008956 pAdapter->sessionId,
8957 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308958 if (eHAL_STATUS_SUCCESS == status)
8959 {
8960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8961 "%s: PNO enabled", __func__);
8962 return VOS_STATUS_SUCCESS;
8963 }
8964error:
8965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8966 "%s: Failed to enable PNO", __func__);
8967 pHddCtx->isPnoEnable = FALSE;
8968 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008969}/*iw_set_pno*/
8970
8971VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
8972 union iwreq_data *wrqu, char *extra, int nOffset)
8973{
8974 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8975 v_U8_t rssiThreshold = 0;
8976 v_U8_t nRead;
8977
Arif Hussain7adce1b2013-11-11 22:59:34 -08008978 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008979 &rssiThreshold);
8980
8981 if ( 1 != nRead )
8982 {
8983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8984 "Incorrect format");
8985 return VOS_STATUS_E_FAILURE;
8986 }
8987
8988 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
8989 return VOS_STATUS_SUCCESS;
8990}
8991
8992
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308993static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 struct iw_request_info *info,
8995 union iwreq_data *wrqu, char *extra)
8996{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308997 hdd_adapter_t *pAdapter;
8998 hdd_context_t *pHddCtx;
8999 int ret = 0;
9000
9001 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9002 if (NULL == pAdapter)
9003 {
9004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9005 "%s: Adapter is NULL",__func__);
9006 return -EINVAL;
9007 }
9008
9009 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9010 ret = wlan_hdd_validate_context(pHddCtx);
9011 if (0 != ret)
9012 {
9013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9014 "%s: HDD context is not valid",__func__);
9015 return ret;
9016 }
9017
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009018
9019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009020 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009021
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009022 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009023}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309024
9025static int iw_set_pno_priv(struct net_device *dev,
9026 struct iw_request_info *info,
9027 union iwreq_data *wrqu, char *extra)
9028{
9029 int ret;
9030
9031 vos_ssr_protect(__func__);
9032 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9033 vos_ssr_unprotect(__func__);
9034
9035 return ret;
9036}
Jeff Johnson295189b2012-06-20 16:38:30 -07009037#endif /*FEATURE_WLAN_SCAN_PNO*/
9038
9039//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309040int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009041{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309042 hdd_adapter_t *pAdapter;
9043 tHalHandle hHal;
9044 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309045 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309046 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07009047 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309048 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309049 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309050 tpAniSirGlobal pMac;
9051 int retval = 0;
9052
9053 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9054 if (NULL == pAdapter)
9055 {
9056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9057 "%s: Adapter is NULL",__func__);
9058 return -EINVAL;
9059 }
9060 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9061 retval = wlan_hdd_validate_context(pHddCtx);
9062 if (0 != retval)
9063 {
9064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9065 "%s: HDD context is not valid",__func__);
9066 return retval;
9067 }
9068 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9069 if (NULL == hHal)
9070 {
9071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9072 "%s: Hal Context is NULL",__func__);
9073 return -EINVAL;
9074 }
9075 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009076
Atul Mittal54378cb2014-04-02 16:51:50 +05309077 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 {
9079 case WLAN_HDD_UI_BAND_AUTO:
9080 band = eCSR_BAND_ALL;
9081 break;
9082 case WLAN_HDD_UI_BAND_5_GHZ:
9083 band = eCSR_BAND_5G;
9084 break;
9085 case WLAN_HDD_UI_BAND_2_4_GHZ:
9086 band = eCSR_BAND_24;
9087 break;
9088 default:
9089 band = eCSR_BAND_MAX;
9090 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309091 connectedBand =
9092 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009093
Atul Mittal54378cb2014-04-02 16:51:50 +05309094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009095 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009096
9097 if (band == eCSR_BAND_MAX)
9098 {
9099 /* Received change band request with invalid band value */
9100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309101 "%s: Invalid band value %u", __func__, ui_band);
9102 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 }
9104
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309105 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
9106 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
9107 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
9108 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009110 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009111 band, pHddCtx->cfg_ini->nBandCapability);
9112 return -EIO;
9113 }
9114
Jeff Johnson295189b2012-06-20 16:38:30 -07009115 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9116 {
9117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9118 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009119 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 return -EIO;
9121 }
9122
9123 if (currBand != band)
9124 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309125 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309126 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309127 /* Return failure if current country code is world regulatory domain*/
9128 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9129 pMac->scan.countryCodeCurrent[1] == '0') )
9130 {
9131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9132 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309133 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309134 return -EAGAIN;
9135 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309136 }
9137
Jeff Johnson295189b2012-06-20 16:38:30 -07009138 /* Change band request received.
9139 * Abort pending scan requests, flush the existing scan results,
9140 * and change the band capability
9141 */
9142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9143 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009144 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009145
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309146 /* We need to change the band and flush the scan results here itself
9147 * as we may get timeout for disconnection in which we will return
9148 * with out doing any of these
9149 */
9150 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9151 {
9152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9153 "%s: failed to set the band value to %u ",
9154 __func__, band);
9155 return -EINVAL;
9156 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309157 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9158 {
9159 v_COUNTRYCODE_t curr_country;
9160 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9161 curr_country[1]=pMac->scan.countryCodeCurrent[1];
9162
9163 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9164 * information available in NV so to get the channel information from kernel
9165 * we need to send regulatory hint for the currunt country
9166 * And to set the same country again we need to set the dummy country
9167 * first and then the actual country.
9168 */
9169
9170#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9171 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9172#else
9173 regulatory_hint_user("00");
9174#endif
9175
9176 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
9177#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9178 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9179#else
9180 regulatory_hint_user(curr_country);
9181#endif
9182 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
9183 }
9184 else
9185 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309186#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309187 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9188 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309189#else
9190 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9191#endif
9192
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309193 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309194 pScanInfo = &pHddCtx->scan_info;
9195 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9196 {
9197 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9198 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9199 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309200 sme_FilterScanResults(hHal, pAdapter->sessionId);
9201
9202 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309203 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9204 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009205 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 eHalStatus status = eHAL_STATUS_SUCCESS;
9207 long lrc;
9208
9209 /* STA already connected on current band, So issue disconnect first,
9210 * then change the band*/
9211
9212 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309213 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309214 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009215
Jeff Johnson295189b2012-06-20 16:38:30 -07009216 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9217
9218 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9219 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9220
Jeff Johnson43971f52012-07-17 12:26:56 -07009221 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 {
9223 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009224 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 __func__, (int)status );
9226 return -EINVAL;
9227 }
9228
9229 lrc = wait_for_completion_interruptible_timeout(
9230 &pAdapter->disconnect_comp_var,
9231 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9232
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309233 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009234
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009235 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009236 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009237
9238 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9239 }
9240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009241 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309242 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009243}
9244
Atul Mittal54378cb2014-04-02 16:51:50 +05309245int hdd_setBand_helper(struct net_device *dev, const char *command)
9246{
9247 u8 band;
9248
9249 /*convert the band value from ascii to integer*/
9250 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9251
9252 return hdd_setBand(dev, band);
9253
9254}
9255
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309256static int __iw_set_band_config(struct net_device *dev,
9257 struct iw_request_info *info,
9258 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009259{
Atul Mittal54378cb2014-04-02 16:51:50 +05309260 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009261
Arif Hussain0273cba2014-01-07 20:58:29 -08009262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009263
Atul Mittal54378cb2014-04-02 16:51:50 +05309264 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009265}
9266
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309267static int iw_set_band_config(struct net_device *dev,
9268 struct iw_request_info *info,
9269 union iwreq_data *wrqu, char *extra)
9270{
9271 int ret;
9272
9273 vos_ssr_protect(__func__);
9274 ret = __iw_set_band_config(dev, info, wrqu, extra);
9275 vos_ssr_unprotect(__func__);
9276
9277 return ret;
9278}
9279
9280static int __iw_set_power_params_priv(struct net_device *dev,
9281 struct iw_request_info *info,
9282 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009283{
Arif Hussain0273cba2014-01-07 20:58:29 -08009284 int ret;
9285 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9287 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009288 /* ODD number is used for set, copy data using copy_from_user */
9289 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9290 wrqu->data.length);
9291 if (NULL == ptr)
9292 {
9293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9294 "mem_alloc_copy_from_user_helper fail");
9295 return -ENOMEM;
9296 }
9297
9298 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9299 kfree(ptr);
9300 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009301}
9302
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309303static int iw_set_power_params_priv(struct net_device *dev,
9304 struct iw_request_info *info,
9305 union iwreq_data *wrqu, char *extra)
9306{
9307 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009308
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309309 vos_ssr_protect(__func__);
9310 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9311 vos_ssr_unprotect(__func__);
9312
9313 return ret;
9314}
Jeff Johnson295189b2012-06-20 16:38:30 -07009315
9316/*string based input*/
9317VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9318 union iwreq_data *wrqu, char *extra, int nOffset)
9319{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309320 hdd_adapter_t *pAdapter;
9321 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009322 tSirSetPowerParamsReq powerRequest;
9323 char *ptr;
9324 v_U8_t ucType;
9325 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309326 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
9328
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309329 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9330 if (NULL == pAdapter)
9331 {
9332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9333 "%s: Adapter is NULL",__func__);
9334 return -EINVAL;
9335 }
9336
9337 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9338 ret = wlan_hdd_validate_context(pHddCtx);
9339 if (0 != ret)
9340 {
9341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9342 "%s: HDD context is not valid",__func__);
9343 return ret;
9344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9346 "Power Params data len %d data %s",
9347 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009348 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009349
9350 if (wrqu->data.length <= nOffset )
9351 {
9352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9353 return VOS_STATUS_E_FAILURE;
9354 }
9355
9356 uTotalSize = wrqu->data.length - nOffset;
9357
9358 /*-----------------------------------------------------------------------
9359 Input is string based and expected to be like this:
9360
9361 <param_type> <param_value> <param_type> <param_value> ...
9362
9363 e.g:
9364 1 2 2 3 3 0 4 1 5 1
9365
9366 e.g. setting just a few:
9367 1 2 4 1
9368
9369 parameter types:
9370 -----------------------------
9371 1 - Ignore DTIM
9372 2 - Listen Interval
9373 3 - Broadcast Multicas Filter
9374 4 - Beacon Early Termination
9375 5 - Beacon Early Termination Interval
9376 -----------------------------------------------------------------------*/
9377 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9378 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9379 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9380 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9381 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9382
Arif Hussain7adce1b2013-11-11 22:59:34 -08009383 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009384
9385 while ( uTotalSize )
9386 {
Wilson Yang6f971452013-10-08 15:00:00 -07009387 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9388 {
9389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9390 "Invalid input parameter type %s",ptr);
9391 return VOS_STATUS_E_FAILURE;
9392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009393
9394 uTotalSize -= nOffset;
9395
9396 if (!uTotalSize)
9397 {
9398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009399 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 ucType, nOffset);
9401 return VOS_STATUS_E_FAILURE;
9402 }
9403
9404 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009405
Jeff Johnson02797792013-10-26 19:17:13 -07009406 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009407 {
9408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9409 "Invalid input parameter value %s",ptr);
9410 return VOS_STATUS_E_FAILURE;
9411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009412
9413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9414 "Power request parameter %d value %d offset %d",
9415 ucType, uValue, nOffset);
9416
9417 switch (ucType)
9418 {
9419 case eSIR_IGNORE_DTIM:
9420 powerRequest.uIgnoreDTIM = uValue;
9421 break;
9422 case eSIR_LISTEN_INTERVAL:
9423 powerRequest.uListenInterval = uValue;
9424 break;
9425 case eSIR_MCAST_BCAST_FILTER:
9426 powerRequest.uBcastMcastFilter = uValue;
9427 break;
9428 case eSIR_ENABLE_BET:
9429 powerRequest.uEnableBET = uValue;
9430 break;
9431 case eSIR_BET_INTERVAL:
9432 powerRequest.uBETInterval = uValue;
9433 break;
9434 default:
9435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009436 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 ucType, uValue, nOffset);
9438 return VOS_STATUS_E_FAILURE;
9439 }
9440
9441 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9443 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009444 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009446 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009447 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009448 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9449 {
9450 uTotalSize = 0;
9451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009452
9453 }/*Go for as long as we have a valid string*/
9454
9455 /* put the device into full power*/
9456 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9457
9458 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009459 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009460
9461 /* put the device back to power save*/
9462 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9463
9464 return VOS_STATUS_SUCCESS;
9465}/*iw_set_power_params*/
9466
Atul Mittalc0f739f2014-07-31 13:47:47 +05309467// tdlsoffchan
9468#ifdef FEATURE_WLAN_TDLS
9469
Atul Mittal87ec2422014-09-24 13:12:50 +05309470int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309471{
9472 if (offchannel < 0 || offchannel > 165)
9473 {
9474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9475 __func__, offchannel);
9476 return -1;
9477
9478 }
9479
9480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9481 __func__, tdlsOffCh, offchannel);
9482
9483 tdlsOffCh = offchannel;
9484 return 0;
9485}
9486
Atul Mittal87ec2422014-09-24 13:12:50 +05309487int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309488{
9489 if (offchanoffset == 0)
9490 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309491 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9493 __func__, tdlsOffChBwOffset);
9494
9495 return 0;
9496
9497 }
9498
9499 if ( offchanoffset == 40 )
9500 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309501 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9503 __func__, tdlsOffChBwOffset);
9504
9505 return 0;
9506
9507 }
9508 if (offchanoffset == -40)
9509 {
9510 tdlsOffChBwOffset = 3;
9511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9512 __func__, tdlsOffChBwOffset);
9513
9514 return 0;
9515
9516 }
9517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9518 __func__, offchanoffset);
9519 return -1;
9520}
9521
Atul Mittal87ec2422014-09-24 13:12:50 +05309522int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309523{
9524 hddTdlsPeer_t *connPeer = NULL;
9525 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9526 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9527
9528 if (offchanmode < 0 || offchanmode > 4)
9529 {
9530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9531 "%s: Invalid tdls off channel mode %d",
9532 __func__, offchanmode);
9533 return -1;
9534 }
9535
9536 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9537 {
9538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9539 "%s: tdls off channel mode req in not associated state %d",
9540 __func__, offchanmode);
9541 return -1;
9542 }
9543
9544 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9545 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9546 {
9547 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309548 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309549 if (NULL == connPeer) {
9550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9551 "%s: No TDLS Connected Peer", __func__);
9552 return -1;
9553 }
9554 }
9555 else
9556 {
9557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9558 "%s: TDLS Connection not supported", __func__);
9559 return -1;
9560 }
9561
9562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9563 ("%s: TDLS Channel Switch in swmode=%d"),
9564 __func__, offchanmode);
9565
9566 switch (offchanmode)
9567 {
9568 case 1:/*Enable*/
9569 case 2:/*Disable*/
9570 {
9571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9572 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9573 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9574 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9575 {
9576
9577 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9578 pAdapter->sessionId, connPeer->peerMac,
9579 tdlsOffCh, tdlsOffChBwOffset,
9580 offchanmode);
9581 }
9582 else
9583 {
9584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9585 "%s: TDLS Off Channel not supported", __func__);
9586 return -1;
9587 }
9588 break;
9589 }
9590 case 3:
9591 {
9592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9593 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
9594 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9595
9596 break;
9597 }
9598 case 4:
9599 {
9600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9601 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
9602 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9603 break;
9604 }
9605 default:
9606 {
9607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9608 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
9609 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9610 break;
9611 }
9612
9613 }
9614
9615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
9616 __func__, offchanmode);
9617 return 0;
9618}
Atul Mittalc0f739f2014-07-31 13:47:47 +05309619#endif
9620
Jeff Johnson295189b2012-06-20 16:38:30 -07009621
9622// Define the Wireless Extensions to the Linux Network Device structure
9623// A number of these routines are NULL (meaning they are not implemented.)
9624
9625static const iw_handler we_handler[] =
9626{
9627 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9628 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9629 (iw_handler) NULL, /* SIOCSIWNWID */
9630 (iw_handler) NULL, /* SIOCGIWNWID */
9631 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9632 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9633 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9634 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9635 (iw_handler) NULL, /* SIOCSIWSENS */
9636 (iw_handler) NULL, /* SIOCGIWSENS */
9637 (iw_handler) NULL, /* SIOCSIWRANGE */
9638 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9639 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
9640 (iw_handler) NULL, /* SIOCGIWPRIV */
9641 (iw_handler) NULL, /* SIOCSIWSTATS */
9642 (iw_handler) NULL, /* SIOCGIWSTATS */
9643 iw_handler_set_spy, /* SIOCSIWSPY */
9644 iw_handler_get_spy, /* SIOCGIWSPY */
9645 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
9646 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
9647 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9648 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9649 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9650 (iw_handler) NULL, /* SIOCGIWAPLIST */
9651 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9652 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9653 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9654 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9655 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9656 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9657 (iw_handler) NULL, /* -- hole -- */
9658 (iw_handler) NULL, /* -- hole -- */
9659 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9660 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9661 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
9662 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
9663 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9664 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9665 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9666 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9667 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9668 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9669 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9670 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9671 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9672 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9673 (iw_handler) NULL, /* -- hole -- */
9674 (iw_handler) NULL, /* -- hole -- */
9675 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9676 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9677 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9678 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9679 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9680 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9681 (iw_handler) NULL, /* SIOCSIWPMKSA */
9682};
9683
9684static const iw_handler we_private[] = {
9685
9686 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
9687 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
9688 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
9689 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
9690 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9691 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +05309692 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9694 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9695 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07009696#ifdef FEATURE_OEM_DATA_SUPPORT
9697 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
9698 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
9699#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009700
Jeff Johnson295189b2012-06-20 16:38:30 -07009701#ifdef WLAN_FEATURE_VOWIFI_11R
9702 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
9703#endif
9704 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9705 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9706 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
9707#ifdef WLAN_FEATURE_PACKET_FILTERING
9708 ,
9709 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
9710#endif
9711#ifdef FEATURE_WLAN_SCAN_PNO
9712 ,
9713 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
9714#endif
9715 ,
9716 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9717 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
9718 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
9719 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07009720 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07009721};
9722
9723/*Maximum command length can be only 15 */
9724static const struct iw_priv_args we_private_args[] = {
9725
9726 /* handlers for main ioctl */
9727 { WLAN_PRIV_SET_INT_GET_NONE,
9728 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9729 0,
9730 "" },
9731
9732 /* handlers for sub-ioctl */
9733 { WE_SET_11D_STATE,
9734 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9735 0,
9736 "set11Dstate" },
9737
9738 { WE_WOWL,
9739 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9740 0,
9741 "wowl" },
9742
9743 { WE_SET_POWER,
9744 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9745 0,
9746 "setPower" },
9747
9748 { WE_SET_MAX_ASSOC,
9749 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9750 0,
9751 "setMaxAssoc" },
9752
9753 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
9754 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9755 0,
9756 "setAutoChannel" },
9757
9758 { WE_SET_DATA_INACTIVITY_TO,
9759 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9760 0,
9761 "inactivityTO" },
9762
9763 { WE_SET_MAX_TX_POWER,
9764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9765 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07009766 "setMaxTxPower" },
9767
9768 { WE_SET_MAX_TX_POWER_2_4,
9769 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9770 0,
9771 "setTxMaxPower2G" },
9772
9773 { WE_SET_MAX_TX_POWER_5_0,
9774 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9775 0,
9776 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07009777
9778 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
9779 * as well to keep same syntax as in SAP. Now onwards, STA
9780 * will support both */
9781 { WE_SET_MAX_TX_POWER,
9782 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9783 0,
9784 "setTxMaxPower" },
9785
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 /* set Higher DTIM Transition (DTIM1 to DTIM3)
9787 * 1 = enable and 0 = disable */
9788 {
9789 WE_SET_HIGHER_DTIM_TRANSITION,
9790 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9791 0,
9792 "setHDtimTransn" },
9793
9794 { WE_SET_TM_LEVEL,
9795 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009796 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 "setTmLevel" },
9798
Kiet Lam46b8e4e2013-11-06 21:49:53 +05309799 { WE_ENABLE_STRICT_FCC_REG,
9800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9801 0,
9802 "setStrictFCCreg" },
9803
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08009804 { WE_SET_DEBUG_LOG,
9805 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9806 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +05309807#ifdef FEATURE_WLAN_TDLS
9808 {
9809 WE_SET_TDLS_OFF_CHAN,
9810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9811 0,
9812 "tdlsoffchan" },
9813 {
9814 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
9815 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9816 0,
9817 "tdlsecchnoffst" },
9818 {
9819 WE_SET_TDLS_OFF_CHAN_MODE,
9820 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9821 0,
9822 "tdlsoffchnmode" },
9823#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08009824
Peng Xu2446a892014-09-05 17:21:18 +05309825 { WE_SET_SCAN_BAND_PREFERENCE,
9826 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9827 0, "set_scan_pref" },
9828
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 /* handlers for main ioctl */
9830 { WLAN_PRIV_SET_NONE_GET_INT,
9831 0,
9832 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9833 "" },
9834
9835 /* handlers for sub-ioctl */
9836 { WE_GET_11D_STATE,
9837 0,
9838 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9839 "get11Dstate" },
9840
9841 { WE_IBSS_STATUS,
9842 0,
9843 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9844 "getAdhocStatus" },
9845
9846 { WE_PMC_STATE,
9847 0,
9848 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9849 "pmcState" },
9850
9851 { WE_GET_WLAN_DBG,
9852 0,
9853 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9854 "getwlandbg" },
9855
Jeff Johnson295189b2012-06-20 16:38:30 -07009856 { WE_GET_MAX_ASSOC,
9857 0,
9858 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9859 "getMaxAssoc" },
9860
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 { WE_GET_WDI_DBG,
9862 0,
9863 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9864 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009865
9866 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
9867 0,
9868 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9869 "getAutoChannel" },
9870
9871 { WE_GET_CONCURRENCY_MODE,
9872 0,
9873 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9874 "getconcurrency" },
9875
Peng Xu2446a892014-09-05 17:21:18 +05309876 { WE_GET_SCAN_BAND_PREFERENCE,
9877 0,
9878 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9879 "get_scan_pref"},
9880
Jeff Johnson295189b2012-06-20 16:38:30 -07009881 /* handlers for main ioctl */
9882 { WLAN_PRIV_SET_CHAR_GET_NONE,
9883 IW_PRIV_TYPE_CHAR| 512,
9884 0,
9885 "" },
9886
9887 /* handlers for sub-ioctl */
9888 { WE_WOWL_ADD_PTRN,
9889 IW_PRIV_TYPE_CHAR| 512,
9890 0,
9891 "wowlAddPtrn" },
9892
9893 { WE_WOWL_DEL_PTRN,
9894 IW_PRIV_TYPE_CHAR| 512,
9895 0,
9896 "wowlDelPtrn" },
9897
9898#if defined WLAN_FEATURE_VOWIFI
9899 /* handlers for sub-ioctl */
9900 { WE_NEIGHBOR_REPORT_REQUEST,
9901 IW_PRIV_TYPE_CHAR | 512,
9902 0,
9903 "neighbor" },
9904#endif
9905 { WE_SET_AP_WPS_IE,
9906 IW_PRIV_TYPE_CHAR| 512,
9907 0,
9908 "set_ap_wps_ie" },
9909
9910 { WE_SET_CONFIG,
9911 IW_PRIV_TYPE_CHAR| 512,
9912 0,
9913 "setConfig" },
9914
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05309915 { WE_SET_ENCRYPT_MSG,
9916 IW_PRIV_TYPE_CHAR| 512,
9917 0,
9918 "encryptMsg" },
9919
9920
Jeff Johnson295189b2012-06-20 16:38:30 -07009921 /* handlers for main ioctl */
9922 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
9923 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9924 0,
9925 "" },
9926
9927 /* handlers for sub-ioctl */
9928 { WE_SET_WLAN_DBG,
9929 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9930 0,
9931 "setwlandbg" },
9932
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 { WE_SET_WDI_DBG,
9934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9935 0,
9936 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009937
9938 { WE_SET_SAP_CHANNELS,
9939 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9940 0,
9941 "setsapchannels" },
9942
9943 /* handlers for main ioctl */
9944 { WLAN_PRIV_GET_CHAR_SET_NONE,
9945 0,
9946 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9947 "" },
9948
9949 /* handlers for sub-ioctl */
9950 { WE_WLAN_VERSION,
9951 0,
9952 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9953 "version" },
9954 { WE_GET_STATS,
9955 0,
9956 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9957 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309958 { WE_GET_STATES,
9959 0,
9960 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9961 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 { WE_GET_CFG,
9963 0,
9964 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9965 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07009966#ifdef WLAN_FEATURE_11AC
9967 { WE_GET_RSSI,
9968 0,
9969 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9970 "getRSSI" },
9971#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009972#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009973 { WE_GET_ROAM_RSSI,
9974 0,
9975 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9976 "getRoamRSSI" },
9977#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009978 { WE_GET_WMM_STATUS,
9979 0,
9980 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9981 "getWmmStatus" },
9982 {
9983 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309984 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07009985 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9986 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08009987#ifdef FEATURE_WLAN_TDLS
9988 {
9989 WE_GET_TDLS_PEERS,
9990 0,
9991 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9992 "getTdlsPeers" },
9993#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009994#ifdef WLAN_FEATURE_11W
9995 {
9996 WE_GET_11W_INFO,
9997 0,
9998 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9999 "getPMFInfo" },
10000#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010001 { WE_GET_SNR,
10002 0,
10003 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10004 "getSNR" },
10005
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 /* handlers for main ioctl */
10007 { WLAN_PRIV_SET_NONE_GET_NONE,
10008 0,
10009 0,
10010 "" },
10011
10012 /* handlers for sub-ioctl */
10013 { WE_CLEAR_STATS,
10014 0,
10015 0,
10016 "clearStats" },
10017 { WE_INIT_AP,
10018 0,
10019 0,
10020 "initAP" },
10021 { WE_STOP_AP,
10022 0,
10023 0,
10024 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010025#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010026 { WE_ENABLE_AMP,
10027 0,
10028 0,
10029 "enableAMP" },
10030 { WE_DISABLE_AMP,
10031 0,
10032 0,
10033 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010034#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010035 { WE_ENABLE_DXE_STALL_DETECT,
10036 0,
10037 0,
10038 "dxeStallDetect" },
10039 { WE_DISPLAY_DXE_SNAP_SHOT,
10040 0,
10041 0,
10042 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010043 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10044 0,
10045 0,
10046 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010047 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010048 WE_SET_REASSOC_TRIGGER,
10049 0,
10050 0,
10051 "reassoc" },
10052 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010053 WE_STOP_OBSS_SCAN,
10054 0,
10055 0,
10056 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010057 {
10058 WE_DUMP_ROAM_TIMER_LOG,
10059 0,
10060 0,
10061 "dumpRoamDelay" },
10062 {
10063 WE_RESET_ROAM_TIMER_LOG,
10064 0,
10065 0,
10066 "resetRoamDelay" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010067 /* handlers for main ioctl */
10068 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10069 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10070 0,
10071 "" },
10072
10073 /* handlers for sub-ioctl */
10074 { WE_LOG_DUMP_CMD,
10075 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10076 0,
10077 "dump" },
10078
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010079 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010080 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10081 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10082 0,
10083 "setdumplog" },
10084
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010085 { WE_MTRACE_DUMP_CMD,
10086 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10087 0,
10088 "dumplog" },
10089
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010090 /* handlers for sub ioctl */
10091 {
10092 WE_MCC_CONFIG_CREDENTIAL,
10093 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10094 0,
10095 "setMccCrdnl" },
10096
10097 /* handlers for sub ioctl */
10098 {
10099 WE_MCC_CONFIG_PARAMS,
10100 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10101 0,
10102 "setMccConfig" },
10103
Chilam NG571c65a2013-01-19 12:27:36 +053010104#ifdef FEATURE_WLAN_TDLS
10105 /* handlers for sub ioctl */
10106 {
10107 WE_TDLS_CONFIG_PARAMS,
10108 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10109 0,
10110 "setTdlsConfig" },
10111#endif
10112
Jeff Johnson295189b2012-06-20 16:38:30 -070010113 /* handlers for main ioctl */
10114 { WLAN_PRIV_ADD_TSPEC,
10115 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10116 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10117 "addTspec" },
10118
10119 /* handlers for main ioctl */
10120 { WLAN_PRIV_DEL_TSPEC,
10121 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10123 "delTspec" },
10124
10125 /* handlers for main ioctl */
10126 { WLAN_PRIV_GET_TSPEC,
10127 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10129 "getTspec" },
10130
Jeff Johnsone7245742012-09-05 17:12:55 -070010131#ifdef FEATURE_OEM_DATA_SUPPORT
10132 /* handlers for main ioctl - OEM DATA */
10133 {
10134 WLAN_PRIV_SET_OEM_DATA_REQ,
10135 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10136 0,
10137 "set_oem_data_req" },
10138
10139 /* handlers for main ioctl - OEM DATA */
10140 {
10141 WLAN_PRIV_GET_OEM_DATA_RSP,
10142 0,
10143 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10144 "get_oem_data_rsp" },
10145#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010146
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 /* handlers for main ioctl - host offload */
10148 {
10149 WLAN_PRIV_SET_HOST_OFFLOAD,
10150 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10151 0,
10152 "setHostOffload" },
10153
10154 {
10155 WLAN_GET_WLAN_STATISTICS,
10156 0,
10157 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10158 "getWlanStats" },
10159
10160 {
10161 WLAN_SET_KEEPALIVE_PARAMS,
10162 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10163 0,
10164 "setKeepAlive" },
10165#ifdef WLAN_FEATURE_PACKET_FILTERING
10166 {
10167 WLAN_SET_PACKET_FILTER_PARAMS,
10168 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10169 0,
10170 "setPktFilter" },
10171#endif
10172#ifdef FEATURE_WLAN_SCAN_PNO
10173 {
10174 WLAN_SET_PNO,
10175 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10176 0,
10177 "setpno" },
10178#endif
10179 {
10180 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010181 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010182 0,
10183 "SETBAND" },
10184 /* handlers for dynamic MC BC ioctl */
10185 {
10186 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010187 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010188 0,
10189 "setMCBCFilter" },
10190 {
10191 WLAN_PRIV_CLEAR_MCBC_FILTER,
10192 0,
10193 0,
10194 "clearMCBCFilter" },
10195 {
10196 WLAN_SET_POWER_PARAMS,
10197 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10198 0,
10199 "setpowerparams" },
10200 {
10201 WLAN_GET_LINK_SPEED,
10202 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010203 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010204};
10205
10206
10207
10208const struct iw_handler_def we_handler_def = {
10209 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10210 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10211 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10212
10213 .standard = (iw_handler *)we_handler,
10214 .private = (iw_handler *)we_private,
10215 .private_args = we_private_args,
10216 .get_wireless_stats = get_wireless_stats,
10217};
10218
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010219int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10220{
10221 v_U32_t cmd = 288; //Command to RIVA
10222 hdd_context_t *pHddCtx = NULL;
10223 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10224 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10225 /*
10226 *configMccParam : specify the bit which needs to be modified
10227 *allowed to update based on wlan_qcom_cfg.ini
10228 * configuration
10229 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10230 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10231 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10232 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10233 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10234 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10235 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10236 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10237 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10238 * Bit 9 : Reserved
10239 */
10240 switch (arg1)
10241 {
10242 //Update MCC SCHEDULE_TIME_SLICE parameter
10243 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10244 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10245 {
10246 if((arg2 >= 5) && (arg2 <= 20))
10247 {
10248 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10249 }
10250 else
10251 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010252 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010253 return 0;
10254 }
10255 }
10256 break;
10257
10258 //Update MCC MAX_NULL_SEND_TIME parameter
10259 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10260 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10261 {
10262 if((arg2 >= 1) && (arg2 <= 10))
10263 {
10264 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10265 }
10266 else
10267 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010268 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010269 return 0;
10270 }
10271 }
10272 break;
10273
10274 //Update MCC TX_EARLY_STOP_TIME parameter
10275 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10276 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10277 {
10278 if((arg2 >= 1) && (arg2 <= 10))
10279 {
10280 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10281 }
10282 else
10283 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010284 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010285 return 0;
10286 }
10287 }
10288 break;
10289
10290 //Update MCC RX_DRAIN_TIME parameter
10291 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10292 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10293 {
10294 if((arg2 >= 1) && (arg2 <= 10))
10295 {
10296 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10297 }
10298 else
10299 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010300 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010301 return 0;
10302 }
10303 }
10304 break;
10305
10306 //Update MCC CHANNEL_SWITCH_TIME parameter
10307 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10308 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10309 {
10310 if((arg2 >= 1) && (arg2 <= 20))
10311 {
10312 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10313 }
10314 else
10315 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010316 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010317 return 0;
10318 }
10319 }
10320 break;
10321
10322 //Update MCC MIN_CHANNEL_TIME parameter
10323 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10324 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10325 {
10326 if((arg2 >= 5) && (arg2 <= 20))
10327 {
10328 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10329 }
10330 else
10331 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010332 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010333 return 0;
10334 }
10335 }
10336 break;
10337
10338 //Update MCC PARK_BEFORE_TBTT parameter
10339 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10340 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10341 {
10342 if((arg2 >= 1) && (arg2 <= 5))
10343 {
10344 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10345 }
10346 else
10347 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010348 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010349 return 0;
10350 }
10351 }
10352 break;
10353
10354 //Update MCC MIN_AFTER_DTIM parameter
10355 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10356 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10357 {
10358 if((arg2 >= 5) && (arg2 <= 15))
10359 {
10360 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10361 }
10362 else
10363 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010364 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010365 return 0;
10366 }
10367 }
10368 break;
10369
10370 //Update MCC TOO_CLOSE_MARGIN parameter
10371 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10372 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10373 {
10374 if((arg2 >= 1) && (arg2 <= 3))
10375 {
10376 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10377 }
10378 else
10379 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010380 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010381 return 0;
10382 }
10383 }
10384 break;
10385
10386 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010387 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010388 __FUNCTION__,arg1);
10389 break;
10390 }
10391 return 0;
10392}
10393
Jeff Johnson295189b2012-06-20 16:38:30 -070010394int hdd_set_wext(hdd_adapter_t *pAdapter)
10395{
10396 hdd_wext_state_t *pwextBuf;
10397 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010398 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010399
10400 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10401
10402 // Now configure the roaming profile links. To SSID and bssid.
10403 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10404 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10405
10406 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10407 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10408
10409 /*Set the numOfChannels to zero to scan all the channels*/
10410 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10411 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10412
10413 /* Default is no encryption */
10414 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10415 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10416
10417 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10418 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10419
10420 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10421
10422 /* Default is no authentication */
10423 pwextBuf->roamProfile.AuthType.numEntries = 1;
10424 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10425
10426 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10427 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10428
10429 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010430 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010431
10432 hdd_clearRoamProfileIe(pAdapter);
10433
10434 return VOS_STATUS_SUCCESS;
10435
10436 }
10437
10438int hdd_register_wext(struct net_device *dev)
10439 {
10440 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10441 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10442 VOS_STATUS status;
10443
10444 ENTER();
10445
10446 // Zero the memory. This zeros the profile structure.
10447 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10448
10449 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10450
10451
10452 status = hdd_set_wext(pAdapter);
10453
10454 if(!VOS_IS_STATUS_SUCCESS(status)) {
10455
Arif Hussain6d2a3322013-11-17 19:50:10 -080010456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 return eHAL_STATUS_FAILURE;
10458 }
10459
10460 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10461 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010463 return eHAL_STATUS_FAILURE;
10464 }
10465
10466 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10467 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 return eHAL_STATUS_FAILURE;
10470 }
10471
10472 // Register as a wireless device
10473 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10474
10475 EXIT();
10476 return 0;
10477}
10478
10479int hdd_UnregisterWext(struct net_device *dev)
10480{
c_hpothu2a13bc32015-01-21 12:48:54 +053010481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10482 if (dev != NULL)
10483 {
10484 rtnl_lock();
10485 dev->wireless_handlers = NULL;
10486 rtnl_unlock();
10487 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010488
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 return 0;
10490}
10491
10492