blob: b093bc56808c5851c37d98f50bf625f10e7267c5 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
c_hpothu002231a2015-02-05 14:58:51 +05302 * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053053#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include <wlan_hdd_includes.h>
55#include <wlan_btc_svc.h>
56#include <wlan_nlink_common.h>
57#ifdef WLAN_BTAMP_FEATURE
58#include <bap_hdd_main.h>
59#endif
60#include <vos_api.h>
61#include <net/arp.h>
62#include "ccmApi.h"
63#include "sirParams.h"
64#include "csrApi.h"
65#include "csrInsideApi.h"
66#if defined WLAN_FEATURE_VOWIFI
67#include "smeRrmInternal.h"
68#endif
69#include <aniGlobal.h>
70#include "dot11f.h"
71#include <wlan_hdd_wowl.h>
72#include <wlan_hdd_cfg.h>
73#include <wlan_hdd_wmm.h>
74#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070075#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053076#ifdef FEATURE_WLAN_TDLS
77#include "wlan_hdd_tdls.h"
78#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070079
80#ifdef CONFIG_HAS_EARLYSUSPEND
81#include <linux/earlysuspend.h>
82#endif
83#include "wlan_hdd_power.h"
84#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070085#include "wlan_hdd_host_offload.h"
86#include "wlan_hdd_keep_alive.h"
87#ifdef WLAN_FEATURE_PACKET_FILTERING
88#include "wlan_hdd_packet_filtering.h"
89#endif
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091#include <linux/wireless.h>
92#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053094#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96#include "wlan_hdd_misc.h"
97#include "bap_hdd_misc.h"
98
99#include "wlan_hdd_dev_pwr.h"
100#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530101#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700102#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530103#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
Mukul Sharma84f27252014-07-14 18:11:42 +0530105#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530106#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#ifdef CONFIG_HAS_EARLYSUSPEND
109extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
110extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
111#endif
112
Jeff Johnsone7245742012-09-05 17:12:55 -0700113#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800114#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700115#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700116
117#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530118#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700119
Jeff Johnson295189b2012-06-20 16:38:30 -0700120
Atul Mittalc0f739f2014-07-31 13:47:47 +0530121// tdlsoffchan
122#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530123static int tdlsOffCh = 1;
124static int tdlsOffChBwOffset = 0;
125#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530126
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700127static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
129
Jeff Johnson295189b2012-06-20 16:38:30 -0700130/* To Validate Channel against the Frequency and Vice-Versa */
131static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
132 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
133 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
134 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
135 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
136 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
137 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
138 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800139 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
140 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700141
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800142#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700143
144/* Private ioctls and their sub-ioctls */
145#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
146#define WE_SET_11D_STATE 1
147#define WE_WOWL 2
148#define WE_SET_POWER 3
149#define WE_SET_MAX_ASSOC 4
150#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
151#define WE_SET_DATA_INACTIVITY_TO 6
152#define WE_SET_MAX_TX_POWER 7
153#define WE_SET_HIGHER_DTIM_TRANSITION 8
154#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530155#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700156#define WE_SET_MAX_TX_POWER_2_4 11
157#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800158/* Private IOCTL for debug connection issues */
159#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530160// tdlsoffchan
161#ifdef FEATURE_WLAN_TDLS
162#define WE_SET_TDLS_OFF_CHAN 14
163#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
164#define WE_SET_TDLS_OFF_CHAN_MODE 16
165#endif
Peng Xu2446a892014-09-05 17:21:18 +0530166#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530167#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530168#define WE_GET_FRAME_LOG 19
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +0530169#ifdef FEATURE_WLAN_TDLS
170#define WE_SET_TDLS_2040_BSS_COEXISTENCE 20
171#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700172
173/* Private ioctls and their sub-ioctls */
174#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
175#define WE_GET_11D_STATE 1
176#define WE_IBSS_STATUS 2
177#define WE_PMC_STATE 3
178#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WE_GET_MAX_ASSOC 6
180#define WE_GET_WDI_DBG 7
181#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
182#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530183#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700184/* Private ioctls and their sub-ioctls */
185#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
186
187/* Private ioctls and their sub-ioctls */
188#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
189#define WE_WOWL_ADD_PTRN 1
190#define WE_WOWL_DEL_PTRN 2
191#if defined WLAN_FEATURE_VOWIFI
192#define WE_NEIGHBOR_REPORT_REQUEST 3
193#endif
194#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
195#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530196#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700197
198/* Private ioctls and their sub-ioctls */
199#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
200#define WE_SET_WLAN_DBG 1
201#define WE_SET_WDI_DBG 2
202#define WE_SET_SAP_CHANNELS 3
203
204/* Private ioctls and their sub-ioctls */
205#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
206#define WE_WLAN_VERSION 1
207#define WE_GET_STATS 2
208#define WE_GET_CFG 3
209#define WE_GET_WMM_STATUS 4
210#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700211#ifdef WLAN_FEATURE_11AC
212#define WE_GET_RSSI 6
213#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800214#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800215#ifdef FEATURE_WLAN_TDLS
216#define WE_GET_TDLS_PEERS 8
217#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700218#ifdef WLAN_FEATURE_11W
219#define WE_GET_11W_INFO 9
220#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530221#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530222#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224/* Private ioctls and their sub-ioctls */
225#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
226#define WE_CLEAR_STATS 1
227#define WE_INIT_AP 2
228#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530229#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700230#define WE_ENABLE_AMP 4
231#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530232#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700233#define WE_ENABLE_DXE_STALL_DETECT 6
234#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700235#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530236#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530237#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530238#define WE_DUMP_ROAM_TIMER_LOG 12
239#define WE_RESET_ROAM_TIMER_LOG 13
Mukul Sharma84f27252014-07-14 18:11:42 +0530240
Jeff Johnson295189b2012-06-20 16:38:30 -0700241/* Private ioctls and their sub-ioctls */
242#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
243#define WE_LOG_DUMP_CMD 1
244
Jeff Johnson295189b2012-06-20 16:38:30 -0700245#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800246//IOCTL to configure MCC params
247#define WE_MCC_CONFIG_CREDENTIAL 3
248#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700249
Chilam NG571c65a2013-01-19 12:27:36 +0530250#ifdef FEATURE_WLAN_TDLS
251#define WE_TDLS_CONFIG_PARAMS 5
252#endif
253
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700254#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530255#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700256
Chilam Ng01120412013-02-19 18:32:21 -0800257#ifdef FEATURE_WLAN_TDLS
258#undef MAX_VAR_ARGS
259#define MAX_VAR_ARGS 10
260#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700261#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800262#endif
263
Jeff Johnson295189b2012-06-20 16:38:30 -0700264/* Private ioctls (with no sub-ioctls) */
265/* note that they must be odd so that they have "get" semantics */
266#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
267#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
268#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
269
Girish Gowli464c9c82014-06-09 19:47:53 +0530270/* (SIOCIWFIRSTPRIV + 8) is currently unused */
271/* (SIOCIWFIRSTPRIV + 16) is currently unused */
272/* (SIOCIWFIRSTPRIV + 10) is currently unused */
273/* (SIOCIWFIRSTPRIV + 12) is currently unused */
274/* (SIOCIWFIRSTPRIV + 14) is currently unused */
275/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700276
Jeff Johnsone7245742012-09-05 17:12:55 -0700277#ifdef FEATURE_OEM_DATA_SUPPORT
278/* Private ioctls for setting the measurement configuration */
279#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
280#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700282
283#ifdef WLAN_FEATURE_VOWIFI_11R
284#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
285#endif
286
287/* Private ioctl for setting the host offload feature */
288#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
289
290/* Private ioctl to get the statistics */
291#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
292
293/* Private ioctl to set the Keep Alive Params */
294#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
295#ifdef WLAN_FEATURE_PACKET_FILTERING
296/* Private ioctl to set the Packet Filtering Params */
297#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
298#endif
299
300#ifdef FEATURE_WLAN_SCAN_PNO
301/* Private ioctl to get the statistics */
302#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
303#endif
304
305#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
306
307#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
308#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700309/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
312#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
313
314#define WLAN_STATS_INVALID 0
315#define WLAN_STATS_RETRY_CNT 1
316#define WLAN_STATS_MUL_RETRY_CNT 2
317#define WLAN_STATS_TX_FRM_CNT 3
318#define WLAN_STATS_RX_FRM_CNT 4
319#define WLAN_STATS_FRM_DUP_CNT 5
320#define WLAN_STATS_FAIL_CNT 6
321#define WLAN_STATS_RTS_FAIL_CNT 7
322#define WLAN_STATS_ACK_FAIL_CNT 8
323#define WLAN_STATS_RTS_SUC_CNT 9
324#define WLAN_STATS_RX_DISCARD_CNT 10
325#define WLAN_STATS_RX_ERROR_CNT 11
326#define WLAN_STATS_TX_BYTE_CNT 12
327
328#define WLAN_STATS_RX_BYTE_CNT 13
329#define WLAN_STATS_RX_RATE 14
330#define WLAN_STATS_TX_RATE 15
331
Jeff Johnsone7245742012-09-05 17:12:55 -0700332#define WLAN_STATS_RX_UC_BYTE_CNT 16
333#define WLAN_STATS_RX_MC_BYTE_CNT 17
334#define WLAN_STATS_RX_BC_BYTE_CNT 18
335#define WLAN_STATS_TX_UC_BYTE_CNT 19
336#define WLAN_STATS_TX_MC_BYTE_CNT 20
337#define WLAN_STATS_TX_BC_BYTE_CNT 21
338
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800339#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
340 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
341 { \
342 *__p++ = __type; \
343 *__p++ = __size; \
344 memcpy(__p, __val, __size); \
345 __p += __size; \
346 __tlen += __size + 2; \
347 } \
348 else \
349 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800350 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800351 } \
352 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700353
354#define VERSION_VALUE_MAX_LEN 32
355
356#define TX_PER_TRACKING_DEFAULT_RATIO 5
357#define TX_PER_TRACKING_MAX_RATIO 10
358#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
359
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530360#define WLAN_ADAPTER 0
361#define P2P_ADAPTER 1
362
Abhishek Singh2ec36ab2014-08-07 16:14:25 +0530363/*
364 * When supplicant sends SETBAND ioctl it queries for channels from
365 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
366 * This is not required if the return type from ioctl is
367 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
368 * event as part of regulatory_hint.
369 */
370enum {
371 SEND_CHANNEL_CHANGE_EVENT = 0,
372 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
373};
374
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800375/*MCC Configuration parameters */
376enum {
377 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
378 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
379 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
380 MCC_RX_DRAIN_TIME_CFG_PARAM,
381 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
382 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
383 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
384 MCC_MIN_AFTER_DTIM_CFG_PARAM,
385 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
386};
387
388int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
389 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
390
Jeff Johnson295189b2012-06-20 16:38:30 -0700391#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800392int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700393 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700394#endif
395
Jeff Johnson295189b2012-06-20 16:38:30 -0700396/**---------------------------------------------------------------------------
397
Arif Hussain0273cba2014-01-07 20:58:29 -0800398 \brief mem_alloc_copy_from_user_helper -
399
400 Helper function to allocate buffer and copy user data.
401
402 \param - wrqu - Pointer to IOCTL Data.
403 len - size
404
405 \return - On Success pointer to buffer, On failure NULL
406
407 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530408void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800409{
410 u8 *ptr = NULL;
411
412 /* in order to protect the code, an extra byte is post appended to the buffer
413 * and the null termination is added. However, when allocating (len+1) byte
414 * of memory, we need to make sure that there is no uint overflow when doing
415 * addition. In theory check len < UINT_MAX protects the uint overflow. For
416 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
417 * guess, now, it is assumed that the private command buffer size is no
418 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
419 */
420 if (len > MAX_USER_COMMAND_SIZE)
421 {
422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
423 "Invalid length");
424 return NULL;
425 }
426
427 ptr = kmalloc(len + 1, GFP_KERNEL);
428 if (NULL == ptr)
429 {
430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
431 "unable to allocate memory");
432 return NULL;
433 }
434
435 if (copy_from_user(ptr, wrqu_data, len))
436 {
437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
438 "%s: failed to copy data to user buffer", __func__);
439 kfree(ptr);
440 return NULL;
441 }
442 ptr[len] = '\0';
443 return ptr;
444}
445
Girish Gowli488ef492014-06-12 18:44:33 +0530446// Function to handle and get compatible struct iw_point passed to ioctl.
447int hdd_priv_get_data(struct iw_point *p_priv_data,
448 union iwreq_data *wrqu)
449{
450 if ((NULL == p_priv_data) || (NULL == wrqu))
451 {
452 return -EINVAL;
453 }
454
455#ifdef CONFIG_COMPAT
456 if (is_compat_task())
457 {
458 struct compat_iw_point *p_compat_priv_data;
459
460 // Compat task: typecast to campat structure and copy the members.
461 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
462
463 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
464 p_priv_data->length = p_compat_priv_data->length;
465 p_priv_data->flags = p_compat_priv_data->flags;
466 }//if(is_compat_task())
467 else
468 {
469#endif //#ifdef CONFIG_COMPAT
470
471 // Non compat task: directly copy the structure.
472 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
473
474#ifdef CONFIG_COMPAT
475 }//else of - if(is_compat_task())
476#endif //#ifdef CONFIG_COMPAT
477
478 return 0;
479}
480
Arif Hussain0273cba2014-01-07 20:58:29 -0800481/**---------------------------------------------------------------------------
482
Jeff Johnson295189b2012-06-20 16:38:30 -0700483 \brief hdd_wlan_get_version() -
484
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800485 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700486
487 \param - pAdapter Pointer to the adapter.
488 wrqu - Pointer to IOCTL REQUEST Data.
489 extra - Pointer to char
490
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800491 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700492
493 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800494void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
495 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700496{
497 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800498 tSirVersionString wcnss_SW_version;
499 tSirVersionString wcnss_HW_version;
500 char *pSWversion;
501 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700503
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800504 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
505 sizeof(wcnss_SW_version));
506 if (VOS_IS_STATUS_SUCCESS(status))
507 {
508 pSWversion = wcnss_SW_version;
509 }
510 else
511 {
512 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 }
514
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800515 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
516 sizeof(wcnss_HW_version));
517 if (VOS_IS_STATUS_SUCCESS(status))
518 {
519 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700520 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800521 else
522 {
523 pHWversion = "Unknown";
524 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700525
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700526 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800527 "Host SW:%s, FW:%s, HW:%s",
528 QWLAN_VERSIONSTR,
529 pSWversion,
530 pHWversion);
531
532 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700533}
534
Jeff Johnson295189b2012-06-20 16:38:30 -0700535int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
536{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530537 tHalHandle hHal;
538 hdd_context_t *pHddCtx;
539 v_U32_t threshold = 0;
540 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700541
542 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530543 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530544 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
546 "%s: Adapter is NULL",__func__);
547 return -EINVAL;
548 }
549
550 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
551 ret = wlan_hdd_validate_context(pHddCtx);
552 if (0 != ret)
553 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530554 return ret;
555 }
556
557 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
558 if (NULL == hHal)
559 {
560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
561 "%s: Hal Context is NULL",__func__);
562 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 }
564
565 if ( eHAL_STATUS_SUCCESS !=
566 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
567 {
c_hpothub8245442013-11-20 23:41:09 +0530568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
569 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 return -EIO;
571 }
572 wrqu->rts.value = threshold;
573
574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800575 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700576
577 EXIT();
578
579 return 0;
580}
581
582int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
583{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530584 tHalHandle hHal;
585 hdd_context_t *pHddCtx;
586 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700587
588 ENTER();
589
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530590 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530591 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
593 "%s: Adapter is NULL",__func__);
594 return -EINVAL;
595 }
596
597 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
598 status = wlan_hdd_validate_context(pHddCtx);
599 if (0 != status)
600 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530601 return status;
602 }
603
604 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
605 if (NULL == hHal)
606 {
607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
608 "%s: Hal Context is NULL",__func__);
609 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 }
611
612 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
613 != eHAL_STATUS_SUCCESS )
614 {
c_hpothub8245442013-11-20 23:41:09 +0530615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
616 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 return -EIO;
618 }
619 wrqu->frag.value = threshold;
620
621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800622 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700623
624 EXIT();
625
626 return 0;
627}
628
629int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
630{
Jeff Johnsone7245742012-09-05 17:12:55 -0700631 int i;
632 if (channel > 0)
633 {
634 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
635 {
636 if (channel == freq_chan_map[i].chan)
637 {
638 *pfreq = freq_chan_map[i].freq;
639 return 1;
640 }
641 }
642 }
643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800644 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700645 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700646}
647
648static v_BOOL_t
649hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
650{
651 v_BOOL_t rsnType = VOS_FALSE;
652 // is the authType supported?
653 switch (authType)
654 {
655 case eCSR_AUTH_TYPE_NONE: //never used
656 rsnType = eANI_BOOLEAN_FALSE;
657 break;
658 // MAC layer authentication types
659 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
660 rsnType = eANI_BOOLEAN_FALSE;
661 break;
662 case eCSR_AUTH_TYPE_SHARED_KEY:
663 rsnType = eANI_BOOLEAN_FALSE;
664 break;
665 case eCSR_AUTH_TYPE_AUTOSWITCH:
666 rsnType = eANI_BOOLEAN_FALSE;
667 break;
668
669 // Upper layer authentication types
670 case eCSR_AUTH_TYPE_WPA:
671 rsnType = eANI_BOOLEAN_TRUE;
672 break;
673 case eCSR_AUTH_TYPE_WPA_PSK:
674 rsnType = eANI_BOOLEAN_TRUE;
675 break;
676 case eCSR_AUTH_TYPE_WPA_NONE:
677 rsnType = eANI_BOOLEAN_TRUE;
678 break;
679#ifdef WLAN_FEATURE_VOWIFI_11R
680 case eCSR_AUTH_TYPE_FT_RSN:
681#endif
682 case eCSR_AUTH_TYPE_RSN:
683 rsnType = eANI_BOOLEAN_TRUE;
684 break;
685#ifdef WLAN_FEATURE_VOWIFI_11R
686 case eCSR_AUTH_TYPE_FT_RSN_PSK:
687#endif
688 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700689#ifdef WLAN_FEATURE_11W
690 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530691 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700692#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 rsnType = eANI_BOOLEAN_TRUE;
694 break;
695 //case eCSR_AUTH_TYPE_FAILED:
696 case eCSR_AUTH_TYPE_UNKNOWN:
697 rsnType = eANI_BOOLEAN_FALSE;
698 break;
699 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800700 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
701 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 rsnType = eANI_BOOLEAN_FALSE;
703 break;
704 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800705 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700706 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 return rsnType;
708}
709
710static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
711{
712 struct statsContext *pStatsContext;
713 hdd_adapter_t *pAdapter;
714
715 if (ioctl_debug)
716 {
717 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700718 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 }
720
721 if (NULL == pContext)
722 {
723 hddLog(VOS_TRACE_LEVEL_ERROR,
724 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700725 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 return;
727 }
728
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 pStatsContext = pContext;
730 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800731
732 /* there is a race condition that exists between this callback
733 function and the caller since the caller could time out either
734 before or while this code is executing. we use a spinlock to
735 serialize these actions */
736 spin_lock(&hdd_context_lock);
737
Jeff Johnson295189b2012-06-20 16:38:30 -0700738 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
739 {
740 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800741 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 hddLog(VOS_TRACE_LEVEL_WARN,
743 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700744 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 if (ioctl_debug)
746 {
747 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700748 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 }
750 return;
751 }
752
Jeff Johnson72a40512013-12-19 10:14:15 -0800753 /* context is valid so caller is still waiting */
754
755 /* paranoia: invalidate the magic */
756 pStatsContext->magic = 0;
757
758 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 pAdapter->rssi = rssi;
760
Jeff Johnson72a40512013-12-19 10:14:15 -0800761 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800763
764 /* serialization is complete */
765 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700766}
767
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530768static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
769{
770 struct statsContext *pStatsContext;
771 hdd_adapter_t *pAdapter;
772
773 if (ioctl_debug)
774 {
775 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
776 __func__, (int)snr, (int)staId, pContext);
777 }
778
779 if (NULL == pContext)
780 {
781 hddLog(VOS_TRACE_LEVEL_ERROR,
782 "%s: Bad param, pContext [%p]",
783 __func__, pContext);
784 return;
785 }
786
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530787 pStatsContext = pContext;
788 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800789
790 /* there is a race condition that exists between this callback
791 function and the caller since the caller could time out either
792 before or while this code is executing. we use a spinlock to
793 serialize these actions */
794 spin_lock(&hdd_context_lock);
795
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530796 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
797 {
798 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800799 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530800 hddLog(VOS_TRACE_LEVEL_WARN,
801 "%s: Invalid context, pAdapter [%p] magic [%08x]",
802 __func__, pAdapter, pStatsContext->magic);
803 if (ioctl_debug)
804 {
805 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
806 __func__, pAdapter, pStatsContext->magic);
807 }
808 return;
809 }
810
Jeff Johnson72a40512013-12-19 10:14:15 -0800811 /* context is valid so caller is still waiting */
812
813 /* paranoia: invalidate the magic */
814 pStatsContext->magic = 0;
815
816 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530817 pAdapter->snr = snr;
818
Jeff Johnson72a40512013-12-19 10:14:15 -0800819 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530820 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800821
822 /* serialization is complete */
823 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530824}
825
Jeff Johnson295189b2012-06-20 16:38:30 -0700826VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
827{
828 struct statsContext context;
829 hdd_context_t *pHddCtx;
830 hdd_station_ctx_t *pHddStaCtx;
831 eHalStatus hstatus;
832 long lrc;
833
834 if (NULL == pAdapter)
835 {
836 hddLog(VOS_TRACE_LEVEL_WARN,
837 "%s: Invalid context, pAdapter", __func__);
838 return VOS_STATUS_E_FAULT;
839 }
840 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
841 {
842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
843 /* return a cached value */
844 *rssi_value = pAdapter->rssi;
845 return VOS_STATUS_SUCCESS;
846 }
847
848 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
849 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
850
851 init_completion(&context.completion);
852 context.pAdapter = pAdapter;
853 context.magic = RSSI_CONTEXT_MAGIC;
854
855 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
856 pHddStaCtx->conn_info.staId[ 0 ],
857 pHddStaCtx->conn_info.bssId,
858 &context, pHddCtx->pvosContext);
859 if (eHAL_STATUS_SUCCESS != hstatus)
860 {
861 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700862 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 /* we'll returned a cached value below */
864 }
865 else
866 {
867 /* request was sent -- wait for the response */
868 lrc = wait_for_completion_interruptible_timeout(&context.completion,
869 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700870 if (lrc <= 0)
871 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800872 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700873 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 /* we'll now returned a cached value below */
875 }
876 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800877
878 /* either we never sent a request, we sent a request and received a
879 response or we sent a request and timed out. if we never sent a
880 request or if we sent a request and got a response, we want to
881 clear the magic out of paranoia. if we timed out there is a
882 race condition such that the callback function could be
883 executing at the same time we are. of primary concern is if the
884 callback function had already verified the "magic" but had not
885 yet set the completion variable when a timeout occurred. we
886 serialize these activities by invalidating the magic while
887 holding a shared spinlock which will cause us to block if the
888 callback is currently executing */
889 spin_lock(&hdd_context_lock);
890 context.magic = 0;
891 spin_unlock(&hdd_context_lock);
892
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 *rssi_value = pAdapter->rssi;
894
895 return VOS_STATUS_SUCCESS;
896}
897
Siddharth Bhal64246172015-02-27 01:04:37 +0530898static void hdd_GetFrameLogCB( void *pContext )
899{
900 struct getFrameLogCtx *pGetFrameLogCtx;
901 hdd_adapter_t *pAdapter;
902
903 if (NULL == pContext)
904 {
905 hddLog(VOS_TRACE_LEVEL_ERROR,
906 "%s: Bad param, pContext [%p]", __func__, pContext);
907 return;
908 }
909
910 pGetFrameLogCtx = pContext;
911 pAdapter = pGetFrameLogCtx->pAdapter;
912
913 /* there is a race condition that exists between this callback
914 function and the caller since the caller could time out either
915 before or while this code is executing. we use a spinlock to
916 serialize these actions */
917 spin_lock(&hdd_context_lock);
918
919 if (GET_FRAME_LOG_MAGIC != pGetFrameLogCtx->magic)
920 {
921 /* the caller presumably timed out so there is nothing we can do */
922 spin_unlock(&hdd_context_lock);
Siddharth Bhalda0d1622015-04-24 15:47:49 +0530923 hddLog(VOS_TRACE_LEVEL_WARN,
Siddharth Bhal64246172015-02-27 01:04:37 +0530924 "%s: Invalid context, pAdapter [%p] magic [%08x]",
925 __func__, pAdapter, pGetFrameLogCtx->magic);
926 return;
927 }
928
929 /* context is valid so caller is still waiting */
930
931 /* paranoia: invalidate the magic */
932 pGetFrameLogCtx->magic = 0;
933
934 /* notify the caller */
935 complete(&pGetFrameLogCtx->completion);
936
937 /* serialization is complete */
938 spin_unlock(&hdd_context_lock);
939}
940
941/**---------------------------------------------------------------------------
942
943 \brief wlan_hdd_get_frame_logs() -
944
945 This function use to get Frames log.
946
947 \param - pAdapter Pointer to the adapter.
948 flag - Specify type of request. Clear and Send request are
949 supported.
950
951 \return - none
952
953 --------------------------------------------------------------------------*/
954VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
955{
956 struct getFrameLogCtx context;
957 hdd_context_t *pHddCtx;
958 eHalStatus hstatus;
959 long lrc;
960
961 if (NULL == pAdapter)
962 {
963 hddLog(VOS_TRACE_LEVEL_WARN,
964 "%s: Invalid context, pAdapter", __func__);
965 return VOS_STATUS_E_FAULT;
966 }
967
968 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
969 if (!pHddCtx->mgmt_frame_logging)
970 {
971 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
972 return VOS_STATUS_E_AGAIN;
973 }
974
Siddharth Bhal4507c262015-04-29 20:20:42 +0530975 if ((flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR) &&
976 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR) &&
977 (flag != WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING))
Siddharth Bhal64246172015-02-27 01:04:37 +0530978 {
979 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
980 return VOS_STATUS_E_INVAL;
981 }
982
Siddharth Bhal4507c262015-04-29 20:20:42 +0530983 if ((flag == WLAN_HDD_GET_FRAME_LOG_CMD_BMU_TRACING) &&
984 (!pHddCtx->cfg_ini->enableBMUHWtracing))
985 {
986 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: BMUHW Tracing not enabled!", __func__);
987 return VOS_STATUS_E_INVAL;
988 }
989
Siddharth Bhal64246172015-02-27 01:04:37 +0530990 init_completion(&context.completion);
991 context.pAdapter = pAdapter;
992 context.magic = GET_FRAME_LOG_MAGIC;
993
994 hstatus = sme_GetFramesLog(pHddCtx->hHal, hdd_GetFrameLogCB,
995 flag, &context);
996 if (eHAL_STATUS_SUCCESS != hstatus)
997 {
998 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
999 }
1000 else
1001 {
1002 /* request was sent -- wait for the response */
1003 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1004 msecs_to_jiffies(WLAN_WAIT_TIME_FRAME_LOG));
1005 if (lrc <= 0)
1006 {
1007 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while fetching Frame logs",
1008 __func__, (0 == lrc) ? "timeout" : "interrupt");
1009 }
1010 }
1011
1012 spin_lock(&hdd_context_lock);
1013 context.magic = 0;
1014 spin_unlock(&hdd_context_lock);
1015
1016 return VOS_STATUS_SUCCESS;
1017}
1018
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301019VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1020{
1021 struct statsContext context;
1022 hdd_context_t *pHddCtx;
1023 hdd_station_ctx_t *pHddStaCtx;
1024 eHalStatus hstatus;
1025 long lrc;
1026 int valid;
1027
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301028 ENTER();
1029
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301030 if (NULL == pAdapter)
1031 {
1032 hddLog(VOS_TRACE_LEVEL_ERROR,
1033 "%s: Invalid context, pAdapter", __func__);
1034 return VOS_STATUS_E_FAULT;
1035 }
1036
1037 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1038
1039 valid = wlan_hdd_validate_context(pHddCtx);
1040 if (0 != valid)
1041 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301042 return VOS_STATUS_E_FAULT;
1043 }
1044
1045 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1046 if (NULL == pHddStaCtx)
1047 {
1048 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1049 return VOS_STATUS_E_FAULT;
1050 }
1051
1052 init_completion(&context.completion);
1053 context.pAdapter = pAdapter;
1054 context.magic = SNR_CONTEXT_MAGIC;
1055
1056 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1057 pHddStaCtx->conn_info.staId[ 0 ],
1058 pHddStaCtx->conn_info.bssId,
1059 &context);
1060 if (eHAL_STATUS_SUCCESS != hstatus)
1061 {
1062 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1063 __func__);
1064 /* we'll returned a cached value below */
1065 }
1066 else
1067 {
1068 /* request was sent -- wait for the response */
1069 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1070 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301071 if (lrc <= 0)
1072 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001073 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301074 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301075 /* we'll now returned a cached value below */
1076 }
1077 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001078
1079 /* either we never sent a request, we sent a request and received a
1080 response or we sent a request and timed out. if we never sent a
1081 request or if we sent a request and got a response, we want to
1082 clear the magic out of paranoia. if we timed out there is a
1083 race condition such that the callback function could be
1084 executing at the same time we are. of primary concern is if the
1085 callback function had already verified the "magic" but had not
1086 yet set the completion variable when a timeout occurred. we
1087 serialize these activities by invalidating the magic while
1088 holding a shared spinlock which will cause us to block if the
1089 callback is currently executing */
1090 spin_lock(&hdd_context_lock);
1091 context.magic = 0;
1092 spin_unlock(&hdd_context_lock);
1093
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301094 *snr = pAdapter->snr;
1095
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301096 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301097 return VOS_STATUS_SUCCESS;
1098}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001099#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001100
1101static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1102{
1103 struct statsContext *pStatsContext;
1104 hdd_adapter_t *pAdapter;
1105 if (ioctl_debug)
1106 {
1107 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1108 __func__, (int)rssi, (int)staId, pContext);
1109 }
1110
1111 if (NULL == pContext)
1112 {
1113 hddLog(VOS_TRACE_LEVEL_ERROR,
1114 "%s: Bad param, pContext [%p]",
1115 __func__, pContext);
1116 return;
1117 }
1118
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001119 pStatsContext = pContext;
1120 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001121
1122 /* there is a race condition that exists between this callback
1123 function and the caller since the caller could time out either
1124 before or while this code is executing. we use a spinlock to
1125 serialize these actions */
1126 spin_lock(&hdd_context_lock);
1127
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001128 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1129 {
1130 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001131 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001132 hddLog(VOS_TRACE_LEVEL_WARN,
1133 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1134 __func__, pAdapter, pStatsContext->magic);
1135 if (ioctl_debug)
1136 {
1137 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1138 __func__, pAdapter, pStatsContext->magic);
1139 }
1140 return;
1141 }
1142
Jeff Johnson72a40512013-12-19 10:14:15 -08001143 /* context is valid so caller is still waiting */
1144
1145 /* paranoia: invalidate the magic */
1146 pStatsContext->magic = 0;
1147
1148 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001149 pAdapter->rssi = rssi;
1150
Jeff Johnson72a40512013-12-19 10:14:15 -08001151 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001152 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001153
1154 /* serialization is complete */
1155 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001156}
1157
1158
1159
1160VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1161{
1162 struct statsContext context;
1163 hdd_context_t *pHddCtx = NULL;
1164 hdd_station_ctx_t *pHddStaCtx = NULL;
1165 eHalStatus hstatus;
1166 long lrc;
1167
1168 if (NULL == pAdapter)
1169 {
1170 hddLog(VOS_TRACE_LEVEL_WARN,
1171 "%s: Invalid context, pAdapter", __func__);
1172 return VOS_STATUS_E_FAULT;
1173 }
1174 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1175 {
1176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1177 /* return a cached value */
1178 *rssi_value = pAdapter->rssi;
1179 return VOS_STATUS_SUCCESS;
1180 }
1181
1182 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1183 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1184
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301185 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001186 {
1187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1188 /* return a cached value */
1189 *rssi_value = 0;
1190 return VOS_STATUS_SUCCESS;
1191 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301192
1193 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1194 {
1195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1196 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1197 *rssi_value = pAdapter->rssi;
1198 return VOS_STATUS_SUCCESS;
1199 }
1200
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001201 init_completion(&context.completion);
1202 context.pAdapter = pAdapter;
1203 context.magic = RSSI_CONTEXT_MAGIC;
1204
1205 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1206 pHddStaCtx->conn_info.staId[ 0 ],
1207 pHddStaCtx->conn_info.bssId,
1208 &context, pHddCtx->pvosContext);
1209 if (eHAL_STATUS_SUCCESS != hstatus)
1210 {
1211 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1212 __func__);
1213 /* we'll returned a cached value below */
1214 }
1215 else
1216 {
1217 /* request was sent -- wait for the response */
1218 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1219 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001220 if (lrc <= 0)
1221 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001222 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001223 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001224 /* we'll now returned a cached value below */
1225 }
1226 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001227
1228 /* either we never sent a request, we sent a request and received a
1229 response or we sent a request and timed out. if we never sent a
1230 request or if we sent a request and got a response, we want to
1231 clear the magic out of paranoia. if we timed out there is a
1232 race condition such that the callback function could be
1233 executing at the same time we are. of primary concern is if the
1234 callback function had already verified the "magic" but had not
1235 yet set the completion variable when a timeout occurred. we
1236 serialize these activities by invalidating the magic while
1237 holding a shared spinlock which will cause us to block if the
1238 callback is currently executing */
1239 spin_lock(&hdd_context_lock);
1240 context.magic = 0;
1241 spin_unlock(&hdd_context_lock);
1242
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001243 *rssi_value = pAdapter->rssi;
1244
1245 return VOS_STATUS_SUCCESS;
1246}
1247#endif
1248
1249
Jeff Johnson295189b2012-06-20 16:38:30 -07001250void hdd_StatisticsCB( void *pStats, void *pContext )
1251{
1252 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1253 hdd_stats_t *pStatsCache = NULL;
1254 hdd_wext_state_t *pWextState;
1255 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1256
1257 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1258 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1259 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1260 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1261 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1262 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1263
1264 if (pAdapter!= NULL)
1265 pStatsCache = &pAdapter->hdd_stats;
1266
1267
1268 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1269 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1270 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1271 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1272 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1273 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1274
1275 if (pStatsCache!=NULL)
1276 {
1277 // and copy the stats into the cache we keep in the adapter instance structure
1278 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1279 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1280 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1281 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1282 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1283 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1284 }
1285
1286 if(pAdapter)
1287 {
1288 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1289 if(pWextState)
1290 {
1291 vos_status = vos_event_set(&pWextState->vosevent);
1292 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1293 {
1294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001295 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 return;
1297 }
1298 }
1299 }
1300}
1301
1302void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1303{
1304 v_CONTEXT_t pVosContext;
1305 hdd_context_t *pHddCtx;
1306 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1307#if 0
1308 hdd_wext_state_t *pWextState;
1309 v_U32_t roamId;
1310#endif
1311
1312 ENTER();
1313
1314 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1315
1316 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1317 if (NULL == pHddCtx)
1318 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001319 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 return;
1321 }
1322#if 0
1323 pWextState = pAdapter->pWextState;
1324#endif
1325
1326 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1327 {
1328 //TODO Verify is this is really used. If yes need to fix it.
1329 hdd_reconnect_all_adapters( pHddCtx );
1330#if 0
1331 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1332 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1333 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1334
1335 if(VOS_STATUS_SUCCESS == vosStatus)
1336 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1337 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1338
1339 sme_RoamConnect(halHandle,
1340 pAdapter->sessionId, &(pWextState->roamProfile),
1341 &roamId);
1342#endif
1343 }
1344
1345 EXIT();
1346
1347}
1348
1349void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1350{
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1352
1353 /* clear WPA/RSN/WSC IE information in the profile */
1354 pWextState->roamProfile.nWPAReqIELength = 0;
1355 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1356 pWextState->roamProfile.nRSNReqIELength = 0;
1357 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1358
Chet Lanctot186b5732013-03-18 10:26:30 -07001359#ifdef FEATURE_WLAN_WAPI
1360 pWextState->roamProfile.nWAPIReqIELength = 0;
1361 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1362#endif
1363
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001365 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 pWextState->roamProfile.nAddIEScanLength = 0;
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05301367 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1369 pWextState->roamProfile.nAddIEAssocLength = 0;
1370
1371 pWextState->roamProfile.EncryptionType.numEntries = 1;
1372 pWextState->roamProfile.EncryptionType.encryptionType[0]
1373 = eCSR_ENCRYPT_TYPE_NONE;
1374
1375 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1376 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1377 = eCSR_ENCRYPT_TYPE_NONE;
1378
1379 pWextState->roamProfile.AuthType.numEntries = 1;
1380 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1381
Chet Lanctot186b5732013-03-18 10:26:30 -07001382#ifdef WLAN_FEATURE_11W
1383 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1384 pWextState->roamProfile.MFPRequired = 0;
1385 pWextState->roamProfile.MFPCapable = 0;
1386#endif
1387
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 pWextState->authKeyMgmt = 0;
1389
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301390 vos_mem_zero(&pWextState->roamProfile.Keys,
1391 sizeof(pWextState->roamProfile.Keys));
1392
Jeff Johnson295189b2012-06-20 16:38:30 -07001393#ifdef FEATURE_WLAN_WAPI
1394 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1395 pAdapter->wapi_info.nWapiMode = 0;
1396#endif
1397
1398 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1399
1400}
1401
1402void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1403{
1404 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001405
Nirav Shahf6bd2672015-03-11 12:53:15 +05301406 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001407 {
1408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301409 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001410 }
1411 else
1412 {
1413 complete(&pAdapter->ula_complete);
1414 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001415}
1416
1417VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1418{
1419 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001421 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001422
1423 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1424 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001425 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001426
1427 /*To avoid race condition between the set key and the last EAPOL
1428 packet, notify TL to finish upper layer authentication incase if the
1429 last EAPOL packet pending in the TL queue.*/
Nirav Shah4f765af2015-01-21 19:51:30 +05301430 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter,
1431 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1432 pHddStaCtx->conn_info.staId[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001433
Nirav Shah4f765af2015-01-21 19:51:30 +05301434 if ( vos_status == VOS_STATUS_E_ALREADY )
1435 {
1436 return VOS_STATUS_SUCCESS;
1437 }
1438 else if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 {
1440 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1441 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1442 __LINE__, vos_status );
1443 return vos_status;
1444
1445 }
1446
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001447 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301449 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001450 {
1451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301452 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001453 /* we'll still fall through and return success since the
1454 * connection may still get established but is just taking
1455 * too long for us to wait */
1456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 }
1458 return VOS_STATUS_SUCCESS;
1459}
1460
1461v_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)
1462{
1463
1464 int left = ie_len;
1465 v_U8_t *ptr = ie;
1466 v_U8_t elem_id,elem_len;
1467 v_U8_t eid = 0xDD;
1468
1469 if ( NULL == ie || 0 == ie_len )
1470 return NULL;
1471
1472 while(left >= 2)
1473 {
1474 elem_id = ptr[0];
1475 elem_len = ptr[1];
1476 left -= 2;
1477 if(elem_len > left)
1478 {
1479 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001480 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 eid,elem_len,left);
1482 return NULL;
1483 }
1484 if (elem_id == eid)
1485 {
1486 if(memcmp( &ptr[2], oui, oui_size)==0)
1487 return ptr;
1488 }
1489
1490 left -= elem_len;
1491 ptr += (elem_len + 2);
1492 }
1493 return NULL;
1494}
1495
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301496static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 union iwreq_data *wrqu, char *extra)
1498{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301499 hdd_adapter_t *pAdapter;
1500 hdd_context_t *pHddCtx;
1501 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301502
1503 ENTER();
1504
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301505 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1506 if (NULL == pAdapter)
1507 {
1508 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1509 "%s: pAdapter is NULL\n", __func__);
1510 return -EINVAL;
1511 }
1512 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1513 ret = wlan_hdd_validate_context(pHddCtx);
1514 if (0 != ret)
1515 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301516 return ret;
1517 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301518
Jeff Johnson295189b2012-06-20 16:38:30 -07001519 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301520
1521 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301522 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001523}
1524
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301525static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1526 union iwreq_data *wrqu, char *extra)
1527{
1528 int ret;
1529
1530 vos_ssr_protect(__func__);
1531 ret = __iw_set_commit(dev, info, wrqu, extra);
1532 vos_ssr_unprotect(__func__);
1533
1534 return ret;
1535}
1536
1537static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 struct iw_request_info *info,
1539 char *wrqu, char *extra)
1540{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301541 hdd_adapter_t *pAdapter;
1542 hdd_context_t *pHddCtx;
1543 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301544
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301546 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1547 if (NULL == pAdapter)
1548 {
1549 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1550 "%s: pAdapter is NULL\n", __func__);
1551 return -EINVAL;
1552 }
1553 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1554 ret = wlan_hdd_validate_context(pHddCtx);
1555 if (0 != ret)
1556 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301557 return ret;
1558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1560 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301561 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001562}
1563
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301564static int iw_get_name(struct net_device *dev,
1565 struct iw_request_info *info,
1566 char *wrqu, char *extra)
1567{
1568 int ret;
1569
1570 vos_ssr_protect(__func__);
1571 ret = __iw_get_name(dev, info, wrqu, extra);
1572 vos_ssr_unprotect(__func__);
1573
1574 return ret;
1575}
1576
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301577static int __iw_set_mode(struct net_device *dev,
1578 struct iw_request_info *info,
1579 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001580{
1581 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301582 hdd_adapter_t *pAdapter;
1583 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 tCsrRoamProfile *pRoamProfile;
1585 eCsrRoamBssType LastBSSType;
1586 eMib_dot11DesiredBssType connectedBssType;
1587 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301589 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001590
1591 ENTER();
1592
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301593 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 if (NULL == pAdapter)
1595 {
1596 hddLog(VOS_TRACE_LEVEL_WARN,
1597 "%s: Invalid context, pAdapter", __func__);
1598 return 0;
1599 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301600 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1601 status = wlan_hdd_validate_context(pHddCtx);
1602 if (0 != status)
1603 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301604 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 }
1606
1607 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1608 if (pWextState == NULL)
1609 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301610 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 return -EINVAL;
1612 }
1613
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 pRoamProfile = &pWextState->roamProfile;
1616 LastBSSType = pRoamProfile->BSSType;
1617
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301618 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001619
1620 switch (wrqu->mode)
1621 {
1622 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301623 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1625 // Set the phymode correctly for IBSS.
1626 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1627 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001628 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 break;
1631 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301632 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 break;
1636 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301637 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1639 break;
1640 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301641 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 return -EOPNOTSUPP;
1643 }
1644
1645 if ( LastBSSType != pRoamProfile->BSSType )
1646 {
1647 //the BSS mode changed
1648 // We need to issue disconnect if connected or in IBSS disconnect state
1649 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1650 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1651 {
1652 VOS_STATUS vosStatus;
1653 // need to issue a disconnect to CSR.
1654 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1655 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1656 pAdapter->sessionId,
1657 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1658 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301659 {
1660 long ret;
1661 ret = wait_for_completion_interruptible_timeout(
1662 &pAdapter->disconnect_comp_var,
1663 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1664 if (ret <= 0)
1665 hddLog(VOS_TRACE_LEVEL_ERROR,
1666 FL("failed wait on disconnect_comp_var %ld"), ret);
1667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 }
1669 }
1670
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 EXIT();
1672 return 0;
1673}
1674
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301675static int iw_set_mode(struct net_device *dev,
1676 struct iw_request_info *info,
1677 union iwreq_data *wrqu, char *extra)
1678{
1679 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001680
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301681 vos_ssr_protect(__func__);
1682 ret = __iw_set_mode(dev, info, wrqu, extra);
1683 vos_ssr_unprotect(__func__);
1684
1685 return ret;
1686}
1687
1688static int __iw_get_mode(struct net_device *dev,
1689 struct iw_request_info *info,
1690 union iwreq_data *wrqu,
1691 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001692{
1693
1694 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301695 hdd_adapter_t *pAdapter;
1696 hdd_context_t *pHddCtx;
1697 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001698
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301699 ENTER();
1700
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301701 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 if (NULL == pAdapter)
1703 {
1704 hddLog(VOS_TRACE_LEVEL_WARN,
1705 "%s: Invalid context, pAdapter", __func__);
1706 return 0;
1707 }
1708
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301709 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1710 ret = wlan_hdd_validate_context(pHddCtx);
1711 if (0 != ret)
1712 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301713 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1716 if (pWextState == NULL)
1717 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301718 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 return -EINVAL;
1720 }
1721
1722 switch (pWextState->roamProfile.BSSType)
1723 {
1724 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001725 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301726 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 break;
1728 case eCSR_BSS_TYPE_IBSS:
1729 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001730 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301731 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 break;
1733 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001734 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301735 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 break;
1737 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001738 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 break;
1740 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301742 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 return 0;
1744}
1745
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301746static int iw_get_mode(struct net_device *dev,
1747 struct iw_request_info *info,
1748 union iwreq_data *wrqu,
1749 char *extra)
1750{
1751 int ret;
1752
1753 vos_ssr_protect(__func__);
1754 ret = __iw_get_mode(dev, info, wrqu, extra);
1755 vos_ssr_unprotect(__func__);
1756
1757 return ret;
1758}
1759
1760static int __iw_set_freq(struct net_device *dev,
1761 struct iw_request_info *info,
1762 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001763{
1764 v_U32_t numChans = 0;
1765 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1766 v_U32_t indx = 0;
1767 v_U32_t status = 0;
1768
1769 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301770 hdd_adapter_t *pAdapter;
1771 hdd_context_t *pHddCtx;
1772 tHalHandle hHal;
1773 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301775
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 ENTER();
1777
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301778 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1779 if (NULL == pAdapter)
1780 {
1781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1782 "%s:Invalid Adapter",__func__);
1783 return -EINVAL;
1784 }
1785
1786 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1787 status = wlan_hdd_validate_context(pHddCtx);
1788 if (0 != status)
1789 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 return status;
1791 }
1792
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301793 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1794 if (NULL == hHal)
1795 {
1796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1797 "%s: Hal Context is NULL",__func__);
1798 return -EINVAL;
1799 }
1800
1801 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1802 if (NULL == pHddStaCtx)
1803 {
1804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1805 "%s:STA context is NULL",__func__);
1806 return -EINVAL;
1807 }
1808
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301810 if (NULL == pWextState)
1811 {
1812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1813 "%s: pWextState is NULL",__func__);
1814 return -EINVAL;
1815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001816
1817 pRoamProfile = &pWextState->roamProfile;
1818
Arif Hussain6d2a3322013-11-17 19:50:10 -08001819 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001820
1821 /* Link is up then return cant set channel*/
1822 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1823 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1824 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001825 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 return -EOPNOTSUPP;
1827 }
1828
1829 /* Settings by Frequency as input */
1830 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1831 (wrqu->freq.m <= (tANI_U32)5.825e8))
1832 {
1833 tANI_U32 freq = wrqu->freq.m / 100000;
1834
1835 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1836 indx++;
1837 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1838 {
1839 return -EINVAL;
1840 }
1841 wrqu->freq.e = 0;
1842 wrqu->freq.m = freq_chan_map[indx].chan;
1843
1844 }
1845
1846 if (wrqu->freq.e == 0)
1847 {
1848 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1849 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1850 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001851 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001852 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1854 return -EINVAL;
1855 }
1856
1857 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1858
1859 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1860 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1862 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 return -EIO;
1864 }
1865
1866 for (indx = 0; indx < numChans; indx++) {
1867 if (wrqu->freq.m == validChan[indx]){
1868 break;
1869 }
1870 }
1871 }
1872 else{
1873
1874 return -EINVAL;
1875 }
1876
1877 if(indx >= numChans)
1878 {
1879 return -EINVAL;
1880 }
1881
1882 /* Set the Operational Channel */
1883 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1884 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1885 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1886
Arif Hussain6d2a3322013-11-17 19:50:10 -08001887 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001888
1889 EXIT();
1890
1891 return status;
1892}
1893
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301894static int iw_set_freq(struct net_device *dev,
1895 struct iw_request_info *info,
1896 union iwreq_data *wrqu, char *extra)
1897{
1898 int ret;
1899
1900 vos_ssr_protect(__func__);
1901 ret = __iw_set_freq(dev, info, wrqu, extra);
1902 vos_ssr_unprotect(__func__);
1903
1904 return ret;
1905}
1906
1907static int __iw_get_freq(struct net_device *dev,
1908 struct iw_request_info *info,
1909 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001910{
Jeff Johnsone7245742012-09-05 17:12:55 -07001911 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301912 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 tHalHandle hHal;
1914 hdd_wext_state_t *pWextState;
1915 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301916 hdd_station_ctx_t *pHddStaCtx;
1917 hdd_context_t *pHddCtx;
1918 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001919
1920 ENTER();
1921
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301922 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1923 if (NULL == pAdapter)
1924 {
1925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1926 "%s: Adapter is NULL", __func__);
1927 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301929 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1930 ret = wlan_hdd_validate_context(pHddCtx);
1931 if (0 != ret)
1932 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301933 return ret;
1934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301936 if (NULL == hHal)
1937 {
1938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1939 "%s: Hal Context is NULL",__func__);
1940 return -EINVAL;
1941 }
1942 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1943 if (NULL == pHddStaCtx)
1944 {
1945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1946 "%s: HddStaCtx is NULL", __func__);
1947 return -EINVAL;
1948 }
1949 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1950 if (NULL == pWextState)
1951 {
1952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1953 "%s: pWextState is NULL",__func__);
1954 return -EINVAL;
1955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 pRoamProfile = &pWextState->roamProfile;
1957
1958 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1959 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001960 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 {
c_hpothub8245442013-11-20 23:41:09 +05301962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1963 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 return -EIO;
1965 }
1966 else
1967 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001968 status = hdd_wlan_get_freq(channel, &freq);
1969 if( TRUE == status )
1970 {
1971 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1972 * iwlist & iwconfig command shows frequency into proper
1973 * format (2.412 GHz instead of 246.2 MHz)*/
1974 fwrq->m = freq;
1975 fwrq->e = MHZ;
1976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 }
1978 }
1979 else
1980 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001981 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1982 * iwlist & iwconfig command shows frequency into proper
1983 * format (2.412 GHz instead of 246.2 MHz)*/
1984 fwrq->m = 0;
1985 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301987
1988 EXIT();
1989 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001990}
1991
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301992static int iw_get_freq(struct net_device *dev,
1993 struct iw_request_info *info,
1994 struct iw_freq *fwrq, char *extra)
1995{
1996 int ret;
1997
1998 vos_ssr_protect(__func__);
1999 ret = __iw_get_freq(dev, info, fwrq, extra);
2000 vos_ssr_unprotect(__func__);
2001
2002 return ret;
2003}
2004
2005static int __iw_get_tx_power(struct net_device *dev,
2006 struct iw_request_info *info,
2007 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002008{
2009
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302010 hdd_adapter_t *pAdapter;
2011 hdd_context_t *pHddCtx;
2012 hdd_station_ctx_t *pHddStaCtx;
2013 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002014
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302015 ENTER();
2016
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302017 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2018 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2021 "%s: Adapter is NULL",__func__);
2022 return -EINVAL;
2023 }
2024 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2025 ret = wlan_hdd_validate_context(pHddCtx);
2026 if (0 != ret)
2027 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302028 return ret;
2029 }
2030
2031 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2032 if (NULL == pHddStaCtx)
2033 {
2034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2035 "%s: STA Context is NULL",__func__);
2036 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 }
2038
2039 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2040 {
2041 wrqu->txpower.value = 0;
2042 return 0;
2043 }
2044 wlan_hdd_get_classAstats(pAdapter);
2045 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2046
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302047 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 return 0;
2049}
2050
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302051static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 struct iw_request_info *info,
2053 union iwreq_data *wrqu, char *extra)
2054{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302055 int ret;
2056
2057 vos_ssr_protect(__func__);
2058 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2059 vos_ssr_unprotect(__func__);
2060
2061 return ret;
2062}
2063
2064static int __iw_set_tx_power(struct net_device *dev,
2065 struct iw_request_info *info,
2066 union iwreq_data *wrqu, char *extra)
2067{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302068 hdd_adapter_t *pAdapter;
2069 tHalHandle hHal;
2070 hdd_context_t *pHddCtx;
2071 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002072
2073 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302074 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2075 if (NULL == pAdapter)
2076 {
2077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2078 "%s: Adapter is NULL",__func__);
2079 return -EINVAL;
2080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002081
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302082 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2083 ret = wlan_hdd_validate_context(pHddCtx);
2084 if (0 != ret)
2085 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302086 return ret;
2087 }
2088
2089 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2090 if (NULL == hHal)
2091 {
2092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2093 "%s: Hal Context is NULL",__func__);
2094 return -EINVAL;
2095 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2097 {
c_hpothub8245442013-11-20 23:41:09 +05302098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2099 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 return -EIO;
2101 }
2102
2103 EXIT();
2104
2105 return 0;
2106}
2107
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302108static int iw_set_tx_power(struct net_device *dev,
2109 struct iw_request_info *info,
2110 union iwreq_data *wrqu, char *extra)
2111{
2112 int ret;
2113
2114 vos_ssr_protect(__func__);
2115 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2116 vos_ssr_unprotect(__func__);
2117
2118 return ret;
2119}
2120
2121static int __iw_get_bitrate(struct net_device *dev,
2122 struct iw_request_info *info,
2123 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002124{
2125 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2126 eHalStatus status = eHAL_STATUS_SUCCESS;
2127 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302128 hdd_adapter_t *pAdapter;
2129 hdd_context_t *pHddCtx;
2130 hdd_station_ctx_t *pHddStaCtx;
2131 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002132
2133 ENTER();
2134
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302135 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2136 if (NULL == pAdapter)
2137 {
2138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2139 "%s: Adapter is NULL",__func__);
2140 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 }
2142
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302143 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2144 ret = wlan_hdd_validate_context(pHddCtx);
2145 if (0 != ret)
2146 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302147 return ret;
2148 }
2149
2150 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2151 if (NULL == pHddStaCtx)
2152 {
2153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2154 "%s: STA Context is NULL",__func__);
2155 return -EINVAL;
2156 }
2157
2158 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 wrqu->bitrate.value = 0;
2160 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302161 else
2162 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2164 SME_SUMMARY_STATS |
2165 SME_GLOBAL_CLASSA_STATS |
2166 SME_GLOBAL_CLASSB_STATS |
2167 SME_GLOBAL_CLASSC_STATS |
2168 SME_GLOBAL_CLASSD_STATS |
2169 SME_PER_STA_STATS,
2170 hdd_StatisticsCB, 0, FALSE,
2171 pHddStaCtx->conn_info.staId[0], pAdapter );
2172
2173 if(eHAL_STATUS_SUCCESS != status)
2174 {
2175 hddLog(VOS_TRACE_LEVEL_ERROR,
2176 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002177 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 return status;
2179 }
2180
2181 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302182 if (NULL == pWextState)
2183 {
2184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2185 "%s: pWextState is NULL",__func__);
2186 return -EINVAL;
2187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002188
2189 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2190
2191 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2192 {
2193 hddLog(VOS_TRACE_LEVEL_ERROR,
2194 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002195 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 return VOS_STATUS_E_FAILURE;
2197 }
2198
2199 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2200 }
2201
2202 EXIT();
2203
2204 return vos_status;
2205}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302206
2207static int iw_get_bitrate(struct net_device *dev,
2208 struct iw_request_info *info,
2209 union iwreq_data *wrqu, char *extra)
2210{
2211 int ret;
2212
2213 vos_ssr_protect(__func__);
2214 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2215 vos_ssr_unprotect(__func__);
2216
2217 return ret;
2218}
2219
2220
Jeff Johnson295189b2012-06-20 16:38:30 -07002221/* ccm call back function */
2222
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302223static int __iw_set_bitrate(struct net_device *dev,
2224 struct iw_request_info *info,
2225 union iwreq_data *wrqu,
2226 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002227{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302228 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302230 hdd_station_ctx_t *pHddStaCtx;
2231 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2233 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2234 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2235 v_U32_t i, rate;
2236 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302237 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002238
2239 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302240 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2241 if (NULL == pAdapter)
2242 {
2243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2244 "%s: Adapter is NULL",__func__);
2245 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 }
2247
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302248 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2249 ret = wlan_hdd_validate_context(pHddCtx);
2250 if (0 != ret)
2251 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302252 return ret;
2253 }
2254
2255 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2256 if (NULL == pHddStaCtx)
2257 {
2258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2259 "%s: STA Context is NULL",__func__);
2260 return -EINVAL;
2261 }
2262
2263
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302265 if (NULL == pWextState)
2266 {
2267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2268 "%s: pWextState is NULL",__func__);
2269 return -EINVAL;
2270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002271
2272 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2273 {
2274 return -ENXIO ;
2275 }
2276
2277 rate = wrqu->bitrate.value;
2278
2279 if (rate == -1)
2280 {
2281 rate = WNI_CFG_FIXED_RATE_AUTO;
2282 valid_rate = TRUE;
2283 }
2284 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2285 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2286 {
2287 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2288 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2289 {
2290 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2291 WNI_CFG_SUPPORTED_RATES_11A,
2292 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2293 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2294 WNI_CFG_SUPPORTED_RATES_11B,
2295 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2296 {
2297 for (i = 0; i < (b_len + a_len); ++i)
2298 {
2299 /* supported rates returned is double the actual rate so we divide it by 2 */
2300 if ((supp_rates[i]&0x7F)/2 == rate)
2301 {
2302 valid_rate = TRUE;
2303 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2304 break;
2305 }
2306 }
2307 }
2308 }
2309 }
2310 if (valid_rate != TRUE)
2311 {
2312 return -EINVAL;
2313 }
2314 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2315 WNI_CFG_FIXED_RATE, rate,
2316 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2317 {
c_hpothub8245442013-11-20 23:41:09 +05302318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2319 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 return -EIO;
2321 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302322
2323 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002324 return 0;
2325}
2326
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302327static int iw_set_bitrate(struct net_device *dev,
2328 struct iw_request_info *info,
2329 union iwreq_data *wrqu,
2330 char *extra)
2331{
2332 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002333
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302334 vos_ssr_protect(__func__);
2335 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2336 vos_ssr_unprotect(__func__);
2337
2338 return ret;
2339}
2340
2341static int __iw_set_genie(struct net_device *dev,
2342 struct iw_request_info *info,
2343 union iwreq_data *wrqu,
2344 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002345{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302346 hdd_adapter_t *pAdapter;
2347 hdd_context_t *pHddCtx;
2348 hdd_wext_state_t *pWextState;
2349 u_int8_t *genie = NULL;
2350 u_int8_t *base_genie = NULL;
2351 v_U16_t remLen;
2352 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002353
2354 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002355
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302356 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2357 if (NULL == pAdapter)
2358 {
2359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2360 "%s: Adapter is NULL",__func__);
2361 return -EINVAL;
2362 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002363
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302364 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2365 ret = wlan_hdd_validate_context(pHddCtx);
2366 if (0 != ret)
2367 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302368 return ret;
2369 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002370
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302371 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2372 if (NULL == pWextState)
2373 {
2374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2375 "%s: pWextState is NULL",__func__);
2376 return -EINVAL;
2377 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002378
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302379 if (!wrqu->data.length) {
2380 hdd_clearRoamProfileIe(pAdapter);
2381 EXIT();
2382 return 0;
2383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002384
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302385 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2386 wrqu->data.length);
2387 if (NULL == base_genie)
2388 {
2389 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2390 "mem_alloc_copy_from_user_helper fail");
2391 return -ENOMEM;
2392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002393
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302394 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002395
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302396 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002397
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302398 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2399
2400 /* clear any previous genIE before this call */
2401 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2402
2403 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 {
2405 v_U16_t eLen = 0;
2406 v_U8_t elementId;
2407 elementId = *genie++;
2408 eLen = *genie++;
2409 remLen -= 2;
2410
Arif Hussain6d2a3322013-11-17 19:50:10 -08002411 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002412 __func__, elementId, eLen);
2413
2414 switch ( elementId )
2415 {
2416 case IE_EID_VENDOR:
2417 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002418 {
2419 kfree(base_genie);
2420 return -EINVAL;
2421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002422
2423 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2424 {
2425 v_U16_t curGenIELen = pWextState->genIE.length;
2426 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2427 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2428
2429 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2430 {
2431 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002432 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002434 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 return -ENOMEM;
2436 }
2437 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2438 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2439 pWextState->genIE.length += eLen + 2;
2440 }
2441 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2442 {
2443 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2444 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2445 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2446 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2447 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2448 }
2449 else /* any vendorId except WPA IE should be accumulated to genIE */
2450 {
2451 v_U16_t curGenIELen = pWextState->genIE.length;
2452 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2453 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2454
2455 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2456 {
2457 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002458 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002460 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 return -ENOMEM;
2462 }
2463 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2464 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2465 pWextState->genIE.length += eLen + 2;
2466 }
2467 break;
2468 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002469 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2471 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2472 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2473 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2474 break;
2475
2476 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002477 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002478 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 return 0;
2480 }
2481 genie += eLen;
2482 remLen -= eLen;
2483 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302484
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002486 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 return 0;
2488}
2489
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302490static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 struct iw_request_info *info,
2492 union iwreq_data *wrqu,
2493 char *extra)
2494{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302495 int ret;
2496
2497 vos_ssr_protect(__func__);
2498 ret = __iw_set_genie(dev, info, wrqu, extra);
2499 vos_ssr_unprotect(__func__);
2500
2501 return ret;
2502}
2503
2504static int __iw_get_genie(struct net_device *dev,
2505 struct iw_request_info *info,
2506 union iwreq_data *wrqu,
2507 char *extra)
2508{
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302510 hdd_context_t *pHddCtx;
2511 hdd_adapter_t *pAdapter;
2512 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 eHalStatus status;
2514 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2515 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2516
2517 ENTER();
2518
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302519 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2520 if (NULL == pAdapter)
2521 {
2522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2523 "%s: Adapter is NULL",__func__);
2524 return -EINVAL;
2525 }
2526 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2527 status = wlan_hdd_validate_context(pHddCtx);
2528 if (0 != status)
2529 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302530 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002531 }
2532
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302534 if (NULL == pWextState)
2535 {
2536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2537 "%s: pWextState is NULL",__func__);
2538 return -EINVAL;
2539 }
2540
2541 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2542 if (NULL == pHddStaCtx)
2543 {
2544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2545 "%s: STA Context is NULL",__func__);
2546 return -EINVAL;
2547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002548
2549 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2550 {
2551 return -ENXIO;
2552 }
2553
2554 // Return something ONLY if we are associated with an RSN or WPA network
2555 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2556 pWextState->roamProfile.negotiatedAuthType))
2557 {
2558 return -ENXIO;
2559 }
2560
2561 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2562 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2563 pAdapter->sessionId,
2564 &length,
2565 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002566 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2567 if (wrqu->data.length < length)
2568 {
2569 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2570 return -EFAULT;
2571 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002572 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002573 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002574
Arif Hussain6d2a3322013-11-17 19:50:10 -08002575 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002576
2577 EXIT();
2578
2579 return 0;
2580}
2581
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302582static int iw_get_genie(struct net_device *dev,
2583 struct iw_request_info *info,
2584 union iwreq_data *wrqu,
2585 char *extra)
2586{
2587 int ret;
2588
2589 vos_ssr_protect(__func__);
2590 ret = __iw_get_genie(dev, info, wrqu, extra);
2591 vos_ssr_unprotect(__func__);
2592
2593 return ret;
2594}
2595
2596
2597static int __iw_get_encode(struct net_device *dev,
2598 struct iw_request_info *info,
2599 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002600{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302601 hdd_adapter_t *pAdapter;
2602 hdd_context_t *pHddCtx;
2603 hdd_wext_state_t *pWextState;
2604 tCsrRoamProfile *pRoamProfile;
2605 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002607
2608 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302609 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2610 if (NULL == pAdapter)
2611 {
2612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2613 "%s: Adapter is NULL",__func__);
2614 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 }
2616
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302617 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2618 ret = wlan_hdd_validate_context(pHddCtx);
2619 if (0 != ret)
2620 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302621 return ret;
2622 }
2623 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2624 if (NULL == pWextState)
2625 {
2626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2627 "%s: pWextState is NULL",__func__);
2628 return -EINVAL;
2629 }
2630
2631 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 keyId = pRoamProfile->Keys.defaultIndex;
2633
2634 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2635 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002636 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 return -EINVAL;
2638 }
2639
2640 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2641 {
2642 dwrq->flags |= IW_ENCODE_ENABLED;
2643 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2644 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2645
2646 dwrq->flags |= (keyId + 1);
2647
2648 }
2649 else
2650 {
2651 dwrq->flags |= IW_ENCODE_DISABLED;
2652 }
2653
2654 for(i=0; i < MAX_WEP_KEYS; i++)
2655 {
2656 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2657 {
2658 continue;
2659 }
2660 else
2661 {
2662 break;
2663 }
2664 }
2665
2666 if(MAX_WEP_KEYS == i)
2667 {
2668 dwrq->flags |= IW_ENCODE_NOKEY;
2669 }
2670
2671 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2672
2673 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2674 {
2675 dwrq->flags |= IW_ENCODE_OPEN;
2676 }
2677 else
2678 {
2679 dwrq->flags |= IW_ENCODE_RESTRICTED;
2680 }
2681 EXIT();
2682 return 0;
2683}
2684
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302685static int iw_get_encode(struct net_device *dev,
2686 struct iw_request_info *info,
2687 struct iw_point *dwrq, char *extra)
2688{
2689 int ret;
2690
2691 vos_ssr_protect(__func__);
2692 ret = __iw_get_encode(dev, info, dwrq, extra);
2693 vos_ssr_unprotect(__func__);
2694
2695 return ret;
2696}
2697
Jeff Johnson295189b2012-06-20 16:38:30 -07002698#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2699#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2700
2701
2702/*
2703 * This function sends a single 'key' to LIM at all time.
2704 */
2705
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302706static int __iw_get_rts_threshold(struct net_device *dev,
2707 struct iw_request_info *info,
2708 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002709{
2710 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2711 v_U32_t status = 0;
2712
2713 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2714
2715 return status;
2716}
2717
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302718static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 struct iw_request_info *info,
2720 union iwreq_data *wrqu, char *extra)
2721{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302722 int ret;
2723
2724 vos_ssr_protect(__func__);
2725 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2726 vos_ssr_unprotect(__func__);
2727
2728 return ret;
2729}
2730
2731static int __iw_set_rts_threshold(struct net_device *dev,
2732 struct iw_request_info *info,
2733 union iwreq_data *wrqu, char *extra)
2734{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302735 hdd_adapter_t *pAdapter;
2736 hdd_context_t *pHddCtx;
2737 tHalHandle hHal;
2738 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002739
2740 ENTER();
2741
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302742 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2743 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002744 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2746 "%s: Adapter is NULL",__func__);
2747 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002748 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302749
2750 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2751 ret = wlan_hdd_validate_context(pHddCtx);
2752 if (0 != ret)
2753 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302754 return ret;
2755 }
2756
2757 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2758 if (NULL == hHal)
2759 {
2760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2761 "%s: Hal Context is NULL",__func__);
2762 return -EINVAL;
2763 }
2764
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2766 {
2767 return -EINVAL;
2768 }
2769
2770 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2771 {
c_hpothub8245442013-11-20 23:41:09 +05302772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2773 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 return -EIO;
2775 }
2776
2777 EXIT();
2778
2779 return 0;
2780}
2781
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302782static int iw_set_rts_threshold(struct net_device *dev,
2783 struct iw_request_info *info,
2784 union iwreq_data *wrqu, char *extra)
2785{
2786 int ret;
2787
2788 vos_ssr_protect(__func__);
2789 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2790 vos_ssr_unprotect(__func__);
2791
2792 return ret;
2793}
2794
2795static int __iw_get_frag_threshold(struct net_device *dev,
2796 struct iw_request_info *info,
2797 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002798{
2799 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2800 v_U32_t status = 0;
2801
2802 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2803
2804 return status;
2805}
2806
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302807static int iw_get_frag_threshold(struct net_device *dev,
2808 struct iw_request_info *info,
2809 union iwreq_data *wrqu, char *extra)
2810{
2811 int ret;
2812
2813 vos_ssr_protect(__func__);
2814 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2815 vos_ssr_unprotect(__func__);
2816
2817 return ret;
2818}
2819
2820static int __iw_set_frag_threshold(struct net_device *dev,
2821 struct iw_request_info *info,
2822 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002823{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302824 hdd_adapter_t *pAdapter;
2825 hdd_context_t *pHddCtx;
2826 tHalHandle hHal;
2827 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002828
2829 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302830 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2831 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002832 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2834 "%s: Adapter is NULL",__func__);
2835 return -EINVAL;
2836 }
2837
2838 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2839 ret = wlan_hdd_validate_context(pHddCtx);
2840 if (0 != ret)
2841 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302842 return ret;
2843 }
2844
2845 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2846 if (NULL == hHal)
2847 {
2848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2849 "%s: Hal Context is NULL",__func__);
2850 return -EINVAL;
2851 }
2852
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2854 {
2855 return -EINVAL;
2856 }
2857
2858 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2859 {
c_hpothub8245442013-11-20 23:41:09 +05302860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2861 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 return -EIO;
2863 }
2864
2865 EXIT();
2866
2867 return 0;
2868}
2869
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302870static int iw_set_frag_threshold(struct net_device *dev,
2871 struct iw_request_info *info,
2872 union iwreq_data *wrqu, char *extra)
2873{
2874 int ret;
2875
2876 vos_ssr_protect(__func__);
2877 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2878 vos_ssr_unprotect(__func__);
2879
2880 return ret;
2881}
2882
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302883static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 struct iw_request_info *info,
2885 union iwreq_data *wrqu, char *extra)
2886{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302887 hdd_adapter_t *pAdapter;
2888 hdd_context_t *pHddCtx;
2889 int ret = 0;
2890
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302892 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2893 if (NULL == pAdapter)
2894 {
2895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2896 "%s: Adapter is NULL",__func__);
2897 return -EINVAL;
2898 }
2899 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2900 ret = wlan_hdd_validate_context(pHddCtx);
2901 if (0 != ret)
2902 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302903 return ret;
2904 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302905
2906 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 return -EOPNOTSUPP;
2908}
2909
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302910static int iw_get_power_mode(struct net_device *dev,
2911 struct iw_request_info *info,
2912 union iwreq_data *wrqu, char *extra)
2913{
2914 int ret;
2915
2916 vos_ssr_protect(__func__);
2917 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2918 vos_ssr_unprotect(__func__);
2919
2920 return ret;
2921}
2922static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 struct iw_request_info *info,
2924 union iwreq_data *wrqu, char *extra)
2925{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302926 hdd_adapter_t *pAdapter;
2927 hdd_context_t *pHddCtx;
2928 int ret = 0;
2929
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302931 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2932 if (NULL == pAdapter)
2933 {
2934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2935 "%s: Adapter is NULL",__func__);
2936 return -EINVAL;
2937 }
2938 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2939 ret = wlan_hdd_validate_context(pHddCtx);
2940 if (0 != ret)
2941 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302942 return ret;
2943 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302944
2945 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 return -EOPNOTSUPP;
2947}
2948
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302949static int iw_set_power_mode(struct net_device *dev,
2950 struct iw_request_info *info,
2951 union iwreq_data *wrqu, char *extra)
2952{
2953 int ret;
2954
2955 vos_ssr_protect(__func__);
2956 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2957 vos_ssr_unprotect(__func__);
2958
2959 return ret;
2960}
2961
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302962static int __iw_get_range(struct net_device *dev,
2963 struct iw_request_info *info,
2964 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002965{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302966 hdd_adapter_t *pAdapter;
2967 tHalHandle hHal;
2968 hdd_context_t *pHddCtx;
2969 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 struct iw_range *range = (struct iw_range *) extra;
2971
2972 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2973
2974 v_U32_t num_channels = sizeof(channels);
2975 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2976 v_U32_t a_len;
2977 v_U32_t b_len;
2978 v_U32_t active_phy_mode = 0;
2979 v_U8_t index = 0, i;
2980
2981 ENTER();
2982
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302983 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2984 if (NULL == pAdapter)
2985 {
2986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2987 "%s: pAdapter is NULL", __func__);
2988 return -EINVAL;
2989 }
2990 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2991 ret = wlan_hdd_validate_context(pHddCtx);
2992 if (0 != ret)
2993 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302994 return ret;
2995 }
2996 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2997 if (NULL == hHal)
2998 {
2999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3000 "%s: pAdapter is NULL", __func__);
3001 return -EINVAL;
3002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 wrqu->data.length = sizeof(struct iw_range);
3004 memset(range, 0, sizeof(struct iw_range));
3005
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 /*Get the phy mode*/
3007 if (ccmCfgGetInt(hHal,
3008 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3009 {
3010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003011 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003012
3013 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3014 {
3015 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003016 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003017 if (ccmCfgGetStr(hHal,
3018 WNI_CFG_SUPPORTED_RATES_11A,
3019 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3020 {
3021 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3022 {
3023 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3024 }
3025 for (i = 0; i < a_len; i++)
3026 {
3027 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3028 }
3029 range->num_bitrates = a_len;
3030 }
3031 else
3032 {
3033 return -EIO;
3034 }
3035 }
3036 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3037 {
3038 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003039 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 if (ccmCfgGetStr(hHal,
3041 WNI_CFG_SUPPORTED_RATES_11B,
3042 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3043 {
3044 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3045 {
3046 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3047 }
3048 for (i = 0; i < b_len; i++)
3049 {
3050 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3051 }
3052 range->num_bitrates = b_len;
3053 }
3054 else
3055 {
3056 return -EIO;
3057 }
3058 }
3059 }
3060
3061 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3062 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3063 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3064
3065 range->encoding_size[0] = 5;
3066 range->encoding_size[1] = 13;
3067 range->num_encoding_sizes = 2;
3068 range->max_encoding_tokens = MAX_WEP_KEYS;
3069
3070 // we support through Wireless Extensions 22
3071 range->we_version_compiled = WIRELESS_EXT;
3072 range->we_version_source = 22;
3073
3074 /*Supported Channels and Frequencies*/
3075 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3076 {
c_hpothub8245442013-11-20 23:41:09 +05303077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3078 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 return -EIO;
3080 }
3081 if (num_channels > IW_MAX_FREQUENCIES)
3082 {
3083 num_channels = IW_MAX_FREQUENCIES;
3084 }
3085
3086 range->num_channels = num_channels;
3087 range->num_frequency = num_channels;
3088
3089 for (index=0; index < num_channels; index++)
3090 {
3091 v_U32_t frq_indx = 0;
3092
3093 range->freq[index].i = channels[index];
3094 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3095 {
3096 if(channels[index] == freq_chan_map[frq_indx].chan)
3097 {
3098 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3099 range->freq[index].e = 1;
3100 break;
3101 }
3102 frq_indx++;
3103 }
3104 }
3105
3106 /* Event capability (kernel + driver) */
3107 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3108 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3109 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3110 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3111
3112 /*Encryption capability*/
3113 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3114 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3115
3116 /* Txpower capability */
3117 range->txpower_capa = IW_TXPOW_MWATT;
3118
3119 /*Scanning capability*/
3120 #if WIRELESS_EXT >= 22
3121 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3122 #endif
3123
3124 EXIT();
3125 return 0;
3126}
3127
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303128static int iw_get_range(struct net_device *dev,
3129 struct iw_request_info *info,
3130 union iwreq_data *wrqu, char *extra)
3131{
3132 int ret;
3133
3134 vos_ssr_protect(__func__);
3135 ret = __iw_get_range(dev, info, wrqu, extra);
3136 vos_ssr_unprotect(__func__);
3137
3138 return ret;
3139}
3140
Jeff Johnson295189b2012-06-20 16:38:30 -07003141/* Callback function registered with PMC to know status of PMC request */
3142static void iw_power_callback_fn (void *pContext, eHalStatus status)
3143{
3144 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003145
3146 if (NULL == pContext)
3147 {
3148 hddLog(VOS_TRACE_LEVEL_ERROR,
3149 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003150 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 return;
3152 }
3153
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003155
Jeff Johnson72a40512013-12-19 10:14:15 -08003156 /* there is a race condition that exists between this callback
3157 function and the caller since the caller could time out either
3158 before or while this code is executing. we use a spinlock to
3159 serialize these actions */
3160 spin_lock(&hdd_context_lock);
3161
3162 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 {
3164 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003165 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003167 "%s: Invalid context, magic [%08x]",
3168 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003169
3170 if (ioctl_debug)
3171 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003172 pr_info("%s: Invalid context, magic [%08x]\n",
3173 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 }
3175 return;
3176 }
3177
Jeff Johnson72a40512013-12-19 10:14:15 -08003178 /* context is valid so caller is still waiting */
3179
3180 /* paranoia: invalidate the magic */
3181 pStatsContext->magic = 0;
3182
3183 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003185
3186 /* serialization is complete */
3187 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003188}
3189
3190/* Callback function for tx per hit */
3191void hdd_tx_per_hit_cb (void *pCallbackContext)
3192{
3193 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3194 unsigned char tx_fail[16];
3195 union iwreq_data wrqu;
3196
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303197 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003199 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 return;
3201 }
3202 memset(&wrqu, 0, sizeof(wrqu));
3203 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3204 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3205}
3206
3207void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3208{
3209 struct statsContext *pStatsContext;
3210 tCsrGlobalClassAStatsInfo *pClassAStats;
3211 hdd_adapter_t *pAdapter;
3212
3213 if (ioctl_debug)
3214 {
3215 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003216 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 }
3218
3219 if ((NULL == pStats) || (NULL == pContext))
3220 {
3221 hddLog(VOS_TRACE_LEVEL_ERROR,
3222 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003223 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 return;
3225 }
3226
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 pClassAStats = pStats;
3228 pStatsContext = pContext;
3229 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003230
3231 /* there is a race condition that exists between this callback
3232 function and the caller since the caller could time out either
3233 before or while this code is executing. we use a spinlock to
3234 serialize these actions */
3235 spin_lock(&hdd_context_lock);
3236
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3238 {
3239 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003240 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 hddLog(VOS_TRACE_LEVEL_WARN,
3242 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003243 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 if (ioctl_debug)
3245 {
3246 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003247 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 }
3249 return;
3250 }
3251
Jeff Johnson72a40512013-12-19 10:14:15 -08003252 /* context is valid so caller is still waiting */
3253
3254 /* paranoia: invalidate the magic */
3255 pStatsContext->magic = 0;
3256
3257 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3259
Jeff Johnson72a40512013-12-19 10:14:15 -08003260 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003262
3263 /* serialization is complete */
3264 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003265}
3266
3267VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3268{
3269 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3270 eHalStatus hstatus;
3271 long lrc;
3272 struct statsContext context;
3273
3274 if (NULL == pAdapter)
3275 {
3276 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3277 return VOS_STATUS_E_FAULT;
3278 }
3279 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3280 {
3281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3282 return VOS_STATUS_SUCCESS;
3283 }
3284
3285 /* we are connected
3286 prepare our callback context */
3287 init_completion(&context.completion);
3288 context.pAdapter = pAdapter;
3289 context.magic = STATS_CONTEXT_MAGIC;
3290 /* query only for Class A statistics (which include link speed) */
3291 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3292 eCSR_HDD,
3293 SME_GLOBAL_CLASSA_STATS,
3294 hdd_GetClassA_statisticsCB,
3295 0, // not periodic
3296 FALSE, //non-cached results
3297 pHddStaCtx->conn_info.staId[0],
3298 &context);
3299 if (eHAL_STATUS_SUCCESS != hstatus)
3300 {
3301 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003302 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003303 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 /* we'll returned a cached value below */
3305 }
3306 else
3307 {
3308 /* request was sent -- wait for the response */
3309 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3310 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 if (lrc <= 0)
3312 {
3313 hddLog(VOS_TRACE_LEVEL_ERROR,
3314 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003315 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 }
3317 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003318
3319 /* either we never sent a request, we sent a request and received a
3320 response or we sent a request and timed out. if we never sent a
3321 request or if we sent a request and got a response, we want to
3322 clear the magic out of paranoia. if we timed out there is a
3323 race condition such that the callback function could be
3324 executing at the same time we are. of primary concern is if the
3325 callback function had already verified the "magic" but had not
3326 yet set the completion variable when a timeout occurred. we
3327 serialize these activities by invalidating the magic while
3328 holding a shared spinlock which will cause us to block if the
3329 callback is currently executing */
3330 spin_lock(&hdd_context_lock);
3331 context.magic = 0;
3332 spin_unlock(&hdd_context_lock);
3333
3334 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 return VOS_STATUS_SUCCESS;
3336}
3337
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003338static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3339{
3340 struct statsContext *pStatsContext;
3341 tCsrSummaryStatsInfo *pSummaryStats;
3342 tCsrGlobalClassAStatsInfo *pClassAStats;
3343 hdd_adapter_t *pAdapter;
3344
3345 if (ioctl_debug)
3346 {
3347 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003348 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003349 }
3350
3351 if ((NULL == pStats) || (NULL == pContext))
3352 {
3353 hddLog(VOS_TRACE_LEVEL_ERROR,
3354 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003355 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003356 return;
3357 }
3358
Jeff Johnson72a40512013-12-19 10:14:15 -08003359 /* there is a race condition that exists between this callback
3360 function and the caller since the caller could time out either
3361 before or while this code is executing. we use a spinlock to
3362 serialize these actions */
3363 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003364
3365 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3366 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3367 pStatsContext = pContext;
3368 pAdapter = pStatsContext->pAdapter;
3369 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3370 {
3371 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003372 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003373 hddLog(VOS_TRACE_LEVEL_WARN,
3374 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003375 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003376 if (ioctl_debug)
3377 {
3378 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003379 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003380 }
3381 return;
3382 }
3383
Jeff Johnson72a40512013-12-19 10:14:15 -08003384 /* context is valid so caller is still waiting */
3385
3386 /* paranoia: invalidate the magic */
3387 pStatsContext->magic = 0;
3388
3389 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003390 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3391 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3392
Jeff Johnson72a40512013-12-19 10:14:15 -08003393 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003394 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003395
3396 /* serialization is complete */
3397 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003398}
3399
3400VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3401{
3402 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3403 eHalStatus hstatus;
3404 long lrc;
3405 struct statsContext context;
3406
3407 if (NULL == pAdapter)
3408 {
3409 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3410 return VOS_STATUS_SUCCESS;
3411 }
3412
3413 /* we are connected
3414 prepare our callback context */
3415 init_completion(&context.completion);
3416 context.pAdapter = pAdapter;
3417 context.magic = STATS_CONTEXT_MAGIC;
3418
3419 /* query only for Summary & Class A statistics */
3420 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3421 eCSR_HDD,
3422 SME_SUMMARY_STATS |
3423 SME_GLOBAL_CLASSA_STATS,
3424 hdd_get_station_statisticsCB,
3425 0, // not periodic
3426 FALSE, //non-cached results
3427 pHddStaCtx->conn_info.staId[0],
3428 &context);
3429 if (eHAL_STATUS_SUCCESS != hstatus)
3430 {
3431 hddLog(VOS_TRACE_LEVEL_ERROR,
3432 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003433 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003434 /* we'll return with cached values */
3435 }
3436 else
3437 {
3438 /* request was sent -- wait for the response */
3439 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3440 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003441
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003442 if (lrc <= 0)
3443 {
3444 hddLog(VOS_TRACE_LEVEL_ERROR,
3445 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003446 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003447 }
3448 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003449
3450 /* either we never sent a request, we sent a request and received a
3451 response or we sent a request and timed out. if we never sent a
3452 request or if we sent a request and got a response, we want to
3453 clear the magic out of paranoia. if we timed out there is a
3454 race condition such that the callback function could be
3455 executing at the same time we are. of primary concern is if the
3456 callback function had already verified the "magic" but had not
3457 yet set the completion variable when a timeout occurred. we
3458 serialize these activities by invalidating the magic while
3459 holding a shared spinlock which will cause us to block if the
3460 callback is currently executing */
3461 spin_lock(&hdd_context_lock);
3462 context.magic = 0;
3463 spin_unlock(&hdd_context_lock);
3464
3465 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003466 return VOS_STATUS_SUCCESS;
3467}
3468
3469
Jeff Johnson295189b2012-06-20 16:38:30 -07003470/*
3471 * Support for the LINKSPEED private command
3472 * Per the WiFi framework the response must be of the form
3473 * "LinkSpeed xx"
3474 */
3475static int iw_get_linkspeed(struct net_device *dev,
3476 struct iw_request_info *info,
3477 union iwreq_data *wrqu, char *extra)
3478{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303479 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303480 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303482 int len = sizeof(v_U32_t) + 1;
3483 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303484 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303485 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303486 int rc, valid = 0;
3487
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303488 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303489 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3490 if (NULL == pAdapter)
3491 {
3492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3493 "%s: Adapter is NULL",__func__);
3494 return -EINVAL;
3495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003496
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303497 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303498 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303499 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003500 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303501 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003502 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303503 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3504 if (NULL == pHddStaCtx)
3505 {
3506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3507 "%s: STA Context is NULL",__func__);
3508 return -EINVAL;
3509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3511 {
3512 /* we are not connected so we don't have a classAstats */
3513 link_speed = 0;
3514 }
3515 else
3516 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303517 status = wlan_hdd_get_classAstats(pAdapter);
3518
3519 if (!VOS_IS_STATUS_SUCCESS(status ))
3520 {
3521 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3522 return -EINVAL;
3523 }
3524
3525 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3526 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3527 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3528 &link_speed);
3529
3530 link_speed = link_speed / 10;
3531
3532 if (0 == link_speed)
3533 {
3534 /* The linkspeed returned by HAL is in units of 500kbps.
3535 * converting it to mbps.
3536 * This is required to support legacy firmware which does
3537 * not return link capacity.
3538 */
3539 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3540 }
3541
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 }
3543
3544 wrqu->data.length = len;
3545 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003546 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 if ((rc < 0) || (rc >= len))
3548 {
3549 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303550 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 return -EIO;
3552 }
3553
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303554 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003556 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003557}
3558
Arif Hussain695279c2014-03-24 14:06:07 -07003559/*
3560 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3561 *
3562 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303563static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003564 struct iw_request_info *info,
3565 union iwreq_data *wrqu, char *extra)
3566{
3567 int rc;
3568
3569 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3570
3571 if (rc < 0)
3572 return rc;
3573
3574 /* a value is being successfully returned */
3575 return 0;
3576}
Jeff Johnson295189b2012-06-20 16:38:30 -07003577
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303578static int iw_get_linkspeed_priv(struct net_device *dev,
3579 struct iw_request_info *info,
3580 union iwreq_data *wrqu, char *extra)
3581{
3582 int ret;
3583
3584 vos_ssr_protect(__func__);
3585 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3586 vos_ssr_unprotect(__func__);
3587
3588 return ret;
3589}
3590
Jeff Johnson295189b2012-06-20 16:38:30 -07003591/*
3592 * Support for the RSSI & RSSI-APPROX private commands
3593 * Per the WiFi framework the response must be of the form
3594 * "<ssid> rssi <xx>"
3595 * unless we are not associated, in which case the response is
3596 * "OK"
3597 */
3598static int iw_get_rssi(struct net_device *dev,
3599 struct iw_request_info *info,
3600 union iwreq_data *wrqu, char *extra)
3601{
3602 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003603 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 int len = wrqu->data.length;
3605 v_S7_t s7Rssi = 0;
3606 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3607 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3608 VOS_STATUS vosStatus;
3609 int rc;
3610
3611 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3612 (0 == ssidlen) || (ssidlen >= len))
3613 {
3614 /* we are not connected or our SSID is too long
3615 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003616 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 }
3618 else
3619 {
3620 /* we are connected with a valid SSID
3621 so we can write the SSID into the return buffer
3622 (note that it is not NUL-terminated) */
3623 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3624
3625 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3626
3627 if (VOS_STATUS_SUCCESS == vosStatus)
3628 {
3629 /* append the rssi to the ssid in the format required by
3630 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003631 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303632 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 }
3634 else
3635 {
3636 rc = -1;
3637 }
3638 }
3639
3640 /* verify that we wrote a valid response */
3641 if ((rc < 0) || (rc >= len))
3642 {
3643 // encoding or length error?
3644 hddLog(VOS_TRACE_LEVEL_ERROR,
3645 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003646 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 return -EIO;
3648 }
3649
3650 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003651 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003652}
3653
3654/*
3655 * Support for SoftAP channel range private command
3656 */
3657static int iw_softap_set_channel_range( struct net_device *dev,
3658 int startChannel,
3659 int endChannel,
3660 int band)
3661{
Jeff Johnson43971f52012-07-17 12:26:56 -07003662 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 int ret = 0;
3664 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3665 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003666 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3667
Jeff Johnson295189b2012-06-20 16:38:30 -07003668
3669 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3670 if (VOS_STATUS_SUCCESS != status)
3671 {
3672 ret = -EINVAL;
3673 }
Yathish9f22e662012-12-10 14:21:35 -08003674 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 return ret;
3676}
3677
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303678static uint8 chartohex(char c)
3679{
3680 uint8 val = 0;
3681 if (c >= '0' && c <= '9')
3682 val = c - '0';
3683 else if (c >= 'a' && c <= 'f')
3684 val = c - 'a' + 10;
3685 else if (c >= 'A' && c <= 'F')
3686 val = c - 'A' + 10;
3687 else
3688 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3689
3690 return val;
3691}
3692
3693uint8 getByte(char **buf)
3694{
3695 uint8 byte = 0;
3696 char *temp = *buf;
3697 byte = chartohex(*temp) * 16;
3698 temp++;
3699 byte += chartohex(*temp);
3700 temp++;
3701 *buf = temp;
3702 return byte;
3703}
3704
3705static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3706{
3707 tSir80211Header *macHeader;
3708 int i = 0, j = 0, length = 0;
3709 uint8 byte = 0;
3710 char *temp = pBuffer;
3711 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303712 char *pHeader;
3713 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303714
3715 macHeader = &pkt->macHeader;
3716
3717 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3718
3719 temp++;
3720
3721 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3722 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3723 pkt->encParams.keyParams.key[0].keyId);
3724
3725 for (i = 0; i< 16; i++) {
3726 pkt->encParams.keyParams.key[0].key[i]
3727 = getByte(&temp);
3728 }
3729
3730 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3731 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3732
3733 for (i = 0; i< 6; i++) {
3734 pkt->encParams.pn[i]
3735 = getByte(&temp);
3736 }
3737
3738 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3739 &pkt->encParams.pn[0], 6, 0);
3740
3741 for (i = 0, j= 5; i< 3; i++, j--) {
3742 byte = pkt->encParams.pn[i];
3743 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3744 pkt->encParams.pn[j] = byte;
3745 }
3746
3747 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303748 if (length > sizeof(tSir80211Header))
3749 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303750
Srinivas Dasari2382de62015-01-22 15:00:04 +05303751 pHeader = temp;
3752 vos_mem_zero(&header, sizeof(tSir80211Header));
3753 for (i = 0; i < length; i++) {
3754 *((uint8 *)&header + i) = getByte(&pHeader);
3755 }
3756
3757 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3758 (char *)&header, length, 0);
3759
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303760 byte = getByte(&temp);
3761
3762 macHeader->frameCtrl.protVer = byte & 0x3;
3763 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3764 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3765
3766 byte = getByte(&temp);
3767 macHeader->frameCtrl.toDS = (byte) & 0x1;
3768 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3769 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3770 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3771 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3772 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3773 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3774 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3775
3776 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3777 "macHeader->frameCtrl.type : %x "
3778 "macHeader->frameCtrl.subType : %x "
3779 "macHeader->frameCtrl.toDS : %x "
3780 "macHeader->frameCtrl.fromDS : %x "
3781 "macHeader->frameCtrl.moreFrag : %x "
3782 "macHeader->frameCtrl.retry : %x "
3783 "macHeader->frameCtrl.powerMgmt : %x "
3784 "macHeader->frameCtrl.MoreData : %x "
3785 "macHeader->frameCtrl.wep : %x "
3786 "macHeader->frameCtrl.order : %x "
3787 , macHeader->frameCtrl.protVer
3788 , macHeader->frameCtrl.type
3789 , macHeader->frameCtrl.subType
3790 , macHeader->frameCtrl.toDS
3791 , macHeader->frameCtrl.fromDS
3792 , macHeader->frameCtrl.moreFrag
3793 , macHeader->frameCtrl.retry
3794 , macHeader->frameCtrl.powerMgmt
3795 , macHeader->frameCtrl.moreData
3796 , macHeader->frameCtrl.wep
3797 , macHeader->frameCtrl.order);
3798
3799
3800 macHeader->usDurationId = getByte(&temp);
3801 macHeader->usDurationId += getByte(&temp) << 8;
3802
3803 macHeader->vA1[0] = getByte(&temp);
3804 macHeader->vA1[1] = getByte(&temp);
3805 macHeader->vA1[2] = getByte(&temp);
3806 macHeader->vA1[3] = getByte(&temp);
3807 macHeader->vA1[4] = getByte(&temp);
3808 macHeader->vA1[5] = getByte(&temp);
3809
3810 macHeader->vA2[0] = getByte(&temp);
3811 macHeader->vA2[1] = getByte(&temp);
3812 macHeader->vA2[2] = getByte(&temp);
3813 macHeader->vA2[3] = getByte(&temp);
3814 macHeader->vA2[4] = getByte(&temp);
3815 macHeader->vA2[5] = getByte(&temp);
3816
3817 macHeader->vA3[0] = getByte(&temp);
3818 macHeader->vA3[1] = getByte(&temp);
3819 macHeader->vA3[2] = getByte(&temp);
3820 macHeader->vA3[3] = getByte(&temp);
3821 macHeader->vA3[4] = getByte(&temp);
3822 macHeader->vA3[5] = getByte(&temp);
3823
3824 macHeader->sSeqCtrl = getByte(&temp);
3825 fragNum = macHeader->sSeqCtrl & 0xF;
3826 macHeader->sSeqCtrl >>= 4;
3827
3828 macHeader->sSeqCtrl += getByte(&temp) << 4;
3829
3830 macHeader->sSeqCtrl |= fragNum << 12;
3831
3832 if (length == 30 || length == 32) {
3833 macHeader->optvA4[0] = getByte(&temp);
3834 macHeader->optvA4[1] = getByte(&temp);
3835 macHeader->optvA4[2] = getByte(&temp);
3836 macHeader->optvA4[3] = getByte(&temp);
3837 macHeader->optvA4[4] = getByte(&temp);
3838 macHeader->optvA4[5] = getByte(&temp);
3839 }
3840
3841 if (length == 26 || length == 32) {
3842 macHeader->usQosCtrl = getByte(&temp);
3843 macHeader->usQosCtrl += getByte(&temp) << 8;
3844 }
3845
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303846 //parse payload
3847 length = getByte(&temp);
3848 length += getByte(&temp) << 8;
3849 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3850
3851 pkt->data.length = length;
3852
3853 for (i = 0; i< length; i++) {
3854 pkt->data.data[i] = getByte(&temp);
3855 }
3856
3857 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3858 &pkt->data.data[0], pkt->data.length, 0);
3859}
3860
3861/**---------------------------------------------------------------------------
3862
3863 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3864 encrypt message request
3865 This is an asynchronous callback function from SME when the encrypted data
3866 is received
3867
3868 \pEncInfoRsp -> Encrypted data info
3869
3870 \return - 0 for success non-zero for failure
3871 --------------------------------------------------------------------------*/
3872static void
3873hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3874{
3875 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3876
3877 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3878
3879 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3880 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3881 pEncryptedDataRsp->encryptedPayload.length);
3882 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3883 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3884 pEncryptedDataRsp->encryptedPayload.data,
3885 pEncryptedDataRsp->encryptedPayload.length, 0);
3886}
3887
Jeff Johnson295189b2012-06-20 16:38:30 -07003888VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3889{
3890 struct statsContext context;
3891 eHalStatus status;
3892 hdd_context_t *pHddCtx;
3893
3894 if (NULL == pAdapter)
3895 {
3896 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3897 return VOS_STATUS_E_FAULT;
3898 }
3899
3900 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3901 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303902 if (pHddCtx->isLogpInProgress) {
3903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3904 "%s:LOGP in Progress. Ignore!!!", __func__);
3905 return VOS_STATUS_E_FAILURE;
3906 }
3907
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 init_completion(&context.completion);
3909
3910 context.pAdapter = pAdapter;
3911 context.magic = POWER_CONTEXT_MAGIC;
3912
3913 if (DRIVER_POWER_MODE_ACTIVE == mode)
3914 {
3915 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3916 "Full Power", __func__);
3917 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3918 iw_power_callback_fn, &context,
3919 eSME_FULL_PWR_NEEDED_BY_HDD);
3920 // Enter Full power command received from GUI this means we are disconnected
3921 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3922 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3923 if (eHAL_STATUS_PMC_PENDING == status)
3924 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003925 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 int lrc = wait_for_completion_interruptible_timeout(
3927 &context.completion,
3928 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003929
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 if (lrc <= 0)
3931 {
3932 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003933 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 }
3935 }
3936 }
3937 else if (DRIVER_POWER_MODE_AUTO == mode)
3938 {
3939 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3940 {
3941 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3942 __func__);
3943 // Enter BMPS command received from GUI this means DHCP is completed
3944 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3945 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3946 FALSE);
3947 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3948 iw_power_callback_fn, &context);
3949 if (eHAL_STATUS_PMC_PENDING == status)
3950 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003951 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 int lrc = wait_for_completion_interruptible_timeout(
3953 &context.completion,
3954 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 if (lrc <= 0)
3956 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003957 hddLog(VOS_TRACE_LEVEL_ERROR,
3958 "%s: SME %s while requesting BMPS",
3959 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 }
3961 }
3962 }
3963 else
3964 {
3965 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3966 "enabled in the cfg");
3967 }
3968 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003969
3970 /* either we never sent a request, we sent a request and received a
3971 response or we sent a request and timed out. if we never sent a
3972 request or if we sent a request and got a response, we want to
3973 clear the magic out of paranoia. if we timed out there is a
3974 race condition such that the callback function could be
3975 executing at the same time we are. of primary concern is if the
3976 callback function had already verified the "magic" but had not
3977 yet set the completion variable when a timeout occurred. we
3978 serialize these activities by invalidating the magic while
3979 holding a shared spinlock which will cause us to block if the
3980 callback is currently executing */
3981 spin_lock(&hdd_context_lock);
3982 context.magic = 0;
3983 spin_unlock(&hdd_context_lock);
3984
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 return VOS_STATUS_SUCCESS;
3986}
3987
3988VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3989 hdd_adapter_t *pAdapter)
3990{
3991 VOS_STATUS vos_Status;
3992
3993 if ((NULL == pAdapter) || (NULL == pHddCtx))
3994 {
3995 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3996 return VOS_STATUS_E_FAULT;
3997 }
3998
3999 /**Exit from Deep sleep or standby if we get the driver
4000 START cmd from android GUI
4001 */
4002 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4003 {
4004 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4005 "from Stand by",__func__);
4006 vos_Status = hdd_exit_standby(pHddCtx);
4007 }
4008 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4009 {
4010 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4011 "from deep sleep",__func__);
4012 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4013 }
4014 else
4015 {
4016 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4017 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4018 vos_Status = VOS_STATUS_SUCCESS;
4019 }
4020
4021 return vos_Status;
4022}
4023
4024VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4025{
4026 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4027
4028 if (NULL == pHddCtx)
4029 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304030 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 return VOS_STATUS_E_FAULT;
4032 }
4033
4034 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4035 {
4036 //Execute standby procedure.
4037 //Executing standby procedure will cause the STA to
4038 //disassociate first and then the chip will be put into standby.
4039 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4040 vos_Status = hdd_enter_standby(pHddCtx);
4041 }
4042 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4043 pHddCtx->cfg_ini->nEnableDriverStop)
4044 {
4045 //Execute deep sleep procedure
4046 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004047 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 //Deep sleep not supported
4049 vos_Status = hdd_enter_standby(pHddCtx);
4050 }
4051 else
4052 {
4053 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4054 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4055 vos_Status = VOS_STATUS_SUCCESS;
4056 }
4057
4058 return vos_Status;
4059}
4060
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004061
4062void* wlan_hdd_change_country_code_callback(void *pAdapter)
4063{
4064
4065 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004066 complete(&call_back_pAdapter->change_country_code);
4067
4068 return NULL;
4069}
4070
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304071static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 struct iw_request_info *info,
4073 union iwreq_data *wrqu, char *extra)
4074{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304075 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004076 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304078 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004079 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4080
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304081 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004082
4083 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304084
4085 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4086 if (NULL == pAdapter)
4087 {
4088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4089 "mem_alloc_copy_from_user_helper fail");
4090 return -EINVAL;
4091 }
4092 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4093 rc = wlan_hdd_validate_context(pHddCtx);
4094 if (0 != rc)
4095 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304096 return rc;
4097 }
4098
Arif Hussain24bfa702014-01-22 13:51:30 -08004099 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4100 wrqu->data.length);
4101 if (NULL == cmd)
4102 {
4103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4104 "mem_alloc_copy_from_user_helper fail");
4105 return -ENOMEM;
4106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004107
4108 if (ioctl_debug)
4109 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004110 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 }
4112
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004113 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4114 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004115
Arif Hussain24bfa702014-01-22 13:51:30 -08004116 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004118 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4120 "%s: Error in iw_set_scan!", __func__);
4121 rc = -EINVAL;
4122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 }
4124 else if( strcasecmp(cmd, "start") == 0 ) {
4125
Arif Hussain6d2a3322013-11-17 19:50:10 -08004126 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004128
Arif Hussain24bfa702014-01-22 13:51:30 -08004129 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4130 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 {
4132 union iwreq_data wrqu;
4133 char buf[10];
4134
4135 memset(&wrqu, 0, sizeof(wrqu));
4136 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4137 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4138 }
4139 else
4140 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004141 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4142 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 }
4144 goto done;
4145 }
4146 else if( strcasecmp(cmd, "stop") == 0 )
4147 {
4148 union iwreq_data wrqu;
4149 char buf[10];
4150
Arif Hussain6d2a3322013-11-17 19:50:10 -08004151 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004152
4153 wlan_hdd_enter_lowpower(pHddCtx);
4154 memset(&wrqu, 0, sizeof(wrqu));
4155 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4156 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 goto done;
4158 }
4159 else if (strcasecmp(cmd, "macaddr") == 0)
4160 {
4161 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4162 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4163 }
4164 else if (strcasecmp(cmd, "scan-active") == 0)
4165 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304166 hddLog(VOS_TRACE_LEVEL_ERROR,
4167 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004168 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 ret = snprintf(cmd, cmd_len, "OK");
4170 }
4171 else if (strcasecmp(cmd, "scan-passive") == 0)
4172 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304173 hddLog(VOS_TRACE_LEVEL_ERROR,
4174 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004175 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 ret = snprintf(cmd, cmd_len, "OK");
4177 }
4178 else if( strcasecmp(cmd, "scan-mode") == 0 )
4179 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004180 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 }
4182 else if( strcasecmp(cmd, "linkspeed") == 0 )
4183 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004184 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 }
4186 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4187 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004188 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004189 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004190
4191 country_code = cmd + 8;
4192
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004193 init_completion(&pAdapter->change_country_code);
4194
Arif Hussain24bfa702014-01-22 13:51:30 -08004195 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004196 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 country_code,
4198 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304199 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304200 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304201 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004202
4203 /* Wait for completion */
4204 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4205 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4206
4207 if (lrc <= 0)
4208 {
4209 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004210 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004211 }
4212
Arif Hussain24bfa702014-01-22 13:51:30 -08004213 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004215 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004216 "%s: SME Change Country code fail", __func__);
4217 kfree(cmd);
4218 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 }
4220 }
4221 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4222 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004223 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 }
4225 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4226 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004227 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004228
Wilson Yang1be3e652013-10-09 15:18:31 -07004229 if (9 < cmd_len)
4230 {
4231 ptr = (char*)(cmd + 9);
4232
4233 }else{
4234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4235 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004236 kfree(cmd);
4237 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004238 }
4239
4240 if (1 != sscanf(ptr,"%d",&mode))
4241 {
4242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4243 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004244 kfree(cmd);
4245 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004246 }
4247
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 wlan_hdd_enter_bmps(pAdapter, mode);
4249 /*TODO:Set the power mode*/
4250 }
4251 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4252 v_U32_t pmc_state;
4253 v_U16_t value;
4254
4255 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4256 if(pmc_state == BMPS) {
4257 value = DRIVER_POWER_MODE_AUTO;
4258 }
4259 else {
4260 value = DRIVER_POWER_MODE_ACTIVE;
4261 }
4262 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4263 }
4264 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004265 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 /*TODO: set the btcoexmode*/
4267 }
4268 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4269
Arif Hussain6d2a3322013-11-17 19:50:10 -08004270 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 /*TODO: Return the btcoex status*/
4272 }
4273 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4274
Arif Hussain6d2a3322013-11-17 19:50:10 -08004275 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004276
4277 /*TODO: Enable Rx data Filter*/
4278 }
4279 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4280
Arif Hussain6d2a3322013-11-17 19:50:10 -08004281 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004282
4283 /*TODO: Disable Rx data Filter*/
4284 }
4285 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4286
Arif Hussain6d2a3322013-11-17 19:50:10 -08004287 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 /*TODO: rxfilter-statistics*/
4289 }
4290 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4291
Arif Hussain6d2a3322013-11-17 19:50:10 -08004292 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 /*TODO: rxfilter-add*/
4294 }
4295 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4296
Arif Hussain6d2a3322013-11-17 19:50:10 -08004297 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 /*TODO: rxfilter-remove*/
4299 }
4300#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004301 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4302 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4303 /*TODO: support pnosetup*/
4304 }
4305 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4306 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4307 /*TODO: support pnoforce*/
4308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4310
Arif Hussain6d2a3322013-11-17 19:50:10 -08004311 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004312 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4313 kfree(cmd);
4314 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 }
4316 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004317 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004318 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4319 kfree(cmd);
4320 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 }
4322#endif /*FEATURE_WLAN_SCAN_PNO*/
4323 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004324 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004325 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4326 kfree(cmd);
4327 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 }
4329 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4330 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004331 char *ptr;
4332
4333 if (18 < cmd_len)
4334 {
4335 ptr = (char*)(cmd + 18);
4336 }else{
4337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4338 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004339 kfree(cmd);
4340 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004341 }
4342
Jeff Johnson02797792013-10-26 19:17:13 -07004343 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004344 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4345 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4346 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4347 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4348 {
4349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4350 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004351 kfree(cmd);
4352 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004354
4355 // parameters checking
4356 // period has to be larger than 0
4357 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4358 {
4359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004360 kfree(cmd);
4361 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 }
4363
4364 // use default value 5 is the input is not reasonable. in unit of 10%
4365 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4366 {
4367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4368 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4369 }
4370
4371 // default is 5
4372 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4373 {
4374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4375 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4376 }
4377
Arif Hussain24bfa702014-01-22 13:51:30 -08004378 if (eHAL_STATUS_SUCCESS !=
4379 sme_SetTxPerTracking(pHddCtx->hHal,
4380 hdd_tx_per_hit_cb,
4381 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004383 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 }
4385 }
4386 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004387 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4388 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 }
4390done:
4391 /* many of the commands write information back into the command
4392 string using snprintf(). check the return value here in one
4393 place */
4394 if ((ret < 0) || (ret >= cmd_len))
4395 {
4396 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004397 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004399 else if (ret > 0)
4400 {
4401 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4402 {
4403 hddLog(VOS_TRACE_LEVEL_ERROR,
4404 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004405 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004406 return -EFAULT;
4407 }
4408 wrqu->data.length = ret;
4409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004410
4411 if (ioctl_debug)
4412 {
4413 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004414 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004416 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304417 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004418 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004419}
4420
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304421static int iw_set_priv(struct net_device *dev,
4422 struct iw_request_info *info,
4423 union iwreq_data *wrqu, char *extra)
4424{
4425 int ret;
4426 vos_ssr_protect(__func__);
4427 ret = __iw_set_priv(dev, info, wrqu, extra);
4428 vos_ssr_unprotect(__func__);
4429
4430 return ret;
4431}
4432
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304433static int __iw_set_nick(struct net_device *dev,
4434 struct iw_request_info *info,
4435 union iwreq_data *wrqu, char *extra)
4436{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304437 hdd_adapter_t *pAdapter;
4438 hdd_context_t *pHddCtx;
4439 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304440
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304441 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304442
4443 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4444 if (NULL == pAdapter)
4445 {
4446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4447 "%s: Adapter is NULL",__func__);
4448 return -EINVAL;
4449 }
4450
4451 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4452 ret = wlan_hdd_validate_context(pHddCtx);
4453 if (0 != ret)
4454 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304455 return ret;
4456 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304457 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304458 return 0;
4459}
4460
Jeff Johnson295189b2012-06-20 16:38:30 -07004461static int iw_set_nick(struct net_device *dev,
4462 struct iw_request_info *info,
4463 union iwreq_data *wrqu, char *extra)
4464{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304465 int ret;
4466
4467 vos_ssr_protect(__func__);
4468 ret = __iw_set_nick(dev, info, wrqu, extra);
4469 vos_ssr_unprotect(__func__);
4470
4471 return ret;
4472}
4473
4474static int __iw_get_nick(struct net_device *dev,
4475 struct iw_request_info *info,
4476 union iwreq_data *wrqu, char *extra)
4477{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304478 hdd_adapter_t *pAdapter;
4479 hdd_context_t *pHddCtx;
4480 int ret = 0;
4481
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304483
4484 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4485 if (NULL == pAdapter)
4486 {
4487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4488 "%s: Adapter is NULL",__func__);
4489 return -EINVAL;
4490 }
4491
4492 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4493 ret = wlan_hdd_validate_context(pHddCtx);
4494 if (0 != ret)
4495 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304496 return ret;
4497 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304498 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 return 0;
4500}
4501
4502static int iw_get_nick(struct net_device *dev,
4503 struct iw_request_info *info,
4504 union iwreq_data *wrqu, char *extra)
4505{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304506 int ret;
4507
4508 vos_ssr_protect(__func__);
4509 ret = __iw_get_nick(dev, info, wrqu, extra);
4510 vos_ssr_unprotect(__func__);
4511
4512 return ret;
4513}
4514
4515static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4516{
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304518 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004519}
4520
4521static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4522{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304523
4524 struct iw_statistics *stats;
4525
4526 vos_ssr_protect(__func__);
4527 stats = __get_wireless_stats(dev);
4528 vos_ssr_unprotect(__func__);
4529
4530 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004531}
4532
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304533static int __iw_set_encode(struct net_device *dev,
4534 struct iw_request_info *info,
4535 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004536
4537{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304538 hdd_adapter_t *pAdapter;
4539 hdd_station_ctx_t *pHddStaCtx;
4540 hdd_wext_state_t *pWextState;
4541 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 struct iw_point *encoderq = &(wrqu->encoding);
4543 v_U32_t keyId;
4544 v_U8_t key_length;
4545 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4546 v_BOOL_t fKeyPresent = 0;
4547 int i;
4548 eHalStatus status = eHAL_STATUS_SUCCESS;
4549
4550
4551 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304552 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4553 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4556 "%s: Adapter is NULL",__func__);
4557 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 }
4559
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304560 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4561 status = wlan_hdd_validate_context(pHddCtx);
4562 if (0 != status)
4563 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304564 return status;
4565 }
4566 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4567 if (NULL == pWextState)
4568 {
4569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4570 "%s: pWextState is NULL ",__func__);
4571 return -EINVAL;
4572 }
4573 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4574 if (NULL == pHddStaCtx)
4575 {
4576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4577 "%s: STA Context is NULL",__func__);
4578 return -EINVAL;
4579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004580
4581 keyId = encoderq->flags & IW_ENCODE_INDEX;
4582
4583 if(keyId)
4584 {
4585 if(keyId > MAX_WEP_KEYS)
4586 {
4587 return -EINVAL;
4588 }
4589
4590 fKeyPresent = 1;
4591 keyId--;
4592 }
4593 else
4594 {
4595 fKeyPresent = 0;
4596 }
4597
4598
4599 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4600 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 if(!fKeyPresent) {
4603
4604 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4605
4606 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4607 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4608 }
4609 }
4610 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4611 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4612 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4613 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4614
4615 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4616 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4617
4618 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4619 {
4620 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4621 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004622 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304623 {
4624 long ret;
4625 ret = wait_for_completion_interruptible_timeout(
4626 &pAdapter->disconnect_comp_var,
4627 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4628 if (ret <= 0)
4629 hddLog(VOS_TRACE_LEVEL_ERROR,
4630 FL("failed wait on disconnect_comp_var %ld"), ret);
4631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 }
4633
4634 return status;
4635
4636 }
4637
4638 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4639 {
4640 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4641
4642 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4643
4644 }
4645
4646
4647 if(wrqu->data.length > 0)
4648 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004649 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004650
4651 key_length = wrqu->data.length;
4652
4653 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4654
4655 if(5 == key_length)
4656 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004657 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004658
4659 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4660 {
4661 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4662 }
4663 else
4664 {
4665 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4666 }
4667 }
4668 else if(13 == key_length)
4669 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004670 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004671
4672 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4673 {
4674 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4675 }
4676 else
4677 {
4678 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4679 }
4680 }
4681 else
4682 {
4683 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004684 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 return -EINVAL;
4686 }
4687
4688 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4689 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4690 pWextState->roamProfile.EncryptionType.numEntries = 1;
4691 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4692 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4693 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4694
4695 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4696 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4697 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4698 {
4699
4700 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4701
4702 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4703 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4704
4705 return status;
4706 }
4707 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304708 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 return 0;
4710}
4711
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304712static int iw_set_encode(struct net_device *dev,
4713 struct iw_request_info *info,
4714 union iwreq_data *wrqu,char *extra)
4715{
4716 int ret;
4717
4718 vos_ssr_protect(__func__);
4719 ret = __iw_set_encode(dev, info, wrqu, extra);
4720 vos_ssr_unprotect(__func__);
4721
4722 return ret;
4723}
4724
4725static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 struct iw_request_info *info,
4727 struct iw_point *dwrq,
4728 char *extra)
4729{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304730 hdd_adapter_t *pAdapter;
4731 hdd_wext_state_t *pWextState;
4732 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 int keyId;
4734 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4735 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304736 int i, ret = 0;
4737 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004738
4739 ENTER();
4740
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304741 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4742 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004743 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4745 "%s: Adapter is NULL",__func__);
4746 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004747 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4749 ret = wlan_hdd_validate_context(pHddCtx);
4750 if (0 != ret)
4751 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304752 return ret;
4753 }
4754 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4755 if (NULL == pWextState)
4756 {
4757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4758 "%s: pWextState is NULL",__func__);
4759 return -EINVAL;
4760 }
4761 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004762
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 keyId = pRoamProfile->Keys.defaultIndex;
4764
4765 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4766 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004767 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 return -EINVAL;
4769 }
4770
4771 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4772 {
4773 dwrq->flags |= IW_ENCODE_ENABLED;
4774 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304775 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4776 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 }
4778 else
4779 {
4780 dwrq->flags |= IW_ENCODE_DISABLED;
4781 }
4782
4783 for(i=0; i < MAX_WEP_KEYS; i++)
4784 {
4785 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4786 {
4787 continue;
4788 }
4789 else
4790 {
4791 break;
4792 }
4793 }
4794
4795 if(MAX_WEP_KEYS == i)
4796 {
4797 dwrq->flags |= IW_ENCODE_NOKEY;
4798 }
4799 else
4800 {
4801 dwrq->flags |= IW_ENCODE_ENABLED;
4802 }
4803
4804 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4805
4806 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4807 {
4808 dwrq->flags |= IW_ENCODE_DISABLED;
4809 }
4810
4811 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4812
4813 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4814 {
4815 dwrq->flags |= IW_ENCODE_OPEN;
4816 }
4817 else
4818 {
4819 dwrq->flags |= IW_ENCODE_RESTRICTED;
4820 }
4821 EXIT();
4822 return 0;
4823
4824}
4825
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304826static int iw_get_encodeext(struct net_device *dev,
4827 struct iw_request_info *info,
4828 struct iw_point *dwrq,
4829 char *extra)
4830{
4831 int ret;
4832 vos_ssr_protect(__func__);
4833 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4834 vos_ssr_unprotect(__func__);
4835
4836 return ret;
4837}
4838
4839static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004840 struct iw_request_info *info,
4841 union iwreq_data *wrqu, char *extra)
4842{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304843 hdd_adapter_t *pAdapter;
4844 hdd_station_ctx_t *pHddStaCtx;
4845 hdd_wext_state_t *pWextState;
4846 hdd_context_t *pHddCtx;
4847 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004848
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304849 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004850 v_U32_t status = 0;
4851
4852 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4853
4854 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4855
4856 int key_index;
4857 struct iw_point *encoding = &wrqu->encoding;
4858 tCsrRoamSetKey setKey;
4859 v_U32_t roamId= 0xFF;
4860 VOS_STATUS vos_status;
4861
4862 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304863 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4864 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004865 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4867 "%s: Adapter is NULL",__func__);
4868 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304870 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4871 status = wlan_hdd_validate_context(pHddCtx);
4872 if (0 != status)
4873 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304874 return status;
4875 }
4876 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4877 if (NULL == pHddStaCtx)
4878 {
4879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4880 "%s: STA Context is NULL",__func__);
4881 return -EINVAL;
4882 }
4883 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4884 if (NULL == pWextState)
4885 {
4886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4887 "%s: pWextState is NULL",__func__);
4888 return -EINVAL;
4889 }
4890 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 key_index = encoding->flags & IW_ENCODE_INDEX;
4892
4893 if(key_index > 0) {
4894
4895 /*Convert from 1-based to 0-based keying*/
4896 key_index--;
4897 }
4898 if(!ext->key_len) {
4899
4900 /*Set the encrytion type to NONE*/
4901 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4902 return status;
4903 }
4904
4905 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4906 (IW_ENCODE_ALG_WEP == ext->alg))
4907 {
4908 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4909
Agarwal Ashish971c2882013-10-30 20:11:12 +05304910 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4911 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004912 return -EINVAL;
4913 }
4914 else {
4915 /*Static wep, update the roam profile with the keys */
4916 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4917 key_index < CSR_MAX_NUM_KEY) {
4918 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4919 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4920
4921 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4922 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4923
4924 }
4925 }
4926 return status;
4927 }
4928
4929 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4930
4931 setKey.keyId = key_index;
4932 setKey.keyLength = ext->key_len;
4933
4934 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4935 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4936 }
4937
4938 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4939 /*Key direction for group is RX only*/
4940 setKey.keyDirection = eSIR_RX_ONLY;
4941 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4942 }
4943 else {
4944
4945 setKey.keyDirection = eSIR_TX_RX;
4946 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4947 }
4948
4949 /*For supplicant pae role is zero*/
4950 setKey.paeRole = 0;
4951
4952 switch(ext->alg)
4953 {
4954 case IW_ENCODE_ALG_NONE:
4955 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4956 break;
4957
4958 case IW_ENCODE_ALG_WEP:
4959 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4960 break;
4961
4962 case IW_ENCODE_ALG_TKIP:
4963 {
4964 v_U8_t *pKey = &setKey.Key[0];
4965
4966 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4967
4968 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4969
4970 /*Supplicant sends the 32bytes key in this order
4971
4972 |--------------|----------|----------|
4973 | Tk1 |TX-MIC | RX Mic |
4974 |--------------|----------|----------|
4975 <---16bytes---><--8bytes--><--8bytes-->
4976
4977 */
4978 /*Sme expects the 32 bytes key to be in the below order
4979
4980 |--------------|----------|----------|
4981 | Tk1 |RX-MIC | TX Mic |
4982 |--------------|----------|----------|
4983 <---16bytes---><--8bytes--><--8bytes-->
4984 */
4985 /* Copy the Temporal Key 1 (TK1) */
4986 vos_mem_copy(pKey,ext->key,16);
4987
4988 /*Copy the rx mic first*/
4989 vos_mem_copy(&pKey[16],&ext->key[24],8);
4990
4991 /*Copy the tx mic */
4992 vos_mem_copy(&pKey[24],&ext->key[16],8);
4993
4994 }
4995 break;
4996
4997 case IW_ENCODE_ALG_CCMP:
4998 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4999 break;
5000
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005001#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005002#define IW_ENCODE_ALG_KRK 6
5003 case IW_ENCODE_ALG_KRK:
5004 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5005 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005006#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005007
5008 default:
5009 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5010 break;
5011 }
5012
5013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005014 ("%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 -07005015
5016#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305017 /* The supplicant may attempt to set the PTK once pre-authentication
5018 is done. Save the key in the UMAC and include it in the ADD
5019 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305021 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305023 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5024 "%s: Update PreAuth Key success", __func__);
5025 return 0;
5026 }
5027 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5028 {
5029 hddLog(VOS_TRACE_LEVEL_ERROR,
5030 "%s: Update PreAuth Key failed", __func__);
5031 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 }
5033#endif /* WLAN_FEATURE_VOWIFI_11R */
5034
5035 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5036
5037 vos_status = wlan_hdd_check_ula_done(pAdapter);
5038 if ( vos_status != VOS_STATUS_SUCCESS )
5039 {
5040 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5041 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5042 __LINE__, vos_status );
5043
5044 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5045 }
5046
5047 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5048
5049 if ( halStatus != eHAL_STATUS_SUCCESS )
5050 {
5051 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5052 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5053 __LINE__, halStatus );
5054
5055 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5056 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305057 EXIT();
5058 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005059}
5060
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305061static int iw_set_encodeext(struct net_device *dev,
5062 struct iw_request_info *info,
5063 union iwreq_data *wrqu, char *extra)
5064{
5065 int ret;
5066
5067 vos_ssr_protect(__func__);
5068 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5069 vos_ssr_unprotect(__func__);
5070
5071 return ret;
5072}
5073
5074static int __iw_set_retry(struct net_device *dev,
5075 struct iw_request_info *info,
5076 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005077{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305078 hdd_adapter_t *pAdapter;
5079 tHalHandle hHal;
5080 hdd_context_t *pHddCtx;
5081 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005082
5083 ENTER();
5084
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305085 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5086 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005087 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5089 "%s: Adapter is NULL",__func__);
5090 return -EINVAL;
5091 }
5092
5093 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5094 ret = wlan_hdd_validate_context(pHddCtx);
5095 if (0 != ret)
5096 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305097 return ret;
5098 }
5099
5100 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5101 if (NULL == hHal)
5102 {
5103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5104 "%s: Hal Context is NULL",__func__);
5105 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005106 }
5107
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5109 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5110
Arif Hussain6d2a3322013-11-17 19:50:10 -08005111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005112
5113 return -EINVAL;
5114 }
5115
5116 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5117
5118 if((wrqu->retry.flags & IW_RETRY_LONG))
5119 {
5120 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5121 {
c_hpothub8245442013-11-20 23:41:09 +05305122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5123 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 return -EIO;
5125 }
5126 }
5127 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5128 {
5129 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5130 {
c_hpothub8245442013-11-20 23:41:09 +05305131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5132 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 return -EIO;
5134 }
5135 }
5136 }
5137 else
5138 {
5139 return -EOPNOTSUPP;
5140 }
5141
Arif Hussain6d2a3322013-11-17 19:50:10 -08005142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005143
5144 EXIT();
5145
5146 return 0;
5147
5148}
5149
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305150static int iw_set_retry(struct net_device *dev,
5151 struct iw_request_info *info,
5152 union iwreq_data *wrqu, char *extra)
5153{
5154 int ret;
5155
5156 vos_ssr_protect(__func__);
5157 ret = __iw_set_retry(dev, info, wrqu, extra);
5158 vos_ssr_unprotect(__func__);
5159
5160 return ret;
5161}
5162
5163static int __iw_get_retry(struct net_device *dev,
5164 struct iw_request_info *info,
5165 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005166{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305167 hdd_adapter_t *pAdapter;
5168 hdd_context_t *pHddCtx;
5169 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305171 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005172
5173 ENTER();
5174
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305175 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5176 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005177 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5179 "%s: Adapter is NULL",__func__);
5180 return -EINVAL;
5181 }
5182
5183 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5184 ret = wlan_hdd_validate_context(pHddCtx);
5185 if (0 != ret)
5186 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305187 return ret;
5188 }
5189
5190 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5191 if (NULL == hHal)
5192 {
5193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5194 "%s: Hal Context is NULL",__func__);
5195 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005196 }
5197
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 if((wrqu->retry.flags & IW_RETRY_LONG))
5199 {
5200 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5201
5202 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5203 {
c_hpothub8245442013-11-20 23:41:09 +05305204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5205 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 return -EIO;
5207 }
5208
5209 wrqu->retry.value = retry;
5210 }
5211 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5212 {
5213 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5214
5215 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5216 {
c_hpothub8245442013-11-20 23:41:09 +05305217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5218 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 return -EIO;
5220 }
5221
5222 wrqu->retry.value = retry;
5223 }
5224 else {
5225 return -EOPNOTSUPP;
5226 }
5227
Arif Hussain6d2a3322013-11-17 19:50:10 -08005228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005229
5230 EXIT();
5231
5232 return 0;
5233}
5234
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305235static int iw_get_retry(struct net_device *dev,
5236 struct iw_request_info *info,
5237 union iwreq_data *wrqu, char *extra)
5238{
5239 int ret;
5240
5241 vos_ssr_protect(__func__);
5242 ret = __iw_get_retry(dev, info, wrqu, extra);
5243 vos_ssr_unprotect(__func__);
5244
5245 return ret;
5246}
5247
5248static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 struct iw_request_info *info,
5250 union iwreq_data *wrqu,
5251 char *extra)
5252{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305253 hdd_adapter_t *pAdapter;
5254 hdd_context_t *pHddCtx;
5255 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5257 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305258 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005259
5260 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305261 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5262 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5265 "%s:Adapter is NULL",__func__);
5266 return -EINVAL;
5267 }
5268 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5269 ret = wlan_hdd_validate_context(pHddCtx);
5270 if (0 != ret)
5271 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305272 return ret;
5273 }
5274 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5275 if (NULL == pHddStaCtx)
5276 {
5277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5278 "%s:STA context is NULL",__func__);
5279 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005280 }
5281
5282 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5283 switch (mlme->cmd) {
5284 case IW_MLME_DISASSOC:
5285 case IW_MLME_DEAUTH:
5286
5287 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5288 {
5289 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5290
5291 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5292 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5293
5294 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5295 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5296
Jeff Johnson43971f52012-07-17 12:26:56 -07005297 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305298 {
5299 long ret;
5300 ret = wait_for_completion_interruptible_timeout(
5301 &pAdapter->disconnect_comp_var,
5302 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5303 if (ret <= 0)
5304 hddLog(VOS_TRACE_LEVEL_ERROR,
5305 FL("failed wait on disconnect_comp_var %ld"), ret);
5306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005308 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005309 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005310
5311 /* Resetting authKeyMgmt */
5312 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5313
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305314 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 netif_tx_disable(dev);
5316 netif_carrier_off(dev);
5317
5318 }
5319 else
5320 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005321 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 -07005322 }
5323 break;
5324 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005325 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005326 return -EINVAL;
5327 }//end of switch
5328
5329 EXIT();
5330
5331 return status;
5332
5333}
5334
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305335static int iw_set_mlme(struct net_device *dev,
5336 struct iw_request_info *info,
5337 union iwreq_data *wrqu,
5338 char *extra)
5339{
5340 int ret;
5341
5342 vos_ssr_protect(__func__);
5343 ret = __iw_set_mlme(dev, info, wrqu, extra);
5344 vos_ssr_unprotect(__func__);
5345
5346 return ret;
5347}
5348
Jeff Johnson295189b2012-06-20 16:38:30 -07005349/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305350static int __iw_setint_getnone(struct net_device *dev,
5351 struct iw_request_info *info,
5352 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005353{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305354 hdd_adapter_t *pAdapter;
5355 tHalHandle hHal;
5356 hdd_wext_state_t *pWextState;
5357 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 int *value = (int *)extra;
5359 int sub_cmd = value[0];
5360 int set_value = value[1];
5361 int ret = 0; /* success */
5362 int enable_pbm, enable_mp;
5363#ifdef CONFIG_HAS_EARLYSUSPEND
5364 v_U8_t nEnableSuspendOld;
5365#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005366
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305367 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305368 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5369 if (NULL == pAdapter)
5370 {
5371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5372 "%s: Adapter is NULL",__func__);
5373 return -EINVAL;
5374 }
5375 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5376 ret = wlan_hdd_validate_context(pHddCtx);
5377 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005378 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305379 return ret;
5380 }
5381 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5382 if (NULL == hHal)
5383 {
5384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5385 "%s: Hal Context is NULL",__func__);
5386 return -EINVAL;
5387 }
5388 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5389 if (NULL == pWextState)
5390 {
5391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5392 "%s: pWextState is NULL",__func__);
5393 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005394 }
5395
c_hpothu4a298be2014-12-22 21:12:51 +05305396 INIT_COMPLETION(pWextState->completion_var);
5397
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 switch(sub_cmd)
5399 {
5400 case WE_SET_11D_STATE:
5401 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005402 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005403 memset(&smeConfig, 0x00, sizeof(smeConfig));
5404
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5406
5407 sme_GetConfigParam(hHal,&smeConfig);
5408 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5409
Arif Hussain6d2a3322013-11-17 19:50:10 -08005410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005411
5412 sme_UpdateConfig(hHal,&smeConfig);
5413 }
5414 else {
5415 return -EINVAL;
5416 }
5417 break;
5418 }
5419
5420 case WE_WOWL:
5421 {
5422 switch (set_value)
5423 {
5424 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305425 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 break;
5427 case 0x01:
5428 case 0x02:
5429 case 0x03:
5430 enable_mp = (set_value & 0x01) ? 1 : 0;
5431 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005432 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5434 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5435 break;
5436 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005437 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 ret = -EINVAL;
5439 break;
5440 }
5441
5442 break;
5443 }
5444 case WE_SET_POWER:
5445 {
5446 switch (set_value)
5447 {
5448 case 0: //Full Power
5449 {
5450 struct statsContext context;
5451 eHalStatus status;
5452
5453 init_completion(&context.completion);
5454
5455 context.pAdapter = pAdapter;
5456 context.magic = POWER_CONTEXT_MAGIC;
5457
5458 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5459 iw_power_callback_fn, &context,
5460 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005461 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 {
5463 int lrc = wait_for_completion_interruptible_timeout(
5464 &context.completion,
5465 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005466
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 if (lrc <= 0)
5468 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005469 hddLog(VOS_TRACE_LEVEL_ERROR,
5470 "%s: SME %s while requesting fullpower",
5471 __func__, (0 == lrc) ?
5472 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 }
5474 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005475 /* either we have a response or we timed out. if we timed
5476 out there is a race condition such that the callback
5477 function could be executing at the same time we are. of
5478 primary concern is if the callback function had already
5479 verified the "magic" but had not yet set the completion
5480 variable when a timeout occurred. we serialize these
5481 activities by invalidating the magic while holding a
5482 shared spinlock which will cause us to block if the
5483 callback is currently executing */
5484 spin_lock(&hdd_context_lock);
5485 context.magic = 0;
5486 spin_unlock(&hdd_context_lock);
5487
Arif Hussain6d2a3322013-11-17 19:50:10 -08005488 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 break;
5490 }
5491 case 1: //Enable BMPS
5492 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5493 break;
5494 case 2: //Disable BMPS
5495 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5496 break;
5497 case 3: //Request Bmps
5498 {
5499 struct statsContext context;
5500 eHalStatus status;
5501
5502 init_completion(&context.completion);
5503
5504 context.pAdapter = pAdapter;
5505 context.magic = POWER_CONTEXT_MAGIC;
5506
5507 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5508 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005509 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 {
5511 int lrc = wait_for_completion_interruptible_timeout(
5512 &context.completion,
5513 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 if (lrc <= 0)
5515 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005516 hddLog(VOS_TRACE_LEVEL_ERROR,
5517 "%s: SME %s while requesting BMPS",
5518 __func__, (0 == lrc) ? "timeout" :
5519 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 }
5521 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005522 /* either we have a response or we timed out. if we
5523 timed out there is a race condition such that the
5524 callback function could be executing at the same
5525 time we are. of primary concern is if the callback
5526 function had already verified the "magic" but had
5527 not yet set the completion variable when a timeout
5528 occurred. we serialize these activities by
5529 invalidating the magic while holding a shared
5530 spinlock which will cause us to block if the
5531 callback is currently executing */
5532 spin_lock(&hdd_context_lock);
5533 context.magic = 0;
5534 spin_unlock(&hdd_context_lock);
5535
Arif Hussain6d2a3322013-11-17 19:50:10 -08005536 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 break;
5538 }
5539 case 4: //Enable IMPS
5540 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5541 break;
5542 case 5: //Disable IMPS
5543 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5544 break;
5545 case 6: //Enable Standby
5546 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5547 break;
5548 case 7: //Disable Standby
5549 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5550 break;
5551 case 8: //Request Standby
5552#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005553#endif
5554 break;
5555 case 9: //Start Auto Bmps Timer
5556 sme_StartAutoBmpsTimer(hHal);
5557 break;
5558 case 10://Stop Auto BMPS Timer
5559 sme_StopAutoBmpsTimer(hHal);
5560 break;
5561#ifdef CONFIG_HAS_EARLYSUSPEND
5562 case 11://suspend to standby
5563#ifdef CONFIG_HAS_EARLYSUSPEND
5564 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5565 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5567#endif
5568 break;
5569 case 12://suspend to deep sleep
5570#ifdef CONFIG_HAS_EARLYSUSPEND
5571 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5572 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5574#endif
5575 break;
5576 case 13://resume from suspend
5577#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005578#endif
5579 break;
5580#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005582 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 ret = -EINVAL;
5584 break;
5585 }
5586 break;
5587 }
5588
5589 case WE_SET_MAX_ASSOC:
5590 {
5591 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5592 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5593 {
5594 ret = -EINVAL;
5595 }
5596 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5597 set_value, NULL, eANI_BOOLEAN_FALSE)
5598 != eHAL_STATUS_SUCCESS )
5599 {
c_hpothub8245442013-11-20 23:41:09 +05305600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5601 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 ret = -EIO;
5603 }
5604 break;
5605 }
5606
5607 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5608 {
5609 if( 0 == set_value )
5610 {
5611 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5612 }
5613 else if ( 1 == set_value )
5614 {
5615 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5616 }
5617 else
5618 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005619 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 ret = -EINVAL;
5621 }
5622 break;
5623 }
5624
5625 case WE_SET_DATA_INACTIVITY_TO:
5626 {
5627 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5628 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5629 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5630 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5631 set_value,
5632 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5633 {
5634 hddLog(LOGE,"Failure: Could not pass on "
5635 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005636 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 ret = -EINVAL;
5638 }
5639 break;
5640 }
5641 case WE_SET_MAX_TX_POWER:
5642 {
5643 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5644 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5645
5646 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5647 __func__, set_value);
5648 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5649 eHAL_STATUS_SUCCESS )
5650 {
5651 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5652 __func__);
5653 return -EIO;
5654 }
5655
5656 break;
5657 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005658 case WE_SET_MAX_TX_POWER_2_4:
5659 {
5660 hddLog(VOS_TRACE_LEVEL_INFO,
5661 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5662 __func__, set_value);
5663 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5664 eHAL_STATUS_SUCCESS)
5665 {
5666 hddLog(VOS_TRACE_LEVEL_ERROR,
5667 "%s: Setting maximum tx power failed for 2.4 GHz band",
5668 __func__);
5669 return -EIO;
5670 }
5671
5672 break;
5673 }
5674 case WE_SET_MAX_TX_POWER_5_0:
5675 {
5676 hddLog(VOS_TRACE_LEVEL_INFO,
5677 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5678 __func__, set_value);
5679 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5680 eHAL_STATUS_SUCCESS)
5681 {
5682 hddLog(VOS_TRACE_LEVEL_ERROR,
5683 "%s: Setting maximum tx power failed for 5.0 GHz band",
5684 __func__);
5685 return -EIO;
5686 }
5687
5688 break;
5689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 case WE_SET_HIGHER_DTIM_TRANSITION:
5691 {
5692 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5693 (set_value == eANI_BOOLEAN_TRUE)))
5694 {
5695 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5696 ret = -EINVAL;
5697 }
5698 else
5699 {
5700 if(pAdapter->higherDtimTransition != set_value)
5701 {
5702 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005703 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 }
5705 }
5706
5707 break;
5708 }
5709
5710 case WE_SET_TM_LEVEL:
5711 {
5712 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005713 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5715
5716 break;
5717 }
5718
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305719 case WE_ENABLE_STRICT_FCC_REG:
5720 {
5721 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5722 struct wiphy *wiphy = NULL;
5723 long lrc;
5724 int status;
5725
5726 wiphy = hddCtxt->wiphy;
5727 if(wiphy == NULL)
5728 {
5729 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5730 break;
5731 }
5732 init_completion(&hddCtxt->wiphy_channel_update_event);
5733
5734 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5735
5736 status = regulatory_hint(wiphy, "00");
5737 if(status < 0)
5738 {
5739 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5740 break;
5741 }
5742
5743 /* Wait for completion */
5744 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5745 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5746 if (lrc <= 0)
5747 {
5748 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5749 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5750 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5751 }
5752 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5753
5754 break;
5755 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005756 case WE_SET_DEBUG_LOG:
5757 {
5758 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5759 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5760 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5761 break;
5762 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305763#ifdef FEATURE_WLAN_TDLS
5764 case WE_SET_TDLS_OFF_CHAN:
5765 {
5766 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5768 __func__, set_value);
5769 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5770 break;
5771 }
5772 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5773 {
5774 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5776 __func__, set_value);
5777 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5778 break;
5779 }
5780 case WE_SET_TDLS_OFF_CHAN_MODE:
5781 {
5782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5783 __func__, set_value);
5784 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5785 break;
5786 }
5787#endif
Peng Xu2446a892014-09-05 17:21:18 +05305788 case WE_SET_SCAN_BAND_PREFERENCE:
5789 {
5790 tSmeConfigParams smeConfig;
5791 memset(&smeConfig, 0x00, sizeof(smeConfig));
5792 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5793 ret = -EINVAL;
5794 break;
5795 }
5796 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5797
5798 if (eCSR_BAND_ALL == set_value ||
5799 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5800 sme_GetConfigParam(hHal, &smeConfig);
5801 smeConfig.csrConfig.scanBandPreference = set_value;
5802
5803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5804 "set band scan preference = %d\n",
5805 smeConfig.csrConfig.scanBandPreference);
5806
5807 sme_UpdateConfig(hHal, &smeConfig);
5808 }
5809 else {
5810 ret = -EINVAL;
5811 }
5812 break;
5813 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305814 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5815 * connection happens so that the params can take effect during
5816 * association. Also this should not be used in STA+p2p concurrency
5817 * as the param will also effect the STA mode.
5818 */
5819 case WE_SET_MIRACAST_VENDOR_CONFIG:
5820 {
5821 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305822
Abhishek Singh01c73d12015-03-12 15:13:44 +05305823 hddLog(LOG1, FL(
5824 "Set Miracast vendor tuning %d"), set_value);
5825
5826 if (1 == set_value || 0 == set_value)
5827 {
5828 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5829 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5830 {
5831 hddLog( LOGE, FL("set vendor miracast config failed"));
5832 ret = -EIO;
5833 }
5834 }
5835 else
5836 {
5837 hddLog(LOGE,
5838 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5839 ret = -EINVAL;
5840 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305841 break;
5842 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305843
5844 case WE_GET_FRAME_LOG:
5845 {
5846 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5847 != VOS_STATUS_SUCCESS)
5848 {
5849 ret = -EINVAL;
5850 }
5851 break;
5852 }
5853
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305854 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5855 {
5856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5857 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5858 if (set_value == 0 || set_value == 1)
5859 {
5860 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5861 set_value);
5862 }
5863 else
5864 ret = -EINVAL;
5865
5866 break;
5867 }
5868
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 default:
5870 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005871 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 sub_cmd, set_value);
5873 break;
5874 }
5875 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305876 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 return ret;
5878}
5879
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305880static int iw_setint_getnone(struct net_device *dev,
5881 struct iw_request_info *info,
5882 union iwreq_data *wrqu, char *extra)
5883{
5884 int ret;
5885
5886 vos_ssr_protect(__func__);
5887 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5888 vos_ssr_unprotect(__func__);
5889
5890 return 0;
5891}
Jeff Johnson295189b2012-06-20 16:38:30 -07005892/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305893static int __iw_setchar_getnone(struct net_device *dev,
5894 struct iw_request_info *info,
5895 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005896{
5897 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305898 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005900 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305901 hdd_adapter_t *pAdapter;
5902 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005903#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305904 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005905#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305906 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305907 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005908
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305909 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305910 pAdapter = (netdev_priv(dev));
5911 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005912 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5914 "%s: Adapter is NULL",__func__);
5915 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005916 }
5917
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305918 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5919 ret = wlan_hdd_validate_context(pHddCtx);
5920 if (0 != ret)
5921 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305922 return ret;
5923 }
5924#ifdef WLAN_FEATURE_VOWIFI
5925 pConfig = pHddCtx->cfg_ini;
5926#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305927 /* helper function to get iwreq_data with compat handling. */
5928 if (hdd_priv_get_data(&s_priv_data, wrqu))
5929 {
5930 return -EINVAL;
5931 }
5932
5933 /* make sure all params are correctly passed to function */
5934 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5935 {
5936 return -EINVAL;
5937 }
5938
5939 sub_cmd = s_priv_data.flags;
5940
Arif Hussain0273cba2014-01-07 20:58:29 -08005941 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305942 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5943 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005944 if (NULL == pBuffer)
5945 {
5946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5947 "mem_alloc_copy_from_user_helper fail");
5948 return -ENOMEM;
5949 }
5950
5951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305952 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5954 "%s: Received data %s", __func__, pBuffer);
5955
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 switch(sub_cmd)
5957 {
5958 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005960 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 break;
5962 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005964 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 break;
5966#if defined WLAN_FEATURE_VOWIFI
5967 case WE_NEIGHBOR_REPORT_REQUEST:
5968 {
5969 tRrmNeighborReq neighborReq;
5970 tRrmNeighborRspCallbackInfo callbackInfo;
5971
5972 if (pConfig->fRrmEnable)
5973 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305975 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 if( !neighborReq.no_ssid )
5977 {
Girish Gowli552fc072014-06-14 18:26:16 +05305978 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005979 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 }
5981
5982 callbackInfo.neighborRspCallback = NULL;
5983 callbackInfo.neighborRspCallbackContext = NULL;
5984 callbackInfo.timeout = 5000; //5 seconds
5985 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5986 }
5987 else
5988 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005989 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 ret = -EINVAL;
5991 }
5992 }
5993 break;
5994#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 case WE_SET_AP_WPS_IE:
5996 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05305997 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08006000 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07006001 if (VOS_STATUS_SUCCESS != vstatus)
6002 {
6003 ret = -EINVAL;
6004 }
6005 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306006 case WE_SET_ENCRYPT_MSG:
6007 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6008 if (NULL == pkt)
6009 {
6010 hddLog(VOS_TRACE_LEVEL_ERROR,
6011 "%s: vos_mem_alloc failed", __func__);
6012 return -ENOMEM;
6013 }
6014
6015 memset(pkt, 0, sizeof(tSirpkt80211));
6016
6017 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6018 hddLog(VOS_TRACE_LEVEL_ERROR,
6019 FL("Firmware is not DISA capable"));
6020 ret = -EINVAL;
6021 vos_mem_free(pkt);
6022 break;
6023 }
6024
6025 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6026
6027 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6028 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6029 if (eHAL_STATUS_SUCCESS != ret) {
6030 hddLog(VOS_TRACE_LEVEL_ERROR,
6031 FL("SENDEncryptMSG: fail to post WDA cmd"));
6032 ret = -EINVAL;
6033 }
6034 vos_mem_free(pkt);
6035
6036 break;
6037
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 default:
6039 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006040 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 ret = -EINVAL;
6042 break;
6043 }
6044 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006045 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306046
6047 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 return ret;
6049}
6050
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306051static int iw_setchar_getnone(struct net_device *dev,
6052 struct iw_request_info *info,
6053 union iwreq_data *wrqu, char *extra)
6054{
6055 int ret;
6056
6057 vos_ssr_protect(__func__);
6058 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6059 vos_ssr_unprotect(__func__);
6060
6061 return ret;
6062}
6063
Jeff Johnson295189b2012-06-20 16:38:30 -07006064/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306065static int __iw_setnone_getint(struct net_device *dev,
6066 struct iw_request_info *info,
6067 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006068{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306069 hdd_adapter_t *pAdapter;
6070 tHalHandle hHal;
6071 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 int *value = (int *)extra;
6073 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05306074 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006075
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306076 ENTER();
6077
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306078 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6079 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006080 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6082 "%s: Adapter is NULL",__func__);
6083 return -EINVAL;
6084 }
6085 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6086 ret = wlan_hdd_validate_context(pHddCtx);
6087 if (0 != ret)
6088 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306089 return ret;
6090 }
6091 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6092 if (NULL == hHal)
6093 {
6094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6095 "%s: Hal Context is NULL",__func__);
6096 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006098
6099 switch (value[0])
6100 {
6101 case WE_GET_11D_STATE:
6102 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006103 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306105
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6107
Arif Hussain6d2a3322013-11-17 19:50:10 -08006108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006109
6110 break;
6111 }
6112
6113 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 break;
6116
6117 case WE_PMC_STATE:
6118 {
6119 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006120 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 break;
6122 }
6123 case WE_GET_WLAN_DBG:
6124 {
6125 vos_trace_display();
6126 *value = 0;
6127 break;
6128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 case WE_GET_MAX_ASSOC:
6130 {
6131 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6132 {
c_hpothub8245442013-11-20 23:41:09 +05306133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6134 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 ret = -EIO;
6136 }
Girish Gowli385be612014-09-18 11:17:20 +05306137#ifdef WLAN_SOFTAP_VSTA_FEATURE
6138 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6139 {
6140 if (*value > VSTA_NUM_ASSOC_STA)
6141 {
6142 *value = VSTA_NUM_ASSOC_STA;
6143 }
6144 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6145 (*value > (VSTA_NUM_ASSOC_STA -
6146 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6147 {
6148 *value = (VSTA_NUM_ASSOC_STA -
6149 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6150 }
6151 }
6152 else
6153#endif
6154 {
6155 if (*value > NUM_ASSOC_STA)
6156 {
6157 *value = NUM_ASSOC_STA;
6158 }
6159 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6160 (*value > (NUM_ASSOC_STA -
6161 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6162 {
6163 *value = (NUM_ASSOC_STA -
6164 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6165 }
6166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 break;
6168 }
6169
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 case WE_GET_WDI_DBG:
6171 {
6172 wpalTraceDisplay();
6173 *value = 0;
6174 break;
6175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006176
6177 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6178 {
6179 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6180 break;
6181 }
6182 case WE_GET_CONCURRENCY_MODE:
6183 {
6184 *value = hdd_get_concurrency_mode ( );
6185
Arif Hussain6d2a3322013-11-17 19:50:10 -08006186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 break;
6188 }
6189
Peng Xu2446a892014-09-05 17:21:18 +05306190 case WE_GET_SCAN_BAND_PREFERENCE:
6191 {
6192 sme_GetConfigParam(hHal, &smeConfig);
6193 *value = smeConfig.csrConfig.scanBandPreference;
6194
6195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6196 "scanBandPreference = %d\n", *value);
6197 break;
6198 }
6199
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 default:
6201 {
6202 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6203 break;
6204 }
6205 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306206 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 return ret;
6208}
6209
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306210static int iw_setnone_getint(struct net_device *dev,
6211 struct iw_request_info *info,
6212 union iwreq_data *wrqu, char *extra)
6213{
6214 int ret;
6215
6216 vos_ssr_protect(__func__);
6217 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6218 vos_ssr_unprotect(__func__);
6219
6220 return ret;
6221
6222}
Jeff Johnson295189b2012-06-20 16:38:30 -07006223/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306224int __iw_set_three_ints_getnone(struct net_device *dev,
6225 struct iw_request_info *info,
6226 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006227{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306228 hdd_adapter_t *pAdapter;
6229 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 int *value = (int *)extra;
6231 int sub_cmd = value[0];
6232 int ret = 0;
6233
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306234 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306235 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6236 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006237 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6239 "%s: Adapter is NULL",__func__);
6240 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006241 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306242 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6243 ret = wlan_hdd_validate_context(pHddCtx);
6244 if (0 != ret)
6245 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306246 return ret;
6247 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006248 switch(sub_cmd)
6249 {
6250 case WE_SET_WLAN_DBG:
6251 {
6252 vos_trace_setValue( value[1], value[2], value[3]);
6253 break;
6254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 case WE_SET_WDI_DBG:
6256 {
6257 wpalTraceSetLevel( value[1], value[2], value[3]);
6258 break;
6259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 case WE_SET_SAP_CHANNELS:
6261 {
6262 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6263 break;
6264 }
6265
6266 default:
6267 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006268 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 break;
6270 }
6271 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306272 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 return ret;
6274}
6275
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306276int iw_set_three_ints_getnone(struct net_device *dev,
6277 struct iw_request_info *info,
6278 union iwreq_data *wrqu, char *extra)
6279{
6280 int ret;
6281
6282 vos_ssr_protect(__func__);
6283 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6284 vos_ssr_unprotect(__func__);
6285
6286 return ret;
6287}
6288
6289static int __iw_get_char_setnone(struct net_device *dev,
6290 struct iw_request_info *info,
6291 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006292{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306293 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306295 hdd_context_t *pHddCtx;
6296 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006297#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006298 hdd_wext_state_t *pWextState;
6299#endif
6300
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306301 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306302 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006303 if (pAdapter == NULL)
6304 {
6305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6306 "%s: pAdapter is NULL!", __func__);
6307 return -EINVAL;
6308 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306309 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6310 ret = wlan_hdd_validate_context(pHddCtx);
6311 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006312 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306313 return ret;
6314 }
6315#ifdef WLAN_FEATURE_11W
6316 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6317 if (NULL == pWextState)
6318 {
6319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6320 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006321 return -EINVAL;
6322 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306323#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006324
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 switch(sub_cmd)
6326 {
6327 case WE_WLAN_VERSION:
6328 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006329 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 break;
6331 }
6332
6333 case WE_GET_STATS:
6334 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306335 tHalHandle hHal = NULL;
6336 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6338 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6339 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6340
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306341
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 snprintf(extra, WE_MAX_STR_LEN,
6343 "\nTransmit"
6344 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6345 "\n dropped BK %u, BE %u, VI %u, VO %u"
6346 "\n classified BK %u, BE %u, VI %u, VO %u"
6347 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6348 "\n queued BK %u, BE %u, VI %u, VO %u"
6349 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006350 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 "\n fetched BK %u, BE %u, VI %u, VO %u"
6352 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6353 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006354 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 "\n flushed BK %u, BE %u, VI %u, VO %u"
6356 "\n\nReceive"
6357 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6358 "\n\nResetsStats"
6359 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6360 "\n",
6361 pStats->txXmitCalled,
6362 pStats->txXmitDropped,
6363 pStats->txXmitBackPressured,
6364 pStats->txXmitQueued,
6365
6366 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6367 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6368 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6369 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6370
6371 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6372 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6373 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6374 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6375
6376 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6377 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6378 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6379 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6380
6381 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6382 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6383 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6384 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6385
6386 pStats->txFetched,
6387 pStats->txFetchEmpty,
6388 pStats->txFetchLowResources,
6389 pStats->txFetchDequeueError,
6390
6391 pStats->txFetchDequeued,
6392 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006393 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006394 pStats->txCompleted,
6395 pStats->txFlushed,
6396
6397 pStats->txFetchedAC[WLANTL_AC_BK],
6398 pStats->txFetchedAC[WLANTL_AC_BE],
6399 pStats->txFetchedAC[WLANTL_AC_VI],
6400 pStats->txFetchedAC[WLANTL_AC_VO],
6401
6402 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6403 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6404 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6405 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6406
6407 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6408 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6409 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6410 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6411
Ravi Joshi41914632013-10-21 23:02:21 -07006412 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6413 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6414 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6415 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6416
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 pStats->txFlushedAC[WLANTL_AC_BK],
6418 pStats->txFlushedAC[WLANTL_AC_BE],
6419 pStats->txFlushedAC[WLANTL_AC_VI],
6420 pStats->txFlushedAC[WLANTL_AC_VO],
6421
6422 pStats->rxChains,
6423 pStats->rxPackets,
6424 pStats->rxDropped,
6425 pStats->rxDelivered,
6426 pStats->rxRefused,
6427
6428 pResetStats->totalLogpResets,
6429 pResetStats->totalCMD53Failures,
6430 pResetStats->totalMutexReadFailures,
6431 pResetStats->totalMIFErrorFailures,
6432 pResetStats->totalFWHearbeatFailures,
6433 pResetStats->totalUnknownExceptions
6434 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306435 wrqu->data.length = strlen(extra);
6436
6437 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6438
6439 if (hHal)
6440 pMac = PMAC_STRUCT( hHal );
6441
6442 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6443 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6444 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306445 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6446 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6447 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6448 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306449 "\n",
6450 pMac->pmm.BmpscntSleep,
6451 pMac->pmm.BmpscntAwake,
6452 pMac->pmm.BmpsSleeReqFailCnt,
6453 pMac->pmm.BmpsWakeupReqFailCnt,
6454 pMac->pmm.ImpsCntSleep,
6455 pMac->pmm.ImpsCntAwake,
6456 pMac->pmm.ImpsSleepErrCnt,
6457 pMac->pmm.ImpsWakeupErrCnt,
6458 pMac->pmm.ImpsLastErr
6459 );
6460 }
6461
Jeff Johnson295189b2012-06-20 16:38:30 -07006462 wrqu->data.length = strlen(extra)+1;
6463 break;
6464 }
6465
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306466/* The case prints the current state of the HDD, SME, CSR, PE, TL
6467 *it can be extended for WDI Global State as well.
6468 *And currently it only checks P2P_CLIENT adapter.
6469 *P2P_DEVICE and P2P_GO have not been added as of now.
6470*/
6471 case WE_GET_STATES:
6472 {
6473 int buf = 0, len = 0;
6474 int adapter_num = 0;
6475 int count = 0, check = 1;
6476
6477 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006478 tHalHandle hHal = NULL;
6479 tpAniSirGlobal pMac = NULL;
6480 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306481
6482 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6483 hdd_adapter_t *useAdapter = NULL;
6484
6485 /* Print wlan0 or p2p0 states based on the adapter_num
6486 *by using the correct adapter
6487 */
6488 while ( adapter_num < 2 )
6489 {
6490 if ( WLAN_ADAPTER == adapter_num )
6491 {
6492 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006493 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306494 "\n\n wlan0 States:-");
6495 len += buf;
6496 }
6497 else if ( P2P_ADAPTER == adapter_num )
6498 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006499 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306500 "\n\n p2p0 States:-");
6501 len += buf;
6502
6503 if( !pHddCtx )
6504 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006505 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306506 "\n pHddCtx is NULL");
6507 len += buf;
6508 break;
6509 }
6510
6511 /*Printing p2p0 states only in the case when the device is
6512 configured as a p2p_client*/
6513 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6514 if ( !useAdapter )
6515 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006516 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306517 "\n Device not configured as P2P_CLIENT.");
6518 len += buf;
6519 break;
6520 }
6521 }
6522
6523 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006524 if (!hHal) {
6525 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6526 "\n pMac is NULL");
6527 len += buf;
6528 break;
6529 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306530 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006531 if (!pMac) {
6532 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6533 "\n pMac is NULL");
6534 len += buf;
6535 break;
6536 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306537 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6538 if( !pHddStaCtx )
6539 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006540 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306541 "\n pHddStaCtx is NULL");
6542 len += buf;
6543 break;
6544 }
6545
6546 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6547
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006548 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306549 "\n HDD Conn State - %s "
6550 "\n \n SME State:"
6551 "\n Neighbour Roam State - %s"
6552 "\n CSR State - %s"
6553 "\n CSR Substate - %s"
6554 "\n \n TL STA %d State: %s",
6555 macTraceGetHDDWlanConnState(
6556 pHddStaCtx->conn_info.connState),
6557 macTraceGetNeighbourRoamState(
6558 pMac->roam.neighborRoamInfo.neighborRoamState),
6559 macTraceGetcsrRoamState(
6560 pMac->roam.curState[useAdapter->sessionId]),
6561 macTraceGetcsrRoamSubState(
6562 pMac->roam.curSubState[useAdapter->sessionId]),
6563 pHddStaCtx->conn_info.staId[0],
6564 macTraceGetTLState(tlState)
6565 );
6566 len += buf;
6567 adapter_num++;
6568 }
6569
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006570 if (pMac) {
6571 /* Printing Lim State starting with global lim states */
6572 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6573 "\n \n LIM STATES:-"
6574 "\n Global Sme State - %s "\
6575 "\n Global mlm State - %s "\
6576 "\n",
6577 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6578 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6579 );
6580 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306581
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006582 /*printing the PE Sme and Mlm states for valid lim sessions*/
6583 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306584 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006585 if ( pMac->lim.gpSession[count].valid )
6586 {
6587 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6588 "\n Lim Valid Session %d:-"
6589 "\n PE Sme State - %s "
6590 "\n PE Mlm State - %s "
6591 "\n",
6592 check,
6593 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6594 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6595 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306596
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006597 len += buf;
6598 check++;
6599 }
6600 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306601 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306602 }
6603
6604 wrqu->data.length = strlen(extra)+1;
6605 break;
6606 }
6607
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 case WE_GET_CFG:
6609 {
6610 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6611 wrqu->data.length = strlen(extra)+1;
6612 break;
6613 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006614#ifdef WLAN_FEATURE_11AC
6615 case WE_GET_RSSI:
6616 {
6617 v_S7_t s7Rssi = 0;
6618 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6619 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6620 wrqu->data.length = strlen(extra)+1;
6621 break;
6622 }
6623#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306624
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006625#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006626 case WE_GET_ROAM_RSSI:
6627 {
6628 v_S7_t s7Rssi = 0;
6629 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6630 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6631 wrqu->data.length = strlen(extra)+1;
6632 break;
6633 }
6634#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 case WE_GET_WMM_STATUS:
6636 {
6637 snprintf(extra, WE_MAX_STR_LEN,
6638 "\nDir: 0=up, 1=down, 3=both\n"
6639 "|------------------------|\n"
6640 "|AC | ACM |Admitted| Dir |\n"
6641 "|------------------------|\n"
6642 "|VO | %d | %3s | %d |\n"
6643 "|VI | %d | %3s | %d |\n"
6644 "|BE | %d | %3s | %d |\n"
6645 "|BK | %d | %3s | %d |\n"
6646 "|------------------------|\n",
6647 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6648 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6649 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6650 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6651 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6652 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6653 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6654 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6655 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6656 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6657 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6658 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6659
Jeff Johnsone7245742012-09-05 17:12:55 -07006660
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 wrqu->data.length = strlen(extra)+1;
6662 break;
6663 }
6664 case WE_GET_CHANNEL_LIST:
6665 {
6666 VOS_STATUS status;
6667 v_U8_t i, len;
6668 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306669 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6670 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6671 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 tChannelListInfo channel_list;
6673
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006674 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006676 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006678 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 return -EINVAL;
6680 }
6681 buf = extra;
6682
6683 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006684 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6685 * needed = 5 * number of channels. Check ifsufficient
6686 * buffer is available and then proceed to fill the buffer.
6687 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6689 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006690 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006691 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006692 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 return -EINVAL;
6694 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006695 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6696 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306697 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6698 {
6699 //Printing Country code in getChannelList
6700 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6701 {
6702 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6703 "%c ", pBuf[i]);
6704 }
6705 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006706 for(i = 0 ; i < channel_list.num_channels; i++)
6707 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006708 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 }
6711 wrqu->data.length = strlen(extra)+1;
6712
6713 break;
6714 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006715#ifdef FEATURE_WLAN_TDLS
6716 case WE_GET_TDLS_PEERS:
6717 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006718 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006719 break;
6720 }
6721#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006722#ifdef WLAN_FEATURE_11W
6723 case WE_GET_11W_INFO:
6724 {
6725 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6726
6727 snprintf(extra, WE_MAX_STR_LEN,
6728 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6729 "\n Number of Unprotected Disassocs %d"
6730 "\n Number of Unprotected Deauths %d",
6731 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6732 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6733 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6734 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6735 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6736
6737 wrqu->data.length = strlen(extra)+1;
6738 break;
6739 }
6740#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306741 case WE_GET_SNR:
6742 {
6743 v_S7_t s7snr = 0;
6744 int status = 0;
6745 hdd_context_t *pHddCtx;
6746 hdd_station_ctx_t *pHddStaCtx;
6747
6748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6749 status = wlan_hdd_validate_context(pHddCtx);
6750 if (0 != status)
6751 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306752 return status;
6753 }
6754
6755 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6756
6757 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6758 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6759 {
6760 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6761 " ConnectionState-%d", __func__,
6762 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6763 pHddStaCtx->conn_info.connState);
6764 return -ENONET;
6765 }
6766
6767 /*update the stats in TL*/
6768 wlan_hdd_get_station_stats(pAdapter);
6769 wlan_hdd_get_snr(pAdapter, &s7snr);
6770 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6771 wrqu->data.length = strlen(extra) + 1;
6772 break;
6773 }
6774
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306775 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006777 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 break;
6779 }
6780 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306781 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 return 0;
6783}
6784
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306785static int iw_get_char_setnone(struct net_device *dev,
6786 struct iw_request_info *info,
6787 union iwreq_data *wrqu, char *extra)
6788{
6789 int ret;
6790
6791 vos_ssr_protect(__func__);
6792 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6793 vos_ssr_unprotect(__func__);
6794
6795 return ret;
6796}
6797
Jeff Johnson295189b2012-06-20 16:38:30 -07006798/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306799static int __iw_setnone_getnone(struct net_device *dev,
6800 struct iw_request_info *info,
6801 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006802{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306803 hdd_adapter_t *pAdapter;
6804 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306805 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006806 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306807 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006808
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306809 ENTER();
6810
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306811 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6812 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006813 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6815 "%s: Adapter is NULL",__func__);
6816 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006817 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306818 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6819 ret = wlan_hdd_validate_context(pHddCtx);
6820 if (0 != ret)
6821 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306822 return ret;
6823 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306824 /* helper function to get iwreq_data with compat handling. */
6825 if (hdd_priv_get_data(&s_priv_data, wrqu))
6826 {
6827 return -EINVAL;
6828 }
6829
6830 sub_cmd = s_priv_data.flags;
6831
Jeff Johnson295189b2012-06-20 16:38:30 -07006832 switch (sub_cmd)
6833 {
6834 case WE_CLEAR_STATS:
6835 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006837 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6838 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6839 break;
6840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006841 case WE_INIT_AP:
6842 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306843 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6844
6845 /* As Soft AP mode might been changed to STA already with
6846 * killing of Hostapd, need to find the adpater by name
6847 * rather than mode */
6848 hdd_adapter_t* pAdapter_to_stop =
6849 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6850 if( pAdapter_to_stop )
6851 {
6852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6853 "Adapter with name softap.0 already "
6854 "exist, ignoring the request.\nRemove the "
6855 "adapter and try again\n");
6856 break;
6857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006858 pr_info("Init AP trigger\n");
6859 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6860 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6861 break;
6862 }
6863 case WE_STOP_AP:
6864 {
6865 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6866 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6867 * this is a dead code and need to find the adpater by name rather than mode */
6868 hdd_adapter_t* pAdapter_to_stop =
6869 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6870 if( pAdapter_to_stop )
6871 {
6872 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6873
6874 pr_info("Stopping AP mode\n");
6875
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306876 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6877 {
6878 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6879 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6880 }
6881
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306883 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306884 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6886
6887 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6888 pAdapter_to_stop->macAddressCurrent.bytes);
6889 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6890 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306891
6892 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6893 {
6894 /* put the device back into BMPS */
6895 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 }
6898 else
6899 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006900 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 }
6902
6903 break;
6904 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006905#ifdef WLAN_BTAMP_FEATURE
6906 case WE_ENABLE_AMP:
6907 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 WLANBAP_RegisterWithHCI(pAdapter);
6910 break;
6911 }
6912 case WE_DISABLE_AMP:
6913 {
6914 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6915 VOS_STATUS status;
6916
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006918
6919 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6920 status = WLANBAP_StopAmp();
6921 if(VOS_STATUS_SUCCESS != status )
6922 {
6923 pHddCtx->isAmpAllowed = VOS_TRUE;
6924 hddLog(VOS_TRACE_LEVEL_FATAL,
6925 "%s: Failed to stop AMP", __func__);
6926 }
6927 else
6928 {
6929 //a state m/c implementation in PAL is TBD to avoid this delay
6930 msleep(500);
6931 pHddCtx->isAmpAllowed = VOS_FALSE;
6932 WLANBAP_DeregisterFromHCI();
6933 }
6934
6935 break;
6936 }
6937#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006938 case WE_ENABLE_DXE_STALL_DETECT:
6939 {
schang6295e542013-03-12 15:31:23 -07006940 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6941 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006942 break;
6943 }
6944 case WE_DISPLAY_DXE_SNAP_SHOT:
6945 {
schang6295e542013-03-12 15:31:23 -07006946 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6947 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006948 break;
6949 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306950 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6951 {
6952 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6953 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306954 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306955 break;
6956 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306957
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306958 case WE_SET_REASSOC_TRIGGER:
6959 {
6960 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6961 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6962 v_U32_t roamId = 0;
6963 tCsrRoamModifyProfileFields modProfileFields;
6964 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6965 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6966 return 0;
6967 }
6968
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306969 case WE_STOP_OBSS_SCAN:
6970 {
6971 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6972 2.OBSS scan is stopped by Firmware during the disassociation
6973 3.OBSS stop comamnd is added for debugging purpose*/
6974 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6975 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006976
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306977 if (pAdapter == NULL)
6978 {
6979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6980 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306981 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306982 }
6983 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6984 if (pMac == NULL)
6985 {
6986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6987 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306988 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306989 }
6990 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6991 }
6992 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306993 case WE_DUMP_ROAM_TIMER_LOG:
6994 {
6995 vos_dump_roam_time_log_service();
6996 break;
6997 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306998
Mukul Sharma84f27252014-07-14 18:11:42 +05306999 case WE_RESET_ROAM_TIMER_LOG:
7000 {
7001 vos_reset_roam_timer_log();
7002 break;
7003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 default:
7005 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007006 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007007 break;
7008 }
7009 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307010 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 return ret;
7012}
7013
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307014static int iw_setnone_getnone(struct net_device *dev,
7015 struct iw_request_info *info,
7016 union iwreq_data *wrqu, char *extra)
7017{
7018 int ret;
7019
7020 vos_ssr_protect(__func__);
7021 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7022 vos_ssr_unprotect(__func__);
7023
7024 return ret;
7025}
7026
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307027void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7028{
7029 /*
7030 * Function to display HDD WMM information
7031 * for Tx Queues.
7032 * Prints globala as well as per client depending
7033 * whether the clients are registered or not.
7034 */
7035 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307036 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7037 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307038 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7039 hdd_ibss_peer_info_t *pPeerInfo;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307040
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307041 for ( i=0; i< NUM_TX_QUEUES; i++)
7042 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307043 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307044
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007045 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307046 i, pAdapter->wmm_tx_queue[i].count,
7047 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307048 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307049 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307050 if(pSapCtx == NULL){
7051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7052 FL("psapCtx is NULL"));
7053 return;
7054 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307055
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307056 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307057 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7058 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307059 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307060 {
7061 hddLog(LOGE, "******STAIndex: %d*********", i);
7062 for ( j=0; j< NUM_TX_QUEUES; j++)
7063 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307064 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007065 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307066 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
7067 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
7068 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
7069 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307070 }
7071 }
7072 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307073 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307074
Katya Nigam1fd24402015-02-16 14:52:19 +05307075 if(pHddStaCtx == NULL){
7076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7077 FL("pHddStaCtx is NULL"));
7078 return;
7079 }
7080
7081 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7082 if(pPeerInfo == NULL){
7083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7084 FL("ppeerinfo is NULL"));
7085 return;
7086 }
7087
7088 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7089 {
7090 if(pPeerInfo->ibssStaInfo[i].isUsed)
7091 {
7092 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7093 for ( j=0; j< NUM_TX_QUEUES; j++)
7094 {
7095 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7096 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7097 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7098 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7099 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7100 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7101 }
7102 }
7103 }
7104
7105
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307106}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307107static int __iw_set_var_ints_getnone(struct net_device *dev,
7108 struct iw_request_info *info,
7109 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007110{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307111 hdd_adapter_t *pAdapter;
7112 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307113 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307114 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007115 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307116 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007117 hdd_ap_ctx_t *pAPCtx = NULL;
7118 int cmd = 0;
7119 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307120 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007121
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307122 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307123 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307124 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7126 "%s: NULL extra buffer pointer", __func__);
7127 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307128 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307129 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7130 if (NULL == pAdapter)
7131 {
7132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7133 "%s: Adapter is NULL",__func__);
7134 return -EINVAL;
7135 }
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307136 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7137 ret = wlan_hdd_validate_context(pHddCtx);
7138 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007139 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307140 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007141 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307142 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7143 if (NULL == hHal)
7144 {
7145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7146 "%s: Hal Context is NULL",__func__);
7147 return -EINVAL;
7148 }
7149 sub_cmd = wrqu->data.flags;
7150
7151 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7152
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007153
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007154 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7155 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7156 {
7157 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7158 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7159 {
7160 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7161 staId = pStaCtx->conn_info.staId[0];
7162 }
7163 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7164 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7165 {
7166 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7167 staId = pAPCtx->uBCStaId;
7168 }
7169 else
7170 {
7171 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7172 return 0;
7173 }
7174 }
7175
Jeff Johnson295189b2012-06-20 16:38:30 -07007176 switch (sub_cmd)
7177 {
7178 case WE_LOG_DUMP_CMD:
7179 {
7180 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007181 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007182 apps_args[3], apps_args[4]);
7183
7184 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7185 apps_args[3], apps_args[4]);
7186
7187 }
7188 break;
7189
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 case WE_P2P_NOA_CMD:
7191 {
7192 p2p_app_setP2pPs_t p2pNoA;
7193
7194 p2pNoA.opp_ps = apps_args[0];
7195 p2pNoA.ctWindow = apps_args[1];
7196 p2pNoA.duration = apps_args[2];
7197 p2pNoA.interval = apps_args[3];
7198 p2pNoA.count = apps_args[4];
7199 p2pNoA.single_noa_duration = apps_args[5];
7200 p2pNoA.psSelection = apps_args[6];
7201
7202 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7203 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007204 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7206
7207 hdd_setP2pPs(dev, &p2pNoA);
7208
7209 }
7210 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007211
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307212 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7213 {
7214 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7215 __func__, apps_args[0], apps_args[1]);
7216 vosTraceEnable(apps_args[0], apps_args[1]);
7217 }
7218 break;
7219
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007220 case WE_MTRACE_DUMP_CMD:
7221 {
7222 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7223 "bitmask_of_module %d ",
7224 __func__, apps_args[0], apps_args[1], apps_args[2],
7225 apps_args[3]);
7226 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7227 apps_args[2], apps_args[3]);
7228
7229 }
7230 break;
7231
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007232 case WE_MCC_CONFIG_CREDENTIAL :
7233 {
7234 cmd = 287; //Command should be updated if there is any change
7235 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007236 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007237 {
7238 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7239 }
7240 else
7241 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007242 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007243 return 0;
7244 }
7245 }
7246 break;
7247
7248 case WE_MCC_CONFIG_PARAMS :
7249 {
7250 cmd = 288; //command Should be updated if there is any change
7251 // in the Riva dump command
7252 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7253 }
7254 break;
7255
Chilam NG571c65a2013-01-19 12:27:36 +05307256#ifdef FEATURE_WLAN_TDLS
7257 case WE_TDLS_CONFIG_PARAMS :
7258 {
7259 tdls_config_params_t tdlsParams;
7260
Chilam Ng01120412013-02-19 18:32:21 -08007261 tdlsParams.tdls = apps_args[0];
7262 tdlsParams.tx_period_t = apps_args[1];
7263 tdlsParams.tx_packet_n = apps_args[2];
7264 tdlsParams.discovery_period_t = apps_args[3];
7265 tdlsParams.discovery_tries_n = apps_args[4];
7266 tdlsParams.idle_timeout_t = apps_args[5];
7267 tdlsParams.idle_packet_n = apps_args[6];
7268 tdlsParams.rssi_hysteresis = apps_args[7];
7269 tdlsParams.rssi_trigger_threshold = apps_args[8];
7270 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307271
Chilam Ng01120412013-02-19 18:32:21 -08007272 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307273 }
7274 break;
7275#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 default:
7277 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007278 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7279 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 }
7281 break;
7282 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307283 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 return 0;
7285}
7286
Girish Gowlifb9758e2014-11-19 15:19:17 +05307287static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7288 struct iw_request_info *info,
7289 union iwreq_data *wrqu, char *extra)
7290{
7291 int ret;
7292 union iwreq_data u_priv_wrqu;
7293 int apps_args[MAX_VAR_ARGS] = {0};
7294 int num_args;
7295
7296 /* helper function to get iwreq_data with compat handling. */
7297 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7298 {
7299 return -EINVAL;
7300 }
7301
7302 if (NULL == u_priv_wrqu.data.pointer)
7303 {
7304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7305 "%s: NULL data pointer", __func__);
7306 return -EINVAL;
7307 }
7308
7309 num_args = u_priv_wrqu.data.length;
7310 if (num_args > MAX_VAR_ARGS)
7311 {
7312 num_args = MAX_VAR_ARGS;
7313 }
7314
7315 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7316 (sizeof(int)) * num_args))
7317 {
7318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7319 "%s: failed to copy data from user buffer", __func__);
7320 return -EFAULT;
7321 }
7322
7323 vos_ssr_protect(__func__);
7324 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7325 (char *)&apps_args);
7326 vos_ssr_unprotect(__func__);
7327
7328 return ret;
7329}
7330
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307331int iw_set_var_ints_getnone(struct net_device *dev,
7332 struct iw_request_info *info,
7333 union iwreq_data *wrqu, char *extra)
7334{
7335 int ret;
7336 vos_ssr_protect(__func__);
7337 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7338 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007339
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307340 return ret;
7341}
7342
7343static int __iw_add_tspec(struct net_device *dev,
7344 struct iw_request_info *info,
7345 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007346{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307347 hdd_adapter_t *pAdapter;
7348 hdd_station_ctx_t *pHddStaCtx;
7349 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007350 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7351 int params[HDD_WLAN_WMM_PARAM_COUNT];
7352 sme_QosWmmTspecInfo tSpec;
7353 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307354 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307355 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007356
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307357 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307358 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7359 if (NULL == pAdapter)
7360 {
7361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7362 "%s: Adapter is NULL",__func__);
7363 return -EINVAL;
7364 }
7365 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7366 ret = wlan_hdd_validate_context(pHddCtx);
7367 if (0 != ret)
7368 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307369 return ret;
7370 }
7371 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7372 if (NULL == pHddStaCtx)
7373 {
7374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7375 "%s: STA Context is NULL",__func__);
7376 return -EINVAL;
7377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007378 // make sure the application is sufficiently priviledged
7379 // note that the kernel will do this for "set" ioctls, but since
7380 // this ioctl wants to return status to user space it must be
7381 // defined as a "get" ioctl
7382 if (!capable(CAP_NET_ADMIN))
7383 {
7384 return -EPERM;
7385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 // we must be associated in order to add a tspec
7387 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7388 {
7389 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7390 return 0;
7391 }
7392
7393 // since we are defined to be a "get" ioctl, and since the number
7394 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307395 // will pass down in the iwreq_data, we must copy the "set" params.
7396 // We must handle the compat for iwreq_data in 32U/64K environment.
7397
7398 // helper fucntion to get iwreq_data with compat handling.
7399 if (hdd_priv_get_data(&s_priv_data, wrqu))
7400 {
7401 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7402 return 0;
7403 }
7404
7405 // make sure all params are correctly passed to function
7406 if ((NULL == s_priv_data.pointer) ||
7407 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7408 {
7409 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7410 return 0;
7411 }
7412
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307414 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 {
7416 // hmmm, can't get them
7417 return -EIO;
7418 }
7419
7420 // clear the tspec
7421 memset(&tSpec, 0, sizeof(tSpec));
7422
7423 // validate the handle
7424 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7425 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7426 {
7427 // that one is reserved
7428 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7429 return 0;
7430 }
7431
7432 // validate the TID
7433 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7434 {
7435 // out of range
7436 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7437 return 0;
7438 }
7439 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7440
7441 // validate the direction
7442 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7443 {
7444 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7445 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7446 break;
7447
7448 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7449 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7450 break;
7451
7452 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7453 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7454 break;
7455
7456 default:
7457 // unknown
7458 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7459 return 0;
7460 }
7461
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307462 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7463
Jeff Johnson295189b2012-06-20 16:38:30 -07007464 // validate the user priority
7465 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7466 {
7467 // out of range
7468 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7469 return 0;
7470 }
7471 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307472 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7473 {
7474 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7475 return 0;
7476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007477
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7479 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7480 tSpec.ts_info.psb, tSpec.ts_info.up);
7481
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7483 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7484 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7485 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7486 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7487 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7488 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7489 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7490 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7491 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7492 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7493 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7494
7495 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7496
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307497 // Save the expected UAPSD settings by application, this will be needed
7498 // when re-negotiating UAPSD settings during BT Coex cases.
7499 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7500
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 // validate the ts info ack policy
7502 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7503 {
7504 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7505 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7506 break;
7507
7508 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7509 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7510 break;
7511
7512 default:
7513 // unknown
7514 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7515 return 0;
7516 }
7517
7518 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307519
7520 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 return 0;
7522}
7523
7524
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307525static int iw_add_tspec(struct net_device *dev,
7526 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007527 union iwreq_data *wrqu, char *extra)
7528{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307529 int ret;
7530
7531 vos_ssr_protect(__func__);
7532 ret = __iw_add_tspec(dev, info, wrqu, extra);
7533 vos_ssr_unprotect(__func__);
7534
7535 return ret;
7536}
7537
7538static int __iw_del_tspec(struct net_device *dev,
7539 struct iw_request_info *info,
7540 union iwreq_data *wrqu, char *extra)
7541{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307542 hdd_adapter_t *pAdapter;
7543 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007544 int *params = (int *)extra;
7545 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7546 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307547 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007548
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307549 ENTER();
7550
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307551 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7552 if (NULL == pAdapter)
7553 {
7554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7555 "%s: Adapter is NULL",__func__);
7556 return -EINVAL;
7557 }
7558
7559 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7560 ret = wlan_hdd_validate_context(pHddCtx);
7561 if (0 != ret)
7562 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307563 return ret;
7564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 // make sure the application is sufficiently priviledged
7566 // note that the kernel will do this for "set" ioctls, but since
7567 // this ioctl wants to return status to user space it must be
7568 // defined as a "get" ioctl
7569 if (!capable(CAP_NET_ADMIN))
7570 {
7571 return -EPERM;
7572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 // although we are defined to be a "get" ioctl, the params we require
7574 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7575 // is no need to copy the params from user space
7576
7577 // validate the handle
7578 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7579 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7580 {
7581 // that one is reserved
7582 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7583 return 0;
7584 }
7585
7586 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307587
7588 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007589 return 0;
7590}
7591
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307592static int iw_del_tspec(struct net_device *dev,
7593 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007594 union iwreq_data *wrqu, char *extra)
7595{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307596 int ret;
7597
7598 vos_ssr_protect(__func__);
7599 ret = __iw_del_tspec(dev, info, wrqu, extra);
7600 vos_ssr_unprotect(__func__);
7601
7602 return ret;
7603}
7604
7605
7606static int __iw_get_tspec(struct net_device *dev,
7607 struct iw_request_info *info,
7608 union iwreq_data *wrqu, char *extra)
7609{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307610 hdd_adapter_t *pAdapter;
7611 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 int *params = (int *)extra;
7613 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7614 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307615 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007616
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307617 ENTER();
7618
Jeff Johnson295189b2012-06-20 16:38:30 -07007619 // although we are defined to be a "get" ioctl, the params we require
7620 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7621 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307622 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7623 if (NULL == pAdapter)
7624 {
7625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7626 "%s: Adapter is NULL",__func__);
7627 return -EINVAL;
7628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007629
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307630 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7631 ret = wlan_hdd_validate_context(pHddCtx);
7632 if (0 != ret)
7633 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307634 return ret;
7635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 // validate the handle
7637 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7638 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7639 {
7640 // that one is reserved
7641 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7642 return 0;
7643 }
7644
7645 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307646 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 return 0;
7648}
7649
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307650static int iw_get_tspec(struct net_device *dev,
7651 struct iw_request_info *info,
7652 union iwreq_data *wrqu, char *extra)
7653{
7654 int ret;
7655
7656 vos_ssr_protect(__func__);
7657 ret = __iw_get_tspec(dev, info, wrqu, extra);
7658 vos_ssr_unprotect(__func__);
7659
7660 return ret;
7661}
7662
Jeff Johnson295189b2012-06-20 16:38:30 -07007663#ifdef WLAN_FEATURE_VOWIFI_11R
7664//
7665//
7666// Each time the supplicant has the auth_request or reassoc request
7667// IEs ready. This is pushed to the driver. The driver will inturn use
7668// it to send out the auth req and reassoc req for 11r FT Assoc.
7669//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307670static int __iw_set_fties(struct net_device *dev,
7671 struct iw_request_info *info,
7672 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007673{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307674 hdd_adapter_t *pAdapter;
7675 hdd_station_ctx_t *pHddStaCtx;
7676 hdd_context_t *pHddCtx;
7677 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007678 //v_CONTEXT_t pVosContext;
7679
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307680 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307681 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7682 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007683 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7685 "%s: Adapter is NULL",__func__);
7686 return -EINVAL;
7687 }
7688 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7689 ret = wlan_hdd_validate_context(pHddCtx);
7690 if (0 != ret)
7691 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307692 return ret;
7693 }
7694 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7695 if (NULL == pHddStaCtx)
7696 {
7697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7698 "%s: STA Context is NULL",__func__);
7699 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 if (!wrqu->data.length)
7702 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007703 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 return -EINVAL;
7705 }
7706 if (wrqu->data.pointer == NULL)
7707 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007708 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 return -EINVAL;
7710 }
7711
7712 // Added for debug on reception of Re-assoc Req.
7713 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7714 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007715 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007716 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007717 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 }
7719
7720#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007721 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007722#endif
7723
7724 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007725 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007726 wrqu->data.length);
7727
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307728 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007729 return 0;
7730}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307731
7732static int iw_set_fties(struct net_device *dev,
7733 struct iw_request_info *info,
7734 union iwreq_data *wrqu, char *extra)
7735{
7736 int ret;
7737
7738 vos_ssr_protect(__func__);
7739 ret = __iw_set_fties(dev, info, wrqu, extra);
7740 vos_ssr_unprotect(__func__);
7741
7742 return ret;
7743}
Jeff Johnson295189b2012-06-20 16:38:30 -07007744#endif
7745
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307746static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007747 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007749{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307750 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007751 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307752 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007753 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307754 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007755 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7756 int idx;
7757 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007758
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307759 ENTER();
7760
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307761 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7762 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007763 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7765 "%s: Adapter is NULL",__func__);
7766 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007767 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307768 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7769 ret_val = wlan_hdd_validate_context(pHddCtx);
7770 if (0 != ret_val)
7771 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307772 return ret_val;
7773 }
7774 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7775 if (NULL == hHal)
7776 {
7777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7778 "%s: Hal Context is NULL",__func__);
7779 return -EINVAL;
7780 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307781 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7782 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307783#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007784
Amar Singhalf3a6e762013-02-19 15:06:50 -08007785 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7786 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007787 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007788 hddLog(VOS_TRACE_LEVEL_ERROR,
7789 "%s: vos_mem_alloc failed", __func__);
7790 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007791 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007792
7793 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7794
7795 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7796 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7797
7798 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7799 mc_addr_list_ptr->ulMulticastAddrCnt);
7800
7801 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007802 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007803 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7804 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7805
7806 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7807 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007808 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007809
Amar Singhalf3a6e762013-02-19 15:06:50 -08007810 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7811 vos_mem_free(mc_addr_list_ptr);
7812 if (eHAL_STATUS_SUCCESS != ret_val)
7813 {
7814 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7815 __func__);
7816 return -EINVAL;
7817 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307818#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307819 }
7820 else
7821 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007822
Amar Singhalf3a6e762013-02-19 15:06:50 -08007823 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7824 "%s: Set MC BC Filter Config request: %d suspend %d",
7825 __func__, pRequest->mcastBcastFilterSetting,
7826 pHddCtx->hdd_wlan_suspended);
7827
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307828 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007829
7830 if (pHddCtx->hdd_wlan_suspended)
7831 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007832 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7833 if (NULL == wlanRxpFilterParam)
7834 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307835 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007836 "%s: vos_mem_alloc failed", __func__);
7837 return -EINVAL;
7838 }
7839
Amar Singhalf3a6e762013-02-19 15:06:50 -08007840 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7841 pRequest->mcastBcastFilterSetting;
7842 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7843
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307844 hdd_conf_hostoffload(pAdapter, TRUE);
7845 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7846 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007847
7848 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7849 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307850 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007851 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7852 wlanRxpFilterParam->setMcstBcstFilter);
7853
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307854 if (eHAL_STATUS_SUCCESS !=
7855 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7856 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007857 {
7858 hddLog(VOS_TRACE_LEVEL_ERROR,
7859 "%s: Failure to execute set HW MC/BC Filter request",
7860 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007861 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007862 return -EINVAL;
7863 }
7864
c_hpothud3ce76d2014-10-28 10:34:13 +05307865 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7866 {
7867 pHddCtx->sus_res_mcastbcast_filter =
7868 pRequest->mcastBcastFilterSetting;
7869 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007870 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007872
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307873 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007874 return 0;
7875}
7876
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307877static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7878 struct iw_request_info *info,
7879 union iwreq_data *wrqu, char *extra)
7880{
7881 int ret;
7882
7883 vos_ssr_protect(__func__);
7884 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
7885 vos_ssr_unprotect(__func__);
7886
7887 return ret;
7888}
7889
7890static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7891 struct iw_request_info *info,
7892 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007893{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307894 hdd_adapter_t *pAdapter;
7895 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307896 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307897 int ret = 0;
7898
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307899 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007900
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307901 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7902 if (NULL == pAdapter)
7903 {
7904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7905 "%s: Adapter is NULL",__func__);
7906 return -EINVAL;
7907 }
7908
7909 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7910 ret = wlan_hdd_validate_context(pHddCtx);
7911 if (0 != ret)
7912 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307913 return ret;
7914 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307915 //Reset the filter to INI value as we have to clear the dynamic filter
7916 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07007917
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307918 //Configure FW with new setting
7919 if (pHddCtx->hdd_wlan_suspended)
7920 {
7921 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7922 if (NULL == wlanRxpFilterParam)
7923 {
7924 hddLog(VOS_TRACE_LEVEL_ERROR,
7925 "%s: vos_mem_alloc failed", __func__);
7926 return -EINVAL;
7927 }
7928
7929 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7930 pHddCtx->configuredMcastBcastFilter;
7931 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7932
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307933 hdd_conf_hostoffload(pAdapter, TRUE);
7934 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7935 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307936
7937 if (eHAL_STATUS_SUCCESS !=
7938 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7939 wlanRxpFilterParam))
7940 {
7941 hddLog(VOS_TRACE_LEVEL_ERROR,
7942 "%s: Failure to execute set HW MC/BC Filter request",
7943 __func__);
7944 vos_mem_free(wlanRxpFilterParam);
7945 return -EINVAL;
7946 }
c_hpothud3ce76d2014-10-28 10:34:13 +05307947
7948 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7949 {
7950 pHddCtx->sus_res_mcastbcast_filter =
7951 pHddCtx->cfg_ini->mcastBcastFilterSetting;
7952 }
7953
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307954 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307955 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 return 0;
7957}
7958
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307959
7960static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7961 struct iw_request_info *info,
7962 union iwreq_data *wrqu, char *extra)
7963{
7964 int ret;
7965
7966 vos_ssr_protect(__func__);
7967 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
7968 vos_ssr_unprotect(__func__);
7969
7970 return ret;
7971}
7972
7973static int __iw_set_host_offload(struct net_device *dev,
7974 struct iw_request_info *info,
7975 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007976{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307977 hdd_adapter_t *pAdapter;
7978 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007979 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307981 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007982
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307983 ENTER();
7984
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307985 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7986 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007987 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7989 "%s: Adapter is NULL",__func__);
7990 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007991 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307992 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7993 ret = wlan_hdd_validate_context(pHddCtx);
7994 if (0 != ret)
7995 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307996 return ret;
7997 }
7998
Jeff Johnson295189b2012-06-20 16:38:30 -07007999 /* Debug display of request components. */
8000 switch (pRequest->offloadType)
8001 {
8002 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008003 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008004 switch (pRequest->enableOrDisable)
8005 {
8006 case WLAN_OFFLOAD_DISABLE:
8007 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8008 break;
8009 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8010 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8011 case WLAN_OFFLOAD_ENABLE:
8012 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8013 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8014 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8015 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8016 }
8017 break;
8018
8019 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008020 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008021 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008022 switch (pRequest->enableOrDisable)
8023 {
8024 case WLAN_OFFLOAD_DISABLE:
8025 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8026 break;
8027 case WLAN_OFFLOAD_ENABLE:
8028 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8029 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8030 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8031 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8032 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8033 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8034 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8035 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8036 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8037 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8038 }
8039 }
8040
8041 /* Execute offload request. The reason that we can copy the request information
8042 from the ioctl structure to the SME structure is that they are laid out
8043 exactly the same. Otherwise, each piece of information would have to be
8044 copied individually. */
8045 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008046 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8047 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008049 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 __func__);
8051 return -EINVAL;
8052 }
8053
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308054 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008055 return 0;
8056}
8057
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308058static int iw_set_host_offload(struct net_device *dev,
8059 struct iw_request_info *info,
8060 union iwreq_data *wrqu, char *extra)
8061{
8062 int ret;
8063
8064 vos_ssr_protect(__func__);
8065 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8066 vos_ssr_unprotect(__func__);
8067
8068 return ret;
8069}
8070
8071static int __iw_set_keepalive_params(struct net_device *dev,
8072 struct iw_request_info *info,
8073 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008074{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308075 hdd_adapter_t *pAdapter;
8076 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008077 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308079 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008080
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308081 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308082 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8083 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008084 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8086 "%s: Adapter is NULL",__func__);
8087 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308089 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8090 ret = wlan_hdd_validate_context(pHddCtx);
8091 if (0 != ret)
8092 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308093 return ret;
8094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008095 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008096 hddLog(VOS_TRACE_LEVEL_INFO,
8097 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8098 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008099
8100 switch (pRequest->packetType)
8101 {
8102 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008103 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 break;
8105
8106 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8107
Arif Hussain6d2a3322013-11-17 19:50:10 -08008108 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008109 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008110
8111 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8112 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8113 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8114
8115 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8116 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8117 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8118
8119 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8120 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8121 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8122 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8123 break;
8124
8125 }
8126
8127 /* Execute keep alive request. The reason that we can copy the request information
8128 from the ioctl structure to the SME structure is that they are laid out
8129 exactly the same. Otherwise, each piece of information would have to be
8130 copied individually. */
8131 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8132
Arif Hussain6d2a3322013-11-17 19:50:10 -08008133 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008134
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008135 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008136 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008138 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 __func__);
8140 return -EINVAL;
8141 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308142 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 return 0;
8144}
8145
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308146static int iw_set_keepalive_params(struct net_device *dev,
8147 struct iw_request_info *info,
8148 union iwreq_data *wrqu, char *extra)
8149{
8150 int ret;
8151 vos_ssr_protect(__func__);
8152 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8153 vos_ssr_unprotect(__func__);
8154
8155 return ret;
8156}
8157
Jeff Johnson295189b2012-06-20 16:38:30 -07008158#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008159int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008160 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008161{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008162 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8163 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 int i=0;
8165
8166 if (pHddCtx->cfg_ini->disablePacketFilter)
8167 {
8168 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008169 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 return 0;
8171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008172 /* Debug display of request components. */
8173 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008174 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008175
8176 switch (pRequest->filterAction)
8177 {
8178 case HDD_RCV_FILTER_SET:
8179 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008180 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008181
8182 packetFilterSetReq.filterId = pRequest->filterId;
8183 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8184 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008185 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 __func__, pRequest->numParams);
8187 return -EINVAL;
8188 }
8189 packetFilterSetReq.numFieldParams = pRequest->numParams;
8190 packetFilterSetReq.coalesceTime = 0;
8191 packetFilterSetReq.filterType = 1;
8192 for (i=0; i < pRequest->numParams; i++)
8193 {
8194 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8195 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8196 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8197 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8198 packetFilterSetReq.paramsData[i].reserved = 0;
8199
Arif Hussain6d2a3322013-11-17 19:50:10 -08008200 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8202 packetFilterSetReq.filterType);
8203
Arif Hussain6d2a3322013-11-17 19:50:10 -08008204 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008205 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8206
8207 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8208 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8209 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8210 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8211
Arif Hussain6d2a3322013-11-17 19:50:10 -08008212 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008213 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8214 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8215 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8216
Arif Hussain6d2a3322013-11-17 19:50:10 -08008217 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8219 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8220 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8221 }
8222
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008223 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008224 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008225 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 __func__);
8227 return -EINVAL;
8228 }
8229
8230 break;
8231
8232 case HDD_RCV_FILTER_CLEAR:
8233
Arif Hussain6d2a3322013-11-17 19:50:10 -08008234 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008235 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008237 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008238 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008239 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 __func__);
8241 return -EINVAL;
8242 }
8243 break;
8244
8245 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008246 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008247 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008248 return -EINVAL;
8249 }
8250 return 0;
8251}
8252
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308253int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8254 tANI_U8 sessionId)
8255{
8256 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8257 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8258
8259 if (NULL == pHddCtx)
8260 {
8261 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8262 return -EINVAL;
8263 }
8264
8265 if (pHddCtx->isLogpInProgress)
8266 {
8267 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8268 "%s:LOGP in Progress. Ignore!!!", __func__);
8269 return -EBUSY;
8270 }
8271
8272 if (pHddCtx->cfg_ini->disablePacketFilter)
8273 {
8274 hddLog(VOS_TRACE_LEVEL_ERROR,
8275 "%s: Packet Filtering Disabled. Returning ",
8276 __func__ );
8277 return -EINVAL;
8278 }
8279
8280 switch (filterType)
8281 {
8282 /* For setting IPV6 MC and UC Filter we need to configure
8283 * 2 filters, one for MC and one for UC.
8284 * The Filter ID shouldn't be swapped, which results in making
8285 * UC Filter ineffective.
8286 * We have Hardcode all the values
8287 *
8288 * Reason for a seperate UC filter is because, driver need to
8289 * specify the FW that the specific filter is for unicast
8290 * otherwise FW will not pass the unicast frames by default
8291 * through the filter. This is required to avoid any performance
8292 * hits when no unicast filter is set and only MC/BC are set.
8293 * The way driver informs host is by using the MAC protocol
8294 * layer, CMP flag set to MAX, CMP Data set to 1.
8295 */
8296
8297 case HDD_FILTER_IPV6_MC_UC:
8298 /* Setting IPV6 MC Filter below
8299 */
8300 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8301 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8302 packetFilterSetReq.numFieldParams = 2;
8303 packetFilterSetReq.paramsData[0].protocolLayer =
8304 HDD_FILTER_PROTO_TYPE_MAC;
8305 packetFilterSetReq.paramsData[0].cmpFlag =
8306 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8307 packetFilterSetReq.paramsData[0].dataOffset =
8308 WLAN_HDD_80211_FRM_DA_OFFSET;
8309 packetFilterSetReq.paramsData[0].dataLength = 1;
8310 packetFilterSetReq.paramsData[0].compareData[0] =
8311 HDD_IPV6_MC_CMP_DATA;
8312
8313 packetFilterSetReq.paramsData[1].protocolLayer =
8314 HDD_FILTER_PROTO_TYPE_ARP;
8315 packetFilterSetReq.paramsData[1].cmpFlag =
8316 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8317 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8318 packetFilterSetReq.paramsData[1].dataLength = 2;
8319 packetFilterSetReq.paramsData[1].compareData[0] =
8320 HDD_IPV6_CMP_DATA_0;
8321 packetFilterSetReq.paramsData[1].compareData[1] =
8322 HDD_IPV6_CMP_DATA_1;
8323
8324
8325 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8326 &packetFilterSetReq, sessionId))
8327 {
8328 hddLog(VOS_TRACE_LEVEL_ERROR,
8329 "%s: Failure to execute Set IPv6 Mulicast Filter",
8330 __func__);
8331 return -EINVAL;
8332 }
8333
8334 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8335
8336 /*
8337 * Setting IPV6 UC Filter below
8338 */
8339 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8340 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8341 packetFilterSetReq.numFieldParams = 2;
8342 packetFilterSetReq.paramsData[0].protocolLayer =
8343 HDD_FILTER_PROTO_TYPE_MAC;
8344 packetFilterSetReq.paramsData[0].cmpFlag =
8345 HDD_FILTER_CMP_TYPE_MAX;
8346 packetFilterSetReq.paramsData[0].dataOffset = 0;
8347 packetFilterSetReq.paramsData[0].dataLength = 1;
8348 packetFilterSetReq.paramsData[0].compareData[0] =
8349 HDD_IPV6_UC_CMP_DATA;
8350
8351 packetFilterSetReq.paramsData[1].protocolLayer =
8352 HDD_FILTER_PROTO_TYPE_ARP;
8353 packetFilterSetReq.paramsData[1].cmpFlag =
8354 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8355 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8356 packetFilterSetReq.paramsData[1].dataLength = 2;
8357 packetFilterSetReq.paramsData[1].compareData[0] =
8358 HDD_IPV6_CMP_DATA_0;
8359 packetFilterSetReq.paramsData[1].compareData[1] =
8360 HDD_IPV6_CMP_DATA_1;
8361
8362 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8363 &packetFilterSetReq, sessionId))
8364 {
8365 hddLog(VOS_TRACE_LEVEL_ERROR,
8366 "%s: Failure to execute Set IPv6 Unicast Filter",
8367 __func__);
8368 return -EINVAL;
8369 }
8370
8371 break;
8372
8373 case HDD_FILTER_IPV6_MC:
8374 /*
8375 * IPV6 UC Filter might be already set,
8376 * clear the UC Filter. As the Filter
8377 * IDs are static, we can directly clear it.
8378 */
8379 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8380 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8381 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8382 &packetFilterClrReq, sessionId))
8383 {
8384 hddLog(VOS_TRACE_LEVEL_ERROR,
8385 "%s: Failure to execute Clear IPv6 Unicast Filter",
8386 __func__);
8387 return -EINVAL;
8388 }
8389
8390 /*
8391 * Setting IPV6 MC Filter below
8392 */
8393 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8394 packetFilterSetReq.numFieldParams = 2;
8395 packetFilterSetReq.paramsData[0].protocolLayer =
8396 HDD_FILTER_PROTO_TYPE_MAC;
8397 packetFilterSetReq.paramsData[0].cmpFlag =
8398 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8399 packetFilterSetReq.paramsData[0].dataOffset =
8400 WLAN_HDD_80211_FRM_DA_OFFSET;
8401 packetFilterSetReq.paramsData[0].dataLength = 1;
8402 packetFilterSetReq.paramsData[0].compareData[0] =
8403 HDD_IPV6_MC_CMP_DATA;
8404
8405 packetFilterSetReq.paramsData[1].protocolLayer =
8406 HDD_FILTER_PROTO_TYPE_ARP;
8407 packetFilterSetReq.paramsData[1].cmpFlag =
8408 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8409 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8410 packetFilterSetReq.paramsData[1].dataLength = 2;
8411 packetFilterSetReq.paramsData[1].compareData[0] =
8412 HDD_IPV6_CMP_DATA_0;
8413 packetFilterSetReq.paramsData[1].compareData[1] =
8414 HDD_IPV6_CMP_DATA_1;
8415
8416
8417 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8418 &packetFilterSetReq, sessionId))
8419 {
8420 hddLog(VOS_TRACE_LEVEL_ERROR,
8421 "%s: Failure to execute Set IPv6 Multicast Filter",
8422 __func__);
8423 return -EINVAL;
8424 }
8425 break;
8426
8427 default :
8428 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8429 "%s: Packet Filter Request: Invalid",
8430 __func__);
8431 return -EINVAL;
8432 }
8433 return 0;
8434}
8435
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308436void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008437{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308438 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308439 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008440 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308441 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008442
Yue Ma3ede6052013-08-29 00:33:26 -07008443 if (NULL == pHddCtx)
8444 {
8445 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8446 return;
8447 }
8448
8449 hHal = pHddCtx->hHal;
8450
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308451 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008452 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308453 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8454 return;
8455 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308456
8457 /* Check if INI is enabled or not, other wise just return
8458 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308459 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308460 {
8461 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8462 if (NULL == pMulticastAddrs)
8463 {
8464 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8465 return;
8466 }
8467
Jeff Johnson295189b2012-06-20 16:38:30 -07008468 if (set)
8469 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308470 /* Following pre-conditions should be satisfied before wei
8471 * configure the MC address list.
8472 */
8473 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8474 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8475 && pAdapter->mc_addr_list.mc_cnt
8476 && (eConnectionState_Associated ==
8477 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8478 {
8479 pMulticastAddrs->ulMulticastAddrCnt =
8480 pAdapter->mc_addr_list.mc_cnt;
8481 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8482 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008483 memcpy(pMulticastAddrs->multicastAddr[i],
8484 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308485 sizeof(pAdapter->mc_addr_list.addr[i]));
8486 hddLog(VOS_TRACE_LEVEL_INFO,
8487 "%s: %s multicast filter: addr ="
8488 MAC_ADDRESS_STR,
8489 __func__, set ? "setting" : "clearing",
8490 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8491 }
8492 /* Set multicast filter */
8493 sme_8023MulticastList(hHal, pAdapter->sessionId,
8494 pMulticastAddrs);
8495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308497 else
8498 {
8499 /* Need to clear only if it was previously configured
8500 */
8501 if (pAdapter->mc_addr_list.isFilterApplied)
8502 {
8503 pMulticastAddrs->ulMulticastAddrCnt = 0;
8504 sme_8023MulticastList(hHal, pAdapter->sessionId,
8505 pMulticastAddrs);
8506 }
8507
8508 }
8509 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008510 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308512 else
8513 {
8514 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308515 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308516 }
8517 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008518}
8519
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308520static int __iw_set_packet_filter_params(struct net_device *dev,
8521 struct iw_request_info *info,
8522 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308523{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308524 hdd_adapter_t *pAdapter;
8525 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008526 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308527 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308528 struct iw_point s_priv_data;
8529
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308530 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308531 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8532 if (NULL == pAdapter)
8533 {
8534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8535 "%s: Adapter is NULL",__func__);
8536 return -EINVAL;
8537 }
8538 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8539 ret = wlan_hdd_validate_context(pHddCtx);
8540 if (0 != ret)
8541 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308542 return ret;
8543 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308544 if (hdd_priv_get_data(&s_priv_data, wrqu))
8545 {
8546 return -EINVAL;
8547 }
8548
8549 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8550 {
8551 return -EINVAL;
8552 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008553
Arif Hussain0273cba2014-01-07 20:58:29 -08008554 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308555 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8556 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008557 if (NULL == pRequest)
8558 {
8559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8560 "mem_alloc_copy_from_user_helper fail");
8561 return -ENOMEM;
8562 }
8563
8564 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8565 kfree(pRequest);
8566
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308567 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008568 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008569}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308570
8571static int iw_set_packet_filter_params(struct net_device *dev,
8572 struct iw_request_info *info,
8573 union iwreq_data *wrqu, char *extra)
8574{
8575 int ret;
8576
8577 vos_ssr_protect(__func__);
8578 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8579 vos_ssr_unprotect(__func__);
8580
8581 return ret;
8582}
Jeff Johnson295189b2012-06-20 16:38:30 -07008583#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308584static int __iw_get_statistics(struct net_device *dev,
8585 struct iw_request_info *info,
8586 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008587{
8588
8589 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8590 eHalStatus status = eHAL_STATUS_SUCCESS;
8591 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308592 hdd_adapter_t *pAdapter;
8593 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308595 int tlen = 0, ret = 0;
8596 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008597
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308598 tCsrGlobalClassAStatsInfo *aStats;
8599 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008600
8601 ENTER();
8602
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308603 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8604 if (NULL == pAdapter)
8605 {
8606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8607 "%s: Adapter is NULL",__func__);
8608 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308610 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8611 ret = wlan_hdd_validate_context(pHddCtx);
8612 if (0 != ret)
8613 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308614 return ret;
8615 }
8616 pStats = &(pAdapter->hdd_stats.summary_stat);
8617 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8618 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8620
8621 wrqu->txpower.value = 0;
8622 }
8623 else {
8624 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8625 SME_SUMMARY_STATS |
8626 SME_GLOBAL_CLASSA_STATS |
8627 SME_GLOBAL_CLASSB_STATS |
8628 SME_GLOBAL_CLASSC_STATS |
8629 SME_GLOBAL_CLASSD_STATS |
8630 SME_PER_STA_STATS,
8631 hdd_StatisticsCB, 0, FALSE,
8632 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8633
8634 if (eHAL_STATUS_SUCCESS != status)
8635 {
8636 hddLog(VOS_TRACE_LEVEL_ERROR,
8637 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008638 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008639 return -EINVAL;
8640 }
8641
8642 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308643 if (NULL == pWextState)
8644 {
8645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8646 "%s: pWextState is NULL",__func__);
8647 return -EINVAL;
8648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008649
8650 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8651 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8652 {
8653 hddLog(VOS_TRACE_LEVEL_ERROR,
8654 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008655 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 /*Remove the SME statistics list by passing NULL in callback argument*/
8657 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8658 SME_SUMMARY_STATS |
8659 SME_GLOBAL_CLASSA_STATS |
8660 SME_GLOBAL_CLASSB_STATS |
8661 SME_GLOBAL_CLASSC_STATS |
8662 SME_GLOBAL_CLASSD_STATS |
8663 SME_PER_STA_STATS,
8664 NULL, 0, FALSE,
8665 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8666
8667 return -EINVAL;
8668 }
8669 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8670 (tANI_U8) sizeof (pStats->retry_cnt),
8671 (char*) &(pStats->retry_cnt[0]),
8672 tlen);
8673
8674 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8675 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8676 (char*) &(pStats->multiple_retry_cnt[0]),
8677 tlen);
8678
8679 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8680 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8681 (char*) &(pStats->tx_frm_cnt[0]),
8682 tlen);
8683
8684 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8685 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8686 (char*) &(pStats->rx_frm_cnt),
8687 tlen);
8688
8689 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8690 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8691 (char*) &(pStats->frm_dup_cnt),
8692 tlen);
8693
8694 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8695 (tANI_U8) sizeof (pStats->fail_cnt),
8696 (char*) &(pStats->fail_cnt[0]),
8697 tlen);
8698
8699 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8700 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8701 (char*) &(pStats->rts_fail_cnt),
8702 tlen);
8703
8704 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8705 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8706 (char*) &(pStats->ack_fail_cnt),
8707 tlen);
8708
8709 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8710 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8711 (char*) &(pStats->rts_succ_cnt),
8712 tlen);
8713
8714 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8715 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8716 (char*) &(pStats->rx_discard_cnt),
8717 tlen);
8718
8719 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8720 (tANI_U8) sizeof (pStats->rx_error_cnt),
8721 (char*) &(pStats->rx_error_cnt),
8722 tlen);
8723
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008724 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008725 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008726 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 tlen);
8728
8729 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8730 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8731 (char*) &(dStats->rx_byte_cnt),
8732 tlen);
8733
8734 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8735 (tANI_U8) sizeof (dStats->rx_rate),
8736 (char*) &(dStats->rx_rate),
8737 tlen);
8738
8739 /* Transmit rate, in units of 500 kbit/sec */
8740 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8741 (tANI_U8) sizeof (aStats->tx_rate),
8742 (char*) &(aStats->tx_rate),
8743 tlen);
8744
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008745 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8746 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8747 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008748 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008749 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8750 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8751 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008752 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008753 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8754 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8755 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008756 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008757 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8758 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8759 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008760 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008761 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8762 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8763 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008764 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008765 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8766 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8767 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008768 tlen);
8769
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 wrqu->data.length = tlen;
8771
8772 }
8773
8774 EXIT();
8775
8776 return 0;
8777}
8778
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308779static int iw_get_statistics(struct net_device *dev,
8780 struct iw_request_info *info,
8781 union iwreq_data *wrqu, char *extra)
8782{
8783 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008784
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308785 vos_ssr_protect(__func__);
8786 ret = __iw_get_statistics(dev, info, wrqu, extra);
8787 vos_ssr_unprotect(__func__);
8788
8789 return ret;
8790}
Jeff Johnson295189b2012-06-20 16:38:30 -07008791#ifdef FEATURE_WLAN_SCAN_PNO
8792
8793/*Max Len for PNO notification*/
8794#define MAX_PNO_NOTIFY_LEN 100
8795void found_pref_network_cb (void *callbackContext,
8796 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8797{
8798 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8799 union iwreq_data wrqu;
8800 char buf[MAX_PNO_NOTIFY_LEN+1];
8801
8802 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8803 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8804
8805 // create the event
8806 memset(&wrqu, 0, sizeof(wrqu));
8807 memset(buf, 0, sizeof(buf));
8808
8809 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8810 pPrefNetworkFoundInd->ssId.ssId,
8811 (unsigned int)pPrefNetworkFoundInd->rssi);
8812
8813 wrqu.data.pointer = buf;
8814 wrqu.data.length = strlen(buf);
8815
8816 // send the event
8817
8818 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8819
8820}
8821
8822
8823/*string based input*/
8824VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8825 union iwreq_data *wrqu, char *extra, int nOffset)
8826{
8827 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308828 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008829 /* pnoRequest is a large struct, so we make it static to avoid stack
8830 overflow. This API is only invoked via ioctl, so it is
8831 serialized by the kernel rtnl_lock and hence does not need to be
8832 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308833 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 char *ptr;
8835 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308836 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8838
8839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8840 "PNO data len %d data %s",
8841 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008842 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008843
8844 if (wrqu->data.length <= nOffset )
8845 {
8846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8847 return VOS_STATUS_E_FAILURE;
8848 }
8849
8850 pnoRequest.enable = 0;
8851 pnoRequest.ucNetworksCount = 0;
8852 /*-----------------------------------------------------------------------
8853 Input is string based and expected to be like this:
8854
8855 <enabled> <netw_count>
8856 for each network:
8857 <ssid_len> <ssid> <authentication> <encryption>
8858 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8859 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8860
8861 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008862 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 -07008863
8864 this translates into:
8865 -----------------------------
8866 enable PNO
8867 look for 2 networks:
8868 test - with authentication type 0 and encryption type 0,
8869 that can be found on 3 channels: 1 6 and 11 ,
8870 SSID bcast type is unknown (directed probe will be sent if AP not found)
8871 and must meet -40dBm RSSI
8872
8873 test2 - with auth and enrytption type 4/4
8874 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
8875 bcast type is non-bcast (directed probe will be sent)
8876 and must not meet any RSSI threshold
8877
Jeff Johnson8301aa12013-03-28 14:27:29 -07008878 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08008880 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008881
Wilson Yang623f6592013-10-08 16:33:37 -07008882 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
8883 {
8884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8885 "PNO enable input is not valid %s",ptr);
8886 return VOS_STATUS_E_FAILURE;
8887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008888
8889 if ( 0 == pnoRequest.enable )
8890 {
8891 /*Disable PNO*/
8892 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05308893 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8894 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 pAdapter->sessionId,
8896 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308897 if (eHAL_STATUS_SUCCESS != status)
8898 {
8899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8900 "%s: failed to disable PNO", __func__);
8901 return VOS_STATUS_E_FAILURE;
8902 }
8903 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 return VOS_STATUS_SUCCESS;
8905 }
8906
c_hpothu37f21312014-04-09 21:49:54 +05308907 if (TRUE == pHddCtx->isPnoEnable)
8908 {
8909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8910 FL("already PNO is enabled"));
8911 return -EBUSY;
8912 }
8913 pHddCtx->isPnoEnable = TRUE;
8914
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07008916
8917 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
8918 {
8919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8920 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308921 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008923
8924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8925 "PNO enable %d networks count %d offset %d",
8926 pnoRequest.enable,
8927 pnoRequest.ucNetworksCount,
8928 nOffset);
8929
8930 /* Parameters checking:
8931 ucNetworksCount has to be larger than 0*/
8932 if (( 0 == pnoRequest.ucNetworksCount ) ||
8933 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8934 {
8935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05308936 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 }
8938
8939 ptr += nOffset;
8940
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308941 pnoRequest.aNetworks =
8942 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8943 if (pnoRequest.aNetworks == NULL)
8944 {
8945 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8946 FL("failed to allocate memory aNetworks %u"),
8947 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8948 goto error;
8949 }
8950 vos_mem_zero(pnoRequest.aNetworks,
8951 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8952
Jeff Johnson295189b2012-06-20 16:38:30 -07008953 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
8954 {
8955
8956 pnoRequest.aNetworks[i].ssId.length = 0;
8957
Wilson Yang623f6592013-10-08 16:33:37 -07008958 ucParams = sscanf(ptr,"%hhu %n",
8959 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
8960
8961 if (1 != ucParams)
8962 {
8963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8964 "PNO ssid length input is not valid %s",ptr);
8965 return VOS_STATUS_E_FAILURE;
8966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008967
8968 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
8969 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
8970 {
8971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8972 "SSID Len %d is not correct for network %d",
8973 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05308974 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008975 }
8976
8977 /*Advance to SSID*/
8978 ptr += nOffset;
8979
Jeff Johnson8301aa12013-03-28 14:27:29 -07008980 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08008981 pnoRequest.aNetworks[i].ssId.length);
8982 ptr += pnoRequest.aNetworks[i].ssId.length;
8983
Jeff Johnson02797792013-10-26 19:17:13 -07008984 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08008985 &(pnoRequest.aNetworks[i].authentication),
8986 &(pnoRequest.aNetworks[i].encryption),
8987 &(pnoRequest.aNetworks[i].ucChannelCount),
8988 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008989
Wilson Yang623f6592013-10-08 16:33:37 -07008990 if ( 3 != ucParams )
8991 {
8992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8993 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308994 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008995 }
8996
Jeff Johnson295189b2012-06-20 16:38:30 -07008997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008998 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08008999 "auth %d encry %d channel count %d offset %d",
9000 pnoRequest.aNetworks[i].ssId.length,
9001 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
9002 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
9003 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
9004 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
9005 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9006 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9007 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9008 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9009 pnoRequest.aNetworks[i].authentication,
9010 pnoRequest.aNetworks[i].encryption,
9011 pnoRequest.aNetworks[i].ucChannelCount,
9012 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009013
Jeff Johnson295189b2012-06-20 16:38:30 -07009014 /*Advance to channel list*/
9015 ptr += nOffset;
9016
Wilson Yang623f6592013-10-08 16:33:37 -07009017 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009018 {
9019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9020 "Incorrect number of channels");
9021 return VOS_STATUS_E_FAILURE;
9022 }
9023
9024 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9025 {
9026 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9027 {
Wilson Yang623f6592013-10-08 16:33:37 -07009028 if (1 != sscanf(ptr,"%hhu %n",
9029 &(pnoRequest.aNetworks[i].aChannels[j]),
9030 &nOffset))
9031 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9032 "PNO network channel input is not valid %s",ptr);
9033 return VOS_STATUS_E_FAILURE;
9034 }
9035 /*Advance to next channel number*/
9036 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009037 }
9038 }
9039
Jeff Johnson02797792013-10-26 19:17:13 -07009040 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009041 &(pnoRequest.aNetworks[i].bcastNetwType),
9042 &nOffset))
9043 {
9044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9045 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309046 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009048
9049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9050 "PNO bcastNetwType %d offset %d",
9051 pnoRequest.aNetworks[i].bcastNetwType,
9052 nOffset );
9053
9054 /*Advance to rssi Threshold*/
9055 ptr += nOffset;
9056
Wilson Yang623f6592013-10-08 16:33:37 -07009057 if (1 != sscanf(ptr,"%hhu %n",
9058 &(pnoRequest.aNetworks[i].rssiThreshold),
9059 &nOffset))
9060 {
9061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9062 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309063 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009065
9066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9067 "PNO rssi %d offset %d",
9068 pnoRequest.aNetworks[i].rssiThreshold,
9069 nOffset );
9070 /*Advance to next network*/
9071 ptr += nOffset;
9072 }/*For ucNetworkCount*/
9073
9074 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009075 &(pnoRequest.scanTimers.ucScanTimersCount),
9076 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009077
9078 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009079 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 {
9081 ptr += nOffset;
9082
Jeff Johnson8301aa12013-03-28 14:27:29 -07009083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9084 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009085 pnoRequest.scanTimers.ucScanTimersCount,
9086 nOffset );
9087
9088 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9089 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009091 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309092 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009093 }
9094
9095 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9096 {
Jeff Johnson02797792013-10-26 19:17:13 -07009097 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009098 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9099 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9100 &nOffset);
9101
Wilson Yang623f6592013-10-08 16:33:37 -07009102 if (2 != ucParams)
9103 {
9104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9105 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309106 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009107 }
9108
Jeff Johnson8301aa12013-03-28 14:27:29 -07009109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9110 "PNO Timer value %d Timer repeat %d offset %d",
9111 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9113 nOffset );
9114
Jeff Johnson295189b2012-06-20 16:38:30 -07009115 ptr += nOffset;
9116 }
9117
9118 }
9119 else
9120 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9122 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9124
9125 /*Scan timers defaults to 5 minutes*/
9126 pnoRequest.scanTimers.ucScanTimersCount = 1;
9127 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9128 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9129 }
9130
Wilson Yang623f6592013-10-08 16:33:37 -07009131 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009132
9133 pnoRequest.modePNO = ucMode;
9134 /*for LA we just expose suspend option*/
9135 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9136 {
9137 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9138 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309139 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9140 if (pnoRequest.p24GProbeTemplate == NULL){
9141 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9142 FL("failed to allocate memory p24GProbeTemplate %u"),
9143 SIR_PNO_MAX_PB_REQ_SIZE);
9144 goto error;
9145 }
9146
9147 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9148 if (pnoRequest.p5GProbeTemplate == NULL){
9149 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9150 FL("failed to allocate memory p5GProbeTemplate %u"),
9151 SIR_PNO_MAX_PB_REQ_SIZE);
9152 goto error;
9153 }
9154
9155 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9156 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009157
c_hpothu37f21312014-04-09 21:49:54 +05309158 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009159 pAdapter->sessionId,
9160 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309161 if (eHAL_STATUS_SUCCESS == status)
9162 {
9163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9164 "%s: PNO enabled", __func__);
9165 return VOS_STATUS_SUCCESS;
9166 }
9167error:
9168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9169 "%s: Failed to enable PNO", __func__);
9170 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309171 if (pnoRequest.aNetworks)
9172 vos_mem_free(pnoRequest.aNetworks);
9173 if (pnoRequest.p24GProbeTemplate)
9174 vos_mem_free(pnoRequest.p24GProbeTemplate);
9175 if (pnoRequest.p5GProbeTemplate)
9176 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309177 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009178}/*iw_set_pno*/
9179
9180VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9181 union iwreq_data *wrqu, char *extra, int nOffset)
9182{
9183 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9184 v_U8_t rssiThreshold = 0;
9185 v_U8_t nRead;
9186
Arif Hussain7adce1b2013-11-11 22:59:34 -08009187 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009188 &rssiThreshold);
9189
9190 if ( 1 != nRead )
9191 {
9192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9193 "Incorrect format");
9194 return VOS_STATUS_E_FAILURE;
9195 }
9196
9197 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9198 return VOS_STATUS_SUCCESS;
9199}
9200
9201
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309202static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009203 struct iw_request_info *info,
9204 union iwreq_data *wrqu, char *extra)
9205{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309206 hdd_adapter_t *pAdapter;
9207 hdd_context_t *pHddCtx;
9208 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309209 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309210
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309211 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309212 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9213 if (NULL == pAdapter)
9214 {
9215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9216 "%s: Adapter is NULL",__func__);
9217 return -EINVAL;
9218 }
9219
9220 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9221 ret = wlan_hdd_validate_context(pHddCtx);
9222 if (0 != ret)
9223 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309224 return ret;
9225 }
9226
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009227
9228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009229 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009230
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309231 status = iw_set_pno(dev,info,wrqu,extra,0);
9232
9233 EXIT();
9234 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009235}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309236
9237static int iw_set_pno_priv(struct net_device *dev,
9238 struct iw_request_info *info,
9239 union iwreq_data *wrqu, char *extra)
9240{
9241 int ret;
9242
9243 vos_ssr_protect(__func__);
9244 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9245 vos_ssr_unprotect(__func__);
9246
9247 return ret;
9248}
Jeff Johnson295189b2012-06-20 16:38:30 -07009249#endif /*FEATURE_WLAN_SCAN_PNO*/
9250
9251//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309252int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009253{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309254 hdd_adapter_t *pAdapter;
9255 tHalHandle hHal;
9256 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309257 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309258 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309259 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009260 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309261 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309262 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309263 tpAniSirGlobal pMac;
9264 int retval = 0;
9265
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309266 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309267 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9268 if (NULL == pAdapter)
9269 {
9270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9271 "%s: Adapter is NULL",__func__);
9272 return -EINVAL;
9273 }
9274 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9275 retval = wlan_hdd_validate_context(pHddCtx);
9276 if (0 != retval)
9277 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309278 return retval;
9279 }
9280 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9281 if (NULL == hHal)
9282 {
9283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9284 "%s: Hal Context is NULL",__func__);
9285 return -EINVAL;
9286 }
9287 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009288
Atul Mittal54378cb2014-04-02 16:51:50 +05309289 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009290 {
9291 case WLAN_HDD_UI_BAND_AUTO:
9292 band = eCSR_BAND_ALL;
9293 break;
9294 case WLAN_HDD_UI_BAND_5_GHZ:
9295 band = eCSR_BAND_5G;
9296 break;
9297 case WLAN_HDD_UI_BAND_2_4_GHZ:
9298 band = eCSR_BAND_24;
9299 break;
9300 default:
9301 band = eCSR_BAND_MAX;
9302 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309303 connectedBand =
9304 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009305
Atul Mittal54378cb2014-04-02 16:51:50 +05309306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009307 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009308
9309 if (band == eCSR_BAND_MAX)
9310 {
9311 /* Received change band request with invalid band value */
9312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309313 "%s: Invalid band value %u", __func__, ui_band);
9314 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009315 }
9316
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309317 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309318 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309319 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009321 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009322 band, pHddCtx->cfg_ini->nBandCapability);
9323 return -EIO;
9324 }
9325
Sushant Kaushik1165f872015-03-30 20:25:27 +05309326 if (band == eCSR_BAND_ALL)
9327 {
9328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9329 "received. Setting band same as ini value %d"),
9330 pHddCtx->cfg_ini->nBandCapability);
9331 band = pHddCtx->cfg_ini->nBandCapability;
9332 }
9333
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9335 {
9336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9337 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009338 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009339 return -EIO;
9340 }
9341
9342 if (currBand != band)
9343 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309344 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309345 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309346 /* Return failure if current country code is world regulatory domain*/
9347 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9348 pMac->scan.countryCodeCurrent[1] == '0') )
9349 {
9350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9351 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309352 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309353 return -EAGAIN;
9354 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309355 }
9356
Jeff Johnson295189b2012-06-20 16:38:30 -07009357 /* Change band request received.
9358 * Abort pending scan requests, flush the existing scan results,
9359 * and change the band capability
9360 */
9361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9362 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009363 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009364
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309365 /* We need to change the band and flush the scan results here itself
9366 * as we may get timeout for disconnection in which we will return
9367 * with out doing any of these
9368 */
9369 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9370 {
9371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9372 "%s: failed to set the band value to %u ",
9373 __func__, band);
9374 return -EINVAL;
9375 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309376 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9377 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309378 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309379 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9380 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309381 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309382 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9383 * information available in NV so to get the channel information from kernel
9384 * we need to send regulatory hint for the currunt country
9385 * And to set the same country again we need to set the dummy country
9386 * first and then the actual country.
9387 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309388#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9389 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9390#else
9391 regulatory_hint_user("00");
9392#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309393 wait_result = wait_for_completion_interruptible_timeout(
9394 &pHddCtx->linux_reg_req,
9395 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9396
9397 /* if the country information does not exist with the kernel,
9398 then the driver callback would not be called */
9399
9400 if (wait_result >= 0)
9401 {
9402 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9403 "runtime country code is found in kernel db");
9404 }
9405 else
9406 {
9407 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9408 "runtime country code is not found"
9409 " in kernel db");
9410 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309411
9412 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309413
9414 /*
9415 * Update 11dcountry and current country here as the hint
9416 * with 00 results in 11d and current country with 00
9417 */
9418 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9419 WNI_CFG_COUNTRY_CODE_LEN);
9420 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9421 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309422#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9423 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9424#else
9425 regulatory_hint_user(curr_country);
9426#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309427 wait_result = wait_for_completion_interruptible_timeout(
9428 &pHddCtx->linux_reg_req,
9429 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9430
9431 /* if the country information does not exist with the kernel,
9432 then the driver callback would not be called */
9433 if (wait_result >= 0)
9434 {
9435 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9436 "runtime country code is found in kernel db");
9437 }
9438 else
9439 {
9440 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9441 "runtime country code is not found"
9442 " in kernel db");
9443 }
9444
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309445 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
9446 }
9447 else
9448 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309449#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309450 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9451 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309452#else
9453 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9454#endif
9455
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309456 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309457 pScanInfo = &pHddCtx->scan_info;
9458 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9459 {
9460 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9461 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9462 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309463 sme_FilterScanResults(hHal, pAdapter->sessionId);
9464
9465 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309466 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9467 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009468 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 eHalStatus status = eHAL_STATUS_SUCCESS;
9470 long lrc;
9471
9472 /* STA already connected on current band, So issue disconnect first,
9473 * then change the band*/
9474
9475 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309476 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309477 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009478
Jeff Johnson295189b2012-06-20 16:38:30 -07009479 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9480
9481 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9482 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9483
Jeff Johnson43971f52012-07-17 12:26:56 -07009484 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 {
9486 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009487 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 __func__, (int)status );
9489 return -EINVAL;
9490 }
9491
9492 lrc = wait_for_completion_interruptible_timeout(
9493 &pAdapter->disconnect_comp_var,
9494 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9495
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309496 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009497
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009498 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009499 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009500
9501 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9502 }
9503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009504 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309505 EXIT();
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309506 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009507}
9508
Atul Mittal54378cb2014-04-02 16:51:50 +05309509int hdd_setBand_helper(struct net_device *dev, const char *command)
9510{
9511 u8 band;
9512
9513 /*convert the band value from ascii to integer*/
9514 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9515
9516 return hdd_setBand(dev, band);
9517
9518}
9519
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309520static int __iw_set_band_config(struct net_device *dev,
9521 struct iw_request_info *info,
9522 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009523{
Atul Mittal54378cb2014-04-02 16:51:50 +05309524 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009525
Arif Hussain0273cba2014-01-07 20:58:29 -08009526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009527
Atul Mittal54378cb2014-04-02 16:51:50 +05309528 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009529}
9530
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309531static int iw_set_band_config(struct net_device *dev,
9532 struct iw_request_info *info,
9533 union iwreq_data *wrqu, char *extra)
9534{
9535 int ret;
9536
9537 vos_ssr_protect(__func__);
9538 ret = __iw_set_band_config(dev, info, wrqu, extra);
9539 vos_ssr_unprotect(__func__);
9540
9541 return ret;
9542}
9543
9544static int __iw_set_power_params_priv(struct net_device *dev,
9545 struct iw_request_info *info,
9546 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009547{
Arif Hussain0273cba2014-01-07 20:58:29 -08009548 int ret;
9549 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9551 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009552 /* ODD number is used for set, copy data using copy_from_user */
9553 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9554 wrqu->data.length);
9555 if (NULL == ptr)
9556 {
9557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9558 "mem_alloc_copy_from_user_helper fail");
9559 return -ENOMEM;
9560 }
9561
9562 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9563 kfree(ptr);
9564 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009565}
9566
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309567static int iw_set_power_params_priv(struct net_device *dev,
9568 struct iw_request_info *info,
9569 union iwreq_data *wrqu, char *extra)
9570{
9571 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009572
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309573 vos_ssr_protect(__func__);
9574 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9575 vos_ssr_unprotect(__func__);
9576
9577 return ret;
9578}
Jeff Johnson295189b2012-06-20 16:38:30 -07009579
9580/*string based input*/
9581VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9582 union iwreq_data *wrqu, char *extra, int nOffset)
9583{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309584 hdd_adapter_t *pAdapter;
9585 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009586 tSirSetPowerParamsReq powerRequest;
9587 char *ptr;
9588 v_U8_t ucType;
9589 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309590 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009591
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309592 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309593 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9594 if (NULL == pAdapter)
9595 {
9596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9597 "%s: Adapter is NULL",__func__);
9598 return -EINVAL;
9599 }
9600
9601 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9602 ret = wlan_hdd_validate_context(pHddCtx);
9603 if (0 != ret)
9604 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309605 return ret;
9606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9608 "Power Params data len %d data %s",
9609 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009610 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009611
9612 if (wrqu->data.length <= nOffset )
9613 {
9614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9615 return VOS_STATUS_E_FAILURE;
9616 }
9617
9618 uTotalSize = wrqu->data.length - nOffset;
9619
9620 /*-----------------------------------------------------------------------
9621 Input is string based and expected to be like this:
9622
9623 <param_type> <param_value> <param_type> <param_value> ...
9624
9625 e.g:
9626 1 2 2 3 3 0 4 1 5 1
9627
9628 e.g. setting just a few:
9629 1 2 4 1
9630
9631 parameter types:
9632 -----------------------------
9633 1 - Ignore DTIM
9634 2 - Listen Interval
9635 3 - Broadcast Multicas Filter
9636 4 - Beacon Early Termination
9637 5 - Beacon Early Termination Interval
9638 -----------------------------------------------------------------------*/
9639 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9640 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9641 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9642 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9643 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9644
Arif Hussain7adce1b2013-11-11 22:59:34 -08009645 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009646
9647 while ( uTotalSize )
9648 {
Wilson Yang6f971452013-10-08 15:00:00 -07009649 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9650 {
9651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9652 "Invalid input parameter type %s",ptr);
9653 return VOS_STATUS_E_FAILURE;
9654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009655
9656 uTotalSize -= nOffset;
9657
9658 if (!uTotalSize)
9659 {
9660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009661 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009662 ucType, nOffset);
9663 return VOS_STATUS_E_FAILURE;
9664 }
9665
9666 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009667
Jeff Johnson02797792013-10-26 19:17:13 -07009668 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009669 {
9670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9671 "Invalid input parameter value %s",ptr);
9672 return VOS_STATUS_E_FAILURE;
9673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009674
9675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9676 "Power request parameter %d value %d offset %d",
9677 ucType, uValue, nOffset);
9678
9679 switch (ucType)
9680 {
9681 case eSIR_IGNORE_DTIM:
9682 powerRequest.uIgnoreDTIM = uValue;
9683 break;
9684 case eSIR_LISTEN_INTERVAL:
9685 powerRequest.uListenInterval = uValue;
9686 break;
9687 case eSIR_MCAST_BCAST_FILTER:
9688 powerRequest.uBcastMcastFilter = uValue;
9689 break;
9690 case eSIR_ENABLE_BET:
9691 powerRequest.uEnableBET = uValue;
9692 break;
9693 case eSIR_BET_INTERVAL:
9694 powerRequest.uBETInterval = uValue;
9695 break;
9696 default:
9697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009698 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009699 ucType, uValue, nOffset);
9700 return VOS_STATUS_E_FAILURE;
9701 }
9702
9703 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9705 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009706 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009707 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009708 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009709 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009710 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9711 {
9712 uTotalSize = 0;
9713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009714
9715 }/*Go for as long as we have a valid string*/
9716
9717 /* put the device into full power*/
9718 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9719
9720 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009721 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009722
9723 /* put the device back to power save*/
9724 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9725
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309726 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 return VOS_STATUS_SUCCESS;
9728}/*iw_set_power_params*/
9729
Atul Mittalc0f739f2014-07-31 13:47:47 +05309730// tdlsoffchan
9731#ifdef FEATURE_WLAN_TDLS
9732
Atul Mittal87ec2422014-09-24 13:12:50 +05309733int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309734{
9735 if (offchannel < 0 || offchannel > 165)
9736 {
9737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9738 __func__, offchannel);
9739 return -1;
9740
9741 }
9742
9743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9744 __func__, tdlsOffCh, offchannel);
9745
9746 tdlsOffCh = offchannel;
9747 return 0;
9748}
9749
Atul Mittal87ec2422014-09-24 13:12:50 +05309750int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309751{
9752 if (offchanoffset == 0)
9753 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309754 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9756 __func__, tdlsOffChBwOffset);
9757
9758 return 0;
9759
9760 }
9761
9762 if ( offchanoffset == 40 )
9763 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309764 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9766 __func__, tdlsOffChBwOffset);
9767
9768 return 0;
9769
9770 }
9771 if (offchanoffset == -40)
9772 {
9773 tdlsOffChBwOffset = 3;
9774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9775 __func__, tdlsOffChBwOffset);
9776
9777 return 0;
9778
9779 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +05309780
9781 if ((offchanoffset == 80) &&
9782 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
9783 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
9784 {
9785 tdlsOffChBwOffset = 4;
9786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9787 "%s: change tdls secondary off channel offset to %u",
9788 __func__, tdlsOffChBwOffset);
9789
9790 return 0;
9791 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05309792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9793 __func__, offchanoffset);
9794 return -1;
9795}
9796
Atul Mittal87ec2422014-09-24 13:12:50 +05309797int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309798{
9799 hddTdlsPeer_t *connPeer = NULL;
9800 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9801 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9802
9803 if (offchanmode < 0 || offchanmode > 4)
9804 {
9805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9806 "%s: Invalid tdls off channel mode %d",
9807 __func__, offchanmode);
9808 return -1;
9809 }
9810
9811 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9812 {
9813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9814 "%s: tdls off channel mode req in not associated state %d",
9815 __func__, offchanmode);
9816 return -1;
9817 }
9818
9819 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9820 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9821 {
9822 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309823 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309824 if (NULL == connPeer) {
9825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9826 "%s: No TDLS Connected Peer", __func__);
9827 return -1;
9828 }
9829 }
9830 else
9831 {
9832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9833 "%s: TDLS Connection not supported", __func__);
9834 return -1;
9835 }
9836
9837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9838 ("%s: TDLS Channel Switch in swmode=%d"),
9839 __func__, offchanmode);
9840
9841 switch (offchanmode)
9842 {
9843 case 1:/*Enable*/
9844 case 2:/*Disable*/
9845 {
9846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9847 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9848 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9849 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9850 {
9851
9852 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9853 pAdapter->sessionId, connPeer->peerMac,
9854 tdlsOffCh, tdlsOffChBwOffset,
9855 offchanmode);
9856 }
9857 else
9858 {
9859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9860 "%s: TDLS Off Channel not supported", __func__);
9861 return -1;
9862 }
9863 break;
9864 }
9865 case 3:
9866 {
9867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9868 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
9869 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9870
9871 break;
9872 }
9873 case 4:
9874 {
9875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9876 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
9877 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9878 break;
9879 }
9880 default:
9881 {
9882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9883 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
9884 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9885 break;
9886 }
9887
9888 }
9889
9890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
9891 __func__, offchanmode);
9892 return 0;
9893}
Atul Mittalc0f739f2014-07-31 13:47:47 +05309894#endif
9895
Jeff Johnson295189b2012-06-20 16:38:30 -07009896
9897// Define the Wireless Extensions to the Linux Network Device structure
9898// A number of these routines are NULL (meaning they are not implemented.)
9899
9900static const iw_handler we_handler[] =
9901{
9902 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9903 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9904 (iw_handler) NULL, /* SIOCSIWNWID */
9905 (iw_handler) NULL, /* SIOCGIWNWID */
9906 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9907 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9908 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9909 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9910 (iw_handler) NULL, /* SIOCSIWSENS */
9911 (iw_handler) NULL, /* SIOCGIWSENS */
9912 (iw_handler) NULL, /* SIOCSIWRANGE */
9913 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9914 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
9915 (iw_handler) NULL, /* SIOCGIWPRIV */
9916 (iw_handler) NULL, /* SIOCSIWSTATS */
9917 (iw_handler) NULL, /* SIOCGIWSTATS */
9918 iw_handler_set_spy, /* SIOCSIWSPY */
9919 iw_handler_get_spy, /* SIOCGIWSPY */
9920 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
9921 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
9922 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9923 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9924 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9925 (iw_handler) NULL, /* SIOCGIWAPLIST */
9926 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9927 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9928 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9929 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9930 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9931 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9932 (iw_handler) NULL, /* -- hole -- */
9933 (iw_handler) NULL, /* -- hole -- */
9934 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9935 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9936 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
9937 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
9938 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9939 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9940 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9941 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9942 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9943 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9944 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9945 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9946 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9947 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9948 (iw_handler) NULL, /* -- hole -- */
9949 (iw_handler) NULL, /* -- hole -- */
9950 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9951 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9952 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9953 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9954 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9955 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9956 (iw_handler) NULL, /* SIOCSIWPMKSA */
9957};
9958
9959static const iw_handler we_private[] = {
9960
9961 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
9962 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
9963 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
9964 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
9965 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9966 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +05309967 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9969 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9970 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07009971#ifdef FEATURE_OEM_DATA_SUPPORT
9972 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
9973 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
9974#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009975
Jeff Johnson295189b2012-06-20 16:38:30 -07009976#ifdef WLAN_FEATURE_VOWIFI_11R
9977 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
9978#endif
9979 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9980 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9981 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
9982#ifdef WLAN_FEATURE_PACKET_FILTERING
9983 ,
9984 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
9985#endif
9986#ifdef FEATURE_WLAN_SCAN_PNO
9987 ,
9988 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
9989#endif
9990 ,
9991 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9992 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
9993 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
9994 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07009995 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07009996};
9997
9998/*Maximum command length can be only 15 */
9999static const struct iw_priv_args we_private_args[] = {
10000
10001 /* handlers for main ioctl */
10002 { WLAN_PRIV_SET_INT_GET_NONE,
10003 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10004 0,
10005 "" },
10006
10007 /* handlers for sub-ioctl */
10008 { WE_SET_11D_STATE,
10009 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10010 0,
10011 "set11Dstate" },
10012
10013 { WE_WOWL,
10014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10015 0,
10016 "wowl" },
10017
10018 { WE_SET_POWER,
10019 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10020 0,
10021 "setPower" },
10022
10023 { WE_SET_MAX_ASSOC,
10024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10025 0,
10026 "setMaxAssoc" },
10027
10028 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10030 0,
10031 "setAutoChannel" },
10032
10033 { WE_SET_DATA_INACTIVITY_TO,
10034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10035 0,
10036 "inactivityTO" },
10037
10038 { WE_SET_MAX_TX_POWER,
10039 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10040 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010041 "setMaxTxPower" },
10042
10043 { WE_SET_MAX_TX_POWER_2_4,
10044 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10045 0,
10046 "setTxMaxPower2G" },
10047
10048 { WE_SET_MAX_TX_POWER_5_0,
10049 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10050 0,
10051 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010052
10053 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10054 * as well to keep same syntax as in SAP. Now onwards, STA
10055 * will support both */
10056 { WE_SET_MAX_TX_POWER,
10057 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10058 0,
10059 "setTxMaxPower" },
10060
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10062 * 1 = enable and 0 = disable */
10063 {
10064 WE_SET_HIGHER_DTIM_TRANSITION,
10065 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10066 0,
10067 "setHDtimTransn" },
10068
10069 { WE_SET_TM_LEVEL,
10070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010071 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010072 "setTmLevel" },
10073
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010074 { WE_ENABLE_STRICT_FCC_REG,
10075 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10076 0,
10077 "setStrictFCCreg" },
10078
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010079 { WE_SET_DEBUG_LOG,
10080 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10081 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010082#ifdef FEATURE_WLAN_TDLS
10083 {
10084 WE_SET_TDLS_OFF_CHAN,
10085 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10086 0,
10087 "tdlsoffchan" },
10088 {
10089 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10090 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10091 0,
10092 "tdlsecchnoffst" },
10093 {
10094 WE_SET_TDLS_OFF_CHAN_MODE,
10095 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10096 0,
10097 "tdlsoffchnmode" },
10098#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010099
Peng Xu2446a892014-09-05 17:21:18 +053010100 { WE_SET_SCAN_BAND_PREFERENCE,
10101 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10102 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010103 {
10104 WE_GET_FRAME_LOG,
10105 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10106 0,
10107 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010108
Abhishek Singh01c73d12015-03-12 15:13:44 +053010109 { WE_SET_MIRACAST_VENDOR_CONFIG,
10110 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10111 0, "setMiracstConf" },
10112
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010113#ifdef FEATURE_WLAN_TDLS
10114 {
10115 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10116 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10117 0,
10118 "tdls_2040bsscox" },
10119#endif
10120
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 /* handlers for main ioctl */
10122 { WLAN_PRIV_SET_NONE_GET_INT,
10123 0,
10124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10125 "" },
10126
10127 /* handlers for sub-ioctl */
10128 { WE_GET_11D_STATE,
10129 0,
10130 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10131 "get11Dstate" },
10132
10133 { WE_IBSS_STATUS,
10134 0,
10135 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10136 "getAdhocStatus" },
10137
10138 { WE_PMC_STATE,
10139 0,
10140 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10141 "pmcState" },
10142
10143 { WE_GET_WLAN_DBG,
10144 0,
10145 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10146 "getwlandbg" },
10147
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 { WE_GET_MAX_ASSOC,
10149 0,
10150 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10151 "getMaxAssoc" },
10152
Jeff Johnson295189b2012-06-20 16:38:30 -070010153 { WE_GET_WDI_DBG,
10154 0,
10155 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10156 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010157
10158 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10159 0,
10160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10161 "getAutoChannel" },
10162
10163 { WE_GET_CONCURRENCY_MODE,
10164 0,
10165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10166 "getconcurrency" },
10167
Peng Xu2446a892014-09-05 17:21:18 +053010168 { WE_GET_SCAN_BAND_PREFERENCE,
10169 0,
10170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10171 "get_scan_pref"},
10172
Jeff Johnson295189b2012-06-20 16:38:30 -070010173 /* handlers for main ioctl */
10174 { WLAN_PRIV_SET_CHAR_GET_NONE,
10175 IW_PRIV_TYPE_CHAR| 512,
10176 0,
10177 "" },
10178
10179 /* handlers for sub-ioctl */
10180 { WE_WOWL_ADD_PTRN,
10181 IW_PRIV_TYPE_CHAR| 512,
10182 0,
10183 "wowlAddPtrn" },
10184
10185 { WE_WOWL_DEL_PTRN,
10186 IW_PRIV_TYPE_CHAR| 512,
10187 0,
10188 "wowlDelPtrn" },
10189
10190#if defined WLAN_FEATURE_VOWIFI
10191 /* handlers for sub-ioctl */
10192 { WE_NEIGHBOR_REPORT_REQUEST,
10193 IW_PRIV_TYPE_CHAR | 512,
10194 0,
10195 "neighbor" },
10196#endif
10197 { WE_SET_AP_WPS_IE,
10198 IW_PRIV_TYPE_CHAR| 512,
10199 0,
10200 "set_ap_wps_ie" },
10201
10202 { WE_SET_CONFIG,
10203 IW_PRIV_TYPE_CHAR| 512,
10204 0,
10205 "setConfig" },
10206
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010207 { WE_SET_ENCRYPT_MSG,
10208 IW_PRIV_TYPE_CHAR| 512,
10209 0,
10210 "encryptMsg" },
10211
10212
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 /* handlers for main ioctl */
10214 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10215 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10216 0,
10217 "" },
10218
10219 /* handlers for sub-ioctl */
10220 { WE_SET_WLAN_DBG,
10221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10222 0,
10223 "setwlandbg" },
10224
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 { WE_SET_WDI_DBG,
10226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10227 0,
10228 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010229
10230 { WE_SET_SAP_CHANNELS,
10231 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10232 0,
10233 "setsapchannels" },
10234
10235 /* handlers for main ioctl */
10236 { WLAN_PRIV_GET_CHAR_SET_NONE,
10237 0,
10238 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10239 "" },
10240
10241 /* handlers for sub-ioctl */
10242 { WE_WLAN_VERSION,
10243 0,
10244 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10245 "version" },
10246 { WE_GET_STATS,
10247 0,
10248 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10249 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010250 { WE_GET_STATES,
10251 0,
10252 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10253 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010254 { WE_GET_CFG,
10255 0,
10256 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10257 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010258#ifdef WLAN_FEATURE_11AC
10259 { WE_GET_RSSI,
10260 0,
10261 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10262 "getRSSI" },
10263#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010264#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010265 { WE_GET_ROAM_RSSI,
10266 0,
10267 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10268 "getRoamRSSI" },
10269#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010270 { WE_GET_WMM_STATUS,
10271 0,
10272 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10273 "getWmmStatus" },
10274 {
10275 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010276 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010277 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10278 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010279#ifdef FEATURE_WLAN_TDLS
10280 {
10281 WE_GET_TDLS_PEERS,
10282 0,
10283 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10284 "getTdlsPeers" },
10285#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010286#ifdef WLAN_FEATURE_11W
10287 {
10288 WE_GET_11W_INFO,
10289 0,
10290 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10291 "getPMFInfo" },
10292#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010293 { WE_GET_SNR,
10294 0,
10295 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10296 "getSNR" },
10297
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 /* handlers for main ioctl */
10299 { WLAN_PRIV_SET_NONE_GET_NONE,
10300 0,
10301 0,
10302 "" },
10303
10304 /* handlers for sub-ioctl */
10305 { WE_CLEAR_STATS,
10306 0,
10307 0,
10308 "clearStats" },
10309 { WE_INIT_AP,
10310 0,
10311 0,
10312 "initAP" },
10313 { WE_STOP_AP,
10314 0,
10315 0,
10316 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010317#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010318 { WE_ENABLE_AMP,
10319 0,
10320 0,
10321 "enableAMP" },
10322 { WE_DISABLE_AMP,
10323 0,
10324 0,
10325 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010326#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010327 { WE_ENABLE_DXE_STALL_DETECT,
10328 0,
10329 0,
10330 "dxeStallDetect" },
10331 { WE_DISPLAY_DXE_SNAP_SHOT,
10332 0,
10333 0,
10334 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010335 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10336 0,
10337 0,
10338 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010339 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010340 WE_SET_REASSOC_TRIGGER,
10341 0,
10342 0,
10343 "reassoc" },
10344 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010345 WE_STOP_OBSS_SCAN,
10346 0,
10347 0,
10348 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010349 {
10350 WE_DUMP_ROAM_TIMER_LOG,
10351 0,
10352 0,
10353 "dumpRoamDelay" },
10354 {
10355 WE_RESET_ROAM_TIMER_LOG,
10356 0,
10357 0,
10358 "resetRoamDelay" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 /* handlers for main ioctl */
10360 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10361 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10362 0,
10363 "" },
10364
10365 /* handlers for sub-ioctl */
10366 { WE_LOG_DUMP_CMD,
10367 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10368 0,
10369 "dump" },
10370
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010371 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010372 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10373 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10374 0,
10375 "setdumplog" },
10376
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010377 { WE_MTRACE_DUMP_CMD,
10378 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10379 0,
10380 "dumplog" },
10381
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010382 /* handlers for sub ioctl */
10383 {
10384 WE_MCC_CONFIG_CREDENTIAL,
10385 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10386 0,
10387 "setMccCrdnl" },
10388
10389 /* handlers for sub ioctl */
10390 {
10391 WE_MCC_CONFIG_PARAMS,
10392 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10393 0,
10394 "setMccConfig" },
10395
Chilam NG571c65a2013-01-19 12:27:36 +053010396#ifdef FEATURE_WLAN_TDLS
10397 /* handlers for sub ioctl */
10398 {
10399 WE_TDLS_CONFIG_PARAMS,
10400 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10401 0,
10402 "setTdlsConfig" },
10403#endif
10404
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 /* handlers for main ioctl */
10406 { WLAN_PRIV_ADD_TSPEC,
10407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10408 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10409 "addTspec" },
10410
10411 /* handlers for main ioctl */
10412 { WLAN_PRIV_DEL_TSPEC,
10413 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10414 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10415 "delTspec" },
10416
10417 /* handlers for main ioctl */
10418 { WLAN_PRIV_GET_TSPEC,
10419 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10420 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10421 "getTspec" },
10422
Jeff Johnsone7245742012-09-05 17:12:55 -070010423#ifdef FEATURE_OEM_DATA_SUPPORT
10424 /* handlers for main ioctl - OEM DATA */
10425 {
10426 WLAN_PRIV_SET_OEM_DATA_REQ,
10427 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10428 0,
10429 "set_oem_data_req" },
10430
10431 /* handlers for main ioctl - OEM DATA */
10432 {
10433 WLAN_PRIV_GET_OEM_DATA_RSP,
10434 0,
10435 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10436 "get_oem_data_rsp" },
10437#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010438
Jeff Johnson295189b2012-06-20 16:38:30 -070010439 /* handlers for main ioctl - host offload */
10440 {
10441 WLAN_PRIV_SET_HOST_OFFLOAD,
10442 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10443 0,
10444 "setHostOffload" },
10445
10446 {
10447 WLAN_GET_WLAN_STATISTICS,
10448 0,
10449 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10450 "getWlanStats" },
10451
10452 {
10453 WLAN_SET_KEEPALIVE_PARAMS,
10454 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10455 0,
10456 "setKeepAlive" },
10457#ifdef WLAN_FEATURE_PACKET_FILTERING
10458 {
10459 WLAN_SET_PACKET_FILTER_PARAMS,
10460 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10461 0,
10462 "setPktFilter" },
10463#endif
10464#ifdef FEATURE_WLAN_SCAN_PNO
10465 {
10466 WLAN_SET_PNO,
10467 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10468 0,
10469 "setpno" },
10470#endif
10471 {
10472 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010473 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010474 0,
10475 "SETBAND" },
10476 /* handlers for dynamic MC BC ioctl */
10477 {
10478 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010479 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010480 0,
10481 "setMCBCFilter" },
10482 {
10483 WLAN_PRIV_CLEAR_MCBC_FILTER,
10484 0,
10485 0,
10486 "clearMCBCFilter" },
10487 {
10488 WLAN_SET_POWER_PARAMS,
10489 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10490 0,
10491 "setpowerparams" },
10492 {
10493 WLAN_GET_LINK_SPEED,
10494 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010495 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010496};
10497
10498
10499
10500const struct iw_handler_def we_handler_def = {
10501 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10502 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10503 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10504
10505 .standard = (iw_handler *)we_handler,
10506 .private = (iw_handler *)we_private,
10507 .private_args = we_private_args,
10508 .get_wireless_stats = get_wireless_stats,
10509};
10510
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010511int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10512{
10513 v_U32_t cmd = 288; //Command to RIVA
10514 hdd_context_t *pHddCtx = NULL;
10515 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10516 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10517 /*
10518 *configMccParam : specify the bit which needs to be modified
10519 *allowed to update based on wlan_qcom_cfg.ini
10520 * configuration
10521 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10522 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10523 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10524 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10525 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10526 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10527 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10528 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10529 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10530 * Bit 9 : Reserved
10531 */
10532 switch (arg1)
10533 {
10534 //Update MCC SCHEDULE_TIME_SLICE parameter
10535 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10536 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10537 {
10538 if((arg2 >= 5) && (arg2 <= 20))
10539 {
10540 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10541 }
10542 else
10543 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010544 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010545 return 0;
10546 }
10547 }
10548 break;
10549
10550 //Update MCC MAX_NULL_SEND_TIME parameter
10551 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10552 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10553 {
10554 if((arg2 >= 1) && (arg2 <= 10))
10555 {
10556 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10557 }
10558 else
10559 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010560 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010561 return 0;
10562 }
10563 }
10564 break;
10565
10566 //Update MCC TX_EARLY_STOP_TIME parameter
10567 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10568 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10569 {
10570 if((arg2 >= 1) && (arg2 <= 10))
10571 {
10572 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10573 }
10574 else
10575 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010576 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010577 return 0;
10578 }
10579 }
10580 break;
10581
10582 //Update MCC RX_DRAIN_TIME parameter
10583 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10584 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10585 {
10586 if((arg2 >= 1) && (arg2 <= 10))
10587 {
10588 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10589 }
10590 else
10591 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010592 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010593 return 0;
10594 }
10595 }
10596 break;
10597
10598 //Update MCC CHANNEL_SWITCH_TIME parameter
10599 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10600 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10601 {
10602 if((arg2 >= 1) && (arg2 <= 20))
10603 {
10604 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10605 }
10606 else
10607 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010608 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010609 return 0;
10610 }
10611 }
10612 break;
10613
10614 //Update MCC MIN_CHANNEL_TIME parameter
10615 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10616 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10617 {
10618 if((arg2 >= 5) && (arg2 <= 20))
10619 {
10620 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10621 }
10622 else
10623 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010624 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010625 return 0;
10626 }
10627 }
10628 break;
10629
10630 //Update MCC PARK_BEFORE_TBTT parameter
10631 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10632 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10633 {
10634 if((arg2 >= 1) && (arg2 <= 5))
10635 {
10636 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10637 }
10638 else
10639 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010640 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010641 return 0;
10642 }
10643 }
10644 break;
10645
10646 //Update MCC MIN_AFTER_DTIM parameter
10647 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10648 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10649 {
10650 if((arg2 >= 5) && (arg2 <= 15))
10651 {
10652 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10653 }
10654 else
10655 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010656 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010657 return 0;
10658 }
10659 }
10660 break;
10661
10662 //Update MCC TOO_CLOSE_MARGIN parameter
10663 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10664 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10665 {
10666 if((arg2 >= 1) && (arg2 <= 3))
10667 {
10668 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10669 }
10670 else
10671 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010672 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010673 return 0;
10674 }
10675 }
10676 break;
10677
10678 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010679 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010680 __FUNCTION__,arg1);
10681 break;
10682 }
10683 return 0;
10684}
10685
Jeff Johnson295189b2012-06-20 16:38:30 -070010686int hdd_set_wext(hdd_adapter_t *pAdapter)
10687{
10688 hdd_wext_state_t *pwextBuf;
10689 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010690 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010691
10692 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10693
10694 // Now configure the roaming profile links. To SSID and bssid.
10695 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10696 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10697
10698 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10699 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10700
10701 /*Set the numOfChannels to zero to scan all the channels*/
10702 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10703 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10704
10705 /* Default is no encryption */
10706 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10707 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10708
10709 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10710 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10711
10712 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10713
10714 /* Default is no authentication */
10715 pwextBuf->roamProfile.AuthType.numEntries = 1;
10716 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10717
10718 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10719 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10720
10721 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010722 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010723
10724 hdd_clearRoamProfileIe(pAdapter);
10725
10726 return VOS_STATUS_SUCCESS;
10727
10728 }
10729
10730int hdd_register_wext(struct net_device *dev)
10731 {
10732 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10733 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10734 VOS_STATUS status;
10735
10736 ENTER();
10737
10738 // Zero the memory. This zeros the profile structure.
10739 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10740
10741 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10742
10743
10744 status = hdd_set_wext(pAdapter);
10745
10746 if(!VOS_IS_STATUS_SUCCESS(status)) {
10747
Arif Hussain6d2a3322013-11-17 19:50:10 -080010748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 return eHAL_STATUS_FAILURE;
10750 }
10751
10752 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10753 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010755 return eHAL_STATUS_FAILURE;
10756 }
10757
10758 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10759 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010761 return eHAL_STATUS_FAILURE;
10762 }
10763
10764 // Register as a wireless device
10765 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10766
10767 EXIT();
10768 return 0;
10769}
10770
10771int hdd_UnregisterWext(struct net_device *dev)
10772{
c_hpothu2a13bc32015-01-21 12:48:54 +053010773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10774 if (dev != NULL)
10775 {
10776 rtnl_lock();
10777 dev->wireless_handlers = NULL;
10778 rtnl_unlock();
10779 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010780
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 return 0;
10782}
10783
10784