blob: e6cb53b55f137de0567737daafea69bbfd93d9a4 [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
Abhishek Singh2ec36ab2014-08-07 16:14:25 +0530358/*
359 * When supplicant sends SETBAND ioctl it queries for channels from
360 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
361 * This is not required if the return type from ioctl is
362 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
363 * event as part of regulatory_hint.
364 */
365enum {
366 SEND_CHANNEL_CHANGE_EVENT = 0,
367 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
368};
369
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800370/*MCC Configuration parameters */
371enum {
372 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
373 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
374 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
375 MCC_RX_DRAIN_TIME_CFG_PARAM,
376 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
377 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
378 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
379 MCC_MIN_AFTER_DTIM_CFG_PARAM,
380 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
381};
382
383int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
384 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
385
Jeff Johnson295189b2012-06-20 16:38:30 -0700386#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800387int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700388 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700389#endif
390
Jeff Johnson295189b2012-06-20 16:38:30 -0700391/**---------------------------------------------------------------------------
392
Arif Hussain0273cba2014-01-07 20:58:29 -0800393 \brief mem_alloc_copy_from_user_helper -
394
395 Helper function to allocate buffer and copy user data.
396
397 \param - wrqu - Pointer to IOCTL Data.
398 len - size
399
400 \return - On Success pointer to buffer, On failure NULL
401
402 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530403void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800404{
405 u8 *ptr = NULL;
406
407 /* in order to protect the code, an extra byte is post appended to the buffer
408 * and the null termination is added. However, when allocating (len+1) byte
409 * of memory, we need to make sure that there is no uint overflow when doing
410 * addition. In theory check len < UINT_MAX protects the uint overflow. For
411 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
412 * guess, now, it is assumed that the private command buffer size is no
413 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
414 */
415 if (len > MAX_USER_COMMAND_SIZE)
416 {
417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
418 "Invalid length");
419 return NULL;
420 }
421
422 ptr = kmalloc(len + 1, GFP_KERNEL);
423 if (NULL == ptr)
424 {
425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
426 "unable to allocate memory");
427 return NULL;
428 }
429
430 if (copy_from_user(ptr, wrqu_data, len))
431 {
432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
433 "%s: failed to copy data to user buffer", __func__);
434 kfree(ptr);
435 return NULL;
436 }
437 ptr[len] = '\0';
438 return ptr;
439}
440
Girish Gowli488ef492014-06-12 18:44:33 +0530441// Function to handle and get compatible struct iw_point passed to ioctl.
442int hdd_priv_get_data(struct iw_point *p_priv_data,
443 union iwreq_data *wrqu)
444{
445 if ((NULL == p_priv_data) || (NULL == wrqu))
446 {
447 return -EINVAL;
448 }
449
450#ifdef CONFIG_COMPAT
451 if (is_compat_task())
452 {
453 struct compat_iw_point *p_compat_priv_data;
454
455 // Compat task: typecast to campat structure and copy the members.
456 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
457
458 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
459 p_priv_data->length = p_compat_priv_data->length;
460 p_priv_data->flags = p_compat_priv_data->flags;
461 }//if(is_compat_task())
462 else
463 {
464#endif //#ifdef CONFIG_COMPAT
465
466 // Non compat task: directly copy the structure.
467 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
468
469#ifdef CONFIG_COMPAT
470 }//else of - if(is_compat_task())
471#endif //#ifdef CONFIG_COMPAT
472
473 return 0;
474}
475
Arif Hussain0273cba2014-01-07 20:58:29 -0800476/**---------------------------------------------------------------------------
477
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 \brief hdd_wlan_get_version() -
479
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800480 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700481
482 \param - pAdapter Pointer to the adapter.
483 wrqu - Pointer to IOCTL REQUEST Data.
484 extra - Pointer to char
485
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800486 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700487
488 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800489void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
490 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700491{
492 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800493 tSirVersionString wcnss_SW_version;
494 tSirVersionString wcnss_HW_version;
495 char *pSWversion;
496 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800499 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
500 sizeof(wcnss_SW_version));
501 if (VOS_IS_STATUS_SUCCESS(status))
502 {
503 pSWversion = wcnss_SW_version;
504 }
505 else
506 {
507 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 }
509
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800510 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
511 sizeof(wcnss_HW_version));
512 if (VOS_IS_STATUS_SUCCESS(status))
513 {
514 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800516 else
517 {
518 pHWversion = "Unknown";
519 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700520
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700521 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800522 "Host SW:%s, FW:%s, HW:%s",
523 QWLAN_VERSIONSTR,
524 pSWversion,
525 pHWversion);
526
527 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700528}
529
Jeff Johnson295189b2012-06-20 16:38:30 -0700530int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
531{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530532 tHalHandle hHal;
533 hdd_context_t *pHddCtx;
534 v_U32_t threshold = 0;
535 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700536
537 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530538 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530539 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
541 "%s: Adapter is NULL",__func__);
542 return -EINVAL;
543 }
544
545 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
546 ret = wlan_hdd_validate_context(pHddCtx);
547 if (0 != ret)
548 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530549 return ret;
550 }
551
552 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
553 if (NULL == hHal)
554 {
555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
556 "%s: Hal Context is NULL",__func__);
557 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 }
559
560 if ( eHAL_STATUS_SUCCESS !=
561 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
562 {
c_hpothub8245442013-11-20 23:41:09 +0530563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
564 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 return -EIO;
566 }
567 wrqu->rts.value = threshold;
568
569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800570 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700571
572 EXIT();
573
574 return 0;
575}
576
577int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
578{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530579 tHalHandle hHal;
580 hdd_context_t *pHddCtx;
581 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700582
583 ENTER();
584
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530585 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530586 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
588 "%s: Adapter is NULL",__func__);
589 return -EINVAL;
590 }
591
592 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
593 status = wlan_hdd_validate_context(pHddCtx);
594 if (0 != status)
595 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530596 return status;
597 }
598
599 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
600 if (NULL == hHal)
601 {
602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
603 "%s: Hal Context is NULL",__func__);
604 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 }
606
607 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
608 != eHAL_STATUS_SUCCESS )
609 {
c_hpothub8245442013-11-20 23:41:09 +0530610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
611 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 return -EIO;
613 }
614 wrqu->frag.value = threshold;
615
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800617 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700618
619 EXIT();
620
621 return 0;
622}
623
624int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
625{
Jeff Johnsone7245742012-09-05 17:12:55 -0700626 int i;
627 if (channel > 0)
628 {
629 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
630 {
631 if (channel == freq_chan_map[i].chan)
632 {
633 *pfreq = freq_chan_map[i].freq;
634 return 1;
635 }
636 }
637 }
638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800639 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700640 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700641}
642
643static v_BOOL_t
644hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
645{
646 v_BOOL_t rsnType = VOS_FALSE;
647 // is the authType supported?
648 switch (authType)
649 {
650 case eCSR_AUTH_TYPE_NONE: //never used
651 rsnType = eANI_BOOLEAN_FALSE;
652 break;
653 // MAC layer authentication types
654 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
655 rsnType = eANI_BOOLEAN_FALSE;
656 break;
657 case eCSR_AUTH_TYPE_SHARED_KEY:
658 rsnType = eANI_BOOLEAN_FALSE;
659 break;
660 case eCSR_AUTH_TYPE_AUTOSWITCH:
661 rsnType = eANI_BOOLEAN_FALSE;
662 break;
663
664 // Upper layer authentication types
665 case eCSR_AUTH_TYPE_WPA:
666 rsnType = eANI_BOOLEAN_TRUE;
667 break;
668 case eCSR_AUTH_TYPE_WPA_PSK:
669 rsnType = eANI_BOOLEAN_TRUE;
670 break;
671 case eCSR_AUTH_TYPE_WPA_NONE:
672 rsnType = eANI_BOOLEAN_TRUE;
673 break;
674#ifdef WLAN_FEATURE_VOWIFI_11R
675 case eCSR_AUTH_TYPE_FT_RSN:
676#endif
677 case eCSR_AUTH_TYPE_RSN:
678 rsnType = eANI_BOOLEAN_TRUE;
679 break;
680#ifdef WLAN_FEATURE_VOWIFI_11R
681 case eCSR_AUTH_TYPE_FT_RSN_PSK:
682#endif
683 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700684#ifdef WLAN_FEATURE_11W
685 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530686 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700687#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 rsnType = eANI_BOOLEAN_TRUE;
689 break;
690 //case eCSR_AUTH_TYPE_FAILED:
691 case eCSR_AUTH_TYPE_UNKNOWN:
692 rsnType = eANI_BOOLEAN_FALSE;
693 break;
694 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800695 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
696 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 rsnType = eANI_BOOLEAN_FALSE;
698 break;
699 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800700 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700701 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 return rsnType;
703}
704
705static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
706{
707 struct statsContext *pStatsContext;
708 hdd_adapter_t *pAdapter;
709
710 if (ioctl_debug)
711 {
712 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700713 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 }
715
716 if (NULL == pContext)
717 {
718 hddLog(VOS_TRACE_LEVEL_ERROR,
719 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700720 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 return;
722 }
723
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 pStatsContext = pContext;
725 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800726
727 /* there is a race condition that exists between this callback
728 function and the caller since the caller could time out either
729 before or while this code is executing. we use a spinlock to
730 serialize these actions */
731 spin_lock(&hdd_context_lock);
732
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
734 {
735 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800736 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 hddLog(VOS_TRACE_LEVEL_WARN,
738 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700739 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 if (ioctl_debug)
741 {
742 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700743 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 }
745 return;
746 }
747
Jeff Johnson72a40512013-12-19 10:14:15 -0800748 /* context is valid so caller is still waiting */
749
750 /* paranoia: invalidate the magic */
751 pStatsContext->magic = 0;
752
753 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 pAdapter->rssi = rssi;
755
Jeff Johnson72a40512013-12-19 10:14:15 -0800756 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800758
759 /* serialization is complete */
760 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700761}
762
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530763static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
764{
765 struct statsContext *pStatsContext;
766 hdd_adapter_t *pAdapter;
767
768 if (ioctl_debug)
769 {
770 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
771 __func__, (int)snr, (int)staId, pContext);
772 }
773
774 if (NULL == pContext)
775 {
776 hddLog(VOS_TRACE_LEVEL_ERROR,
777 "%s: Bad param, pContext [%p]",
778 __func__, pContext);
779 return;
780 }
781
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530782 pStatsContext = pContext;
783 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800784
785 /* there is a race condition that exists between this callback
786 function and the caller since the caller could time out either
787 before or while this code is executing. we use a spinlock to
788 serialize these actions */
789 spin_lock(&hdd_context_lock);
790
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530791 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
792 {
793 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800794 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530795 hddLog(VOS_TRACE_LEVEL_WARN,
796 "%s: Invalid context, pAdapter [%p] magic [%08x]",
797 __func__, pAdapter, pStatsContext->magic);
798 if (ioctl_debug)
799 {
800 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
801 __func__, pAdapter, pStatsContext->magic);
802 }
803 return;
804 }
805
Jeff Johnson72a40512013-12-19 10:14:15 -0800806 /* context is valid so caller is still waiting */
807
808 /* paranoia: invalidate the magic */
809 pStatsContext->magic = 0;
810
811 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530812 pAdapter->snr = snr;
813
Jeff Johnson72a40512013-12-19 10:14:15 -0800814 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530815 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800816
817 /* serialization is complete */
818 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530819}
820
Jeff Johnson295189b2012-06-20 16:38:30 -0700821VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
822{
823 struct statsContext context;
824 hdd_context_t *pHddCtx;
825 hdd_station_ctx_t *pHddStaCtx;
826 eHalStatus hstatus;
827 long lrc;
828
829 if (NULL == pAdapter)
830 {
831 hddLog(VOS_TRACE_LEVEL_WARN,
832 "%s: Invalid context, pAdapter", __func__);
833 return VOS_STATUS_E_FAULT;
834 }
835 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
836 {
837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
838 /* return a cached value */
839 *rssi_value = pAdapter->rssi;
840 return VOS_STATUS_SUCCESS;
841 }
842
843 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
844 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
845
846 init_completion(&context.completion);
847 context.pAdapter = pAdapter;
848 context.magic = RSSI_CONTEXT_MAGIC;
849
850 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
851 pHddStaCtx->conn_info.staId[ 0 ],
852 pHddStaCtx->conn_info.bssId,
853 &context, pHddCtx->pvosContext);
854 if (eHAL_STATUS_SUCCESS != hstatus)
855 {
856 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700857 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 /* we'll returned a cached value below */
859 }
860 else
861 {
862 /* request was sent -- wait for the response */
863 lrc = wait_for_completion_interruptible_timeout(&context.completion,
864 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 if (lrc <= 0)
866 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800867 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700868 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 /* we'll now returned a cached value below */
870 }
871 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800872
873 /* either we never sent a request, we sent a request and received a
874 response or we sent a request and timed out. if we never sent a
875 request or if we sent a request and got a response, we want to
876 clear the magic out of paranoia. if we timed out there is a
877 race condition such that the callback function could be
878 executing at the same time we are. of primary concern is if the
879 callback function had already verified the "magic" but had not
880 yet set the completion variable when a timeout occurred. we
881 serialize these activities by invalidating the magic while
882 holding a shared spinlock which will cause us to block if the
883 callback is currently executing */
884 spin_lock(&hdd_context_lock);
885 context.magic = 0;
886 spin_unlock(&hdd_context_lock);
887
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 *rssi_value = pAdapter->rssi;
889
890 return VOS_STATUS_SUCCESS;
891}
892
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530893VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
894{
895 struct statsContext context;
896 hdd_context_t *pHddCtx;
897 hdd_station_ctx_t *pHddStaCtx;
898 eHalStatus hstatus;
899 long lrc;
900 int valid;
901
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530902 ENTER();
903
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530904 if (NULL == pAdapter)
905 {
906 hddLog(VOS_TRACE_LEVEL_ERROR,
907 "%s: Invalid context, pAdapter", __func__);
908 return VOS_STATUS_E_FAULT;
909 }
910
911 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
912
913 valid = wlan_hdd_validate_context(pHddCtx);
914 if (0 != valid)
915 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530916 return VOS_STATUS_E_FAULT;
917 }
918
919 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
920 if (NULL == pHddStaCtx)
921 {
922 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
923 return VOS_STATUS_E_FAULT;
924 }
925
926 init_completion(&context.completion);
927 context.pAdapter = pAdapter;
928 context.magic = SNR_CONTEXT_MAGIC;
929
930 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
931 pHddStaCtx->conn_info.staId[ 0 ],
932 pHddStaCtx->conn_info.bssId,
933 &context);
934 if (eHAL_STATUS_SUCCESS != hstatus)
935 {
936 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
937 __func__);
938 /* we'll returned a cached value below */
939 }
940 else
941 {
942 /* request was sent -- wait for the response */
943 lrc = wait_for_completion_interruptible_timeout(&context.completion,
944 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530945 if (lrc <= 0)
946 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800947 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530948 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530949 /* we'll now returned a cached value below */
950 }
951 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800952
953 /* either we never sent a request, we sent a request and received a
954 response or we sent a request and timed out. if we never sent a
955 request or if we sent a request and got a response, we want to
956 clear the magic out of paranoia. if we timed out there is a
957 race condition such that the callback function could be
958 executing at the same time we are. of primary concern is if the
959 callback function had already verified the "magic" but had not
960 yet set the completion variable when a timeout occurred. we
961 serialize these activities by invalidating the magic while
962 holding a shared spinlock which will cause us to block if the
963 callback is currently executing */
964 spin_lock(&hdd_context_lock);
965 context.magic = 0;
966 spin_unlock(&hdd_context_lock);
967
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530968 *snr = pAdapter->snr;
969
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +0530970 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530971 return VOS_STATUS_SUCCESS;
972}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800973#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800974
975static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
976{
977 struct statsContext *pStatsContext;
978 hdd_adapter_t *pAdapter;
979 if (ioctl_debug)
980 {
981 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
982 __func__, (int)rssi, (int)staId, pContext);
983 }
984
985 if (NULL == pContext)
986 {
987 hddLog(VOS_TRACE_LEVEL_ERROR,
988 "%s: Bad param, pContext [%p]",
989 __func__, pContext);
990 return;
991 }
992
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800993 pStatsContext = pContext;
994 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800995
996 /* there is a race condition that exists between this callback
997 function and the caller since the caller could time out either
998 before or while this code is executing. we use a spinlock to
999 serialize these actions */
1000 spin_lock(&hdd_context_lock);
1001
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001002 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1003 {
1004 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001005 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001006 hddLog(VOS_TRACE_LEVEL_WARN,
1007 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1008 __func__, pAdapter, pStatsContext->magic);
1009 if (ioctl_debug)
1010 {
1011 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1012 __func__, pAdapter, pStatsContext->magic);
1013 }
1014 return;
1015 }
1016
Jeff Johnson72a40512013-12-19 10:14:15 -08001017 /* context is valid so caller is still waiting */
1018
1019 /* paranoia: invalidate the magic */
1020 pStatsContext->magic = 0;
1021
1022 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001023 pAdapter->rssi = rssi;
1024
Jeff Johnson72a40512013-12-19 10:14:15 -08001025 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001026 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001027
1028 /* serialization is complete */
1029 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001030}
1031
1032
1033
1034VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1035{
1036 struct statsContext context;
1037 hdd_context_t *pHddCtx = NULL;
1038 hdd_station_ctx_t *pHddStaCtx = NULL;
1039 eHalStatus hstatus;
1040 long lrc;
1041
1042 if (NULL == pAdapter)
1043 {
1044 hddLog(VOS_TRACE_LEVEL_WARN,
1045 "%s: Invalid context, pAdapter", __func__);
1046 return VOS_STATUS_E_FAULT;
1047 }
1048 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1049 {
1050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1051 /* return a cached value */
1052 *rssi_value = pAdapter->rssi;
1053 return VOS_STATUS_SUCCESS;
1054 }
1055
1056 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1057 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1058
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301059 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001060 {
1061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1062 /* return a cached value */
1063 *rssi_value = 0;
1064 return VOS_STATUS_SUCCESS;
1065 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301066
1067 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1068 {
1069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1070 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1071 *rssi_value = pAdapter->rssi;
1072 return VOS_STATUS_SUCCESS;
1073 }
1074
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001075 init_completion(&context.completion);
1076 context.pAdapter = pAdapter;
1077 context.magic = RSSI_CONTEXT_MAGIC;
1078
1079 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1080 pHddStaCtx->conn_info.staId[ 0 ],
1081 pHddStaCtx->conn_info.bssId,
1082 &context, pHddCtx->pvosContext);
1083 if (eHAL_STATUS_SUCCESS != hstatus)
1084 {
1085 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1086 __func__);
1087 /* we'll returned a cached value below */
1088 }
1089 else
1090 {
1091 /* request was sent -- wait for the response */
1092 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1093 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001094 if (lrc <= 0)
1095 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001096 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001097 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001098 /* we'll now returned a cached value below */
1099 }
1100 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001101
1102 /* either we never sent a request, we sent a request and received a
1103 response or we sent a request and timed out. if we never sent a
1104 request or if we sent a request and got a response, we want to
1105 clear the magic out of paranoia. if we timed out there is a
1106 race condition such that the callback function could be
1107 executing at the same time we are. of primary concern is if the
1108 callback function had already verified the "magic" but had not
1109 yet set the completion variable when a timeout occurred. we
1110 serialize these activities by invalidating the magic while
1111 holding a shared spinlock which will cause us to block if the
1112 callback is currently executing */
1113 spin_lock(&hdd_context_lock);
1114 context.magic = 0;
1115 spin_unlock(&hdd_context_lock);
1116
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001117 *rssi_value = pAdapter->rssi;
1118
1119 return VOS_STATUS_SUCCESS;
1120}
1121#endif
1122
1123
Jeff Johnson295189b2012-06-20 16:38:30 -07001124void hdd_StatisticsCB( void *pStats, void *pContext )
1125{
1126 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1127 hdd_stats_t *pStatsCache = NULL;
1128 hdd_wext_state_t *pWextState;
1129 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1130
1131 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1132 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1133 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1134 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1135 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1136 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1137
1138 if (pAdapter!= NULL)
1139 pStatsCache = &pAdapter->hdd_stats;
1140
1141
1142 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1143 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1144 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1145 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1146 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1147 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1148
1149 if (pStatsCache!=NULL)
1150 {
1151 // and copy the stats into the cache we keep in the adapter instance structure
1152 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1153 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1154 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1155 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1156 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1157 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1158 }
1159
1160 if(pAdapter)
1161 {
1162 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1163 if(pWextState)
1164 {
1165 vos_status = vos_event_set(&pWextState->vosevent);
1166 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1167 {
1168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001169 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001170 return;
1171 }
1172 }
1173 }
1174}
1175
1176void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1177{
1178 v_CONTEXT_t pVosContext;
1179 hdd_context_t *pHddCtx;
1180 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1181#if 0
1182 hdd_wext_state_t *pWextState;
1183 v_U32_t roamId;
1184#endif
1185
1186 ENTER();
1187
1188 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1189
1190 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1191 if (NULL == pHddCtx)
1192 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001193 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 return;
1195 }
1196#if 0
1197 pWextState = pAdapter->pWextState;
1198#endif
1199
1200 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1201 {
1202 //TODO Verify is this is really used. If yes need to fix it.
1203 hdd_reconnect_all_adapters( pHddCtx );
1204#if 0
1205 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1206 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1207 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1208
1209 if(VOS_STATUS_SUCCESS == vosStatus)
1210 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1211 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1212
1213 sme_RoamConnect(halHandle,
1214 pAdapter->sessionId, &(pWextState->roamProfile),
1215 &roamId);
1216#endif
1217 }
1218
1219 EXIT();
1220
1221}
1222
1223void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1224{
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1226
1227 /* clear WPA/RSN/WSC IE information in the profile */
1228 pWextState->roamProfile.nWPAReqIELength = 0;
1229 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1230 pWextState->roamProfile.nRSNReqIELength = 0;
1231 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1232
Chet Lanctot186b5732013-03-18 10:26:30 -07001233#ifdef FEATURE_WLAN_WAPI
1234 pWextState->roamProfile.nWAPIReqIELength = 0;
1235 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1236#endif
1237
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001239 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301241 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1243 pWextState->roamProfile.nAddIEAssocLength = 0;
1244
1245 pWextState->roamProfile.EncryptionType.numEntries = 1;
1246 pWextState->roamProfile.EncryptionType.encryptionType[0]
1247 = eCSR_ENCRYPT_TYPE_NONE;
1248
1249 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1250 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1251 = eCSR_ENCRYPT_TYPE_NONE;
1252
1253 pWextState->roamProfile.AuthType.numEntries = 1;
1254 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1255
Chet Lanctot186b5732013-03-18 10:26:30 -07001256#ifdef WLAN_FEATURE_11W
1257 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1258 pWextState->roamProfile.MFPRequired = 0;
1259 pWextState->roamProfile.MFPCapable = 0;
1260#endif
1261
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 pWextState->authKeyMgmt = 0;
1263
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301264 vos_mem_zero(&pWextState->roamProfile.Keys,
1265 sizeof(pWextState->roamProfile.Keys));
1266
Jeff Johnson295189b2012-06-20 16:38:30 -07001267#ifdef FEATURE_WLAN_WAPI
1268 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1269 pAdapter->wapi_info.nWapiMode = 0;
1270#endif
1271
1272 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1273
1274}
1275
1276void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1277{
1278 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001279
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001280 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1281 {
1282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1283 "%s: Invalid pAdapter magic", __func__);
1284 }
1285 else
1286 {
1287 complete(&pAdapter->ula_complete);
1288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001289}
1290
1291VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1292{
1293 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001295 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001296
1297 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1298 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001299 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001300
1301 /*To avoid race condition between the set key and the last EAPOL
1302 packet, notify TL to finish upper layer authentication incase if the
1303 last EAPOL packet pending in the TL queue.*/
Nirav Shah4f765af2015-01-21 19:51:30 +05301304 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter,
1305 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1306 pHddStaCtx->conn_info.staId[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001307
Nirav Shah4f765af2015-01-21 19:51:30 +05301308 if ( vos_status == VOS_STATUS_E_ALREADY )
1309 {
1310 return VOS_STATUS_SUCCESS;
1311 }
1312 else if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 {
1314 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1315 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1316 __LINE__, vos_status );
1317 return vos_status;
1318
1319 }
1320
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001321 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301323 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001324 {
1325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301326 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001327 /* we'll still fall through and return success since the
1328 * connection may still get established but is just taking
1329 * too long for us to wait */
1330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 }
1332 return VOS_STATUS_SUCCESS;
1333}
1334
1335v_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)
1336{
1337
1338 int left = ie_len;
1339 v_U8_t *ptr = ie;
1340 v_U8_t elem_id,elem_len;
1341 v_U8_t eid = 0xDD;
1342
1343 if ( NULL == ie || 0 == ie_len )
1344 return NULL;
1345
1346 while(left >= 2)
1347 {
1348 elem_id = ptr[0];
1349 elem_len = ptr[1];
1350 left -= 2;
1351 if(elem_len > left)
1352 {
1353 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001354 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 eid,elem_len,left);
1356 return NULL;
1357 }
1358 if (elem_id == eid)
1359 {
1360 if(memcmp( &ptr[2], oui, oui_size)==0)
1361 return ptr;
1362 }
1363
1364 left -= elem_len;
1365 ptr += (elem_len + 2);
1366 }
1367 return NULL;
1368}
1369
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301370static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 union iwreq_data *wrqu, char *extra)
1372{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301373 hdd_adapter_t *pAdapter;
1374 hdd_context_t *pHddCtx;
1375 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301376
1377 ENTER();
1378
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301379 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1380 if (NULL == pAdapter)
1381 {
1382 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1383 "%s: pAdapter is NULL\n", __func__);
1384 return -EINVAL;
1385 }
1386 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1387 ret = wlan_hdd_validate_context(pHddCtx);
1388 if (0 != ret)
1389 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301390 return ret;
1391 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301392
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301394
1395 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301396 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001397}
1398
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301399static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1400 union iwreq_data *wrqu, char *extra)
1401{
1402 int ret;
1403
1404 vos_ssr_protect(__func__);
1405 ret = __iw_set_commit(dev, info, wrqu, extra);
1406 vos_ssr_unprotect(__func__);
1407
1408 return ret;
1409}
1410
1411static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 struct iw_request_info *info,
1413 char *wrqu, char *extra)
1414{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301415 hdd_adapter_t *pAdapter;
1416 hdd_context_t *pHddCtx;
1417 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301418
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301420 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1421 if (NULL == pAdapter)
1422 {
1423 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1424 "%s: pAdapter is NULL\n", __func__);
1425 return -EINVAL;
1426 }
1427 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1428 ret = wlan_hdd_validate_context(pHddCtx);
1429 if (0 != ret)
1430 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301431 return ret;
1432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1434 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301435 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001436}
1437
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301438static int iw_get_name(struct net_device *dev,
1439 struct iw_request_info *info,
1440 char *wrqu, char *extra)
1441{
1442 int ret;
1443
1444 vos_ssr_protect(__func__);
1445 ret = __iw_get_name(dev, info, wrqu, extra);
1446 vos_ssr_unprotect(__func__);
1447
1448 return ret;
1449}
1450
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301451static int __iw_set_mode(struct net_device *dev,
1452 struct iw_request_info *info,
1453 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001454{
1455 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301456 hdd_adapter_t *pAdapter;
1457 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 tCsrRoamProfile *pRoamProfile;
1459 eCsrRoamBssType LastBSSType;
1460 eMib_dot11DesiredBssType connectedBssType;
1461 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301463 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001464
1465 ENTER();
1466
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301467 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 if (NULL == pAdapter)
1469 {
1470 hddLog(VOS_TRACE_LEVEL_WARN,
1471 "%s: Invalid context, pAdapter", __func__);
1472 return 0;
1473 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301474 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1475 status = wlan_hdd_validate_context(pHddCtx);
1476 if (0 != status)
1477 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301478 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 }
1480
1481 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1482 if (pWextState == NULL)
1483 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301484 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001485 return -EINVAL;
1486 }
1487
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 pRoamProfile = &pWextState->roamProfile;
1490 LastBSSType = pRoamProfile->BSSType;
1491
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301492 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
1494 switch (wrqu->mode)
1495 {
1496 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301497 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1499 // Set the phymode correctly for IBSS.
1500 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1501 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001502 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 break;
1505 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301506 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 break;
1510 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301511 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1513 break;
1514 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301515 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 return -EOPNOTSUPP;
1517 }
1518
1519 if ( LastBSSType != pRoamProfile->BSSType )
1520 {
1521 //the BSS mode changed
1522 // We need to issue disconnect if connected or in IBSS disconnect state
1523 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1524 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1525 {
1526 VOS_STATUS vosStatus;
1527 // need to issue a disconnect to CSR.
1528 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1529 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1530 pAdapter->sessionId,
1531 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1532 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301533 {
1534 long ret;
1535 ret = wait_for_completion_interruptible_timeout(
1536 &pAdapter->disconnect_comp_var,
1537 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1538 if (ret <= 0)
1539 hddLog(VOS_TRACE_LEVEL_ERROR,
1540 FL("failed wait on disconnect_comp_var %ld"), ret);
1541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 }
1543 }
1544
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 EXIT();
1546 return 0;
1547}
1548
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301549static int iw_set_mode(struct net_device *dev,
1550 struct iw_request_info *info,
1551 union iwreq_data *wrqu, char *extra)
1552{
1553 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001554
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301555 vos_ssr_protect(__func__);
1556 ret = __iw_set_mode(dev, info, wrqu, extra);
1557 vos_ssr_unprotect(__func__);
1558
1559 return ret;
1560}
1561
1562static int __iw_get_mode(struct net_device *dev,
1563 struct iw_request_info *info,
1564 union iwreq_data *wrqu,
1565 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001566{
1567
1568 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301569 hdd_adapter_t *pAdapter;
1570 hdd_context_t *pHddCtx;
1571 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001572
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301573 ENTER();
1574
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301575 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 if (NULL == pAdapter)
1577 {
1578 hddLog(VOS_TRACE_LEVEL_WARN,
1579 "%s: Invalid context, pAdapter", __func__);
1580 return 0;
1581 }
1582
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301583 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1584 ret = wlan_hdd_validate_context(pHddCtx);
1585 if (0 != ret)
1586 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301587 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1590 if (pWextState == NULL)
1591 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301592 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 return -EINVAL;
1594 }
1595
1596 switch (pWextState->roamProfile.BSSType)
1597 {
1598 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001599 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301600 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 break;
1602 case eCSR_BSS_TYPE_IBSS:
1603 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001604 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301605 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 break;
1607 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001608 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301609 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 break;
1611 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001612 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 break;
1614 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301615
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301616 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 return 0;
1618}
1619
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301620static int iw_get_mode(struct net_device *dev,
1621 struct iw_request_info *info,
1622 union iwreq_data *wrqu,
1623 char *extra)
1624{
1625 int ret;
1626
1627 vos_ssr_protect(__func__);
1628 ret = __iw_get_mode(dev, info, wrqu, extra);
1629 vos_ssr_unprotect(__func__);
1630
1631 return ret;
1632}
1633
1634static int __iw_set_freq(struct net_device *dev,
1635 struct iw_request_info *info,
1636 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001637{
1638 v_U32_t numChans = 0;
1639 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1640 v_U32_t indx = 0;
1641 v_U32_t status = 0;
1642
1643 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301644 hdd_adapter_t *pAdapter;
1645 hdd_context_t *pHddCtx;
1646 tHalHandle hHal;
1647 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301649
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 ENTER();
1651
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301652 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1653 if (NULL == pAdapter)
1654 {
1655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1656 "%s:Invalid Adapter",__func__);
1657 return -EINVAL;
1658 }
1659
1660 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1661 status = wlan_hdd_validate_context(pHddCtx);
1662 if (0 != status)
1663 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 return status;
1665 }
1666
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301667 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1668 if (NULL == hHal)
1669 {
1670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1671 "%s: Hal Context is NULL",__func__);
1672 return -EINVAL;
1673 }
1674
1675 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1676 if (NULL == pHddStaCtx)
1677 {
1678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1679 "%s:STA context is NULL",__func__);
1680 return -EINVAL;
1681 }
1682
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301684 if (NULL == pWextState)
1685 {
1686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1687 "%s: pWextState is NULL",__func__);
1688 return -EINVAL;
1689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001690
1691 pRoamProfile = &pWextState->roamProfile;
1692
Arif Hussain6d2a3322013-11-17 19:50:10 -08001693 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001694
1695 /* Link is up then return cant set channel*/
1696 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1697 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1698 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001699 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 return -EOPNOTSUPP;
1701 }
1702
1703 /* Settings by Frequency as input */
1704 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1705 (wrqu->freq.m <= (tANI_U32)5.825e8))
1706 {
1707 tANI_U32 freq = wrqu->freq.m / 100000;
1708
1709 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1710 indx++;
1711 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1712 {
1713 return -EINVAL;
1714 }
1715 wrqu->freq.e = 0;
1716 wrqu->freq.m = freq_chan_map[indx].chan;
1717
1718 }
1719
1720 if (wrqu->freq.e == 0)
1721 {
1722 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1723 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1724 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001725 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001726 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1728 return -EINVAL;
1729 }
1730
1731 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1732
1733 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1734 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1736 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 return -EIO;
1738 }
1739
1740 for (indx = 0; indx < numChans; indx++) {
1741 if (wrqu->freq.m == validChan[indx]){
1742 break;
1743 }
1744 }
1745 }
1746 else{
1747
1748 return -EINVAL;
1749 }
1750
1751 if(indx >= numChans)
1752 {
1753 return -EINVAL;
1754 }
1755
1756 /* Set the Operational Channel */
1757 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1758 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1759 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1760
Arif Hussain6d2a3322013-11-17 19:50:10 -08001761 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001762
1763 EXIT();
1764
1765 return status;
1766}
1767
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301768static int iw_set_freq(struct net_device *dev,
1769 struct iw_request_info *info,
1770 union iwreq_data *wrqu, char *extra)
1771{
1772 int ret;
1773
1774 vos_ssr_protect(__func__);
1775 ret = __iw_set_freq(dev, info, wrqu, extra);
1776 vos_ssr_unprotect(__func__);
1777
1778 return ret;
1779}
1780
1781static int __iw_get_freq(struct net_device *dev,
1782 struct iw_request_info *info,
1783 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001784{
Jeff Johnsone7245742012-09-05 17:12:55 -07001785 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301786 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 tHalHandle hHal;
1788 hdd_wext_state_t *pWextState;
1789 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301790 hdd_station_ctx_t *pHddStaCtx;
1791 hdd_context_t *pHddCtx;
1792 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001793
1794 ENTER();
1795
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301796 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1797 if (NULL == pAdapter)
1798 {
1799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1800 "%s: Adapter is NULL", __func__);
1801 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301803 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1804 ret = wlan_hdd_validate_context(pHddCtx);
1805 if (0 != ret)
1806 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301807 return ret;
1808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301810 if (NULL == hHal)
1811 {
1812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1813 "%s: Hal Context is NULL",__func__);
1814 return -EINVAL;
1815 }
1816 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1817 if (NULL == pHddStaCtx)
1818 {
1819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1820 "%s: HddStaCtx is NULL", __func__);
1821 return -EINVAL;
1822 }
1823 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1824 if (NULL == pWextState)
1825 {
1826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1827 "%s: pWextState is NULL",__func__);
1828 return -EINVAL;
1829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 pRoamProfile = &pWextState->roamProfile;
1831
1832 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1833 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001834 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 {
c_hpothub8245442013-11-20 23:41:09 +05301836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1837 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 return -EIO;
1839 }
1840 else
1841 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001842 status = hdd_wlan_get_freq(channel, &freq);
1843 if( TRUE == status )
1844 {
1845 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1846 * iwlist & iwconfig command shows frequency into proper
1847 * format (2.412 GHz instead of 246.2 MHz)*/
1848 fwrq->m = freq;
1849 fwrq->e = MHZ;
1850 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 }
1852 }
1853 else
1854 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001855 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1856 * iwlist & iwconfig command shows frequency into proper
1857 * format (2.412 GHz instead of 246.2 MHz)*/
1858 fwrq->m = 0;
1859 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001860 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301861
1862 EXIT();
1863 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001864}
1865
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301866static int iw_get_freq(struct net_device *dev,
1867 struct iw_request_info *info,
1868 struct iw_freq *fwrq, char *extra)
1869{
1870 int ret;
1871
1872 vos_ssr_protect(__func__);
1873 ret = __iw_get_freq(dev, info, fwrq, extra);
1874 vos_ssr_unprotect(__func__);
1875
1876 return ret;
1877}
1878
1879static int __iw_get_tx_power(struct net_device *dev,
1880 struct iw_request_info *info,
1881 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001882{
1883
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301884 hdd_adapter_t *pAdapter;
1885 hdd_context_t *pHddCtx;
1886 hdd_station_ctx_t *pHddStaCtx;
1887 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001888
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301889 ENTER();
1890
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301891 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1892 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1895 "%s: Adapter is NULL",__func__);
1896 return -EINVAL;
1897 }
1898 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1899 ret = wlan_hdd_validate_context(pHddCtx);
1900 if (0 != ret)
1901 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301902 return ret;
1903 }
1904
1905 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1906 if (NULL == pHddStaCtx)
1907 {
1908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1909 "%s: STA Context is NULL",__func__);
1910 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 }
1912
1913 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1914 {
1915 wrqu->txpower.value = 0;
1916 return 0;
1917 }
1918 wlan_hdd_get_classAstats(pAdapter);
1919 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1920
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301921 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 return 0;
1923}
1924
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301925static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 struct iw_request_info *info,
1927 union iwreq_data *wrqu, char *extra)
1928{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301929 int ret;
1930
1931 vos_ssr_protect(__func__);
1932 ret = __iw_get_tx_power(dev, info, wrqu, extra);
1933 vos_ssr_unprotect(__func__);
1934
1935 return ret;
1936}
1937
1938static int __iw_set_tx_power(struct net_device *dev,
1939 struct iw_request_info *info,
1940 union iwreq_data *wrqu, char *extra)
1941{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301942 hdd_adapter_t *pAdapter;
1943 tHalHandle hHal;
1944 hdd_context_t *pHddCtx;
1945 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001946
1947 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301948 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1949 if (NULL == pAdapter)
1950 {
1951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1952 "%s: Adapter is NULL",__func__);
1953 return -EINVAL;
1954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001955
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301956 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1957 ret = wlan_hdd_validate_context(pHddCtx);
1958 if (0 != ret)
1959 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301960 return ret;
1961 }
1962
1963 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1964 if (NULL == hHal)
1965 {
1966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1967 "%s: Hal Context is NULL",__func__);
1968 return -EINVAL;
1969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001970 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1971 {
c_hpothub8245442013-11-20 23:41:09 +05301972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1973 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 return -EIO;
1975 }
1976
1977 EXIT();
1978
1979 return 0;
1980}
1981
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301982static int iw_set_tx_power(struct net_device *dev,
1983 struct iw_request_info *info,
1984 union iwreq_data *wrqu, char *extra)
1985{
1986 int ret;
1987
1988 vos_ssr_protect(__func__);
1989 ret = __iw_set_tx_power(dev, info, wrqu, extra);
1990 vos_ssr_unprotect(__func__);
1991
1992 return ret;
1993}
1994
1995static int __iw_get_bitrate(struct net_device *dev,
1996 struct iw_request_info *info,
1997 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001998{
1999 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2000 eHalStatus status = eHAL_STATUS_SUCCESS;
2001 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302002 hdd_adapter_t *pAdapter;
2003 hdd_context_t *pHddCtx;
2004 hdd_station_ctx_t *pHddStaCtx;
2005 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002006
2007 ENTER();
2008
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302009 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2010 if (NULL == pAdapter)
2011 {
2012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2013 "%s: Adapter is NULL",__func__);
2014 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 }
2016
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302017 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2018 ret = wlan_hdd_validate_context(pHddCtx);
2019 if (0 != ret)
2020 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302021 return ret;
2022 }
2023
2024 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2025 if (NULL == pHddStaCtx)
2026 {
2027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2028 "%s: STA Context is NULL",__func__);
2029 return -EINVAL;
2030 }
2031
2032 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 wrqu->bitrate.value = 0;
2034 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302035 else
2036 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2038 SME_SUMMARY_STATS |
2039 SME_GLOBAL_CLASSA_STATS |
2040 SME_GLOBAL_CLASSB_STATS |
2041 SME_GLOBAL_CLASSC_STATS |
2042 SME_GLOBAL_CLASSD_STATS |
2043 SME_PER_STA_STATS,
2044 hdd_StatisticsCB, 0, FALSE,
2045 pHddStaCtx->conn_info.staId[0], pAdapter );
2046
2047 if(eHAL_STATUS_SUCCESS != status)
2048 {
2049 hddLog(VOS_TRACE_LEVEL_ERROR,
2050 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002051 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 return status;
2053 }
2054
2055 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302056 if (NULL == pWextState)
2057 {
2058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2059 "%s: pWextState is NULL",__func__);
2060 return -EINVAL;
2061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002062
2063 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2064
2065 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2066 {
2067 hddLog(VOS_TRACE_LEVEL_ERROR,
2068 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002069 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 return VOS_STATUS_E_FAILURE;
2071 }
2072
2073 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2074 }
2075
2076 EXIT();
2077
2078 return vos_status;
2079}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302080
2081static int iw_get_bitrate(struct net_device *dev,
2082 struct iw_request_info *info,
2083 union iwreq_data *wrqu, char *extra)
2084{
2085 int ret;
2086
2087 vos_ssr_protect(__func__);
2088 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2089 vos_ssr_unprotect(__func__);
2090
2091 return ret;
2092}
2093
2094
Jeff Johnson295189b2012-06-20 16:38:30 -07002095/* ccm call back function */
2096
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302097static int __iw_set_bitrate(struct net_device *dev,
2098 struct iw_request_info *info,
2099 union iwreq_data *wrqu,
2100 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002101{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302102 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302104 hdd_station_ctx_t *pHddStaCtx;
2105 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2107 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2108 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2109 v_U32_t i, rate;
2110 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302111 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002112
2113 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302114 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2115 if (NULL == pAdapter)
2116 {
2117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2118 "%s: Adapter is NULL",__func__);
2119 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 }
2121
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302122 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2123 ret = wlan_hdd_validate_context(pHddCtx);
2124 if (0 != ret)
2125 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302126 return ret;
2127 }
2128
2129 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2130 if (NULL == pHddStaCtx)
2131 {
2132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2133 "%s: STA Context is NULL",__func__);
2134 return -EINVAL;
2135 }
2136
2137
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302139 if (NULL == pWextState)
2140 {
2141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2142 "%s: pWextState is NULL",__func__);
2143 return -EINVAL;
2144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002145
2146 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2147 {
2148 return -ENXIO ;
2149 }
2150
2151 rate = wrqu->bitrate.value;
2152
2153 if (rate == -1)
2154 {
2155 rate = WNI_CFG_FIXED_RATE_AUTO;
2156 valid_rate = TRUE;
2157 }
2158 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2159 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2160 {
2161 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2162 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2163 {
2164 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2165 WNI_CFG_SUPPORTED_RATES_11A,
2166 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2167 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2168 WNI_CFG_SUPPORTED_RATES_11B,
2169 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2170 {
2171 for (i = 0; i < (b_len + a_len); ++i)
2172 {
2173 /* supported rates returned is double the actual rate so we divide it by 2 */
2174 if ((supp_rates[i]&0x7F)/2 == rate)
2175 {
2176 valid_rate = TRUE;
2177 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2178 break;
2179 }
2180 }
2181 }
2182 }
2183 }
2184 if (valid_rate != TRUE)
2185 {
2186 return -EINVAL;
2187 }
2188 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2189 WNI_CFG_FIXED_RATE, rate,
2190 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2191 {
c_hpothub8245442013-11-20 23:41:09 +05302192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2193 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 return -EIO;
2195 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302196
2197 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 return 0;
2199}
2200
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302201static int iw_set_bitrate(struct net_device *dev,
2202 struct iw_request_info *info,
2203 union iwreq_data *wrqu,
2204 char *extra)
2205{
2206 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302208 vos_ssr_protect(__func__);
2209 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2210 vos_ssr_unprotect(__func__);
2211
2212 return ret;
2213}
2214
2215static int __iw_set_genie(struct net_device *dev,
2216 struct iw_request_info *info,
2217 union iwreq_data *wrqu,
2218 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002219{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302220 hdd_adapter_t *pAdapter;
2221 hdd_context_t *pHddCtx;
2222 hdd_wext_state_t *pWextState;
2223 u_int8_t *genie = NULL;
2224 u_int8_t *base_genie = NULL;
2225 v_U16_t remLen;
2226 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002227
2228 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002229
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302230 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2231 if (NULL == pAdapter)
2232 {
2233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2234 "%s: Adapter is NULL",__func__);
2235 return -EINVAL;
2236 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002237
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302238 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2239 ret = wlan_hdd_validate_context(pHddCtx);
2240 if (0 != ret)
2241 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302242 return ret;
2243 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002244
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302245 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2246 if (NULL == pWextState)
2247 {
2248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2249 "%s: pWextState is NULL",__func__);
2250 return -EINVAL;
2251 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002252
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302253 if (!wrqu->data.length) {
2254 hdd_clearRoamProfileIe(pAdapter);
2255 EXIT();
2256 return 0;
2257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002258
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302259 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2260 wrqu->data.length);
2261 if (NULL == base_genie)
2262 {
2263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2264 "mem_alloc_copy_from_user_helper fail");
2265 return -ENOMEM;
2266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002267
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302268 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002269
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302270 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002271
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302272 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2273
2274 /* clear any previous genIE before this call */
2275 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2276
2277 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 {
2279 v_U16_t eLen = 0;
2280 v_U8_t elementId;
2281 elementId = *genie++;
2282 eLen = *genie++;
2283 remLen -= 2;
2284
Arif Hussain6d2a3322013-11-17 19:50:10 -08002285 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 __func__, elementId, eLen);
2287
2288 switch ( elementId )
2289 {
2290 case IE_EID_VENDOR:
2291 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002292 {
2293 kfree(base_genie);
2294 return -EINVAL;
2295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002296
2297 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2298 {
2299 v_U16_t curGenIELen = pWextState->genIE.length;
2300 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2301 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2302
2303 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2304 {
2305 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002306 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002308 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 return -ENOMEM;
2310 }
2311 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2312 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2313 pWextState->genIE.length += eLen + 2;
2314 }
2315 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2316 {
2317 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2318 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2319 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2320 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2321 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2322 }
2323 else /* any vendorId except WPA IE should be accumulated to genIE */
2324 {
2325 v_U16_t curGenIELen = pWextState->genIE.length;
2326 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2327 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2328
2329 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2330 {
2331 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002332 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002333 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002334 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002335 return -ENOMEM;
2336 }
2337 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2338 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2339 pWextState->genIE.length += eLen + 2;
2340 }
2341 break;
2342 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002343 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2345 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2346 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2347 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2348 break;
2349
2350 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002351 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002352 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 return 0;
2354 }
2355 genie += eLen;
2356 remLen -= eLen;
2357 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302358
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002360 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 return 0;
2362}
2363
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302364static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 struct iw_request_info *info,
2366 union iwreq_data *wrqu,
2367 char *extra)
2368{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302369 int ret;
2370
2371 vos_ssr_protect(__func__);
2372 ret = __iw_set_genie(dev, info, wrqu, extra);
2373 vos_ssr_unprotect(__func__);
2374
2375 return ret;
2376}
2377
2378static int __iw_get_genie(struct net_device *dev,
2379 struct iw_request_info *info,
2380 union iwreq_data *wrqu,
2381 char *extra)
2382{
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302384 hdd_context_t *pHddCtx;
2385 hdd_adapter_t *pAdapter;
2386 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 eHalStatus status;
2388 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2389 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2390
2391 ENTER();
2392
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302393 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2394 if (NULL == pAdapter)
2395 {
2396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2397 "%s: Adapter is NULL",__func__);
2398 return -EINVAL;
2399 }
2400 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2401 status = wlan_hdd_validate_context(pHddCtx);
2402 if (0 != status)
2403 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302404 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 }
2406
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302408 if (NULL == pWextState)
2409 {
2410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2411 "%s: pWextState is NULL",__func__);
2412 return -EINVAL;
2413 }
2414
2415 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2416 if (NULL == pHddStaCtx)
2417 {
2418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2419 "%s: STA Context is NULL",__func__);
2420 return -EINVAL;
2421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002422
2423 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2424 {
2425 return -ENXIO;
2426 }
2427
2428 // Return something ONLY if we are associated with an RSN or WPA network
2429 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2430 pWextState->roamProfile.negotiatedAuthType))
2431 {
2432 return -ENXIO;
2433 }
2434
2435 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2436 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2437 pAdapter->sessionId,
2438 &length,
2439 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002440 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2441 if (wrqu->data.length < length)
2442 {
2443 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2444 return -EFAULT;
2445 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002446 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002447 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002448
Arif Hussain6d2a3322013-11-17 19:50:10 -08002449 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002450
2451 EXIT();
2452
2453 return 0;
2454}
2455
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302456static int iw_get_genie(struct net_device *dev,
2457 struct iw_request_info *info,
2458 union iwreq_data *wrqu,
2459 char *extra)
2460{
2461 int ret;
2462
2463 vos_ssr_protect(__func__);
2464 ret = __iw_get_genie(dev, info, wrqu, extra);
2465 vos_ssr_unprotect(__func__);
2466
2467 return ret;
2468}
2469
2470
2471static int __iw_get_encode(struct net_device *dev,
2472 struct iw_request_info *info,
2473 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002474{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302475 hdd_adapter_t *pAdapter;
2476 hdd_context_t *pHddCtx;
2477 hdd_wext_state_t *pWextState;
2478 tCsrRoamProfile *pRoamProfile;
2479 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002481
2482 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302483 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2484 if (NULL == pAdapter)
2485 {
2486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2487 "%s: Adapter is NULL",__func__);
2488 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 }
2490
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302491 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2492 ret = wlan_hdd_validate_context(pHddCtx);
2493 if (0 != ret)
2494 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302495 return ret;
2496 }
2497 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2498 if (NULL == pWextState)
2499 {
2500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2501 "%s: pWextState is NULL",__func__);
2502 return -EINVAL;
2503 }
2504
2505 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 keyId = pRoamProfile->Keys.defaultIndex;
2507
2508 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2509 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002510 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 return -EINVAL;
2512 }
2513
2514 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2515 {
2516 dwrq->flags |= IW_ENCODE_ENABLED;
2517 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2518 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2519
2520 dwrq->flags |= (keyId + 1);
2521
2522 }
2523 else
2524 {
2525 dwrq->flags |= IW_ENCODE_DISABLED;
2526 }
2527
2528 for(i=0; i < MAX_WEP_KEYS; i++)
2529 {
2530 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2531 {
2532 continue;
2533 }
2534 else
2535 {
2536 break;
2537 }
2538 }
2539
2540 if(MAX_WEP_KEYS == i)
2541 {
2542 dwrq->flags |= IW_ENCODE_NOKEY;
2543 }
2544
2545 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2546
2547 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2548 {
2549 dwrq->flags |= IW_ENCODE_OPEN;
2550 }
2551 else
2552 {
2553 dwrq->flags |= IW_ENCODE_RESTRICTED;
2554 }
2555 EXIT();
2556 return 0;
2557}
2558
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302559static int iw_get_encode(struct net_device *dev,
2560 struct iw_request_info *info,
2561 struct iw_point *dwrq, char *extra)
2562{
2563 int ret;
2564
2565 vos_ssr_protect(__func__);
2566 ret = __iw_get_encode(dev, info, dwrq, extra);
2567 vos_ssr_unprotect(__func__);
2568
2569 return ret;
2570}
2571
Jeff Johnson295189b2012-06-20 16:38:30 -07002572#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2573#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2574
2575
2576/*
2577 * This function sends a single 'key' to LIM at all time.
2578 */
2579
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302580static int __iw_get_rts_threshold(struct net_device *dev,
2581 struct iw_request_info *info,
2582 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002583{
2584 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2585 v_U32_t status = 0;
2586
2587 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2588
2589 return status;
2590}
2591
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302592static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 struct iw_request_info *info,
2594 union iwreq_data *wrqu, char *extra)
2595{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302596 int ret;
2597
2598 vos_ssr_protect(__func__);
2599 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2600 vos_ssr_unprotect(__func__);
2601
2602 return ret;
2603}
2604
2605static int __iw_set_rts_threshold(struct net_device *dev,
2606 struct iw_request_info *info,
2607 union iwreq_data *wrqu, char *extra)
2608{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302609 hdd_adapter_t *pAdapter;
2610 hdd_context_t *pHddCtx;
2611 tHalHandle hHal;
2612 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002613
2614 ENTER();
2615
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302616 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2617 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002618 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2620 "%s: Adapter is NULL",__func__);
2621 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002622 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302623
2624 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2625 ret = wlan_hdd_validate_context(pHddCtx);
2626 if (0 != ret)
2627 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302628 return ret;
2629 }
2630
2631 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2632 if (NULL == hHal)
2633 {
2634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2635 "%s: Hal Context is NULL",__func__);
2636 return -EINVAL;
2637 }
2638
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2640 {
2641 return -EINVAL;
2642 }
2643
2644 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2645 {
c_hpothub8245442013-11-20 23:41:09 +05302646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2647 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 return -EIO;
2649 }
2650
2651 EXIT();
2652
2653 return 0;
2654}
2655
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302656static int iw_set_rts_threshold(struct net_device *dev,
2657 struct iw_request_info *info,
2658 union iwreq_data *wrqu, char *extra)
2659{
2660 int ret;
2661
2662 vos_ssr_protect(__func__);
2663 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2664 vos_ssr_unprotect(__func__);
2665
2666 return ret;
2667}
2668
2669static int __iw_get_frag_threshold(struct net_device *dev,
2670 struct iw_request_info *info,
2671 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002672{
2673 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2674 v_U32_t status = 0;
2675
2676 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2677
2678 return status;
2679}
2680
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302681static int iw_get_frag_threshold(struct net_device *dev,
2682 struct iw_request_info *info,
2683 union iwreq_data *wrqu, char *extra)
2684{
2685 int ret;
2686
2687 vos_ssr_protect(__func__);
2688 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2689 vos_ssr_unprotect(__func__);
2690
2691 return ret;
2692}
2693
2694static int __iw_set_frag_threshold(struct net_device *dev,
2695 struct iw_request_info *info,
2696 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002697{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302698 hdd_adapter_t *pAdapter;
2699 hdd_context_t *pHddCtx;
2700 tHalHandle hHal;
2701 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002702
2703 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302704 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2705 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002706 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2708 "%s: Adapter is NULL",__func__);
2709 return -EINVAL;
2710 }
2711
2712 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2713 ret = wlan_hdd_validate_context(pHddCtx);
2714 if (0 != ret)
2715 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302716 return ret;
2717 }
2718
2719 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2720 if (NULL == hHal)
2721 {
2722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2723 "%s: Hal Context is NULL",__func__);
2724 return -EINVAL;
2725 }
2726
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2728 {
2729 return -EINVAL;
2730 }
2731
2732 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2733 {
c_hpothub8245442013-11-20 23:41:09 +05302734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2735 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 return -EIO;
2737 }
2738
2739 EXIT();
2740
2741 return 0;
2742}
2743
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302744static int iw_set_frag_threshold(struct net_device *dev,
2745 struct iw_request_info *info,
2746 union iwreq_data *wrqu, char *extra)
2747{
2748 int ret;
2749
2750 vos_ssr_protect(__func__);
2751 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2752 vos_ssr_unprotect(__func__);
2753
2754 return ret;
2755}
2756
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302757static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 struct iw_request_info *info,
2759 union iwreq_data *wrqu, char *extra)
2760{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302761 hdd_adapter_t *pAdapter;
2762 hdd_context_t *pHddCtx;
2763 int ret = 0;
2764
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302766 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2767 if (NULL == pAdapter)
2768 {
2769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2770 "%s: Adapter is NULL",__func__);
2771 return -EINVAL;
2772 }
2773 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2774 ret = wlan_hdd_validate_context(pHddCtx);
2775 if (0 != ret)
2776 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302777 return ret;
2778 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302779
2780 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 return -EOPNOTSUPP;
2782}
2783
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302784static int iw_get_power_mode(struct net_device *dev,
2785 struct iw_request_info *info,
2786 union iwreq_data *wrqu, char *extra)
2787{
2788 int ret;
2789
2790 vos_ssr_protect(__func__);
2791 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2792 vos_ssr_unprotect(__func__);
2793
2794 return ret;
2795}
2796static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 struct iw_request_info *info,
2798 union iwreq_data *wrqu, char *extra)
2799{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302800 hdd_adapter_t *pAdapter;
2801 hdd_context_t *pHddCtx;
2802 int ret = 0;
2803
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302805 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2806 if (NULL == pAdapter)
2807 {
2808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2809 "%s: Adapter is NULL",__func__);
2810 return -EINVAL;
2811 }
2812 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2813 ret = wlan_hdd_validate_context(pHddCtx);
2814 if (0 != ret)
2815 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302816 return ret;
2817 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302818
2819 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 return -EOPNOTSUPP;
2821}
2822
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302823static int iw_set_power_mode(struct net_device *dev,
2824 struct iw_request_info *info,
2825 union iwreq_data *wrqu, char *extra)
2826{
2827 int ret;
2828
2829 vos_ssr_protect(__func__);
2830 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2831 vos_ssr_unprotect(__func__);
2832
2833 return ret;
2834}
2835
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302836static int __iw_get_range(struct net_device *dev,
2837 struct iw_request_info *info,
2838 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002839{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302840 hdd_adapter_t *pAdapter;
2841 tHalHandle hHal;
2842 hdd_context_t *pHddCtx;
2843 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 struct iw_range *range = (struct iw_range *) extra;
2845
2846 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2847
2848 v_U32_t num_channels = sizeof(channels);
2849 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2850 v_U32_t a_len;
2851 v_U32_t b_len;
2852 v_U32_t active_phy_mode = 0;
2853 v_U8_t index = 0, i;
2854
2855 ENTER();
2856
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302857 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2858 if (NULL == pAdapter)
2859 {
2860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2861 "%s: pAdapter is NULL", __func__);
2862 return -EINVAL;
2863 }
2864 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2865 ret = wlan_hdd_validate_context(pHddCtx);
2866 if (0 != ret)
2867 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302868 return ret;
2869 }
2870 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2871 if (NULL == hHal)
2872 {
2873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2874 "%s: pAdapter is NULL", __func__);
2875 return -EINVAL;
2876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 wrqu->data.length = sizeof(struct iw_range);
2878 memset(range, 0, sizeof(struct iw_range));
2879
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 /*Get the phy mode*/
2881 if (ccmCfgGetInt(hHal,
2882 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2883 {
2884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002885 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002886
2887 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2888 {
2889 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002890 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 if (ccmCfgGetStr(hHal,
2892 WNI_CFG_SUPPORTED_RATES_11A,
2893 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2894 {
2895 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2896 {
2897 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2898 }
2899 for (i = 0; i < a_len; i++)
2900 {
2901 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2902 }
2903 range->num_bitrates = a_len;
2904 }
2905 else
2906 {
2907 return -EIO;
2908 }
2909 }
2910 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2911 {
2912 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002913 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 if (ccmCfgGetStr(hHal,
2915 WNI_CFG_SUPPORTED_RATES_11B,
2916 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2917 {
2918 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2919 {
2920 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2921 }
2922 for (i = 0; i < b_len; i++)
2923 {
2924 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2925 }
2926 range->num_bitrates = b_len;
2927 }
2928 else
2929 {
2930 return -EIO;
2931 }
2932 }
2933 }
2934
2935 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2936 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2937 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2938
2939 range->encoding_size[0] = 5;
2940 range->encoding_size[1] = 13;
2941 range->num_encoding_sizes = 2;
2942 range->max_encoding_tokens = MAX_WEP_KEYS;
2943
2944 // we support through Wireless Extensions 22
2945 range->we_version_compiled = WIRELESS_EXT;
2946 range->we_version_source = 22;
2947
2948 /*Supported Channels and Frequencies*/
2949 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2950 {
c_hpothub8245442013-11-20 23:41:09 +05302951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2952 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002953 return -EIO;
2954 }
2955 if (num_channels > IW_MAX_FREQUENCIES)
2956 {
2957 num_channels = IW_MAX_FREQUENCIES;
2958 }
2959
2960 range->num_channels = num_channels;
2961 range->num_frequency = num_channels;
2962
2963 for (index=0; index < num_channels; index++)
2964 {
2965 v_U32_t frq_indx = 0;
2966
2967 range->freq[index].i = channels[index];
2968 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2969 {
2970 if(channels[index] == freq_chan_map[frq_indx].chan)
2971 {
2972 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2973 range->freq[index].e = 1;
2974 break;
2975 }
2976 frq_indx++;
2977 }
2978 }
2979
2980 /* Event capability (kernel + driver) */
2981 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2982 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2983 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2984 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2985
2986 /*Encryption capability*/
2987 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2988 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2989
2990 /* Txpower capability */
2991 range->txpower_capa = IW_TXPOW_MWATT;
2992
2993 /*Scanning capability*/
2994 #if WIRELESS_EXT >= 22
2995 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2996 #endif
2997
2998 EXIT();
2999 return 0;
3000}
3001
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303002static int iw_get_range(struct net_device *dev,
3003 struct iw_request_info *info,
3004 union iwreq_data *wrqu, char *extra)
3005{
3006 int ret;
3007
3008 vos_ssr_protect(__func__);
3009 ret = __iw_get_range(dev, info, wrqu, extra);
3010 vos_ssr_unprotect(__func__);
3011
3012 return ret;
3013}
3014
Jeff Johnson295189b2012-06-20 16:38:30 -07003015/* Callback function registered with PMC to know status of PMC request */
3016static void iw_power_callback_fn (void *pContext, eHalStatus status)
3017{
3018 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003019
3020 if (NULL == pContext)
3021 {
3022 hddLog(VOS_TRACE_LEVEL_ERROR,
3023 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003024 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003025 return;
3026 }
3027
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003029
Jeff Johnson72a40512013-12-19 10:14:15 -08003030 /* there is a race condition that exists between this callback
3031 function and the caller since the caller could time out either
3032 before or while this code is executing. we use a spinlock to
3033 serialize these actions */
3034 spin_lock(&hdd_context_lock);
3035
3036 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 {
3038 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003039 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003041 "%s: Invalid context, magic [%08x]",
3042 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003043
3044 if (ioctl_debug)
3045 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003046 pr_info("%s: Invalid context, magic [%08x]\n",
3047 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 }
3049 return;
3050 }
3051
Jeff Johnson72a40512013-12-19 10:14:15 -08003052 /* context is valid so caller is still waiting */
3053
3054 /* paranoia: invalidate the magic */
3055 pStatsContext->magic = 0;
3056
3057 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003059
3060 /* serialization is complete */
3061 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003062}
3063
3064/* Callback function for tx per hit */
3065void hdd_tx_per_hit_cb (void *pCallbackContext)
3066{
3067 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3068 unsigned char tx_fail[16];
3069 union iwreq_data wrqu;
3070
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303071 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003073 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 return;
3075 }
3076 memset(&wrqu, 0, sizeof(wrqu));
3077 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3078 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3079}
3080
3081void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3082{
3083 struct statsContext *pStatsContext;
3084 tCsrGlobalClassAStatsInfo *pClassAStats;
3085 hdd_adapter_t *pAdapter;
3086
3087 if (ioctl_debug)
3088 {
3089 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003090 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 }
3092
3093 if ((NULL == pStats) || (NULL == pContext))
3094 {
3095 hddLog(VOS_TRACE_LEVEL_ERROR,
3096 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003097 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 return;
3099 }
3100
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 pClassAStats = pStats;
3102 pStatsContext = pContext;
3103 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003104
3105 /* there is a race condition that exists between this callback
3106 function and the caller since the caller could time out either
3107 before or while this code is executing. we use a spinlock to
3108 serialize these actions */
3109 spin_lock(&hdd_context_lock);
3110
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3112 {
3113 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003114 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 hddLog(VOS_TRACE_LEVEL_WARN,
3116 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003117 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 if (ioctl_debug)
3119 {
3120 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003121 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 }
3123 return;
3124 }
3125
Jeff Johnson72a40512013-12-19 10:14:15 -08003126 /* context is valid so caller is still waiting */
3127
3128 /* paranoia: invalidate the magic */
3129 pStatsContext->magic = 0;
3130
3131 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3133
Jeff Johnson72a40512013-12-19 10:14:15 -08003134 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003136
3137 /* serialization is complete */
3138 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003139}
3140
3141VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3142{
3143 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3144 eHalStatus hstatus;
3145 long lrc;
3146 struct statsContext context;
3147
3148 if (NULL == pAdapter)
3149 {
3150 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3151 return VOS_STATUS_E_FAULT;
3152 }
3153 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3154 {
3155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3156 return VOS_STATUS_SUCCESS;
3157 }
3158
3159 /* we are connected
3160 prepare our callback context */
3161 init_completion(&context.completion);
3162 context.pAdapter = pAdapter;
3163 context.magic = STATS_CONTEXT_MAGIC;
3164 /* query only for Class A statistics (which include link speed) */
3165 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3166 eCSR_HDD,
3167 SME_GLOBAL_CLASSA_STATS,
3168 hdd_GetClassA_statisticsCB,
3169 0, // not periodic
3170 FALSE, //non-cached results
3171 pHddStaCtx->conn_info.staId[0],
3172 &context);
3173 if (eHAL_STATUS_SUCCESS != hstatus)
3174 {
3175 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003176 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003177 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 /* we'll returned a cached value below */
3179 }
3180 else
3181 {
3182 /* request was sent -- wait for the response */
3183 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3184 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 if (lrc <= 0)
3186 {
3187 hddLog(VOS_TRACE_LEVEL_ERROR,
3188 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003189 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 }
3191 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003192
3193 /* either we never sent a request, we sent a request and received a
3194 response or we sent a request and timed out. if we never sent a
3195 request or if we sent a request and got a response, we want to
3196 clear the magic out of paranoia. if we timed out there is a
3197 race condition such that the callback function could be
3198 executing at the same time we are. of primary concern is if the
3199 callback function had already verified the "magic" but had not
3200 yet set the completion variable when a timeout occurred. we
3201 serialize these activities by invalidating the magic while
3202 holding a shared spinlock which will cause us to block if the
3203 callback is currently executing */
3204 spin_lock(&hdd_context_lock);
3205 context.magic = 0;
3206 spin_unlock(&hdd_context_lock);
3207
3208 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 return VOS_STATUS_SUCCESS;
3210}
3211
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003212static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3213{
3214 struct statsContext *pStatsContext;
3215 tCsrSummaryStatsInfo *pSummaryStats;
3216 tCsrGlobalClassAStatsInfo *pClassAStats;
3217 hdd_adapter_t *pAdapter;
3218
3219 if (ioctl_debug)
3220 {
3221 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003222 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003223 }
3224
3225 if ((NULL == pStats) || (NULL == pContext))
3226 {
3227 hddLog(VOS_TRACE_LEVEL_ERROR,
3228 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003229 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003230 return;
3231 }
3232
Jeff Johnson72a40512013-12-19 10:14:15 -08003233 /* there is a race condition that exists between this callback
3234 function and the caller since the caller could time out either
3235 before or while this code is executing. we use a spinlock to
3236 serialize these actions */
3237 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003238
3239 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3240 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3241 pStatsContext = pContext;
3242 pAdapter = pStatsContext->pAdapter;
3243 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3244 {
3245 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003246 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003247 hddLog(VOS_TRACE_LEVEL_WARN,
3248 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003249 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003250 if (ioctl_debug)
3251 {
3252 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003253 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003254 }
3255 return;
3256 }
3257
Jeff Johnson72a40512013-12-19 10:14:15 -08003258 /* context is valid so caller is still waiting */
3259
3260 /* paranoia: invalidate the magic */
3261 pStatsContext->magic = 0;
3262
3263 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003264 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3265 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3266
Jeff Johnson72a40512013-12-19 10:14:15 -08003267 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003268 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003269
3270 /* serialization is complete */
3271 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003272}
3273
3274VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3275{
3276 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3277 eHalStatus hstatus;
3278 long lrc;
3279 struct statsContext context;
3280
3281 if (NULL == pAdapter)
3282 {
3283 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3284 return VOS_STATUS_SUCCESS;
3285 }
3286
3287 /* we are connected
3288 prepare our callback context */
3289 init_completion(&context.completion);
3290 context.pAdapter = pAdapter;
3291 context.magic = STATS_CONTEXT_MAGIC;
3292
3293 /* query only for Summary & Class A statistics */
3294 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3295 eCSR_HDD,
3296 SME_SUMMARY_STATS |
3297 SME_GLOBAL_CLASSA_STATS,
3298 hdd_get_station_statisticsCB,
3299 0, // not periodic
3300 FALSE, //non-cached results
3301 pHddStaCtx->conn_info.staId[0],
3302 &context);
3303 if (eHAL_STATUS_SUCCESS != hstatus)
3304 {
3305 hddLog(VOS_TRACE_LEVEL_ERROR,
3306 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003307 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003308 /* we'll return with cached values */
3309 }
3310 else
3311 {
3312 /* request was sent -- wait for the response */
3313 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3314 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003315
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003316 if (lrc <= 0)
3317 {
3318 hddLog(VOS_TRACE_LEVEL_ERROR,
3319 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003320 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003321 }
3322 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003323
3324 /* either we never sent a request, we sent a request and received a
3325 response or we sent a request and timed out. if we never sent a
3326 request or if we sent a request and got a response, we want to
3327 clear the magic out of paranoia. if we timed out there is a
3328 race condition such that the callback function could be
3329 executing at the same time we are. of primary concern is if the
3330 callback function had already verified the "magic" but had not
3331 yet set the completion variable when a timeout occurred. we
3332 serialize these activities by invalidating the magic while
3333 holding a shared spinlock which will cause us to block if the
3334 callback is currently executing */
3335 spin_lock(&hdd_context_lock);
3336 context.magic = 0;
3337 spin_unlock(&hdd_context_lock);
3338
3339 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003340 return VOS_STATUS_SUCCESS;
3341}
3342
3343
Jeff Johnson295189b2012-06-20 16:38:30 -07003344/*
3345 * Support for the LINKSPEED private command
3346 * Per the WiFi framework the response must be of the form
3347 * "LinkSpeed xx"
3348 */
3349static int iw_get_linkspeed(struct net_device *dev,
3350 struct iw_request_info *info,
3351 union iwreq_data *wrqu, char *extra)
3352{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303353 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303354 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303356 int len = sizeof(v_U32_t) + 1;
3357 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303358 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303359 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303360 int rc, valid = 0;
3361
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303362 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303363 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3364 if (NULL == pAdapter)
3365 {
3366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3367 "%s: Adapter is NULL",__func__);
3368 return -EINVAL;
3369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003370
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303371 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303372 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303373 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003374 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303375 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003376 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303377 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3378 if (NULL == pHddStaCtx)
3379 {
3380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3381 "%s: STA Context is NULL",__func__);
3382 return -EINVAL;
3383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3385 {
3386 /* we are not connected so we don't have a classAstats */
3387 link_speed = 0;
3388 }
3389 else
3390 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303391 status = wlan_hdd_get_classAstats(pAdapter);
3392
3393 if (!VOS_IS_STATUS_SUCCESS(status ))
3394 {
3395 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3396 return -EINVAL;
3397 }
3398
3399 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3400 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3401 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3402 &link_speed);
3403
3404 link_speed = link_speed / 10;
3405
3406 if (0 == link_speed)
3407 {
3408 /* The linkspeed returned by HAL is in units of 500kbps.
3409 * converting it to mbps.
3410 * This is required to support legacy firmware which does
3411 * not return link capacity.
3412 */
3413 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3414 }
3415
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 }
3417
3418 wrqu->data.length = len;
3419 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003420 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 if ((rc < 0) || (rc >= len))
3422 {
3423 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303424 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003425 return -EIO;
3426 }
3427
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303428 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003430 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003431}
3432
Arif Hussain695279c2014-03-24 14:06:07 -07003433/*
3434 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3435 *
3436 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303437static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003438 struct iw_request_info *info,
3439 union iwreq_data *wrqu, char *extra)
3440{
3441 int rc;
3442
3443 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3444
3445 if (rc < 0)
3446 return rc;
3447
3448 /* a value is being successfully returned */
3449 return 0;
3450}
Jeff Johnson295189b2012-06-20 16:38:30 -07003451
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303452static int iw_get_linkspeed_priv(struct net_device *dev,
3453 struct iw_request_info *info,
3454 union iwreq_data *wrqu, char *extra)
3455{
3456 int ret;
3457
3458 vos_ssr_protect(__func__);
3459 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3460 vos_ssr_unprotect(__func__);
3461
3462 return ret;
3463}
3464
Jeff Johnson295189b2012-06-20 16:38:30 -07003465/*
3466 * Support for the RSSI & RSSI-APPROX private commands
3467 * Per the WiFi framework the response must be of the form
3468 * "<ssid> rssi <xx>"
3469 * unless we are not associated, in which case the response is
3470 * "OK"
3471 */
3472static int iw_get_rssi(struct net_device *dev,
3473 struct iw_request_info *info,
3474 union iwreq_data *wrqu, char *extra)
3475{
3476 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003477 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 int len = wrqu->data.length;
3479 v_S7_t s7Rssi = 0;
3480 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3481 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3482 VOS_STATUS vosStatus;
3483 int rc;
3484
3485 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3486 (0 == ssidlen) || (ssidlen >= len))
3487 {
3488 /* we are not connected or our SSID is too long
3489 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003490 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 }
3492 else
3493 {
3494 /* we are connected with a valid SSID
3495 so we can write the SSID into the return buffer
3496 (note that it is not NUL-terminated) */
3497 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3498
3499 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3500
3501 if (VOS_STATUS_SUCCESS == vosStatus)
3502 {
3503 /* append the rssi to the ssid in the format required by
3504 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003505 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303506 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 }
3508 else
3509 {
3510 rc = -1;
3511 }
3512 }
3513
3514 /* verify that we wrote a valid response */
3515 if ((rc < 0) || (rc >= len))
3516 {
3517 // encoding or length error?
3518 hddLog(VOS_TRACE_LEVEL_ERROR,
3519 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003520 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 return -EIO;
3522 }
3523
3524 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003525 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003526}
3527
3528/*
3529 * Support for SoftAP channel range private command
3530 */
3531static int iw_softap_set_channel_range( struct net_device *dev,
3532 int startChannel,
3533 int endChannel,
3534 int band)
3535{
Jeff Johnson43971f52012-07-17 12:26:56 -07003536 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003537 int ret = 0;
3538 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3539 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003540 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3541
Jeff Johnson295189b2012-06-20 16:38:30 -07003542
3543 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3544 if (VOS_STATUS_SUCCESS != status)
3545 {
3546 ret = -EINVAL;
3547 }
Yathish9f22e662012-12-10 14:21:35 -08003548 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 return ret;
3550}
3551
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303552static uint8 chartohex(char c)
3553{
3554 uint8 val = 0;
3555 if (c >= '0' && c <= '9')
3556 val = c - '0';
3557 else if (c >= 'a' && c <= 'f')
3558 val = c - 'a' + 10;
3559 else if (c >= 'A' && c <= 'F')
3560 val = c - 'A' + 10;
3561 else
3562 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3563
3564 return val;
3565}
3566
3567uint8 getByte(char **buf)
3568{
3569 uint8 byte = 0;
3570 char *temp = *buf;
3571 byte = chartohex(*temp) * 16;
3572 temp++;
3573 byte += chartohex(*temp);
3574 temp++;
3575 *buf = temp;
3576 return byte;
3577}
3578
3579static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3580{
3581 tSir80211Header *macHeader;
3582 int i = 0, j = 0, length = 0;
3583 uint8 byte = 0;
3584 char *temp = pBuffer;
3585 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303586 char *pHeader;
3587 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303588
3589 macHeader = &pkt->macHeader;
3590
3591 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3592
3593 temp++;
3594
3595 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3596 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3597 pkt->encParams.keyParams.key[0].keyId);
3598
3599 for (i = 0; i< 16; i++) {
3600 pkt->encParams.keyParams.key[0].key[i]
3601 = getByte(&temp);
3602 }
3603
3604 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3605 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3606
3607 for (i = 0; i< 6; i++) {
3608 pkt->encParams.pn[i]
3609 = getByte(&temp);
3610 }
3611
3612 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3613 &pkt->encParams.pn[0], 6, 0);
3614
3615 for (i = 0, j= 5; i< 3; i++, j--) {
3616 byte = pkt->encParams.pn[i];
3617 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3618 pkt->encParams.pn[j] = byte;
3619 }
3620
3621 length = getByte(&temp);
3622
Srinivas Dasari2382de62015-01-22 15:00:04 +05303623 pHeader = temp;
3624 vos_mem_zero(&header, sizeof(tSir80211Header));
3625 for (i = 0; i < length; i++) {
3626 *((uint8 *)&header + i) = getByte(&pHeader);
3627 }
3628
3629 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3630 (char *)&header, length, 0);
3631
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303632 byte = getByte(&temp);
3633
3634 macHeader->frameCtrl.protVer = byte & 0x3;
3635 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3636 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3637
3638 byte = getByte(&temp);
3639 macHeader->frameCtrl.toDS = (byte) & 0x1;
3640 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3641 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3642 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3643 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3644 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3645 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3646 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3647
3648 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3649 "macHeader->frameCtrl.type : %x "
3650 "macHeader->frameCtrl.subType : %x "
3651 "macHeader->frameCtrl.toDS : %x "
3652 "macHeader->frameCtrl.fromDS : %x "
3653 "macHeader->frameCtrl.moreFrag : %x "
3654 "macHeader->frameCtrl.retry : %x "
3655 "macHeader->frameCtrl.powerMgmt : %x "
3656 "macHeader->frameCtrl.MoreData : %x "
3657 "macHeader->frameCtrl.wep : %x "
3658 "macHeader->frameCtrl.order : %x "
3659 , macHeader->frameCtrl.protVer
3660 , macHeader->frameCtrl.type
3661 , macHeader->frameCtrl.subType
3662 , macHeader->frameCtrl.toDS
3663 , macHeader->frameCtrl.fromDS
3664 , macHeader->frameCtrl.moreFrag
3665 , macHeader->frameCtrl.retry
3666 , macHeader->frameCtrl.powerMgmt
3667 , macHeader->frameCtrl.moreData
3668 , macHeader->frameCtrl.wep
3669 , macHeader->frameCtrl.order);
3670
3671
3672 macHeader->usDurationId = getByte(&temp);
3673 macHeader->usDurationId += getByte(&temp) << 8;
3674
3675 macHeader->vA1[0] = getByte(&temp);
3676 macHeader->vA1[1] = getByte(&temp);
3677 macHeader->vA1[2] = getByte(&temp);
3678 macHeader->vA1[3] = getByte(&temp);
3679 macHeader->vA1[4] = getByte(&temp);
3680 macHeader->vA1[5] = getByte(&temp);
3681
3682 macHeader->vA2[0] = getByte(&temp);
3683 macHeader->vA2[1] = getByte(&temp);
3684 macHeader->vA2[2] = getByte(&temp);
3685 macHeader->vA2[3] = getByte(&temp);
3686 macHeader->vA2[4] = getByte(&temp);
3687 macHeader->vA2[5] = getByte(&temp);
3688
3689 macHeader->vA3[0] = getByte(&temp);
3690 macHeader->vA3[1] = getByte(&temp);
3691 macHeader->vA3[2] = getByte(&temp);
3692 macHeader->vA3[3] = getByte(&temp);
3693 macHeader->vA3[4] = getByte(&temp);
3694 macHeader->vA3[5] = getByte(&temp);
3695
3696 macHeader->sSeqCtrl = getByte(&temp);
3697 fragNum = macHeader->sSeqCtrl & 0xF;
3698 macHeader->sSeqCtrl >>= 4;
3699
3700 macHeader->sSeqCtrl += getByte(&temp) << 4;
3701
3702 macHeader->sSeqCtrl |= fragNum << 12;
3703
3704 if (length == 30 || length == 32) {
3705 macHeader->optvA4[0] = getByte(&temp);
3706 macHeader->optvA4[1] = getByte(&temp);
3707 macHeader->optvA4[2] = getByte(&temp);
3708 macHeader->optvA4[3] = getByte(&temp);
3709 macHeader->optvA4[4] = getByte(&temp);
3710 macHeader->optvA4[5] = getByte(&temp);
3711 }
3712
3713 if (length == 26 || length == 32) {
3714 macHeader->usQosCtrl = getByte(&temp);
3715 macHeader->usQosCtrl += getByte(&temp) << 8;
3716 }
3717
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303718 //parse payload
3719 length = getByte(&temp);
3720 length += getByte(&temp) << 8;
3721 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3722
3723 pkt->data.length = length;
3724
3725 for (i = 0; i< length; i++) {
3726 pkt->data.data[i] = getByte(&temp);
3727 }
3728
3729 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3730 &pkt->data.data[0], pkt->data.length, 0);
3731}
3732
3733/**---------------------------------------------------------------------------
3734
3735 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3736 encrypt message request
3737 This is an asynchronous callback function from SME when the encrypted data
3738 is received
3739
3740 \pEncInfoRsp -> Encrypted data info
3741
3742 \return - 0 for success non-zero for failure
3743 --------------------------------------------------------------------------*/
3744static void
3745hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3746{
3747 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3748
3749 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3750
3751 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3752 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3753 pEncryptedDataRsp->encryptedPayload.length);
3754 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3755 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3756 pEncryptedDataRsp->encryptedPayload.data,
3757 pEncryptedDataRsp->encryptedPayload.length, 0);
3758}
3759
Jeff Johnson295189b2012-06-20 16:38:30 -07003760VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3761{
3762 struct statsContext context;
3763 eHalStatus status;
3764 hdd_context_t *pHddCtx;
3765
3766 if (NULL == pAdapter)
3767 {
3768 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3769 return VOS_STATUS_E_FAULT;
3770 }
3771
3772 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3773 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303774 if (pHddCtx->isLogpInProgress) {
3775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3776 "%s:LOGP in Progress. Ignore!!!", __func__);
3777 return VOS_STATUS_E_FAILURE;
3778 }
3779
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 init_completion(&context.completion);
3781
3782 context.pAdapter = pAdapter;
3783 context.magic = POWER_CONTEXT_MAGIC;
3784
3785 if (DRIVER_POWER_MODE_ACTIVE == mode)
3786 {
3787 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3788 "Full Power", __func__);
3789 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3790 iw_power_callback_fn, &context,
3791 eSME_FULL_PWR_NEEDED_BY_HDD);
3792 // Enter Full power command received from GUI this means we are disconnected
3793 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3794 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3795 if (eHAL_STATUS_PMC_PENDING == status)
3796 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003797 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 int lrc = wait_for_completion_interruptible_timeout(
3799 &context.completion,
3800 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003801
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 if (lrc <= 0)
3803 {
3804 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003805 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 }
3807 }
3808 }
3809 else if (DRIVER_POWER_MODE_AUTO == mode)
3810 {
3811 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3812 {
3813 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3814 __func__);
3815 // Enter BMPS command received from GUI this means DHCP is completed
3816 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3817 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3818 FALSE);
3819 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3820 iw_power_callback_fn, &context);
3821 if (eHAL_STATUS_PMC_PENDING == status)
3822 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003823 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 int lrc = wait_for_completion_interruptible_timeout(
3825 &context.completion,
3826 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 if (lrc <= 0)
3828 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003829 hddLog(VOS_TRACE_LEVEL_ERROR,
3830 "%s: SME %s while requesting BMPS",
3831 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 }
3833 }
3834 }
3835 else
3836 {
3837 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3838 "enabled in the cfg");
3839 }
3840 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003841
3842 /* either we never sent a request, we sent a request and received a
3843 response or we sent a request and timed out. if we never sent a
3844 request or if we sent a request and got a response, we want to
3845 clear the magic out of paranoia. if we timed out there is a
3846 race condition such that the callback function could be
3847 executing at the same time we are. of primary concern is if the
3848 callback function had already verified the "magic" but had not
3849 yet set the completion variable when a timeout occurred. we
3850 serialize these activities by invalidating the magic while
3851 holding a shared spinlock which will cause us to block if the
3852 callback is currently executing */
3853 spin_lock(&hdd_context_lock);
3854 context.magic = 0;
3855 spin_unlock(&hdd_context_lock);
3856
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 return VOS_STATUS_SUCCESS;
3858}
3859
3860VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3861 hdd_adapter_t *pAdapter)
3862{
3863 VOS_STATUS vos_Status;
3864
3865 if ((NULL == pAdapter) || (NULL == pHddCtx))
3866 {
3867 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3868 return VOS_STATUS_E_FAULT;
3869 }
3870
3871 /**Exit from Deep sleep or standby if we get the driver
3872 START cmd from android GUI
3873 */
3874 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3875 {
3876 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3877 "from Stand by",__func__);
3878 vos_Status = hdd_exit_standby(pHddCtx);
3879 }
3880 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
3881 {
3882 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3883 "from deep sleep",__func__);
3884 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
3885 }
3886 else
3887 {
3888 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
3889 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
3890 vos_Status = VOS_STATUS_SUCCESS;
3891 }
3892
3893 return vos_Status;
3894}
3895
3896VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3897{
3898 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3899
3900 if (NULL == pHddCtx)
3901 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303902 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 return VOS_STATUS_E_FAULT;
3904 }
3905
3906 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3907 {
3908 //Execute standby procedure.
3909 //Executing standby procedure will cause the STA to
3910 //disassociate first and then the chip will be put into standby.
3911 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3912 vos_Status = hdd_enter_standby(pHddCtx);
3913 }
3914 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3915 pHddCtx->cfg_ini->nEnableDriverStop)
3916 {
3917 //Execute deep sleep procedure
3918 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003919 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 //Deep sleep not supported
3921 vos_Status = hdd_enter_standby(pHddCtx);
3922 }
3923 else
3924 {
3925 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3926 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3927 vos_Status = VOS_STATUS_SUCCESS;
3928 }
3929
3930 return vos_Status;
3931}
3932
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003933
3934void* wlan_hdd_change_country_code_callback(void *pAdapter)
3935{
3936
3937 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003938 complete(&call_back_pAdapter->change_country_code);
3939
3940 return NULL;
3941}
3942
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303943static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 struct iw_request_info *info,
3945 union iwreq_data *wrqu, char *extra)
3946{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303947 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08003948 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303950 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003951 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3952
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303953 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003954
3955 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303956
3957 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3958 if (NULL == pAdapter)
3959 {
3960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3961 "mem_alloc_copy_from_user_helper fail");
3962 return -EINVAL;
3963 }
3964 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3965 rc = wlan_hdd_validate_context(pHddCtx);
3966 if (0 != rc)
3967 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303968 return rc;
3969 }
3970
Arif Hussain24bfa702014-01-22 13:51:30 -08003971 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3972 wrqu->data.length);
3973 if (NULL == cmd)
3974 {
3975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3976 "mem_alloc_copy_from_user_helper fail");
3977 return -ENOMEM;
3978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003979
3980 if (ioctl_debug)
3981 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003982 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 }
3984
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003985 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3986 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003987
Arif Hussain24bfa702014-01-22 13:51:30 -08003988 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003990 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3992 "%s: Error in iw_set_scan!", __func__);
3993 rc = -EINVAL;
3994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 }
3996 else if( strcasecmp(cmd, "start") == 0 ) {
3997
Arif Hussain6d2a3322013-11-17 19:50:10 -08003998 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004000
Arif Hussain24bfa702014-01-22 13:51:30 -08004001 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4002 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 {
4004 union iwreq_data wrqu;
4005 char buf[10];
4006
4007 memset(&wrqu, 0, sizeof(wrqu));
4008 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4009 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4010 }
4011 else
4012 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004013 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4014 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 }
4016 goto done;
4017 }
4018 else if( strcasecmp(cmd, "stop") == 0 )
4019 {
4020 union iwreq_data wrqu;
4021 char buf[10];
4022
Arif Hussain6d2a3322013-11-17 19:50:10 -08004023 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004024
4025 wlan_hdd_enter_lowpower(pHddCtx);
4026 memset(&wrqu, 0, sizeof(wrqu));
4027 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4028 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 goto done;
4030 }
4031 else if (strcasecmp(cmd, "macaddr") == 0)
4032 {
4033 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4034 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4035 }
4036 else if (strcasecmp(cmd, "scan-active") == 0)
4037 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304038 hddLog(VOS_TRACE_LEVEL_ERROR,
4039 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004040 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 ret = snprintf(cmd, cmd_len, "OK");
4042 }
4043 else if (strcasecmp(cmd, "scan-passive") == 0)
4044 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304045 hddLog(VOS_TRACE_LEVEL_ERROR,
4046 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004047 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 ret = snprintf(cmd, cmd_len, "OK");
4049 }
4050 else if( strcasecmp(cmd, "scan-mode") == 0 )
4051 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004052 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 }
4054 else if( strcasecmp(cmd, "linkspeed") == 0 )
4055 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004056 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 }
4058 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4059 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004060 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004061 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004062
4063 country_code = cmd + 8;
4064
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004065 init_completion(&pAdapter->change_country_code);
4066
Arif Hussain24bfa702014-01-22 13:51:30 -08004067 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004068 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 country_code,
4070 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304071 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304072 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304073 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004074
4075 /* Wait for completion */
4076 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4077 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4078
4079 if (lrc <= 0)
4080 {
4081 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004082 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004083 }
4084
Arif Hussain24bfa702014-01-22 13:51:30 -08004085 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004087 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004088 "%s: SME Change Country code fail", __func__);
4089 kfree(cmd);
4090 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 }
4092 }
4093 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4094 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004095 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 }
4097 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4098 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004099 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004100
Wilson Yang1be3e652013-10-09 15:18:31 -07004101 if (9 < cmd_len)
4102 {
4103 ptr = (char*)(cmd + 9);
4104
4105 }else{
4106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4107 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004108 kfree(cmd);
4109 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004110 }
4111
4112 if (1 != sscanf(ptr,"%d",&mode))
4113 {
4114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4115 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004116 kfree(cmd);
4117 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004118 }
4119
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 wlan_hdd_enter_bmps(pAdapter, mode);
4121 /*TODO:Set the power mode*/
4122 }
4123 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4124 v_U32_t pmc_state;
4125 v_U16_t value;
4126
4127 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4128 if(pmc_state == BMPS) {
4129 value = DRIVER_POWER_MODE_AUTO;
4130 }
4131 else {
4132 value = DRIVER_POWER_MODE_ACTIVE;
4133 }
4134 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4135 }
4136 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004137 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 /*TODO: set the btcoexmode*/
4139 }
4140 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4141
Arif Hussain6d2a3322013-11-17 19:50:10 -08004142 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 /*TODO: Return the btcoex status*/
4144 }
4145 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4146
Arif Hussain6d2a3322013-11-17 19:50:10 -08004147 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004148
4149 /*TODO: Enable Rx data Filter*/
4150 }
4151 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4152
Arif Hussain6d2a3322013-11-17 19:50:10 -08004153 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004154
4155 /*TODO: Disable Rx data Filter*/
4156 }
4157 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4158
Arif Hussain6d2a3322013-11-17 19:50:10 -08004159 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 /*TODO: rxfilter-statistics*/
4161 }
4162 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4163
Arif Hussain6d2a3322013-11-17 19:50:10 -08004164 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 /*TODO: rxfilter-add*/
4166 }
4167 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4168
Arif Hussain6d2a3322013-11-17 19:50:10 -08004169 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 /*TODO: rxfilter-remove*/
4171 }
4172#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004173 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4174 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4175 /*TODO: support pnosetup*/
4176 }
4177 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4178 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4179 /*TODO: support pnoforce*/
4180 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4182
Arif Hussain6d2a3322013-11-17 19:50:10 -08004183 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004184 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4185 kfree(cmd);
4186 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 }
4188 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004189 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004190 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4191 kfree(cmd);
4192 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 }
4194#endif /*FEATURE_WLAN_SCAN_PNO*/
4195 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004196 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004197 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4198 kfree(cmd);
4199 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 }
4201 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4202 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004203 char *ptr;
4204
4205 if (18 < cmd_len)
4206 {
4207 ptr = (char*)(cmd + 18);
4208 }else{
4209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4210 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004211 kfree(cmd);
4212 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004213 }
4214
Jeff Johnson02797792013-10-26 19:17:13 -07004215 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004216 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4217 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4218 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4219 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4220 {
4221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4222 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004223 kfree(cmd);
4224 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004226
4227 // parameters checking
4228 // period has to be larger than 0
4229 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4230 {
4231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004232 kfree(cmd);
4233 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 }
4235
4236 // use default value 5 is the input is not reasonable. in unit of 10%
4237 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4238 {
4239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4240 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4241 }
4242
4243 // default is 5
4244 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4245 {
4246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4247 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4248 }
4249
Arif Hussain24bfa702014-01-22 13:51:30 -08004250 if (eHAL_STATUS_SUCCESS !=
4251 sme_SetTxPerTracking(pHddCtx->hHal,
4252 hdd_tx_per_hit_cb,
4253 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004255 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 }
4257 }
4258 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004259 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4260 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 }
4262done:
4263 /* many of the commands write information back into the command
4264 string using snprintf(). check the return value here in one
4265 place */
4266 if ((ret < 0) || (ret >= cmd_len))
4267 {
4268 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004269 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004271 else if (ret > 0)
4272 {
4273 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4274 {
4275 hddLog(VOS_TRACE_LEVEL_ERROR,
4276 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004277 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004278 return -EFAULT;
4279 }
4280 wrqu->data.length = ret;
4281 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004282
4283 if (ioctl_debug)
4284 {
4285 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004286 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004288 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304289 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004290 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004291}
4292
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304293static int iw_set_priv(struct net_device *dev,
4294 struct iw_request_info *info,
4295 union iwreq_data *wrqu, char *extra)
4296{
4297 int ret;
4298 vos_ssr_protect(__func__);
4299 ret = __iw_set_priv(dev, info, wrqu, extra);
4300 vos_ssr_unprotect(__func__);
4301
4302 return ret;
4303}
4304
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304305static int __iw_set_nick(struct net_device *dev,
4306 struct iw_request_info *info,
4307 union iwreq_data *wrqu, char *extra)
4308{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304309 hdd_adapter_t *pAdapter;
4310 hdd_context_t *pHddCtx;
4311 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304312
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304313 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304314
4315 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4316 if (NULL == pAdapter)
4317 {
4318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4319 "%s: Adapter is NULL",__func__);
4320 return -EINVAL;
4321 }
4322
4323 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4324 ret = wlan_hdd_validate_context(pHddCtx);
4325 if (0 != ret)
4326 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304327 return ret;
4328 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304329 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304330 return 0;
4331}
4332
Jeff Johnson295189b2012-06-20 16:38:30 -07004333static int iw_set_nick(struct net_device *dev,
4334 struct iw_request_info *info,
4335 union iwreq_data *wrqu, char *extra)
4336{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304337 int ret;
4338
4339 vos_ssr_protect(__func__);
4340 ret = __iw_set_nick(dev, info, wrqu, extra);
4341 vos_ssr_unprotect(__func__);
4342
4343 return ret;
4344}
4345
4346static int __iw_get_nick(struct net_device *dev,
4347 struct iw_request_info *info,
4348 union iwreq_data *wrqu, char *extra)
4349{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304350 hdd_adapter_t *pAdapter;
4351 hdd_context_t *pHddCtx;
4352 int ret = 0;
4353
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304355
4356 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4357 if (NULL == pAdapter)
4358 {
4359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4360 "%s: Adapter is NULL",__func__);
4361 return -EINVAL;
4362 }
4363
4364 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4365 ret = wlan_hdd_validate_context(pHddCtx);
4366 if (0 != ret)
4367 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304368 return ret;
4369 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304370 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 return 0;
4372}
4373
4374static int iw_get_nick(struct net_device *dev,
4375 struct iw_request_info *info,
4376 union iwreq_data *wrqu, char *extra)
4377{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304378 int ret;
4379
4380 vos_ssr_protect(__func__);
4381 ret = __iw_get_nick(dev, info, wrqu, extra);
4382 vos_ssr_unprotect(__func__);
4383
4384 return ret;
4385}
4386
4387static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4388{
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304390 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004391}
4392
4393static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4394{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304395
4396 struct iw_statistics *stats;
4397
4398 vos_ssr_protect(__func__);
4399 stats = __get_wireless_stats(dev);
4400 vos_ssr_unprotect(__func__);
4401
4402 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004403}
4404
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304405static int __iw_set_encode(struct net_device *dev,
4406 struct iw_request_info *info,
4407 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004408
4409{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304410 hdd_adapter_t *pAdapter;
4411 hdd_station_ctx_t *pHddStaCtx;
4412 hdd_wext_state_t *pWextState;
4413 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 struct iw_point *encoderq = &(wrqu->encoding);
4415 v_U32_t keyId;
4416 v_U8_t key_length;
4417 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4418 v_BOOL_t fKeyPresent = 0;
4419 int i;
4420 eHalStatus status = eHAL_STATUS_SUCCESS;
4421
4422
4423 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304424 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4425 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4428 "%s: Adapter is NULL",__func__);
4429 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004430 }
4431
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304432 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4433 status = wlan_hdd_validate_context(pHddCtx);
4434 if (0 != status)
4435 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304436 return status;
4437 }
4438 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4439 if (NULL == pWextState)
4440 {
4441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4442 "%s: pWextState is NULL ",__func__);
4443 return -EINVAL;
4444 }
4445 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4446 if (NULL == pHddStaCtx)
4447 {
4448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4449 "%s: STA Context is NULL",__func__);
4450 return -EINVAL;
4451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004452
4453 keyId = encoderq->flags & IW_ENCODE_INDEX;
4454
4455 if(keyId)
4456 {
4457 if(keyId > MAX_WEP_KEYS)
4458 {
4459 return -EINVAL;
4460 }
4461
4462 fKeyPresent = 1;
4463 keyId--;
4464 }
4465 else
4466 {
4467 fKeyPresent = 0;
4468 }
4469
4470
4471 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4472 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 if(!fKeyPresent) {
4475
4476 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4477
4478 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4479 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4480 }
4481 }
4482 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4483 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4484 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4485 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4486
4487 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4488 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4489
4490 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4491 {
4492 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4493 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004494 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304495 {
4496 long ret;
4497 ret = wait_for_completion_interruptible_timeout(
4498 &pAdapter->disconnect_comp_var,
4499 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4500 if (ret <= 0)
4501 hddLog(VOS_TRACE_LEVEL_ERROR,
4502 FL("failed wait on disconnect_comp_var %ld"), ret);
4503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 }
4505
4506 return status;
4507
4508 }
4509
4510 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4511 {
4512 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4513
4514 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4515
4516 }
4517
4518
4519 if(wrqu->data.length > 0)
4520 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004521 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004522
4523 key_length = wrqu->data.length;
4524
4525 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4526
4527 if(5 == key_length)
4528 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004529 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004530
4531 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4532 {
4533 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4534 }
4535 else
4536 {
4537 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4538 }
4539 }
4540 else if(13 == key_length)
4541 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004542 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004543
4544 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4545 {
4546 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4547 }
4548 else
4549 {
4550 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4551 }
4552 }
4553 else
4554 {
4555 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004556 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 return -EINVAL;
4558 }
4559
4560 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4561 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4562 pWextState->roamProfile.EncryptionType.numEntries = 1;
4563 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4564 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4565 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4566
4567 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4568 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4569 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4570 {
4571
4572 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4573
4574 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4575 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4576
4577 return status;
4578 }
4579 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304580 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 return 0;
4582}
4583
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304584static int iw_set_encode(struct net_device *dev,
4585 struct iw_request_info *info,
4586 union iwreq_data *wrqu,char *extra)
4587{
4588 int ret;
4589
4590 vos_ssr_protect(__func__);
4591 ret = __iw_set_encode(dev, info, wrqu, extra);
4592 vos_ssr_unprotect(__func__);
4593
4594 return ret;
4595}
4596
4597static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 struct iw_request_info *info,
4599 struct iw_point *dwrq,
4600 char *extra)
4601{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304602 hdd_adapter_t *pAdapter;
4603 hdd_wext_state_t *pWextState;
4604 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 int keyId;
4606 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4607 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304608 int i, ret = 0;
4609 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004610
4611 ENTER();
4612
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304613 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4614 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004615 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4617 "%s: Adapter is NULL",__func__);
4618 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004619 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304620 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4621 ret = wlan_hdd_validate_context(pHddCtx);
4622 if (0 != ret)
4623 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304624 return ret;
4625 }
4626 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4627 if (NULL == pWextState)
4628 {
4629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4630 "%s: pWextState is NULL",__func__);
4631 return -EINVAL;
4632 }
4633 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004634
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 keyId = pRoamProfile->Keys.defaultIndex;
4636
4637 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4638 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004639 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 return -EINVAL;
4641 }
4642
4643 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4644 {
4645 dwrq->flags |= IW_ENCODE_ENABLED;
4646 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304647 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4648 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 }
4650 else
4651 {
4652 dwrq->flags |= IW_ENCODE_DISABLED;
4653 }
4654
4655 for(i=0; i < MAX_WEP_KEYS; i++)
4656 {
4657 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4658 {
4659 continue;
4660 }
4661 else
4662 {
4663 break;
4664 }
4665 }
4666
4667 if(MAX_WEP_KEYS == i)
4668 {
4669 dwrq->flags |= IW_ENCODE_NOKEY;
4670 }
4671 else
4672 {
4673 dwrq->flags |= IW_ENCODE_ENABLED;
4674 }
4675
4676 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4677
4678 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4679 {
4680 dwrq->flags |= IW_ENCODE_DISABLED;
4681 }
4682
4683 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4684
4685 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4686 {
4687 dwrq->flags |= IW_ENCODE_OPEN;
4688 }
4689 else
4690 {
4691 dwrq->flags |= IW_ENCODE_RESTRICTED;
4692 }
4693 EXIT();
4694 return 0;
4695
4696}
4697
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304698static int iw_get_encodeext(struct net_device *dev,
4699 struct iw_request_info *info,
4700 struct iw_point *dwrq,
4701 char *extra)
4702{
4703 int ret;
4704 vos_ssr_protect(__func__);
4705 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4706 vos_ssr_unprotect(__func__);
4707
4708 return ret;
4709}
4710
4711static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 struct iw_request_info *info,
4713 union iwreq_data *wrqu, char *extra)
4714{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304715 hdd_adapter_t *pAdapter;
4716 hdd_station_ctx_t *pHddStaCtx;
4717 hdd_wext_state_t *pWextState;
4718 hdd_context_t *pHddCtx;
4719 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004720
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304721 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 v_U32_t status = 0;
4723
4724 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4725
4726 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4727
4728 int key_index;
4729 struct iw_point *encoding = &wrqu->encoding;
4730 tCsrRoamSetKey setKey;
4731 v_U32_t roamId= 0xFF;
4732 VOS_STATUS vos_status;
4733
4734 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304735 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4736 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4739 "%s: Adapter is NULL",__func__);
4740 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304742 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4743 status = wlan_hdd_validate_context(pHddCtx);
4744 if (0 != status)
4745 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304746 return status;
4747 }
4748 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4749 if (NULL == pHddStaCtx)
4750 {
4751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4752 "%s: STA Context is NULL",__func__);
4753 return -EINVAL;
4754 }
4755 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4756 if (NULL == pWextState)
4757 {
4758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4759 "%s: pWextState is NULL",__func__);
4760 return -EINVAL;
4761 }
4762 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 key_index = encoding->flags & IW_ENCODE_INDEX;
4764
4765 if(key_index > 0) {
4766
4767 /*Convert from 1-based to 0-based keying*/
4768 key_index--;
4769 }
4770 if(!ext->key_len) {
4771
4772 /*Set the encrytion type to NONE*/
4773 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4774 return status;
4775 }
4776
4777 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4778 (IW_ENCODE_ALG_WEP == ext->alg))
4779 {
4780 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4781
Agarwal Ashish971c2882013-10-30 20:11:12 +05304782 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4783 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 return -EINVAL;
4785 }
4786 else {
4787 /*Static wep, update the roam profile with the keys */
4788 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4789 key_index < CSR_MAX_NUM_KEY) {
4790 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4791 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4792
4793 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4794 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4795
4796 }
4797 }
4798 return status;
4799 }
4800
4801 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4802
4803 setKey.keyId = key_index;
4804 setKey.keyLength = ext->key_len;
4805
4806 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4807 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4808 }
4809
4810 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4811 /*Key direction for group is RX only*/
4812 setKey.keyDirection = eSIR_RX_ONLY;
4813 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4814 }
4815 else {
4816
4817 setKey.keyDirection = eSIR_TX_RX;
4818 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4819 }
4820
4821 /*For supplicant pae role is zero*/
4822 setKey.paeRole = 0;
4823
4824 switch(ext->alg)
4825 {
4826 case IW_ENCODE_ALG_NONE:
4827 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4828 break;
4829
4830 case IW_ENCODE_ALG_WEP:
4831 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4832 break;
4833
4834 case IW_ENCODE_ALG_TKIP:
4835 {
4836 v_U8_t *pKey = &setKey.Key[0];
4837
4838 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4839
4840 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4841
4842 /*Supplicant sends the 32bytes key in this order
4843
4844 |--------------|----------|----------|
4845 | Tk1 |TX-MIC | RX Mic |
4846 |--------------|----------|----------|
4847 <---16bytes---><--8bytes--><--8bytes-->
4848
4849 */
4850 /*Sme expects the 32 bytes key to be in the below order
4851
4852 |--------------|----------|----------|
4853 | Tk1 |RX-MIC | TX Mic |
4854 |--------------|----------|----------|
4855 <---16bytes---><--8bytes--><--8bytes-->
4856 */
4857 /* Copy the Temporal Key 1 (TK1) */
4858 vos_mem_copy(pKey,ext->key,16);
4859
4860 /*Copy the rx mic first*/
4861 vos_mem_copy(&pKey[16],&ext->key[24],8);
4862
4863 /*Copy the tx mic */
4864 vos_mem_copy(&pKey[24],&ext->key[16],8);
4865
4866 }
4867 break;
4868
4869 case IW_ENCODE_ALG_CCMP:
4870 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4871 break;
4872
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004873#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004874#define IW_ENCODE_ALG_KRK 6
4875 case IW_ENCODE_ALG_KRK:
4876 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4877 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004878#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004879
4880 default:
4881 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4882 break;
4883 }
4884
4885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004886 ("%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 -07004887
4888#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304889 /* The supplicant may attempt to set the PTK once pre-authentication
4890 is done. Save the key in the UMAC and include it in the ADD
4891 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304893 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05304895 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4896 "%s: Update PreAuth Key success", __func__);
4897 return 0;
4898 }
4899 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
4900 {
4901 hddLog(VOS_TRACE_LEVEL_ERROR,
4902 "%s: Update PreAuth Key failed", __func__);
4903 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 }
4905#endif /* WLAN_FEATURE_VOWIFI_11R */
4906
4907 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4908
4909 vos_status = wlan_hdd_check_ula_done(pAdapter);
4910 if ( vos_status != VOS_STATUS_SUCCESS )
4911 {
4912 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4913 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
4914 __LINE__, vos_status );
4915
4916 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4917 }
4918
4919 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
4920
4921 if ( halStatus != eHAL_STATUS_SUCCESS )
4922 {
4923 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4924 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4925 __LINE__, halStatus );
4926
4927 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4928 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304929 EXIT();
4930 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004931}
4932
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304933static int iw_set_encodeext(struct net_device *dev,
4934 struct iw_request_info *info,
4935 union iwreq_data *wrqu, char *extra)
4936{
4937 int ret;
4938
4939 vos_ssr_protect(__func__);
4940 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4941 vos_ssr_unprotect(__func__);
4942
4943 return ret;
4944}
4945
4946static int __iw_set_retry(struct net_device *dev,
4947 struct iw_request_info *info,
4948 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004949{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304950 hdd_adapter_t *pAdapter;
4951 tHalHandle hHal;
4952 hdd_context_t *pHddCtx;
4953 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004954
4955 ENTER();
4956
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304957 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4958 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004959 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4961 "%s: Adapter is NULL",__func__);
4962 return -EINVAL;
4963 }
4964
4965 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4966 ret = wlan_hdd_validate_context(pHddCtx);
4967 if (0 != ret)
4968 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304969 return ret;
4970 }
4971
4972 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4973 if (NULL == hHal)
4974 {
4975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4976 "%s: Hal Context is NULL",__func__);
4977 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004978 }
4979
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4981 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4982
Arif Hussain6d2a3322013-11-17 19:50:10 -08004983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004984
4985 return -EINVAL;
4986 }
4987
4988 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
4989
4990 if((wrqu->retry.flags & IW_RETRY_LONG))
4991 {
4992 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
4993 {
c_hpothub8245442013-11-20 23:41:09 +05304994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4995 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 return -EIO;
4997 }
4998 }
4999 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5000 {
5001 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5002 {
c_hpothub8245442013-11-20 23:41:09 +05305003 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5004 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 return -EIO;
5006 }
5007 }
5008 }
5009 else
5010 {
5011 return -EOPNOTSUPP;
5012 }
5013
Arif Hussain6d2a3322013-11-17 19:50:10 -08005014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005015
5016 EXIT();
5017
5018 return 0;
5019
5020}
5021
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305022static int iw_set_retry(struct net_device *dev,
5023 struct iw_request_info *info,
5024 union iwreq_data *wrqu, char *extra)
5025{
5026 int ret;
5027
5028 vos_ssr_protect(__func__);
5029 ret = __iw_set_retry(dev, info, wrqu, extra);
5030 vos_ssr_unprotect(__func__);
5031
5032 return ret;
5033}
5034
5035static int __iw_get_retry(struct net_device *dev,
5036 struct iw_request_info *info,
5037 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005038{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305039 hdd_adapter_t *pAdapter;
5040 hdd_context_t *pHddCtx;
5041 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305043 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005044
5045 ENTER();
5046
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305047 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5048 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005049 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5051 "%s: Adapter is NULL",__func__);
5052 return -EINVAL;
5053 }
5054
5055 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5056 ret = wlan_hdd_validate_context(pHddCtx);
5057 if (0 != ret)
5058 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305059 return ret;
5060 }
5061
5062 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5063 if (NULL == hHal)
5064 {
5065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5066 "%s: Hal Context is NULL",__func__);
5067 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005068 }
5069
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 if((wrqu->retry.flags & IW_RETRY_LONG))
5071 {
5072 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5073
5074 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5075 {
c_hpothub8245442013-11-20 23:41:09 +05305076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5077 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 return -EIO;
5079 }
5080
5081 wrqu->retry.value = retry;
5082 }
5083 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5084 {
5085 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5086
5087 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5088 {
c_hpothub8245442013-11-20 23:41:09 +05305089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5090 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 return -EIO;
5092 }
5093
5094 wrqu->retry.value = retry;
5095 }
5096 else {
5097 return -EOPNOTSUPP;
5098 }
5099
Arif Hussain6d2a3322013-11-17 19:50:10 -08005100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005101
5102 EXIT();
5103
5104 return 0;
5105}
5106
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305107static int iw_get_retry(struct net_device *dev,
5108 struct iw_request_info *info,
5109 union iwreq_data *wrqu, char *extra)
5110{
5111 int ret;
5112
5113 vos_ssr_protect(__func__);
5114 ret = __iw_get_retry(dev, info, wrqu, extra);
5115 vos_ssr_unprotect(__func__);
5116
5117 return ret;
5118}
5119
5120static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 struct iw_request_info *info,
5122 union iwreq_data *wrqu,
5123 char *extra)
5124{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305125 hdd_adapter_t *pAdapter;
5126 hdd_context_t *pHddCtx;
5127 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5129 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305130 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005131
5132 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305133 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5134 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5137 "%s:Adapter is NULL",__func__);
5138 return -EINVAL;
5139 }
5140 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5141 ret = wlan_hdd_validate_context(pHddCtx);
5142 if (0 != ret)
5143 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305144 return ret;
5145 }
5146 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5147 if (NULL == pHddStaCtx)
5148 {
5149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5150 "%s:STA context is NULL",__func__);
5151 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 }
5153
5154 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5155 switch (mlme->cmd) {
5156 case IW_MLME_DISASSOC:
5157 case IW_MLME_DEAUTH:
5158
5159 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5160 {
5161 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5162
5163 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5164 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5165
5166 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5167 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5168
Jeff Johnson43971f52012-07-17 12:26:56 -07005169 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305170 {
5171 long ret;
5172 ret = wait_for_completion_interruptible_timeout(
5173 &pAdapter->disconnect_comp_var,
5174 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5175 if (ret <= 0)
5176 hddLog(VOS_TRACE_LEVEL_ERROR,
5177 FL("failed wait on disconnect_comp_var %ld"), ret);
5178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005180 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005181 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005182
5183 /* Resetting authKeyMgmt */
5184 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5185
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305186 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005187 netif_tx_disable(dev);
5188 netif_carrier_off(dev);
5189
5190 }
5191 else
5192 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005193 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 -07005194 }
5195 break;
5196 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005197 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 return -EINVAL;
5199 }//end of switch
5200
5201 EXIT();
5202
5203 return status;
5204
5205}
5206
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305207static int iw_set_mlme(struct net_device *dev,
5208 struct iw_request_info *info,
5209 union iwreq_data *wrqu,
5210 char *extra)
5211{
5212 int ret;
5213
5214 vos_ssr_protect(__func__);
5215 ret = __iw_set_mlme(dev, info, wrqu, extra);
5216 vos_ssr_unprotect(__func__);
5217
5218 return ret;
5219}
5220
Jeff Johnson295189b2012-06-20 16:38:30 -07005221/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305222static int __iw_setint_getnone(struct net_device *dev,
5223 struct iw_request_info *info,
5224 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005225{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305226 hdd_adapter_t *pAdapter;
5227 tHalHandle hHal;
5228 hdd_wext_state_t *pWextState;
5229 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005230 int *value = (int *)extra;
5231 int sub_cmd = value[0];
5232 int set_value = value[1];
5233 int ret = 0; /* success */
5234 int enable_pbm, enable_mp;
5235#ifdef CONFIG_HAS_EARLYSUSPEND
5236 v_U8_t nEnableSuspendOld;
5237#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005238
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305239 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305240 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5241 if (NULL == pAdapter)
5242 {
5243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5244 "%s: Adapter is NULL",__func__);
5245 return -EINVAL;
5246 }
5247 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5248 ret = wlan_hdd_validate_context(pHddCtx);
5249 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005250 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305251 return ret;
5252 }
5253 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5254 if (NULL == hHal)
5255 {
5256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5257 "%s: Hal Context is NULL",__func__);
5258 return -EINVAL;
5259 }
5260 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5261 if (NULL == pWextState)
5262 {
5263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5264 "%s: pWextState is NULL",__func__);
5265 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005266 }
5267
c_hpothu4a298be2014-12-22 21:12:51 +05305268 INIT_COMPLETION(pWextState->completion_var);
5269
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 switch(sub_cmd)
5271 {
5272 case WE_SET_11D_STATE:
5273 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005274 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005275 memset(&smeConfig, 0x00, sizeof(smeConfig));
5276
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5278
5279 sme_GetConfigParam(hHal,&smeConfig);
5280 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5281
Arif Hussain6d2a3322013-11-17 19:50:10 -08005282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005283
5284 sme_UpdateConfig(hHal,&smeConfig);
5285 }
5286 else {
5287 return -EINVAL;
5288 }
5289 break;
5290 }
5291
5292 case WE_WOWL:
5293 {
5294 switch (set_value)
5295 {
5296 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305297 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 break;
5299 case 0x01:
5300 case 0x02:
5301 case 0x03:
5302 enable_mp = (set_value & 0x01) ? 1 : 0;
5303 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005304 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5306 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5307 break;
5308 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005309 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 ret = -EINVAL;
5311 break;
5312 }
5313
5314 break;
5315 }
5316 case WE_SET_POWER:
5317 {
5318 switch (set_value)
5319 {
5320 case 0: //Full Power
5321 {
5322 struct statsContext context;
5323 eHalStatus status;
5324
5325 init_completion(&context.completion);
5326
5327 context.pAdapter = pAdapter;
5328 context.magic = POWER_CONTEXT_MAGIC;
5329
5330 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5331 iw_power_callback_fn, &context,
5332 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005333 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 {
5335 int lrc = wait_for_completion_interruptible_timeout(
5336 &context.completion,
5337 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005338
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 if (lrc <= 0)
5340 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005341 hddLog(VOS_TRACE_LEVEL_ERROR,
5342 "%s: SME %s while requesting fullpower",
5343 __func__, (0 == lrc) ?
5344 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 }
5346 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005347 /* either we have a response or we timed out. if we timed
5348 out there is a race condition such that the callback
5349 function could be executing at the same time we are. of
5350 primary concern is if the callback function had already
5351 verified the "magic" but had not yet set the completion
5352 variable when a timeout occurred. we serialize these
5353 activities by invalidating the magic while holding a
5354 shared spinlock which will cause us to block if the
5355 callback is currently executing */
5356 spin_lock(&hdd_context_lock);
5357 context.magic = 0;
5358 spin_unlock(&hdd_context_lock);
5359
Arif Hussain6d2a3322013-11-17 19:50:10 -08005360 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 break;
5362 }
5363 case 1: //Enable BMPS
5364 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5365 break;
5366 case 2: //Disable BMPS
5367 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5368 break;
5369 case 3: //Request Bmps
5370 {
5371 struct statsContext context;
5372 eHalStatus status;
5373
5374 init_completion(&context.completion);
5375
5376 context.pAdapter = pAdapter;
5377 context.magic = POWER_CONTEXT_MAGIC;
5378
5379 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5380 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005381 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 {
5383 int lrc = wait_for_completion_interruptible_timeout(
5384 &context.completion,
5385 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 if (lrc <= 0)
5387 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005388 hddLog(VOS_TRACE_LEVEL_ERROR,
5389 "%s: SME %s while requesting BMPS",
5390 __func__, (0 == lrc) ? "timeout" :
5391 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 }
5393 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005394 /* either we have a response or we timed out. if we
5395 timed out there is a race condition such that the
5396 callback function could be executing at the same
5397 time we are. of primary concern is if the callback
5398 function had already verified the "magic" but had
5399 not yet set the completion variable when a timeout
5400 occurred. we serialize these activities by
5401 invalidating the magic while holding a shared
5402 spinlock which will cause us to block if the
5403 callback is currently executing */
5404 spin_lock(&hdd_context_lock);
5405 context.magic = 0;
5406 spin_unlock(&hdd_context_lock);
5407
Arif Hussain6d2a3322013-11-17 19:50:10 -08005408 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 break;
5410 }
5411 case 4: //Enable IMPS
5412 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5413 break;
5414 case 5: //Disable IMPS
5415 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5416 break;
5417 case 6: //Enable Standby
5418 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5419 break;
5420 case 7: //Disable Standby
5421 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5422 break;
5423 case 8: //Request Standby
5424#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005425#endif
5426 break;
5427 case 9: //Start Auto Bmps Timer
5428 sme_StartAutoBmpsTimer(hHal);
5429 break;
5430 case 10://Stop Auto BMPS Timer
5431 sme_StopAutoBmpsTimer(hHal);
5432 break;
5433#ifdef CONFIG_HAS_EARLYSUSPEND
5434 case 11://suspend to standby
5435#ifdef CONFIG_HAS_EARLYSUSPEND
5436 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5437 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5439#endif
5440 break;
5441 case 12://suspend to deep sleep
5442#ifdef CONFIG_HAS_EARLYSUSPEND
5443 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5444 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005445 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5446#endif
5447 break;
5448 case 13://resume from suspend
5449#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005450#endif
5451 break;
5452#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005454 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 ret = -EINVAL;
5456 break;
5457 }
5458 break;
5459 }
5460
5461 case WE_SET_MAX_ASSOC:
5462 {
5463 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5464 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5465 {
5466 ret = -EINVAL;
5467 }
5468 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5469 set_value, NULL, eANI_BOOLEAN_FALSE)
5470 != eHAL_STATUS_SUCCESS )
5471 {
c_hpothub8245442013-11-20 23:41:09 +05305472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5473 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005474 ret = -EIO;
5475 }
5476 break;
5477 }
5478
5479 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5480 {
5481 if( 0 == set_value )
5482 {
5483 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5484 }
5485 else if ( 1 == set_value )
5486 {
5487 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5488 }
5489 else
5490 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005491 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 ret = -EINVAL;
5493 }
5494 break;
5495 }
5496
5497 case WE_SET_DATA_INACTIVITY_TO:
5498 {
5499 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5500 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5501 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5502 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5503 set_value,
5504 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5505 {
5506 hddLog(LOGE,"Failure: Could not pass on "
5507 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005508 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 ret = -EINVAL;
5510 }
5511 break;
5512 }
5513 case WE_SET_MAX_TX_POWER:
5514 {
5515 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5516 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5517
5518 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5519 __func__, set_value);
5520 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5521 eHAL_STATUS_SUCCESS )
5522 {
5523 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5524 __func__);
5525 return -EIO;
5526 }
5527
5528 break;
5529 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005530 case WE_SET_MAX_TX_POWER_2_4:
5531 {
5532 hddLog(VOS_TRACE_LEVEL_INFO,
5533 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5534 __func__, set_value);
5535 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5536 eHAL_STATUS_SUCCESS)
5537 {
5538 hddLog(VOS_TRACE_LEVEL_ERROR,
5539 "%s: Setting maximum tx power failed for 2.4 GHz band",
5540 __func__);
5541 return -EIO;
5542 }
5543
5544 break;
5545 }
5546 case WE_SET_MAX_TX_POWER_5_0:
5547 {
5548 hddLog(VOS_TRACE_LEVEL_INFO,
5549 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5550 __func__, set_value);
5551 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5552 eHAL_STATUS_SUCCESS)
5553 {
5554 hddLog(VOS_TRACE_LEVEL_ERROR,
5555 "%s: Setting maximum tx power failed for 5.0 GHz band",
5556 __func__);
5557 return -EIO;
5558 }
5559
5560 break;
5561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 case WE_SET_HIGHER_DTIM_TRANSITION:
5563 {
5564 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5565 (set_value == eANI_BOOLEAN_TRUE)))
5566 {
5567 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5568 ret = -EINVAL;
5569 }
5570 else
5571 {
5572 if(pAdapter->higherDtimTransition != set_value)
5573 {
5574 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005575 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 }
5577 }
5578
5579 break;
5580 }
5581
5582 case WE_SET_TM_LEVEL:
5583 {
5584 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005585 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005586 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5587
5588 break;
5589 }
5590
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305591 case WE_ENABLE_STRICT_FCC_REG:
5592 {
5593 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5594 struct wiphy *wiphy = NULL;
5595 long lrc;
5596 int status;
5597
5598 wiphy = hddCtxt->wiphy;
5599 if(wiphy == NULL)
5600 {
5601 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5602 break;
5603 }
5604 init_completion(&hddCtxt->wiphy_channel_update_event);
5605
5606 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5607
5608 status = regulatory_hint(wiphy, "00");
5609 if(status < 0)
5610 {
5611 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5612 break;
5613 }
5614
5615 /* Wait for completion */
5616 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5617 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5618 if (lrc <= 0)
5619 {
5620 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5621 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5622 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5623 }
5624 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5625
5626 break;
5627 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005628 case WE_SET_DEBUG_LOG:
5629 {
5630 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5631 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5632 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5633 break;
5634 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305635#ifdef FEATURE_WLAN_TDLS
5636 case WE_SET_TDLS_OFF_CHAN:
5637 {
5638 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5640 __func__, set_value);
5641 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5642 break;
5643 }
5644 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5645 {
5646 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5647 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5648 __func__, set_value);
5649 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5650 break;
5651 }
5652 case WE_SET_TDLS_OFF_CHAN_MODE:
5653 {
5654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5655 __func__, set_value);
5656 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5657 break;
5658 }
5659#endif
Peng Xu2446a892014-09-05 17:21:18 +05305660 case WE_SET_SCAN_BAND_PREFERENCE:
5661 {
5662 tSmeConfigParams smeConfig;
5663 memset(&smeConfig, 0x00, sizeof(smeConfig));
5664 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5665 ret = -EINVAL;
5666 break;
5667 }
5668 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5669
5670 if (eCSR_BAND_ALL == set_value ||
5671 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5672 sme_GetConfigParam(hHal, &smeConfig);
5673 smeConfig.csrConfig.scanBandPreference = set_value;
5674
5675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5676 "set band scan preference = %d\n",
5677 smeConfig.csrConfig.scanBandPreference);
5678
5679 sme_UpdateConfig(hHal, &smeConfig);
5680 }
5681 else {
5682 ret = -EINVAL;
5683 }
5684 break;
5685 }
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305686
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 default:
5688 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005689 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 sub_cmd, set_value);
5691 break;
5692 }
5693 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305694 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005695 return ret;
5696}
5697
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305698static int iw_setint_getnone(struct net_device *dev,
5699 struct iw_request_info *info,
5700 union iwreq_data *wrqu, char *extra)
5701{
5702 int ret;
5703
5704 vos_ssr_protect(__func__);
5705 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5706 vos_ssr_unprotect(__func__);
5707
5708 return 0;
5709}
Jeff Johnson295189b2012-06-20 16:38:30 -07005710/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305711static int __iw_setchar_getnone(struct net_device *dev,
5712 struct iw_request_info *info,
5713 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005714{
5715 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305716 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005718 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305719 hdd_adapter_t *pAdapter;
5720 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005721#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305722 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005723#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305724 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305725 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005726
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305727 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305728 pAdapter = (netdev_priv(dev));
5729 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005730 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5732 "%s: Adapter is NULL",__func__);
5733 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005734 }
5735
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305736 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5737 ret = wlan_hdd_validate_context(pHddCtx);
5738 if (0 != ret)
5739 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305740 return ret;
5741 }
5742#ifdef WLAN_FEATURE_VOWIFI
5743 pConfig = pHddCtx->cfg_ini;
5744#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305745 /* helper function to get iwreq_data with compat handling. */
5746 if (hdd_priv_get_data(&s_priv_data, wrqu))
5747 {
5748 return -EINVAL;
5749 }
5750
5751 /* make sure all params are correctly passed to function */
5752 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5753 {
5754 return -EINVAL;
5755 }
5756
5757 sub_cmd = s_priv_data.flags;
5758
Arif Hussain0273cba2014-01-07 20:58:29 -08005759 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305760 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5761 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005762 if (NULL == pBuffer)
5763 {
5764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5765 "mem_alloc_copy_from_user_helper fail");
5766 return -ENOMEM;
5767 }
5768
5769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305770 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5772 "%s: Received data %s", __func__, pBuffer);
5773
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 switch(sub_cmd)
5775 {
5776 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005778 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 break;
5780 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005782 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 break;
5784#if defined WLAN_FEATURE_VOWIFI
5785 case WE_NEIGHBOR_REPORT_REQUEST:
5786 {
5787 tRrmNeighborReq neighborReq;
5788 tRrmNeighborRspCallbackInfo callbackInfo;
5789
5790 if (pConfig->fRrmEnable)
5791 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305793 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 if( !neighborReq.no_ssid )
5795 {
Girish Gowli552fc072014-06-14 18:26:16 +05305796 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005797 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 }
5799
5800 callbackInfo.neighborRspCallback = NULL;
5801 callbackInfo.neighborRspCallbackContext = NULL;
5802 callbackInfo.timeout = 5000; //5 seconds
5803 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5804 }
5805 else
5806 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005807 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 ret = -EINVAL;
5809 }
5810 }
5811 break;
5812#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 case WE_SET_AP_WPS_IE:
5814 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05305815 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08005818 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 if (VOS_STATUS_SUCCESS != vstatus)
5820 {
5821 ret = -EINVAL;
5822 }
5823 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305824 case WE_SET_ENCRYPT_MSG:
5825 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
5826 if (NULL == pkt)
5827 {
5828 hddLog(VOS_TRACE_LEVEL_ERROR,
5829 "%s: vos_mem_alloc failed", __func__);
5830 return -ENOMEM;
5831 }
5832
5833 memset(pkt, 0, sizeof(tSirpkt80211));
5834
5835 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
5836 hddLog(VOS_TRACE_LEVEL_ERROR,
5837 FL("Firmware is not DISA capable"));
5838 ret = -EINVAL;
5839 vos_mem_free(pkt);
5840 break;
5841 }
5842
5843 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
5844
5845 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
5846 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
5847 if (eHAL_STATUS_SUCCESS != ret) {
5848 hddLog(VOS_TRACE_LEVEL_ERROR,
5849 FL("SENDEncryptMSG: fail to post WDA cmd"));
5850 ret = -EINVAL;
5851 }
5852 vos_mem_free(pkt);
5853
5854 break;
5855
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 default:
5857 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005858 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 ret = -EINVAL;
5860 break;
5861 }
5862 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005863 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305864
5865 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 return ret;
5867}
5868
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305869static int iw_setchar_getnone(struct net_device *dev,
5870 struct iw_request_info *info,
5871 union iwreq_data *wrqu, char *extra)
5872{
5873 int ret;
5874
5875 vos_ssr_protect(__func__);
5876 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
5877 vos_ssr_unprotect(__func__);
5878
5879 return ret;
5880}
5881
Jeff Johnson295189b2012-06-20 16:38:30 -07005882/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305883static int __iw_setnone_getint(struct net_device *dev,
5884 struct iw_request_info *info,
5885 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005886{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305887 hdd_adapter_t *pAdapter;
5888 tHalHandle hHal;
5889 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 int *value = (int *)extra;
5891 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05305892 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005893
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305894 ENTER();
5895
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305896 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5897 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005898 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5900 "%s: Adapter is NULL",__func__);
5901 return -EINVAL;
5902 }
5903 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5904 ret = wlan_hdd_validate_context(pHddCtx);
5905 if (0 != ret)
5906 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305907 return ret;
5908 }
5909 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5910 if (NULL == hHal)
5911 {
5912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5913 "%s: Hal Context is NULL",__func__);
5914 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005916
5917 switch (value[0])
5918 {
5919 case WE_GET_11D_STATE:
5920 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005921 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305923
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 *value = smeConfig.csrConfig.Is11dSupportEnabled;
5925
Arif Hussain6d2a3322013-11-17 19:50:10 -08005926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005927
5928 break;
5929 }
5930
5931 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 break;
5934
5935 case WE_PMC_STATE:
5936 {
5937 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 break;
5940 }
5941 case WE_GET_WLAN_DBG:
5942 {
5943 vos_trace_display();
5944 *value = 0;
5945 break;
5946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 case WE_GET_MAX_ASSOC:
5948 {
5949 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
5950 {
c_hpothub8245442013-11-20 23:41:09 +05305951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5952 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 ret = -EIO;
5954 }
Girish Gowli385be612014-09-18 11:17:20 +05305955#ifdef WLAN_SOFTAP_VSTA_FEATURE
5956 if (pHddCtx->cfg_ini->fEnableVSTASupport)
5957 {
5958 if (*value > VSTA_NUM_ASSOC_STA)
5959 {
5960 *value = VSTA_NUM_ASSOC_STA;
5961 }
5962 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
5963 (*value > (VSTA_NUM_ASSOC_STA -
5964 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
5965 {
5966 *value = (VSTA_NUM_ASSOC_STA -
5967 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
5968 }
5969 }
5970 else
5971#endif
5972 {
5973 if (*value > NUM_ASSOC_STA)
5974 {
5975 *value = NUM_ASSOC_STA;
5976 }
5977 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
5978 (*value > (NUM_ASSOC_STA -
5979 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
5980 {
5981 *value = (NUM_ASSOC_STA -
5982 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
5983 }
5984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 break;
5986 }
5987
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 case WE_GET_WDI_DBG:
5989 {
5990 wpalTraceDisplay();
5991 *value = 0;
5992 break;
5993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005994
5995 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
5996 {
5997 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
5998 break;
5999 }
6000 case WE_GET_CONCURRENCY_MODE:
6001 {
6002 *value = hdd_get_concurrency_mode ( );
6003
Arif Hussain6d2a3322013-11-17 19:50:10 -08006004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 break;
6006 }
6007
Peng Xu2446a892014-09-05 17:21:18 +05306008 case WE_GET_SCAN_BAND_PREFERENCE:
6009 {
6010 sme_GetConfigParam(hHal, &smeConfig);
6011 *value = smeConfig.csrConfig.scanBandPreference;
6012
6013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6014 "scanBandPreference = %d\n", *value);
6015 break;
6016 }
6017
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 default:
6019 {
6020 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6021 break;
6022 }
6023 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306024 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 return ret;
6026}
6027
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306028static int iw_setnone_getint(struct net_device *dev,
6029 struct iw_request_info *info,
6030 union iwreq_data *wrqu, char *extra)
6031{
6032 int ret;
6033
6034 vos_ssr_protect(__func__);
6035 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6036 vos_ssr_unprotect(__func__);
6037
6038 return ret;
6039
6040}
Jeff Johnson295189b2012-06-20 16:38:30 -07006041/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306042int __iw_set_three_ints_getnone(struct net_device *dev,
6043 struct iw_request_info *info,
6044 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006045{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306046 hdd_adapter_t *pAdapter;
6047 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 int *value = (int *)extra;
6049 int sub_cmd = value[0];
6050 int ret = 0;
6051
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306052 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306053 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6054 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006055 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6057 "%s: Adapter is NULL",__func__);
6058 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006059 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306060 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6061 ret = wlan_hdd_validate_context(pHddCtx);
6062 if (0 != ret)
6063 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306064 return ret;
6065 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 switch(sub_cmd)
6067 {
6068 case WE_SET_WLAN_DBG:
6069 {
6070 vos_trace_setValue( value[1], value[2], value[3]);
6071 break;
6072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 case WE_SET_WDI_DBG:
6074 {
6075 wpalTraceSetLevel( value[1], value[2], value[3]);
6076 break;
6077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 case WE_SET_SAP_CHANNELS:
6079 {
6080 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6081 break;
6082 }
6083
6084 default:
6085 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006086 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 break;
6088 }
6089 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306090 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 return ret;
6092}
6093
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306094int iw_set_three_ints_getnone(struct net_device *dev,
6095 struct iw_request_info *info,
6096 union iwreq_data *wrqu, char *extra)
6097{
6098 int ret;
6099
6100 vos_ssr_protect(__func__);
6101 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6102 vos_ssr_unprotect(__func__);
6103
6104 return ret;
6105}
6106
6107static int __iw_get_char_setnone(struct net_device *dev,
6108 struct iw_request_info *info,
6109 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006110{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306111 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306113 hdd_context_t *pHddCtx;
6114 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006115#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006116 hdd_wext_state_t *pWextState;
6117#endif
6118
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306119 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306120 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006121 if (pAdapter == NULL)
6122 {
6123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6124 "%s: pAdapter is NULL!", __func__);
6125 return -EINVAL;
6126 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306127 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6128 ret = wlan_hdd_validate_context(pHddCtx);
6129 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006130 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306131 return ret;
6132 }
6133#ifdef WLAN_FEATURE_11W
6134 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6135 if (NULL == pWextState)
6136 {
6137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6138 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006139 return -EINVAL;
6140 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306141#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006142
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 switch(sub_cmd)
6144 {
6145 case WE_WLAN_VERSION:
6146 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006147 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 break;
6149 }
6150
6151 case WE_GET_STATS:
6152 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306153 tHalHandle hHal = NULL;
6154 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6156 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6157 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6158
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306159
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 snprintf(extra, WE_MAX_STR_LEN,
6161 "\nTransmit"
6162 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6163 "\n dropped BK %u, BE %u, VI %u, VO %u"
6164 "\n classified BK %u, BE %u, VI %u, VO %u"
6165 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6166 "\n queued BK %u, BE %u, VI %u, VO %u"
6167 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006168 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 "\n fetched BK %u, BE %u, VI %u, VO %u"
6170 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6171 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006172 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 "\n flushed BK %u, BE %u, VI %u, VO %u"
6174 "\n\nReceive"
6175 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6176 "\n\nResetsStats"
6177 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6178 "\n",
6179 pStats->txXmitCalled,
6180 pStats->txXmitDropped,
6181 pStats->txXmitBackPressured,
6182 pStats->txXmitQueued,
6183
6184 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6185 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6186 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6187 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6188
6189 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6190 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6191 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6192 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6193
6194 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6195 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6196 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6197 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6198
6199 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6200 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6201 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6202 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6203
6204 pStats->txFetched,
6205 pStats->txFetchEmpty,
6206 pStats->txFetchLowResources,
6207 pStats->txFetchDequeueError,
6208
6209 pStats->txFetchDequeued,
6210 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006211 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 pStats->txCompleted,
6213 pStats->txFlushed,
6214
6215 pStats->txFetchedAC[WLANTL_AC_BK],
6216 pStats->txFetchedAC[WLANTL_AC_BE],
6217 pStats->txFetchedAC[WLANTL_AC_VI],
6218 pStats->txFetchedAC[WLANTL_AC_VO],
6219
6220 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6221 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6222 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6223 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6224
6225 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6226 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6227 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6228 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6229
Ravi Joshi41914632013-10-21 23:02:21 -07006230 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6231 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6232 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6233 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6234
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 pStats->txFlushedAC[WLANTL_AC_BK],
6236 pStats->txFlushedAC[WLANTL_AC_BE],
6237 pStats->txFlushedAC[WLANTL_AC_VI],
6238 pStats->txFlushedAC[WLANTL_AC_VO],
6239
6240 pStats->rxChains,
6241 pStats->rxPackets,
6242 pStats->rxDropped,
6243 pStats->rxDelivered,
6244 pStats->rxRefused,
6245
6246 pResetStats->totalLogpResets,
6247 pResetStats->totalCMD53Failures,
6248 pResetStats->totalMutexReadFailures,
6249 pResetStats->totalMIFErrorFailures,
6250 pResetStats->totalFWHearbeatFailures,
6251 pResetStats->totalUnknownExceptions
6252 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306253 wrqu->data.length = strlen(extra);
6254
6255 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6256
6257 if (hHal)
6258 pMac = PMAC_STRUCT( hHal );
6259
6260 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6261 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6262 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306263 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6264 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6265 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6266 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306267 "\n",
6268 pMac->pmm.BmpscntSleep,
6269 pMac->pmm.BmpscntAwake,
6270 pMac->pmm.BmpsSleeReqFailCnt,
6271 pMac->pmm.BmpsWakeupReqFailCnt,
6272 pMac->pmm.ImpsCntSleep,
6273 pMac->pmm.ImpsCntAwake,
6274 pMac->pmm.ImpsSleepErrCnt,
6275 pMac->pmm.ImpsWakeupErrCnt,
6276 pMac->pmm.ImpsLastErr
6277 );
6278 }
6279
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 wrqu->data.length = strlen(extra)+1;
6281 break;
6282 }
6283
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306284/* The case prints the current state of the HDD, SME, CSR, PE, TL
6285 *it can be extended for WDI Global State as well.
6286 *And currently it only checks P2P_CLIENT adapter.
6287 *P2P_DEVICE and P2P_GO have not been added as of now.
6288*/
6289 case WE_GET_STATES:
6290 {
6291 int buf = 0, len = 0;
6292 int adapter_num = 0;
6293 int count = 0, check = 1;
6294
6295 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006296 tHalHandle hHal = NULL;
6297 tpAniSirGlobal pMac = NULL;
6298 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306299
6300 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6301 hdd_adapter_t *useAdapter = NULL;
6302
6303 /* Print wlan0 or p2p0 states based on the adapter_num
6304 *by using the correct adapter
6305 */
6306 while ( adapter_num < 2 )
6307 {
6308 if ( WLAN_ADAPTER == adapter_num )
6309 {
6310 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006311 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306312 "\n\n wlan0 States:-");
6313 len += buf;
6314 }
6315 else if ( P2P_ADAPTER == adapter_num )
6316 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006317 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306318 "\n\n p2p0 States:-");
6319 len += buf;
6320
6321 if( !pHddCtx )
6322 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006323 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306324 "\n pHddCtx is NULL");
6325 len += buf;
6326 break;
6327 }
6328
6329 /*Printing p2p0 states only in the case when the device is
6330 configured as a p2p_client*/
6331 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6332 if ( !useAdapter )
6333 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006334 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306335 "\n Device not configured as P2P_CLIENT.");
6336 len += buf;
6337 break;
6338 }
6339 }
6340
6341 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006342 if (!hHal) {
6343 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6344 "\n pMac is NULL");
6345 len += buf;
6346 break;
6347 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306348 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006349 if (!pMac) {
6350 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6351 "\n pMac is NULL");
6352 len += buf;
6353 break;
6354 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306355 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6356 if( !pHddStaCtx )
6357 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006358 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306359 "\n pHddStaCtx is NULL");
6360 len += buf;
6361 break;
6362 }
6363
6364 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6365
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006366 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306367 "\n HDD Conn State - %s "
6368 "\n \n SME State:"
6369 "\n Neighbour Roam State - %s"
6370 "\n CSR State - %s"
6371 "\n CSR Substate - %s"
6372 "\n \n TL STA %d State: %s",
6373 macTraceGetHDDWlanConnState(
6374 pHddStaCtx->conn_info.connState),
6375 macTraceGetNeighbourRoamState(
6376 pMac->roam.neighborRoamInfo.neighborRoamState),
6377 macTraceGetcsrRoamState(
6378 pMac->roam.curState[useAdapter->sessionId]),
6379 macTraceGetcsrRoamSubState(
6380 pMac->roam.curSubState[useAdapter->sessionId]),
6381 pHddStaCtx->conn_info.staId[0],
6382 macTraceGetTLState(tlState)
6383 );
6384 len += buf;
6385 adapter_num++;
6386 }
6387
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006388 if (pMac) {
6389 /* Printing Lim State starting with global lim states */
6390 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6391 "\n \n LIM STATES:-"
6392 "\n Global Sme State - %s "\
6393 "\n Global mlm State - %s "\
6394 "\n",
6395 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6396 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6397 );
6398 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306399
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006400 /*printing the PE Sme and Mlm states for valid lim sessions*/
6401 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306402 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006403 if ( pMac->lim.gpSession[count].valid )
6404 {
6405 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6406 "\n Lim Valid Session %d:-"
6407 "\n PE Sme State - %s "
6408 "\n PE Mlm State - %s "
6409 "\n",
6410 check,
6411 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6412 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6413 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306414
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006415 len += buf;
6416 check++;
6417 }
6418 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306419 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306420 }
6421
6422 wrqu->data.length = strlen(extra)+1;
6423 break;
6424 }
6425
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 case WE_GET_CFG:
6427 {
6428 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6429 wrqu->data.length = strlen(extra)+1;
6430 break;
6431 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006432#ifdef WLAN_FEATURE_11AC
6433 case WE_GET_RSSI:
6434 {
6435 v_S7_t s7Rssi = 0;
6436 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6437 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6438 wrqu->data.length = strlen(extra)+1;
6439 break;
6440 }
6441#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306442
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006443#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006444 case WE_GET_ROAM_RSSI:
6445 {
6446 v_S7_t s7Rssi = 0;
6447 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6448 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6449 wrqu->data.length = strlen(extra)+1;
6450 break;
6451 }
6452#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 case WE_GET_WMM_STATUS:
6454 {
6455 snprintf(extra, WE_MAX_STR_LEN,
6456 "\nDir: 0=up, 1=down, 3=both\n"
6457 "|------------------------|\n"
6458 "|AC | ACM |Admitted| Dir |\n"
6459 "|------------------------|\n"
6460 "|VO | %d | %3s | %d |\n"
6461 "|VI | %d | %3s | %d |\n"
6462 "|BE | %d | %3s | %d |\n"
6463 "|BK | %d | %3s | %d |\n"
6464 "|------------------------|\n",
6465 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6466 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6467 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6468 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6469 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6470 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6471 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6472 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6473 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6474 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6475 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6476 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6477
Jeff Johnsone7245742012-09-05 17:12:55 -07006478
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 wrqu->data.length = strlen(extra)+1;
6480 break;
6481 }
6482 case WE_GET_CHANNEL_LIST:
6483 {
6484 VOS_STATUS status;
6485 v_U8_t i, len;
6486 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306487 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6488 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6489 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 tChannelListInfo channel_list;
6491
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006492 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006494 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006496 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 return -EINVAL;
6498 }
6499 buf = extra;
6500
6501 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006502 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6503 * needed = 5 * number of channels. Check ifsufficient
6504 * buffer is available and then proceed to fill the buffer.
6505 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6507 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006508 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006509 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006510 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 return -EINVAL;
6512 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006513 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6514 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306515 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6516 {
6517 //Printing Country code in getChannelList
6518 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6519 {
6520 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6521 "%c ", pBuf[i]);
6522 }
6523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 for(i = 0 ; i < channel_list.num_channels; i++)
6525 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006526 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 }
6529 wrqu->data.length = strlen(extra)+1;
6530
6531 break;
6532 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006533#ifdef FEATURE_WLAN_TDLS
6534 case WE_GET_TDLS_PEERS:
6535 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006536 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006537 break;
6538 }
6539#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006540#ifdef WLAN_FEATURE_11W
6541 case WE_GET_11W_INFO:
6542 {
6543 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6544
6545 snprintf(extra, WE_MAX_STR_LEN,
6546 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6547 "\n Number of Unprotected Disassocs %d"
6548 "\n Number of Unprotected Deauths %d",
6549 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6550 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6551 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6552 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6553 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6554
6555 wrqu->data.length = strlen(extra)+1;
6556 break;
6557 }
6558#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306559 case WE_GET_SNR:
6560 {
6561 v_S7_t s7snr = 0;
6562 int status = 0;
6563 hdd_context_t *pHddCtx;
6564 hdd_station_ctx_t *pHddStaCtx;
6565
6566 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6567 status = wlan_hdd_validate_context(pHddCtx);
6568 if (0 != status)
6569 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306570 return status;
6571 }
6572
6573 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6574
6575 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6576 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6577 {
6578 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6579 " ConnectionState-%d", __func__,
6580 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6581 pHddStaCtx->conn_info.connState);
6582 return -ENONET;
6583 }
6584
6585 /*update the stats in TL*/
6586 wlan_hdd_get_station_stats(pAdapter);
6587 wlan_hdd_get_snr(pAdapter, &s7snr);
6588 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6589 wrqu->data.length = strlen(extra) + 1;
6590 break;
6591 }
6592
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306593 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006595 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 break;
6597 }
6598 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306599 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 return 0;
6601}
6602
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306603static int iw_get_char_setnone(struct net_device *dev,
6604 struct iw_request_info *info,
6605 union iwreq_data *wrqu, char *extra)
6606{
6607 int ret;
6608
6609 vos_ssr_protect(__func__);
6610 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6611 vos_ssr_unprotect(__func__);
6612
6613 return ret;
6614}
6615
Jeff Johnson295189b2012-06-20 16:38:30 -07006616/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306617static int __iw_setnone_getnone(struct net_device *dev,
6618 struct iw_request_info *info,
6619 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006620{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306621 hdd_adapter_t *pAdapter;
6622 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306623 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006624 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306625 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006626
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306627 ENTER();
6628
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306629 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6630 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006631 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6633 "%s: Adapter is NULL",__func__);
6634 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006635 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306636 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6637 ret = wlan_hdd_validate_context(pHddCtx);
6638 if (0 != ret)
6639 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306640 return ret;
6641 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306642 /* helper function to get iwreq_data with compat handling. */
6643 if (hdd_priv_get_data(&s_priv_data, wrqu))
6644 {
6645 return -EINVAL;
6646 }
6647
6648 sub_cmd = s_priv_data.flags;
6649
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 switch (sub_cmd)
6651 {
6652 case WE_CLEAR_STATS:
6653 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6656 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6657 break;
6658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 case WE_INIT_AP:
6660 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306661 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6662
6663 /* As Soft AP mode might been changed to STA already with
6664 * killing of Hostapd, need to find the adpater by name
6665 * rather than mode */
6666 hdd_adapter_t* pAdapter_to_stop =
6667 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6668 if( pAdapter_to_stop )
6669 {
6670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6671 "Adapter with name softap.0 already "
6672 "exist, ignoring the request.\nRemove the "
6673 "adapter and try again\n");
6674 break;
6675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 pr_info("Init AP trigger\n");
6677 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6678 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6679 break;
6680 }
6681 case WE_STOP_AP:
6682 {
6683 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6684 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6685 * this is a dead code and need to find the adpater by name rather than mode */
6686 hdd_adapter_t* pAdapter_to_stop =
6687 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6688 if( pAdapter_to_stop )
6689 {
6690 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6691
6692 pr_info("Stopping AP mode\n");
6693
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306694 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6695 {
6696 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6697 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6698 }
6699
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306701 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306702 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6704
6705 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6706 pAdapter_to_stop->macAddressCurrent.bytes);
6707 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6708 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306709
6710 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6711 {
6712 /* put the device back into BMPS */
6713 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 }
6716 else
6717 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006718 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 }
6720
6721 break;
6722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006723#ifdef WLAN_BTAMP_FEATURE
6724 case WE_ENABLE_AMP:
6725 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 WLANBAP_RegisterWithHCI(pAdapter);
6728 break;
6729 }
6730 case WE_DISABLE_AMP:
6731 {
6732 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6733 VOS_STATUS status;
6734
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006736
6737 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6738 status = WLANBAP_StopAmp();
6739 if(VOS_STATUS_SUCCESS != status )
6740 {
6741 pHddCtx->isAmpAllowed = VOS_TRUE;
6742 hddLog(VOS_TRACE_LEVEL_FATAL,
6743 "%s: Failed to stop AMP", __func__);
6744 }
6745 else
6746 {
6747 //a state m/c implementation in PAL is TBD to avoid this delay
6748 msleep(500);
6749 pHddCtx->isAmpAllowed = VOS_FALSE;
6750 WLANBAP_DeregisterFromHCI();
6751 }
6752
6753 break;
6754 }
6755#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006756 case WE_ENABLE_DXE_STALL_DETECT:
6757 {
schang6295e542013-03-12 15:31:23 -07006758 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6759 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006760 break;
6761 }
6762 case WE_DISPLAY_DXE_SNAP_SHOT:
6763 {
schang6295e542013-03-12 15:31:23 -07006764 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6765 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006766 break;
6767 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306768 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6769 {
6770 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6771 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306772 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306773 break;
6774 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306775
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306776 case WE_SET_REASSOC_TRIGGER:
6777 {
6778 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6779 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6780 v_U32_t roamId = 0;
6781 tCsrRoamModifyProfileFields modProfileFields;
6782 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6783 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6784 return 0;
6785 }
6786
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306787 case WE_STOP_OBSS_SCAN:
6788 {
6789 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6790 2.OBSS scan is stopped by Firmware during the disassociation
6791 3.OBSS stop comamnd is added for debugging purpose*/
6792 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6793 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006794
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306795 if (pAdapter == NULL)
6796 {
6797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6798 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306799 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306800 }
6801 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6802 if (pMac == NULL)
6803 {
6804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6805 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306806 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306807 }
6808 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6809 }
6810 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306811 case WE_DUMP_ROAM_TIMER_LOG:
6812 {
6813 vos_dump_roam_time_log_service();
6814 break;
6815 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306816
Mukul Sharma84f27252014-07-14 18:11:42 +05306817 case WE_RESET_ROAM_TIMER_LOG:
6818 {
6819 vos_reset_roam_timer_log();
6820 break;
6821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 default:
6823 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006824 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 break;
6826 }
6827 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306828 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 return ret;
6830}
6831
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306832static int iw_setnone_getnone(struct net_device *dev,
6833 struct iw_request_info *info,
6834 union iwreq_data *wrqu, char *extra)
6835{
6836 int ret;
6837
6838 vos_ssr_protect(__func__);
6839 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
6840 vos_ssr_unprotect(__func__);
6841
6842 return ret;
6843}
6844
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306845void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
6846{
6847 /*
6848 * Function to display HDD WMM information
6849 * for Tx Queues.
6850 * Prints globala as well as per client depending
6851 * whether the clients are registered or not.
6852 */
6853 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306854 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
6855 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
6856
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306857 for ( i=0; i< NUM_TX_QUEUES; i++)
6858 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05306859 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306860
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006861 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306862 i, pAdapter->wmm_tx_queue[i].count,
6863 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05306864 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306865 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306866 if(pSapCtx == NULL){
6867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6868 FL("psapCtx is NULL"));
6869 return;
6870 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306871
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05306872 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306873 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
6874 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306875 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306876 {
6877 hddLog(LOGE, "******STAIndex: %d*********", i);
6878 for ( j=0; j< NUM_TX_QUEUES; j++)
6879 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306880 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006881 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05306882 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
6883 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
6884 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
6885 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306886 }
6887 }
6888 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05306889 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306890
6891}
Girish Gowlifb9758e2014-11-19 15:19:17 +05306892static int __iw_set_var_ints_getnone(struct net_device *dev,
6893 struct iw_request_info *info,
6894 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006895{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306896 hdd_adapter_t *pAdapter;
6897 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05306898 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05306899 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006900 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306901 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006902 hdd_ap_ctx_t *pAPCtx = NULL;
6903 int cmd = 0;
6904 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306905 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006906
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306907 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05306908 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05306909 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05306910 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6911 "%s: NULL extra buffer pointer", __func__);
6912 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05306913 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306914 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6915 if (NULL == pAdapter)
6916 {
6917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6918 "%s: Adapter is NULL",__func__);
6919 return -EINVAL;
6920 }
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306921 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6922 ret = wlan_hdd_validate_context(pHddCtx);
6923 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006924 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05306925 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006926 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306927 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6928 if (NULL == hHal)
6929 {
6930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6931 "%s: Hal Context is NULL",__func__);
6932 return -EINVAL;
6933 }
6934 sub_cmd = wrqu->data.flags;
6935
6936 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
6937
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006938
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08006939 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
6940 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
6941 {
6942 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
6943 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
6944 {
6945 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6946 staId = pStaCtx->conn_info.staId[0];
6947 }
6948 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
6949 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
6950 {
6951 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
6952 staId = pAPCtx->uBCStaId;
6953 }
6954 else
6955 {
6956 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
6957 return 0;
6958 }
6959 }
6960
Jeff Johnson295189b2012-06-20 16:38:30 -07006961 switch (sub_cmd)
6962 {
6963 case WE_LOG_DUMP_CMD:
6964 {
6965 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006966 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 apps_args[3], apps_args[4]);
6968
6969 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
6970 apps_args[3], apps_args[4]);
6971
6972 }
6973 break;
6974
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 case WE_P2P_NOA_CMD:
6976 {
6977 p2p_app_setP2pPs_t p2pNoA;
6978
6979 p2pNoA.opp_ps = apps_args[0];
6980 p2pNoA.ctWindow = apps_args[1];
6981 p2pNoA.duration = apps_args[2];
6982 p2pNoA.interval = apps_args[3];
6983 p2pNoA.count = apps_args[4];
6984 p2pNoA.single_noa_duration = apps_args[5];
6985 p2pNoA.psSelection = apps_args[6];
6986
6987 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
6988 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006989 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
6991
6992 hdd_setP2pPs(dev, &p2pNoA);
6993
6994 }
6995 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006996
Katya Nigamc2f29dc2014-01-20 19:29:30 +05306997 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
6998 {
6999 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7000 __func__, apps_args[0], apps_args[1]);
7001 vosTraceEnable(apps_args[0], apps_args[1]);
7002 }
7003 break;
7004
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007005 case WE_MTRACE_DUMP_CMD:
7006 {
7007 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7008 "bitmask_of_module %d ",
7009 __func__, apps_args[0], apps_args[1], apps_args[2],
7010 apps_args[3]);
7011 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7012 apps_args[2], apps_args[3]);
7013
7014 }
7015 break;
7016
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007017 case WE_MCC_CONFIG_CREDENTIAL :
7018 {
7019 cmd = 287; //Command should be updated if there is any change
7020 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007021 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007022 {
7023 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7024 }
7025 else
7026 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007027 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007028 return 0;
7029 }
7030 }
7031 break;
7032
7033 case WE_MCC_CONFIG_PARAMS :
7034 {
7035 cmd = 288; //command Should be updated if there is any change
7036 // in the Riva dump command
7037 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7038 }
7039 break;
7040
Chilam NG571c65a2013-01-19 12:27:36 +05307041#ifdef FEATURE_WLAN_TDLS
7042 case WE_TDLS_CONFIG_PARAMS :
7043 {
7044 tdls_config_params_t tdlsParams;
7045
Chilam Ng01120412013-02-19 18:32:21 -08007046 tdlsParams.tdls = apps_args[0];
7047 tdlsParams.tx_period_t = apps_args[1];
7048 tdlsParams.tx_packet_n = apps_args[2];
7049 tdlsParams.discovery_period_t = apps_args[3];
7050 tdlsParams.discovery_tries_n = apps_args[4];
7051 tdlsParams.idle_timeout_t = apps_args[5];
7052 tdlsParams.idle_packet_n = apps_args[6];
7053 tdlsParams.rssi_hysteresis = apps_args[7];
7054 tdlsParams.rssi_trigger_threshold = apps_args[8];
7055 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307056
Chilam Ng01120412013-02-19 18:32:21 -08007057 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307058 }
7059 break;
7060#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 default:
7062 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007063 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7064 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 }
7066 break;
7067 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307068 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007069 return 0;
7070}
7071
Girish Gowlifb9758e2014-11-19 15:19:17 +05307072static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7073 struct iw_request_info *info,
7074 union iwreq_data *wrqu, char *extra)
7075{
7076 int ret;
7077 union iwreq_data u_priv_wrqu;
7078 int apps_args[MAX_VAR_ARGS] = {0};
7079 int num_args;
7080
7081 /* helper function to get iwreq_data with compat handling. */
7082 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7083 {
7084 return -EINVAL;
7085 }
7086
7087 if (NULL == u_priv_wrqu.data.pointer)
7088 {
7089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7090 "%s: NULL data pointer", __func__);
7091 return -EINVAL;
7092 }
7093
7094 num_args = u_priv_wrqu.data.length;
7095 if (num_args > MAX_VAR_ARGS)
7096 {
7097 num_args = MAX_VAR_ARGS;
7098 }
7099
7100 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7101 (sizeof(int)) * num_args))
7102 {
7103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7104 "%s: failed to copy data from user buffer", __func__);
7105 return -EFAULT;
7106 }
7107
7108 vos_ssr_protect(__func__);
7109 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7110 (char *)&apps_args);
7111 vos_ssr_unprotect(__func__);
7112
7113 return ret;
7114}
7115
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307116int iw_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 vos_ssr_protect(__func__);
7122 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7123 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007124
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307125 return ret;
7126}
7127
7128static int __iw_add_tspec(struct net_device *dev,
7129 struct iw_request_info *info,
7130 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007131{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307132 hdd_adapter_t *pAdapter;
7133 hdd_station_ctx_t *pHddStaCtx;
7134 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7136 int params[HDD_WLAN_WMM_PARAM_COUNT];
7137 sme_QosWmmTspecInfo tSpec;
7138 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307139 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307140 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007141
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307142 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307143 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7144 if (NULL == pAdapter)
7145 {
7146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7147 "%s: Adapter is NULL",__func__);
7148 return -EINVAL;
7149 }
7150 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7151 ret = wlan_hdd_validate_context(pHddCtx);
7152 if (0 != ret)
7153 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307154 return ret;
7155 }
7156 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7157 if (NULL == pHddStaCtx)
7158 {
7159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7160 "%s: STA Context is NULL",__func__);
7161 return -EINVAL;
7162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007163 // make sure the application is sufficiently priviledged
7164 // note that the kernel will do this for "set" ioctls, but since
7165 // this ioctl wants to return status to user space it must be
7166 // defined as a "get" ioctl
7167 if (!capable(CAP_NET_ADMIN))
7168 {
7169 return -EPERM;
7170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 // we must be associated in order to add a tspec
7172 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7173 {
7174 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7175 return 0;
7176 }
7177
7178 // since we are defined to be a "get" ioctl, and since the number
7179 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307180 // will pass down in the iwreq_data, we must copy the "set" params.
7181 // We must handle the compat for iwreq_data in 32U/64K environment.
7182
7183 // helper fucntion to get iwreq_data with compat handling.
7184 if (hdd_priv_get_data(&s_priv_data, wrqu))
7185 {
7186 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7187 return 0;
7188 }
7189
7190 // make sure all params are correctly passed to function
7191 if ((NULL == s_priv_data.pointer) ||
7192 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7193 {
7194 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7195 return 0;
7196 }
7197
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307199 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007200 {
7201 // hmmm, can't get them
7202 return -EIO;
7203 }
7204
7205 // clear the tspec
7206 memset(&tSpec, 0, sizeof(tSpec));
7207
7208 // validate the handle
7209 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7210 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7211 {
7212 // that one is reserved
7213 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7214 return 0;
7215 }
7216
7217 // validate the TID
7218 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7219 {
7220 // out of range
7221 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7222 return 0;
7223 }
7224 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7225
7226 // validate the direction
7227 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7228 {
7229 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7230 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7231 break;
7232
7233 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7234 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7235 break;
7236
7237 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7238 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7239 break;
7240
7241 default:
7242 // unknown
7243 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7244 return 0;
7245 }
7246
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307247 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7248
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 // validate the user priority
7250 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7251 {
7252 // out of range
7253 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7254 return 0;
7255 }
7256 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307257 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7258 {
7259 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7260 return 0;
7261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007262
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7264 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7265 tSpec.ts_info.psb, tSpec.ts_info.up);
7266
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7268 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7269 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7270 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7271 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7272 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7273 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7274 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7275 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7276 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7277 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7278 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7279
7280 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7281
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307282 // Save the expected UAPSD settings by application, this will be needed
7283 // when re-negotiating UAPSD settings during BT Coex cases.
7284 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7285
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 // validate the ts info ack policy
7287 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7288 {
7289 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7290 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7291 break;
7292
7293 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7294 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7295 break;
7296
7297 default:
7298 // unknown
7299 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7300 return 0;
7301 }
7302
7303 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307304
7305 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007306 return 0;
7307}
7308
7309
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307310static int iw_add_tspec(struct net_device *dev,
7311 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 union iwreq_data *wrqu, char *extra)
7313{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307314 int ret;
7315
7316 vos_ssr_protect(__func__);
7317 ret = __iw_add_tspec(dev, info, wrqu, extra);
7318 vos_ssr_unprotect(__func__);
7319
7320 return ret;
7321}
7322
7323static int __iw_del_tspec(struct net_device *dev,
7324 struct iw_request_info *info,
7325 union iwreq_data *wrqu, char *extra)
7326{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307327 hdd_adapter_t *pAdapter;
7328 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007329 int *params = (int *)extra;
7330 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7331 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307332 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007333
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307334 ENTER();
7335
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307336 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7337 if (NULL == pAdapter)
7338 {
7339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7340 "%s: Adapter is NULL",__func__);
7341 return -EINVAL;
7342 }
7343
7344 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7345 ret = wlan_hdd_validate_context(pHddCtx);
7346 if (0 != ret)
7347 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307348 return ret;
7349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007350 // make sure the application is sufficiently priviledged
7351 // note that the kernel will do this for "set" ioctls, but since
7352 // this ioctl wants to return status to user space it must be
7353 // defined as a "get" ioctl
7354 if (!capable(CAP_NET_ADMIN))
7355 {
7356 return -EPERM;
7357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 // although we are defined to be a "get" ioctl, the params we require
7359 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7360 // is no need to copy the params from user space
7361
7362 // validate the handle
7363 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7364 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7365 {
7366 // that one is reserved
7367 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7368 return 0;
7369 }
7370
7371 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307372
7373 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 return 0;
7375}
7376
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307377static int iw_del_tspec(struct net_device *dev,
7378 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 union iwreq_data *wrqu, char *extra)
7380{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307381 int ret;
7382
7383 vos_ssr_protect(__func__);
7384 ret = __iw_del_tspec(dev, info, wrqu, extra);
7385 vos_ssr_unprotect(__func__);
7386
7387 return ret;
7388}
7389
7390
7391static int __iw_get_tspec(struct net_device *dev,
7392 struct iw_request_info *info,
7393 union iwreq_data *wrqu, char *extra)
7394{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307395 hdd_adapter_t *pAdapter;
7396 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 int *params = (int *)extra;
7398 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7399 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307400 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007401
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307402 ENTER();
7403
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 // although we are defined to be a "get" ioctl, the params we require
7405 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7406 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307407 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7408 if (NULL == pAdapter)
7409 {
7410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7411 "%s: Adapter is NULL",__func__);
7412 return -EINVAL;
7413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007414
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307415 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7416 ret = wlan_hdd_validate_context(pHddCtx);
7417 if (0 != ret)
7418 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307419 return ret;
7420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 // validate the handle
7422 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7423 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7424 {
7425 // that one is reserved
7426 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7427 return 0;
7428 }
7429
7430 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307431 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 return 0;
7433}
7434
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307435static int iw_get_tspec(struct net_device *dev,
7436 struct iw_request_info *info,
7437 union iwreq_data *wrqu, char *extra)
7438{
7439 int ret;
7440
7441 vos_ssr_protect(__func__);
7442 ret = __iw_get_tspec(dev, info, wrqu, extra);
7443 vos_ssr_unprotect(__func__);
7444
7445 return ret;
7446}
7447
Jeff Johnson295189b2012-06-20 16:38:30 -07007448#ifdef WLAN_FEATURE_VOWIFI_11R
7449//
7450//
7451// Each time the supplicant has the auth_request or reassoc request
7452// IEs ready. This is pushed to the driver. The driver will inturn use
7453// it to send out the auth req and reassoc req for 11r FT Assoc.
7454//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307455static int __iw_set_fties(struct net_device *dev,
7456 struct iw_request_info *info,
7457 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007458{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307459 hdd_adapter_t *pAdapter;
7460 hdd_station_ctx_t *pHddStaCtx;
7461 hdd_context_t *pHddCtx;
7462 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 //v_CONTEXT_t pVosContext;
7464
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307465 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307466 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7467 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007468 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7470 "%s: Adapter is NULL",__func__);
7471 return -EINVAL;
7472 }
7473 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7474 ret = wlan_hdd_validate_context(pHddCtx);
7475 if (0 != ret)
7476 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307477 return ret;
7478 }
7479 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7480 if (NULL == pHddStaCtx)
7481 {
7482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7483 "%s: STA Context is NULL",__func__);
7484 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 if (!wrqu->data.length)
7487 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007488 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 return -EINVAL;
7490 }
7491 if (wrqu->data.pointer == NULL)
7492 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007493 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 return -EINVAL;
7495 }
7496
7497 // Added for debug on reception of Re-assoc Req.
7498 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7499 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007500 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007502 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007503 }
7504
7505#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007506 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007507#endif
7508
7509 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007510 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007511 wrqu->data.length);
7512
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307513 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007514 return 0;
7515}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307516
7517static int iw_set_fties(struct net_device *dev,
7518 struct iw_request_info *info,
7519 union iwreq_data *wrqu, char *extra)
7520{
7521 int ret;
7522
7523 vos_ssr_protect(__func__);
7524 ret = __iw_set_fties(dev, info, wrqu, extra);
7525 vos_ssr_unprotect(__func__);
7526
7527 return ret;
7528}
Jeff Johnson295189b2012-06-20 16:38:30 -07007529#endif
7530
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307531static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007532 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007534{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307535 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007536 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307537 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007538 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307539 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007540 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7541 int idx;
7542 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007543
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307544 ENTER();
7545
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307546 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7547 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007548 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7550 "%s: Adapter is NULL",__func__);
7551 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007552 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307553 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7554 ret_val = wlan_hdd_validate_context(pHddCtx);
7555 if (0 != ret_val)
7556 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307557 return ret_val;
7558 }
7559 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7560 if (NULL == hHal)
7561 {
7562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7563 "%s: Hal Context is NULL",__func__);
7564 return -EINVAL;
7565 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307566 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7567 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307568#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007569
Amar Singhalf3a6e762013-02-19 15:06:50 -08007570 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7571 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007572 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007573 hddLog(VOS_TRACE_LEVEL_ERROR,
7574 "%s: vos_mem_alloc failed", __func__);
7575 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007576 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007577
7578 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7579
7580 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7581 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7582
7583 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7584 mc_addr_list_ptr->ulMulticastAddrCnt);
7585
7586 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007587 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007588 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7589 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7590
7591 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7592 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007593 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007594
Amar Singhalf3a6e762013-02-19 15:06:50 -08007595 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7596 vos_mem_free(mc_addr_list_ptr);
7597 if (eHAL_STATUS_SUCCESS != ret_val)
7598 {
7599 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7600 __func__);
7601 return -EINVAL;
7602 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307603#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307604 }
7605 else
7606 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007607
Amar Singhalf3a6e762013-02-19 15:06:50 -08007608 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7609 "%s: Set MC BC Filter Config request: %d suspend %d",
7610 __func__, pRequest->mcastBcastFilterSetting,
7611 pHddCtx->hdd_wlan_suspended);
7612
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307613 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007614
7615 if (pHddCtx->hdd_wlan_suspended)
7616 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007617 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7618 if (NULL == wlanRxpFilterParam)
7619 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307620 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007621 "%s: vos_mem_alloc failed", __func__);
7622 return -EINVAL;
7623 }
7624
Amar Singhalf3a6e762013-02-19 15:06:50 -08007625 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7626 pRequest->mcastBcastFilterSetting;
7627 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7628
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307629 hdd_conf_hostoffload(pAdapter, TRUE);
7630 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7631 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007632
7633 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7634 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307635 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007636 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7637 wlanRxpFilterParam->setMcstBcstFilter);
7638
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307639 if (eHAL_STATUS_SUCCESS !=
7640 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7641 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007642 {
7643 hddLog(VOS_TRACE_LEVEL_ERROR,
7644 "%s: Failure to execute set HW MC/BC Filter request",
7645 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007646 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007647 return -EINVAL;
7648 }
7649
c_hpothud3ce76d2014-10-28 10:34:13 +05307650 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7651 {
7652 pHddCtx->sus_res_mcastbcast_filter =
7653 pRequest->mcastBcastFilterSetting;
7654 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007655 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007657
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307658 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007659 return 0;
7660}
7661
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307662static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7663 struct iw_request_info *info,
7664 union iwreq_data *wrqu, char *extra)
7665{
7666 int ret;
7667
7668 vos_ssr_protect(__func__);
7669 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
7670 vos_ssr_unprotect(__func__);
7671
7672 return ret;
7673}
7674
7675static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7676 struct iw_request_info *info,
7677 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007678{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307679 hdd_adapter_t *pAdapter;
7680 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307681 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307682 int ret = 0;
7683
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307684 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007685
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307686 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7687 if (NULL == pAdapter)
7688 {
7689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7690 "%s: Adapter is NULL",__func__);
7691 return -EINVAL;
7692 }
7693
7694 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7695 ret = wlan_hdd_validate_context(pHddCtx);
7696 if (0 != ret)
7697 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307698 return ret;
7699 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307700 //Reset the filter to INI value as we have to clear the dynamic filter
7701 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07007702
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307703 //Configure FW with new setting
7704 if (pHddCtx->hdd_wlan_suspended)
7705 {
7706 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7707 if (NULL == wlanRxpFilterParam)
7708 {
7709 hddLog(VOS_TRACE_LEVEL_ERROR,
7710 "%s: vos_mem_alloc failed", __func__);
7711 return -EINVAL;
7712 }
7713
7714 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7715 pHddCtx->configuredMcastBcastFilter;
7716 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7717
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307718 hdd_conf_hostoffload(pAdapter, TRUE);
7719 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7720 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307721
7722 if (eHAL_STATUS_SUCCESS !=
7723 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7724 wlanRxpFilterParam))
7725 {
7726 hddLog(VOS_TRACE_LEVEL_ERROR,
7727 "%s: Failure to execute set HW MC/BC Filter request",
7728 __func__);
7729 vos_mem_free(wlanRxpFilterParam);
7730 return -EINVAL;
7731 }
c_hpothud3ce76d2014-10-28 10:34:13 +05307732
7733 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7734 {
7735 pHddCtx->sus_res_mcastbcast_filter =
7736 pHddCtx->cfg_ini->mcastBcastFilterSetting;
7737 }
7738
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307739 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307740 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 return 0;
7742}
7743
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307744
7745static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7746 struct iw_request_info *info,
7747 union iwreq_data *wrqu, char *extra)
7748{
7749 int ret;
7750
7751 vos_ssr_protect(__func__);
7752 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
7753 vos_ssr_unprotect(__func__);
7754
7755 return ret;
7756}
7757
7758static int __iw_set_host_offload(struct net_device *dev,
7759 struct iw_request_info *info,
7760 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007761{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307762 hdd_adapter_t *pAdapter;
7763 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007764 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007765 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307766 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007767
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307768 ENTER();
7769
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307770 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7771 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007772 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7774 "%s: Adapter is NULL",__func__);
7775 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007776 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307777 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7778 ret = wlan_hdd_validate_context(pHddCtx);
7779 if (0 != ret)
7780 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307781 return ret;
7782 }
7783
Jeff Johnson295189b2012-06-20 16:38:30 -07007784 /* Debug display of request components. */
7785 switch (pRequest->offloadType)
7786 {
7787 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007788 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007789 switch (pRequest->enableOrDisable)
7790 {
7791 case WLAN_OFFLOAD_DISABLE:
7792 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
7793 break;
7794 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
7795 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
7796 case WLAN_OFFLOAD_ENABLE:
7797 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
7798 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
7799 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
7800 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
7801 }
7802 break;
7803
7804 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08007805 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007806 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007807 switch (pRequest->enableOrDisable)
7808 {
7809 case WLAN_OFFLOAD_DISABLE:
7810 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
7811 break;
7812 case WLAN_OFFLOAD_ENABLE:
7813 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
7814 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
7815 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
7816 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
7817 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
7818 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
7819 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
7820 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
7821 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
7822 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
7823 }
7824 }
7825
7826 /* Execute offload request. The reason that we can copy the request information
7827 from the ioctl structure to the SME structure is that they are laid out
7828 exactly the same. Otherwise, each piece of information would have to be
7829 copied individually. */
7830 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07007831 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
7832 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007834 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07007835 __func__);
7836 return -EINVAL;
7837 }
7838
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307839 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 return 0;
7841}
7842
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307843static int iw_set_host_offload(struct net_device *dev,
7844 struct iw_request_info *info,
7845 union iwreq_data *wrqu, char *extra)
7846{
7847 int ret;
7848
7849 vos_ssr_protect(__func__);
7850 ret = __iw_set_host_offload(dev, info, wrqu, extra);
7851 vos_ssr_unprotect(__func__);
7852
7853 return ret;
7854}
7855
7856static int __iw_set_keepalive_params(struct net_device *dev,
7857 struct iw_request_info *info,
7858 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007859{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307860 hdd_adapter_t *pAdapter;
7861 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007862 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307864 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007865
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307866 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307867 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7868 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7871 "%s: Adapter is NULL",__func__);
7872 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307874 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7875 ret = wlan_hdd_validate_context(pHddCtx);
7876 if (0 != ret)
7877 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307878 return ret;
7879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007880 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08007881 hddLog(VOS_TRACE_LEVEL_INFO,
7882 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
7883 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07007884
7885 switch (pRequest->packetType)
7886 {
7887 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007888 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007889 break;
7890
7891 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
7892
Arif Hussain6d2a3322013-11-17 19:50:10 -08007893 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007894 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007895
7896 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
7897 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
7898 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
7899
7900 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
7901 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
7902 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
7903
7904 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
7905 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
7906 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
7907 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
7908 break;
7909
7910 }
7911
7912 /* Execute keep alive request. The reason that we can copy the request information
7913 from the ioctl structure to the SME structure is that they are laid out
7914 exactly the same. Otherwise, each piece of information would have to be
7915 copied individually. */
7916 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
7917
Arif Hussain6d2a3322013-11-17 19:50:10 -08007918 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07007919
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007920 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07007921 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007923 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07007924 __func__);
7925 return -EINVAL;
7926 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307927 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 return 0;
7929}
7930
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307931static int iw_set_keepalive_params(struct net_device *dev,
7932 struct iw_request_info *info,
7933 union iwreq_data *wrqu, char *extra)
7934{
7935 int ret;
7936 vos_ssr_protect(__func__);
7937 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
7938 vos_ssr_unprotect(__func__);
7939
7940 return ret;
7941}
7942
Jeff Johnson295189b2012-06-20 16:38:30 -07007943#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007944int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07007945 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007946{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007947 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
7948 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 int i=0;
7950
7951 if (pHddCtx->cfg_ini->disablePacketFilter)
7952 {
7953 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007954 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 return 0;
7956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007957 /* Debug display of request components. */
7958 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007959 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007960
7961 switch (pRequest->filterAction)
7962 {
7963 case HDD_RCV_FILTER_SET:
7964 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007965 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007966
7967 packetFilterSetReq.filterId = pRequest->filterId;
7968 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
7969 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007970 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 __func__, pRequest->numParams);
7972 return -EINVAL;
7973 }
7974 packetFilterSetReq.numFieldParams = pRequest->numParams;
7975 packetFilterSetReq.coalesceTime = 0;
7976 packetFilterSetReq.filterType = 1;
7977 for (i=0; i < pRequest->numParams; i++)
7978 {
7979 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
7980 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
7981 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
7982 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
7983 packetFilterSetReq.paramsData[i].reserved = 0;
7984
Arif Hussain6d2a3322013-11-17 19:50:10 -08007985 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
7987 packetFilterSetReq.filterType);
7988
Arif Hussain6d2a3322013-11-17 19:50:10 -08007989 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
7991
7992 memcpy(&packetFilterSetReq.paramsData[i].compareData,
7993 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
7994 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
7995 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
7996
Arif Hussain6d2a3322013-11-17 19:50:10 -08007997 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007998 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
7999 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8000 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8001
Arif Hussain6d2a3322013-11-17 19:50:10 -08008002 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008003 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8004 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8005 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8006 }
8007
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008008 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008009 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008010 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008011 __func__);
8012 return -EINVAL;
8013 }
8014
8015 break;
8016
8017 case HDD_RCV_FILTER_CLEAR:
8018
Arif Hussain6d2a3322013-11-17 19:50:10 -08008019 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008020 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008021 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008022 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008023 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008024 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 __func__);
8026 return -EINVAL;
8027 }
8028 break;
8029
8030 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008031 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008032 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 return -EINVAL;
8034 }
8035 return 0;
8036}
8037
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308038int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8039 tANI_U8 sessionId)
8040{
8041 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8042 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8043
8044 if (NULL == pHddCtx)
8045 {
8046 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8047 return -EINVAL;
8048 }
8049
8050 if (pHddCtx->isLogpInProgress)
8051 {
8052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8053 "%s:LOGP in Progress. Ignore!!!", __func__);
8054 return -EBUSY;
8055 }
8056
8057 if (pHddCtx->cfg_ini->disablePacketFilter)
8058 {
8059 hddLog(VOS_TRACE_LEVEL_ERROR,
8060 "%s: Packet Filtering Disabled. Returning ",
8061 __func__ );
8062 return -EINVAL;
8063 }
8064
8065 switch (filterType)
8066 {
8067 /* For setting IPV6 MC and UC Filter we need to configure
8068 * 2 filters, one for MC and one for UC.
8069 * The Filter ID shouldn't be swapped, which results in making
8070 * UC Filter ineffective.
8071 * We have Hardcode all the values
8072 *
8073 * Reason for a seperate UC filter is because, driver need to
8074 * specify the FW that the specific filter is for unicast
8075 * otherwise FW will not pass the unicast frames by default
8076 * through the filter. This is required to avoid any performance
8077 * hits when no unicast filter is set and only MC/BC are set.
8078 * The way driver informs host is by using the MAC protocol
8079 * layer, CMP flag set to MAX, CMP Data set to 1.
8080 */
8081
8082 case HDD_FILTER_IPV6_MC_UC:
8083 /* Setting IPV6 MC Filter below
8084 */
8085 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8086 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8087 packetFilterSetReq.numFieldParams = 2;
8088 packetFilterSetReq.paramsData[0].protocolLayer =
8089 HDD_FILTER_PROTO_TYPE_MAC;
8090 packetFilterSetReq.paramsData[0].cmpFlag =
8091 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8092 packetFilterSetReq.paramsData[0].dataOffset =
8093 WLAN_HDD_80211_FRM_DA_OFFSET;
8094 packetFilterSetReq.paramsData[0].dataLength = 1;
8095 packetFilterSetReq.paramsData[0].compareData[0] =
8096 HDD_IPV6_MC_CMP_DATA;
8097
8098 packetFilterSetReq.paramsData[1].protocolLayer =
8099 HDD_FILTER_PROTO_TYPE_ARP;
8100 packetFilterSetReq.paramsData[1].cmpFlag =
8101 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8102 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8103 packetFilterSetReq.paramsData[1].dataLength = 2;
8104 packetFilterSetReq.paramsData[1].compareData[0] =
8105 HDD_IPV6_CMP_DATA_0;
8106 packetFilterSetReq.paramsData[1].compareData[1] =
8107 HDD_IPV6_CMP_DATA_1;
8108
8109
8110 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8111 &packetFilterSetReq, sessionId))
8112 {
8113 hddLog(VOS_TRACE_LEVEL_ERROR,
8114 "%s: Failure to execute Set IPv6 Mulicast Filter",
8115 __func__);
8116 return -EINVAL;
8117 }
8118
8119 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8120
8121 /*
8122 * Setting IPV6 UC Filter below
8123 */
8124 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8125 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8126 packetFilterSetReq.numFieldParams = 2;
8127 packetFilterSetReq.paramsData[0].protocolLayer =
8128 HDD_FILTER_PROTO_TYPE_MAC;
8129 packetFilterSetReq.paramsData[0].cmpFlag =
8130 HDD_FILTER_CMP_TYPE_MAX;
8131 packetFilterSetReq.paramsData[0].dataOffset = 0;
8132 packetFilterSetReq.paramsData[0].dataLength = 1;
8133 packetFilterSetReq.paramsData[0].compareData[0] =
8134 HDD_IPV6_UC_CMP_DATA;
8135
8136 packetFilterSetReq.paramsData[1].protocolLayer =
8137 HDD_FILTER_PROTO_TYPE_ARP;
8138 packetFilterSetReq.paramsData[1].cmpFlag =
8139 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8140 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8141 packetFilterSetReq.paramsData[1].dataLength = 2;
8142 packetFilterSetReq.paramsData[1].compareData[0] =
8143 HDD_IPV6_CMP_DATA_0;
8144 packetFilterSetReq.paramsData[1].compareData[1] =
8145 HDD_IPV6_CMP_DATA_1;
8146
8147 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8148 &packetFilterSetReq, sessionId))
8149 {
8150 hddLog(VOS_TRACE_LEVEL_ERROR,
8151 "%s: Failure to execute Set IPv6 Unicast Filter",
8152 __func__);
8153 return -EINVAL;
8154 }
8155
8156 break;
8157
8158 case HDD_FILTER_IPV6_MC:
8159 /*
8160 * IPV6 UC Filter might be already set,
8161 * clear the UC Filter. As the Filter
8162 * IDs are static, we can directly clear it.
8163 */
8164 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8165 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8166 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8167 &packetFilterClrReq, sessionId))
8168 {
8169 hddLog(VOS_TRACE_LEVEL_ERROR,
8170 "%s: Failure to execute Clear IPv6 Unicast Filter",
8171 __func__);
8172 return -EINVAL;
8173 }
8174
8175 /*
8176 * Setting IPV6 MC Filter below
8177 */
8178 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8179 packetFilterSetReq.numFieldParams = 2;
8180 packetFilterSetReq.paramsData[0].protocolLayer =
8181 HDD_FILTER_PROTO_TYPE_MAC;
8182 packetFilterSetReq.paramsData[0].cmpFlag =
8183 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8184 packetFilterSetReq.paramsData[0].dataOffset =
8185 WLAN_HDD_80211_FRM_DA_OFFSET;
8186 packetFilterSetReq.paramsData[0].dataLength = 1;
8187 packetFilterSetReq.paramsData[0].compareData[0] =
8188 HDD_IPV6_MC_CMP_DATA;
8189
8190 packetFilterSetReq.paramsData[1].protocolLayer =
8191 HDD_FILTER_PROTO_TYPE_ARP;
8192 packetFilterSetReq.paramsData[1].cmpFlag =
8193 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8194 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8195 packetFilterSetReq.paramsData[1].dataLength = 2;
8196 packetFilterSetReq.paramsData[1].compareData[0] =
8197 HDD_IPV6_CMP_DATA_0;
8198 packetFilterSetReq.paramsData[1].compareData[1] =
8199 HDD_IPV6_CMP_DATA_1;
8200
8201
8202 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8203 &packetFilterSetReq, sessionId))
8204 {
8205 hddLog(VOS_TRACE_LEVEL_ERROR,
8206 "%s: Failure to execute Set IPv6 Multicast Filter",
8207 __func__);
8208 return -EINVAL;
8209 }
8210 break;
8211
8212 default :
8213 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8214 "%s: Packet Filter Request: Invalid",
8215 __func__);
8216 return -EINVAL;
8217 }
8218 return 0;
8219}
8220
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308221void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008222{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308223 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308224 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008225 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308226 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008227
Yue Ma3ede6052013-08-29 00:33:26 -07008228 if (NULL == pHddCtx)
8229 {
8230 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8231 return;
8232 }
8233
8234 hHal = pHddCtx->hHal;
8235
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308236 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008237 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308238 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8239 return;
8240 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308241
8242 /* Check if INI is enabled or not, other wise just return
8243 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308244 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308245 {
8246 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8247 if (NULL == pMulticastAddrs)
8248 {
8249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8250 return;
8251 }
8252
Jeff Johnson295189b2012-06-20 16:38:30 -07008253 if (set)
8254 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308255 /* Following pre-conditions should be satisfied before wei
8256 * configure the MC address list.
8257 */
8258 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8259 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8260 && pAdapter->mc_addr_list.mc_cnt
8261 && (eConnectionState_Associated ==
8262 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8263 {
8264 pMulticastAddrs->ulMulticastAddrCnt =
8265 pAdapter->mc_addr_list.mc_cnt;
8266 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8267 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008268 memcpy(pMulticastAddrs->multicastAddr[i],
8269 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308270 sizeof(pAdapter->mc_addr_list.addr[i]));
8271 hddLog(VOS_TRACE_LEVEL_INFO,
8272 "%s: %s multicast filter: addr ="
8273 MAC_ADDRESS_STR,
8274 __func__, set ? "setting" : "clearing",
8275 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8276 }
8277 /* Set multicast filter */
8278 sme_8023MulticastList(hHal, pAdapter->sessionId,
8279 pMulticastAddrs);
8280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008281 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308282 else
8283 {
8284 /* Need to clear only if it was previously configured
8285 */
8286 if (pAdapter->mc_addr_list.isFilterApplied)
8287 {
8288 pMulticastAddrs->ulMulticastAddrCnt = 0;
8289 sme_8023MulticastList(hHal, pAdapter->sessionId,
8290 pMulticastAddrs);
8291 }
8292
8293 }
8294 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008295 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308297 else
8298 {
8299 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308300 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308301 }
8302 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008303}
8304
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308305static int __iw_set_packet_filter_params(struct net_device *dev,
8306 struct iw_request_info *info,
8307 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308308{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308309 hdd_adapter_t *pAdapter;
8310 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008311 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308312 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308313 struct iw_point s_priv_data;
8314
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308315 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308316 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8317 if (NULL == pAdapter)
8318 {
8319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8320 "%s: Adapter is NULL",__func__);
8321 return -EINVAL;
8322 }
8323 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8324 ret = wlan_hdd_validate_context(pHddCtx);
8325 if (0 != ret)
8326 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308327 return ret;
8328 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308329 if (hdd_priv_get_data(&s_priv_data, wrqu))
8330 {
8331 return -EINVAL;
8332 }
8333
8334 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8335 {
8336 return -EINVAL;
8337 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008338
Arif Hussain0273cba2014-01-07 20:58:29 -08008339 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308340 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8341 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008342 if (NULL == pRequest)
8343 {
8344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8345 "mem_alloc_copy_from_user_helper fail");
8346 return -ENOMEM;
8347 }
8348
8349 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8350 kfree(pRequest);
8351
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308352 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008353 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008354}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308355
8356static int iw_set_packet_filter_params(struct net_device *dev,
8357 struct iw_request_info *info,
8358 union iwreq_data *wrqu, char *extra)
8359{
8360 int ret;
8361
8362 vos_ssr_protect(__func__);
8363 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8364 vos_ssr_unprotect(__func__);
8365
8366 return ret;
8367}
Jeff Johnson295189b2012-06-20 16:38:30 -07008368#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308369static int __iw_get_statistics(struct net_device *dev,
8370 struct iw_request_info *info,
8371 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008372{
8373
8374 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8375 eHalStatus status = eHAL_STATUS_SUCCESS;
8376 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308377 hdd_adapter_t *pAdapter;
8378 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008379 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308380 int tlen = 0, ret = 0;
8381 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008382
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308383 tCsrGlobalClassAStatsInfo *aStats;
8384 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008385
8386 ENTER();
8387
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308388 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8389 if (NULL == pAdapter)
8390 {
8391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8392 "%s: Adapter is NULL",__func__);
8393 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008394 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308395 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8396 ret = wlan_hdd_validate_context(pHddCtx);
8397 if (0 != ret)
8398 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308399 return ret;
8400 }
8401 pStats = &(pAdapter->hdd_stats.summary_stat);
8402 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8403 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8405
8406 wrqu->txpower.value = 0;
8407 }
8408 else {
8409 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8410 SME_SUMMARY_STATS |
8411 SME_GLOBAL_CLASSA_STATS |
8412 SME_GLOBAL_CLASSB_STATS |
8413 SME_GLOBAL_CLASSC_STATS |
8414 SME_GLOBAL_CLASSD_STATS |
8415 SME_PER_STA_STATS,
8416 hdd_StatisticsCB, 0, FALSE,
8417 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8418
8419 if (eHAL_STATUS_SUCCESS != status)
8420 {
8421 hddLog(VOS_TRACE_LEVEL_ERROR,
8422 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008423 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 return -EINVAL;
8425 }
8426
8427 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308428 if (NULL == pWextState)
8429 {
8430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8431 "%s: pWextState is NULL",__func__);
8432 return -EINVAL;
8433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008434
8435 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8436 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8437 {
8438 hddLog(VOS_TRACE_LEVEL_ERROR,
8439 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008440 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008441 /*Remove the SME statistics list by passing NULL in callback argument*/
8442 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8443 SME_SUMMARY_STATS |
8444 SME_GLOBAL_CLASSA_STATS |
8445 SME_GLOBAL_CLASSB_STATS |
8446 SME_GLOBAL_CLASSC_STATS |
8447 SME_GLOBAL_CLASSD_STATS |
8448 SME_PER_STA_STATS,
8449 NULL, 0, FALSE,
8450 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8451
8452 return -EINVAL;
8453 }
8454 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8455 (tANI_U8) sizeof (pStats->retry_cnt),
8456 (char*) &(pStats->retry_cnt[0]),
8457 tlen);
8458
8459 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8460 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8461 (char*) &(pStats->multiple_retry_cnt[0]),
8462 tlen);
8463
8464 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8465 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8466 (char*) &(pStats->tx_frm_cnt[0]),
8467 tlen);
8468
8469 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8470 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8471 (char*) &(pStats->rx_frm_cnt),
8472 tlen);
8473
8474 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8475 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8476 (char*) &(pStats->frm_dup_cnt),
8477 tlen);
8478
8479 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8480 (tANI_U8) sizeof (pStats->fail_cnt),
8481 (char*) &(pStats->fail_cnt[0]),
8482 tlen);
8483
8484 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8485 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8486 (char*) &(pStats->rts_fail_cnt),
8487 tlen);
8488
8489 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8490 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8491 (char*) &(pStats->ack_fail_cnt),
8492 tlen);
8493
8494 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8495 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8496 (char*) &(pStats->rts_succ_cnt),
8497 tlen);
8498
8499 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8500 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8501 (char*) &(pStats->rx_discard_cnt),
8502 tlen);
8503
8504 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8505 (tANI_U8) sizeof (pStats->rx_error_cnt),
8506 (char*) &(pStats->rx_error_cnt),
8507 tlen);
8508
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008509 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008510 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008511 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 tlen);
8513
8514 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8515 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8516 (char*) &(dStats->rx_byte_cnt),
8517 tlen);
8518
8519 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8520 (tANI_U8) sizeof (dStats->rx_rate),
8521 (char*) &(dStats->rx_rate),
8522 tlen);
8523
8524 /* Transmit rate, in units of 500 kbit/sec */
8525 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8526 (tANI_U8) sizeof (aStats->tx_rate),
8527 (char*) &(aStats->tx_rate),
8528 tlen);
8529
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008530 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8531 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8532 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008533 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008534 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8535 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8536 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008537 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008538 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8539 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8540 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008541 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008542 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8543 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8544 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008545 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008546 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8547 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8548 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008549 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008550 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8551 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8552 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008553 tlen);
8554
Jeff Johnson295189b2012-06-20 16:38:30 -07008555 wrqu->data.length = tlen;
8556
8557 }
8558
8559 EXIT();
8560
8561 return 0;
8562}
8563
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308564static int iw_get_statistics(struct net_device *dev,
8565 struct iw_request_info *info,
8566 union iwreq_data *wrqu, char *extra)
8567{
8568 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008569
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308570 vos_ssr_protect(__func__);
8571 ret = __iw_get_statistics(dev, info, wrqu, extra);
8572 vos_ssr_unprotect(__func__);
8573
8574 return ret;
8575}
Jeff Johnson295189b2012-06-20 16:38:30 -07008576#ifdef FEATURE_WLAN_SCAN_PNO
8577
8578/*Max Len for PNO notification*/
8579#define MAX_PNO_NOTIFY_LEN 100
8580void found_pref_network_cb (void *callbackContext,
8581 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8582{
8583 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8584 union iwreq_data wrqu;
8585 char buf[MAX_PNO_NOTIFY_LEN+1];
8586
8587 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8588 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8589
8590 // create the event
8591 memset(&wrqu, 0, sizeof(wrqu));
8592 memset(buf, 0, sizeof(buf));
8593
8594 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8595 pPrefNetworkFoundInd->ssId.ssId,
8596 (unsigned int)pPrefNetworkFoundInd->rssi);
8597
8598 wrqu.data.pointer = buf;
8599 wrqu.data.length = strlen(buf);
8600
8601 // send the event
8602
8603 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8604
8605}
8606
8607
8608/*string based input*/
8609VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8610 union iwreq_data *wrqu, char *extra, int nOffset)
8611{
8612 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308613 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008614 /* pnoRequest is a large struct, so we make it static to avoid stack
8615 overflow. This API is only invoked via ioctl, so it is
8616 serialized by the kernel rtnl_lock and hence does not need to be
8617 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308618 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 char *ptr;
8620 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308621 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8623
8624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8625 "PNO data len %d data %s",
8626 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008627 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008628
8629 if (wrqu->data.length <= nOffset )
8630 {
8631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8632 return VOS_STATUS_E_FAILURE;
8633 }
8634
8635 pnoRequest.enable = 0;
8636 pnoRequest.ucNetworksCount = 0;
8637 /*-----------------------------------------------------------------------
8638 Input is string based and expected to be like this:
8639
8640 <enabled> <netw_count>
8641 for each network:
8642 <ssid_len> <ssid> <authentication> <encryption>
8643 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8644 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8645
8646 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008647 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 -07008648
8649 this translates into:
8650 -----------------------------
8651 enable PNO
8652 look for 2 networks:
8653 test - with authentication type 0 and encryption type 0,
8654 that can be found on 3 channels: 1 6 and 11 ,
8655 SSID bcast type is unknown (directed probe will be sent if AP not found)
8656 and must meet -40dBm RSSI
8657
8658 test2 - with auth and enrytption type 4/4
8659 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
8660 bcast type is non-bcast (directed probe will be sent)
8661 and must not meet any RSSI threshold
8662
Jeff Johnson8301aa12013-03-28 14:27:29 -07008663 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07008664 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08008665 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008666
Wilson Yang623f6592013-10-08 16:33:37 -07008667 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
8668 {
8669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8670 "PNO enable input is not valid %s",ptr);
8671 return VOS_STATUS_E_FAILURE;
8672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008673
8674 if ( 0 == pnoRequest.enable )
8675 {
8676 /*Disable PNO*/
8677 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05308678 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8679 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008680 pAdapter->sessionId,
8681 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308682 if (eHAL_STATUS_SUCCESS != status)
8683 {
8684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8685 "%s: failed to disable PNO", __func__);
8686 return VOS_STATUS_E_FAILURE;
8687 }
8688 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008689 return VOS_STATUS_SUCCESS;
8690 }
8691
c_hpothu37f21312014-04-09 21:49:54 +05308692 if (TRUE == pHddCtx->isPnoEnable)
8693 {
8694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8695 FL("already PNO is enabled"));
8696 return -EBUSY;
8697 }
8698 pHddCtx->isPnoEnable = TRUE;
8699
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07008701
8702 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
8703 {
8704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8705 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308706 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008708
8709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8710 "PNO enable %d networks count %d offset %d",
8711 pnoRequest.enable,
8712 pnoRequest.ucNetworksCount,
8713 nOffset);
8714
8715 /* Parameters checking:
8716 ucNetworksCount has to be larger than 0*/
8717 if (( 0 == pnoRequest.ucNetworksCount ) ||
8718 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8719 {
8720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05308721 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 }
8723
8724 ptr += nOffset;
8725
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308726 pnoRequest.aNetworks =
8727 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8728 if (pnoRequest.aNetworks == NULL)
8729 {
8730 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8731 FL("failed to allocate memory aNetworks %u"),
8732 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8733 goto error;
8734 }
8735 vos_mem_zero(pnoRequest.aNetworks,
8736 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8737
Jeff Johnson295189b2012-06-20 16:38:30 -07008738 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
8739 {
8740
8741 pnoRequest.aNetworks[i].ssId.length = 0;
8742
Wilson Yang623f6592013-10-08 16:33:37 -07008743 ucParams = sscanf(ptr,"%hhu %n",
8744 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
8745
8746 if (1 != ucParams)
8747 {
8748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8749 "PNO ssid length input is not valid %s",ptr);
8750 return VOS_STATUS_E_FAILURE;
8751 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008752
8753 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
8754 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
8755 {
8756 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8757 "SSID Len %d is not correct for network %d",
8758 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05308759 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 }
8761
8762 /*Advance to SSID*/
8763 ptr += nOffset;
8764
Jeff Johnson8301aa12013-03-28 14:27:29 -07008765 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08008766 pnoRequest.aNetworks[i].ssId.length);
8767 ptr += pnoRequest.aNetworks[i].ssId.length;
8768
Jeff Johnson02797792013-10-26 19:17:13 -07008769 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08008770 &(pnoRequest.aNetworks[i].authentication),
8771 &(pnoRequest.aNetworks[i].encryption),
8772 &(pnoRequest.aNetworks[i].ucChannelCount),
8773 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008774
Wilson Yang623f6592013-10-08 16:33:37 -07008775 if ( 3 != ucParams )
8776 {
8777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8778 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308779 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008780 }
8781
Jeff Johnson295189b2012-06-20 16:38:30 -07008782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008783 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08008784 "auth %d encry %d channel count %d offset %d",
8785 pnoRequest.aNetworks[i].ssId.length,
8786 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
8787 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
8788 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
8789 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
8790 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
8791 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
8792 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
8793 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
8794 pnoRequest.aNetworks[i].authentication,
8795 pnoRequest.aNetworks[i].encryption,
8796 pnoRequest.aNetworks[i].ucChannelCount,
8797 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07008798
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 /*Advance to channel list*/
8800 ptr += nOffset;
8801
Wilson Yang623f6592013-10-08 16:33:37 -07008802 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07008803 {
8804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8805 "Incorrect number of channels");
8806 return VOS_STATUS_E_FAILURE;
8807 }
8808
8809 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
8810 {
8811 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
8812 {
Wilson Yang623f6592013-10-08 16:33:37 -07008813 if (1 != sscanf(ptr,"%hhu %n",
8814 &(pnoRequest.aNetworks[i].aChannels[j]),
8815 &nOffset))
8816 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8817 "PNO network channel input is not valid %s",ptr);
8818 return VOS_STATUS_E_FAILURE;
8819 }
8820 /*Advance to next channel number*/
8821 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008822 }
8823 }
8824
Jeff Johnson02797792013-10-26 19:17:13 -07008825 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07008826 &(pnoRequest.aNetworks[i].bcastNetwType),
8827 &nOffset))
8828 {
8829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8830 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308831 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008833
8834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8835 "PNO bcastNetwType %d offset %d",
8836 pnoRequest.aNetworks[i].bcastNetwType,
8837 nOffset );
8838
8839 /*Advance to rssi Threshold*/
8840 ptr += nOffset;
8841
Wilson Yang623f6592013-10-08 16:33:37 -07008842 if (1 != sscanf(ptr,"%hhu %n",
8843 &(pnoRequest.aNetworks[i].rssiThreshold),
8844 &nOffset))
8845 {
8846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8847 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308848 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008850
8851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8852 "PNO rssi %d offset %d",
8853 pnoRequest.aNetworks[i].rssiThreshold,
8854 nOffset );
8855 /*Advance to next network*/
8856 ptr += nOffset;
8857 }/*For ucNetworkCount*/
8858
8859 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07008860 &(pnoRequest.scanTimers.ucScanTimersCount),
8861 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008862
8863 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07008864 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07008865 {
8866 ptr += nOffset;
8867
Jeff Johnson8301aa12013-03-28 14:27:29 -07008868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8869 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 pnoRequest.scanTimers.ucScanTimersCount,
8871 nOffset );
8872
8873 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
8874 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07008875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008876 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05308877 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008878 }
8879
8880 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
8881 {
Jeff Johnson02797792013-10-26 19:17:13 -07008882 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
8884 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
8885 &nOffset);
8886
Wilson Yang623f6592013-10-08 16:33:37 -07008887 if (2 != ucParams)
8888 {
8889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8890 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05308891 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008892 }
8893
Jeff Johnson8301aa12013-03-28 14:27:29 -07008894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8895 "PNO Timer value %d Timer repeat %d offset %d",
8896 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07008897 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
8898 nOffset );
8899
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 ptr += nOffset;
8901 }
8902
8903 }
8904 else
8905 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07008906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8907 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008908 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
8909
8910 /*Scan timers defaults to 5 minutes*/
8911 pnoRequest.scanTimers.ucScanTimersCount = 1;
8912 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
8913 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
8914 }
8915
Wilson Yang623f6592013-10-08 16:33:37 -07008916 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008917
8918 pnoRequest.modePNO = ucMode;
8919 /*for LA we just expose suspend option*/
8920 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
8921 {
8922 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
8923 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308924 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
8925 if (pnoRequest.p24GProbeTemplate == NULL){
8926 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8927 FL("failed to allocate memory p24GProbeTemplate %u"),
8928 SIR_PNO_MAX_PB_REQ_SIZE);
8929 goto error;
8930 }
8931
8932 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
8933 if (pnoRequest.p5GProbeTemplate == NULL){
8934 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8935 FL("failed to allocate memory p5GProbeTemplate %u"),
8936 SIR_PNO_MAX_PB_REQ_SIZE);
8937 goto error;
8938 }
8939
8940 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
8941 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008942
c_hpothu37f21312014-04-09 21:49:54 +05308943 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 pAdapter->sessionId,
8945 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308946 if (eHAL_STATUS_SUCCESS == status)
8947 {
8948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8949 "%s: PNO enabled", __func__);
8950 return VOS_STATUS_SUCCESS;
8951 }
8952error:
8953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8954 "%s: Failed to enable PNO", __func__);
8955 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308956 if (pnoRequest.aNetworks)
8957 vos_mem_free(pnoRequest.aNetworks);
8958 if (pnoRequest.p24GProbeTemplate)
8959 vos_mem_free(pnoRequest.p24GProbeTemplate);
8960 if (pnoRequest.p5GProbeTemplate)
8961 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05308962 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008963}/*iw_set_pno*/
8964
8965VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
8966 union iwreq_data *wrqu, char *extra, int nOffset)
8967{
8968 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8969 v_U8_t rssiThreshold = 0;
8970 v_U8_t nRead;
8971
Arif Hussain7adce1b2013-11-11 22:59:34 -08008972 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008973 &rssiThreshold);
8974
8975 if ( 1 != nRead )
8976 {
8977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8978 "Incorrect format");
8979 return VOS_STATUS_E_FAILURE;
8980 }
8981
8982 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
8983 return VOS_STATUS_SUCCESS;
8984}
8985
8986
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308987static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 struct iw_request_info *info,
8989 union iwreq_data *wrqu, char *extra)
8990{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308991 hdd_adapter_t *pAdapter;
8992 hdd_context_t *pHddCtx;
8993 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308994 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308995
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308996 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308997 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8998 if (NULL == pAdapter)
8999 {
9000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9001 "%s: Adapter is NULL",__func__);
9002 return -EINVAL;
9003 }
9004
9005 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9006 ret = wlan_hdd_validate_context(pHddCtx);
9007 if (0 != ret)
9008 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309009 return ret;
9010 }
9011
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009012
9013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009014 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009015
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309016 status = iw_set_pno(dev,info,wrqu,extra,0);
9017
9018 EXIT();
9019 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009020}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309021
9022static int iw_set_pno_priv(struct net_device *dev,
9023 struct iw_request_info *info,
9024 union iwreq_data *wrqu, char *extra)
9025{
9026 int ret;
9027
9028 vos_ssr_protect(__func__);
9029 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9030 vos_ssr_unprotect(__func__);
9031
9032 return ret;
9033}
Jeff Johnson295189b2012-06-20 16:38:30 -07009034#endif /*FEATURE_WLAN_SCAN_PNO*/
9035
9036//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309037int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009038{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309039 hdd_adapter_t *pAdapter;
9040 tHalHandle hHal;
9041 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309042 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309043 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309044 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009045 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309046 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309047 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309048 tpAniSirGlobal pMac;
9049 int retval = 0;
9050
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309051 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309052 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9053 if (NULL == pAdapter)
9054 {
9055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9056 "%s: Adapter is NULL",__func__);
9057 return -EINVAL;
9058 }
9059 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9060 retval = wlan_hdd_validate_context(pHddCtx);
9061 if (0 != retval)
9062 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309063 return retval;
9064 }
9065 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9066 if (NULL == hHal)
9067 {
9068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9069 "%s: Hal Context is NULL",__func__);
9070 return -EINVAL;
9071 }
9072 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009073
Atul Mittal54378cb2014-04-02 16:51:50 +05309074 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009075 {
9076 case WLAN_HDD_UI_BAND_AUTO:
9077 band = eCSR_BAND_ALL;
9078 break;
9079 case WLAN_HDD_UI_BAND_5_GHZ:
9080 band = eCSR_BAND_5G;
9081 break;
9082 case WLAN_HDD_UI_BAND_2_4_GHZ:
9083 band = eCSR_BAND_24;
9084 break;
9085 default:
9086 band = eCSR_BAND_MAX;
9087 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309088 connectedBand =
9089 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009090
Atul Mittal54378cb2014-04-02 16:51:50 +05309091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009092 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009093
9094 if (band == eCSR_BAND_MAX)
9095 {
9096 /* Received change band request with invalid band value */
9097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309098 "%s: Invalid band value %u", __func__, ui_band);
9099 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009100 }
9101
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309102 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
9103 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
9104 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
9105 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009107 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009108 band, pHddCtx->cfg_ini->nBandCapability);
9109 return -EIO;
9110 }
9111
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9113 {
9114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9115 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009116 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009117 return -EIO;
9118 }
9119
9120 if (currBand != band)
9121 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309122 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309123 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309124 /* Return failure if current country code is world regulatory domain*/
9125 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9126 pMac->scan.countryCodeCurrent[1] == '0') )
9127 {
9128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9129 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309130 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309131 return -EAGAIN;
9132 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309133 }
9134
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 /* Change band request received.
9136 * Abort pending scan requests, flush the existing scan results,
9137 * and change the band capability
9138 */
9139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9140 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009141 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009142
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309143 /* We need to change the band and flush the scan results here itself
9144 * as we may get timeout for disconnection in which we will return
9145 * with out doing any of these
9146 */
9147 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9148 {
9149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9150 "%s: failed to set the band value to %u ",
9151 __func__, band);
9152 return -EINVAL;
9153 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309154 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9155 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309156 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309157 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9158 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309159 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309160 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9161 * information available in NV so to get the channel information from kernel
9162 * we need to send regulatory hint for the currunt country
9163 * And to set the same country again we need to set the dummy country
9164 * first and then the actual country.
9165 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309166#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9167 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9168#else
9169 regulatory_hint_user("00");
9170#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309171 wait_result = wait_for_completion_interruptible_timeout(
9172 &pHddCtx->linux_reg_req,
9173 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9174
9175 /* if the country information does not exist with the kernel,
9176 then the driver callback would not be called */
9177
9178 if (wait_result >= 0)
9179 {
9180 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9181 "runtime country code is found in kernel db");
9182 }
9183 else
9184 {
9185 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9186 "runtime country code is not found"
9187 " in kernel db");
9188 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309189
9190 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309191
9192 /*
9193 * Update 11dcountry and current country here as the hint
9194 * with 00 results in 11d and current country with 00
9195 */
9196 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9197 WNI_CFG_COUNTRY_CODE_LEN);
9198 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9199 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309200#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9201 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9202#else
9203 regulatory_hint_user(curr_country);
9204#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309205 wait_result = wait_for_completion_interruptible_timeout(
9206 &pHddCtx->linux_reg_req,
9207 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9208
9209 /* if the country information does not exist with the kernel,
9210 then the driver callback would not be called */
9211 if (wait_result >= 0)
9212 {
9213 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9214 "runtime country code is found in kernel db");
9215 }
9216 else
9217 {
9218 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9219 "runtime country code is not found"
9220 " in kernel db");
9221 }
9222
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309223 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
9224 }
9225 else
9226 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309227#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309228 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9229 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309230#else
9231 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9232#endif
9233
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309234 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309235 pScanInfo = &pHddCtx->scan_info;
9236 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9237 {
9238 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9239 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9240 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309241 sme_FilterScanResults(hHal, pAdapter->sessionId);
9242
9243 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309244 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9245 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 eHalStatus status = eHAL_STATUS_SUCCESS;
9248 long lrc;
9249
9250 /* STA already connected on current band, So issue disconnect first,
9251 * then change the band*/
9252
9253 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309254 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309255 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009256
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9258
9259 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9260 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9261
Jeff Johnson43971f52012-07-17 12:26:56 -07009262 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009263 {
9264 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009265 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 __func__, (int)status );
9267 return -EINVAL;
9268 }
9269
9270 lrc = wait_for_completion_interruptible_timeout(
9271 &pAdapter->disconnect_comp_var,
9272 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9273
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309274 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009275
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009276 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009277 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009278
9279 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9280 }
9281 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009282 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309283 EXIT();
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309284 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009285}
9286
Atul Mittal54378cb2014-04-02 16:51:50 +05309287int hdd_setBand_helper(struct net_device *dev, const char *command)
9288{
9289 u8 band;
9290
9291 /*convert the band value from ascii to integer*/
9292 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9293
9294 return hdd_setBand(dev, band);
9295
9296}
9297
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309298static int __iw_set_band_config(struct net_device *dev,
9299 struct iw_request_info *info,
9300 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009301{
Atul Mittal54378cb2014-04-02 16:51:50 +05309302 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009303
Arif Hussain0273cba2014-01-07 20:58:29 -08009304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009305
Atul Mittal54378cb2014-04-02 16:51:50 +05309306 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009307}
9308
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309309static int iw_set_band_config(struct net_device *dev,
9310 struct iw_request_info *info,
9311 union iwreq_data *wrqu, char *extra)
9312{
9313 int ret;
9314
9315 vos_ssr_protect(__func__);
9316 ret = __iw_set_band_config(dev, info, wrqu, extra);
9317 vos_ssr_unprotect(__func__);
9318
9319 return ret;
9320}
9321
9322static int __iw_set_power_params_priv(struct net_device *dev,
9323 struct iw_request_info *info,
9324 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009325{
Arif Hussain0273cba2014-01-07 20:58:29 -08009326 int ret;
9327 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9329 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009330 /* ODD number is used for set, copy data using copy_from_user */
9331 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9332 wrqu->data.length);
9333 if (NULL == ptr)
9334 {
9335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9336 "mem_alloc_copy_from_user_helper fail");
9337 return -ENOMEM;
9338 }
9339
9340 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9341 kfree(ptr);
9342 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009343}
9344
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309345static int iw_set_power_params_priv(struct net_device *dev,
9346 struct iw_request_info *info,
9347 union iwreq_data *wrqu, char *extra)
9348{
9349 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009350
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309351 vos_ssr_protect(__func__);
9352 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9353 vos_ssr_unprotect(__func__);
9354
9355 return ret;
9356}
Jeff Johnson295189b2012-06-20 16:38:30 -07009357
9358/*string based input*/
9359VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9360 union iwreq_data *wrqu, char *extra, int nOffset)
9361{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309362 hdd_adapter_t *pAdapter;
9363 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 tSirSetPowerParamsReq powerRequest;
9365 char *ptr;
9366 v_U8_t ucType;
9367 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309368 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009369
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309370 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309371 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9372 if (NULL == pAdapter)
9373 {
9374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9375 "%s: Adapter is NULL",__func__);
9376 return -EINVAL;
9377 }
9378
9379 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9380 ret = wlan_hdd_validate_context(pHddCtx);
9381 if (0 != ret)
9382 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309383 return ret;
9384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9386 "Power Params data len %d data %s",
9387 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009388 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009389
9390 if (wrqu->data.length <= nOffset )
9391 {
9392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9393 return VOS_STATUS_E_FAILURE;
9394 }
9395
9396 uTotalSize = wrqu->data.length - nOffset;
9397
9398 /*-----------------------------------------------------------------------
9399 Input is string based and expected to be like this:
9400
9401 <param_type> <param_value> <param_type> <param_value> ...
9402
9403 e.g:
9404 1 2 2 3 3 0 4 1 5 1
9405
9406 e.g. setting just a few:
9407 1 2 4 1
9408
9409 parameter types:
9410 -----------------------------
9411 1 - Ignore DTIM
9412 2 - Listen Interval
9413 3 - Broadcast Multicas Filter
9414 4 - Beacon Early Termination
9415 5 - Beacon Early Termination Interval
9416 -----------------------------------------------------------------------*/
9417 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9418 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9419 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9420 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9421 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9422
Arif Hussain7adce1b2013-11-11 22:59:34 -08009423 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009424
9425 while ( uTotalSize )
9426 {
Wilson Yang6f971452013-10-08 15:00:00 -07009427 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9428 {
9429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9430 "Invalid input parameter type %s",ptr);
9431 return VOS_STATUS_E_FAILURE;
9432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009433
9434 uTotalSize -= nOffset;
9435
9436 if (!uTotalSize)
9437 {
9438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009439 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 ucType, nOffset);
9441 return VOS_STATUS_E_FAILURE;
9442 }
9443
9444 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009445
Jeff Johnson02797792013-10-26 19:17:13 -07009446 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009447 {
9448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9449 "Invalid input parameter value %s",ptr);
9450 return VOS_STATUS_E_FAILURE;
9451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009452
9453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9454 "Power request parameter %d value %d offset %d",
9455 ucType, uValue, nOffset);
9456
9457 switch (ucType)
9458 {
9459 case eSIR_IGNORE_DTIM:
9460 powerRequest.uIgnoreDTIM = uValue;
9461 break;
9462 case eSIR_LISTEN_INTERVAL:
9463 powerRequest.uListenInterval = uValue;
9464 break;
9465 case eSIR_MCAST_BCAST_FILTER:
9466 powerRequest.uBcastMcastFilter = uValue;
9467 break;
9468 case eSIR_ENABLE_BET:
9469 powerRequest.uEnableBET = uValue;
9470 break;
9471 case eSIR_BET_INTERVAL:
9472 powerRequest.uBETInterval = uValue;
9473 break;
9474 default:
9475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009476 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 ucType, uValue, nOffset);
9478 return VOS_STATUS_E_FAILURE;
9479 }
9480
9481 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9483 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009484 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009486 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009487 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009488 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9489 {
9490 uTotalSize = 0;
9491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009492
9493 }/*Go for as long as we have a valid string*/
9494
9495 /* put the device into full power*/
9496 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9497
9498 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009499 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009500
9501 /* put the device back to power save*/
9502 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9503
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309504 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009505 return VOS_STATUS_SUCCESS;
9506}/*iw_set_power_params*/
9507
Atul Mittalc0f739f2014-07-31 13:47:47 +05309508// tdlsoffchan
9509#ifdef FEATURE_WLAN_TDLS
9510
Atul Mittal87ec2422014-09-24 13:12:50 +05309511int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309512{
9513 if (offchannel < 0 || offchannel > 165)
9514 {
9515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9516 __func__, offchannel);
9517 return -1;
9518
9519 }
9520
9521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9522 __func__, tdlsOffCh, offchannel);
9523
9524 tdlsOffCh = offchannel;
9525 return 0;
9526}
9527
Atul Mittal87ec2422014-09-24 13:12:50 +05309528int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309529{
9530 if (offchanoffset == 0)
9531 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309532 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9534 __func__, tdlsOffChBwOffset);
9535
9536 return 0;
9537
9538 }
9539
9540 if ( offchanoffset == 40 )
9541 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309542 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9544 __func__, tdlsOffChBwOffset);
9545
9546 return 0;
9547
9548 }
9549 if (offchanoffset == -40)
9550 {
9551 tdlsOffChBwOffset = 3;
9552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9553 __func__, tdlsOffChBwOffset);
9554
9555 return 0;
9556
9557 }
9558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9559 __func__, offchanoffset);
9560 return -1;
9561}
9562
Atul Mittal87ec2422014-09-24 13:12:50 +05309563int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309564{
9565 hddTdlsPeer_t *connPeer = NULL;
9566 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9567 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9568
9569 if (offchanmode < 0 || offchanmode > 4)
9570 {
9571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9572 "%s: Invalid tdls off channel mode %d",
9573 __func__, offchanmode);
9574 return -1;
9575 }
9576
9577 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9578 {
9579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9580 "%s: tdls off channel mode req in not associated state %d",
9581 __func__, offchanmode);
9582 return -1;
9583 }
9584
9585 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9586 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9587 {
9588 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309589 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309590 if (NULL == connPeer) {
9591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9592 "%s: No TDLS Connected Peer", __func__);
9593 return -1;
9594 }
9595 }
9596 else
9597 {
9598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9599 "%s: TDLS Connection not supported", __func__);
9600 return -1;
9601 }
9602
9603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9604 ("%s: TDLS Channel Switch in swmode=%d"),
9605 __func__, offchanmode);
9606
9607 switch (offchanmode)
9608 {
9609 case 1:/*Enable*/
9610 case 2:/*Disable*/
9611 {
9612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9613 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9614 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9615 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9616 {
9617
9618 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9619 pAdapter->sessionId, connPeer->peerMac,
9620 tdlsOffCh, tdlsOffChBwOffset,
9621 offchanmode);
9622 }
9623 else
9624 {
9625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9626 "%s: TDLS Off Channel not supported", __func__);
9627 return -1;
9628 }
9629 break;
9630 }
9631 case 3:
9632 {
9633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9634 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
9635 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9636
9637 break;
9638 }
9639 case 4:
9640 {
9641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9642 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
9643 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9644 break;
9645 }
9646 default:
9647 {
9648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9649 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
9650 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9651 break;
9652 }
9653
9654 }
9655
9656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
9657 __func__, offchanmode);
9658 return 0;
9659}
Atul Mittalc0f739f2014-07-31 13:47:47 +05309660#endif
9661
Jeff Johnson295189b2012-06-20 16:38:30 -07009662
9663// Define the Wireless Extensions to the Linux Network Device structure
9664// A number of these routines are NULL (meaning they are not implemented.)
9665
9666static const iw_handler we_handler[] =
9667{
9668 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9669 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9670 (iw_handler) NULL, /* SIOCSIWNWID */
9671 (iw_handler) NULL, /* SIOCGIWNWID */
9672 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9673 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9674 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9675 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9676 (iw_handler) NULL, /* SIOCSIWSENS */
9677 (iw_handler) NULL, /* SIOCGIWSENS */
9678 (iw_handler) NULL, /* SIOCSIWRANGE */
9679 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9680 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
9681 (iw_handler) NULL, /* SIOCGIWPRIV */
9682 (iw_handler) NULL, /* SIOCSIWSTATS */
9683 (iw_handler) NULL, /* SIOCGIWSTATS */
9684 iw_handler_set_spy, /* SIOCSIWSPY */
9685 iw_handler_get_spy, /* SIOCGIWSPY */
9686 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
9687 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
9688 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9689 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9690 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9691 (iw_handler) NULL, /* SIOCGIWAPLIST */
9692 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9693 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9694 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9695 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9696 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9697 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9698 (iw_handler) NULL, /* -- hole -- */
9699 (iw_handler) NULL, /* -- hole -- */
9700 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9701 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9702 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
9703 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
9704 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9705 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9706 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9707 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9708 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9709 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9710 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9711 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9712 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9713 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9714 (iw_handler) NULL, /* -- hole -- */
9715 (iw_handler) NULL, /* -- hole -- */
9716 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9717 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9718 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9719 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9720 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9721 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9722 (iw_handler) NULL, /* SIOCSIWPMKSA */
9723};
9724
9725static const iw_handler we_private[] = {
9726
9727 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
9728 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
9729 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
9730 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
9731 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9732 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +05309733 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07009734 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9735 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9736 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07009737#ifdef FEATURE_OEM_DATA_SUPPORT
9738 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
9739 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
9740#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009741
Jeff Johnson295189b2012-06-20 16:38:30 -07009742#ifdef WLAN_FEATURE_VOWIFI_11R
9743 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
9744#endif
9745 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9746 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9747 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
9748#ifdef WLAN_FEATURE_PACKET_FILTERING
9749 ,
9750 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
9751#endif
9752#ifdef FEATURE_WLAN_SCAN_PNO
9753 ,
9754 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
9755#endif
9756 ,
9757 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9758 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
9759 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
9760 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07009761 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07009762};
9763
9764/*Maximum command length can be only 15 */
9765static const struct iw_priv_args we_private_args[] = {
9766
9767 /* handlers for main ioctl */
9768 { WLAN_PRIV_SET_INT_GET_NONE,
9769 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9770 0,
9771 "" },
9772
9773 /* handlers for sub-ioctl */
9774 { WE_SET_11D_STATE,
9775 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9776 0,
9777 "set11Dstate" },
9778
9779 { WE_WOWL,
9780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9781 0,
9782 "wowl" },
9783
9784 { WE_SET_POWER,
9785 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9786 0,
9787 "setPower" },
9788
9789 { WE_SET_MAX_ASSOC,
9790 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9791 0,
9792 "setMaxAssoc" },
9793
9794 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
9795 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9796 0,
9797 "setAutoChannel" },
9798
9799 { WE_SET_DATA_INACTIVITY_TO,
9800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9801 0,
9802 "inactivityTO" },
9803
9804 { WE_SET_MAX_TX_POWER,
9805 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9806 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07009807 "setMaxTxPower" },
9808
9809 { WE_SET_MAX_TX_POWER_2_4,
9810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9811 0,
9812 "setTxMaxPower2G" },
9813
9814 { WE_SET_MAX_TX_POWER_5_0,
9815 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9816 0,
9817 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07009818
9819 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
9820 * as well to keep same syntax as in SAP. Now onwards, STA
9821 * will support both */
9822 { WE_SET_MAX_TX_POWER,
9823 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9824 0,
9825 "setTxMaxPower" },
9826
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 /* set Higher DTIM Transition (DTIM1 to DTIM3)
9828 * 1 = enable and 0 = disable */
9829 {
9830 WE_SET_HIGHER_DTIM_TRANSITION,
9831 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9832 0,
9833 "setHDtimTransn" },
9834
9835 { WE_SET_TM_LEVEL,
9836 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009837 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 "setTmLevel" },
9839
Kiet Lam46b8e4e2013-11-06 21:49:53 +05309840 { WE_ENABLE_STRICT_FCC_REG,
9841 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9842 0,
9843 "setStrictFCCreg" },
9844
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08009845 { WE_SET_DEBUG_LOG,
9846 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9847 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +05309848#ifdef FEATURE_WLAN_TDLS
9849 {
9850 WE_SET_TDLS_OFF_CHAN,
9851 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9852 0,
9853 "tdlsoffchan" },
9854 {
9855 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
9856 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9857 0,
9858 "tdlsecchnoffst" },
9859 {
9860 WE_SET_TDLS_OFF_CHAN_MODE,
9861 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9862 0,
9863 "tdlsoffchnmode" },
9864#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08009865
Peng Xu2446a892014-09-05 17:21:18 +05309866 { WE_SET_SCAN_BAND_PREFERENCE,
9867 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9868 0, "set_scan_pref" },
9869
Jeff Johnson295189b2012-06-20 16:38:30 -07009870 /* handlers for main ioctl */
9871 { WLAN_PRIV_SET_NONE_GET_INT,
9872 0,
9873 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9874 "" },
9875
9876 /* handlers for sub-ioctl */
9877 { WE_GET_11D_STATE,
9878 0,
9879 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9880 "get11Dstate" },
9881
9882 { WE_IBSS_STATUS,
9883 0,
9884 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9885 "getAdhocStatus" },
9886
9887 { WE_PMC_STATE,
9888 0,
9889 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9890 "pmcState" },
9891
9892 { WE_GET_WLAN_DBG,
9893 0,
9894 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9895 "getwlandbg" },
9896
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 { WE_GET_MAX_ASSOC,
9898 0,
9899 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9900 "getMaxAssoc" },
9901
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 { WE_GET_WDI_DBG,
9903 0,
9904 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9905 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009906
9907 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
9908 0,
9909 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9910 "getAutoChannel" },
9911
9912 { WE_GET_CONCURRENCY_MODE,
9913 0,
9914 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9915 "getconcurrency" },
9916
Peng Xu2446a892014-09-05 17:21:18 +05309917 { WE_GET_SCAN_BAND_PREFERENCE,
9918 0,
9919 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9920 "get_scan_pref"},
9921
Jeff Johnson295189b2012-06-20 16:38:30 -07009922 /* handlers for main ioctl */
9923 { WLAN_PRIV_SET_CHAR_GET_NONE,
9924 IW_PRIV_TYPE_CHAR| 512,
9925 0,
9926 "" },
9927
9928 /* handlers for sub-ioctl */
9929 { WE_WOWL_ADD_PTRN,
9930 IW_PRIV_TYPE_CHAR| 512,
9931 0,
9932 "wowlAddPtrn" },
9933
9934 { WE_WOWL_DEL_PTRN,
9935 IW_PRIV_TYPE_CHAR| 512,
9936 0,
9937 "wowlDelPtrn" },
9938
9939#if defined WLAN_FEATURE_VOWIFI
9940 /* handlers for sub-ioctl */
9941 { WE_NEIGHBOR_REPORT_REQUEST,
9942 IW_PRIV_TYPE_CHAR | 512,
9943 0,
9944 "neighbor" },
9945#endif
9946 { WE_SET_AP_WPS_IE,
9947 IW_PRIV_TYPE_CHAR| 512,
9948 0,
9949 "set_ap_wps_ie" },
9950
9951 { WE_SET_CONFIG,
9952 IW_PRIV_TYPE_CHAR| 512,
9953 0,
9954 "setConfig" },
9955
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05309956 { WE_SET_ENCRYPT_MSG,
9957 IW_PRIV_TYPE_CHAR| 512,
9958 0,
9959 "encryptMsg" },
9960
9961
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 /* handlers for main ioctl */
9963 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
9964 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9965 0,
9966 "" },
9967
9968 /* handlers for sub-ioctl */
9969 { WE_SET_WLAN_DBG,
9970 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9971 0,
9972 "setwlandbg" },
9973
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 { WE_SET_WDI_DBG,
9975 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9976 0,
9977 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07009978
9979 { WE_SET_SAP_CHANNELS,
9980 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9981 0,
9982 "setsapchannels" },
9983
9984 /* handlers for main ioctl */
9985 { WLAN_PRIV_GET_CHAR_SET_NONE,
9986 0,
9987 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9988 "" },
9989
9990 /* handlers for sub-ioctl */
9991 { WE_WLAN_VERSION,
9992 0,
9993 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9994 "version" },
9995 { WE_GET_STATS,
9996 0,
9997 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
9998 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309999 { WE_GET_STATES,
10000 0,
10001 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10002 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010003 { WE_GET_CFG,
10004 0,
10005 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10006 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010007#ifdef WLAN_FEATURE_11AC
10008 { WE_GET_RSSI,
10009 0,
10010 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10011 "getRSSI" },
10012#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010013#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010014 { WE_GET_ROAM_RSSI,
10015 0,
10016 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10017 "getRoamRSSI" },
10018#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010019 { WE_GET_WMM_STATUS,
10020 0,
10021 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10022 "getWmmStatus" },
10023 {
10024 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010025 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010026 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10027 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010028#ifdef FEATURE_WLAN_TDLS
10029 {
10030 WE_GET_TDLS_PEERS,
10031 0,
10032 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10033 "getTdlsPeers" },
10034#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010035#ifdef WLAN_FEATURE_11W
10036 {
10037 WE_GET_11W_INFO,
10038 0,
10039 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10040 "getPMFInfo" },
10041#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010042 { WE_GET_SNR,
10043 0,
10044 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10045 "getSNR" },
10046
Jeff Johnson295189b2012-06-20 16:38:30 -070010047 /* handlers for main ioctl */
10048 { WLAN_PRIV_SET_NONE_GET_NONE,
10049 0,
10050 0,
10051 "" },
10052
10053 /* handlers for sub-ioctl */
10054 { WE_CLEAR_STATS,
10055 0,
10056 0,
10057 "clearStats" },
10058 { WE_INIT_AP,
10059 0,
10060 0,
10061 "initAP" },
10062 { WE_STOP_AP,
10063 0,
10064 0,
10065 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010066#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010067 { WE_ENABLE_AMP,
10068 0,
10069 0,
10070 "enableAMP" },
10071 { WE_DISABLE_AMP,
10072 0,
10073 0,
10074 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010075#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010076 { WE_ENABLE_DXE_STALL_DETECT,
10077 0,
10078 0,
10079 "dxeStallDetect" },
10080 { WE_DISPLAY_DXE_SNAP_SHOT,
10081 0,
10082 0,
10083 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010084 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10085 0,
10086 0,
10087 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010088 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010089 WE_SET_REASSOC_TRIGGER,
10090 0,
10091 0,
10092 "reassoc" },
10093 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010094 WE_STOP_OBSS_SCAN,
10095 0,
10096 0,
10097 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010098 {
10099 WE_DUMP_ROAM_TIMER_LOG,
10100 0,
10101 0,
10102 "dumpRoamDelay" },
10103 {
10104 WE_RESET_ROAM_TIMER_LOG,
10105 0,
10106 0,
10107 "resetRoamDelay" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010108 /* handlers for main ioctl */
10109 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10110 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10111 0,
10112 "" },
10113
10114 /* handlers for sub-ioctl */
10115 { WE_LOG_DUMP_CMD,
10116 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10117 0,
10118 "dump" },
10119
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010120 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010121 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10122 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10123 0,
10124 "setdumplog" },
10125
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010126 { WE_MTRACE_DUMP_CMD,
10127 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10128 0,
10129 "dumplog" },
10130
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010131 /* handlers for sub ioctl */
10132 {
10133 WE_MCC_CONFIG_CREDENTIAL,
10134 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10135 0,
10136 "setMccCrdnl" },
10137
10138 /* handlers for sub ioctl */
10139 {
10140 WE_MCC_CONFIG_PARAMS,
10141 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10142 0,
10143 "setMccConfig" },
10144
Chilam NG571c65a2013-01-19 12:27:36 +053010145#ifdef FEATURE_WLAN_TDLS
10146 /* handlers for sub ioctl */
10147 {
10148 WE_TDLS_CONFIG_PARAMS,
10149 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10150 0,
10151 "setTdlsConfig" },
10152#endif
10153
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 /* handlers for main ioctl */
10155 { WLAN_PRIV_ADD_TSPEC,
10156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10157 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10158 "addTspec" },
10159
10160 /* handlers for main ioctl */
10161 { WLAN_PRIV_DEL_TSPEC,
10162 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10163 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10164 "delTspec" },
10165
10166 /* handlers for main ioctl */
10167 { WLAN_PRIV_GET_TSPEC,
10168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10169 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10170 "getTspec" },
10171
Jeff Johnsone7245742012-09-05 17:12:55 -070010172#ifdef FEATURE_OEM_DATA_SUPPORT
10173 /* handlers for main ioctl - OEM DATA */
10174 {
10175 WLAN_PRIV_SET_OEM_DATA_REQ,
10176 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10177 0,
10178 "set_oem_data_req" },
10179
10180 /* handlers for main ioctl - OEM DATA */
10181 {
10182 WLAN_PRIV_GET_OEM_DATA_RSP,
10183 0,
10184 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10185 "get_oem_data_rsp" },
10186#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010187
Jeff Johnson295189b2012-06-20 16:38:30 -070010188 /* handlers for main ioctl - host offload */
10189 {
10190 WLAN_PRIV_SET_HOST_OFFLOAD,
10191 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10192 0,
10193 "setHostOffload" },
10194
10195 {
10196 WLAN_GET_WLAN_STATISTICS,
10197 0,
10198 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10199 "getWlanStats" },
10200
10201 {
10202 WLAN_SET_KEEPALIVE_PARAMS,
10203 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10204 0,
10205 "setKeepAlive" },
10206#ifdef WLAN_FEATURE_PACKET_FILTERING
10207 {
10208 WLAN_SET_PACKET_FILTER_PARAMS,
10209 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10210 0,
10211 "setPktFilter" },
10212#endif
10213#ifdef FEATURE_WLAN_SCAN_PNO
10214 {
10215 WLAN_SET_PNO,
10216 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10217 0,
10218 "setpno" },
10219#endif
10220 {
10221 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010222 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 0,
10224 "SETBAND" },
10225 /* handlers for dynamic MC BC ioctl */
10226 {
10227 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010228 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010229 0,
10230 "setMCBCFilter" },
10231 {
10232 WLAN_PRIV_CLEAR_MCBC_FILTER,
10233 0,
10234 0,
10235 "clearMCBCFilter" },
10236 {
10237 WLAN_SET_POWER_PARAMS,
10238 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10239 0,
10240 "setpowerparams" },
10241 {
10242 WLAN_GET_LINK_SPEED,
10243 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010244 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010245};
10246
10247
10248
10249const struct iw_handler_def we_handler_def = {
10250 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10251 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10252 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10253
10254 .standard = (iw_handler *)we_handler,
10255 .private = (iw_handler *)we_private,
10256 .private_args = we_private_args,
10257 .get_wireless_stats = get_wireless_stats,
10258};
10259
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010260int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10261{
10262 v_U32_t cmd = 288; //Command to RIVA
10263 hdd_context_t *pHddCtx = NULL;
10264 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10265 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10266 /*
10267 *configMccParam : specify the bit which needs to be modified
10268 *allowed to update based on wlan_qcom_cfg.ini
10269 * configuration
10270 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10271 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10272 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10273 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10274 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10275 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10276 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10277 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10278 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10279 * Bit 9 : Reserved
10280 */
10281 switch (arg1)
10282 {
10283 //Update MCC SCHEDULE_TIME_SLICE parameter
10284 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10285 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10286 {
10287 if((arg2 >= 5) && (arg2 <= 20))
10288 {
10289 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10290 }
10291 else
10292 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010293 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010294 return 0;
10295 }
10296 }
10297 break;
10298
10299 //Update MCC MAX_NULL_SEND_TIME parameter
10300 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10301 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10302 {
10303 if((arg2 >= 1) && (arg2 <= 10))
10304 {
10305 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10306 }
10307 else
10308 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010309 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010310 return 0;
10311 }
10312 }
10313 break;
10314
10315 //Update MCC TX_EARLY_STOP_TIME parameter
10316 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10317 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10318 {
10319 if((arg2 >= 1) && (arg2 <= 10))
10320 {
10321 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10322 }
10323 else
10324 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010325 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010326 return 0;
10327 }
10328 }
10329 break;
10330
10331 //Update MCC RX_DRAIN_TIME parameter
10332 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10333 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10334 {
10335 if((arg2 >= 1) && (arg2 <= 10))
10336 {
10337 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10338 }
10339 else
10340 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010341 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010342 return 0;
10343 }
10344 }
10345 break;
10346
10347 //Update MCC CHANNEL_SWITCH_TIME parameter
10348 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10349 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10350 {
10351 if((arg2 >= 1) && (arg2 <= 20))
10352 {
10353 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10354 }
10355 else
10356 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010357 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010358 return 0;
10359 }
10360 }
10361 break;
10362
10363 //Update MCC MIN_CHANNEL_TIME parameter
10364 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10365 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10366 {
10367 if((arg2 >= 5) && (arg2 <= 20))
10368 {
10369 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10370 }
10371 else
10372 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010373 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010374 return 0;
10375 }
10376 }
10377 break;
10378
10379 //Update MCC PARK_BEFORE_TBTT parameter
10380 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10381 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10382 {
10383 if((arg2 >= 1) && (arg2 <= 5))
10384 {
10385 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10386 }
10387 else
10388 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010389 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010390 return 0;
10391 }
10392 }
10393 break;
10394
10395 //Update MCC MIN_AFTER_DTIM parameter
10396 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10397 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10398 {
10399 if((arg2 >= 5) && (arg2 <= 15))
10400 {
10401 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10402 }
10403 else
10404 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010405 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010406 return 0;
10407 }
10408 }
10409 break;
10410
10411 //Update MCC TOO_CLOSE_MARGIN parameter
10412 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10413 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10414 {
10415 if((arg2 >= 1) && (arg2 <= 3))
10416 {
10417 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10418 }
10419 else
10420 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010421 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010422 return 0;
10423 }
10424 }
10425 break;
10426
10427 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010428 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010429 __FUNCTION__,arg1);
10430 break;
10431 }
10432 return 0;
10433}
10434
Jeff Johnson295189b2012-06-20 16:38:30 -070010435int hdd_set_wext(hdd_adapter_t *pAdapter)
10436{
10437 hdd_wext_state_t *pwextBuf;
10438 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010439 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010440
10441 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10442
10443 // Now configure the roaming profile links. To SSID and bssid.
10444 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10445 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10446
10447 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10448 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10449
10450 /*Set the numOfChannels to zero to scan all the channels*/
10451 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10452 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10453
10454 /* Default is no encryption */
10455 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10456 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10457
10458 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10459 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10460
10461 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10462
10463 /* Default is no authentication */
10464 pwextBuf->roamProfile.AuthType.numEntries = 1;
10465 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10466
10467 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10468 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10469
10470 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010471 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010472
10473 hdd_clearRoamProfileIe(pAdapter);
10474
10475 return VOS_STATUS_SUCCESS;
10476
10477 }
10478
10479int hdd_register_wext(struct net_device *dev)
10480 {
10481 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10482 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10483 VOS_STATUS status;
10484
10485 ENTER();
10486
10487 // Zero the memory. This zeros the profile structure.
10488 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10489
10490 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10491
10492
10493 status = hdd_set_wext(pAdapter);
10494
10495 if(!VOS_IS_STATUS_SUCCESS(status)) {
10496
Arif Hussain6d2a3322013-11-17 19:50:10 -080010497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010498 return eHAL_STATUS_FAILURE;
10499 }
10500
10501 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10502 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010504 return eHAL_STATUS_FAILURE;
10505 }
10506
10507 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10508 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010510 return eHAL_STATUS_FAILURE;
10511 }
10512
10513 // Register as a wireless device
10514 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10515
10516 EXIT();
10517 return 0;
10518}
10519
10520int hdd_UnregisterWext(struct net_device *dev)
10521{
c_hpothu2a13bc32015-01-21 12:48:54 +053010522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10523 if (dev != NULL)
10524 {
10525 rtnl_lock();
10526 dev->wireless_handlers = NULL;
10527 rtnl_unlock();
10528 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010529
Jeff Johnson295189b2012-06-20 16:38:30 -070010530 return 0;
10531}
10532
10533