blob: ad3f5213ff8422e8f86389573bb82b114f745f15 [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 Shah4b53d4b2015-05-08 05:35:00 -07001430 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001431
Nirav Shah4b53d4b2015-05-08 05:35:00 -07001432 if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 {
1434 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1435 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1436 __LINE__, vos_status );
1437 return vos_status;
1438
1439 }
1440
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001441 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301443 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001444 {
1445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301446 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001447 /* we'll still fall through and return success since the
1448 * connection may still get established but is just taking
1449 * too long for us to wait */
1450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001451 }
1452 return VOS_STATUS_SUCCESS;
1453}
1454
1455v_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)
1456{
1457
1458 int left = ie_len;
1459 v_U8_t *ptr = ie;
1460 v_U8_t elem_id,elem_len;
1461 v_U8_t eid = 0xDD;
1462
1463 if ( NULL == ie || 0 == ie_len )
1464 return NULL;
1465
1466 while(left >= 2)
1467 {
1468 elem_id = ptr[0];
1469 elem_len = ptr[1];
1470 left -= 2;
1471 if(elem_len > left)
1472 {
1473 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001474 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 eid,elem_len,left);
1476 return NULL;
1477 }
1478 if (elem_id == eid)
1479 {
1480 if(memcmp( &ptr[2], oui, oui_size)==0)
1481 return ptr;
1482 }
1483
1484 left -= elem_len;
1485 ptr += (elem_len + 2);
1486 }
1487 return NULL;
1488}
1489
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301490static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 union iwreq_data *wrqu, char *extra)
1492{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301493 hdd_adapter_t *pAdapter;
1494 hdd_context_t *pHddCtx;
1495 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301496
1497 ENTER();
1498
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301499 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1500 if (NULL == pAdapter)
1501 {
1502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1503 "%s: pAdapter is NULL\n", __func__);
1504 return -EINVAL;
1505 }
1506 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1507 ret = wlan_hdd_validate_context(pHddCtx);
1508 if (0 != ret)
1509 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301510 return ret;
1511 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301512
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301514
1515 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301516 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001517}
1518
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301519static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1520 union iwreq_data *wrqu, char *extra)
1521{
1522 int ret;
1523
1524 vos_ssr_protect(__func__);
1525 ret = __iw_set_commit(dev, info, wrqu, extra);
1526 vos_ssr_unprotect(__func__);
1527
1528 return ret;
1529}
1530
1531static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 struct iw_request_info *info,
1533 char *wrqu, char *extra)
1534{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301535 hdd_adapter_t *pAdapter;
1536 hdd_context_t *pHddCtx;
1537 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301538
Jeff Johnson295189b2012-06-20 16:38:30 -07001539 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301540 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1541 if (NULL == pAdapter)
1542 {
1543 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1544 "%s: pAdapter is NULL\n", __func__);
1545 return -EINVAL;
1546 }
1547 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1548 ret = wlan_hdd_validate_context(pHddCtx);
1549 if (0 != ret)
1550 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301551 return ret;
1552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1554 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301555 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001556}
1557
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301558static int iw_get_name(struct net_device *dev,
1559 struct iw_request_info *info,
1560 char *wrqu, char *extra)
1561{
1562 int ret;
1563
1564 vos_ssr_protect(__func__);
1565 ret = __iw_get_name(dev, info, wrqu, extra);
1566 vos_ssr_unprotect(__func__);
1567
1568 return ret;
1569}
1570
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301571static int __iw_set_mode(struct net_device *dev,
1572 struct iw_request_info *info,
1573 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001574{
1575 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301576 hdd_adapter_t *pAdapter;
1577 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 tCsrRoamProfile *pRoamProfile;
1579 eCsrRoamBssType LastBSSType;
1580 eMib_dot11DesiredBssType connectedBssType;
1581 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301583 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001584
1585 ENTER();
1586
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301587 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001588 if (NULL == pAdapter)
1589 {
1590 hddLog(VOS_TRACE_LEVEL_WARN,
1591 "%s: Invalid context, pAdapter", __func__);
1592 return 0;
1593 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301594 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1595 status = wlan_hdd_validate_context(pHddCtx);
1596 if (0 != status)
1597 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301598 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 }
1600
1601 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1602 if (pWextState == NULL)
1603 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301604 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 return -EINVAL;
1606 }
1607
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 pRoamProfile = &pWextState->roamProfile;
1610 LastBSSType = pRoamProfile->BSSType;
1611
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301612 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001613
1614 switch (wrqu->mode)
1615 {
1616 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301617 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1619 // Set the phymode correctly for IBSS.
1620 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1621 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001622 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 break;
1625 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301626 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 break;
1630 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301631 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1633 break;
1634 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301635 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 return -EOPNOTSUPP;
1637 }
1638
1639 if ( LastBSSType != pRoamProfile->BSSType )
1640 {
1641 //the BSS mode changed
1642 // We need to issue disconnect if connected or in IBSS disconnect state
1643 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1644 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1645 {
1646 VOS_STATUS vosStatus;
1647 // need to issue a disconnect to CSR.
1648 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1649 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1650 pAdapter->sessionId,
1651 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1652 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301653 {
1654 long ret;
1655 ret = wait_for_completion_interruptible_timeout(
1656 &pAdapter->disconnect_comp_var,
1657 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1658 if (ret <= 0)
1659 hddLog(VOS_TRACE_LEVEL_ERROR,
1660 FL("failed wait on disconnect_comp_var %ld"), ret);
1661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 }
1663 }
1664
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 EXIT();
1666 return 0;
1667}
1668
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301669static int iw_set_mode(struct net_device *dev,
1670 struct iw_request_info *info,
1671 union iwreq_data *wrqu, char *extra)
1672{
1673 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001674
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301675 vos_ssr_protect(__func__);
1676 ret = __iw_set_mode(dev, info, wrqu, extra);
1677 vos_ssr_unprotect(__func__);
1678
1679 return ret;
1680}
1681
1682static int __iw_get_mode(struct net_device *dev,
1683 struct iw_request_info *info,
1684 union iwreq_data *wrqu,
1685 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001686{
1687
1688 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301689 hdd_adapter_t *pAdapter;
1690 hdd_context_t *pHddCtx;
1691 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301693 ENTER();
1694
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301695 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 if (NULL == pAdapter)
1697 {
1698 hddLog(VOS_TRACE_LEVEL_WARN,
1699 "%s: Invalid context, pAdapter", __func__);
1700 return 0;
1701 }
1702
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301703 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1704 ret = wlan_hdd_validate_context(pHddCtx);
1705 if (0 != ret)
1706 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301707 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1710 if (pWextState == NULL)
1711 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301712 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 return -EINVAL;
1714 }
1715
1716 switch (pWextState->roamProfile.BSSType)
1717 {
1718 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001719 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301720 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 break;
1722 case eCSR_BSS_TYPE_IBSS:
1723 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001724 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301725 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 break;
1727 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001728 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301729 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 break;
1731 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001732 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 break;
1734 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301735
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301736 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 return 0;
1738}
1739
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301740static int iw_get_mode(struct net_device *dev,
1741 struct iw_request_info *info,
1742 union iwreq_data *wrqu,
1743 char *extra)
1744{
1745 int ret;
1746
1747 vos_ssr_protect(__func__);
1748 ret = __iw_get_mode(dev, info, wrqu, extra);
1749 vos_ssr_unprotect(__func__);
1750
1751 return ret;
1752}
1753
1754static int __iw_set_freq(struct net_device *dev,
1755 struct iw_request_info *info,
1756 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001757{
1758 v_U32_t numChans = 0;
1759 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1760 v_U32_t indx = 0;
1761 v_U32_t status = 0;
1762
1763 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301764 hdd_adapter_t *pAdapter;
1765 hdd_context_t *pHddCtx;
1766 tHalHandle hHal;
1767 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301769
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 ENTER();
1771
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301772 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1773 if (NULL == pAdapter)
1774 {
1775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1776 "%s:Invalid Adapter",__func__);
1777 return -EINVAL;
1778 }
1779
1780 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1781 status = wlan_hdd_validate_context(pHddCtx);
1782 if (0 != status)
1783 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 return status;
1785 }
1786
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301787 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1788 if (NULL == hHal)
1789 {
1790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1791 "%s: Hal Context is NULL",__func__);
1792 return -EINVAL;
1793 }
1794
1795 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1796 if (NULL == pHddStaCtx)
1797 {
1798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1799 "%s:STA context is NULL",__func__);
1800 return -EINVAL;
1801 }
1802
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301804 if (NULL == pWextState)
1805 {
1806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1807 "%s: pWextState is NULL",__func__);
1808 return -EINVAL;
1809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001810
1811 pRoamProfile = &pWextState->roamProfile;
1812
Arif Hussain6d2a3322013-11-17 19:50:10 -08001813 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001814
1815 /* Link is up then return cant set channel*/
1816 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1817 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1818 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001819 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 return -EOPNOTSUPP;
1821 }
1822
1823 /* Settings by Frequency as input */
1824 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1825 (wrqu->freq.m <= (tANI_U32)5.825e8))
1826 {
1827 tANI_U32 freq = wrqu->freq.m / 100000;
1828
1829 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1830 indx++;
1831 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1832 {
1833 return -EINVAL;
1834 }
1835 wrqu->freq.e = 0;
1836 wrqu->freq.m = freq_chan_map[indx].chan;
1837
1838 }
1839
1840 if (wrqu->freq.e == 0)
1841 {
1842 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1843 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1844 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001845 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001846 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1848 return -EINVAL;
1849 }
1850
1851 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1852
1853 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1854 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1856 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 return -EIO;
1858 }
1859
1860 for (indx = 0; indx < numChans; indx++) {
1861 if (wrqu->freq.m == validChan[indx]){
1862 break;
1863 }
1864 }
1865 }
1866 else{
1867
1868 return -EINVAL;
1869 }
1870
1871 if(indx >= numChans)
1872 {
1873 return -EINVAL;
1874 }
1875
1876 /* Set the Operational Channel */
1877 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1878 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1879 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1880
Arif Hussain6d2a3322013-11-17 19:50:10 -08001881 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001882
1883 EXIT();
1884
1885 return status;
1886}
1887
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301888static int iw_set_freq(struct net_device *dev,
1889 struct iw_request_info *info,
1890 union iwreq_data *wrqu, char *extra)
1891{
1892 int ret;
1893
1894 vos_ssr_protect(__func__);
1895 ret = __iw_set_freq(dev, info, wrqu, extra);
1896 vos_ssr_unprotect(__func__);
1897
1898 return ret;
1899}
1900
1901static int __iw_get_freq(struct net_device *dev,
1902 struct iw_request_info *info,
1903 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001904{
Jeff Johnsone7245742012-09-05 17:12:55 -07001905 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301906 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 tHalHandle hHal;
1908 hdd_wext_state_t *pWextState;
1909 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301910 hdd_station_ctx_t *pHddStaCtx;
1911 hdd_context_t *pHddCtx;
1912 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001913
1914 ENTER();
1915
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301916 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1917 if (NULL == pAdapter)
1918 {
1919 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1920 "%s: Adapter is NULL", __func__);
1921 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301923 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1924 ret = wlan_hdd_validate_context(pHddCtx);
1925 if (0 != ret)
1926 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301927 return ret;
1928 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301930 if (NULL == hHal)
1931 {
1932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1933 "%s: Hal Context is NULL",__func__);
1934 return -EINVAL;
1935 }
1936 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1937 if (NULL == pHddStaCtx)
1938 {
1939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1940 "%s: HddStaCtx is NULL", __func__);
1941 return -EINVAL;
1942 }
1943 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1944 if (NULL == pWextState)
1945 {
1946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1947 "%s: pWextState is NULL",__func__);
1948 return -EINVAL;
1949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 pRoamProfile = &pWextState->roamProfile;
1951
1952 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1953 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001954 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 {
c_hpothub8245442013-11-20 23:41:09 +05301956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1957 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 return -EIO;
1959 }
1960 else
1961 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001962 status = hdd_wlan_get_freq(channel, &freq);
1963 if( TRUE == status )
1964 {
1965 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1966 * iwlist & iwconfig command shows frequency into proper
1967 * format (2.412 GHz instead of 246.2 MHz)*/
1968 fwrq->m = freq;
1969 fwrq->e = MHZ;
1970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 }
1972 }
1973 else
1974 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001975 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1976 * iwlist & iwconfig command shows frequency into proper
1977 * format (2.412 GHz instead of 246.2 MHz)*/
1978 fwrq->m = 0;
1979 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301981
1982 EXIT();
1983 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001984}
1985
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301986static int iw_get_freq(struct net_device *dev,
1987 struct iw_request_info *info,
1988 struct iw_freq *fwrq, char *extra)
1989{
1990 int ret;
1991
1992 vos_ssr_protect(__func__);
1993 ret = __iw_get_freq(dev, info, fwrq, extra);
1994 vos_ssr_unprotect(__func__);
1995
1996 return ret;
1997}
1998
1999static int __iw_get_tx_power(struct net_device *dev,
2000 struct iw_request_info *info,
2001 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002002{
2003
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302004 hdd_adapter_t *pAdapter;
2005 hdd_context_t *pHddCtx;
2006 hdd_station_ctx_t *pHddStaCtx;
2007 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002008
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302009 ENTER();
2010
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302011 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2012 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2015 "%s: Adapter is NULL",__func__);
2016 return -EINVAL;
2017 }
2018 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2019 ret = wlan_hdd_validate_context(pHddCtx);
2020 if (0 != ret)
2021 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302022 return ret;
2023 }
2024
2025 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2026 if (NULL == pHddStaCtx)
2027 {
2028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2029 "%s: STA Context is NULL",__func__);
2030 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 }
2032
2033 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2034 {
2035 wrqu->txpower.value = 0;
2036 return 0;
2037 }
2038 wlan_hdd_get_classAstats(pAdapter);
2039 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2040
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302041 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 return 0;
2043}
2044
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302045static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 struct iw_request_info *info,
2047 union iwreq_data *wrqu, char *extra)
2048{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302049 int ret;
2050
2051 vos_ssr_protect(__func__);
2052 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2053 vos_ssr_unprotect(__func__);
2054
2055 return ret;
2056}
2057
2058static int __iw_set_tx_power(struct net_device *dev,
2059 struct iw_request_info *info,
2060 union iwreq_data *wrqu, char *extra)
2061{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302062 hdd_adapter_t *pAdapter;
2063 tHalHandle hHal;
2064 hdd_context_t *pHddCtx;
2065 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002066
2067 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302068 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2069 if (NULL == pAdapter)
2070 {
2071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2072 "%s: Adapter is NULL",__func__);
2073 return -EINVAL;
2074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002075
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302076 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2077 ret = wlan_hdd_validate_context(pHddCtx);
2078 if (0 != ret)
2079 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302080 return ret;
2081 }
2082
2083 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2084 if (NULL == hHal)
2085 {
2086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2087 "%s: Hal Context is NULL",__func__);
2088 return -EINVAL;
2089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2091 {
c_hpothub8245442013-11-20 23:41:09 +05302092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2093 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 return -EIO;
2095 }
2096
2097 EXIT();
2098
2099 return 0;
2100}
2101
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302102static int iw_set_tx_power(struct net_device *dev,
2103 struct iw_request_info *info,
2104 union iwreq_data *wrqu, char *extra)
2105{
2106 int ret;
2107
2108 vos_ssr_protect(__func__);
2109 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2110 vos_ssr_unprotect(__func__);
2111
2112 return ret;
2113}
2114
2115static int __iw_get_bitrate(struct net_device *dev,
2116 struct iw_request_info *info,
2117 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002118{
2119 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2120 eHalStatus status = eHAL_STATUS_SUCCESS;
2121 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302122 hdd_adapter_t *pAdapter;
2123 hdd_context_t *pHddCtx;
2124 hdd_station_ctx_t *pHddStaCtx;
2125 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002126
2127 ENTER();
2128
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302129 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2130 if (NULL == pAdapter)
2131 {
2132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2133 "%s: Adapter is NULL",__func__);
2134 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 }
2136
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302137 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2138 ret = wlan_hdd_validate_context(pHddCtx);
2139 if (0 != ret)
2140 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302141 return ret;
2142 }
2143
2144 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2145 if (NULL == pHddStaCtx)
2146 {
2147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2148 "%s: STA Context is NULL",__func__);
2149 return -EINVAL;
2150 }
2151
2152 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 wrqu->bitrate.value = 0;
2154 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302155 else
2156 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2158 SME_SUMMARY_STATS |
2159 SME_GLOBAL_CLASSA_STATS |
2160 SME_GLOBAL_CLASSB_STATS |
2161 SME_GLOBAL_CLASSC_STATS |
2162 SME_GLOBAL_CLASSD_STATS |
2163 SME_PER_STA_STATS,
2164 hdd_StatisticsCB, 0, FALSE,
2165 pHddStaCtx->conn_info.staId[0], pAdapter );
2166
2167 if(eHAL_STATUS_SUCCESS != status)
2168 {
2169 hddLog(VOS_TRACE_LEVEL_ERROR,
2170 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002171 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 return status;
2173 }
2174
2175 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302176 if (NULL == pWextState)
2177 {
2178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2179 "%s: pWextState is NULL",__func__);
2180 return -EINVAL;
2181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002182
2183 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2184
2185 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2186 {
2187 hddLog(VOS_TRACE_LEVEL_ERROR,
2188 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002189 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 return VOS_STATUS_E_FAILURE;
2191 }
2192
2193 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2194 }
2195
2196 EXIT();
2197
2198 return vos_status;
2199}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302200
2201static int iw_get_bitrate(struct net_device *dev,
2202 struct iw_request_info *info,
2203 union iwreq_data *wrqu, char *extra)
2204{
2205 int ret;
2206
2207 vos_ssr_protect(__func__);
2208 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2209 vos_ssr_unprotect(__func__);
2210
2211 return ret;
2212}
2213
2214
Jeff Johnson295189b2012-06-20 16:38:30 -07002215/* ccm call back function */
2216
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302217static int __iw_set_bitrate(struct net_device *dev,
2218 struct iw_request_info *info,
2219 union iwreq_data *wrqu,
2220 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002221{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302222 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302224 hdd_station_ctx_t *pHddStaCtx;
2225 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2227 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2228 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2229 v_U32_t i, rate;
2230 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302231 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002232
2233 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302234 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2235 if (NULL == pAdapter)
2236 {
2237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2238 "%s: Adapter is NULL",__func__);
2239 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 }
2241
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302242 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2243 ret = wlan_hdd_validate_context(pHddCtx);
2244 if (0 != ret)
2245 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302246 return ret;
2247 }
2248
2249 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2250 if (NULL == pHddStaCtx)
2251 {
2252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2253 "%s: STA Context is NULL",__func__);
2254 return -EINVAL;
2255 }
2256
2257
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302259 if (NULL == pWextState)
2260 {
2261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2262 "%s: pWextState is NULL",__func__);
2263 return -EINVAL;
2264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002265
2266 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2267 {
2268 return -ENXIO ;
2269 }
2270
2271 rate = wrqu->bitrate.value;
2272
2273 if (rate == -1)
2274 {
2275 rate = WNI_CFG_FIXED_RATE_AUTO;
2276 valid_rate = TRUE;
2277 }
2278 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2279 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2280 {
2281 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2282 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2283 {
2284 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2285 WNI_CFG_SUPPORTED_RATES_11A,
2286 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2287 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2288 WNI_CFG_SUPPORTED_RATES_11B,
2289 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2290 {
2291 for (i = 0; i < (b_len + a_len); ++i)
2292 {
2293 /* supported rates returned is double the actual rate so we divide it by 2 */
2294 if ((supp_rates[i]&0x7F)/2 == rate)
2295 {
2296 valid_rate = TRUE;
2297 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2298 break;
2299 }
2300 }
2301 }
2302 }
2303 }
2304 if (valid_rate != TRUE)
2305 {
2306 return -EINVAL;
2307 }
2308 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2309 WNI_CFG_FIXED_RATE, rate,
2310 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2311 {
c_hpothub8245442013-11-20 23:41:09 +05302312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2313 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 return -EIO;
2315 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302316
2317 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002318 return 0;
2319}
2320
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302321static int iw_set_bitrate(struct net_device *dev,
2322 struct iw_request_info *info,
2323 union iwreq_data *wrqu,
2324 char *extra)
2325{
2326 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002327
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302328 vos_ssr_protect(__func__);
2329 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2330 vos_ssr_unprotect(__func__);
2331
2332 return ret;
2333}
2334
2335static int __iw_set_genie(struct net_device *dev,
2336 struct iw_request_info *info,
2337 union iwreq_data *wrqu,
2338 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002339{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302340 hdd_adapter_t *pAdapter;
2341 hdd_context_t *pHddCtx;
2342 hdd_wext_state_t *pWextState;
2343 u_int8_t *genie = NULL;
2344 u_int8_t *base_genie = NULL;
2345 v_U16_t remLen;
2346 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002347
2348 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002349
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302350 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2351 if (NULL == pAdapter)
2352 {
2353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2354 "%s: Adapter is NULL",__func__);
2355 return -EINVAL;
2356 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002357
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302358 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2359 ret = wlan_hdd_validate_context(pHddCtx);
2360 if (0 != ret)
2361 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302362 return ret;
2363 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002364
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302365 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2366 if (NULL == pWextState)
2367 {
2368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2369 "%s: pWextState is NULL",__func__);
2370 return -EINVAL;
2371 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002372
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302373 if (!wrqu->data.length) {
2374 hdd_clearRoamProfileIe(pAdapter);
2375 EXIT();
2376 return 0;
2377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002378
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302379 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2380 wrqu->data.length);
2381 if (NULL == base_genie)
2382 {
2383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2384 "mem_alloc_copy_from_user_helper fail");
2385 return -ENOMEM;
2386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002387
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302388 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002389
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302390 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002391
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302392 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2393
2394 /* clear any previous genIE before this call */
2395 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2396
2397 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 {
2399 v_U16_t eLen = 0;
2400 v_U8_t elementId;
2401 elementId = *genie++;
2402 eLen = *genie++;
2403 remLen -= 2;
2404
Arif Hussain6d2a3322013-11-17 19:50:10 -08002405 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 __func__, elementId, eLen);
2407
2408 switch ( elementId )
2409 {
2410 case IE_EID_VENDOR:
2411 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002412 {
2413 kfree(base_genie);
2414 return -EINVAL;
2415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002416
2417 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2418 {
2419 v_U16_t curGenIELen = pWextState->genIE.length;
2420 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2421 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2422
2423 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2424 {
2425 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002426 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002428 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 return -ENOMEM;
2430 }
2431 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2432 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2433 pWextState->genIE.length += eLen + 2;
2434 }
2435 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2436 {
2437 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2438 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2439 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2440 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2441 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2442 }
2443 else /* any vendorId except WPA IE should be accumulated to genIE */
2444 {
2445 v_U16_t curGenIELen = pWextState->genIE.length;
2446 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2447 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2448
2449 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2450 {
2451 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002452 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002454 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 return -ENOMEM;
2456 }
2457 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2458 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2459 pWextState->genIE.length += eLen + 2;
2460 }
2461 break;
2462 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002463 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2465 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2466 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2467 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2468 break;
2469
2470 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002471 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002472 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 return 0;
2474 }
2475 genie += eLen;
2476 remLen -= eLen;
2477 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302478
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002480 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 return 0;
2482}
2483
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302484static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 struct iw_request_info *info,
2486 union iwreq_data *wrqu,
2487 char *extra)
2488{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302489 int ret;
2490
2491 vos_ssr_protect(__func__);
2492 ret = __iw_set_genie(dev, info, wrqu, extra);
2493 vos_ssr_unprotect(__func__);
2494
2495 return ret;
2496}
2497
2498static int __iw_get_genie(struct net_device *dev,
2499 struct iw_request_info *info,
2500 union iwreq_data *wrqu,
2501 char *extra)
2502{
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302504 hdd_context_t *pHddCtx;
2505 hdd_adapter_t *pAdapter;
2506 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002507 eHalStatus status;
2508 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2509 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2510
2511 ENTER();
2512
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302513 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2514 if (NULL == pAdapter)
2515 {
2516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2517 "%s: Adapter is NULL",__func__);
2518 return -EINVAL;
2519 }
2520 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2521 status = wlan_hdd_validate_context(pHddCtx);
2522 if (0 != status)
2523 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302524 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 }
2526
Jeff Johnson295189b2012-06-20 16:38:30 -07002527 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302528 if (NULL == pWextState)
2529 {
2530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2531 "%s: pWextState is NULL",__func__);
2532 return -EINVAL;
2533 }
2534
2535 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2536 if (NULL == pHddStaCtx)
2537 {
2538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2539 "%s: STA Context is NULL",__func__);
2540 return -EINVAL;
2541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002542
2543 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2544 {
2545 return -ENXIO;
2546 }
2547
2548 // Return something ONLY if we are associated with an RSN or WPA network
2549 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2550 pWextState->roamProfile.negotiatedAuthType))
2551 {
2552 return -ENXIO;
2553 }
2554
2555 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2556 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2557 pAdapter->sessionId,
2558 &length,
2559 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002560 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2561 if (wrqu->data.length < length)
2562 {
2563 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2564 return -EFAULT;
2565 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002566 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002567 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002568
Arif Hussain6d2a3322013-11-17 19:50:10 -08002569 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002570
2571 EXIT();
2572
2573 return 0;
2574}
2575
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302576static int iw_get_genie(struct net_device *dev,
2577 struct iw_request_info *info,
2578 union iwreq_data *wrqu,
2579 char *extra)
2580{
2581 int ret;
2582
2583 vos_ssr_protect(__func__);
2584 ret = __iw_get_genie(dev, info, wrqu, extra);
2585 vos_ssr_unprotect(__func__);
2586
2587 return ret;
2588}
2589
2590
2591static int __iw_get_encode(struct net_device *dev,
2592 struct iw_request_info *info,
2593 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002594{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302595 hdd_adapter_t *pAdapter;
2596 hdd_context_t *pHddCtx;
2597 hdd_wext_state_t *pWextState;
2598 tCsrRoamProfile *pRoamProfile;
2599 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002601
2602 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302603 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2604 if (NULL == pAdapter)
2605 {
2606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2607 "%s: Adapter is NULL",__func__);
2608 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 }
2610
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2612 ret = wlan_hdd_validate_context(pHddCtx);
2613 if (0 != ret)
2614 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302615 return ret;
2616 }
2617 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2618 if (NULL == pWextState)
2619 {
2620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2621 "%s: pWextState is NULL",__func__);
2622 return -EINVAL;
2623 }
2624
2625 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 keyId = pRoamProfile->Keys.defaultIndex;
2627
2628 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2629 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002630 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 return -EINVAL;
2632 }
2633
2634 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2635 {
2636 dwrq->flags |= IW_ENCODE_ENABLED;
2637 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2638 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2639
2640 dwrq->flags |= (keyId + 1);
2641
2642 }
2643 else
2644 {
2645 dwrq->flags |= IW_ENCODE_DISABLED;
2646 }
2647
2648 for(i=0; i < MAX_WEP_KEYS; i++)
2649 {
2650 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2651 {
2652 continue;
2653 }
2654 else
2655 {
2656 break;
2657 }
2658 }
2659
2660 if(MAX_WEP_KEYS == i)
2661 {
2662 dwrq->flags |= IW_ENCODE_NOKEY;
2663 }
2664
2665 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2666
2667 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2668 {
2669 dwrq->flags |= IW_ENCODE_OPEN;
2670 }
2671 else
2672 {
2673 dwrq->flags |= IW_ENCODE_RESTRICTED;
2674 }
2675 EXIT();
2676 return 0;
2677}
2678
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302679static int iw_get_encode(struct net_device *dev,
2680 struct iw_request_info *info,
2681 struct iw_point *dwrq, char *extra)
2682{
2683 int ret;
2684
2685 vos_ssr_protect(__func__);
2686 ret = __iw_get_encode(dev, info, dwrq, extra);
2687 vos_ssr_unprotect(__func__);
2688
2689 return ret;
2690}
2691
Jeff Johnson295189b2012-06-20 16:38:30 -07002692#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2693#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2694
2695
2696/*
2697 * This function sends a single 'key' to LIM at all time.
2698 */
2699
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302700static int __iw_get_rts_threshold(struct net_device *dev,
2701 struct iw_request_info *info,
2702 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002703{
2704 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2705 v_U32_t status = 0;
2706
2707 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2708
2709 return status;
2710}
2711
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302712static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 struct iw_request_info *info,
2714 union iwreq_data *wrqu, char *extra)
2715{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302716 int ret;
2717
2718 vos_ssr_protect(__func__);
2719 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2720 vos_ssr_unprotect(__func__);
2721
2722 return ret;
2723}
2724
2725static int __iw_set_rts_threshold(struct net_device *dev,
2726 struct iw_request_info *info,
2727 union iwreq_data *wrqu, char *extra)
2728{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302729 hdd_adapter_t *pAdapter;
2730 hdd_context_t *pHddCtx;
2731 tHalHandle hHal;
2732 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002733
2734 ENTER();
2735
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302736 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2737 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002738 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2740 "%s: Adapter is NULL",__func__);
2741 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002742 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302743
2744 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2745 ret = wlan_hdd_validate_context(pHddCtx);
2746 if (0 != ret)
2747 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302748 return ret;
2749 }
2750
2751 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2752 if (NULL == hHal)
2753 {
2754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2755 "%s: Hal Context is NULL",__func__);
2756 return -EINVAL;
2757 }
2758
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2760 {
2761 return -EINVAL;
2762 }
2763
2764 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2765 {
c_hpothub8245442013-11-20 23:41:09 +05302766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2767 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 return -EIO;
2769 }
2770
2771 EXIT();
2772
2773 return 0;
2774}
2775
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302776static int iw_set_rts_threshold(struct net_device *dev,
2777 struct iw_request_info *info,
2778 union iwreq_data *wrqu, char *extra)
2779{
2780 int ret;
2781
2782 vos_ssr_protect(__func__);
2783 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2784 vos_ssr_unprotect(__func__);
2785
2786 return ret;
2787}
2788
2789static int __iw_get_frag_threshold(struct net_device *dev,
2790 struct iw_request_info *info,
2791 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002792{
2793 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2794 v_U32_t status = 0;
2795
2796 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2797
2798 return status;
2799}
2800
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302801static int iw_get_frag_threshold(struct net_device *dev,
2802 struct iw_request_info *info,
2803 union iwreq_data *wrqu, char *extra)
2804{
2805 int ret;
2806
2807 vos_ssr_protect(__func__);
2808 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2809 vos_ssr_unprotect(__func__);
2810
2811 return ret;
2812}
2813
2814static int __iw_set_frag_threshold(struct net_device *dev,
2815 struct iw_request_info *info,
2816 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002817{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302818 hdd_adapter_t *pAdapter;
2819 hdd_context_t *pHddCtx;
2820 tHalHandle hHal;
2821 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002822
2823 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302824 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2825 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002826 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2828 "%s: Adapter is NULL",__func__);
2829 return -EINVAL;
2830 }
2831
2832 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2833 ret = wlan_hdd_validate_context(pHddCtx);
2834 if (0 != ret)
2835 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302836 return ret;
2837 }
2838
2839 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2840 if (NULL == hHal)
2841 {
2842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2843 "%s: Hal Context is NULL",__func__);
2844 return -EINVAL;
2845 }
2846
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2848 {
2849 return -EINVAL;
2850 }
2851
2852 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2853 {
c_hpothub8245442013-11-20 23:41:09 +05302854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2855 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 return -EIO;
2857 }
2858
2859 EXIT();
2860
2861 return 0;
2862}
2863
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302864static int iw_set_frag_threshold(struct net_device *dev,
2865 struct iw_request_info *info,
2866 union iwreq_data *wrqu, char *extra)
2867{
2868 int ret;
2869
2870 vos_ssr_protect(__func__);
2871 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2872 vos_ssr_unprotect(__func__);
2873
2874 return ret;
2875}
2876
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302877static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 struct iw_request_info *info,
2879 union iwreq_data *wrqu, char *extra)
2880{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302881 hdd_adapter_t *pAdapter;
2882 hdd_context_t *pHddCtx;
2883 int ret = 0;
2884
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302886 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2887 if (NULL == pAdapter)
2888 {
2889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2890 "%s: Adapter is NULL",__func__);
2891 return -EINVAL;
2892 }
2893 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2894 ret = wlan_hdd_validate_context(pHddCtx);
2895 if (0 != ret)
2896 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302897 return ret;
2898 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302899
2900 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 return -EOPNOTSUPP;
2902}
2903
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302904static int iw_get_power_mode(struct net_device *dev,
2905 struct iw_request_info *info,
2906 union iwreq_data *wrqu, char *extra)
2907{
2908 int ret;
2909
2910 vos_ssr_protect(__func__);
2911 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2912 vos_ssr_unprotect(__func__);
2913
2914 return ret;
2915}
2916static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 struct iw_request_info *info,
2918 union iwreq_data *wrqu, char *extra)
2919{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302920 hdd_adapter_t *pAdapter;
2921 hdd_context_t *pHddCtx;
2922 int ret = 0;
2923
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302925 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2926 if (NULL == pAdapter)
2927 {
2928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2929 "%s: Adapter is NULL",__func__);
2930 return -EINVAL;
2931 }
2932 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2933 ret = wlan_hdd_validate_context(pHddCtx);
2934 if (0 != ret)
2935 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302936 return ret;
2937 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302938
2939 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002940 return -EOPNOTSUPP;
2941}
2942
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302943static int iw_set_power_mode(struct net_device *dev,
2944 struct iw_request_info *info,
2945 union iwreq_data *wrqu, char *extra)
2946{
2947 int ret;
2948
2949 vos_ssr_protect(__func__);
2950 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2951 vos_ssr_unprotect(__func__);
2952
2953 return ret;
2954}
2955
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302956static int __iw_get_range(struct net_device *dev,
2957 struct iw_request_info *info,
2958 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002959{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302960 hdd_adapter_t *pAdapter;
2961 tHalHandle hHal;
2962 hdd_context_t *pHddCtx;
2963 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 struct iw_range *range = (struct iw_range *) extra;
2965
2966 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2967
2968 v_U32_t num_channels = sizeof(channels);
2969 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2970 v_U32_t a_len;
2971 v_U32_t b_len;
2972 v_U32_t active_phy_mode = 0;
2973 v_U8_t index = 0, i;
2974
2975 ENTER();
2976
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302977 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2978 if (NULL == pAdapter)
2979 {
2980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2981 "%s: pAdapter is NULL", __func__);
2982 return -EINVAL;
2983 }
2984 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2985 ret = wlan_hdd_validate_context(pHddCtx);
2986 if (0 != ret)
2987 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302988 return ret;
2989 }
2990 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2991 if (NULL == hHal)
2992 {
2993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2994 "%s: pAdapter is NULL", __func__);
2995 return -EINVAL;
2996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 wrqu->data.length = sizeof(struct iw_range);
2998 memset(range, 0, sizeof(struct iw_range));
2999
Jeff Johnson295189b2012-06-20 16:38:30 -07003000 /*Get the phy mode*/
3001 if (ccmCfgGetInt(hHal,
3002 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3003 {
3004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003005 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003006
3007 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3008 {
3009 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003010 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 if (ccmCfgGetStr(hHal,
3012 WNI_CFG_SUPPORTED_RATES_11A,
3013 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3014 {
3015 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3016 {
3017 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3018 }
3019 for (i = 0; i < a_len; i++)
3020 {
3021 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3022 }
3023 range->num_bitrates = a_len;
3024 }
3025 else
3026 {
3027 return -EIO;
3028 }
3029 }
3030 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3031 {
3032 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003033 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 if (ccmCfgGetStr(hHal,
3035 WNI_CFG_SUPPORTED_RATES_11B,
3036 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3037 {
3038 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3039 {
3040 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3041 }
3042 for (i = 0; i < b_len; i++)
3043 {
3044 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3045 }
3046 range->num_bitrates = b_len;
3047 }
3048 else
3049 {
3050 return -EIO;
3051 }
3052 }
3053 }
3054
3055 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3056 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3057 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3058
3059 range->encoding_size[0] = 5;
3060 range->encoding_size[1] = 13;
3061 range->num_encoding_sizes = 2;
3062 range->max_encoding_tokens = MAX_WEP_KEYS;
3063
3064 // we support through Wireless Extensions 22
3065 range->we_version_compiled = WIRELESS_EXT;
3066 range->we_version_source = 22;
3067
3068 /*Supported Channels and Frequencies*/
3069 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3070 {
c_hpothub8245442013-11-20 23:41:09 +05303071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3072 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 return -EIO;
3074 }
3075 if (num_channels > IW_MAX_FREQUENCIES)
3076 {
3077 num_channels = IW_MAX_FREQUENCIES;
3078 }
3079
3080 range->num_channels = num_channels;
3081 range->num_frequency = num_channels;
3082
3083 for (index=0; index < num_channels; index++)
3084 {
3085 v_U32_t frq_indx = 0;
3086
3087 range->freq[index].i = channels[index];
3088 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3089 {
3090 if(channels[index] == freq_chan_map[frq_indx].chan)
3091 {
3092 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3093 range->freq[index].e = 1;
3094 break;
3095 }
3096 frq_indx++;
3097 }
3098 }
3099
3100 /* Event capability (kernel + driver) */
3101 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3102 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3103 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3104 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3105
3106 /*Encryption capability*/
3107 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3108 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3109
3110 /* Txpower capability */
3111 range->txpower_capa = IW_TXPOW_MWATT;
3112
3113 /*Scanning capability*/
3114 #if WIRELESS_EXT >= 22
3115 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3116 #endif
3117
3118 EXIT();
3119 return 0;
3120}
3121
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303122static int iw_get_range(struct net_device *dev,
3123 struct iw_request_info *info,
3124 union iwreq_data *wrqu, char *extra)
3125{
3126 int ret;
3127
3128 vos_ssr_protect(__func__);
3129 ret = __iw_get_range(dev, info, wrqu, extra);
3130 vos_ssr_unprotect(__func__);
3131
3132 return ret;
3133}
3134
Jeff Johnson295189b2012-06-20 16:38:30 -07003135/* Callback function registered with PMC to know status of PMC request */
3136static void iw_power_callback_fn (void *pContext, eHalStatus status)
3137{
3138 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003139
3140 if (NULL == pContext)
3141 {
3142 hddLog(VOS_TRACE_LEVEL_ERROR,
3143 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003144 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 return;
3146 }
3147
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003149
Jeff Johnson72a40512013-12-19 10:14:15 -08003150 /* there is a race condition that exists between this callback
3151 function and the caller since the caller could time out either
3152 before or while this code is executing. we use a spinlock to
3153 serialize these actions */
3154 spin_lock(&hdd_context_lock);
3155
3156 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 {
3158 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003159 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003161 "%s: Invalid context, magic [%08x]",
3162 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003163
3164 if (ioctl_debug)
3165 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003166 pr_info("%s: Invalid context, magic [%08x]\n",
3167 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 }
3169 return;
3170 }
3171
Jeff Johnson72a40512013-12-19 10:14:15 -08003172 /* context is valid so caller is still waiting */
3173
3174 /* paranoia: invalidate the magic */
3175 pStatsContext->magic = 0;
3176
3177 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003179
3180 /* serialization is complete */
3181 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003182}
3183
3184/* Callback function for tx per hit */
3185void hdd_tx_per_hit_cb (void *pCallbackContext)
3186{
3187 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3188 unsigned char tx_fail[16];
3189 union iwreq_data wrqu;
3190
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303191 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003193 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 return;
3195 }
3196 memset(&wrqu, 0, sizeof(wrqu));
3197 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3198 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3199}
3200
3201void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3202{
3203 struct statsContext *pStatsContext;
3204 tCsrGlobalClassAStatsInfo *pClassAStats;
3205 hdd_adapter_t *pAdapter;
3206
3207 if (ioctl_debug)
3208 {
3209 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003210 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 }
3212
3213 if ((NULL == pStats) || (NULL == pContext))
3214 {
3215 hddLog(VOS_TRACE_LEVEL_ERROR,
3216 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003217 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 return;
3219 }
3220
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 pClassAStats = pStats;
3222 pStatsContext = pContext;
3223 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003224
3225 /* there is a race condition that exists between this callback
3226 function and the caller since the caller could time out either
3227 before or while this code is executing. we use a spinlock to
3228 serialize these actions */
3229 spin_lock(&hdd_context_lock);
3230
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3232 {
3233 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003234 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003235 hddLog(VOS_TRACE_LEVEL_WARN,
3236 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003237 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 if (ioctl_debug)
3239 {
3240 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003241 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 }
3243 return;
3244 }
3245
Jeff Johnson72a40512013-12-19 10:14:15 -08003246 /* context is valid so caller is still waiting */
3247
3248 /* paranoia: invalidate the magic */
3249 pStatsContext->magic = 0;
3250
3251 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3253
Jeff Johnson72a40512013-12-19 10:14:15 -08003254 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003256
3257 /* serialization is complete */
3258 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003259}
3260
3261VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3262{
3263 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3264 eHalStatus hstatus;
3265 long lrc;
3266 struct statsContext context;
3267
3268 if (NULL == pAdapter)
3269 {
3270 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3271 return VOS_STATUS_E_FAULT;
3272 }
3273 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3274 {
3275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3276 return VOS_STATUS_SUCCESS;
3277 }
3278
3279 /* we are connected
3280 prepare our callback context */
3281 init_completion(&context.completion);
3282 context.pAdapter = pAdapter;
3283 context.magic = STATS_CONTEXT_MAGIC;
3284 /* query only for Class A statistics (which include link speed) */
3285 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3286 eCSR_HDD,
3287 SME_GLOBAL_CLASSA_STATS,
3288 hdd_GetClassA_statisticsCB,
3289 0, // not periodic
3290 FALSE, //non-cached results
3291 pHddStaCtx->conn_info.staId[0],
3292 &context);
3293 if (eHAL_STATUS_SUCCESS != hstatus)
3294 {
3295 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003296 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003297 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 /* we'll returned a cached value below */
3299 }
3300 else
3301 {
3302 /* request was sent -- wait for the response */
3303 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3304 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 if (lrc <= 0)
3306 {
3307 hddLog(VOS_TRACE_LEVEL_ERROR,
3308 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003309 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 }
3311 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003312
3313 /* either we never sent a request, we sent a request and received a
3314 response or we sent a request and timed out. if we never sent a
3315 request or if we sent a request and got a response, we want to
3316 clear the magic out of paranoia. if we timed out there is a
3317 race condition such that the callback function could be
3318 executing at the same time we are. of primary concern is if the
3319 callback function had already verified the "magic" but had not
3320 yet set the completion variable when a timeout occurred. we
3321 serialize these activities by invalidating the magic while
3322 holding a shared spinlock which will cause us to block if the
3323 callback is currently executing */
3324 spin_lock(&hdd_context_lock);
3325 context.magic = 0;
3326 spin_unlock(&hdd_context_lock);
3327
3328 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 return VOS_STATUS_SUCCESS;
3330}
3331
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003332static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3333{
3334 struct statsContext *pStatsContext;
3335 tCsrSummaryStatsInfo *pSummaryStats;
3336 tCsrGlobalClassAStatsInfo *pClassAStats;
3337 hdd_adapter_t *pAdapter;
3338
3339 if (ioctl_debug)
3340 {
3341 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003342 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003343 }
3344
3345 if ((NULL == pStats) || (NULL == pContext))
3346 {
3347 hddLog(VOS_TRACE_LEVEL_ERROR,
3348 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003349 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003350 return;
3351 }
3352
Jeff Johnson72a40512013-12-19 10:14:15 -08003353 /* there is a race condition that exists between this callback
3354 function and the caller since the caller could time out either
3355 before or while this code is executing. we use a spinlock to
3356 serialize these actions */
3357 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003358
3359 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3360 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3361 pStatsContext = pContext;
3362 pAdapter = pStatsContext->pAdapter;
3363 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3364 {
3365 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003366 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003367 hddLog(VOS_TRACE_LEVEL_WARN,
3368 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003369 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003370 if (ioctl_debug)
3371 {
3372 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003373 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003374 }
3375 return;
3376 }
3377
Jeff Johnson72a40512013-12-19 10:14:15 -08003378 /* context is valid so caller is still waiting */
3379
3380 /* paranoia: invalidate the magic */
3381 pStatsContext->magic = 0;
3382
3383 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003384 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3385 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3386
Jeff Johnson72a40512013-12-19 10:14:15 -08003387 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003388 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003389
3390 /* serialization is complete */
3391 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003392}
3393
3394VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3395{
3396 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3397 eHalStatus hstatus;
3398 long lrc;
3399 struct statsContext context;
3400
3401 if (NULL == pAdapter)
3402 {
3403 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3404 return VOS_STATUS_SUCCESS;
3405 }
3406
3407 /* we are connected
3408 prepare our callback context */
3409 init_completion(&context.completion);
3410 context.pAdapter = pAdapter;
3411 context.magic = STATS_CONTEXT_MAGIC;
3412
3413 /* query only for Summary & Class A statistics */
3414 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3415 eCSR_HDD,
3416 SME_SUMMARY_STATS |
3417 SME_GLOBAL_CLASSA_STATS,
3418 hdd_get_station_statisticsCB,
3419 0, // not periodic
3420 FALSE, //non-cached results
3421 pHddStaCtx->conn_info.staId[0],
3422 &context);
3423 if (eHAL_STATUS_SUCCESS != hstatus)
3424 {
3425 hddLog(VOS_TRACE_LEVEL_ERROR,
3426 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003427 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003428 /* we'll return with cached values */
3429 }
3430 else
3431 {
3432 /* request was sent -- wait for the response */
3433 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3434 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003435
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003436 if (lrc <= 0)
3437 {
3438 hddLog(VOS_TRACE_LEVEL_ERROR,
3439 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003440 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003441 }
3442 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003443
3444 /* either we never sent a request, we sent a request and received a
3445 response or we sent a request and timed out. if we never sent a
3446 request or if we sent a request and got a response, we want to
3447 clear the magic out of paranoia. if we timed out there is a
3448 race condition such that the callback function could be
3449 executing at the same time we are. of primary concern is if the
3450 callback function had already verified the "magic" but had not
3451 yet set the completion variable when a timeout occurred. we
3452 serialize these activities by invalidating the magic while
3453 holding a shared spinlock which will cause us to block if the
3454 callback is currently executing */
3455 spin_lock(&hdd_context_lock);
3456 context.magic = 0;
3457 spin_unlock(&hdd_context_lock);
3458
3459 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003460 return VOS_STATUS_SUCCESS;
3461}
3462
3463
Jeff Johnson295189b2012-06-20 16:38:30 -07003464/*
3465 * Support for the LINKSPEED private command
3466 * Per the WiFi framework the response must be of the form
3467 * "LinkSpeed xx"
3468 */
3469static int iw_get_linkspeed(struct net_device *dev,
3470 struct iw_request_info *info,
3471 union iwreq_data *wrqu, char *extra)
3472{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303473 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303474 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303476 int len = sizeof(v_U32_t) + 1;
3477 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303478 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303479 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303480 int rc, valid = 0;
3481
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303482 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303483 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3484 if (NULL == pAdapter)
3485 {
3486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3487 "%s: Adapter is NULL",__func__);
3488 return -EINVAL;
3489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003490
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303491 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303492 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303493 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003494 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303495 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003496 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303497 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3498 if (NULL == pHddStaCtx)
3499 {
3500 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3501 "%s: STA Context is NULL",__func__);
3502 return -EINVAL;
3503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3505 {
3506 /* we are not connected so we don't have a classAstats */
3507 link_speed = 0;
3508 }
3509 else
3510 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303511 status = wlan_hdd_get_classAstats(pAdapter);
3512
3513 if (!VOS_IS_STATUS_SUCCESS(status ))
3514 {
3515 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3516 return -EINVAL;
3517 }
3518
3519 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3520 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3521 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3522 &link_speed);
3523
3524 link_speed = link_speed / 10;
3525
3526 if (0 == link_speed)
3527 {
3528 /* The linkspeed returned by HAL is in units of 500kbps.
3529 * converting it to mbps.
3530 * This is required to support legacy firmware which does
3531 * not return link capacity.
3532 */
3533 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3534 }
3535
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 }
3537
3538 wrqu->data.length = len;
3539 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003540 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 if ((rc < 0) || (rc >= len))
3542 {
3543 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303544 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 return -EIO;
3546 }
3547
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303548 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003550 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003551}
3552
Arif Hussain695279c2014-03-24 14:06:07 -07003553/*
3554 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3555 *
3556 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303557static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003558 struct iw_request_info *info,
3559 union iwreq_data *wrqu, char *extra)
3560{
3561 int rc;
3562
3563 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3564
3565 if (rc < 0)
3566 return rc;
3567
3568 /* a value is being successfully returned */
3569 return 0;
3570}
Jeff Johnson295189b2012-06-20 16:38:30 -07003571
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303572static int iw_get_linkspeed_priv(struct net_device *dev,
3573 struct iw_request_info *info,
3574 union iwreq_data *wrqu, char *extra)
3575{
3576 int ret;
3577
3578 vos_ssr_protect(__func__);
3579 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3580 vos_ssr_unprotect(__func__);
3581
3582 return ret;
3583}
3584
Jeff Johnson295189b2012-06-20 16:38:30 -07003585/*
3586 * Support for the RSSI & RSSI-APPROX private commands
3587 * Per the WiFi framework the response must be of the form
3588 * "<ssid> rssi <xx>"
3589 * unless we are not associated, in which case the response is
3590 * "OK"
3591 */
3592static int iw_get_rssi(struct net_device *dev,
3593 struct iw_request_info *info,
3594 union iwreq_data *wrqu, char *extra)
3595{
3596 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003597 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 int len = wrqu->data.length;
3599 v_S7_t s7Rssi = 0;
3600 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3601 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3602 VOS_STATUS vosStatus;
3603 int rc;
3604
3605 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3606 (0 == ssidlen) || (ssidlen >= len))
3607 {
3608 /* we are not connected or our SSID is too long
3609 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003610 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 }
3612 else
3613 {
3614 /* we are connected with a valid SSID
3615 so we can write the SSID into the return buffer
3616 (note that it is not NUL-terminated) */
3617 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3618
3619 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3620
3621 if (VOS_STATUS_SUCCESS == vosStatus)
3622 {
3623 /* append the rssi to the ssid in the format required by
3624 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003625 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303626 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 }
3628 else
3629 {
3630 rc = -1;
3631 }
3632 }
3633
3634 /* verify that we wrote a valid response */
3635 if ((rc < 0) || (rc >= len))
3636 {
3637 // encoding or length error?
3638 hddLog(VOS_TRACE_LEVEL_ERROR,
3639 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003640 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 return -EIO;
3642 }
3643
3644 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003645 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003646}
3647
3648/*
3649 * Support for SoftAP channel range private command
3650 */
3651static int iw_softap_set_channel_range( struct net_device *dev,
3652 int startChannel,
3653 int endChannel,
3654 int band)
3655{
Jeff Johnson43971f52012-07-17 12:26:56 -07003656 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 int ret = 0;
3658 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3659 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003660 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3661
Jeff Johnson295189b2012-06-20 16:38:30 -07003662
3663 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3664 if (VOS_STATUS_SUCCESS != status)
3665 {
3666 ret = -EINVAL;
3667 }
Yathish9f22e662012-12-10 14:21:35 -08003668 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 return ret;
3670}
3671
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303672static uint8 chartohex(char c)
3673{
3674 uint8 val = 0;
3675 if (c >= '0' && c <= '9')
3676 val = c - '0';
3677 else if (c >= 'a' && c <= 'f')
3678 val = c - 'a' + 10;
3679 else if (c >= 'A' && c <= 'F')
3680 val = c - 'A' + 10;
3681 else
3682 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3683
3684 return val;
3685}
3686
3687uint8 getByte(char **buf)
3688{
3689 uint8 byte = 0;
3690 char *temp = *buf;
3691 byte = chartohex(*temp) * 16;
3692 temp++;
3693 byte += chartohex(*temp);
3694 temp++;
3695 *buf = temp;
3696 return byte;
3697}
3698
3699static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3700{
3701 tSir80211Header *macHeader;
3702 int i = 0, j = 0, length = 0;
3703 uint8 byte = 0;
3704 char *temp = pBuffer;
3705 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303706 char *pHeader;
3707 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303708
3709 macHeader = &pkt->macHeader;
3710
3711 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3712
3713 temp++;
3714
3715 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3716 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3717 pkt->encParams.keyParams.key[0].keyId);
3718
3719 for (i = 0; i< 16; i++) {
3720 pkt->encParams.keyParams.key[0].key[i]
3721 = getByte(&temp);
3722 }
3723
3724 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3725 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3726
3727 for (i = 0; i< 6; i++) {
3728 pkt->encParams.pn[i]
3729 = getByte(&temp);
3730 }
3731
3732 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3733 &pkt->encParams.pn[0], 6, 0);
3734
3735 for (i = 0, j= 5; i< 3; i++, j--) {
3736 byte = pkt->encParams.pn[i];
3737 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3738 pkt->encParams.pn[j] = byte;
3739 }
3740
3741 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303742 if (length > sizeof(tSir80211Header))
3743 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303744
Srinivas Dasari2382de62015-01-22 15:00:04 +05303745 pHeader = temp;
3746 vos_mem_zero(&header, sizeof(tSir80211Header));
3747 for (i = 0; i < length; i++) {
3748 *((uint8 *)&header + i) = getByte(&pHeader);
3749 }
3750
3751 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3752 (char *)&header, length, 0);
3753
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303754 byte = getByte(&temp);
3755
3756 macHeader->frameCtrl.protVer = byte & 0x3;
3757 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3758 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3759
3760 byte = getByte(&temp);
3761 macHeader->frameCtrl.toDS = (byte) & 0x1;
3762 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3763 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3764 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3765 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3766 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3767 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3768 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3769
3770 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3771 "macHeader->frameCtrl.type : %x "
3772 "macHeader->frameCtrl.subType : %x "
3773 "macHeader->frameCtrl.toDS : %x "
3774 "macHeader->frameCtrl.fromDS : %x "
3775 "macHeader->frameCtrl.moreFrag : %x "
3776 "macHeader->frameCtrl.retry : %x "
3777 "macHeader->frameCtrl.powerMgmt : %x "
3778 "macHeader->frameCtrl.MoreData : %x "
3779 "macHeader->frameCtrl.wep : %x "
3780 "macHeader->frameCtrl.order : %x "
3781 , macHeader->frameCtrl.protVer
3782 , macHeader->frameCtrl.type
3783 , macHeader->frameCtrl.subType
3784 , macHeader->frameCtrl.toDS
3785 , macHeader->frameCtrl.fromDS
3786 , macHeader->frameCtrl.moreFrag
3787 , macHeader->frameCtrl.retry
3788 , macHeader->frameCtrl.powerMgmt
3789 , macHeader->frameCtrl.moreData
3790 , macHeader->frameCtrl.wep
3791 , macHeader->frameCtrl.order);
3792
3793
3794 macHeader->usDurationId = getByte(&temp);
3795 macHeader->usDurationId += getByte(&temp) << 8;
3796
3797 macHeader->vA1[0] = getByte(&temp);
3798 macHeader->vA1[1] = getByte(&temp);
3799 macHeader->vA1[2] = getByte(&temp);
3800 macHeader->vA1[3] = getByte(&temp);
3801 macHeader->vA1[4] = getByte(&temp);
3802 macHeader->vA1[5] = getByte(&temp);
3803
3804 macHeader->vA2[0] = getByte(&temp);
3805 macHeader->vA2[1] = getByte(&temp);
3806 macHeader->vA2[2] = getByte(&temp);
3807 macHeader->vA2[3] = getByte(&temp);
3808 macHeader->vA2[4] = getByte(&temp);
3809 macHeader->vA2[5] = getByte(&temp);
3810
3811 macHeader->vA3[0] = getByte(&temp);
3812 macHeader->vA3[1] = getByte(&temp);
3813 macHeader->vA3[2] = getByte(&temp);
3814 macHeader->vA3[3] = getByte(&temp);
3815 macHeader->vA3[4] = getByte(&temp);
3816 macHeader->vA3[5] = getByte(&temp);
3817
3818 macHeader->sSeqCtrl = getByte(&temp);
3819 fragNum = macHeader->sSeqCtrl & 0xF;
3820 macHeader->sSeqCtrl >>= 4;
3821
3822 macHeader->sSeqCtrl += getByte(&temp) << 4;
3823
3824 macHeader->sSeqCtrl |= fragNum << 12;
3825
3826 if (length == 30 || length == 32) {
3827 macHeader->optvA4[0] = getByte(&temp);
3828 macHeader->optvA4[1] = getByte(&temp);
3829 macHeader->optvA4[2] = getByte(&temp);
3830 macHeader->optvA4[3] = getByte(&temp);
3831 macHeader->optvA4[4] = getByte(&temp);
3832 macHeader->optvA4[5] = getByte(&temp);
3833 }
3834
3835 if (length == 26 || length == 32) {
3836 macHeader->usQosCtrl = getByte(&temp);
3837 macHeader->usQosCtrl += getByte(&temp) << 8;
3838 }
3839
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303840 //parse payload
3841 length = getByte(&temp);
3842 length += getByte(&temp) << 8;
3843 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3844
3845 pkt->data.length = length;
3846
3847 for (i = 0; i< length; i++) {
3848 pkt->data.data[i] = getByte(&temp);
3849 }
3850
3851 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3852 &pkt->data.data[0], pkt->data.length, 0);
3853}
3854
3855/**---------------------------------------------------------------------------
3856
3857 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3858 encrypt message request
3859 This is an asynchronous callback function from SME when the encrypted data
3860 is received
3861
3862 \pEncInfoRsp -> Encrypted data info
3863
3864 \return - 0 for success non-zero for failure
3865 --------------------------------------------------------------------------*/
3866static void
3867hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3868{
3869 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3870
3871 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3872
3873 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3874 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3875 pEncryptedDataRsp->encryptedPayload.length);
3876 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3877 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3878 pEncryptedDataRsp->encryptedPayload.data,
3879 pEncryptedDataRsp->encryptedPayload.length, 0);
3880}
3881
Jeff Johnson295189b2012-06-20 16:38:30 -07003882VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3883{
3884 struct statsContext context;
3885 eHalStatus status;
3886 hdd_context_t *pHddCtx;
3887
3888 if (NULL == pAdapter)
3889 {
3890 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3891 return VOS_STATUS_E_FAULT;
3892 }
3893
3894 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3895 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303896 if (pHddCtx->isLogpInProgress) {
3897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3898 "%s:LOGP in Progress. Ignore!!!", __func__);
3899 return VOS_STATUS_E_FAILURE;
3900 }
3901
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 init_completion(&context.completion);
3903
3904 context.pAdapter = pAdapter;
3905 context.magic = POWER_CONTEXT_MAGIC;
3906
3907 if (DRIVER_POWER_MODE_ACTIVE == mode)
3908 {
3909 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3910 "Full Power", __func__);
3911 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3912 iw_power_callback_fn, &context,
3913 eSME_FULL_PWR_NEEDED_BY_HDD);
3914 // Enter Full power command received from GUI this means we are disconnected
3915 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3916 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3917 if (eHAL_STATUS_PMC_PENDING == status)
3918 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003919 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 int lrc = wait_for_completion_interruptible_timeout(
3921 &context.completion,
3922 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003923
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 if (lrc <= 0)
3925 {
3926 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003927 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 }
3929 }
3930 }
3931 else if (DRIVER_POWER_MODE_AUTO == mode)
3932 {
3933 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3934 {
3935 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3936 __func__);
3937 // Enter BMPS command received from GUI this means DHCP is completed
3938 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3939 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3940 FALSE);
3941 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3942 iw_power_callback_fn, &context);
3943 if (eHAL_STATUS_PMC_PENDING == status)
3944 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003945 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 int lrc = wait_for_completion_interruptible_timeout(
3947 &context.completion,
3948 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 if (lrc <= 0)
3950 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003951 hddLog(VOS_TRACE_LEVEL_ERROR,
3952 "%s: SME %s while requesting BMPS",
3953 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 }
3955 }
3956 }
3957 else
3958 {
3959 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3960 "enabled in the cfg");
3961 }
3962 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003963
3964 /* either we never sent a request, we sent a request and received a
3965 response or we sent a request and timed out. if we never sent a
3966 request or if we sent a request and got a response, we want to
3967 clear the magic out of paranoia. if we timed out there is a
3968 race condition such that the callback function could be
3969 executing at the same time we are. of primary concern is if the
3970 callback function had already verified the "magic" but had not
3971 yet set the completion variable when a timeout occurred. we
3972 serialize these activities by invalidating the magic while
3973 holding a shared spinlock which will cause us to block if the
3974 callback is currently executing */
3975 spin_lock(&hdd_context_lock);
3976 context.magic = 0;
3977 spin_unlock(&hdd_context_lock);
3978
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 return VOS_STATUS_SUCCESS;
3980}
3981
3982VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3983 hdd_adapter_t *pAdapter)
3984{
3985 VOS_STATUS vos_Status;
3986
3987 if ((NULL == pAdapter) || (NULL == pHddCtx))
3988 {
3989 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3990 return VOS_STATUS_E_FAULT;
3991 }
3992
3993 /**Exit from Deep sleep or standby if we get the driver
3994 START cmd from android GUI
3995 */
3996 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3997 {
3998 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
3999 "from Stand by",__func__);
4000 vos_Status = hdd_exit_standby(pHddCtx);
4001 }
4002 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4003 {
4004 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4005 "from deep sleep",__func__);
4006 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4007 }
4008 else
4009 {
4010 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4011 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4012 vos_Status = VOS_STATUS_SUCCESS;
4013 }
4014
4015 return vos_Status;
4016}
4017
4018VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4019{
4020 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4021
4022 if (NULL == pHddCtx)
4023 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304024 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 return VOS_STATUS_E_FAULT;
4026 }
4027
4028 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4029 {
4030 //Execute standby procedure.
4031 //Executing standby procedure will cause the STA to
4032 //disassociate first and then the chip will be put into standby.
4033 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4034 vos_Status = hdd_enter_standby(pHddCtx);
4035 }
4036 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4037 pHddCtx->cfg_ini->nEnableDriverStop)
4038 {
4039 //Execute deep sleep procedure
4040 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004041 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 //Deep sleep not supported
4043 vos_Status = hdd_enter_standby(pHddCtx);
4044 }
4045 else
4046 {
4047 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4048 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4049 vos_Status = VOS_STATUS_SUCCESS;
4050 }
4051
4052 return vos_Status;
4053}
4054
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004055
4056void* wlan_hdd_change_country_code_callback(void *pAdapter)
4057{
4058
4059 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004060 complete(&call_back_pAdapter->change_country_code);
4061
4062 return NULL;
4063}
4064
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304065static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 struct iw_request_info *info,
4067 union iwreq_data *wrqu, char *extra)
4068{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304069 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004070 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304072 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004073 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4074
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304075 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004076
4077 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304078
4079 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4080 if (NULL == pAdapter)
4081 {
4082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4083 "mem_alloc_copy_from_user_helper fail");
4084 return -EINVAL;
4085 }
4086 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4087 rc = wlan_hdd_validate_context(pHddCtx);
4088 if (0 != rc)
4089 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304090 return rc;
4091 }
4092
Arif Hussain24bfa702014-01-22 13:51:30 -08004093 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4094 wrqu->data.length);
4095 if (NULL == cmd)
4096 {
4097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4098 "mem_alloc_copy_from_user_helper fail");
4099 return -ENOMEM;
4100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004101
4102 if (ioctl_debug)
4103 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004104 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 }
4106
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004107 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4108 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004109
Arif Hussain24bfa702014-01-22 13:51:30 -08004110 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004112 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4114 "%s: Error in iw_set_scan!", __func__);
4115 rc = -EINVAL;
4116 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 }
4118 else if( strcasecmp(cmd, "start") == 0 ) {
4119
Arif Hussain6d2a3322013-11-17 19:50:10 -08004120 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004122
Arif Hussain24bfa702014-01-22 13:51:30 -08004123 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4124 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 {
4126 union iwreq_data wrqu;
4127 char buf[10];
4128
4129 memset(&wrqu, 0, sizeof(wrqu));
4130 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4131 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4132 }
4133 else
4134 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004135 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4136 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 }
4138 goto done;
4139 }
4140 else if( strcasecmp(cmd, "stop") == 0 )
4141 {
4142 union iwreq_data wrqu;
4143 char buf[10];
4144
Arif Hussain6d2a3322013-11-17 19:50:10 -08004145 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004146
4147 wlan_hdd_enter_lowpower(pHddCtx);
4148 memset(&wrqu, 0, sizeof(wrqu));
4149 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4150 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 goto done;
4152 }
4153 else if (strcasecmp(cmd, "macaddr") == 0)
4154 {
4155 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4156 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4157 }
4158 else if (strcasecmp(cmd, "scan-active") == 0)
4159 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304160 hddLog(VOS_TRACE_LEVEL_ERROR,
4161 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004162 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 ret = snprintf(cmd, cmd_len, "OK");
4164 }
4165 else if (strcasecmp(cmd, "scan-passive") == 0)
4166 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304167 hddLog(VOS_TRACE_LEVEL_ERROR,
4168 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004169 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 ret = snprintf(cmd, cmd_len, "OK");
4171 }
4172 else if( strcasecmp(cmd, "scan-mode") == 0 )
4173 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004174 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 }
4176 else if( strcasecmp(cmd, "linkspeed") == 0 )
4177 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004178 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 }
4180 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4181 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004182 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004183 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004184
4185 country_code = cmd + 8;
4186
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004187 init_completion(&pAdapter->change_country_code);
4188
Arif Hussain24bfa702014-01-22 13:51:30 -08004189 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004190 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 country_code,
4192 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304193 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304194 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304195 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004196
4197 /* Wait for completion */
4198 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4199 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4200
4201 if (lrc <= 0)
4202 {
4203 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004204 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004205 }
4206
Arif Hussain24bfa702014-01-22 13:51:30 -08004207 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004209 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004210 "%s: SME Change Country code fail", __func__);
4211 kfree(cmd);
4212 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 }
4214 }
4215 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4216 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004217 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 }
4219 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4220 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004221 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004222
Wilson Yang1be3e652013-10-09 15:18:31 -07004223 if (9 < cmd_len)
4224 {
4225 ptr = (char*)(cmd + 9);
4226
4227 }else{
4228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4229 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004230 kfree(cmd);
4231 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004232 }
4233
4234 if (1 != sscanf(ptr,"%d",&mode))
4235 {
4236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4237 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004238 kfree(cmd);
4239 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004240 }
4241
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 wlan_hdd_enter_bmps(pAdapter, mode);
4243 /*TODO:Set the power mode*/
4244 }
4245 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4246 v_U32_t pmc_state;
4247 v_U16_t value;
4248
4249 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4250 if(pmc_state == BMPS) {
4251 value = DRIVER_POWER_MODE_AUTO;
4252 }
4253 else {
4254 value = DRIVER_POWER_MODE_ACTIVE;
4255 }
4256 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4257 }
4258 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004259 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004260 /*TODO: set the btcoexmode*/
4261 }
4262 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4263
Arif Hussain6d2a3322013-11-17 19:50:10 -08004264 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 /*TODO: Return the btcoex status*/
4266 }
4267 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4268
Arif Hussain6d2a3322013-11-17 19:50:10 -08004269 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004270
4271 /*TODO: Enable Rx data Filter*/
4272 }
4273 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4274
Arif Hussain6d2a3322013-11-17 19:50:10 -08004275 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004276
4277 /*TODO: Disable Rx data Filter*/
4278 }
4279 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4280
Arif Hussain6d2a3322013-11-17 19:50:10 -08004281 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 /*TODO: rxfilter-statistics*/
4283 }
4284 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4285
Arif Hussain6d2a3322013-11-17 19:50:10 -08004286 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 /*TODO: rxfilter-add*/
4288 }
4289 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4290
Arif Hussain6d2a3322013-11-17 19:50:10 -08004291 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 /*TODO: rxfilter-remove*/
4293 }
4294#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004295 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4296 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4297 /*TODO: support pnosetup*/
4298 }
4299 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4300 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4301 /*TODO: support pnoforce*/
4302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4304
Arif Hussain6d2a3322013-11-17 19:50:10 -08004305 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004306 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4307 kfree(cmd);
4308 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 }
4310 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004311 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004312 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4313 kfree(cmd);
4314 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 }
4316#endif /*FEATURE_WLAN_SCAN_PNO*/
4317 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004318 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004319 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4320 kfree(cmd);
4321 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 }
4323 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4324 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004325 char *ptr;
4326
4327 if (18 < cmd_len)
4328 {
4329 ptr = (char*)(cmd + 18);
4330 }else{
4331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4332 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004333 kfree(cmd);
4334 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004335 }
4336
Jeff Johnson02797792013-10-26 19:17:13 -07004337 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004338 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4339 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4340 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4341 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4342 {
4343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4344 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004345 kfree(cmd);
4346 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004348
4349 // parameters checking
4350 // period has to be larger than 0
4351 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4352 {
4353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004354 kfree(cmd);
4355 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 }
4357
4358 // use default value 5 is the input is not reasonable. in unit of 10%
4359 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4360 {
4361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4362 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4363 }
4364
4365 // default is 5
4366 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4367 {
4368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4369 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4370 }
4371
Arif Hussain24bfa702014-01-22 13:51:30 -08004372 if (eHAL_STATUS_SUCCESS !=
4373 sme_SetTxPerTracking(pHddCtx->hHal,
4374 hdd_tx_per_hit_cb,
4375 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004377 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 }
4379 }
4380 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004381 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4382 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 }
4384done:
4385 /* many of the commands write information back into the command
4386 string using snprintf(). check the return value here in one
4387 place */
4388 if ((ret < 0) || (ret >= cmd_len))
4389 {
4390 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004391 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004393 else if (ret > 0)
4394 {
4395 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4396 {
4397 hddLog(VOS_TRACE_LEVEL_ERROR,
4398 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004399 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004400 return -EFAULT;
4401 }
4402 wrqu->data.length = ret;
4403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004404
4405 if (ioctl_debug)
4406 {
4407 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004408 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004410 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304411 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004412 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004413}
4414
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304415static int iw_set_priv(struct net_device *dev,
4416 struct iw_request_info *info,
4417 union iwreq_data *wrqu, char *extra)
4418{
4419 int ret;
4420 vos_ssr_protect(__func__);
4421 ret = __iw_set_priv(dev, info, wrqu, extra);
4422 vos_ssr_unprotect(__func__);
4423
4424 return ret;
4425}
4426
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304427static int __iw_set_nick(struct net_device *dev,
4428 struct iw_request_info *info,
4429 union iwreq_data *wrqu, char *extra)
4430{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304431 hdd_adapter_t *pAdapter;
4432 hdd_context_t *pHddCtx;
4433 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304434
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304435 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304436
4437 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4438 if (NULL == pAdapter)
4439 {
4440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4441 "%s: Adapter is NULL",__func__);
4442 return -EINVAL;
4443 }
4444
4445 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4446 ret = wlan_hdd_validate_context(pHddCtx);
4447 if (0 != ret)
4448 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304449 return ret;
4450 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304451 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304452 return 0;
4453}
4454
Jeff Johnson295189b2012-06-20 16:38:30 -07004455static int iw_set_nick(struct net_device *dev,
4456 struct iw_request_info *info,
4457 union iwreq_data *wrqu, char *extra)
4458{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304459 int ret;
4460
4461 vos_ssr_protect(__func__);
4462 ret = __iw_set_nick(dev, info, wrqu, extra);
4463 vos_ssr_unprotect(__func__);
4464
4465 return ret;
4466}
4467
4468static int __iw_get_nick(struct net_device *dev,
4469 struct iw_request_info *info,
4470 union iwreq_data *wrqu, char *extra)
4471{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304472 hdd_adapter_t *pAdapter;
4473 hdd_context_t *pHddCtx;
4474 int ret = 0;
4475
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304477
4478 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4479 if (NULL == pAdapter)
4480 {
4481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4482 "%s: Adapter is NULL",__func__);
4483 return -EINVAL;
4484 }
4485
4486 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4487 ret = wlan_hdd_validate_context(pHddCtx);
4488 if (0 != ret)
4489 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304490 return ret;
4491 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304492 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 return 0;
4494}
4495
4496static int iw_get_nick(struct net_device *dev,
4497 struct iw_request_info *info,
4498 union iwreq_data *wrqu, char *extra)
4499{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304500 int ret;
4501
4502 vos_ssr_protect(__func__);
4503 ret = __iw_get_nick(dev, info, wrqu, extra);
4504 vos_ssr_unprotect(__func__);
4505
4506 return ret;
4507}
4508
4509static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4510{
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304512 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004513}
4514
4515static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4516{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304517
4518 struct iw_statistics *stats;
4519
4520 vos_ssr_protect(__func__);
4521 stats = __get_wireless_stats(dev);
4522 vos_ssr_unprotect(__func__);
4523
4524 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004525}
4526
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304527static int __iw_set_encode(struct net_device *dev,
4528 struct iw_request_info *info,
4529 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004530
4531{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304532 hdd_adapter_t *pAdapter;
4533 hdd_station_ctx_t *pHddStaCtx;
4534 hdd_wext_state_t *pWextState;
4535 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 struct iw_point *encoderq = &(wrqu->encoding);
4537 v_U32_t keyId;
4538 v_U8_t key_length;
4539 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4540 v_BOOL_t fKeyPresent = 0;
4541 int i;
4542 eHalStatus status = eHAL_STATUS_SUCCESS;
4543
4544
4545 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304546 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4547 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4550 "%s: Adapter is NULL",__func__);
4551 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 }
4553
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304554 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4555 status = wlan_hdd_validate_context(pHddCtx);
4556 if (0 != status)
4557 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304558 return status;
4559 }
4560 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4561 if (NULL == pWextState)
4562 {
4563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4564 "%s: pWextState is NULL ",__func__);
4565 return -EINVAL;
4566 }
4567 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4568 if (NULL == pHddStaCtx)
4569 {
4570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4571 "%s: STA Context is NULL",__func__);
4572 return -EINVAL;
4573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004574
4575 keyId = encoderq->flags & IW_ENCODE_INDEX;
4576
4577 if(keyId)
4578 {
4579 if(keyId > MAX_WEP_KEYS)
4580 {
4581 return -EINVAL;
4582 }
4583
4584 fKeyPresent = 1;
4585 keyId--;
4586 }
4587 else
4588 {
4589 fKeyPresent = 0;
4590 }
4591
4592
4593 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4594 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 if(!fKeyPresent) {
4597
4598 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4599
4600 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4601 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4602 }
4603 }
4604 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4605 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4606 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4607 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4608
4609 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4610 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4611
4612 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4613 {
4614 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4615 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004616 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304617 {
4618 long ret;
4619 ret = wait_for_completion_interruptible_timeout(
4620 &pAdapter->disconnect_comp_var,
4621 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4622 if (ret <= 0)
4623 hddLog(VOS_TRACE_LEVEL_ERROR,
4624 FL("failed wait on disconnect_comp_var %ld"), ret);
4625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 }
4627
4628 return status;
4629
4630 }
4631
4632 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4633 {
4634 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4635
4636 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4637
4638 }
4639
4640
4641 if(wrqu->data.length > 0)
4642 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004643 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004644
4645 key_length = wrqu->data.length;
4646
4647 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4648
4649 if(5 == key_length)
4650 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004651 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004652
4653 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4654 {
4655 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4656 }
4657 else
4658 {
4659 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4660 }
4661 }
4662 else if(13 == key_length)
4663 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004664 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004665
4666 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4667 {
4668 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4669 }
4670 else
4671 {
4672 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4673 }
4674 }
4675 else
4676 {
4677 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004678 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 return -EINVAL;
4680 }
4681
4682 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4683 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4684 pWextState->roamProfile.EncryptionType.numEntries = 1;
4685 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4686 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4687 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4688
4689 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4690 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4691 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4692 {
4693
4694 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4695
4696 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4697 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4698
4699 return status;
4700 }
4701 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304702 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 return 0;
4704}
4705
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304706static int iw_set_encode(struct net_device *dev,
4707 struct iw_request_info *info,
4708 union iwreq_data *wrqu,char *extra)
4709{
4710 int ret;
4711
4712 vos_ssr_protect(__func__);
4713 ret = __iw_set_encode(dev, info, wrqu, extra);
4714 vos_ssr_unprotect(__func__);
4715
4716 return ret;
4717}
4718
4719static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 struct iw_request_info *info,
4721 struct iw_point *dwrq,
4722 char *extra)
4723{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304724 hdd_adapter_t *pAdapter;
4725 hdd_wext_state_t *pWextState;
4726 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 int keyId;
4728 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4729 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304730 int i, ret = 0;
4731 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004732
4733 ENTER();
4734
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304735 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4736 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004737 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4739 "%s: Adapter is NULL",__func__);
4740 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004741 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304742 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4743 ret = wlan_hdd_validate_context(pHddCtx);
4744 if (0 != ret)
4745 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304746 return ret;
4747 }
4748 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4749 if (NULL == pWextState)
4750 {
4751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4752 "%s: pWextState is NULL",__func__);
4753 return -EINVAL;
4754 }
4755 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004756
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 keyId = pRoamProfile->Keys.defaultIndex;
4758
4759 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4760 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004761 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 return -EINVAL;
4763 }
4764
4765 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4766 {
4767 dwrq->flags |= IW_ENCODE_ENABLED;
4768 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304769 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4770 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 }
4772 else
4773 {
4774 dwrq->flags |= IW_ENCODE_DISABLED;
4775 }
4776
4777 for(i=0; i < MAX_WEP_KEYS; i++)
4778 {
4779 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4780 {
4781 continue;
4782 }
4783 else
4784 {
4785 break;
4786 }
4787 }
4788
4789 if(MAX_WEP_KEYS == i)
4790 {
4791 dwrq->flags |= IW_ENCODE_NOKEY;
4792 }
4793 else
4794 {
4795 dwrq->flags |= IW_ENCODE_ENABLED;
4796 }
4797
4798 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4799
4800 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4801 {
4802 dwrq->flags |= IW_ENCODE_DISABLED;
4803 }
4804
4805 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4806
4807 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4808 {
4809 dwrq->flags |= IW_ENCODE_OPEN;
4810 }
4811 else
4812 {
4813 dwrq->flags |= IW_ENCODE_RESTRICTED;
4814 }
4815 EXIT();
4816 return 0;
4817
4818}
4819
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304820static int iw_get_encodeext(struct net_device *dev,
4821 struct iw_request_info *info,
4822 struct iw_point *dwrq,
4823 char *extra)
4824{
4825 int ret;
4826 vos_ssr_protect(__func__);
4827 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4828 vos_ssr_unprotect(__func__);
4829
4830 return ret;
4831}
4832
4833static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 struct iw_request_info *info,
4835 union iwreq_data *wrqu, char *extra)
4836{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304837 hdd_adapter_t *pAdapter;
4838 hdd_station_ctx_t *pHddStaCtx;
4839 hdd_wext_state_t *pWextState;
4840 hdd_context_t *pHddCtx;
4841 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004842
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304843 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 v_U32_t status = 0;
4845
4846 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4847
4848 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4849
4850 int key_index;
4851 struct iw_point *encoding = &wrqu->encoding;
4852 tCsrRoamSetKey setKey;
4853 v_U32_t roamId= 0xFF;
4854 VOS_STATUS vos_status;
4855
4856 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304857 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4858 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4861 "%s: Adapter is NULL",__func__);
4862 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304864 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4865 status = wlan_hdd_validate_context(pHddCtx);
4866 if (0 != status)
4867 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304868 return status;
4869 }
4870 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4871 if (NULL == pHddStaCtx)
4872 {
4873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4874 "%s: STA Context is NULL",__func__);
4875 return -EINVAL;
4876 }
4877 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4878 if (NULL == pWextState)
4879 {
4880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4881 "%s: pWextState is NULL",__func__);
4882 return -EINVAL;
4883 }
4884 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 key_index = encoding->flags & IW_ENCODE_INDEX;
4886
4887 if(key_index > 0) {
4888
4889 /*Convert from 1-based to 0-based keying*/
4890 key_index--;
4891 }
4892 if(!ext->key_len) {
4893
4894 /*Set the encrytion type to NONE*/
4895 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4896 return status;
4897 }
4898
4899 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4900 (IW_ENCODE_ALG_WEP == ext->alg))
4901 {
4902 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4903
Agarwal Ashish971c2882013-10-30 20:11:12 +05304904 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4905 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 return -EINVAL;
4907 }
4908 else {
4909 /*Static wep, update the roam profile with the keys */
4910 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4911 key_index < CSR_MAX_NUM_KEY) {
4912 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4913 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4914
4915 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4916 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4917
4918 }
4919 }
4920 return status;
4921 }
4922
4923 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4924
4925 setKey.keyId = key_index;
4926 setKey.keyLength = ext->key_len;
4927
4928 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4929 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4930 }
4931
4932 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4933 /*Key direction for group is RX only*/
4934 setKey.keyDirection = eSIR_RX_ONLY;
4935 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4936 }
4937 else {
4938
4939 setKey.keyDirection = eSIR_TX_RX;
4940 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4941 }
4942
4943 /*For supplicant pae role is zero*/
4944 setKey.paeRole = 0;
4945
4946 switch(ext->alg)
4947 {
4948 case IW_ENCODE_ALG_NONE:
4949 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4950 break;
4951
4952 case IW_ENCODE_ALG_WEP:
4953 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4954 break;
4955
4956 case IW_ENCODE_ALG_TKIP:
4957 {
4958 v_U8_t *pKey = &setKey.Key[0];
4959
4960 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4961
4962 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4963
4964 /*Supplicant sends the 32bytes key in this order
4965
4966 |--------------|----------|----------|
4967 | Tk1 |TX-MIC | RX Mic |
4968 |--------------|----------|----------|
4969 <---16bytes---><--8bytes--><--8bytes-->
4970
4971 */
4972 /*Sme expects the 32 bytes key to be in the below order
4973
4974 |--------------|----------|----------|
4975 | Tk1 |RX-MIC | TX Mic |
4976 |--------------|----------|----------|
4977 <---16bytes---><--8bytes--><--8bytes-->
4978 */
4979 /* Copy the Temporal Key 1 (TK1) */
4980 vos_mem_copy(pKey,ext->key,16);
4981
4982 /*Copy the rx mic first*/
4983 vos_mem_copy(&pKey[16],&ext->key[24],8);
4984
4985 /*Copy the tx mic */
4986 vos_mem_copy(&pKey[24],&ext->key[16],8);
4987
4988 }
4989 break;
4990
4991 case IW_ENCODE_ALG_CCMP:
4992 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4993 break;
4994
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004995#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004996#define IW_ENCODE_ALG_KRK 6
4997 case IW_ENCODE_ALG_KRK:
4998 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4999 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005000#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005001
5002 default:
5003 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5004 break;
5005 }
5006
5007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005008 ("%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 -07005009
5010#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305011 /* The supplicant may attempt to set the PTK once pre-authentication
5012 is done. Save the key in the UMAC and include it in the ADD
5013 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305015 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305017 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5018 "%s: Update PreAuth Key success", __func__);
5019 return 0;
5020 }
5021 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5022 {
5023 hddLog(VOS_TRACE_LEVEL_ERROR,
5024 "%s: Update PreAuth Key failed", __func__);
5025 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 }
5027#endif /* WLAN_FEATURE_VOWIFI_11R */
5028
5029 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5030
5031 vos_status = wlan_hdd_check_ula_done(pAdapter);
5032 if ( vos_status != VOS_STATUS_SUCCESS )
5033 {
5034 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5035 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5036 __LINE__, vos_status );
5037
5038 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5039 }
5040
5041 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5042
5043 if ( halStatus != eHAL_STATUS_SUCCESS )
5044 {
5045 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5046 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5047 __LINE__, halStatus );
5048
5049 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5050 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305051 EXIT();
5052 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005053}
5054
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305055static int iw_set_encodeext(struct net_device *dev,
5056 struct iw_request_info *info,
5057 union iwreq_data *wrqu, char *extra)
5058{
5059 int ret;
5060
5061 vos_ssr_protect(__func__);
5062 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5063 vos_ssr_unprotect(__func__);
5064
5065 return ret;
5066}
5067
5068static int __iw_set_retry(struct net_device *dev,
5069 struct iw_request_info *info,
5070 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005071{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305072 hdd_adapter_t *pAdapter;
5073 tHalHandle hHal;
5074 hdd_context_t *pHddCtx;
5075 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005076
5077 ENTER();
5078
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305079 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5080 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005081 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5083 "%s: Adapter is NULL",__func__);
5084 return -EINVAL;
5085 }
5086
5087 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5088 ret = wlan_hdd_validate_context(pHddCtx);
5089 if (0 != ret)
5090 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305091 return ret;
5092 }
5093
5094 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5095 if (NULL == hHal)
5096 {
5097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5098 "%s: Hal Context is NULL",__func__);
5099 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005100 }
5101
Jeff Johnson295189b2012-06-20 16:38:30 -07005102 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5103 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5104
Arif Hussain6d2a3322013-11-17 19:50:10 -08005105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005106
5107 return -EINVAL;
5108 }
5109
5110 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5111
5112 if((wrqu->retry.flags & IW_RETRY_LONG))
5113 {
5114 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5115 {
c_hpothub8245442013-11-20 23:41:09 +05305116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5117 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 return -EIO;
5119 }
5120 }
5121 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5122 {
5123 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5124 {
c_hpothub8245442013-11-20 23:41:09 +05305125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5126 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005127 return -EIO;
5128 }
5129 }
5130 }
5131 else
5132 {
5133 return -EOPNOTSUPP;
5134 }
5135
Arif Hussain6d2a3322013-11-17 19:50:10 -08005136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005137
5138 EXIT();
5139
5140 return 0;
5141
5142}
5143
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305144static int iw_set_retry(struct net_device *dev,
5145 struct iw_request_info *info,
5146 union iwreq_data *wrqu, char *extra)
5147{
5148 int ret;
5149
5150 vos_ssr_protect(__func__);
5151 ret = __iw_set_retry(dev, info, wrqu, extra);
5152 vos_ssr_unprotect(__func__);
5153
5154 return ret;
5155}
5156
5157static int __iw_get_retry(struct net_device *dev,
5158 struct iw_request_info *info,
5159 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005160{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305161 hdd_adapter_t *pAdapter;
5162 hdd_context_t *pHddCtx;
5163 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305165 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005166
5167 ENTER();
5168
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305169 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5170 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005171 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5173 "%s: Adapter is NULL",__func__);
5174 return -EINVAL;
5175 }
5176
5177 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5178 ret = wlan_hdd_validate_context(pHddCtx);
5179 if (0 != ret)
5180 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305181 return ret;
5182 }
5183
5184 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5185 if (NULL == hHal)
5186 {
5187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5188 "%s: Hal Context is NULL",__func__);
5189 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005190 }
5191
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 if((wrqu->retry.flags & IW_RETRY_LONG))
5193 {
5194 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5195
5196 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5197 {
c_hpothub8245442013-11-20 23:41:09 +05305198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5199 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 return -EIO;
5201 }
5202
5203 wrqu->retry.value = retry;
5204 }
5205 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5206 {
5207 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5208
5209 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5210 {
c_hpothub8245442013-11-20 23:41:09 +05305211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5212 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005213 return -EIO;
5214 }
5215
5216 wrqu->retry.value = retry;
5217 }
5218 else {
5219 return -EOPNOTSUPP;
5220 }
5221
Arif Hussain6d2a3322013-11-17 19:50:10 -08005222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005223
5224 EXIT();
5225
5226 return 0;
5227}
5228
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305229static int iw_get_retry(struct net_device *dev,
5230 struct iw_request_info *info,
5231 union iwreq_data *wrqu, char *extra)
5232{
5233 int ret;
5234
5235 vos_ssr_protect(__func__);
5236 ret = __iw_get_retry(dev, info, wrqu, extra);
5237 vos_ssr_unprotect(__func__);
5238
5239 return ret;
5240}
5241
5242static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 struct iw_request_info *info,
5244 union iwreq_data *wrqu,
5245 char *extra)
5246{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305247 hdd_adapter_t *pAdapter;
5248 hdd_context_t *pHddCtx;
5249 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005250 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5251 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305252 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005253
5254 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305255 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5256 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5259 "%s:Adapter is NULL",__func__);
5260 return -EINVAL;
5261 }
5262 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5263 ret = wlan_hdd_validate_context(pHddCtx);
5264 if (0 != ret)
5265 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305266 return ret;
5267 }
5268 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5269 if (NULL == pHddStaCtx)
5270 {
5271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5272 "%s:STA context is NULL",__func__);
5273 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 }
5275
5276 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5277 switch (mlme->cmd) {
5278 case IW_MLME_DISASSOC:
5279 case IW_MLME_DEAUTH:
5280
5281 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5282 {
5283 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5284
5285 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5286 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5287
5288 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5289 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5290
Jeff Johnson43971f52012-07-17 12:26:56 -07005291 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305292 {
5293 long ret;
5294 ret = wait_for_completion_interruptible_timeout(
5295 &pAdapter->disconnect_comp_var,
5296 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5297 if (ret <= 0)
5298 hddLog(VOS_TRACE_LEVEL_ERROR,
5299 FL("failed wait on disconnect_comp_var %ld"), ret);
5300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005301 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005302 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005303 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005304
5305 /* Resetting authKeyMgmt */
5306 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5307
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305308 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005309 netif_tx_disable(dev);
5310 netif_carrier_off(dev);
5311
5312 }
5313 else
5314 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005315 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 -07005316 }
5317 break;
5318 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005319 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 return -EINVAL;
5321 }//end of switch
5322
5323 EXIT();
5324
5325 return status;
5326
5327}
5328
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305329static int iw_set_mlme(struct net_device *dev,
5330 struct iw_request_info *info,
5331 union iwreq_data *wrqu,
5332 char *extra)
5333{
5334 int ret;
5335
5336 vos_ssr_protect(__func__);
5337 ret = __iw_set_mlme(dev, info, wrqu, extra);
5338 vos_ssr_unprotect(__func__);
5339
5340 return ret;
5341}
5342
Jeff Johnson295189b2012-06-20 16:38:30 -07005343/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305344static int __iw_setint_getnone(struct net_device *dev,
5345 struct iw_request_info *info,
5346 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005347{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305348 hdd_adapter_t *pAdapter;
5349 tHalHandle hHal;
5350 hdd_wext_state_t *pWextState;
5351 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005352 int *value = (int *)extra;
5353 int sub_cmd = value[0];
5354 int set_value = value[1];
5355 int ret = 0; /* success */
5356 int enable_pbm, enable_mp;
5357#ifdef CONFIG_HAS_EARLYSUSPEND
5358 v_U8_t nEnableSuspendOld;
5359#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005360
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305361 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305362 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5363 if (NULL == pAdapter)
5364 {
5365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5366 "%s: Adapter is NULL",__func__);
5367 return -EINVAL;
5368 }
5369 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5370 ret = wlan_hdd_validate_context(pHddCtx);
5371 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005372 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305373 return ret;
5374 }
5375 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5376 if (NULL == hHal)
5377 {
5378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5379 "%s: Hal Context is NULL",__func__);
5380 return -EINVAL;
5381 }
5382 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5383 if (NULL == pWextState)
5384 {
5385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5386 "%s: pWextState is NULL",__func__);
5387 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005388 }
5389
c_hpothu4a298be2014-12-22 21:12:51 +05305390 INIT_COMPLETION(pWextState->completion_var);
5391
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 switch(sub_cmd)
5393 {
5394 case WE_SET_11D_STATE:
5395 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005396 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005397 memset(&smeConfig, 0x00, sizeof(smeConfig));
5398
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5400
5401 sme_GetConfigParam(hHal,&smeConfig);
5402 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5403
Arif Hussain6d2a3322013-11-17 19:50:10 -08005404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005405
5406 sme_UpdateConfig(hHal,&smeConfig);
5407 }
5408 else {
5409 return -EINVAL;
5410 }
5411 break;
5412 }
5413
5414 case WE_WOWL:
5415 {
5416 switch (set_value)
5417 {
5418 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305419 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 break;
5421 case 0x01:
5422 case 0x02:
5423 case 0x03:
5424 enable_mp = (set_value & 0x01) ? 1 : 0;
5425 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005426 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5428 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5429 break;
5430 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005431 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 ret = -EINVAL;
5433 break;
5434 }
5435
5436 break;
5437 }
5438 case WE_SET_POWER:
5439 {
5440 switch (set_value)
5441 {
5442 case 0: //Full Power
5443 {
5444 struct statsContext context;
5445 eHalStatus status;
5446
5447 init_completion(&context.completion);
5448
5449 context.pAdapter = pAdapter;
5450 context.magic = POWER_CONTEXT_MAGIC;
5451
5452 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5453 iw_power_callback_fn, &context,
5454 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005455 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005456 {
5457 int lrc = wait_for_completion_interruptible_timeout(
5458 &context.completion,
5459 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005460
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 if (lrc <= 0)
5462 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005463 hddLog(VOS_TRACE_LEVEL_ERROR,
5464 "%s: SME %s while requesting fullpower",
5465 __func__, (0 == lrc) ?
5466 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 }
5468 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005469 /* either we have a response or we timed out. if we timed
5470 out there is a race condition such that the callback
5471 function could be executing at the same time we are. of
5472 primary concern is if the callback function had already
5473 verified the "magic" but had not yet set the completion
5474 variable when a timeout occurred. we serialize these
5475 activities by invalidating the magic while holding a
5476 shared spinlock which will cause us to block if the
5477 callback is currently executing */
5478 spin_lock(&hdd_context_lock);
5479 context.magic = 0;
5480 spin_unlock(&hdd_context_lock);
5481
Arif Hussain6d2a3322013-11-17 19:50:10 -08005482 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 break;
5484 }
5485 case 1: //Enable BMPS
5486 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5487 break;
5488 case 2: //Disable BMPS
5489 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5490 break;
5491 case 3: //Request Bmps
5492 {
5493 struct statsContext context;
5494 eHalStatus status;
5495
5496 init_completion(&context.completion);
5497
5498 context.pAdapter = pAdapter;
5499 context.magic = POWER_CONTEXT_MAGIC;
5500
5501 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5502 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005503 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 {
5505 int lrc = wait_for_completion_interruptible_timeout(
5506 &context.completion,
5507 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 if (lrc <= 0)
5509 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005510 hddLog(VOS_TRACE_LEVEL_ERROR,
5511 "%s: SME %s while requesting BMPS",
5512 __func__, (0 == lrc) ? "timeout" :
5513 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 }
5515 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005516 /* either we have a response or we timed out. if we
5517 timed out there is a race condition such that the
5518 callback function could be executing at the same
5519 time we are. of primary concern is if the callback
5520 function had already verified the "magic" but had
5521 not yet set the completion variable when a timeout
5522 occurred. we serialize these activities by
5523 invalidating the magic while holding a shared
5524 spinlock which will cause us to block if the
5525 callback is currently executing */
5526 spin_lock(&hdd_context_lock);
5527 context.magic = 0;
5528 spin_unlock(&hdd_context_lock);
5529
Arif Hussain6d2a3322013-11-17 19:50:10 -08005530 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 break;
5532 }
5533 case 4: //Enable IMPS
5534 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5535 break;
5536 case 5: //Disable IMPS
5537 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5538 break;
5539 case 6: //Enable Standby
5540 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5541 break;
5542 case 7: //Disable Standby
5543 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5544 break;
5545 case 8: //Request Standby
5546#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005547#endif
5548 break;
5549 case 9: //Start Auto Bmps Timer
5550 sme_StartAutoBmpsTimer(hHal);
5551 break;
5552 case 10://Stop Auto BMPS Timer
5553 sme_StopAutoBmpsTimer(hHal);
5554 break;
5555#ifdef CONFIG_HAS_EARLYSUSPEND
5556 case 11://suspend to standby
5557#ifdef CONFIG_HAS_EARLYSUSPEND
5558 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5559 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5561#endif
5562 break;
5563 case 12://suspend to deep sleep
5564#ifdef CONFIG_HAS_EARLYSUSPEND
5565 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5566 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5568#endif
5569 break;
5570 case 13://resume from suspend
5571#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005572#endif
5573 break;
5574#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005575 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005576 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 ret = -EINVAL;
5578 break;
5579 }
5580 break;
5581 }
5582
5583 case WE_SET_MAX_ASSOC:
5584 {
5585 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5586 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5587 {
5588 ret = -EINVAL;
5589 }
5590 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5591 set_value, NULL, eANI_BOOLEAN_FALSE)
5592 != eHAL_STATUS_SUCCESS )
5593 {
c_hpothub8245442013-11-20 23:41:09 +05305594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5595 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005596 ret = -EIO;
5597 }
5598 break;
5599 }
5600
5601 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5602 {
5603 if( 0 == set_value )
5604 {
5605 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5606 }
5607 else if ( 1 == set_value )
5608 {
5609 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5610 }
5611 else
5612 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005613 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 ret = -EINVAL;
5615 }
5616 break;
5617 }
5618
5619 case WE_SET_DATA_INACTIVITY_TO:
5620 {
5621 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5622 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5623 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5624 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5625 set_value,
5626 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5627 {
5628 hddLog(LOGE,"Failure: Could not pass on "
5629 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005630 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 ret = -EINVAL;
5632 }
5633 break;
5634 }
5635 case WE_SET_MAX_TX_POWER:
5636 {
5637 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5638 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5639
5640 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5641 __func__, set_value);
5642 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5643 eHAL_STATUS_SUCCESS )
5644 {
5645 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5646 __func__);
5647 return -EIO;
5648 }
5649
5650 break;
5651 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005652 case WE_SET_MAX_TX_POWER_2_4:
5653 {
5654 hddLog(VOS_TRACE_LEVEL_INFO,
5655 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5656 __func__, set_value);
5657 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5658 eHAL_STATUS_SUCCESS)
5659 {
5660 hddLog(VOS_TRACE_LEVEL_ERROR,
5661 "%s: Setting maximum tx power failed for 2.4 GHz band",
5662 __func__);
5663 return -EIO;
5664 }
5665
5666 break;
5667 }
5668 case WE_SET_MAX_TX_POWER_5_0:
5669 {
5670 hddLog(VOS_TRACE_LEVEL_INFO,
5671 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5672 __func__, set_value);
5673 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5674 eHAL_STATUS_SUCCESS)
5675 {
5676 hddLog(VOS_TRACE_LEVEL_ERROR,
5677 "%s: Setting maximum tx power failed for 5.0 GHz band",
5678 __func__);
5679 return -EIO;
5680 }
5681
5682 break;
5683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 case WE_SET_HIGHER_DTIM_TRANSITION:
5685 {
5686 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5687 (set_value == eANI_BOOLEAN_TRUE)))
5688 {
5689 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5690 ret = -EINVAL;
5691 }
5692 else
5693 {
5694 if(pAdapter->higherDtimTransition != set_value)
5695 {
5696 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005697 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 }
5699 }
5700
5701 break;
5702 }
5703
5704 case WE_SET_TM_LEVEL:
5705 {
5706 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005707 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5709
5710 break;
5711 }
5712
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305713 case WE_ENABLE_STRICT_FCC_REG:
5714 {
5715 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5716 struct wiphy *wiphy = NULL;
5717 long lrc;
5718 int status;
5719
5720 wiphy = hddCtxt->wiphy;
5721 if(wiphy == NULL)
5722 {
5723 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5724 break;
5725 }
5726 init_completion(&hddCtxt->wiphy_channel_update_event);
5727
5728 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5729
5730 status = regulatory_hint(wiphy, "00");
5731 if(status < 0)
5732 {
5733 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5734 break;
5735 }
5736
5737 /* Wait for completion */
5738 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5739 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5740 if (lrc <= 0)
5741 {
5742 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5743 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5744 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5745 }
5746 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5747
5748 break;
5749 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005750 case WE_SET_DEBUG_LOG:
5751 {
5752 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5753 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5754 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5755 break;
5756 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305757#ifdef FEATURE_WLAN_TDLS
5758 case WE_SET_TDLS_OFF_CHAN:
5759 {
5760 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5762 __func__, set_value);
5763 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5764 break;
5765 }
5766 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5767 {
5768 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5770 __func__, set_value);
5771 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5772 break;
5773 }
5774 case WE_SET_TDLS_OFF_CHAN_MODE:
5775 {
5776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5777 __func__, set_value);
5778 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5779 break;
5780 }
5781#endif
Peng Xu2446a892014-09-05 17:21:18 +05305782 case WE_SET_SCAN_BAND_PREFERENCE:
5783 {
5784 tSmeConfigParams smeConfig;
5785 memset(&smeConfig, 0x00, sizeof(smeConfig));
5786 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5787 ret = -EINVAL;
5788 break;
5789 }
5790 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5791
5792 if (eCSR_BAND_ALL == set_value ||
5793 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5794 sme_GetConfigParam(hHal, &smeConfig);
5795 smeConfig.csrConfig.scanBandPreference = set_value;
5796
5797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5798 "set band scan preference = %d\n",
5799 smeConfig.csrConfig.scanBandPreference);
5800
5801 sme_UpdateConfig(hHal, &smeConfig);
5802 }
5803 else {
5804 ret = -EINVAL;
5805 }
5806 break;
5807 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305808 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5809 * connection happens so that the params can take effect during
5810 * association. Also this should not be used in STA+p2p concurrency
5811 * as the param will also effect the STA mode.
5812 */
5813 case WE_SET_MIRACAST_VENDOR_CONFIG:
5814 {
5815 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305816
Abhishek Singh01c73d12015-03-12 15:13:44 +05305817 hddLog(LOG1, FL(
5818 "Set Miracast vendor tuning %d"), set_value);
5819
5820 if (1 == set_value || 0 == set_value)
5821 {
5822 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5823 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5824 {
5825 hddLog( LOGE, FL("set vendor miracast config failed"));
5826 ret = -EIO;
5827 }
5828 }
5829 else
5830 {
5831 hddLog(LOGE,
5832 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5833 ret = -EINVAL;
5834 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305835 break;
5836 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305837
5838 case WE_GET_FRAME_LOG:
5839 {
5840 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5841 != VOS_STATUS_SUCCESS)
5842 {
5843 ret = -EINVAL;
5844 }
5845 break;
5846 }
5847
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +05305848 case WE_SET_TDLS_2040_BSS_COEXISTENCE:
5849 {
5850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5851 "%s: TDLS_2040_BSS_COEXISTENCE %d", __func__, set_value);
5852 if (set_value == 0 || set_value == 1)
5853 {
5854 sme_SetTdls2040BSSCoexistence(WLAN_HDD_GET_HAL_CTX(pAdapter),
5855 set_value);
5856 }
5857 else
5858 ret = -EINVAL;
5859
5860 break;
5861 }
5862
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 default:
5864 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005865 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 sub_cmd, set_value);
5867 break;
5868 }
5869 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305870 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 return ret;
5872}
5873
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305874static int iw_setint_getnone(struct net_device *dev,
5875 struct iw_request_info *info,
5876 union iwreq_data *wrqu, char *extra)
5877{
5878 int ret;
5879
5880 vos_ssr_protect(__func__);
5881 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5882 vos_ssr_unprotect(__func__);
5883
5884 return 0;
5885}
Jeff Johnson295189b2012-06-20 16:38:30 -07005886/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305887static int __iw_setchar_getnone(struct net_device *dev,
5888 struct iw_request_info *info,
5889 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005890{
5891 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305892 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005894 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305895 hdd_adapter_t *pAdapter;
5896 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005897#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305898 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005899#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305900 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305901 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005902
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305903 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305904 pAdapter = (netdev_priv(dev));
5905 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005906 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5908 "%s: Adapter is NULL",__func__);
5909 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005910 }
5911
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305912 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5913 ret = wlan_hdd_validate_context(pHddCtx);
5914 if (0 != ret)
5915 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305916 return ret;
5917 }
5918#ifdef WLAN_FEATURE_VOWIFI
5919 pConfig = pHddCtx->cfg_ini;
5920#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305921 /* helper function to get iwreq_data with compat handling. */
5922 if (hdd_priv_get_data(&s_priv_data, wrqu))
5923 {
5924 return -EINVAL;
5925 }
5926
5927 /* make sure all params are correctly passed to function */
5928 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5929 {
5930 return -EINVAL;
5931 }
5932
5933 sub_cmd = s_priv_data.flags;
5934
Arif Hussain0273cba2014-01-07 20:58:29 -08005935 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305936 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5937 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005938 if (NULL == pBuffer)
5939 {
5940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5941 "mem_alloc_copy_from_user_helper fail");
5942 return -ENOMEM;
5943 }
5944
5945 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305946 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5948 "%s: Received data %s", __func__, pBuffer);
5949
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 switch(sub_cmd)
5951 {
5952 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005954 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 break;
5956 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005958 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 break;
5960#if defined WLAN_FEATURE_VOWIFI
5961 case WE_NEIGHBOR_REPORT_REQUEST:
5962 {
5963 tRrmNeighborReq neighborReq;
5964 tRrmNeighborRspCallbackInfo callbackInfo;
5965
5966 if (pConfig->fRrmEnable)
5967 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305969 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 if( !neighborReq.no_ssid )
5971 {
Girish Gowli552fc072014-06-14 18:26:16 +05305972 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005973 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 }
5975
5976 callbackInfo.neighborRspCallback = NULL;
5977 callbackInfo.neighborRspCallbackContext = NULL;
5978 callbackInfo.timeout = 5000; //5 seconds
5979 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5980 }
5981 else
5982 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005983 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 ret = -EINVAL;
5985 }
5986 }
5987 break;
5988#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 case WE_SET_AP_WPS_IE:
5990 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05305991 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08005994 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 if (VOS_STATUS_SUCCESS != vstatus)
5996 {
5997 ret = -EINVAL;
5998 }
5999 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05306000 case WE_SET_ENCRYPT_MSG:
6001 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
6002 if (NULL == pkt)
6003 {
6004 hddLog(VOS_TRACE_LEVEL_ERROR,
6005 "%s: vos_mem_alloc failed", __func__);
6006 return -ENOMEM;
6007 }
6008
6009 memset(pkt, 0, sizeof(tSirpkt80211));
6010
6011 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
6012 hddLog(VOS_TRACE_LEVEL_ERROR,
6013 FL("Firmware is not DISA capable"));
6014 ret = -EINVAL;
6015 vos_mem_free(pkt);
6016 break;
6017 }
6018
6019 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6020
6021 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6022 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6023 if (eHAL_STATUS_SUCCESS != ret) {
6024 hddLog(VOS_TRACE_LEVEL_ERROR,
6025 FL("SENDEncryptMSG: fail to post WDA cmd"));
6026 ret = -EINVAL;
6027 }
6028 vos_mem_free(pkt);
6029
6030 break;
6031
Jeff Johnson295189b2012-06-20 16:38:30 -07006032 default:
6033 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006034 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 ret = -EINVAL;
6036 break;
6037 }
6038 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006039 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306040
6041 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 return ret;
6043}
6044
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306045static int iw_setchar_getnone(struct net_device *dev,
6046 struct iw_request_info *info,
6047 union iwreq_data *wrqu, char *extra)
6048{
6049 int ret;
6050
6051 vos_ssr_protect(__func__);
6052 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6053 vos_ssr_unprotect(__func__);
6054
6055 return ret;
6056}
6057
Jeff Johnson295189b2012-06-20 16:38:30 -07006058/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306059static int __iw_setnone_getint(struct net_device *dev,
6060 struct iw_request_info *info,
6061 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006062{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306063 hdd_adapter_t *pAdapter;
6064 tHalHandle hHal;
6065 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 int *value = (int *)extra;
6067 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05306068 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006069
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306070 ENTER();
6071
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306072 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6073 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006074 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6076 "%s: Adapter is NULL",__func__);
6077 return -EINVAL;
6078 }
6079 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6080 ret = wlan_hdd_validate_context(pHddCtx);
6081 if (0 != ret)
6082 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306083 return ret;
6084 }
6085 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6086 if (NULL == hHal)
6087 {
6088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6089 "%s: Hal Context is NULL",__func__);
6090 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006092
6093 switch (value[0])
6094 {
6095 case WE_GET_11D_STATE:
6096 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006097 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306099
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6101
Arif Hussain6d2a3322013-11-17 19:50:10 -08006102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006103
6104 break;
6105 }
6106
6107 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 break;
6110
6111 case WE_PMC_STATE:
6112 {
6113 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 break;
6116 }
6117 case WE_GET_WLAN_DBG:
6118 {
6119 vos_trace_display();
6120 *value = 0;
6121 break;
6122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 case WE_GET_MAX_ASSOC:
6124 {
6125 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6126 {
c_hpothub8245442013-11-20 23:41:09 +05306127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6128 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 ret = -EIO;
6130 }
Girish Gowli385be612014-09-18 11:17:20 +05306131#ifdef WLAN_SOFTAP_VSTA_FEATURE
6132 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6133 {
6134 if (*value > VSTA_NUM_ASSOC_STA)
6135 {
6136 *value = VSTA_NUM_ASSOC_STA;
6137 }
6138 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6139 (*value > (VSTA_NUM_ASSOC_STA -
6140 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6141 {
6142 *value = (VSTA_NUM_ASSOC_STA -
6143 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6144 }
6145 }
6146 else
6147#endif
6148 {
6149 if (*value > NUM_ASSOC_STA)
6150 {
6151 *value = NUM_ASSOC_STA;
6152 }
6153 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6154 (*value > (NUM_ASSOC_STA -
6155 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6156 {
6157 *value = (NUM_ASSOC_STA -
6158 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6159 }
6160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 break;
6162 }
6163
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 case WE_GET_WDI_DBG:
6165 {
6166 wpalTraceDisplay();
6167 *value = 0;
6168 break;
6169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006170
6171 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6172 {
6173 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6174 break;
6175 }
6176 case WE_GET_CONCURRENCY_MODE:
6177 {
6178 *value = hdd_get_concurrency_mode ( );
6179
Arif Hussain6d2a3322013-11-17 19:50:10 -08006180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 break;
6182 }
6183
Peng Xu2446a892014-09-05 17:21:18 +05306184 case WE_GET_SCAN_BAND_PREFERENCE:
6185 {
6186 sme_GetConfigParam(hHal, &smeConfig);
6187 *value = smeConfig.csrConfig.scanBandPreference;
6188
6189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6190 "scanBandPreference = %d\n", *value);
6191 break;
6192 }
6193
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 default:
6195 {
6196 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6197 break;
6198 }
6199 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306200 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 return ret;
6202}
6203
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306204static int iw_setnone_getint(struct net_device *dev,
6205 struct iw_request_info *info,
6206 union iwreq_data *wrqu, char *extra)
6207{
6208 int ret;
6209
6210 vos_ssr_protect(__func__);
6211 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6212 vos_ssr_unprotect(__func__);
6213
6214 return ret;
6215
6216}
Jeff Johnson295189b2012-06-20 16:38:30 -07006217/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306218int __iw_set_three_ints_getnone(struct net_device *dev,
6219 struct iw_request_info *info,
6220 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006221{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306222 hdd_adapter_t *pAdapter;
6223 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 int *value = (int *)extra;
6225 int sub_cmd = value[0];
6226 int ret = 0;
6227
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306228 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306229 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6230 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006231 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306232 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6233 "%s: Adapter is NULL",__func__);
6234 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006235 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306236 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6237 ret = wlan_hdd_validate_context(pHddCtx);
6238 if (0 != ret)
6239 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306240 return ret;
6241 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006242 switch(sub_cmd)
6243 {
6244 case WE_SET_WLAN_DBG:
6245 {
6246 vos_trace_setValue( value[1], value[2], value[3]);
6247 break;
6248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006249 case WE_SET_WDI_DBG:
6250 {
6251 wpalTraceSetLevel( value[1], value[2], value[3]);
6252 break;
6253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 case WE_SET_SAP_CHANNELS:
6255 {
6256 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6257 break;
6258 }
6259
6260 default:
6261 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006262 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 break;
6264 }
6265 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306266 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 return ret;
6268}
6269
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306270int iw_set_three_ints_getnone(struct net_device *dev,
6271 struct iw_request_info *info,
6272 union iwreq_data *wrqu, char *extra)
6273{
6274 int ret;
6275
6276 vos_ssr_protect(__func__);
6277 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6278 vos_ssr_unprotect(__func__);
6279
6280 return ret;
6281}
6282
6283static int __iw_get_char_setnone(struct net_device *dev,
6284 struct iw_request_info *info,
6285 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006286{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306287 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006288 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306289 hdd_context_t *pHddCtx;
6290 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006291#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006292 hdd_wext_state_t *pWextState;
6293#endif
6294
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306295 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306296 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006297 if (pAdapter == NULL)
6298 {
6299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6300 "%s: pAdapter is NULL!", __func__);
6301 return -EINVAL;
6302 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306303 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6304 ret = wlan_hdd_validate_context(pHddCtx);
6305 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006306 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306307 return ret;
6308 }
6309#ifdef WLAN_FEATURE_11W
6310 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6311 if (NULL == pWextState)
6312 {
6313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6314 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006315 return -EINVAL;
6316 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306317#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006318
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 switch(sub_cmd)
6320 {
6321 case WE_WLAN_VERSION:
6322 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006323 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 break;
6325 }
6326
6327 case WE_GET_STATS:
6328 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306329 tHalHandle hHal = NULL;
6330 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6332 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6333 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6334
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306335
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 snprintf(extra, WE_MAX_STR_LEN,
6337 "\nTransmit"
6338 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6339 "\n dropped BK %u, BE %u, VI %u, VO %u"
6340 "\n classified BK %u, BE %u, VI %u, VO %u"
6341 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6342 "\n queued BK %u, BE %u, VI %u, VO %u"
6343 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006344 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006345 "\n fetched BK %u, BE %u, VI %u, VO %u"
6346 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6347 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006348 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006349 "\n flushed BK %u, BE %u, VI %u, VO %u"
6350 "\n\nReceive"
6351 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6352 "\n\nResetsStats"
6353 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6354 "\n",
6355 pStats->txXmitCalled,
6356 pStats->txXmitDropped,
6357 pStats->txXmitBackPressured,
6358 pStats->txXmitQueued,
6359
6360 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6361 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6362 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6363 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6364
6365 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6366 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6367 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6368 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6369
6370 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6371 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6372 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6373 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6374
6375 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6376 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6377 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6378 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6379
6380 pStats->txFetched,
6381 pStats->txFetchEmpty,
6382 pStats->txFetchLowResources,
6383 pStats->txFetchDequeueError,
6384
6385 pStats->txFetchDequeued,
6386 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006387 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 pStats->txCompleted,
6389 pStats->txFlushed,
6390
6391 pStats->txFetchedAC[WLANTL_AC_BK],
6392 pStats->txFetchedAC[WLANTL_AC_BE],
6393 pStats->txFetchedAC[WLANTL_AC_VI],
6394 pStats->txFetchedAC[WLANTL_AC_VO],
6395
6396 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6397 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6398 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6399 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6400
6401 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6402 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6403 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6404 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6405
Ravi Joshi41914632013-10-21 23:02:21 -07006406 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6407 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6408 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6409 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6410
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 pStats->txFlushedAC[WLANTL_AC_BK],
6412 pStats->txFlushedAC[WLANTL_AC_BE],
6413 pStats->txFlushedAC[WLANTL_AC_VI],
6414 pStats->txFlushedAC[WLANTL_AC_VO],
6415
6416 pStats->rxChains,
6417 pStats->rxPackets,
6418 pStats->rxDropped,
6419 pStats->rxDelivered,
6420 pStats->rxRefused,
6421
6422 pResetStats->totalLogpResets,
6423 pResetStats->totalCMD53Failures,
6424 pResetStats->totalMutexReadFailures,
6425 pResetStats->totalMIFErrorFailures,
6426 pResetStats->totalFWHearbeatFailures,
6427 pResetStats->totalUnknownExceptions
6428 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306429 wrqu->data.length = strlen(extra);
6430
6431 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6432
6433 if (hHal)
6434 pMac = PMAC_STRUCT( hHal );
6435
6436 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6437 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6438 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306439 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6440 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6441 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6442 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306443 "\n",
6444 pMac->pmm.BmpscntSleep,
6445 pMac->pmm.BmpscntAwake,
6446 pMac->pmm.BmpsSleeReqFailCnt,
6447 pMac->pmm.BmpsWakeupReqFailCnt,
6448 pMac->pmm.ImpsCntSleep,
6449 pMac->pmm.ImpsCntAwake,
6450 pMac->pmm.ImpsSleepErrCnt,
6451 pMac->pmm.ImpsWakeupErrCnt,
6452 pMac->pmm.ImpsLastErr
6453 );
6454 }
6455
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 wrqu->data.length = strlen(extra)+1;
6457 break;
6458 }
6459
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306460/* The case prints the current state of the HDD, SME, CSR, PE, TL
6461 *it can be extended for WDI Global State as well.
6462 *And currently it only checks P2P_CLIENT adapter.
6463 *P2P_DEVICE and P2P_GO have not been added as of now.
6464*/
6465 case WE_GET_STATES:
6466 {
6467 int buf = 0, len = 0;
6468 int adapter_num = 0;
6469 int count = 0, check = 1;
6470
6471 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006472 tHalHandle hHal = NULL;
6473 tpAniSirGlobal pMac = NULL;
6474 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306475
6476 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6477 hdd_adapter_t *useAdapter = NULL;
6478
6479 /* Print wlan0 or p2p0 states based on the adapter_num
6480 *by using the correct adapter
6481 */
6482 while ( adapter_num < 2 )
6483 {
6484 if ( WLAN_ADAPTER == adapter_num )
6485 {
6486 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006487 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306488 "\n\n wlan0 States:-");
6489 len += buf;
6490 }
6491 else if ( P2P_ADAPTER == adapter_num )
6492 {
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 p2p0 States:-");
6495 len += buf;
6496
6497 if( !pHddCtx )
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 pHddCtx is NULL");
6501 len += buf;
6502 break;
6503 }
6504
6505 /*Printing p2p0 states only in the case when the device is
6506 configured as a p2p_client*/
6507 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6508 if ( !useAdapter )
6509 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006510 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306511 "\n Device not configured as P2P_CLIENT.");
6512 len += buf;
6513 break;
6514 }
6515 }
6516
6517 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006518 if (!hHal) {
6519 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6520 "\n pMac is NULL");
6521 len += buf;
6522 break;
6523 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306524 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006525 if (!pMac) {
6526 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6527 "\n pMac is NULL");
6528 len += buf;
6529 break;
6530 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306531 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6532 if( !pHddStaCtx )
6533 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006534 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306535 "\n pHddStaCtx is NULL");
6536 len += buf;
6537 break;
6538 }
6539
6540 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6541
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006542 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306543 "\n HDD Conn State - %s "
6544 "\n \n SME State:"
6545 "\n Neighbour Roam State - %s"
6546 "\n CSR State - %s"
6547 "\n CSR Substate - %s"
6548 "\n \n TL STA %d State: %s",
6549 macTraceGetHDDWlanConnState(
6550 pHddStaCtx->conn_info.connState),
6551 macTraceGetNeighbourRoamState(
6552 pMac->roam.neighborRoamInfo.neighborRoamState),
6553 macTraceGetcsrRoamState(
6554 pMac->roam.curState[useAdapter->sessionId]),
6555 macTraceGetcsrRoamSubState(
6556 pMac->roam.curSubState[useAdapter->sessionId]),
6557 pHddStaCtx->conn_info.staId[0],
6558 macTraceGetTLState(tlState)
6559 );
6560 len += buf;
6561 adapter_num++;
6562 }
6563
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006564 if (pMac) {
6565 /* Printing Lim State starting with global lim states */
6566 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6567 "\n \n LIM STATES:-"
6568 "\n Global Sme State - %s "\
6569 "\n Global mlm State - %s "\
6570 "\n",
6571 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6572 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6573 );
6574 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306575
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006576 /*printing the PE Sme and Mlm states for valid lim sessions*/
6577 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306578 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006579 if ( pMac->lim.gpSession[count].valid )
6580 {
6581 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6582 "\n Lim Valid Session %d:-"
6583 "\n PE Sme State - %s "
6584 "\n PE Mlm State - %s "
6585 "\n",
6586 check,
6587 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6588 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6589 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306590
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006591 len += buf;
6592 check++;
6593 }
6594 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306595 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306596 }
6597
6598 wrqu->data.length = strlen(extra)+1;
6599 break;
6600 }
6601
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 case WE_GET_CFG:
6603 {
6604 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6605 wrqu->data.length = strlen(extra)+1;
6606 break;
6607 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006608#ifdef WLAN_FEATURE_11AC
6609 case WE_GET_RSSI:
6610 {
6611 v_S7_t s7Rssi = 0;
6612 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6613 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6614 wrqu->data.length = strlen(extra)+1;
6615 break;
6616 }
6617#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306618
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006619#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006620 case WE_GET_ROAM_RSSI:
6621 {
6622 v_S7_t s7Rssi = 0;
6623 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6624 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6625 wrqu->data.length = strlen(extra)+1;
6626 break;
6627 }
6628#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 case WE_GET_WMM_STATUS:
6630 {
6631 snprintf(extra, WE_MAX_STR_LEN,
6632 "\nDir: 0=up, 1=down, 3=both\n"
6633 "|------------------------|\n"
6634 "|AC | ACM |Admitted| Dir |\n"
6635 "|------------------------|\n"
6636 "|VO | %d | %3s | %d |\n"
6637 "|VI | %d | %3s | %d |\n"
6638 "|BE | %d | %3s | %d |\n"
6639 "|BK | %d | %3s | %d |\n"
6640 "|------------------------|\n",
6641 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6642 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6643 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6644 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6645 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6646 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6647 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6648 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6649 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6650 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6651 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6652 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6653
Jeff Johnsone7245742012-09-05 17:12:55 -07006654
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 wrqu->data.length = strlen(extra)+1;
6656 break;
6657 }
6658 case WE_GET_CHANNEL_LIST:
6659 {
6660 VOS_STATUS status;
6661 v_U8_t i, len;
6662 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306663 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6664 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6665 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006666 tChannelListInfo channel_list;
6667
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006668 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006670 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006672 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 return -EINVAL;
6674 }
6675 buf = extra;
6676
6677 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006678 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6679 * needed = 5 * number of channels. Check ifsufficient
6680 * buffer is available and then proceed to fill the buffer.
6681 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6683 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006684 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006685 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006686 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 return -EINVAL;
6688 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006689 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6690 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306691 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6692 {
6693 //Printing Country code in getChannelList
6694 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6695 {
6696 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6697 "%c ", pBuf[i]);
6698 }
6699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 for(i = 0 ; i < channel_list.num_channels; i++)
6701 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006702 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 }
6705 wrqu->data.length = strlen(extra)+1;
6706
6707 break;
6708 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006709#ifdef FEATURE_WLAN_TDLS
6710 case WE_GET_TDLS_PEERS:
6711 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006712 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006713 break;
6714 }
6715#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006716#ifdef WLAN_FEATURE_11W
6717 case WE_GET_11W_INFO:
6718 {
6719 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6720
6721 snprintf(extra, WE_MAX_STR_LEN,
6722 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6723 "\n Number of Unprotected Disassocs %d"
6724 "\n Number of Unprotected Deauths %d",
6725 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6726 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6727 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6728 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6729 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6730
6731 wrqu->data.length = strlen(extra)+1;
6732 break;
6733 }
6734#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306735 case WE_GET_SNR:
6736 {
6737 v_S7_t s7snr = 0;
6738 int status = 0;
6739 hdd_context_t *pHddCtx;
6740 hdd_station_ctx_t *pHddStaCtx;
6741
6742 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6743 status = wlan_hdd_validate_context(pHddCtx);
6744 if (0 != status)
6745 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306746 return status;
6747 }
6748
6749 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6750
6751 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6752 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6753 {
6754 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6755 " ConnectionState-%d", __func__,
6756 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6757 pHddStaCtx->conn_info.connState);
6758 return -ENONET;
6759 }
6760
6761 /*update the stats in TL*/
6762 wlan_hdd_get_station_stats(pAdapter);
6763 wlan_hdd_get_snr(pAdapter, &s7snr);
6764 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6765 wrqu->data.length = strlen(extra) + 1;
6766 break;
6767 }
6768
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306769 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006771 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 break;
6773 }
6774 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306775 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 return 0;
6777}
6778
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306779static int iw_get_char_setnone(struct net_device *dev,
6780 struct iw_request_info *info,
6781 union iwreq_data *wrqu, char *extra)
6782{
6783 int ret;
6784
6785 vos_ssr_protect(__func__);
6786 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6787 vos_ssr_unprotect(__func__);
6788
6789 return ret;
6790}
6791
Jeff Johnson295189b2012-06-20 16:38:30 -07006792/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306793static int __iw_setnone_getnone(struct net_device *dev,
6794 struct iw_request_info *info,
6795 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006796{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306797 hdd_adapter_t *pAdapter;
6798 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306799 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006800 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306801 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006802
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306803 ENTER();
6804
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306805 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6806 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006807 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6809 "%s: Adapter is NULL",__func__);
6810 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006811 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306812 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6813 ret = wlan_hdd_validate_context(pHddCtx);
6814 if (0 != ret)
6815 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306816 return ret;
6817 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306818 /* helper function to get iwreq_data with compat handling. */
6819 if (hdd_priv_get_data(&s_priv_data, wrqu))
6820 {
6821 return -EINVAL;
6822 }
6823
6824 sub_cmd = s_priv_data.flags;
6825
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 switch (sub_cmd)
6827 {
6828 case WE_CLEAR_STATS:
6829 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6832 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6833 break;
6834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 case WE_INIT_AP:
6836 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306837 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6838
6839 /* As Soft AP mode might been changed to STA already with
6840 * killing of Hostapd, need to find the adpater by name
6841 * rather than mode */
6842 hdd_adapter_t* pAdapter_to_stop =
6843 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6844 if( pAdapter_to_stop )
6845 {
6846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6847 "Adapter with name softap.0 already "
6848 "exist, ignoring the request.\nRemove the "
6849 "adapter and try again\n");
6850 break;
6851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 pr_info("Init AP trigger\n");
6853 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6854 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6855 break;
6856 }
6857 case WE_STOP_AP:
6858 {
6859 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6860 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6861 * this is a dead code and need to find the adpater by name rather than mode */
6862 hdd_adapter_t* pAdapter_to_stop =
6863 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6864 if( pAdapter_to_stop )
6865 {
6866 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6867
6868 pr_info("Stopping AP mode\n");
6869
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306870 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6871 {
6872 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6873 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6874 }
6875
Jeff Johnson295189b2012-06-20 16:38:30 -07006876 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306877 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306878 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6880
6881 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6882 pAdapter_to_stop->macAddressCurrent.bytes);
6883 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6884 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306885
6886 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6887 {
6888 /* put the device back into BMPS */
6889 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 }
6892 else
6893 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006894 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006895 }
6896
6897 break;
6898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006899#ifdef WLAN_BTAMP_FEATURE
6900 case WE_ENABLE_AMP:
6901 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 WLANBAP_RegisterWithHCI(pAdapter);
6904 break;
6905 }
6906 case WE_DISABLE_AMP:
6907 {
6908 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6909 VOS_STATUS status;
6910
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006912
6913 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6914 status = WLANBAP_StopAmp();
6915 if(VOS_STATUS_SUCCESS != status )
6916 {
6917 pHddCtx->isAmpAllowed = VOS_TRUE;
6918 hddLog(VOS_TRACE_LEVEL_FATAL,
6919 "%s: Failed to stop AMP", __func__);
6920 }
6921 else
6922 {
6923 //a state m/c implementation in PAL is TBD to avoid this delay
6924 msleep(500);
6925 pHddCtx->isAmpAllowed = VOS_FALSE;
6926 WLANBAP_DeregisterFromHCI();
6927 }
6928
6929 break;
6930 }
6931#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006932 case WE_ENABLE_DXE_STALL_DETECT:
6933 {
schang6295e542013-03-12 15:31:23 -07006934 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6935 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006936 break;
6937 }
6938 case WE_DISPLAY_DXE_SNAP_SHOT:
6939 {
schang6295e542013-03-12 15:31:23 -07006940 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6941 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006942 break;
6943 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306944 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6945 {
6946 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6947 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306948 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306949 break;
6950 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306951
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306952 case WE_SET_REASSOC_TRIGGER:
6953 {
6954 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6955 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6956 v_U32_t roamId = 0;
6957 tCsrRoamModifyProfileFields modProfileFields;
6958 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6959 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6960 return 0;
6961 }
6962
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306963 case WE_STOP_OBSS_SCAN:
6964 {
6965 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6966 2.OBSS scan is stopped by Firmware during the disassociation
6967 3.OBSS stop comamnd is added for debugging purpose*/
6968 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6969 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006970
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306971 if (pAdapter == NULL)
6972 {
6973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6974 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306975 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306976 }
6977 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6978 if (pMac == NULL)
6979 {
6980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6981 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306982 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306983 }
6984 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6985 }
6986 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306987 case WE_DUMP_ROAM_TIMER_LOG:
6988 {
6989 vos_dump_roam_time_log_service();
6990 break;
6991 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306992
Mukul Sharma84f27252014-07-14 18:11:42 +05306993 case WE_RESET_ROAM_TIMER_LOG:
6994 {
6995 vos_reset_roam_timer_log();
6996 break;
6997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006998 default:
6999 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007000 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 break;
7002 }
7003 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307004 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 return ret;
7006}
7007
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307008static int iw_setnone_getnone(struct net_device *dev,
7009 struct iw_request_info *info,
7010 union iwreq_data *wrqu, char *extra)
7011{
7012 int ret;
7013
7014 vos_ssr_protect(__func__);
7015 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7016 vos_ssr_unprotect(__func__);
7017
7018 return ret;
7019}
7020
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307021void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7022{
7023 /*
7024 * Function to display HDD WMM information
7025 * for Tx Queues.
7026 * Prints globala as well as per client depending
7027 * whether the clients are registered or not.
7028 */
7029 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307030 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7031 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307032 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7033 hdd_ibss_peer_info_t *pPeerInfo;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307034
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307035 for ( i=0; i< NUM_TX_QUEUES; i++)
7036 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307037 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307038
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007039 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307040 i, pAdapter->wmm_tx_queue[i].count,
7041 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307042 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307043 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307044 if(pSapCtx == NULL){
7045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7046 FL("psapCtx is NULL"));
7047 return;
7048 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307049
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307050 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307051 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7052 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307053 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307054 {
7055 hddLog(LOGE, "******STAIndex: %d*********", i);
7056 for ( j=0; j< NUM_TX_QUEUES; j++)
7057 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307058 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007059 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307060 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
7061 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
7062 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
7063 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307064 }
7065 }
7066 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307067 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307068
Katya Nigam1fd24402015-02-16 14:52:19 +05307069 if(pHddStaCtx == NULL){
7070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7071 FL("pHddStaCtx is NULL"));
7072 return;
7073 }
7074
7075 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7076 if(pPeerInfo == NULL){
7077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7078 FL("ppeerinfo is NULL"));
7079 return;
7080 }
7081
7082 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7083 {
7084 if(pPeerInfo->ibssStaInfo[i].isUsed)
7085 {
7086 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7087 for ( j=0; j< NUM_TX_QUEUES; j++)
7088 {
7089 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7090 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7091 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7092 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7093 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7094 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7095 }
7096 }
7097 }
7098
7099
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307100}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307101static int __iw_set_var_ints_getnone(struct net_device *dev,
7102 struct iw_request_info *info,
7103 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007104{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307105 hdd_adapter_t *pAdapter;
7106 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307107 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307108 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007109 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307110 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007111 hdd_ap_ctx_t *pAPCtx = NULL;
7112 int cmd = 0;
7113 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307114 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007115
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307116 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307117 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307118 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7120 "%s: NULL extra buffer pointer", __func__);
7121 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307122 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307123 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7124 if (NULL == pAdapter)
7125 {
7126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7127 "%s: Adapter is NULL",__func__);
7128 return -EINVAL;
7129 }
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307130 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7131 ret = wlan_hdd_validate_context(pHddCtx);
7132 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007133 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307134 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007135 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307136 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7137 if (NULL == hHal)
7138 {
7139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7140 "%s: Hal Context is NULL",__func__);
7141 return -EINVAL;
7142 }
7143 sub_cmd = wrqu->data.flags;
7144
7145 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7146
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007147
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007148 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7149 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7150 {
7151 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7152 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7153 {
7154 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7155 staId = pStaCtx->conn_info.staId[0];
7156 }
7157 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7158 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7159 {
7160 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7161 staId = pAPCtx->uBCStaId;
7162 }
7163 else
7164 {
7165 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7166 return 0;
7167 }
7168 }
7169
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 switch (sub_cmd)
7171 {
7172 case WE_LOG_DUMP_CMD:
7173 {
7174 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007175 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007176 apps_args[3], apps_args[4]);
7177
7178 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7179 apps_args[3], apps_args[4]);
7180
7181 }
7182 break;
7183
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 case WE_P2P_NOA_CMD:
7185 {
7186 p2p_app_setP2pPs_t p2pNoA;
7187
7188 p2pNoA.opp_ps = apps_args[0];
7189 p2pNoA.ctWindow = apps_args[1];
7190 p2pNoA.duration = apps_args[2];
7191 p2pNoA.interval = apps_args[3];
7192 p2pNoA.count = apps_args[4];
7193 p2pNoA.single_noa_duration = apps_args[5];
7194 p2pNoA.psSelection = apps_args[6];
7195
7196 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7197 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007198 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007199 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7200
7201 hdd_setP2pPs(dev, &p2pNoA);
7202
7203 }
7204 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007205
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307206 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7207 {
7208 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7209 __func__, apps_args[0], apps_args[1]);
7210 vosTraceEnable(apps_args[0], apps_args[1]);
7211 }
7212 break;
7213
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007214 case WE_MTRACE_DUMP_CMD:
7215 {
7216 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7217 "bitmask_of_module %d ",
7218 __func__, apps_args[0], apps_args[1], apps_args[2],
7219 apps_args[3]);
7220 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7221 apps_args[2], apps_args[3]);
7222
7223 }
7224 break;
7225
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007226 case WE_MCC_CONFIG_CREDENTIAL :
7227 {
7228 cmd = 287; //Command should be updated if there is any change
7229 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007230 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007231 {
7232 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7233 }
7234 else
7235 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007236 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007237 return 0;
7238 }
7239 }
7240 break;
7241
7242 case WE_MCC_CONFIG_PARAMS :
7243 {
7244 cmd = 288; //command Should be updated if there is any change
7245 // in the Riva dump command
7246 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7247 }
7248 break;
7249
Chilam NG571c65a2013-01-19 12:27:36 +05307250#ifdef FEATURE_WLAN_TDLS
7251 case WE_TDLS_CONFIG_PARAMS :
7252 {
7253 tdls_config_params_t tdlsParams;
7254
Chilam Ng01120412013-02-19 18:32:21 -08007255 tdlsParams.tdls = apps_args[0];
7256 tdlsParams.tx_period_t = apps_args[1];
7257 tdlsParams.tx_packet_n = apps_args[2];
7258 tdlsParams.discovery_period_t = apps_args[3];
7259 tdlsParams.discovery_tries_n = apps_args[4];
7260 tdlsParams.idle_timeout_t = apps_args[5];
7261 tdlsParams.idle_packet_n = apps_args[6];
7262 tdlsParams.rssi_hysteresis = apps_args[7];
7263 tdlsParams.rssi_trigger_threshold = apps_args[8];
7264 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307265
Chilam Ng01120412013-02-19 18:32:21 -08007266 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307267 }
7268 break;
7269#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 default:
7271 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007272 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7273 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007274 }
7275 break;
7276 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307277 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007278 return 0;
7279}
7280
Girish Gowlifb9758e2014-11-19 15:19:17 +05307281static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7282 struct iw_request_info *info,
7283 union iwreq_data *wrqu, char *extra)
7284{
7285 int ret;
7286 union iwreq_data u_priv_wrqu;
7287 int apps_args[MAX_VAR_ARGS] = {0};
7288 int num_args;
7289
7290 /* helper function to get iwreq_data with compat handling. */
7291 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7292 {
7293 return -EINVAL;
7294 }
7295
7296 if (NULL == u_priv_wrqu.data.pointer)
7297 {
7298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7299 "%s: NULL data pointer", __func__);
7300 return -EINVAL;
7301 }
7302
7303 num_args = u_priv_wrqu.data.length;
7304 if (num_args > MAX_VAR_ARGS)
7305 {
7306 num_args = MAX_VAR_ARGS;
7307 }
7308
7309 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7310 (sizeof(int)) * num_args))
7311 {
7312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7313 "%s: failed to copy data from user buffer", __func__);
7314 return -EFAULT;
7315 }
7316
7317 vos_ssr_protect(__func__);
7318 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7319 (char *)&apps_args);
7320 vos_ssr_unprotect(__func__);
7321
7322 return ret;
7323}
7324
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307325int iw_set_var_ints_getnone(struct net_device *dev,
7326 struct iw_request_info *info,
7327 union iwreq_data *wrqu, char *extra)
7328{
7329 int ret;
7330 vos_ssr_protect(__func__);
7331 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7332 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007333
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307334 return ret;
7335}
7336
7337static int __iw_add_tspec(struct net_device *dev,
7338 struct iw_request_info *info,
7339 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007340{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307341 hdd_adapter_t *pAdapter;
7342 hdd_station_ctx_t *pHddStaCtx;
7343 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7345 int params[HDD_WLAN_WMM_PARAM_COUNT];
7346 sme_QosWmmTspecInfo tSpec;
7347 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307348 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307349 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007350
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307351 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307352 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7353 if (NULL == pAdapter)
7354 {
7355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7356 "%s: Adapter is NULL",__func__);
7357 return -EINVAL;
7358 }
7359 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7360 ret = wlan_hdd_validate_context(pHddCtx);
7361 if (0 != ret)
7362 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307363 return ret;
7364 }
7365 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7366 if (NULL == pHddStaCtx)
7367 {
7368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7369 "%s: STA Context is NULL",__func__);
7370 return -EINVAL;
7371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007372 // make sure the application is sufficiently priviledged
7373 // note that the kernel will do this for "set" ioctls, but since
7374 // this ioctl wants to return status to user space it must be
7375 // defined as a "get" ioctl
7376 if (!capable(CAP_NET_ADMIN))
7377 {
7378 return -EPERM;
7379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007380 // we must be associated in order to add a tspec
7381 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7382 {
7383 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7384 return 0;
7385 }
7386
7387 // since we are defined to be a "get" ioctl, and since the number
7388 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307389 // will pass down in the iwreq_data, we must copy the "set" params.
7390 // We must handle the compat for iwreq_data in 32U/64K environment.
7391
7392 // helper fucntion to get iwreq_data with compat handling.
7393 if (hdd_priv_get_data(&s_priv_data, wrqu))
7394 {
7395 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7396 return 0;
7397 }
7398
7399 // make sure all params are correctly passed to function
7400 if ((NULL == s_priv_data.pointer) ||
7401 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7402 {
7403 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7404 return 0;
7405 }
7406
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307408 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 {
7410 // hmmm, can't get them
7411 return -EIO;
7412 }
7413
7414 // clear the tspec
7415 memset(&tSpec, 0, sizeof(tSpec));
7416
7417 // validate the handle
7418 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7419 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7420 {
7421 // that one is reserved
7422 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7423 return 0;
7424 }
7425
7426 // validate the TID
7427 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7428 {
7429 // out of range
7430 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7431 return 0;
7432 }
7433 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7434
7435 // validate the direction
7436 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7437 {
7438 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7439 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7440 break;
7441
7442 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7443 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7444 break;
7445
7446 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7447 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7448 break;
7449
7450 default:
7451 // unknown
7452 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7453 return 0;
7454 }
7455
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307456 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7457
Jeff Johnson295189b2012-06-20 16:38:30 -07007458 // validate the user priority
7459 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7460 {
7461 // out of range
7462 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7463 return 0;
7464 }
7465 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307466 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7467 {
7468 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7469 return 0;
7470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007471
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7473 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7474 tSpec.ts_info.psb, tSpec.ts_info.up);
7475
Jeff Johnson295189b2012-06-20 16:38:30 -07007476 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7477 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7478 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7479 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7480 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7481 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7482 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7483 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7484 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7485 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7486 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7487 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7488
7489 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7490
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307491 // Save the expected UAPSD settings by application, this will be needed
7492 // when re-negotiating UAPSD settings during BT Coex cases.
7493 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7494
Jeff Johnson295189b2012-06-20 16:38:30 -07007495 // validate the ts info ack policy
7496 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7497 {
7498 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7499 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7500 break;
7501
7502 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7503 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7504 break;
7505
7506 default:
7507 // unknown
7508 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7509 return 0;
7510 }
7511
7512 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307513
7514 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007515 return 0;
7516}
7517
7518
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307519static int iw_add_tspec(struct net_device *dev,
7520 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 union iwreq_data *wrqu, char *extra)
7522{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307523 int ret;
7524
7525 vos_ssr_protect(__func__);
7526 ret = __iw_add_tspec(dev, info, wrqu, extra);
7527 vos_ssr_unprotect(__func__);
7528
7529 return ret;
7530}
7531
7532static int __iw_del_tspec(struct net_device *dev,
7533 struct iw_request_info *info,
7534 union iwreq_data *wrqu, char *extra)
7535{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307536 hdd_adapter_t *pAdapter;
7537 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 int *params = (int *)extra;
7539 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7540 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307541 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007542
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307543 ENTER();
7544
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307545 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7546 if (NULL == pAdapter)
7547 {
7548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7549 "%s: Adapter is NULL",__func__);
7550 return -EINVAL;
7551 }
7552
7553 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7554 ret = wlan_hdd_validate_context(pHddCtx);
7555 if (0 != ret)
7556 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307557 return ret;
7558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007559 // make sure the application is sufficiently priviledged
7560 // note that the kernel will do this for "set" ioctls, but since
7561 // this ioctl wants to return status to user space it must be
7562 // defined as a "get" ioctl
7563 if (!capable(CAP_NET_ADMIN))
7564 {
7565 return -EPERM;
7566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007567 // although we are defined to be a "get" ioctl, the params we require
7568 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7569 // is no need to copy the params from user space
7570
7571 // validate the handle
7572 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7573 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7574 {
7575 // that one is reserved
7576 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7577 return 0;
7578 }
7579
7580 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307581
7582 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007583 return 0;
7584}
7585
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307586static int iw_del_tspec(struct net_device *dev,
7587 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 union iwreq_data *wrqu, char *extra)
7589{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307590 int ret;
7591
7592 vos_ssr_protect(__func__);
7593 ret = __iw_del_tspec(dev, info, wrqu, extra);
7594 vos_ssr_unprotect(__func__);
7595
7596 return ret;
7597}
7598
7599
7600static int __iw_get_tspec(struct net_device *dev,
7601 struct iw_request_info *info,
7602 union iwreq_data *wrqu, char *extra)
7603{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307604 hdd_adapter_t *pAdapter;
7605 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007606 int *params = (int *)extra;
7607 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7608 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307609 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007610
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307611 ENTER();
7612
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 // although we are defined to be a "get" ioctl, the params we require
7614 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7615 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307616 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7617 if (NULL == pAdapter)
7618 {
7619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7620 "%s: Adapter is NULL",__func__);
7621 return -EINVAL;
7622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007623
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307624 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7625 ret = wlan_hdd_validate_context(pHddCtx);
7626 if (0 != ret)
7627 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307628 return ret;
7629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 // validate the handle
7631 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7632 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7633 {
7634 // that one is reserved
7635 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7636 return 0;
7637 }
7638
7639 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307640 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 return 0;
7642}
7643
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307644static int iw_get_tspec(struct net_device *dev,
7645 struct iw_request_info *info,
7646 union iwreq_data *wrqu, char *extra)
7647{
7648 int ret;
7649
7650 vos_ssr_protect(__func__);
7651 ret = __iw_get_tspec(dev, info, wrqu, extra);
7652 vos_ssr_unprotect(__func__);
7653
7654 return ret;
7655}
7656
Jeff Johnson295189b2012-06-20 16:38:30 -07007657#ifdef WLAN_FEATURE_VOWIFI_11R
7658//
7659//
7660// Each time the supplicant has the auth_request or reassoc request
7661// IEs ready. This is pushed to the driver. The driver will inturn use
7662// it to send out the auth req and reassoc req for 11r FT Assoc.
7663//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307664static int __iw_set_fties(struct net_device *dev,
7665 struct iw_request_info *info,
7666 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007667{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307668 hdd_adapter_t *pAdapter;
7669 hdd_station_ctx_t *pHddStaCtx;
7670 hdd_context_t *pHddCtx;
7671 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 //v_CONTEXT_t pVosContext;
7673
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307674 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307675 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7676 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007677 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7679 "%s: Adapter is NULL",__func__);
7680 return -EINVAL;
7681 }
7682 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7683 ret = wlan_hdd_validate_context(pHddCtx);
7684 if (0 != ret)
7685 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307686 return ret;
7687 }
7688 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7689 if (NULL == pHddStaCtx)
7690 {
7691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7692 "%s: STA Context is NULL",__func__);
7693 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 if (!wrqu->data.length)
7696 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007697 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 return -EINVAL;
7699 }
7700 if (wrqu->data.pointer == NULL)
7701 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007702 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 return -EINVAL;
7704 }
7705
7706 // Added for debug on reception of Re-assoc Req.
7707 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7708 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007709 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007710 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007711 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 }
7713
7714#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007715 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007716#endif
7717
7718 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007719 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007720 wrqu->data.length);
7721
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307722 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007723 return 0;
7724}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307725
7726static int iw_set_fties(struct net_device *dev,
7727 struct iw_request_info *info,
7728 union iwreq_data *wrqu, char *extra)
7729{
7730 int ret;
7731
7732 vos_ssr_protect(__func__);
7733 ret = __iw_set_fties(dev, info, wrqu, extra);
7734 vos_ssr_unprotect(__func__);
7735
7736 return ret;
7737}
Jeff Johnson295189b2012-06-20 16:38:30 -07007738#endif
7739
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307740static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007741 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007742 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007743{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307744 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007745 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307746 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007747 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307748 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007749 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7750 int idx;
7751 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007752
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307753 ENTER();
7754
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307755 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7756 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007757 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7759 "%s: Adapter is NULL",__func__);
7760 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007761 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307762 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7763 ret_val = wlan_hdd_validate_context(pHddCtx);
7764 if (0 != ret_val)
7765 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307766 return ret_val;
7767 }
7768 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7769 if (NULL == hHal)
7770 {
7771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7772 "%s: Hal Context is NULL",__func__);
7773 return -EINVAL;
7774 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307775 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7776 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307777#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007778
Amar Singhalf3a6e762013-02-19 15:06:50 -08007779 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7780 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007781 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007782 hddLog(VOS_TRACE_LEVEL_ERROR,
7783 "%s: vos_mem_alloc failed", __func__);
7784 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007785 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007786
7787 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7788
7789 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7790 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7791
7792 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7793 mc_addr_list_ptr->ulMulticastAddrCnt);
7794
7795 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007796 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007797 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7798 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7799
7800 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7801 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007802 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007803
Amar Singhalf3a6e762013-02-19 15:06:50 -08007804 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7805 vos_mem_free(mc_addr_list_ptr);
7806 if (eHAL_STATUS_SUCCESS != ret_val)
7807 {
7808 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7809 __func__);
7810 return -EINVAL;
7811 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307812#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307813 }
7814 else
7815 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007816
Amar Singhalf3a6e762013-02-19 15:06:50 -08007817 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7818 "%s: Set MC BC Filter Config request: %d suspend %d",
7819 __func__, pRequest->mcastBcastFilterSetting,
7820 pHddCtx->hdd_wlan_suspended);
7821
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307822 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007823
7824 if (pHddCtx->hdd_wlan_suspended)
7825 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007826 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7827 if (NULL == wlanRxpFilterParam)
7828 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307829 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007830 "%s: vos_mem_alloc failed", __func__);
7831 return -EINVAL;
7832 }
7833
Amar Singhalf3a6e762013-02-19 15:06:50 -08007834 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7835 pRequest->mcastBcastFilterSetting;
7836 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7837
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307838 hdd_conf_hostoffload(pAdapter, TRUE);
7839 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7840 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007841
7842 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7843 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307844 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007845 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7846 wlanRxpFilterParam->setMcstBcstFilter);
7847
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307848 if (eHAL_STATUS_SUCCESS !=
7849 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7850 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007851 {
7852 hddLog(VOS_TRACE_LEVEL_ERROR,
7853 "%s: Failure to execute set HW MC/BC Filter request",
7854 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007855 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007856 return -EINVAL;
7857 }
7858
c_hpothud3ce76d2014-10-28 10:34:13 +05307859 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7860 {
7861 pHddCtx->sus_res_mcastbcast_filter =
7862 pRequest->mcastBcastFilterSetting;
7863 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007864 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007865 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007866
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307867 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 return 0;
7869}
7870
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307871static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7872 struct iw_request_info *info,
7873 union iwreq_data *wrqu, char *extra)
7874{
7875 int ret;
7876
7877 vos_ssr_protect(__func__);
7878 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
7879 vos_ssr_unprotect(__func__);
7880
7881 return ret;
7882}
7883
7884static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7885 struct iw_request_info *info,
7886 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007887{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307888 hdd_adapter_t *pAdapter;
7889 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307890 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307891 int ret = 0;
7892
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307893 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007894
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307895 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7896 if (NULL == pAdapter)
7897 {
7898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7899 "%s: Adapter is NULL",__func__);
7900 return -EINVAL;
7901 }
7902
7903 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7904 ret = wlan_hdd_validate_context(pHddCtx);
7905 if (0 != ret)
7906 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307907 return ret;
7908 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307909 //Reset the filter to INI value as we have to clear the dynamic filter
7910 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07007911
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307912 //Configure FW with new setting
7913 if (pHddCtx->hdd_wlan_suspended)
7914 {
7915 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7916 if (NULL == wlanRxpFilterParam)
7917 {
7918 hddLog(VOS_TRACE_LEVEL_ERROR,
7919 "%s: vos_mem_alloc failed", __func__);
7920 return -EINVAL;
7921 }
7922
7923 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7924 pHddCtx->configuredMcastBcastFilter;
7925 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7926
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307927 hdd_conf_hostoffload(pAdapter, TRUE);
7928 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7929 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307930
7931 if (eHAL_STATUS_SUCCESS !=
7932 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7933 wlanRxpFilterParam))
7934 {
7935 hddLog(VOS_TRACE_LEVEL_ERROR,
7936 "%s: Failure to execute set HW MC/BC Filter request",
7937 __func__);
7938 vos_mem_free(wlanRxpFilterParam);
7939 return -EINVAL;
7940 }
c_hpothud3ce76d2014-10-28 10:34:13 +05307941
7942 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7943 {
7944 pHddCtx->sus_res_mcastbcast_filter =
7945 pHddCtx->cfg_ini->mcastBcastFilterSetting;
7946 }
7947
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307948 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307949 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007950 return 0;
7951}
7952
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307953
7954static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7955 struct iw_request_info *info,
7956 union iwreq_data *wrqu, char *extra)
7957{
7958 int ret;
7959
7960 vos_ssr_protect(__func__);
7961 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
7962 vos_ssr_unprotect(__func__);
7963
7964 return ret;
7965}
7966
7967static int __iw_set_host_offload(struct net_device *dev,
7968 struct iw_request_info *info,
7969 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007970{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307971 hdd_adapter_t *pAdapter;
7972 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007973 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007974 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307975 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007976
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307977 ENTER();
7978
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307979 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7980 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007981 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7983 "%s: Adapter is NULL",__func__);
7984 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007985 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307986 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7987 ret = wlan_hdd_validate_context(pHddCtx);
7988 if (0 != ret)
7989 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307990 return ret;
7991 }
7992
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 /* Debug display of request components. */
7994 switch (pRequest->offloadType)
7995 {
7996 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007997 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007998 switch (pRequest->enableOrDisable)
7999 {
8000 case WLAN_OFFLOAD_DISABLE:
8001 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
8002 break;
8003 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
8004 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
8005 case WLAN_OFFLOAD_ENABLE:
8006 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
8007 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
8008 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
8009 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
8010 }
8011 break;
8012
8013 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008014 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008015 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008016 switch (pRequest->enableOrDisable)
8017 {
8018 case WLAN_OFFLOAD_DISABLE:
8019 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8020 break;
8021 case WLAN_OFFLOAD_ENABLE:
8022 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8023 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8024 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8025 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8026 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8027 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8028 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8029 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8030 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8031 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8032 }
8033 }
8034
8035 /* Execute offload request. The reason that we can copy the request information
8036 from the ioctl structure to the SME structure is that they are laid out
8037 exactly the same. Otherwise, each piece of information would have to be
8038 copied individually. */
8039 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008040 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8041 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008043 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 __func__);
8045 return -EINVAL;
8046 }
8047
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308048 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 return 0;
8050}
8051
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308052static int iw_set_host_offload(struct net_device *dev,
8053 struct iw_request_info *info,
8054 union iwreq_data *wrqu, char *extra)
8055{
8056 int ret;
8057
8058 vos_ssr_protect(__func__);
8059 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8060 vos_ssr_unprotect(__func__);
8061
8062 return ret;
8063}
8064
8065static int __iw_set_keepalive_params(struct net_device *dev,
8066 struct iw_request_info *info,
8067 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008068{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308069 hdd_adapter_t *pAdapter;
8070 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008071 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308073 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008074
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308075 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308076 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8077 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8080 "%s: Adapter is NULL",__func__);
8081 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308083 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8084 ret = wlan_hdd_validate_context(pHddCtx);
8085 if (0 != ret)
8086 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308087 return ret;
8088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008090 hddLog(VOS_TRACE_LEVEL_INFO,
8091 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8092 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008093
8094 switch (pRequest->packetType)
8095 {
8096 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008097 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008098 break;
8099
8100 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8101
Arif Hussain6d2a3322013-11-17 19:50:10 -08008102 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008103 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008104
8105 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8106 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8107 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8108
8109 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8110 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8111 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8112
8113 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8114 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8115 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8116 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8117 break;
8118
8119 }
8120
8121 /* Execute keep alive request. The reason that we can copy the request information
8122 from the ioctl structure to the SME structure is that they are laid out
8123 exactly the same. Otherwise, each piece of information would have to be
8124 copied individually. */
8125 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8126
Arif Hussain6d2a3322013-11-17 19:50:10 -08008127 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008128
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008129 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008130 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008131 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008132 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 __func__);
8134 return -EINVAL;
8135 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308136 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 return 0;
8138}
8139
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308140static int iw_set_keepalive_params(struct net_device *dev,
8141 struct iw_request_info *info,
8142 union iwreq_data *wrqu, char *extra)
8143{
8144 int ret;
8145 vos_ssr_protect(__func__);
8146 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8147 vos_ssr_unprotect(__func__);
8148
8149 return ret;
8150}
8151
Jeff Johnson295189b2012-06-20 16:38:30 -07008152#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008153int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008154 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008155{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008156 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8157 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008158 int i=0;
8159
8160 if (pHddCtx->cfg_ini->disablePacketFilter)
8161 {
8162 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008163 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 return 0;
8165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 /* Debug display of request components. */
8167 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008168 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008169
8170 switch (pRequest->filterAction)
8171 {
8172 case HDD_RCV_FILTER_SET:
8173 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008174 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008175
8176 packetFilterSetReq.filterId = pRequest->filterId;
8177 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8178 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008179 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 __func__, pRequest->numParams);
8181 return -EINVAL;
8182 }
8183 packetFilterSetReq.numFieldParams = pRequest->numParams;
8184 packetFilterSetReq.coalesceTime = 0;
8185 packetFilterSetReq.filterType = 1;
8186 for (i=0; i < pRequest->numParams; i++)
8187 {
8188 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8189 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8190 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8191 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8192 packetFilterSetReq.paramsData[i].reserved = 0;
8193
Arif Hussain6d2a3322013-11-17 19:50:10 -08008194 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008195 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8196 packetFilterSetReq.filterType);
8197
Arif Hussain6d2a3322013-11-17 19:50:10 -08008198 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8200
8201 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8202 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8203 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8204 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8205
Arif Hussain6d2a3322013-11-17 19:50:10 -08008206 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8208 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8209 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8210
Arif Hussain6d2a3322013-11-17 19:50:10 -08008211 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8213 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8214 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8215 }
8216
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008217 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008219 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 __func__);
8221 return -EINVAL;
8222 }
8223
8224 break;
8225
8226 case HDD_RCV_FILTER_CLEAR:
8227
Arif Hussain6d2a3322013-11-17 19:50:10 -08008228 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008229 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008231 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008232 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008233 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 __func__);
8235 return -EINVAL;
8236 }
8237 break;
8238
8239 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008240 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008241 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 return -EINVAL;
8243 }
8244 return 0;
8245}
8246
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308247int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8248 tANI_U8 sessionId)
8249{
8250 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8251 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8252
8253 if (NULL == pHddCtx)
8254 {
8255 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8256 return -EINVAL;
8257 }
8258
8259 if (pHddCtx->isLogpInProgress)
8260 {
8261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8262 "%s:LOGP in Progress. Ignore!!!", __func__);
8263 return -EBUSY;
8264 }
8265
8266 if (pHddCtx->cfg_ini->disablePacketFilter)
8267 {
8268 hddLog(VOS_TRACE_LEVEL_ERROR,
8269 "%s: Packet Filtering Disabled. Returning ",
8270 __func__ );
8271 return -EINVAL;
8272 }
8273
8274 switch (filterType)
8275 {
8276 /* For setting IPV6 MC and UC Filter we need to configure
8277 * 2 filters, one for MC and one for UC.
8278 * The Filter ID shouldn't be swapped, which results in making
8279 * UC Filter ineffective.
8280 * We have Hardcode all the values
8281 *
8282 * Reason for a seperate UC filter is because, driver need to
8283 * specify the FW that the specific filter is for unicast
8284 * otherwise FW will not pass the unicast frames by default
8285 * through the filter. This is required to avoid any performance
8286 * hits when no unicast filter is set and only MC/BC are set.
8287 * The way driver informs host is by using the MAC protocol
8288 * layer, CMP flag set to MAX, CMP Data set to 1.
8289 */
8290
8291 case HDD_FILTER_IPV6_MC_UC:
8292 /* Setting IPV6 MC Filter below
8293 */
8294 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8295 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8296 packetFilterSetReq.numFieldParams = 2;
8297 packetFilterSetReq.paramsData[0].protocolLayer =
8298 HDD_FILTER_PROTO_TYPE_MAC;
8299 packetFilterSetReq.paramsData[0].cmpFlag =
8300 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8301 packetFilterSetReq.paramsData[0].dataOffset =
8302 WLAN_HDD_80211_FRM_DA_OFFSET;
8303 packetFilterSetReq.paramsData[0].dataLength = 1;
8304 packetFilterSetReq.paramsData[0].compareData[0] =
8305 HDD_IPV6_MC_CMP_DATA;
8306
8307 packetFilterSetReq.paramsData[1].protocolLayer =
8308 HDD_FILTER_PROTO_TYPE_ARP;
8309 packetFilterSetReq.paramsData[1].cmpFlag =
8310 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8311 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8312 packetFilterSetReq.paramsData[1].dataLength = 2;
8313 packetFilterSetReq.paramsData[1].compareData[0] =
8314 HDD_IPV6_CMP_DATA_0;
8315 packetFilterSetReq.paramsData[1].compareData[1] =
8316 HDD_IPV6_CMP_DATA_1;
8317
8318
8319 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8320 &packetFilterSetReq, sessionId))
8321 {
8322 hddLog(VOS_TRACE_LEVEL_ERROR,
8323 "%s: Failure to execute Set IPv6 Mulicast Filter",
8324 __func__);
8325 return -EINVAL;
8326 }
8327
8328 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8329
8330 /*
8331 * Setting IPV6 UC Filter below
8332 */
8333 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8334 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8335 packetFilterSetReq.numFieldParams = 2;
8336 packetFilterSetReq.paramsData[0].protocolLayer =
8337 HDD_FILTER_PROTO_TYPE_MAC;
8338 packetFilterSetReq.paramsData[0].cmpFlag =
8339 HDD_FILTER_CMP_TYPE_MAX;
8340 packetFilterSetReq.paramsData[0].dataOffset = 0;
8341 packetFilterSetReq.paramsData[0].dataLength = 1;
8342 packetFilterSetReq.paramsData[0].compareData[0] =
8343 HDD_IPV6_UC_CMP_DATA;
8344
8345 packetFilterSetReq.paramsData[1].protocolLayer =
8346 HDD_FILTER_PROTO_TYPE_ARP;
8347 packetFilterSetReq.paramsData[1].cmpFlag =
8348 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8349 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8350 packetFilterSetReq.paramsData[1].dataLength = 2;
8351 packetFilterSetReq.paramsData[1].compareData[0] =
8352 HDD_IPV6_CMP_DATA_0;
8353 packetFilterSetReq.paramsData[1].compareData[1] =
8354 HDD_IPV6_CMP_DATA_1;
8355
8356 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8357 &packetFilterSetReq, sessionId))
8358 {
8359 hddLog(VOS_TRACE_LEVEL_ERROR,
8360 "%s: Failure to execute Set IPv6 Unicast Filter",
8361 __func__);
8362 return -EINVAL;
8363 }
8364
8365 break;
8366
8367 case HDD_FILTER_IPV6_MC:
8368 /*
8369 * IPV6 UC Filter might be already set,
8370 * clear the UC Filter. As the Filter
8371 * IDs are static, we can directly clear it.
8372 */
8373 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8374 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8375 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8376 &packetFilterClrReq, sessionId))
8377 {
8378 hddLog(VOS_TRACE_LEVEL_ERROR,
8379 "%s: Failure to execute Clear IPv6 Unicast Filter",
8380 __func__);
8381 return -EINVAL;
8382 }
8383
8384 /*
8385 * Setting IPV6 MC Filter below
8386 */
8387 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8388 packetFilterSetReq.numFieldParams = 2;
8389 packetFilterSetReq.paramsData[0].protocolLayer =
8390 HDD_FILTER_PROTO_TYPE_MAC;
8391 packetFilterSetReq.paramsData[0].cmpFlag =
8392 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8393 packetFilterSetReq.paramsData[0].dataOffset =
8394 WLAN_HDD_80211_FRM_DA_OFFSET;
8395 packetFilterSetReq.paramsData[0].dataLength = 1;
8396 packetFilterSetReq.paramsData[0].compareData[0] =
8397 HDD_IPV6_MC_CMP_DATA;
8398
8399 packetFilterSetReq.paramsData[1].protocolLayer =
8400 HDD_FILTER_PROTO_TYPE_ARP;
8401 packetFilterSetReq.paramsData[1].cmpFlag =
8402 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8403 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8404 packetFilterSetReq.paramsData[1].dataLength = 2;
8405 packetFilterSetReq.paramsData[1].compareData[0] =
8406 HDD_IPV6_CMP_DATA_0;
8407 packetFilterSetReq.paramsData[1].compareData[1] =
8408 HDD_IPV6_CMP_DATA_1;
8409
8410
8411 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8412 &packetFilterSetReq, sessionId))
8413 {
8414 hddLog(VOS_TRACE_LEVEL_ERROR,
8415 "%s: Failure to execute Set IPv6 Multicast Filter",
8416 __func__);
8417 return -EINVAL;
8418 }
8419 break;
8420
8421 default :
8422 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8423 "%s: Packet Filter Request: Invalid",
8424 __func__);
8425 return -EINVAL;
8426 }
8427 return 0;
8428}
8429
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308430void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008431{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308432 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308433 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008434 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308435 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008436
Yue Ma3ede6052013-08-29 00:33:26 -07008437 if (NULL == pHddCtx)
8438 {
8439 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8440 return;
8441 }
8442
8443 hHal = pHddCtx->hHal;
8444
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308445 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308447 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8448 return;
8449 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308450
8451 /* Check if INI is enabled or not, other wise just return
8452 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308453 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308454 {
8455 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8456 if (NULL == pMulticastAddrs)
8457 {
8458 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8459 return;
8460 }
8461
Jeff Johnson295189b2012-06-20 16:38:30 -07008462 if (set)
8463 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308464 /* Following pre-conditions should be satisfied before wei
8465 * configure the MC address list.
8466 */
8467 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8468 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8469 && pAdapter->mc_addr_list.mc_cnt
8470 && (eConnectionState_Associated ==
8471 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8472 {
8473 pMulticastAddrs->ulMulticastAddrCnt =
8474 pAdapter->mc_addr_list.mc_cnt;
8475 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8476 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008477 memcpy(pMulticastAddrs->multicastAddr[i],
8478 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308479 sizeof(pAdapter->mc_addr_list.addr[i]));
8480 hddLog(VOS_TRACE_LEVEL_INFO,
8481 "%s: %s multicast filter: addr ="
8482 MAC_ADDRESS_STR,
8483 __func__, set ? "setting" : "clearing",
8484 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8485 }
8486 /* Set multicast filter */
8487 sme_8023MulticastList(hHal, pAdapter->sessionId,
8488 pMulticastAddrs);
8489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008490 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308491 else
8492 {
8493 /* Need to clear only if it was previously configured
8494 */
8495 if (pAdapter->mc_addr_list.isFilterApplied)
8496 {
8497 pMulticastAddrs->ulMulticastAddrCnt = 0;
8498 sme_8023MulticastList(hHal, pAdapter->sessionId,
8499 pMulticastAddrs);
8500 }
8501
8502 }
8503 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008504 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308506 else
8507 {
8508 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308509 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308510 }
8511 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008512}
8513
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308514static int __iw_set_packet_filter_params(struct net_device *dev,
8515 struct iw_request_info *info,
8516 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308517{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308518 hdd_adapter_t *pAdapter;
8519 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008520 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308521 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308522 struct iw_point s_priv_data;
8523
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308524 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308525 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8526 if (NULL == pAdapter)
8527 {
8528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8529 "%s: Adapter is NULL",__func__);
8530 return -EINVAL;
8531 }
8532 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8533 ret = wlan_hdd_validate_context(pHddCtx);
8534 if (0 != ret)
8535 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308536 return ret;
8537 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308538 if (hdd_priv_get_data(&s_priv_data, wrqu))
8539 {
8540 return -EINVAL;
8541 }
8542
8543 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8544 {
8545 return -EINVAL;
8546 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008547
Arif Hussain0273cba2014-01-07 20:58:29 -08008548 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308549 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8550 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008551 if (NULL == pRequest)
8552 {
8553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8554 "mem_alloc_copy_from_user_helper fail");
8555 return -ENOMEM;
8556 }
8557
8558 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8559 kfree(pRequest);
8560
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308561 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008562 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008563}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308564
8565static int iw_set_packet_filter_params(struct net_device *dev,
8566 struct iw_request_info *info,
8567 union iwreq_data *wrqu, char *extra)
8568{
8569 int ret;
8570
8571 vos_ssr_protect(__func__);
8572 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8573 vos_ssr_unprotect(__func__);
8574
8575 return ret;
8576}
Jeff Johnson295189b2012-06-20 16:38:30 -07008577#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308578static int __iw_get_statistics(struct net_device *dev,
8579 struct iw_request_info *info,
8580 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008581{
8582
8583 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8584 eHalStatus status = eHAL_STATUS_SUCCESS;
8585 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308586 hdd_adapter_t *pAdapter;
8587 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008588 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308589 int tlen = 0, ret = 0;
8590 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008591
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308592 tCsrGlobalClassAStatsInfo *aStats;
8593 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008594
8595 ENTER();
8596
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308597 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8598 if (NULL == pAdapter)
8599 {
8600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8601 "%s: Adapter is NULL",__func__);
8602 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308604 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8605 ret = wlan_hdd_validate_context(pHddCtx);
8606 if (0 != ret)
8607 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308608 return ret;
8609 }
8610 pStats = &(pAdapter->hdd_stats.summary_stat);
8611 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8612 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8614
8615 wrqu->txpower.value = 0;
8616 }
8617 else {
8618 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8619 SME_SUMMARY_STATS |
8620 SME_GLOBAL_CLASSA_STATS |
8621 SME_GLOBAL_CLASSB_STATS |
8622 SME_GLOBAL_CLASSC_STATS |
8623 SME_GLOBAL_CLASSD_STATS |
8624 SME_PER_STA_STATS,
8625 hdd_StatisticsCB, 0, FALSE,
8626 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8627
8628 if (eHAL_STATUS_SUCCESS != status)
8629 {
8630 hddLog(VOS_TRACE_LEVEL_ERROR,
8631 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008632 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008633 return -EINVAL;
8634 }
8635
8636 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308637 if (NULL == pWextState)
8638 {
8639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8640 "%s: pWextState is NULL",__func__);
8641 return -EINVAL;
8642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008643
8644 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8645 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8646 {
8647 hddLog(VOS_TRACE_LEVEL_ERROR,
8648 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008649 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 /*Remove the SME statistics list by passing NULL in callback argument*/
8651 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8652 SME_SUMMARY_STATS |
8653 SME_GLOBAL_CLASSA_STATS |
8654 SME_GLOBAL_CLASSB_STATS |
8655 SME_GLOBAL_CLASSC_STATS |
8656 SME_GLOBAL_CLASSD_STATS |
8657 SME_PER_STA_STATS,
8658 NULL, 0, FALSE,
8659 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8660
8661 return -EINVAL;
8662 }
8663 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8664 (tANI_U8) sizeof (pStats->retry_cnt),
8665 (char*) &(pStats->retry_cnt[0]),
8666 tlen);
8667
8668 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8669 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8670 (char*) &(pStats->multiple_retry_cnt[0]),
8671 tlen);
8672
8673 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8674 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8675 (char*) &(pStats->tx_frm_cnt[0]),
8676 tlen);
8677
8678 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8679 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8680 (char*) &(pStats->rx_frm_cnt),
8681 tlen);
8682
8683 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8684 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8685 (char*) &(pStats->frm_dup_cnt),
8686 tlen);
8687
8688 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8689 (tANI_U8) sizeof (pStats->fail_cnt),
8690 (char*) &(pStats->fail_cnt[0]),
8691 tlen);
8692
8693 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8694 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8695 (char*) &(pStats->rts_fail_cnt),
8696 tlen);
8697
8698 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8699 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8700 (char*) &(pStats->ack_fail_cnt),
8701 tlen);
8702
8703 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8704 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8705 (char*) &(pStats->rts_succ_cnt),
8706 tlen);
8707
8708 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8709 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8710 (char*) &(pStats->rx_discard_cnt),
8711 tlen);
8712
8713 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8714 (tANI_U8) sizeof (pStats->rx_error_cnt),
8715 (char*) &(pStats->rx_error_cnt),
8716 tlen);
8717
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008718 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008719 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008720 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 tlen);
8722
8723 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8724 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8725 (char*) &(dStats->rx_byte_cnt),
8726 tlen);
8727
8728 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8729 (tANI_U8) sizeof (dStats->rx_rate),
8730 (char*) &(dStats->rx_rate),
8731 tlen);
8732
8733 /* Transmit rate, in units of 500 kbit/sec */
8734 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8735 (tANI_U8) sizeof (aStats->tx_rate),
8736 (char*) &(aStats->tx_rate),
8737 tlen);
8738
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008739 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8740 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8741 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008742 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008743 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8744 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8745 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008746 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008747 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8748 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8749 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008750 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008751 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8752 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8753 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008754 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008755 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8756 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8757 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008758 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008759 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8760 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8761 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008762 tlen);
8763
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 wrqu->data.length = tlen;
8765
8766 }
8767
8768 EXIT();
8769
8770 return 0;
8771}
8772
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308773static int iw_get_statistics(struct net_device *dev,
8774 struct iw_request_info *info,
8775 union iwreq_data *wrqu, char *extra)
8776{
8777 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008778
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308779 vos_ssr_protect(__func__);
8780 ret = __iw_get_statistics(dev, info, wrqu, extra);
8781 vos_ssr_unprotect(__func__);
8782
8783 return ret;
8784}
Jeff Johnson295189b2012-06-20 16:38:30 -07008785#ifdef FEATURE_WLAN_SCAN_PNO
8786
8787/*Max Len for PNO notification*/
8788#define MAX_PNO_NOTIFY_LEN 100
8789void found_pref_network_cb (void *callbackContext,
8790 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8791{
8792 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8793 union iwreq_data wrqu;
8794 char buf[MAX_PNO_NOTIFY_LEN+1];
8795
8796 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8797 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8798
8799 // create the event
8800 memset(&wrqu, 0, sizeof(wrqu));
8801 memset(buf, 0, sizeof(buf));
8802
8803 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8804 pPrefNetworkFoundInd->ssId.ssId,
8805 (unsigned int)pPrefNetworkFoundInd->rssi);
8806
8807 wrqu.data.pointer = buf;
8808 wrqu.data.length = strlen(buf);
8809
8810 // send the event
8811
8812 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8813
8814}
8815
8816
8817/*string based input*/
8818VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8819 union iwreq_data *wrqu, char *extra, int nOffset)
8820{
8821 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308822 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008823 /* pnoRequest is a large struct, so we make it static to avoid stack
8824 overflow. This API is only invoked via ioctl, so it is
8825 serialized by the kernel rtnl_lock and hence does not need to be
8826 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308827 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008828 char *ptr;
8829 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308830 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8832
8833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8834 "PNO data len %d data %s",
8835 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008836 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008837
8838 if (wrqu->data.length <= nOffset )
8839 {
8840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8841 return VOS_STATUS_E_FAILURE;
8842 }
8843
8844 pnoRequest.enable = 0;
8845 pnoRequest.ucNetworksCount = 0;
8846 /*-----------------------------------------------------------------------
8847 Input is string based and expected to be like this:
8848
8849 <enabled> <netw_count>
8850 for each network:
8851 <ssid_len> <ssid> <authentication> <encryption>
8852 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8853 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8854
8855 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008856 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 -07008857
8858 this translates into:
8859 -----------------------------
8860 enable PNO
8861 look for 2 networks:
8862 test - with authentication type 0 and encryption type 0,
8863 that can be found on 3 channels: 1 6 and 11 ,
8864 SSID bcast type is unknown (directed probe will be sent if AP not found)
8865 and must meet -40dBm RSSI
8866
8867 test2 - with auth and enrytption type 4/4
8868 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
8869 bcast type is non-bcast (directed probe will be sent)
8870 and must not meet any RSSI threshold
8871
Jeff Johnson8301aa12013-03-28 14:27:29 -07008872 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08008874 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008875
Wilson Yang623f6592013-10-08 16:33:37 -07008876 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
8877 {
8878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8879 "PNO enable input is not valid %s",ptr);
8880 return VOS_STATUS_E_FAILURE;
8881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008882
8883 if ( 0 == pnoRequest.enable )
8884 {
8885 /*Disable PNO*/
8886 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05308887 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8888 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008889 pAdapter->sessionId,
8890 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308891 if (eHAL_STATUS_SUCCESS != status)
8892 {
8893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8894 "%s: failed to disable PNO", __func__);
8895 return VOS_STATUS_E_FAILURE;
8896 }
8897 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008898 return VOS_STATUS_SUCCESS;
8899 }
8900
c_hpothu37f21312014-04-09 21:49:54 +05308901 if (TRUE == pHddCtx->isPnoEnable)
8902 {
8903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8904 FL("already PNO is enabled"));
8905 return -EBUSY;
8906 }
8907 pHddCtx->isPnoEnable = TRUE;
8908
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07008910
8911 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
8912 {
8913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8914 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308915 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008917
8918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8919 "PNO enable %d networks count %d offset %d",
8920 pnoRequest.enable,
8921 pnoRequest.ucNetworksCount,
8922 nOffset);
8923
8924 /* Parameters checking:
8925 ucNetworksCount has to be larger than 0*/
8926 if (( 0 == pnoRequest.ucNetworksCount ) ||
8927 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8928 {
8929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05308930 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008931 }
8932
8933 ptr += nOffset;
8934
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308935 pnoRequest.aNetworks =
8936 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8937 if (pnoRequest.aNetworks == NULL)
8938 {
8939 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8940 FL("failed to allocate memory aNetworks %u"),
8941 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8942 goto error;
8943 }
8944 vos_mem_zero(pnoRequest.aNetworks,
8945 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8946
Jeff Johnson295189b2012-06-20 16:38:30 -07008947 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
8948 {
8949
8950 pnoRequest.aNetworks[i].ssId.length = 0;
8951
Wilson Yang623f6592013-10-08 16:33:37 -07008952 ucParams = sscanf(ptr,"%hhu %n",
8953 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
8954
8955 if (1 != ucParams)
8956 {
8957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8958 "PNO ssid length input is not valid %s",ptr);
8959 return VOS_STATUS_E_FAILURE;
8960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008961
8962 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
8963 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
8964 {
8965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8966 "SSID Len %d is not correct for network %d",
8967 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05308968 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008969 }
8970
8971 /*Advance to SSID*/
8972 ptr += nOffset;
8973
Jeff Johnson8301aa12013-03-28 14:27:29 -07008974 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08008975 pnoRequest.aNetworks[i].ssId.length);
8976 ptr += pnoRequest.aNetworks[i].ssId.length;
8977
Jeff Johnson02797792013-10-26 19:17:13 -07008978 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08008979 &(pnoRequest.aNetworks[i].authentication),
8980 &(pnoRequest.aNetworks[i].encryption),
8981 &(pnoRequest.aNetworks[i].ucChannelCount),
8982 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008983
Wilson Yang623f6592013-10-08 16:33:37 -07008984 if ( 3 != ucParams )
8985 {
8986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8987 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308988 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008989 }
8990
Jeff Johnson295189b2012-06-20 16:38:30 -07008991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008992 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08008993 "auth %d encry %d channel count %d offset %d",
8994 pnoRequest.aNetworks[i].ssId.length,
8995 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
8996 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
8997 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
8998 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
8999 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
9000 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
9001 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
9002 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
9003 pnoRequest.aNetworks[i].authentication,
9004 pnoRequest.aNetworks[i].encryption,
9005 pnoRequest.aNetworks[i].ucChannelCount,
9006 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07009007
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 /*Advance to channel list*/
9009 ptr += nOffset;
9010
Wilson Yang623f6592013-10-08 16:33:37 -07009011 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07009012 {
9013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9014 "Incorrect number of channels");
9015 return VOS_STATUS_E_FAILURE;
9016 }
9017
9018 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9019 {
9020 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9021 {
Wilson Yang623f6592013-10-08 16:33:37 -07009022 if (1 != sscanf(ptr,"%hhu %n",
9023 &(pnoRequest.aNetworks[i].aChannels[j]),
9024 &nOffset))
9025 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9026 "PNO network channel input is not valid %s",ptr);
9027 return VOS_STATUS_E_FAILURE;
9028 }
9029 /*Advance to next channel number*/
9030 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009031 }
9032 }
9033
Jeff Johnson02797792013-10-26 19:17:13 -07009034 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009035 &(pnoRequest.aNetworks[i].bcastNetwType),
9036 &nOffset))
9037 {
9038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9039 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309040 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009042
9043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9044 "PNO bcastNetwType %d offset %d",
9045 pnoRequest.aNetworks[i].bcastNetwType,
9046 nOffset );
9047
9048 /*Advance to rssi Threshold*/
9049 ptr += nOffset;
9050
Wilson Yang623f6592013-10-08 16:33:37 -07009051 if (1 != sscanf(ptr,"%hhu %n",
9052 &(pnoRequest.aNetworks[i].rssiThreshold),
9053 &nOffset))
9054 {
9055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9056 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309057 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009059
9060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9061 "PNO rssi %d offset %d",
9062 pnoRequest.aNetworks[i].rssiThreshold,
9063 nOffset );
9064 /*Advance to next network*/
9065 ptr += nOffset;
9066 }/*For ucNetworkCount*/
9067
9068 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009069 &(pnoRequest.scanTimers.ucScanTimersCount),
9070 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009071
9072 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009073 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 {
9075 ptr += nOffset;
9076
Jeff Johnson8301aa12013-03-28 14:27:29 -07009077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9078 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009079 pnoRequest.scanTimers.ucScanTimersCount,
9080 nOffset );
9081
9082 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9083 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009085 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309086 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 }
9088
9089 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9090 {
Jeff Johnson02797792013-10-26 19:17:13 -07009091 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9093 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9094 &nOffset);
9095
Wilson Yang623f6592013-10-08 16:33:37 -07009096 if (2 != ucParams)
9097 {
9098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9099 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309100 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009101 }
9102
Jeff Johnson8301aa12013-03-28 14:27:29 -07009103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9104 "PNO Timer value %d Timer repeat %d offset %d",
9105 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009106 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9107 nOffset );
9108
Jeff Johnson295189b2012-06-20 16:38:30 -07009109 ptr += nOffset;
9110 }
9111
9112 }
9113 else
9114 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9116 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009117 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9118
9119 /*Scan timers defaults to 5 minutes*/
9120 pnoRequest.scanTimers.ucScanTimersCount = 1;
9121 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9122 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9123 }
9124
Wilson Yang623f6592013-10-08 16:33:37 -07009125 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009126
9127 pnoRequest.modePNO = ucMode;
9128 /*for LA we just expose suspend option*/
9129 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9130 {
9131 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9132 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309133 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9134 if (pnoRequest.p24GProbeTemplate == NULL){
9135 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9136 FL("failed to allocate memory p24GProbeTemplate %u"),
9137 SIR_PNO_MAX_PB_REQ_SIZE);
9138 goto error;
9139 }
9140
9141 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9142 if (pnoRequest.p5GProbeTemplate == NULL){
9143 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9144 FL("failed to allocate memory p5GProbeTemplate %u"),
9145 SIR_PNO_MAX_PB_REQ_SIZE);
9146 goto error;
9147 }
9148
9149 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9150 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009151
c_hpothu37f21312014-04-09 21:49:54 +05309152 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 pAdapter->sessionId,
9154 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309155 if (eHAL_STATUS_SUCCESS == status)
9156 {
9157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9158 "%s: PNO enabled", __func__);
9159 return VOS_STATUS_SUCCESS;
9160 }
9161error:
9162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9163 "%s: Failed to enable PNO", __func__);
9164 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309165 if (pnoRequest.aNetworks)
9166 vos_mem_free(pnoRequest.aNetworks);
9167 if (pnoRequest.p24GProbeTemplate)
9168 vos_mem_free(pnoRequest.p24GProbeTemplate);
9169 if (pnoRequest.p5GProbeTemplate)
9170 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309171 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009172}/*iw_set_pno*/
9173
9174VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9175 union iwreq_data *wrqu, char *extra, int nOffset)
9176{
9177 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9178 v_U8_t rssiThreshold = 0;
9179 v_U8_t nRead;
9180
Arif Hussain7adce1b2013-11-11 22:59:34 -08009181 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009182 &rssiThreshold);
9183
9184 if ( 1 != nRead )
9185 {
9186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9187 "Incorrect format");
9188 return VOS_STATUS_E_FAILURE;
9189 }
9190
9191 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9192 return VOS_STATUS_SUCCESS;
9193}
9194
9195
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309196static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009197 struct iw_request_info *info,
9198 union iwreq_data *wrqu, char *extra)
9199{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309200 hdd_adapter_t *pAdapter;
9201 hdd_context_t *pHddCtx;
9202 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309203 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309204
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309205 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309206 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9207 if (NULL == pAdapter)
9208 {
9209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9210 "%s: Adapter is NULL",__func__);
9211 return -EINVAL;
9212 }
9213
9214 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9215 ret = wlan_hdd_validate_context(pHddCtx);
9216 if (0 != ret)
9217 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309218 return ret;
9219 }
9220
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009221
9222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009224
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309225 status = iw_set_pno(dev,info,wrqu,extra,0);
9226
9227 EXIT();
9228 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009229}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309230
9231static int iw_set_pno_priv(struct net_device *dev,
9232 struct iw_request_info *info,
9233 union iwreq_data *wrqu, char *extra)
9234{
9235 int ret;
9236
9237 vos_ssr_protect(__func__);
9238 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9239 vos_ssr_unprotect(__func__);
9240
9241 return ret;
9242}
Jeff Johnson295189b2012-06-20 16:38:30 -07009243#endif /*FEATURE_WLAN_SCAN_PNO*/
9244
9245//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309246int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009247{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309248 hdd_adapter_t *pAdapter;
9249 tHalHandle hHal;
9250 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309251 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309252 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309253 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309255 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309256 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309257 tpAniSirGlobal pMac;
9258 int retval = 0;
9259
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309260 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309261 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9262 if (NULL == pAdapter)
9263 {
9264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9265 "%s: Adapter is NULL",__func__);
9266 return -EINVAL;
9267 }
9268 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9269 retval = wlan_hdd_validate_context(pHddCtx);
9270 if (0 != retval)
9271 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309272 return retval;
9273 }
9274 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9275 if (NULL == hHal)
9276 {
9277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9278 "%s: Hal Context is NULL",__func__);
9279 return -EINVAL;
9280 }
9281 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009282
Atul Mittal54378cb2014-04-02 16:51:50 +05309283 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 {
9285 case WLAN_HDD_UI_BAND_AUTO:
9286 band = eCSR_BAND_ALL;
9287 break;
9288 case WLAN_HDD_UI_BAND_5_GHZ:
9289 band = eCSR_BAND_5G;
9290 break;
9291 case WLAN_HDD_UI_BAND_2_4_GHZ:
9292 band = eCSR_BAND_24;
9293 break;
9294 default:
9295 band = eCSR_BAND_MAX;
9296 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309297 connectedBand =
9298 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009299
Atul Mittal54378cb2014-04-02 16:51:50 +05309300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009301 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009302
9303 if (band == eCSR_BAND_MAX)
9304 {
9305 /* Received change band request with invalid band value */
9306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309307 "%s: Invalid band value %u", __func__, ui_band);
9308 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 }
9310
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309311 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309312 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309313 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009315 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009316 band, pHddCtx->cfg_ini->nBandCapability);
9317 return -EIO;
9318 }
9319
Sushant Kaushik1165f872015-03-30 20:25:27 +05309320 if (band == eCSR_BAND_ALL)
9321 {
9322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9323 "received. Setting band same as ini value %d"),
9324 pHddCtx->cfg_ini->nBandCapability);
9325 band = pHddCtx->cfg_ini->nBandCapability;
9326 }
9327
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9329 {
9330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9331 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009332 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 return -EIO;
9334 }
9335
9336 if (currBand != band)
9337 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309338 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309339 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309340 /* Return failure if current country code is world regulatory domain*/
9341 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9342 pMac->scan.countryCodeCurrent[1] == '0') )
9343 {
9344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9345 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309346 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309347 return -EAGAIN;
9348 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309349 }
9350
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 /* Change band request received.
9352 * Abort pending scan requests, flush the existing scan results,
9353 * and change the band capability
9354 */
9355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9356 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009357 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009358
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309359 /* We need to change the band and flush the scan results here itself
9360 * as we may get timeout for disconnection in which we will return
9361 * with out doing any of these
9362 */
9363 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9364 {
9365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9366 "%s: failed to set the band value to %u ",
9367 __func__, band);
9368 return -EINVAL;
9369 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309370 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9371 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309372 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309373 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9374 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309375 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309376 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9377 * information available in NV so to get the channel information from kernel
9378 * we need to send regulatory hint for the currunt country
9379 * And to set the same country again we need to set the dummy country
9380 * first and then the actual country.
9381 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309382#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9383 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9384#else
9385 regulatory_hint_user("00");
9386#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309387 wait_result = wait_for_completion_interruptible_timeout(
9388 &pHddCtx->linux_reg_req,
9389 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9390
9391 /* if the country information does not exist with the kernel,
9392 then the driver callback would not be called */
9393
9394 if (wait_result >= 0)
9395 {
9396 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9397 "runtime country code is found in kernel db");
9398 }
9399 else
9400 {
9401 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9402 "runtime country code is not found"
9403 " in kernel db");
9404 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309405
9406 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309407
9408 /*
9409 * Update 11dcountry and current country here as the hint
9410 * with 00 results in 11d and current country with 00
9411 */
9412 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9413 WNI_CFG_COUNTRY_CODE_LEN);
9414 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9415 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309416#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9417 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9418#else
9419 regulatory_hint_user(curr_country);
9420#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309421 wait_result = wait_for_completion_interruptible_timeout(
9422 &pHddCtx->linux_reg_req,
9423 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9424
9425 /* if the country information does not exist with the kernel,
9426 then the driver callback would not be called */
9427 if (wait_result >= 0)
9428 {
9429 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9430 "runtime country code is found in kernel db");
9431 }
9432 else
9433 {
9434 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9435 "runtime country code is not found"
9436 " in kernel db");
9437 }
9438
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309439 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
9440 }
9441 else
9442 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309443#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309444 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9445 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309446#else
9447 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9448#endif
9449
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309450 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309451 pScanInfo = &pHddCtx->scan_info;
9452 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9453 {
9454 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9455 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9456 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309457 sme_FilterScanResults(hHal, pAdapter->sessionId);
9458
9459 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309460 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9461 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009462 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 eHalStatus status = eHAL_STATUS_SUCCESS;
9464 long lrc;
9465
9466 /* STA already connected on current band, So issue disconnect first,
9467 * then change the band*/
9468
9469 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309470 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309471 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009472
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9474
9475 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9476 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9477
Jeff Johnson43971f52012-07-17 12:26:56 -07009478 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009479 {
9480 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009481 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009482 __func__, (int)status );
9483 return -EINVAL;
9484 }
9485
9486 lrc = wait_for_completion_interruptible_timeout(
9487 &pAdapter->disconnect_comp_var,
9488 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9489
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309490 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009491
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009492 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009493 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009494
9495 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9496 }
9497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009498 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309499 EXIT();
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309500 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009501}
9502
Atul Mittal54378cb2014-04-02 16:51:50 +05309503int hdd_setBand_helper(struct net_device *dev, const char *command)
9504{
9505 u8 band;
9506
9507 /*convert the band value from ascii to integer*/
9508 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9509
9510 return hdd_setBand(dev, band);
9511
9512}
9513
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309514static int __iw_set_band_config(struct net_device *dev,
9515 struct iw_request_info *info,
9516 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009517{
Atul Mittal54378cb2014-04-02 16:51:50 +05309518 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009519
Arif Hussain0273cba2014-01-07 20:58:29 -08009520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009521
Atul Mittal54378cb2014-04-02 16:51:50 +05309522 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009523}
9524
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309525static int iw_set_band_config(struct net_device *dev,
9526 struct iw_request_info *info,
9527 union iwreq_data *wrqu, char *extra)
9528{
9529 int ret;
9530
9531 vos_ssr_protect(__func__);
9532 ret = __iw_set_band_config(dev, info, wrqu, extra);
9533 vos_ssr_unprotect(__func__);
9534
9535 return ret;
9536}
9537
9538static int __iw_set_power_params_priv(struct net_device *dev,
9539 struct iw_request_info *info,
9540 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009541{
Arif Hussain0273cba2014-01-07 20:58:29 -08009542 int ret;
9543 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9545 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009546 /* ODD number is used for set, copy data using copy_from_user */
9547 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9548 wrqu->data.length);
9549 if (NULL == ptr)
9550 {
9551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9552 "mem_alloc_copy_from_user_helper fail");
9553 return -ENOMEM;
9554 }
9555
9556 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9557 kfree(ptr);
9558 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009559}
9560
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309561static int iw_set_power_params_priv(struct net_device *dev,
9562 struct iw_request_info *info,
9563 union iwreq_data *wrqu, char *extra)
9564{
9565 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009566
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309567 vos_ssr_protect(__func__);
9568 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9569 vos_ssr_unprotect(__func__);
9570
9571 return ret;
9572}
Jeff Johnson295189b2012-06-20 16:38:30 -07009573
9574/*string based input*/
9575VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9576 union iwreq_data *wrqu, char *extra, int nOffset)
9577{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309578 hdd_adapter_t *pAdapter;
9579 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009580 tSirSetPowerParamsReq powerRequest;
9581 char *ptr;
9582 v_U8_t ucType;
9583 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309584 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009585
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309586 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309587 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9588 if (NULL == pAdapter)
9589 {
9590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9591 "%s: Adapter is NULL",__func__);
9592 return -EINVAL;
9593 }
9594
9595 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9596 ret = wlan_hdd_validate_context(pHddCtx);
9597 if (0 != ret)
9598 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309599 return ret;
9600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9602 "Power Params data len %d data %s",
9603 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009604 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009605
9606 if (wrqu->data.length <= nOffset )
9607 {
9608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9609 return VOS_STATUS_E_FAILURE;
9610 }
9611
9612 uTotalSize = wrqu->data.length - nOffset;
9613
9614 /*-----------------------------------------------------------------------
9615 Input is string based and expected to be like this:
9616
9617 <param_type> <param_value> <param_type> <param_value> ...
9618
9619 e.g:
9620 1 2 2 3 3 0 4 1 5 1
9621
9622 e.g. setting just a few:
9623 1 2 4 1
9624
9625 parameter types:
9626 -----------------------------
9627 1 - Ignore DTIM
9628 2 - Listen Interval
9629 3 - Broadcast Multicas Filter
9630 4 - Beacon Early Termination
9631 5 - Beacon Early Termination Interval
9632 -----------------------------------------------------------------------*/
9633 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9634 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9635 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9636 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9637 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9638
Arif Hussain7adce1b2013-11-11 22:59:34 -08009639 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009640
9641 while ( uTotalSize )
9642 {
Wilson Yang6f971452013-10-08 15:00:00 -07009643 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9644 {
9645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9646 "Invalid input parameter type %s",ptr);
9647 return VOS_STATUS_E_FAILURE;
9648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009649
9650 uTotalSize -= nOffset;
9651
9652 if (!uTotalSize)
9653 {
9654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009655 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009656 ucType, nOffset);
9657 return VOS_STATUS_E_FAILURE;
9658 }
9659
9660 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009661
Jeff Johnson02797792013-10-26 19:17:13 -07009662 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009663 {
9664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9665 "Invalid input parameter value %s",ptr);
9666 return VOS_STATUS_E_FAILURE;
9667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009668
9669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9670 "Power request parameter %d value %d offset %d",
9671 ucType, uValue, nOffset);
9672
9673 switch (ucType)
9674 {
9675 case eSIR_IGNORE_DTIM:
9676 powerRequest.uIgnoreDTIM = uValue;
9677 break;
9678 case eSIR_LISTEN_INTERVAL:
9679 powerRequest.uListenInterval = uValue;
9680 break;
9681 case eSIR_MCAST_BCAST_FILTER:
9682 powerRequest.uBcastMcastFilter = uValue;
9683 break;
9684 case eSIR_ENABLE_BET:
9685 powerRequest.uEnableBET = uValue;
9686 break;
9687 case eSIR_BET_INTERVAL:
9688 powerRequest.uBETInterval = uValue;
9689 break;
9690 default:
9691 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009692 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 ucType, uValue, nOffset);
9694 return VOS_STATUS_E_FAILURE;
9695 }
9696
9697 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9699 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009700 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009702 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009703 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009704 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9705 {
9706 uTotalSize = 0;
9707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009708
9709 }/*Go for as long as we have a valid string*/
9710
9711 /* put the device into full power*/
9712 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9713
9714 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009715 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009716
9717 /* put the device back to power save*/
9718 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9719
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309720 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 return VOS_STATUS_SUCCESS;
9722}/*iw_set_power_params*/
9723
Atul Mittalc0f739f2014-07-31 13:47:47 +05309724// tdlsoffchan
9725#ifdef FEATURE_WLAN_TDLS
9726
Atul Mittal87ec2422014-09-24 13:12:50 +05309727int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309728{
9729 if (offchannel < 0 || offchannel > 165)
9730 {
9731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9732 __func__, offchannel);
9733 return -1;
9734
9735 }
9736
9737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9738 __func__, tdlsOffCh, offchannel);
9739
9740 tdlsOffCh = offchannel;
9741 return 0;
9742}
9743
Atul Mittal87ec2422014-09-24 13:12:50 +05309744int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309745{
9746 if (offchanoffset == 0)
9747 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309748 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9750 __func__, tdlsOffChBwOffset);
9751
9752 return 0;
9753
9754 }
9755
9756 if ( offchanoffset == 40 )
9757 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309758 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9760 __func__, tdlsOffChBwOffset);
9761
9762 return 0;
9763
9764 }
9765 if (offchanoffset == -40)
9766 {
9767 tdlsOffChBwOffset = 3;
9768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9769 __func__, tdlsOffChBwOffset);
9770
9771 return 0;
9772
9773 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +05309774
9775 if ((offchanoffset == 80) &&
9776 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
9777 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
9778 {
9779 tdlsOffChBwOffset = 4;
9780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9781 "%s: change tdls secondary off channel offset to %u",
9782 __func__, tdlsOffChBwOffset);
9783
9784 return 0;
9785 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05309786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9787 __func__, offchanoffset);
9788 return -1;
9789}
9790
Atul Mittal87ec2422014-09-24 13:12:50 +05309791int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309792{
9793 hddTdlsPeer_t *connPeer = NULL;
9794 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9795 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9796
9797 if (offchanmode < 0 || offchanmode > 4)
9798 {
9799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9800 "%s: Invalid tdls off channel mode %d",
9801 __func__, offchanmode);
9802 return -1;
9803 }
9804
9805 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9806 {
9807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9808 "%s: tdls off channel mode req in not associated state %d",
9809 __func__, offchanmode);
9810 return -1;
9811 }
9812
9813 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9814 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9815 {
9816 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309817 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309818 if (NULL == connPeer) {
9819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9820 "%s: No TDLS Connected Peer", __func__);
9821 return -1;
9822 }
9823 }
9824 else
9825 {
9826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9827 "%s: TDLS Connection not supported", __func__);
9828 return -1;
9829 }
9830
9831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9832 ("%s: TDLS Channel Switch in swmode=%d"),
9833 __func__, offchanmode);
9834
9835 switch (offchanmode)
9836 {
9837 case 1:/*Enable*/
9838 case 2:/*Disable*/
9839 {
9840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9841 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9842 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9843 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9844 {
9845
9846 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9847 pAdapter->sessionId, connPeer->peerMac,
9848 tdlsOffCh, tdlsOffChBwOffset,
9849 offchanmode);
9850 }
9851 else
9852 {
9853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9854 "%s: TDLS Off Channel not supported", __func__);
9855 return -1;
9856 }
9857 break;
9858 }
9859 case 3:
9860 {
9861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9862 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
9863 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9864
9865 break;
9866 }
9867 case 4:
9868 {
9869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9870 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
9871 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9872 break;
9873 }
9874 default:
9875 {
9876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9877 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
9878 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9879 break;
9880 }
9881
9882 }
9883
9884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
9885 __func__, offchanmode);
9886 return 0;
9887}
Atul Mittalc0f739f2014-07-31 13:47:47 +05309888#endif
9889
Jeff Johnson295189b2012-06-20 16:38:30 -07009890
9891// Define the Wireless Extensions to the Linux Network Device structure
9892// A number of these routines are NULL (meaning they are not implemented.)
9893
9894static const iw_handler we_handler[] =
9895{
9896 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9897 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9898 (iw_handler) NULL, /* SIOCSIWNWID */
9899 (iw_handler) NULL, /* SIOCGIWNWID */
9900 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9901 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9902 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9903 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9904 (iw_handler) NULL, /* SIOCSIWSENS */
9905 (iw_handler) NULL, /* SIOCGIWSENS */
9906 (iw_handler) NULL, /* SIOCSIWRANGE */
9907 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9908 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
9909 (iw_handler) NULL, /* SIOCGIWPRIV */
9910 (iw_handler) NULL, /* SIOCSIWSTATS */
9911 (iw_handler) NULL, /* SIOCGIWSTATS */
9912 iw_handler_set_spy, /* SIOCSIWSPY */
9913 iw_handler_get_spy, /* SIOCGIWSPY */
9914 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
9915 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
9916 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9917 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9918 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9919 (iw_handler) NULL, /* SIOCGIWAPLIST */
9920 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9921 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9922 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9923 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9924 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9925 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9926 (iw_handler) NULL, /* -- hole -- */
9927 (iw_handler) NULL, /* -- hole -- */
9928 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9929 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9930 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
9931 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
9932 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9933 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9934 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9935 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9936 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9937 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9938 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9939 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9940 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9941 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9942 (iw_handler) NULL, /* -- hole -- */
9943 (iw_handler) NULL, /* -- hole -- */
9944 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9945 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9946 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9947 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9948 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9949 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9950 (iw_handler) NULL, /* SIOCSIWPMKSA */
9951};
9952
9953static const iw_handler we_private[] = {
9954
9955 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
9956 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
9957 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
9958 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
9959 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9960 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +05309961 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9963 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9964 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07009965#ifdef FEATURE_OEM_DATA_SUPPORT
9966 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
9967 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
9968#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009969
Jeff Johnson295189b2012-06-20 16:38:30 -07009970#ifdef WLAN_FEATURE_VOWIFI_11R
9971 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
9972#endif
9973 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9974 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9975 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
9976#ifdef WLAN_FEATURE_PACKET_FILTERING
9977 ,
9978 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
9979#endif
9980#ifdef FEATURE_WLAN_SCAN_PNO
9981 ,
9982 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
9983#endif
9984 ,
9985 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9986 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
9987 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
9988 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07009989 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07009990};
9991
9992/*Maximum command length can be only 15 */
9993static const struct iw_priv_args we_private_args[] = {
9994
9995 /* handlers for main ioctl */
9996 { WLAN_PRIV_SET_INT_GET_NONE,
9997 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9998 0,
9999 "" },
10000
10001 /* handlers for sub-ioctl */
10002 { WE_SET_11D_STATE,
10003 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10004 0,
10005 "set11Dstate" },
10006
10007 { WE_WOWL,
10008 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10009 0,
10010 "wowl" },
10011
10012 { WE_SET_POWER,
10013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10014 0,
10015 "setPower" },
10016
10017 { WE_SET_MAX_ASSOC,
10018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10019 0,
10020 "setMaxAssoc" },
10021
10022 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10024 0,
10025 "setAutoChannel" },
10026
10027 { WE_SET_DATA_INACTIVITY_TO,
10028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10029 0,
10030 "inactivityTO" },
10031
10032 { WE_SET_MAX_TX_POWER,
10033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10034 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010035 "setMaxTxPower" },
10036
10037 { WE_SET_MAX_TX_POWER_2_4,
10038 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10039 0,
10040 "setTxMaxPower2G" },
10041
10042 { WE_SET_MAX_TX_POWER_5_0,
10043 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10044 0,
10045 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010046
10047 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10048 * as well to keep same syntax as in SAP. Now onwards, STA
10049 * will support both */
10050 { WE_SET_MAX_TX_POWER,
10051 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10052 0,
10053 "setTxMaxPower" },
10054
Jeff Johnson295189b2012-06-20 16:38:30 -070010055 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10056 * 1 = enable and 0 = disable */
10057 {
10058 WE_SET_HIGHER_DTIM_TRANSITION,
10059 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10060 0,
10061 "setHDtimTransn" },
10062
10063 { WE_SET_TM_LEVEL,
10064 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010065 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010066 "setTmLevel" },
10067
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010068 { WE_ENABLE_STRICT_FCC_REG,
10069 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10070 0,
10071 "setStrictFCCreg" },
10072
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010073 { WE_SET_DEBUG_LOG,
10074 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10075 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010076#ifdef FEATURE_WLAN_TDLS
10077 {
10078 WE_SET_TDLS_OFF_CHAN,
10079 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10080 0,
10081 "tdlsoffchan" },
10082 {
10083 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10084 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10085 0,
10086 "tdlsecchnoffst" },
10087 {
10088 WE_SET_TDLS_OFF_CHAN_MODE,
10089 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10090 0,
10091 "tdlsoffchnmode" },
10092#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010093
Peng Xu2446a892014-09-05 17:21:18 +053010094 { WE_SET_SCAN_BAND_PREFERENCE,
10095 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10096 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010097 {
10098 WE_GET_FRAME_LOG,
10099 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10100 0,
10101 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010102
Abhishek Singh01c73d12015-03-12 15:13:44 +053010103 { WE_SET_MIRACAST_VENDOR_CONFIG,
10104 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10105 0, "setMiracstConf" },
10106
Pradeep Reddy POTTETI31505892015-04-16 16:47:54 +053010107#ifdef FEATURE_WLAN_TDLS
10108 {
10109 WE_SET_TDLS_2040_BSS_COEXISTENCE,
10110 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10111 0,
10112 "tdls_2040bsscox" },
10113#endif
10114
Jeff Johnson295189b2012-06-20 16:38:30 -070010115 /* handlers for main ioctl */
10116 { WLAN_PRIV_SET_NONE_GET_INT,
10117 0,
10118 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10119 "" },
10120
10121 /* handlers for sub-ioctl */
10122 { WE_GET_11D_STATE,
10123 0,
10124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10125 "get11Dstate" },
10126
10127 { WE_IBSS_STATUS,
10128 0,
10129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10130 "getAdhocStatus" },
10131
10132 { WE_PMC_STATE,
10133 0,
10134 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10135 "pmcState" },
10136
10137 { WE_GET_WLAN_DBG,
10138 0,
10139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10140 "getwlandbg" },
10141
Jeff Johnson295189b2012-06-20 16:38:30 -070010142 { WE_GET_MAX_ASSOC,
10143 0,
10144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10145 "getMaxAssoc" },
10146
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 { WE_GET_WDI_DBG,
10148 0,
10149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10150 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010151
10152 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10153 0,
10154 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10155 "getAutoChannel" },
10156
10157 { WE_GET_CONCURRENCY_MODE,
10158 0,
10159 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10160 "getconcurrency" },
10161
Peng Xu2446a892014-09-05 17:21:18 +053010162 { WE_GET_SCAN_BAND_PREFERENCE,
10163 0,
10164 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10165 "get_scan_pref"},
10166
Jeff Johnson295189b2012-06-20 16:38:30 -070010167 /* handlers for main ioctl */
10168 { WLAN_PRIV_SET_CHAR_GET_NONE,
10169 IW_PRIV_TYPE_CHAR| 512,
10170 0,
10171 "" },
10172
10173 /* handlers for sub-ioctl */
10174 { WE_WOWL_ADD_PTRN,
10175 IW_PRIV_TYPE_CHAR| 512,
10176 0,
10177 "wowlAddPtrn" },
10178
10179 { WE_WOWL_DEL_PTRN,
10180 IW_PRIV_TYPE_CHAR| 512,
10181 0,
10182 "wowlDelPtrn" },
10183
10184#if defined WLAN_FEATURE_VOWIFI
10185 /* handlers for sub-ioctl */
10186 { WE_NEIGHBOR_REPORT_REQUEST,
10187 IW_PRIV_TYPE_CHAR | 512,
10188 0,
10189 "neighbor" },
10190#endif
10191 { WE_SET_AP_WPS_IE,
10192 IW_PRIV_TYPE_CHAR| 512,
10193 0,
10194 "set_ap_wps_ie" },
10195
10196 { WE_SET_CONFIG,
10197 IW_PRIV_TYPE_CHAR| 512,
10198 0,
10199 "setConfig" },
10200
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010201 { WE_SET_ENCRYPT_MSG,
10202 IW_PRIV_TYPE_CHAR| 512,
10203 0,
10204 "encryptMsg" },
10205
10206
Jeff Johnson295189b2012-06-20 16:38:30 -070010207 /* handlers for main ioctl */
10208 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10209 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10210 0,
10211 "" },
10212
10213 /* handlers for sub-ioctl */
10214 { WE_SET_WLAN_DBG,
10215 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10216 0,
10217 "setwlandbg" },
10218
Jeff Johnson295189b2012-06-20 16:38:30 -070010219 { WE_SET_WDI_DBG,
10220 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10221 0,
10222 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010223
10224 { WE_SET_SAP_CHANNELS,
10225 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10226 0,
10227 "setsapchannels" },
10228
10229 /* handlers for main ioctl */
10230 { WLAN_PRIV_GET_CHAR_SET_NONE,
10231 0,
10232 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10233 "" },
10234
10235 /* handlers for sub-ioctl */
10236 { WE_WLAN_VERSION,
10237 0,
10238 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10239 "version" },
10240 { WE_GET_STATS,
10241 0,
10242 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10243 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010244 { WE_GET_STATES,
10245 0,
10246 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10247 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010248 { WE_GET_CFG,
10249 0,
10250 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10251 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010252#ifdef WLAN_FEATURE_11AC
10253 { WE_GET_RSSI,
10254 0,
10255 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10256 "getRSSI" },
10257#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010258#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010259 { WE_GET_ROAM_RSSI,
10260 0,
10261 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10262 "getRoamRSSI" },
10263#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010264 { WE_GET_WMM_STATUS,
10265 0,
10266 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10267 "getWmmStatus" },
10268 {
10269 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010270 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010271 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10272 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010273#ifdef FEATURE_WLAN_TDLS
10274 {
10275 WE_GET_TDLS_PEERS,
10276 0,
10277 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10278 "getTdlsPeers" },
10279#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010280#ifdef WLAN_FEATURE_11W
10281 {
10282 WE_GET_11W_INFO,
10283 0,
10284 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10285 "getPMFInfo" },
10286#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010287 { WE_GET_SNR,
10288 0,
10289 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10290 "getSNR" },
10291
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 /* handlers for main ioctl */
10293 { WLAN_PRIV_SET_NONE_GET_NONE,
10294 0,
10295 0,
10296 "" },
10297
10298 /* handlers for sub-ioctl */
10299 { WE_CLEAR_STATS,
10300 0,
10301 0,
10302 "clearStats" },
10303 { WE_INIT_AP,
10304 0,
10305 0,
10306 "initAP" },
10307 { WE_STOP_AP,
10308 0,
10309 0,
10310 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010311#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010312 { WE_ENABLE_AMP,
10313 0,
10314 0,
10315 "enableAMP" },
10316 { WE_DISABLE_AMP,
10317 0,
10318 0,
10319 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010320#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010321 { WE_ENABLE_DXE_STALL_DETECT,
10322 0,
10323 0,
10324 "dxeStallDetect" },
10325 { WE_DISPLAY_DXE_SNAP_SHOT,
10326 0,
10327 0,
10328 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010329 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10330 0,
10331 0,
10332 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010333 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010334 WE_SET_REASSOC_TRIGGER,
10335 0,
10336 0,
10337 "reassoc" },
10338 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010339 WE_STOP_OBSS_SCAN,
10340 0,
10341 0,
10342 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010343 {
10344 WE_DUMP_ROAM_TIMER_LOG,
10345 0,
10346 0,
10347 "dumpRoamDelay" },
10348 {
10349 WE_RESET_ROAM_TIMER_LOG,
10350 0,
10351 0,
10352 "resetRoamDelay" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010353 /* handlers for main ioctl */
10354 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10355 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10356 0,
10357 "" },
10358
10359 /* handlers for sub-ioctl */
10360 { WE_LOG_DUMP_CMD,
10361 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10362 0,
10363 "dump" },
10364
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010365 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010366 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10367 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10368 0,
10369 "setdumplog" },
10370
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010371 { WE_MTRACE_DUMP_CMD,
10372 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10373 0,
10374 "dumplog" },
10375
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010376 /* handlers for sub ioctl */
10377 {
10378 WE_MCC_CONFIG_CREDENTIAL,
10379 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10380 0,
10381 "setMccCrdnl" },
10382
10383 /* handlers for sub ioctl */
10384 {
10385 WE_MCC_CONFIG_PARAMS,
10386 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10387 0,
10388 "setMccConfig" },
10389
Chilam NG571c65a2013-01-19 12:27:36 +053010390#ifdef FEATURE_WLAN_TDLS
10391 /* handlers for sub ioctl */
10392 {
10393 WE_TDLS_CONFIG_PARAMS,
10394 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10395 0,
10396 "setTdlsConfig" },
10397#endif
10398
Jeff Johnson295189b2012-06-20 16:38:30 -070010399 /* handlers for main ioctl */
10400 { WLAN_PRIV_ADD_TSPEC,
10401 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10403 "addTspec" },
10404
10405 /* handlers for main ioctl */
10406 { WLAN_PRIV_DEL_TSPEC,
10407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10408 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10409 "delTspec" },
10410
10411 /* handlers for main ioctl */
10412 { WLAN_PRIV_GET_TSPEC,
10413 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10414 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10415 "getTspec" },
10416
Jeff Johnsone7245742012-09-05 17:12:55 -070010417#ifdef FEATURE_OEM_DATA_SUPPORT
10418 /* handlers for main ioctl - OEM DATA */
10419 {
10420 WLAN_PRIV_SET_OEM_DATA_REQ,
10421 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10422 0,
10423 "set_oem_data_req" },
10424
10425 /* handlers for main ioctl - OEM DATA */
10426 {
10427 WLAN_PRIV_GET_OEM_DATA_RSP,
10428 0,
10429 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10430 "get_oem_data_rsp" },
10431#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010432
Jeff Johnson295189b2012-06-20 16:38:30 -070010433 /* handlers for main ioctl - host offload */
10434 {
10435 WLAN_PRIV_SET_HOST_OFFLOAD,
10436 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10437 0,
10438 "setHostOffload" },
10439
10440 {
10441 WLAN_GET_WLAN_STATISTICS,
10442 0,
10443 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10444 "getWlanStats" },
10445
10446 {
10447 WLAN_SET_KEEPALIVE_PARAMS,
10448 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10449 0,
10450 "setKeepAlive" },
10451#ifdef WLAN_FEATURE_PACKET_FILTERING
10452 {
10453 WLAN_SET_PACKET_FILTER_PARAMS,
10454 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10455 0,
10456 "setPktFilter" },
10457#endif
10458#ifdef FEATURE_WLAN_SCAN_PNO
10459 {
10460 WLAN_SET_PNO,
10461 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10462 0,
10463 "setpno" },
10464#endif
10465 {
10466 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010467 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010468 0,
10469 "SETBAND" },
10470 /* handlers for dynamic MC BC ioctl */
10471 {
10472 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010473 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010474 0,
10475 "setMCBCFilter" },
10476 {
10477 WLAN_PRIV_CLEAR_MCBC_FILTER,
10478 0,
10479 0,
10480 "clearMCBCFilter" },
10481 {
10482 WLAN_SET_POWER_PARAMS,
10483 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10484 0,
10485 "setpowerparams" },
10486 {
10487 WLAN_GET_LINK_SPEED,
10488 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010489 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010490};
10491
10492
10493
10494const struct iw_handler_def we_handler_def = {
10495 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10496 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10497 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10498
10499 .standard = (iw_handler *)we_handler,
10500 .private = (iw_handler *)we_private,
10501 .private_args = we_private_args,
10502 .get_wireless_stats = get_wireless_stats,
10503};
10504
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010505int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10506{
10507 v_U32_t cmd = 288; //Command to RIVA
10508 hdd_context_t *pHddCtx = NULL;
10509 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10510 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10511 /*
10512 *configMccParam : specify the bit which needs to be modified
10513 *allowed to update based on wlan_qcom_cfg.ini
10514 * configuration
10515 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10516 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10517 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10518 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10519 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10520 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10521 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10522 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10523 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10524 * Bit 9 : Reserved
10525 */
10526 switch (arg1)
10527 {
10528 //Update MCC SCHEDULE_TIME_SLICE parameter
10529 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10530 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10531 {
10532 if((arg2 >= 5) && (arg2 <= 20))
10533 {
10534 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10535 }
10536 else
10537 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010538 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010539 return 0;
10540 }
10541 }
10542 break;
10543
10544 //Update MCC MAX_NULL_SEND_TIME parameter
10545 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10546 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10547 {
10548 if((arg2 >= 1) && (arg2 <= 10))
10549 {
10550 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10551 }
10552 else
10553 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010554 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010555 return 0;
10556 }
10557 }
10558 break;
10559
10560 //Update MCC TX_EARLY_STOP_TIME parameter
10561 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10562 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10563 {
10564 if((arg2 >= 1) && (arg2 <= 10))
10565 {
10566 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10567 }
10568 else
10569 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010570 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010571 return 0;
10572 }
10573 }
10574 break;
10575
10576 //Update MCC RX_DRAIN_TIME parameter
10577 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10578 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10579 {
10580 if((arg2 >= 1) && (arg2 <= 10))
10581 {
10582 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10583 }
10584 else
10585 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010586 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010587 return 0;
10588 }
10589 }
10590 break;
10591
10592 //Update MCC CHANNEL_SWITCH_TIME parameter
10593 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10594 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10595 {
10596 if((arg2 >= 1) && (arg2 <= 20))
10597 {
10598 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10599 }
10600 else
10601 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010602 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010603 return 0;
10604 }
10605 }
10606 break;
10607
10608 //Update MCC MIN_CHANNEL_TIME parameter
10609 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10610 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10611 {
10612 if((arg2 >= 5) && (arg2 <= 20))
10613 {
10614 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10615 }
10616 else
10617 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010618 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010619 return 0;
10620 }
10621 }
10622 break;
10623
10624 //Update MCC PARK_BEFORE_TBTT parameter
10625 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10626 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10627 {
10628 if((arg2 >= 1) && (arg2 <= 5))
10629 {
10630 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10631 }
10632 else
10633 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010634 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010635 return 0;
10636 }
10637 }
10638 break;
10639
10640 //Update MCC MIN_AFTER_DTIM parameter
10641 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10642 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10643 {
10644 if((arg2 >= 5) && (arg2 <= 15))
10645 {
10646 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10647 }
10648 else
10649 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010650 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010651 return 0;
10652 }
10653 }
10654 break;
10655
10656 //Update MCC TOO_CLOSE_MARGIN parameter
10657 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10658 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10659 {
10660 if((arg2 >= 1) && (arg2 <= 3))
10661 {
10662 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10663 }
10664 else
10665 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010666 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010667 return 0;
10668 }
10669 }
10670 break;
10671
10672 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010673 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010674 __FUNCTION__,arg1);
10675 break;
10676 }
10677 return 0;
10678}
10679
Jeff Johnson295189b2012-06-20 16:38:30 -070010680int hdd_set_wext(hdd_adapter_t *pAdapter)
10681{
10682 hdd_wext_state_t *pwextBuf;
10683 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010684 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010685
10686 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10687
10688 // Now configure the roaming profile links. To SSID and bssid.
10689 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10690 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10691
10692 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10693 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10694
10695 /*Set the numOfChannels to zero to scan all the channels*/
10696 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10697 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10698
10699 /* Default is no encryption */
10700 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10701 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10702
10703 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10704 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10705
10706 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10707
10708 /* Default is no authentication */
10709 pwextBuf->roamProfile.AuthType.numEntries = 1;
10710 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10711
10712 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10713 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10714
10715 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010716 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010717
10718 hdd_clearRoamProfileIe(pAdapter);
10719
10720 return VOS_STATUS_SUCCESS;
10721
10722 }
10723
10724int hdd_register_wext(struct net_device *dev)
10725 {
10726 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10727 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10728 VOS_STATUS status;
10729
10730 ENTER();
10731
10732 // Zero the memory. This zeros the profile structure.
10733 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10734
10735 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10736
10737
10738 status = hdd_set_wext(pAdapter);
10739
10740 if(!VOS_IS_STATUS_SUCCESS(status)) {
10741
Arif Hussain6d2a3322013-11-17 19:50:10 -080010742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010743 return eHAL_STATUS_FAILURE;
10744 }
10745
10746 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10747 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010748 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init 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->scanevent)))
10753 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010755 return eHAL_STATUS_FAILURE;
10756 }
10757
10758 // Register as a wireless device
10759 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10760
10761 EXIT();
10762 return 0;
10763}
10764
10765int hdd_UnregisterWext(struct net_device *dev)
10766{
c_hpothu2a13bc32015-01-21 12:48:54 +053010767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10768 if (dev != NULL)
10769 {
10770 rtnl_lock();
10771 dev->wireless_handlers = NULL;
10772 rtnl_unlock();
10773 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010774
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 return 0;
10776}
10777
10778