blob: 69f89029951637d4349318f1f80453cab93d6a26 [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
168
Jeff Johnson295189b2012-06-20 16:38:30 -0700169
170/* Private ioctls and their sub-ioctls */
171#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
172#define WE_GET_11D_STATE 1
173#define WE_IBSS_STATUS 2
174#define WE_PMC_STATE 3
175#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700176#define WE_GET_MAX_ASSOC 6
177#define WE_GET_WDI_DBG 7
178#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
179#define WE_GET_CONCURRENCY_MODE 9
Peng Xu2446a892014-09-05 17:21:18 +0530180#define WE_GET_SCAN_BAND_PREFERENCE 10
Jeff Johnson295189b2012-06-20 16:38:30 -0700181/* Private ioctls and their sub-ioctls */
182#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
183
184/* Private ioctls and their sub-ioctls */
185#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
186#define WE_WOWL_ADD_PTRN 1
187#define WE_WOWL_DEL_PTRN 2
188#if defined WLAN_FEATURE_VOWIFI
189#define WE_NEIGHBOR_REPORT_REQUEST 3
190#endif
191#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
192#define WE_SET_CONFIG 5
Srinivas Dasarib8fdd422014-11-27 10:44:20 +0530193#define WE_SET_ENCRYPT_MSG 6
Jeff Johnson295189b2012-06-20 16:38:30 -0700194
195/* Private ioctls and their sub-ioctls */
196#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
197#define WE_SET_WLAN_DBG 1
198#define WE_SET_WDI_DBG 2
199#define WE_SET_SAP_CHANNELS 3
200
201/* Private ioctls and their sub-ioctls */
202#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
203#define WE_WLAN_VERSION 1
204#define WE_GET_STATS 2
205#define WE_GET_CFG 3
206#define WE_GET_WMM_STATUS 4
207#define WE_GET_CHANNEL_LIST 5
Jeff Johnsone7245742012-09-05 17:12:55 -0700208#ifdef WLAN_FEATURE_11AC
209#define WE_GET_RSSI 6
210#endif
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800211#define WE_GET_ROAM_RSSI 7
Chilam Ng16a2a1c2013-01-29 01:27:29 -0800212#ifdef FEATURE_WLAN_TDLS
213#define WE_GET_TDLS_PEERS 8
214#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700215#ifdef WLAN_FEATURE_11W
216#define WE_GET_11W_INFO 9
217#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530218#define WE_GET_STATES 10
Girish Gowlidab72f12014-09-04 15:34:43 +0530219#define WE_GET_SNR 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700220
221/* Private ioctls and their sub-ioctls */
222#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
223#define WE_CLEAR_STATS 1
224#define WE_INIT_AP 2
225#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530226#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700227#define WE_ENABLE_AMP 4
228#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530229#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700230#define WE_ENABLE_DXE_STALL_DETECT 6
231#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700232#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530233#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530234#define WE_STOP_OBSS_SCAN 11
Mukul Sharma84f27252014-07-14 18:11:42 +0530235#define WE_DUMP_ROAM_TIMER_LOG 12
236#define WE_RESET_ROAM_TIMER_LOG 13
Mukul Sharma84f27252014-07-14 18:11:42 +0530237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238/* Private ioctls and their sub-ioctls */
239#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
240#define WE_LOG_DUMP_CMD 1
241
Jeff Johnson295189b2012-06-20 16:38:30 -0700242#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800243//IOCTL to configure MCC params
244#define WE_MCC_CONFIG_CREDENTIAL 3
245#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700246
Chilam NG571c65a2013-01-19 12:27:36 +0530247#ifdef FEATURE_WLAN_TDLS
248#define WE_TDLS_CONFIG_PARAMS 5
249#endif
250
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700251#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530252#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700253
Chilam Ng01120412013-02-19 18:32:21 -0800254#ifdef FEATURE_WLAN_TDLS
255#undef MAX_VAR_ARGS
256#define MAX_VAR_ARGS 10
257#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700258#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800259#endif
260
Jeff Johnson295189b2012-06-20 16:38:30 -0700261/* Private ioctls (with no sub-ioctls) */
262/* note that they must be odd so that they have "get" semantics */
263#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
264#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
265#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
266
Girish Gowli464c9c82014-06-09 19:47:53 +0530267/* (SIOCIWFIRSTPRIV + 8) is currently unused */
268/* (SIOCIWFIRSTPRIV + 16) is currently unused */
269/* (SIOCIWFIRSTPRIV + 10) is currently unused */
270/* (SIOCIWFIRSTPRIV + 12) is currently unused */
271/* (SIOCIWFIRSTPRIV + 14) is currently unused */
272/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
Jeff Johnsone7245742012-09-05 17:12:55 -0700274#ifdef FEATURE_OEM_DATA_SUPPORT
275/* Private ioctls for setting the measurement configuration */
276#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
277#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
278#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280#ifdef WLAN_FEATURE_VOWIFI_11R
281#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
282#endif
283
284/* Private ioctl for setting the host offload feature */
285#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
286
287/* Private ioctl to get the statistics */
288#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
289
290/* Private ioctl to set the Keep Alive Params */
291#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
292#ifdef WLAN_FEATURE_PACKET_FILTERING
293/* Private ioctl to set the Packet Filtering Params */
294#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
295#endif
296
297#ifdef FEATURE_WLAN_SCAN_PNO
298/* Private ioctl to get the statistics */
299#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
300#endif
301
302#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
303
304#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
305#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700306/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700307
Jeff Johnson295189b2012-06-20 16:38:30 -0700308#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
309#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
310
311#define WLAN_STATS_INVALID 0
312#define WLAN_STATS_RETRY_CNT 1
313#define WLAN_STATS_MUL_RETRY_CNT 2
314#define WLAN_STATS_TX_FRM_CNT 3
315#define WLAN_STATS_RX_FRM_CNT 4
316#define WLAN_STATS_FRM_DUP_CNT 5
317#define WLAN_STATS_FAIL_CNT 6
318#define WLAN_STATS_RTS_FAIL_CNT 7
319#define WLAN_STATS_ACK_FAIL_CNT 8
320#define WLAN_STATS_RTS_SUC_CNT 9
321#define WLAN_STATS_RX_DISCARD_CNT 10
322#define WLAN_STATS_RX_ERROR_CNT 11
323#define WLAN_STATS_TX_BYTE_CNT 12
324
325#define WLAN_STATS_RX_BYTE_CNT 13
326#define WLAN_STATS_RX_RATE 14
327#define WLAN_STATS_TX_RATE 15
328
Jeff Johnsone7245742012-09-05 17:12:55 -0700329#define WLAN_STATS_RX_UC_BYTE_CNT 16
330#define WLAN_STATS_RX_MC_BYTE_CNT 17
331#define WLAN_STATS_RX_BC_BYTE_CNT 18
332#define WLAN_STATS_TX_UC_BYTE_CNT 19
333#define WLAN_STATS_TX_MC_BYTE_CNT 20
334#define WLAN_STATS_TX_BC_BYTE_CNT 21
335
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800336#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
337 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
338 { \
339 *__p++ = __type; \
340 *__p++ = __size; \
341 memcpy(__p, __val, __size); \
342 __p += __size; \
343 __tlen += __size + 2; \
344 } \
345 else \
346 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800347 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800348 } \
349 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700350
351#define VERSION_VALUE_MAX_LEN 32
352
353#define TX_PER_TRACKING_DEFAULT_RATIO 5
354#define TX_PER_TRACKING_MAX_RATIO 10
355#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
356
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530357#define WLAN_ADAPTER 0
358#define P2P_ADAPTER 1
359
Abhishek Singh2ec36ab2014-08-07 16:14:25 +0530360/*
361 * When supplicant sends SETBAND ioctl it queries for channels from
362 * cfg80211 layer by sending itself EVENT_CHANNEL_LIST_CHANGED command.
363 * This is not required if the return type from ioctl is
364 * DO_NOT_SEND_CHANNEL_CHANGE_EVENT as wiphy will send channel change
365 * event as part of regulatory_hint.
366 */
367enum {
368 SEND_CHANNEL_CHANGE_EVENT = 0,
369 DO_NOT_SEND_CHANNEL_CHANGE_EVENT,
370};
371
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800372/*MCC Configuration parameters */
373enum {
374 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
375 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
376 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
377 MCC_RX_DRAIN_TIME_CFG_PARAM,
378 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
379 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
380 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
381 MCC_MIN_AFTER_DTIM_CFG_PARAM,
382 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
383};
384
Siddharth Bhal64246172015-02-27 01:04:37 +0530385enum
386{
387 WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR = 1<<0,
388 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR = 1<<1,
389};
390
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800391int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
392 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
393
Jeff Johnson295189b2012-06-20 16:38:30 -0700394#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800395int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700396 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700397#endif
398
Jeff Johnson295189b2012-06-20 16:38:30 -0700399/**---------------------------------------------------------------------------
400
Arif Hussain0273cba2014-01-07 20:58:29 -0800401 \brief mem_alloc_copy_from_user_helper -
402
403 Helper function to allocate buffer and copy user data.
404
405 \param - wrqu - Pointer to IOCTL Data.
406 len - size
407
408 \return - On Success pointer to buffer, On failure NULL
409
410 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530411void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800412{
413 u8 *ptr = NULL;
414
415 /* in order to protect the code, an extra byte is post appended to the buffer
416 * and the null termination is added. However, when allocating (len+1) byte
417 * of memory, we need to make sure that there is no uint overflow when doing
418 * addition. In theory check len < UINT_MAX protects the uint overflow. For
419 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
420 * guess, now, it is assumed that the private command buffer size is no
421 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
422 */
423 if (len > MAX_USER_COMMAND_SIZE)
424 {
425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
426 "Invalid length");
427 return NULL;
428 }
429
430 ptr = kmalloc(len + 1, GFP_KERNEL);
431 if (NULL == ptr)
432 {
433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
434 "unable to allocate memory");
435 return NULL;
436 }
437
438 if (copy_from_user(ptr, wrqu_data, len))
439 {
440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
441 "%s: failed to copy data to user buffer", __func__);
442 kfree(ptr);
443 return NULL;
444 }
445 ptr[len] = '\0';
446 return ptr;
447}
448
Girish Gowli488ef492014-06-12 18:44:33 +0530449// Function to handle and get compatible struct iw_point passed to ioctl.
450int hdd_priv_get_data(struct iw_point *p_priv_data,
451 union iwreq_data *wrqu)
452{
453 if ((NULL == p_priv_data) || (NULL == wrqu))
454 {
455 return -EINVAL;
456 }
457
458#ifdef CONFIG_COMPAT
459 if (is_compat_task())
460 {
461 struct compat_iw_point *p_compat_priv_data;
462
463 // Compat task: typecast to campat structure and copy the members.
464 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
465
466 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
467 p_priv_data->length = p_compat_priv_data->length;
468 p_priv_data->flags = p_compat_priv_data->flags;
469 }//if(is_compat_task())
470 else
471 {
472#endif //#ifdef CONFIG_COMPAT
473
474 // Non compat task: directly copy the structure.
475 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
476
477#ifdef CONFIG_COMPAT
478 }//else of - if(is_compat_task())
479#endif //#ifdef CONFIG_COMPAT
480
481 return 0;
482}
483
Arif Hussain0273cba2014-01-07 20:58:29 -0800484/**---------------------------------------------------------------------------
485
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 \brief hdd_wlan_get_version() -
487
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800488 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700489
490 \param - pAdapter Pointer to the adapter.
491 wrqu - Pointer to IOCTL REQUEST Data.
492 extra - Pointer to char
493
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800494 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700495
496 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800497void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
498 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700499{
500 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800501 tSirVersionString wcnss_SW_version;
502 tSirVersionString wcnss_HW_version;
503 char *pSWversion;
504 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700506
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800507 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
508 sizeof(wcnss_SW_version));
509 if (VOS_IS_STATUS_SUCCESS(status))
510 {
511 pSWversion = wcnss_SW_version;
512 }
513 else
514 {
515 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 }
517
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800518 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
519 sizeof(wcnss_HW_version));
520 if (VOS_IS_STATUS_SUCCESS(status))
521 {
522 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800524 else
525 {
526 pHWversion = "Unknown";
527 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700528
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700529 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800530 "Host SW:%s, FW:%s, HW:%s",
531 QWLAN_VERSIONSTR,
532 pSWversion,
533 pHWversion);
534
535 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700536}
537
Jeff Johnson295189b2012-06-20 16:38:30 -0700538int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
539{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530540 tHalHandle hHal;
541 hdd_context_t *pHddCtx;
542 v_U32_t threshold = 0;
543 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700544
545 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530546 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530547 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
549 "%s: Adapter is NULL",__func__);
550 return -EINVAL;
551 }
552
553 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
554 ret = wlan_hdd_validate_context(pHddCtx);
555 if (0 != ret)
556 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530557 return ret;
558 }
559
560 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
561 if (NULL == hHal)
562 {
563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
564 "%s: Hal Context is NULL",__func__);
565 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 }
567
568 if ( eHAL_STATUS_SUCCESS !=
569 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
570 {
c_hpothub8245442013-11-20 23:41:09 +0530571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
572 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 return -EIO;
574 }
575 wrqu->rts.value = threshold;
576
577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800578 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
580 EXIT();
581
582 return 0;
583}
584
585int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
586{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530587 tHalHandle hHal;
588 hdd_context_t *pHddCtx;
589 v_U32_t threshold = 0, status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700590
591 ENTER();
592
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530593 if (NULL == pAdapter)
Agarwal Ashish971c2882013-10-30 20:11:12 +0530594 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
596 "%s: Adapter is NULL",__func__);
597 return -EINVAL;
598 }
599
600 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
601 status = wlan_hdd_validate_context(pHddCtx);
602 if (0 != status)
603 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +0530604 return status;
605 }
606
607 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
608 if (NULL == hHal)
609 {
610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
611 "%s: Hal Context is NULL",__func__);
612 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 }
614
615 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
616 != eHAL_STATUS_SUCCESS )
617 {
c_hpothub8245442013-11-20 23:41:09 +0530618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
619 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 return -EIO;
621 }
622 wrqu->frag.value = threshold;
623
624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800625 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700626
627 EXIT();
628
629 return 0;
630}
631
632int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
633{
Jeff Johnsone7245742012-09-05 17:12:55 -0700634 int i;
635 if (channel > 0)
636 {
637 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
638 {
639 if (channel == freq_chan_map[i].chan)
640 {
641 *pfreq = freq_chan_map[i].freq;
642 return 1;
643 }
644 }
645 }
646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800647 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700648 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700649}
650
651static v_BOOL_t
652hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
653{
654 v_BOOL_t rsnType = VOS_FALSE;
655 // is the authType supported?
656 switch (authType)
657 {
658 case eCSR_AUTH_TYPE_NONE: //never used
659 rsnType = eANI_BOOLEAN_FALSE;
660 break;
661 // MAC layer authentication types
662 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
663 rsnType = eANI_BOOLEAN_FALSE;
664 break;
665 case eCSR_AUTH_TYPE_SHARED_KEY:
666 rsnType = eANI_BOOLEAN_FALSE;
667 break;
668 case eCSR_AUTH_TYPE_AUTOSWITCH:
669 rsnType = eANI_BOOLEAN_FALSE;
670 break;
671
672 // Upper layer authentication types
673 case eCSR_AUTH_TYPE_WPA:
674 rsnType = eANI_BOOLEAN_TRUE;
675 break;
676 case eCSR_AUTH_TYPE_WPA_PSK:
677 rsnType = eANI_BOOLEAN_TRUE;
678 break;
679 case eCSR_AUTH_TYPE_WPA_NONE:
680 rsnType = eANI_BOOLEAN_TRUE;
681 break;
682#ifdef WLAN_FEATURE_VOWIFI_11R
683 case eCSR_AUTH_TYPE_FT_RSN:
684#endif
685 case eCSR_AUTH_TYPE_RSN:
686 rsnType = eANI_BOOLEAN_TRUE;
687 break;
688#ifdef WLAN_FEATURE_VOWIFI_11R
689 case eCSR_AUTH_TYPE_FT_RSN_PSK:
690#endif
691 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700692#ifdef WLAN_FEATURE_11W
693 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +0530694 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -0700695#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 rsnType = eANI_BOOLEAN_TRUE;
697 break;
698 //case eCSR_AUTH_TYPE_FAILED:
699 case eCSR_AUTH_TYPE_UNKNOWN:
700 rsnType = eANI_BOOLEAN_FALSE;
701 break;
702 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800703 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
704 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 rsnType = eANI_BOOLEAN_FALSE;
706 break;
707 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800708 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700709 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 return rsnType;
711}
712
713static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
714{
715 struct statsContext *pStatsContext;
716 hdd_adapter_t *pAdapter;
717
718 if (ioctl_debug)
719 {
720 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700721 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 }
723
724 if (NULL == pContext)
725 {
726 hddLog(VOS_TRACE_LEVEL_ERROR,
727 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700728 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 return;
730 }
731
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 pStatsContext = pContext;
733 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800734
735 /* there is a race condition that exists between this callback
736 function and the caller since the caller could time out either
737 before or while this code is executing. we use a spinlock to
738 serialize these actions */
739 spin_lock(&hdd_context_lock);
740
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
742 {
743 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800744 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 hddLog(VOS_TRACE_LEVEL_WARN,
746 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700747 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 if (ioctl_debug)
749 {
750 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700751 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 }
753 return;
754 }
755
Jeff Johnson72a40512013-12-19 10:14:15 -0800756 /* context is valid so caller is still waiting */
757
758 /* paranoia: invalidate the magic */
759 pStatsContext->magic = 0;
760
761 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 pAdapter->rssi = rssi;
763
Jeff Johnson72a40512013-12-19 10:14:15 -0800764 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800766
767 /* serialization is complete */
768 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700769}
770
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530771static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
772{
773 struct statsContext *pStatsContext;
774 hdd_adapter_t *pAdapter;
775
776 if (ioctl_debug)
777 {
778 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
779 __func__, (int)snr, (int)staId, pContext);
780 }
781
782 if (NULL == pContext)
783 {
784 hddLog(VOS_TRACE_LEVEL_ERROR,
785 "%s: Bad param, pContext [%p]",
786 __func__, pContext);
787 return;
788 }
789
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530790 pStatsContext = pContext;
791 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800792
793 /* there is a race condition that exists between this callback
794 function and the caller since the caller could time out either
795 before or while this code is executing. we use a spinlock to
796 serialize these actions */
797 spin_lock(&hdd_context_lock);
798
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530799 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
800 {
801 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800802 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530803 hddLog(VOS_TRACE_LEVEL_WARN,
804 "%s: Invalid context, pAdapter [%p] magic [%08x]",
805 __func__, pAdapter, pStatsContext->magic);
806 if (ioctl_debug)
807 {
808 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
809 __func__, pAdapter, pStatsContext->magic);
810 }
811 return;
812 }
813
Jeff Johnson72a40512013-12-19 10:14:15 -0800814 /* context is valid so caller is still waiting */
815
816 /* paranoia: invalidate the magic */
817 pStatsContext->magic = 0;
818
819 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530820 pAdapter->snr = snr;
821
Jeff Johnson72a40512013-12-19 10:14:15 -0800822 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530823 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800824
825 /* serialization is complete */
826 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530827}
828
Jeff Johnson295189b2012-06-20 16:38:30 -0700829VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
830{
831 struct statsContext context;
832 hdd_context_t *pHddCtx;
833 hdd_station_ctx_t *pHddStaCtx;
834 eHalStatus hstatus;
835 long lrc;
836
837 if (NULL == pAdapter)
838 {
839 hddLog(VOS_TRACE_LEVEL_WARN,
840 "%s: Invalid context, pAdapter", __func__);
841 return VOS_STATUS_E_FAULT;
842 }
843 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
844 {
845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
846 /* return a cached value */
847 *rssi_value = pAdapter->rssi;
848 return VOS_STATUS_SUCCESS;
849 }
850
851 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
852 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
853
854 init_completion(&context.completion);
855 context.pAdapter = pAdapter;
856 context.magic = RSSI_CONTEXT_MAGIC;
857
858 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
859 pHddStaCtx->conn_info.staId[ 0 ],
860 pHddStaCtx->conn_info.bssId,
861 &context, pHddCtx->pvosContext);
862 if (eHAL_STATUS_SUCCESS != hstatus)
863 {
864 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700865 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 /* we'll returned a cached value below */
867 }
868 else
869 {
870 /* request was sent -- wait for the response */
871 lrc = wait_for_completion_interruptible_timeout(&context.completion,
872 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 if (lrc <= 0)
874 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800875 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700876 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 /* we'll now returned a cached value below */
878 }
879 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800880
881 /* either we never sent a request, we sent a request and received a
882 response or we sent a request and timed out. if we never sent a
883 request or if we sent a request and got a response, we want to
884 clear the magic out of paranoia. if we timed out there is a
885 race condition such that the callback function could be
886 executing at the same time we are. of primary concern is if the
887 callback function had already verified the "magic" but had not
888 yet set the completion variable when a timeout occurred. we
889 serialize these activities by invalidating the magic while
890 holding a shared spinlock which will cause us to block if the
891 callback is currently executing */
892 spin_lock(&hdd_context_lock);
893 context.magic = 0;
894 spin_unlock(&hdd_context_lock);
895
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 *rssi_value = pAdapter->rssi;
897
898 return VOS_STATUS_SUCCESS;
899}
900
Siddharth Bhal64246172015-02-27 01:04:37 +0530901static void hdd_GetFrameLogCB( void *pContext )
902{
903 struct getFrameLogCtx *pGetFrameLogCtx;
904 hdd_adapter_t *pAdapter;
905
906 if (NULL == pContext)
907 {
908 hddLog(VOS_TRACE_LEVEL_ERROR,
909 "%s: Bad param, pContext [%p]", __func__, pContext);
910 return;
911 }
912
913 pGetFrameLogCtx = pContext;
914 pAdapter = pGetFrameLogCtx->pAdapter;
915
916 /* there is a race condition that exists between this callback
917 function and the caller since the caller could time out either
918 before or while this code is executing. we use a spinlock to
919 serialize these actions */
920 spin_lock(&hdd_context_lock);
921
922 if (GET_FRAME_LOG_MAGIC != pGetFrameLogCtx->magic)
923 {
924 /* the caller presumably timed out so there is nothing we can do */
925 spin_unlock(&hdd_context_lock);
926 hddLog(VOS_TRACE_LEVEL_ERROR,
927 "%s: Invalid context, pAdapter [%p] magic [%08x]",
928 __func__, pAdapter, pGetFrameLogCtx->magic);
929 return;
930 }
931
932 /* context is valid so caller is still waiting */
933
934 /* paranoia: invalidate the magic */
935 pGetFrameLogCtx->magic = 0;
936
937 /* notify the caller */
938 complete(&pGetFrameLogCtx->completion);
939
940 /* serialization is complete */
941 spin_unlock(&hdd_context_lock);
942}
943
944/**---------------------------------------------------------------------------
945
946 \brief wlan_hdd_get_frame_logs() -
947
948 This function use to get Frames log.
949
950 \param - pAdapter Pointer to the adapter.
951 flag - Specify type of request. Clear and Send request are
952 supported.
953
954 \return - none
955
956 --------------------------------------------------------------------------*/
957VOS_STATUS wlan_hdd_get_frame_logs(hdd_adapter_t *pAdapter, v_U8_t flag)
958{
959 struct getFrameLogCtx context;
960 hdd_context_t *pHddCtx;
961 eHalStatus hstatus;
962 long lrc;
963
964 if (NULL == pAdapter)
965 {
966 hddLog(VOS_TRACE_LEVEL_WARN,
967 "%s: Invalid context, pAdapter", __func__);
968 return VOS_STATUS_E_FAULT;
969 }
970
971 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
972 if (!pHddCtx->mgmt_frame_logging)
973 {
974 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Frame Logging not init!", __func__);
975 return VOS_STATUS_E_AGAIN;
976 }
977
978 if (flag != WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR &&
979 flag != WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR)
980 {
981 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Incorrect getFrame params!", __func__);
982 return VOS_STATUS_E_INVAL;
983 }
984
985 init_completion(&context.completion);
986 context.pAdapter = pAdapter;
987 context.magic = GET_FRAME_LOG_MAGIC;
988
989 hstatus = sme_GetFramesLog(pHddCtx->hHal, hdd_GetFrameLogCB,
990 flag, &context);
991 if (eHAL_STATUS_SUCCESS != hstatus)
992 {
993 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to get Frame Logs", __func__);
994 }
995 else
996 {
997 /* request was sent -- wait for the response */
998 lrc = wait_for_completion_interruptible_timeout(&context.completion,
999 msecs_to_jiffies(WLAN_WAIT_TIME_FRAME_LOG));
1000 if (lrc <= 0)
1001 {
1002 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while fetching Frame logs",
1003 __func__, (0 == lrc) ? "timeout" : "interrupt");
1004 }
1005 }
1006
1007 spin_lock(&hdd_context_lock);
1008 context.magic = 0;
1009 spin_unlock(&hdd_context_lock);
1010
1011 return VOS_STATUS_SUCCESS;
1012}
1013
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301014VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
1015{
1016 struct statsContext context;
1017 hdd_context_t *pHddCtx;
1018 hdd_station_ctx_t *pHddStaCtx;
1019 eHalStatus hstatus;
1020 long lrc;
1021 int valid;
1022
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301023 ENTER();
1024
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301025 if (NULL == pAdapter)
1026 {
1027 hddLog(VOS_TRACE_LEVEL_ERROR,
1028 "%s: Invalid context, pAdapter", __func__);
1029 return VOS_STATUS_E_FAULT;
1030 }
1031
1032 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1033
1034 valid = wlan_hdd_validate_context(pHddCtx);
1035 if (0 != valid)
1036 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301037 return VOS_STATUS_E_FAULT;
1038 }
1039
1040 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1041 if (NULL == pHddStaCtx)
1042 {
1043 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
1044 return VOS_STATUS_E_FAULT;
1045 }
1046
1047 init_completion(&context.completion);
1048 context.pAdapter = pAdapter;
1049 context.magic = SNR_CONTEXT_MAGIC;
1050
1051 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
1052 pHddStaCtx->conn_info.staId[ 0 ],
1053 pHddStaCtx->conn_info.bssId,
1054 &context);
1055 if (eHAL_STATUS_SUCCESS != hstatus)
1056 {
1057 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1058 __func__);
1059 /* we'll returned a cached value below */
1060 }
1061 else
1062 {
1063 /* request was sent -- wait for the response */
1064 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1065 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301066 if (lrc <= 0)
1067 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001068 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301069 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301070 /* we'll now returned a cached value below */
1071 }
1072 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001073
1074 /* either we never sent a request, we sent a request and received a
1075 response or we sent a request and timed out. if we never sent a
1076 request or if we sent a request and got a response, we want to
1077 clear the magic out of paranoia. if we timed out there is a
1078 race condition such that the callback function could be
1079 executing at the same time we are. of primary concern is if the
1080 callback function had already verified the "magic" but had not
1081 yet set the completion variable when a timeout occurred. we
1082 serialize these activities by invalidating the magic while
1083 holding a shared spinlock which will cause us to block if the
1084 callback is currently executing */
1085 spin_lock(&hdd_context_lock);
1086 context.magic = 0;
1087 spin_unlock(&hdd_context_lock);
1088
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301089 *snr = pAdapter->snr;
1090
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301091 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05301092 return VOS_STATUS_SUCCESS;
1093}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001094#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001095
1096static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
1097{
1098 struct statsContext *pStatsContext;
1099 hdd_adapter_t *pAdapter;
1100 if (ioctl_debug)
1101 {
1102 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1103 __func__, (int)rssi, (int)staId, pContext);
1104 }
1105
1106 if (NULL == pContext)
1107 {
1108 hddLog(VOS_TRACE_LEVEL_ERROR,
1109 "%s: Bad param, pContext [%p]",
1110 __func__, pContext);
1111 return;
1112 }
1113
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001114 pStatsContext = pContext;
1115 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08001116
1117 /* there is a race condition that exists between this callback
1118 function and the caller since the caller could time out either
1119 before or while this code is executing. we use a spinlock to
1120 serialize these actions */
1121 spin_lock(&hdd_context_lock);
1122
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001123 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
1124 {
1125 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08001126 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001127 hddLog(VOS_TRACE_LEVEL_WARN,
1128 "%s: Invalid context, pAdapter [%p] magic [%08x]",
1129 __func__, pAdapter, pStatsContext->magic);
1130 if (ioctl_debug)
1131 {
1132 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1133 __func__, pAdapter, pStatsContext->magic);
1134 }
1135 return;
1136 }
1137
Jeff Johnson72a40512013-12-19 10:14:15 -08001138 /* context is valid so caller is still waiting */
1139
1140 /* paranoia: invalidate the magic */
1141 pStatsContext->magic = 0;
1142
1143 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001144 pAdapter->rssi = rssi;
1145
Jeff Johnson72a40512013-12-19 10:14:15 -08001146 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001147 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08001148
1149 /* serialization is complete */
1150 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001151}
1152
1153
1154
1155VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
1156{
1157 struct statsContext context;
1158 hdd_context_t *pHddCtx = NULL;
1159 hdd_station_ctx_t *pHddStaCtx = NULL;
1160 eHalStatus hstatus;
1161 long lrc;
1162
1163 if (NULL == pAdapter)
1164 {
1165 hddLog(VOS_TRACE_LEVEL_WARN,
1166 "%s: Invalid context, pAdapter", __func__);
1167 return VOS_STATUS_E_FAULT;
1168 }
1169 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1170 {
1171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1172 /* return a cached value */
1173 *rssi_value = pAdapter->rssi;
1174 return VOS_STATUS_SUCCESS;
1175 }
1176
1177 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1178 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1179
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301180 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001181 {
1182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1183 /* return a cached value */
1184 *rssi_value = 0;
1185 return VOS_STATUS_SUCCESS;
1186 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301187
1188 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1189 {
1190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1191 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1192 *rssi_value = pAdapter->rssi;
1193 return VOS_STATUS_SUCCESS;
1194 }
1195
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001196 init_completion(&context.completion);
1197 context.pAdapter = pAdapter;
1198 context.magic = RSSI_CONTEXT_MAGIC;
1199
1200 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1201 pHddStaCtx->conn_info.staId[ 0 ],
1202 pHddStaCtx->conn_info.bssId,
1203 &context, pHddCtx->pvosContext);
1204 if (eHAL_STATUS_SUCCESS != hstatus)
1205 {
1206 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1207 __func__);
1208 /* we'll returned a cached value below */
1209 }
1210 else
1211 {
1212 /* request was sent -- wait for the response */
1213 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1214 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001215 if (lrc <= 0)
1216 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001217 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001218 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001219 /* we'll now returned a cached value below */
1220 }
1221 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001222
1223 /* either we never sent a request, we sent a request and received a
1224 response or we sent a request and timed out. if we never sent a
1225 request or if we sent a request and got a response, we want to
1226 clear the magic out of paranoia. if we timed out there is a
1227 race condition such that the callback function could be
1228 executing at the same time we are. of primary concern is if the
1229 callback function had already verified the "magic" but had not
1230 yet set the completion variable when a timeout occurred. we
1231 serialize these activities by invalidating the magic while
1232 holding a shared spinlock which will cause us to block if the
1233 callback is currently executing */
1234 spin_lock(&hdd_context_lock);
1235 context.magic = 0;
1236 spin_unlock(&hdd_context_lock);
1237
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001238 *rssi_value = pAdapter->rssi;
1239
1240 return VOS_STATUS_SUCCESS;
1241}
1242#endif
1243
1244
Jeff Johnson295189b2012-06-20 16:38:30 -07001245void hdd_StatisticsCB( void *pStats, void *pContext )
1246{
1247 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1248 hdd_stats_t *pStatsCache = NULL;
1249 hdd_wext_state_t *pWextState;
1250 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1251
1252 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1253 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1254 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1255 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1256 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1257 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1258
1259 if (pAdapter!= NULL)
1260 pStatsCache = &pAdapter->hdd_stats;
1261
1262
1263 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1264 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1265 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1266 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1267 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1268 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1269
1270 if (pStatsCache!=NULL)
1271 {
1272 // and copy the stats into the cache we keep in the adapter instance structure
1273 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1274 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1275 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1276 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1277 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1278 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1279 }
1280
1281 if(pAdapter)
1282 {
1283 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1284 if(pWextState)
1285 {
1286 vos_status = vos_event_set(&pWextState->vosevent);
1287 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1288 {
1289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001290 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001291 return;
1292 }
1293 }
1294 }
1295}
1296
1297void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1298{
1299 v_CONTEXT_t pVosContext;
1300 hdd_context_t *pHddCtx;
1301 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1302#if 0
1303 hdd_wext_state_t *pWextState;
1304 v_U32_t roamId;
1305#endif
1306
1307 ENTER();
1308
1309 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1310
1311 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1312 if (NULL == pHddCtx)
1313 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001314 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 return;
1316 }
1317#if 0
1318 pWextState = pAdapter->pWextState;
1319#endif
1320
1321 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1322 {
1323 //TODO Verify is this is really used. If yes need to fix it.
1324 hdd_reconnect_all_adapters( pHddCtx );
1325#if 0
1326 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1327 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1328 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1329
1330 if(VOS_STATUS_SUCCESS == vosStatus)
1331 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1332 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1333
1334 sme_RoamConnect(halHandle,
1335 pAdapter->sessionId, &(pWextState->roamProfile),
1336 &roamId);
1337#endif
1338 }
1339
1340 EXIT();
1341
1342}
1343
1344void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1345{
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1347
1348 /* clear WPA/RSN/WSC IE information in the profile */
1349 pWextState->roamProfile.nWPAReqIELength = 0;
1350 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1351 pWextState->roamProfile.nRSNReqIELength = 0;
1352 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1353
Chet Lanctot186b5732013-03-18 10:26:30 -07001354#ifdef FEATURE_WLAN_WAPI
1355 pWextState->roamProfile.nWAPIReqIELength = 0;
1356 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1357#endif
1358
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001360 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301362 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1364 pWextState->roamProfile.nAddIEAssocLength = 0;
1365
1366 pWextState->roamProfile.EncryptionType.numEntries = 1;
1367 pWextState->roamProfile.EncryptionType.encryptionType[0]
1368 = eCSR_ENCRYPT_TYPE_NONE;
1369
1370 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1371 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1372 = eCSR_ENCRYPT_TYPE_NONE;
1373
1374 pWextState->roamProfile.AuthType.numEntries = 1;
1375 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1376
Chet Lanctot186b5732013-03-18 10:26:30 -07001377#ifdef WLAN_FEATURE_11W
1378 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1379 pWextState->roamProfile.MFPRequired = 0;
1380 pWextState->roamProfile.MFPCapable = 0;
1381#endif
1382
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 pWextState->authKeyMgmt = 0;
1384
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05301385 vos_mem_zero(&pWextState->roamProfile.Keys,
1386 sizeof(pWextState->roamProfile.Keys));
1387
Jeff Johnson295189b2012-06-20 16:38:30 -07001388#ifdef FEATURE_WLAN_WAPI
1389 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1390 pAdapter->wapi_info.nWapiMode = 0;
1391#endif
1392
1393 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1394
1395}
1396
1397void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1398{
1399 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001400
Nirav Shahf6bd2672015-03-11 12:53:15 +05301401 if ( (pAdapter == NULL) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001402 {
1403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shahf6bd2672015-03-11 12:53:15 +05301404 "%s: Invalid pAdapter magic/ pAdapter is NULL", __func__);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001405 }
1406 else
1407 {
1408 complete(&pAdapter->ula_complete);
1409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001410}
1411
1412VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1413{
1414 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001416 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417
1418 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1419 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001420 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001421
1422 /*To avoid race condition between the set key and the last EAPOL
1423 packet, notify TL to finish upper layer authentication incase if the
1424 last EAPOL packet pending in the TL queue.*/
Nirav Shah4f765af2015-01-21 19:51:30 +05301425 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter,
1426 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1427 pHddStaCtx->conn_info.staId[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001428
Nirav Shah4f765af2015-01-21 19:51:30 +05301429 if ( vos_status == VOS_STATUS_E_ALREADY )
1430 {
1431 return VOS_STATUS_SUCCESS;
1432 }
1433 else if ( vos_status != VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07001434 {
1435 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1436 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1437 __LINE__, vos_status );
1438 return vos_status;
1439
1440 }
1441
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001442 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301444 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001445 {
1446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301447 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001448 /* we'll still fall through and return success since the
1449 * connection may still get established but is just taking
1450 * too long for us to wait */
1451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 }
1453 return VOS_STATUS_SUCCESS;
1454}
1455
1456v_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)
1457{
1458
1459 int left = ie_len;
1460 v_U8_t *ptr = ie;
1461 v_U8_t elem_id,elem_len;
1462 v_U8_t eid = 0xDD;
1463
1464 if ( NULL == ie || 0 == ie_len )
1465 return NULL;
1466
1467 while(left >= 2)
1468 {
1469 elem_id = ptr[0];
1470 elem_len = ptr[1];
1471 left -= 2;
1472 if(elem_len > left)
1473 {
1474 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001475 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 eid,elem_len,left);
1477 return NULL;
1478 }
1479 if (elem_id == eid)
1480 {
1481 if(memcmp( &ptr[2], oui, oui_size)==0)
1482 return ptr;
1483 }
1484
1485 left -= elem_len;
1486 ptr += (elem_len + 2);
1487 }
1488 return NULL;
1489}
1490
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301491static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 union iwreq_data *wrqu, char *extra)
1493{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301494 hdd_adapter_t *pAdapter;
1495 hdd_context_t *pHddCtx;
1496 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301497
1498 ENTER();
1499
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301500 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1501 if (NULL == pAdapter)
1502 {
1503 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1504 "%s: pAdapter is NULL\n", __func__);
1505 return -EINVAL;
1506 }
1507 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1508 ret = wlan_hdd_validate_context(pHddCtx);
1509 if (0 != ret)
1510 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301511 return ret;
1512 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301513
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 /* Do nothing for now */
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301515
1516 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301517 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001518}
1519
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301520static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1521 union iwreq_data *wrqu, char *extra)
1522{
1523 int ret;
1524
1525 vos_ssr_protect(__func__);
1526 ret = __iw_set_commit(dev, info, wrqu, extra);
1527 vos_ssr_unprotect(__func__);
1528
1529 return ret;
1530}
1531
1532static int __iw_get_name(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 struct iw_request_info *info,
1534 char *wrqu, char *extra)
1535{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301536 hdd_adapter_t *pAdapter;
1537 hdd_context_t *pHddCtx;
1538 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301539
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301541 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1542 if (NULL == pAdapter)
1543 {
1544 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1545 "%s: pAdapter is NULL\n", __func__);
1546 return -EINVAL;
1547 }
1548 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1549 ret = wlan_hdd_validate_context(pHddCtx);
1550 if (0 != ret)
1551 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301552 return ret;
1553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1555 EXIT();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301556 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001557}
1558
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05301559static int iw_get_name(struct net_device *dev,
1560 struct iw_request_info *info,
1561 char *wrqu, char *extra)
1562{
1563 int ret;
1564
1565 vos_ssr_protect(__func__);
1566 ret = __iw_get_name(dev, info, wrqu, extra);
1567 vos_ssr_unprotect(__func__);
1568
1569 return ret;
1570}
1571
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301572static int __iw_set_mode(struct net_device *dev,
1573 struct iw_request_info *info,
1574 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001575{
1576 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301577 hdd_adapter_t *pAdapter;
1578 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 tCsrRoamProfile *pRoamProfile;
1580 eCsrRoamBssType LastBSSType;
1581 eMib_dot11DesiredBssType connectedBssType;
1582 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 struct wireless_dev *wdev;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301584 int status = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001585
1586 ENTER();
1587
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301588 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 if (NULL == pAdapter)
1590 {
1591 hddLog(VOS_TRACE_LEVEL_WARN,
1592 "%s: Invalid context, pAdapter", __func__);
1593 return 0;
1594 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301595 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1596 status = wlan_hdd_validate_context(pHddCtx);
1597 if (0 != status)
1598 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301599 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 }
1601
1602 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1603 if (pWextState == NULL)
1604 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301605 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 return -EINVAL;
1607 }
1608
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 pRoamProfile = &pWextState->roamProfile;
1611 LastBSSType = pRoamProfile->BSSType;
1612
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301613 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001614
1615 switch (wrqu->mode)
1616 {
1617 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301618 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1620 // Set the phymode correctly for IBSS.
1621 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1622 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001623 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 break;
1626 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301627 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 break;
1631 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301632 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1634 break;
1635 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301636 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 return -EOPNOTSUPP;
1638 }
1639
1640 if ( LastBSSType != pRoamProfile->BSSType )
1641 {
1642 //the BSS mode changed
1643 // We need to issue disconnect if connected or in IBSS disconnect state
1644 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1645 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1646 {
1647 VOS_STATUS vosStatus;
1648 // need to issue a disconnect to CSR.
1649 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1650 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1651 pAdapter->sessionId,
1652 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1653 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301654 {
1655 long ret;
1656 ret = wait_for_completion_interruptible_timeout(
1657 &pAdapter->disconnect_comp_var,
1658 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1659 if (ret <= 0)
1660 hddLog(VOS_TRACE_LEVEL_ERROR,
1661 FL("failed wait on disconnect_comp_var %ld"), ret);
1662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 }
1664 }
1665
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 EXIT();
1667 return 0;
1668}
1669
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301670static int iw_set_mode(struct net_device *dev,
1671 struct iw_request_info *info,
1672 union iwreq_data *wrqu, char *extra)
1673{
1674 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001675
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301676 vos_ssr_protect(__func__);
1677 ret = __iw_set_mode(dev, info, wrqu, extra);
1678 vos_ssr_unprotect(__func__);
1679
1680 return ret;
1681}
1682
1683static int __iw_get_mode(struct net_device *dev,
1684 struct iw_request_info *info,
1685 union iwreq_data *wrqu,
1686 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001687{
1688
1689 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301690 hdd_adapter_t *pAdapter;
1691 hdd_context_t *pHddCtx;
1692 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001693
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301694 ENTER();
1695
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301696 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 if (NULL == pAdapter)
1698 {
1699 hddLog(VOS_TRACE_LEVEL_WARN,
1700 "%s: Invalid context, pAdapter", __func__);
1701 return 0;
1702 }
1703
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301704 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1705 ret = wlan_hdd_validate_context(pHddCtx);
1706 if (0 != ret)
1707 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301708 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1711 if (pWextState == NULL)
1712 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301713 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 return -EINVAL;
1715 }
1716
1717 switch (pWextState->roamProfile.BSSType)
1718 {
1719 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001720 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301721 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 break;
1723 case eCSR_BSS_TYPE_IBSS:
1724 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001725 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301726 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001727 break;
1728 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001729 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301730 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 break;
1732 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001733 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 break;
1735 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301736
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301737 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 return 0;
1739}
1740
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301741static int iw_get_mode(struct net_device *dev,
1742 struct iw_request_info *info,
1743 union iwreq_data *wrqu,
1744 char *extra)
1745{
1746 int ret;
1747
1748 vos_ssr_protect(__func__);
1749 ret = __iw_get_mode(dev, info, wrqu, extra);
1750 vos_ssr_unprotect(__func__);
1751
1752 return ret;
1753}
1754
1755static int __iw_set_freq(struct net_device *dev,
1756 struct iw_request_info *info,
1757 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001758{
1759 v_U32_t numChans = 0;
1760 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1761 v_U32_t indx = 0;
1762 v_U32_t status = 0;
1763
1764 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301765 hdd_adapter_t *pAdapter;
1766 hdd_context_t *pHddCtx;
1767 tHalHandle hHal;
1768 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 tCsrRoamProfile * pRoamProfile;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301770
Jeff Johnson295189b2012-06-20 16:38:30 -07001771 ENTER();
1772
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301773 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1774 if (NULL == pAdapter)
1775 {
1776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1777 "%s:Invalid Adapter",__func__);
1778 return -EINVAL;
1779 }
1780
1781 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1782 status = wlan_hdd_validate_context(pHddCtx);
1783 if (0 != status)
1784 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 return status;
1786 }
1787
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301788 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1789 if (NULL == hHal)
1790 {
1791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1792 "%s: Hal Context is NULL",__func__);
1793 return -EINVAL;
1794 }
1795
1796 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1797 if (NULL == pHddStaCtx)
1798 {
1799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1800 "%s:STA context is NULL",__func__);
1801 return -EINVAL;
1802 }
1803
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301805 if (NULL == pWextState)
1806 {
1807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1808 "%s: pWextState is NULL",__func__);
1809 return -EINVAL;
1810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001811
1812 pRoamProfile = &pWextState->roamProfile;
1813
Arif Hussain6d2a3322013-11-17 19:50:10 -08001814 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001815
1816 /* Link is up then return cant set channel*/
1817 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1818 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1819 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001820 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 return -EOPNOTSUPP;
1822 }
1823
1824 /* Settings by Frequency as input */
1825 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1826 (wrqu->freq.m <= (tANI_U32)5.825e8))
1827 {
1828 tANI_U32 freq = wrqu->freq.m / 100000;
1829
1830 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1831 indx++;
1832 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1833 {
1834 return -EINVAL;
1835 }
1836 wrqu->freq.e = 0;
1837 wrqu->freq.m = freq_chan_map[indx].chan;
1838
1839 }
1840
1841 if (wrqu->freq.e == 0)
1842 {
1843 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1844 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1845 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001846 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001847 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1849 return -EINVAL;
1850 }
1851
1852 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1853
1854 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1855 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1857 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 return -EIO;
1859 }
1860
1861 for (indx = 0; indx < numChans; indx++) {
1862 if (wrqu->freq.m == validChan[indx]){
1863 break;
1864 }
1865 }
1866 }
1867 else{
1868
1869 return -EINVAL;
1870 }
1871
1872 if(indx >= numChans)
1873 {
1874 return -EINVAL;
1875 }
1876
1877 /* Set the Operational Channel */
1878 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1879 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1880 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1881
Arif Hussain6d2a3322013-11-17 19:50:10 -08001882 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001883
1884 EXIT();
1885
1886 return status;
1887}
1888
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301889static int iw_set_freq(struct net_device *dev,
1890 struct iw_request_info *info,
1891 union iwreq_data *wrqu, char *extra)
1892{
1893 int ret;
1894
1895 vos_ssr_protect(__func__);
1896 ret = __iw_set_freq(dev, info, wrqu, extra);
1897 vos_ssr_unprotect(__func__);
1898
1899 return ret;
1900}
1901
1902static int __iw_get_freq(struct net_device *dev,
1903 struct iw_request_info *info,
1904 struct iw_freq *fwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001905{
Jeff Johnsone7245742012-09-05 17:12:55 -07001906 v_U32_t status = FALSE, channel = 0, freq = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301907 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 tHalHandle hHal;
1909 hdd_wext_state_t *pWextState;
1910 tCsrRoamProfile * pRoamProfile;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301911 hdd_station_ctx_t *pHddStaCtx;
1912 hdd_context_t *pHddCtx;
1913 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001914
1915 ENTER();
1916
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301917 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1918 if (NULL == pAdapter)
1919 {
1920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1921 "%s: Adapter is NULL", __func__);
1922 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301924 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1925 ret = wlan_hdd_validate_context(pHddCtx);
1926 if (0 != ret)
1927 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301928 return ret;
1929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05301931 if (NULL == hHal)
1932 {
1933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1934 "%s: Hal Context is NULL",__func__);
1935 return -EINVAL;
1936 }
1937 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1938 if (NULL == pHddStaCtx)
1939 {
1940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1941 "%s: HddStaCtx is NULL", __func__);
1942 return -EINVAL;
1943 }
1944 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1945 if (NULL == pWextState)
1946 {
1947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1948 "%s: pWextState is NULL",__func__);
1949 return -EINVAL;
1950 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 pRoamProfile = &pWextState->roamProfile;
1952
1953 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1954 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001955 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 {
c_hpothub8245442013-11-20 23:41:09 +05301957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1958 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 return -EIO;
1960 }
1961 else
1962 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001963 status = hdd_wlan_get_freq(channel, &freq);
1964 if( TRUE == status )
1965 {
1966 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1967 * iwlist & iwconfig command shows frequency into proper
1968 * format (2.412 GHz instead of 246.2 MHz)*/
1969 fwrq->m = freq;
1970 fwrq->e = MHZ;
1971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 }
1973 }
1974 else
1975 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001976 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1977 * iwlist & iwconfig command shows frequency into proper
1978 * format (2.412 GHz instead of 246.2 MHz)*/
1979 fwrq->m = 0;
1980 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301982
1983 EXIT();
1984 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001985}
1986
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05301987static int iw_get_freq(struct net_device *dev,
1988 struct iw_request_info *info,
1989 struct iw_freq *fwrq, char *extra)
1990{
1991 int ret;
1992
1993 vos_ssr_protect(__func__);
1994 ret = __iw_get_freq(dev, info, fwrq, extra);
1995 vos_ssr_unprotect(__func__);
1996
1997 return ret;
1998}
1999
2000static int __iw_get_tx_power(struct net_device *dev,
2001 struct iw_request_info *info,
2002 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002003{
2004
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302005 hdd_adapter_t *pAdapter;
2006 hdd_context_t *pHddCtx;
2007 hdd_station_ctx_t *pHddStaCtx;
2008 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002009
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302010 ENTER();
2011
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302012 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2013 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2016 "%s: Adapter is NULL",__func__);
2017 return -EINVAL;
2018 }
2019 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2020 ret = wlan_hdd_validate_context(pHddCtx);
2021 if (0 != ret)
2022 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302023 return ret;
2024 }
2025
2026 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2027 if (NULL == pHddStaCtx)
2028 {
2029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2030 "%s: STA Context is NULL",__func__);
2031 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 }
2033
2034 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2035 {
2036 wrqu->txpower.value = 0;
2037 return 0;
2038 }
2039 wlan_hdd_get_classAstats(pAdapter);
2040 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2041
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302042 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 return 0;
2044}
2045
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302046static int iw_get_tx_power(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 struct iw_request_info *info,
2048 union iwreq_data *wrqu, char *extra)
2049{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302050 int ret;
2051
2052 vos_ssr_protect(__func__);
2053 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2054 vos_ssr_unprotect(__func__);
2055
2056 return ret;
2057}
2058
2059static int __iw_set_tx_power(struct net_device *dev,
2060 struct iw_request_info *info,
2061 union iwreq_data *wrqu, char *extra)
2062{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302063 hdd_adapter_t *pAdapter;
2064 tHalHandle hHal;
2065 hdd_context_t *pHddCtx;
2066 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002067
2068 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302069 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2070 if (NULL == pAdapter)
2071 {
2072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2073 "%s: Adapter is NULL",__func__);
2074 return -EINVAL;
2075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002076
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302077 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2078 ret = wlan_hdd_validate_context(pHddCtx);
2079 if (0 != ret)
2080 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302081 return ret;
2082 }
2083
2084 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2085 if (NULL == hHal)
2086 {
2087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2088 "%s: Hal Context is NULL",__func__);
2089 return -EINVAL;
2090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2092 {
c_hpothub8245442013-11-20 23:41:09 +05302093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2094 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 return -EIO;
2096 }
2097
2098 EXIT();
2099
2100 return 0;
2101}
2102
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302103static int iw_set_tx_power(struct net_device *dev,
2104 struct iw_request_info *info,
2105 union iwreq_data *wrqu, char *extra)
2106{
2107 int ret;
2108
2109 vos_ssr_protect(__func__);
2110 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2111 vos_ssr_unprotect(__func__);
2112
2113 return ret;
2114}
2115
2116static int __iw_get_bitrate(struct net_device *dev,
2117 struct iw_request_info *info,
2118 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002119{
2120 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
2121 eHalStatus status = eHAL_STATUS_SUCCESS;
2122 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302123 hdd_adapter_t *pAdapter;
2124 hdd_context_t *pHddCtx;
2125 hdd_station_ctx_t *pHddStaCtx;
2126 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002127
2128 ENTER();
2129
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302130 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2131 if (NULL == pAdapter)
2132 {
2133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2134 "%s: Adapter is NULL",__func__);
2135 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 }
2137
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302138 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2139 ret = wlan_hdd_validate_context(pHddCtx);
2140 if (0 != ret)
2141 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302142 return ret;
2143 }
2144
2145 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2146 if (NULL == pHddStaCtx)
2147 {
2148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2149 "%s: STA Context is NULL",__func__);
2150 return -EINVAL;
2151 }
2152
2153 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 wrqu->bitrate.value = 0;
2155 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302156 else
2157 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
2159 SME_SUMMARY_STATS |
2160 SME_GLOBAL_CLASSA_STATS |
2161 SME_GLOBAL_CLASSB_STATS |
2162 SME_GLOBAL_CLASSC_STATS |
2163 SME_GLOBAL_CLASSD_STATS |
2164 SME_PER_STA_STATS,
2165 hdd_StatisticsCB, 0, FALSE,
2166 pHddStaCtx->conn_info.staId[0], pAdapter );
2167
2168 if(eHAL_STATUS_SUCCESS != status)
2169 {
2170 hddLog(VOS_TRACE_LEVEL_ERROR,
2171 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002172 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 return status;
2174 }
2175
2176 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302177 if (NULL == pWextState)
2178 {
2179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2180 "%s: pWextState is NULL",__func__);
2181 return -EINVAL;
2182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002183
2184 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
2185
2186 if (!VOS_IS_STATUS_SUCCESS(vos_status))
2187 {
2188 hddLog(VOS_TRACE_LEVEL_ERROR,
2189 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002190 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 return VOS_STATUS_E_FAILURE;
2192 }
2193
2194 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
2195 }
2196
2197 EXIT();
2198
2199 return vos_status;
2200}
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302201
2202static int iw_get_bitrate(struct net_device *dev,
2203 struct iw_request_info *info,
2204 union iwreq_data *wrqu, char *extra)
2205{
2206 int ret;
2207
2208 vos_ssr_protect(__func__);
2209 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2210 vos_ssr_unprotect(__func__);
2211
2212 return ret;
2213}
2214
2215
Jeff Johnson295189b2012-06-20 16:38:30 -07002216/* ccm call back function */
2217
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302218static int __iw_set_bitrate(struct net_device *dev,
2219 struct iw_request_info *info,
2220 union iwreq_data *wrqu,
2221 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002222{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302223 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302225 hdd_station_ctx_t *pHddStaCtx;
2226 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2228 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2229 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2230 v_U32_t i, rate;
2231 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302232 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002233
2234 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302235 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2236 if (NULL == pAdapter)
2237 {
2238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2239 "%s: Adapter is NULL",__func__);
2240 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 }
2242
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302243 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2244 ret = wlan_hdd_validate_context(pHddCtx);
2245 if (0 != ret)
2246 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302247 return ret;
2248 }
2249
2250 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2251 if (NULL == pHddStaCtx)
2252 {
2253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2254 "%s: STA Context is NULL",__func__);
2255 return -EINVAL;
2256 }
2257
2258
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302260 if (NULL == pWextState)
2261 {
2262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2263 "%s: pWextState is NULL",__func__);
2264 return -EINVAL;
2265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002266
2267 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2268 {
2269 return -ENXIO ;
2270 }
2271
2272 rate = wrqu->bitrate.value;
2273
2274 if (rate == -1)
2275 {
2276 rate = WNI_CFG_FIXED_RATE_AUTO;
2277 valid_rate = TRUE;
2278 }
2279 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2280 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2281 {
2282 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2283 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2284 {
2285 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2286 WNI_CFG_SUPPORTED_RATES_11A,
2287 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
2288 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
2289 WNI_CFG_SUPPORTED_RATES_11B,
2290 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
2291 {
2292 for (i = 0; i < (b_len + a_len); ++i)
2293 {
2294 /* supported rates returned is double the actual rate so we divide it by 2 */
2295 if ((supp_rates[i]&0x7F)/2 == rate)
2296 {
2297 valid_rate = TRUE;
2298 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
2299 break;
2300 }
2301 }
2302 }
2303 }
2304 }
2305 if (valid_rate != TRUE)
2306 {
2307 return -EINVAL;
2308 }
2309 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
2310 WNI_CFG_FIXED_RATE, rate,
2311 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
2312 {
c_hpothub8245442013-11-20 23:41:09 +05302313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2314 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 return -EIO;
2316 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302317
2318 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 return 0;
2320}
2321
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302322static int iw_set_bitrate(struct net_device *dev,
2323 struct iw_request_info *info,
2324 union iwreq_data *wrqu,
2325 char *extra)
2326{
2327 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002328
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302329 vos_ssr_protect(__func__);
2330 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2331 vos_ssr_unprotect(__func__);
2332
2333 return ret;
2334}
2335
2336static int __iw_set_genie(struct net_device *dev,
2337 struct iw_request_info *info,
2338 union iwreq_data *wrqu,
2339 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002340{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302341 hdd_adapter_t *pAdapter;
2342 hdd_context_t *pHddCtx;
2343 hdd_wext_state_t *pWextState;
2344 u_int8_t *genie = NULL;
2345 u_int8_t *base_genie = NULL;
2346 v_U16_t remLen;
2347 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002348
2349 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002350
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302351 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2352 if (NULL == pAdapter)
2353 {
2354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2355 "%s: Adapter is NULL",__func__);
2356 return -EINVAL;
2357 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002358
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302359 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2360 ret = wlan_hdd_validate_context(pHddCtx);
2361 if (0 != ret)
2362 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302363 return ret;
2364 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002365
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302366 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2367 if (NULL == pWextState)
2368 {
2369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2370 "%s: pWextState is NULL",__func__);
2371 return -EINVAL;
2372 }
Arif Hussain24bfa702014-01-22 13:51:30 -08002373
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302374 if (!wrqu->data.length) {
2375 hdd_clearRoamProfileIe(pAdapter);
2376 EXIT();
2377 return 0;
2378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002379
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302380 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2381 wrqu->data.length);
2382 if (NULL == base_genie)
2383 {
2384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2385 "mem_alloc_copy_from_user_helper fail");
2386 return -ENOMEM;
2387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002388
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302389 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07002390
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302391 remLen = wrqu->data.length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002392
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302393 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
2394
2395 /* clear any previous genIE before this call */
2396 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
2397
2398 while (remLen >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 {
2400 v_U16_t eLen = 0;
2401 v_U8_t elementId;
2402 elementId = *genie++;
2403 eLen = *genie++;
2404 remLen -= 2;
2405
Arif Hussain6d2a3322013-11-17 19:50:10 -08002406 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 __func__, elementId, eLen);
2408
2409 switch ( elementId )
2410 {
2411 case IE_EID_VENDOR:
2412 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08002413 {
2414 kfree(base_genie);
2415 return -EINVAL;
2416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002417
2418 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
2419 {
2420 v_U16_t curGenIELen = pWextState->genIE.length;
2421 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2422 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2423
2424 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2425 {
2426 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002427 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002429 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 return -ENOMEM;
2431 }
2432 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2433 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2434 pWextState->genIE.length += eLen + 2;
2435 }
2436 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
2437 {
2438 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
2439 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2440 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2441 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
2442 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
2443 }
2444 else /* any vendorId except WPA IE should be accumulated to genIE */
2445 {
2446 v_U16_t curGenIELen = pWextState->genIE.length;
2447 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
2448 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
2449
2450 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
2451 {
2452 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002453 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08002455 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 return -ENOMEM;
2457 }
2458 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
2459 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
2460 pWextState->genIE.length += eLen + 2;
2461 }
2462 break;
2463 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002464 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
2466 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
2467 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
2468 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2469 break;
2470
2471 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002472 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08002473 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 return 0;
2475 }
2476 genie += eLen;
2477 remLen -= eLen;
2478 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302479
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08002481 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 return 0;
2483}
2484
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302485static int iw_set_genie(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 struct iw_request_info *info,
2487 union iwreq_data *wrqu,
2488 char *extra)
2489{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302490 int ret;
2491
2492 vos_ssr_protect(__func__);
2493 ret = __iw_set_genie(dev, info, wrqu, extra);
2494 vos_ssr_unprotect(__func__);
2495
2496 return ret;
2497}
2498
2499static int __iw_get_genie(struct net_device *dev,
2500 struct iw_request_info *info,
2501 union iwreq_data *wrqu,
2502 char *extra)
2503{
Jeff Johnson295189b2012-06-20 16:38:30 -07002504 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302505 hdd_context_t *pHddCtx;
2506 hdd_adapter_t *pAdapter;
2507 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 eHalStatus status;
2509 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
2510 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2511
2512 ENTER();
2513
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302514 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2515 if (NULL == pAdapter)
2516 {
2517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2518 "%s: Adapter is NULL",__func__);
2519 return -EINVAL;
2520 }
2521 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2522 status = wlan_hdd_validate_context(pHddCtx);
2523 if (0 != status)
2524 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302525 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 }
2527
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302529 if (NULL == pWextState)
2530 {
2531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2532 "%s: pWextState is NULL",__func__);
2533 return -EINVAL;
2534 }
2535
2536 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2537 if (NULL == pHddStaCtx)
2538 {
2539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2540 "%s: STA Context is NULL",__func__);
2541 return -EINVAL;
2542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002543
2544 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
2545 {
2546 return -ENXIO;
2547 }
2548
2549 // Return something ONLY if we are associated with an RSN or WPA network
2550 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
2551 pWextState->roamProfile.negotiatedAuthType))
2552 {
2553 return -ENXIO;
2554 }
2555
2556 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2557 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2558 pAdapter->sessionId,
2559 &length,
2560 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002561 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2562 if (wrqu->data.length < length)
2563 {
2564 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2565 return -EFAULT;
2566 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002567 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002568 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002569
Arif Hussain6d2a3322013-11-17 19:50:10 -08002570 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002571
2572 EXIT();
2573
2574 return 0;
2575}
2576
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302577static int iw_get_genie(struct net_device *dev,
2578 struct iw_request_info *info,
2579 union iwreq_data *wrqu,
2580 char *extra)
2581{
2582 int ret;
2583
2584 vos_ssr_protect(__func__);
2585 ret = __iw_get_genie(dev, info, wrqu, extra);
2586 vos_ssr_unprotect(__func__);
2587
2588 return ret;
2589}
2590
2591
2592static int __iw_get_encode(struct net_device *dev,
2593 struct iw_request_info *info,
2594 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002595{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302596 hdd_adapter_t *pAdapter;
2597 hdd_context_t *pHddCtx;
2598 hdd_wext_state_t *pWextState;
2599 tCsrRoamProfile *pRoamProfile;
2600 int keyId, i, ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002602
2603 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302604 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2605 if (NULL == pAdapter)
2606 {
2607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2608 "%s: Adapter is NULL",__func__);
2609 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 }
2611
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302612 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2613 ret = wlan_hdd_validate_context(pHddCtx);
2614 if (0 != ret)
2615 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302616 return ret;
2617 }
2618 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2619 if (NULL == pWextState)
2620 {
2621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2622 "%s: pWextState is NULL",__func__);
2623 return -EINVAL;
2624 }
2625
2626 pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 keyId = pRoamProfile->Keys.defaultIndex;
2628
2629 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2630 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002631 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 return -EINVAL;
2633 }
2634
2635 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2636 {
2637 dwrq->flags |= IW_ENCODE_ENABLED;
2638 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2639 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2640
2641 dwrq->flags |= (keyId + 1);
2642
2643 }
2644 else
2645 {
2646 dwrq->flags |= IW_ENCODE_DISABLED;
2647 }
2648
2649 for(i=0; i < MAX_WEP_KEYS; i++)
2650 {
2651 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2652 {
2653 continue;
2654 }
2655 else
2656 {
2657 break;
2658 }
2659 }
2660
2661 if(MAX_WEP_KEYS == i)
2662 {
2663 dwrq->flags |= IW_ENCODE_NOKEY;
2664 }
2665
2666 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2667
2668 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2669 {
2670 dwrq->flags |= IW_ENCODE_OPEN;
2671 }
2672 else
2673 {
2674 dwrq->flags |= IW_ENCODE_RESTRICTED;
2675 }
2676 EXIT();
2677 return 0;
2678}
2679
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302680static int iw_get_encode(struct net_device *dev,
2681 struct iw_request_info *info,
2682 struct iw_point *dwrq, char *extra)
2683{
2684 int ret;
2685
2686 vos_ssr_protect(__func__);
2687 ret = __iw_get_encode(dev, info, dwrq, extra);
2688 vos_ssr_unprotect(__func__);
2689
2690 return ret;
2691}
2692
Jeff Johnson295189b2012-06-20 16:38:30 -07002693#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2694#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2695
2696
2697/*
2698 * This function sends a single 'key' to LIM at all time.
2699 */
2700
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302701static int __iw_get_rts_threshold(struct net_device *dev,
2702 struct iw_request_info *info,
2703 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002704{
2705 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2706 v_U32_t status = 0;
2707
2708 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2709
2710 return status;
2711}
2712
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302713static int iw_get_rts_threshold(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 struct iw_request_info *info,
2715 union iwreq_data *wrqu, char *extra)
2716{
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302717 int ret;
2718
2719 vos_ssr_protect(__func__);
2720 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
2721 vos_ssr_unprotect(__func__);
2722
2723 return ret;
2724}
2725
2726static int __iw_set_rts_threshold(struct net_device *dev,
2727 struct iw_request_info *info,
2728 union iwreq_data *wrqu, char *extra)
2729{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302730 hdd_adapter_t *pAdapter;
2731 hdd_context_t *pHddCtx;
2732 tHalHandle hHal;
2733 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002734
2735 ENTER();
2736
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302737 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2738 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002739 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2741 "%s: Adapter is NULL",__func__);
2742 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002743 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302744
2745 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2746 ret = wlan_hdd_validate_context(pHddCtx);
2747 if (0 != ret)
2748 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302749 return ret;
2750 }
2751
2752 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2753 if (NULL == hHal)
2754 {
2755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2756 "%s: Hal Context is NULL",__func__);
2757 return -EINVAL;
2758 }
2759
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2761 {
2762 return -EINVAL;
2763 }
2764
2765 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2766 {
c_hpothub8245442013-11-20 23:41:09 +05302767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2768 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 return -EIO;
2770 }
2771
2772 EXIT();
2773
2774 return 0;
2775}
2776
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302777static int iw_set_rts_threshold(struct net_device *dev,
2778 struct iw_request_info *info,
2779 union iwreq_data *wrqu, char *extra)
2780{
2781 int ret;
2782
2783 vos_ssr_protect(__func__);
2784 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
2785 vos_ssr_unprotect(__func__);
2786
2787 return ret;
2788}
2789
2790static int __iw_get_frag_threshold(struct net_device *dev,
2791 struct iw_request_info *info,
2792 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002793{
2794 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2795 v_U32_t status = 0;
2796
2797 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2798
2799 return status;
2800}
2801
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302802static int iw_get_frag_threshold(struct net_device *dev,
2803 struct iw_request_info *info,
2804 union iwreq_data *wrqu, char *extra)
2805{
2806 int ret;
2807
2808 vos_ssr_protect(__func__);
2809 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
2810 vos_ssr_unprotect(__func__);
2811
2812 return ret;
2813}
2814
2815static int __iw_set_frag_threshold(struct net_device *dev,
2816 struct iw_request_info *info,
2817 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002818{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302819 hdd_adapter_t *pAdapter;
2820 hdd_context_t *pHddCtx;
2821 tHalHandle hHal;
2822 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002823
2824 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302825 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2826 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002827 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2829 "%s: Adapter is NULL",__func__);
2830 return -EINVAL;
2831 }
2832
2833 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2834 ret = wlan_hdd_validate_context(pHddCtx);
2835 if (0 != ret)
2836 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302837 return ret;
2838 }
2839
2840 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2841 if (NULL == hHal)
2842 {
2843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2844 "%s: Hal Context is NULL",__func__);
2845 return -EINVAL;
2846 }
2847
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2849 {
2850 return -EINVAL;
2851 }
2852
2853 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2854 {
c_hpothub8245442013-11-20 23:41:09 +05302855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2856 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 return -EIO;
2858 }
2859
2860 EXIT();
2861
2862 return 0;
2863}
2864
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302865static int iw_set_frag_threshold(struct net_device *dev,
2866 struct iw_request_info *info,
2867 union iwreq_data *wrqu, char *extra)
2868{
2869 int ret;
2870
2871 vos_ssr_protect(__func__);
2872 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
2873 vos_ssr_unprotect(__func__);
2874
2875 return ret;
2876}
2877
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302878static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 struct iw_request_info *info,
2880 union iwreq_data *wrqu, char *extra)
2881{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302882 hdd_adapter_t *pAdapter;
2883 hdd_context_t *pHddCtx;
2884 int ret = 0;
2885
Jeff Johnson295189b2012-06-20 16:38:30 -07002886 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302887 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2888 if (NULL == pAdapter)
2889 {
2890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2891 "%s: Adapter is NULL",__func__);
2892 return -EINVAL;
2893 }
2894 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2895 ret = wlan_hdd_validate_context(pHddCtx);
2896 if (0 != ret)
2897 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302898 return ret;
2899 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302900
2901 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 return -EOPNOTSUPP;
2903}
2904
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302905static int iw_get_power_mode(struct net_device *dev,
2906 struct iw_request_info *info,
2907 union iwreq_data *wrqu, char *extra)
2908{
2909 int ret;
2910
2911 vos_ssr_protect(__func__);
2912 ret = __iw_get_power_mode(dev, info, wrqu, extra);
2913 vos_ssr_unprotect(__func__);
2914
2915 return ret;
2916}
2917static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 struct iw_request_info *info,
2919 union iwreq_data *wrqu, char *extra)
2920{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302921 hdd_adapter_t *pAdapter;
2922 hdd_context_t *pHddCtx;
2923 int ret = 0;
2924
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302926 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2927 if (NULL == pAdapter)
2928 {
2929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2930 "%s: Adapter is NULL",__func__);
2931 return -EINVAL;
2932 }
2933 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2934 ret = wlan_hdd_validate_context(pHddCtx);
2935 if (0 != ret)
2936 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302937 return ret;
2938 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302939
2940 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 return -EOPNOTSUPP;
2942}
2943
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05302944static int iw_set_power_mode(struct net_device *dev,
2945 struct iw_request_info *info,
2946 union iwreq_data *wrqu, char *extra)
2947{
2948 int ret;
2949
2950 vos_ssr_protect(__func__);
2951 ret = __iw_set_power_mode(dev, info, wrqu, extra);
2952 vos_ssr_unprotect(__func__);
2953
2954 return ret;
2955}
2956
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05302957static int __iw_get_range(struct net_device *dev,
2958 struct iw_request_info *info,
2959 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07002960{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302961 hdd_adapter_t *pAdapter;
2962 tHalHandle hHal;
2963 hdd_context_t *pHddCtx;
2964 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 struct iw_range *range = (struct iw_range *) extra;
2966
2967 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2968
2969 v_U32_t num_channels = sizeof(channels);
2970 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2971 v_U32_t a_len;
2972 v_U32_t b_len;
2973 v_U32_t active_phy_mode = 0;
2974 v_U8_t index = 0, i;
2975
2976 ENTER();
2977
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302978 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2979 if (NULL == pAdapter)
2980 {
2981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2982 "%s: pAdapter is NULL", __func__);
2983 return -EINVAL;
2984 }
2985 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2986 ret = wlan_hdd_validate_context(pHddCtx);
2987 if (0 != ret)
2988 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302989 return ret;
2990 }
2991 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2992 if (NULL == hHal)
2993 {
2994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2995 "%s: pAdapter is NULL", __func__);
2996 return -EINVAL;
2997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 wrqu->data.length = sizeof(struct iw_range);
2999 memset(range, 0, sizeof(struct iw_range));
3000
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 /*Get the phy mode*/
3002 if (ccmCfgGetInt(hHal,
3003 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
3004 {
3005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003006 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003007
3008 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
3009 {
3010 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003011 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 if (ccmCfgGetStr(hHal,
3013 WNI_CFG_SUPPORTED_RATES_11A,
3014 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
3015 {
3016 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
3017 {
3018 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3019 }
3020 for (i = 0; i < a_len; i++)
3021 {
3022 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3023 }
3024 range->num_bitrates = a_len;
3025 }
3026 else
3027 {
3028 return -EIO;
3029 }
3030 }
3031 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
3032 {
3033 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07003034 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 if (ccmCfgGetStr(hHal,
3036 WNI_CFG_SUPPORTED_RATES_11B,
3037 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
3038 {
3039 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
3040 {
3041 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3042 }
3043 for (i = 0; i < b_len; i++)
3044 {
3045 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
3046 }
3047 range->num_bitrates = b_len;
3048 }
3049 else
3050 {
3051 return -EIO;
3052 }
3053 }
3054 }
3055
3056 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3057 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3058 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3059
3060 range->encoding_size[0] = 5;
3061 range->encoding_size[1] = 13;
3062 range->num_encoding_sizes = 2;
3063 range->max_encoding_tokens = MAX_WEP_KEYS;
3064
3065 // we support through Wireless Extensions 22
3066 range->we_version_compiled = WIRELESS_EXT;
3067 range->we_version_source = 22;
3068
3069 /*Supported Channels and Frequencies*/
3070 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
3071 {
c_hpothub8245442013-11-20 23:41:09 +05303072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3073 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 return -EIO;
3075 }
3076 if (num_channels > IW_MAX_FREQUENCIES)
3077 {
3078 num_channels = IW_MAX_FREQUENCIES;
3079 }
3080
3081 range->num_channels = num_channels;
3082 range->num_frequency = num_channels;
3083
3084 for (index=0; index < num_channels; index++)
3085 {
3086 v_U32_t frq_indx = 0;
3087
3088 range->freq[index].i = channels[index];
3089 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
3090 {
3091 if(channels[index] == freq_chan_map[frq_indx].chan)
3092 {
3093 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
3094 range->freq[index].e = 1;
3095 break;
3096 }
3097 frq_indx++;
3098 }
3099 }
3100
3101 /* Event capability (kernel + driver) */
3102 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3103 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3104 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3105 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3106
3107 /*Encryption capability*/
3108 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3109 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3110
3111 /* Txpower capability */
3112 range->txpower_capa = IW_TXPOW_MWATT;
3113
3114 /*Scanning capability*/
3115 #if WIRELESS_EXT >= 22
3116 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3117 #endif
3118
3119 EXIT();
3120 return 0;
3121}
3122
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05303123static int iw_get_range(struct net_device *dev,
3124 struct iw_request_info *info,
3125 union iwreq_data *wrqu, char *extra)
3126{
3127 int ret;
3128
3129 vos_ssr_protect(__func__);
3130 ret = __iw_get_range(dev, info, wrqu, extra);
3131 vos_ssr_unprotect(__func__);
3132
3133 return ret;
3134}
3135
Jeff Johnson295189b2012-06-20 16:38:30 -07003136/* Callback function registered with PMC to know status of PMC request */
3137static void iw_power_callback_fn (void *pContext, eHalStatus status)
3138{
3139 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003140
3141 if (NULL == pContext)
3142 {
3143 hddLog(VOS_TRACE_LEVEL_ERROR,
3144 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003145 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 return;
3147 }
3148
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003150
Jeff Johnson72a40512013-12-19 10:14:15 -08003151 /* there is a race condition that exists between this callback
3152 function and the caller since the caller could time out either
3153 before or while this code is executing. we use a spinlock to
3154 serialize these actions */
3155 spin_lock(&hdd_context_lock);
3156
3157 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 {
3159 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003160 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08003162 "%s: Invalid context, magic [%08x]",
3163 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003164
3165 if (ioctl_debug)
3166 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003167 pr_info("%s: Invalid context, magic [%08x]\n",
3168 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 }
3170 return;
3171 }
3172
Jeff Johnson72a40512013-12-19 10:14:15 -08003173 /* context is valid so caller is still waiting */
3174
3175 /* paranoia: invalidate the magic */
3176 pStatsContext->magic = 0;
3177
3178 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003180
3181 /* serialization is complete */
3182 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003183}
3184
3185/* Callback function for tx per hit */
3186void hdd_tx_per_hit_cb (void *pCallbackContext)
3187{
3188 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
3189 unsigned char tx_fail[16];
3190 union iwreq_data wrqu;
3191
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05303192 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003194 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 return;
3196 }
3197 memset(&wrqu, 0, sizeof(wrqu));
3198 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
3199 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
3200}
3201
3202void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
3203{
3204 struct statsContext *pStatsContext;
3205 tCsrGlobalClassAStatsInfo *pClassAStats;
3206 hdd_adapter_t *pAdapter;
3207
3208 if (ioctl_debug)
3209 {
3210 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003211 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 }
3213
3214 if ((NULL == pStats) || (NULL == pContext))
3215 {
3216 hddLog(VOS_TRACE_LEVEL_ERROR,
3217 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003218 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 return;
3220 }
3221
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 pClassAStats = pStats;
3223 pStatsContext = pContext;
3224 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08003225
3226 /* there is a race condition that exists between this callback
3227 function and the caller since the caller could time out either
3228 before or while this code is executing. we use a spinlock to
3229 serialize these actions */
3230 spin_lock(&hdd_context_lock);
3231
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3233 {
3234 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003235 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003236 hddLog(VOS_TRACE_LEVEL_WARN,
3237 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003238 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 if (ioctl_debug)
3240 {
3241 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003242 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 }
3244 return;
3245 }
3246
Jeff Johnson72a40512013-12-19 10:14:15 -08003247 /* context is valid so caller is still waiting */
3248
3249 /* paranoia: invalidate the magic */
3250 pStatsContext->magic = 0;
3251
3252 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3254
Jeff Johnson72a40512013-12-19 10:14:15 -08003255 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003257
3258 /* serialization is complete */
3259 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003260}
3261
3262VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
3263{
3264 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3265 eHalStatus hstatus;
3266 long lrc;
3267 struct statsContext context;
3268
3269 if (NULL == pAdapter)
3270 {
3271 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3272 return VOS_STATUS_E_FAULT;
3273 }
3274 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3275 {
3276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
3277 return VOS_STATUS_SUCCESS;
3278 }
3279
3280 /* we are connected
3281 prepare our callback context */
3282 init_completion(&context.completion);
3283 context.pAdapter = pAdapter;
3284 context.magic = STATS_CONTEXT_MAGIC;
3285 /* query only for Class A statistics (which include link speed) */
3286 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
3287 eCSR_HDD,
3288 SME_GLOBAL_CLASSA_STATS,
3289 hdd_GetClassA_statisticsCB,
3290 0, // not periodic
3291 FALSE, //non-cached results
3292 pHddStaCtx->conn_info.staId[0],
3293 &context);
3294 if (eHAL_STATUS_SUCCESS != hstatus)
3295 {
3296 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08003297 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003298 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 /* we'll returned a cached value below */
3300 }
3301 else
3302 {
3303 /* request was sent -- wait for the response */
3304 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3305 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 if (lrc <= 0)
3307 {
3308 hddLog(VOS_TRACE_LEVEL_ERROR,
3309 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003310 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 }
3312 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003313
3314 /* either we never sent a request, we sent a request and received a
3315 response or we sent a request and timed out. if we never sent a
3316 request or if we sent a request and got a response, we want to
3317 clear the magic out of paranoia. if we timed out there is a
3318 race condition such that the callback function could be
3319 executing at the same time we are. of primary concern is if the
3320 callback function had already verified the "magic" but had not
3321 yet set the completion variable when a timeout occurred. we
3322 serialize these activities by invalidating the magic while
3323 holding a shared spinlock which will cause us to block if the
3324 callback is currently executing */
3325 spin_lock(&hdd_context_lock);
3326 context.magic = 0;
3327 spin_unlock(&hdd_context_lock);
3328
3329 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 return VOS_STATUS_SUCCESS;
3331}
3332
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003333static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
3334{
3335 struct statsContext *pStatsContext;
3336 tCsrSummaryStatsInfo *pSummaryStats;
3337 tCsrGlobalClassAStatsInfo *pClassAStats;
3338 hdd_adapter_t *pAdapter;
3339
3340 if (ioctl_debug)
3341 {
3342 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003343 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003344 }
3345
3346 if ((NULL == pStats) || (NULL == pContext))
3347 {
3348 hddLog(VOS_TRACE_LEVEL_ERROR,
3349 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003350 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003351 return;
3352 }
3353
Jeff Johnson72a40512013-12-19 10:14:15 -08003354 /* there is a race condition that exists between this callback
3355 function and the caller since the caller could time out either
3356 before or while this code is executing. we use a spinlock to
3357 serialize these actions */
3358 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003359
3360 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
3361 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
3362 pStatsContext = pContext;
3363 pAdapter = pStatsContext->pAdapter;
3364 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
3365 {
3366 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08003367 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003368 hddLog(VOS_TRACE_LEVEL_WARN,
3369 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003370 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003371 if (ioctl_debug)
3372 {
3373 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003374 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003375 }
3376 return;
3377 }
3378
Jeff Johnson72a40512013-12-19 10:14:15 -08003379 /* context is valid so caller is still waiting */
3380
3381 /* paranoia: invalidate the magic */
3382 pStatsContext->magic = 0;
3383
3384 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003385 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3386 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3387
Jeff Johnson72a40512013-12-19 10:14:15 -08003388 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003389 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08003390
3391 /* serialization is complete */
3392 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003393}
3394
3395VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
3396{
3397 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3398 eHalStatus hstatus;
3399 long lrc;
3400 struct statsContext context;
3401
3402 if (NULL == pAdapter)
3403 {
3404 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
3405 return VOS_STATUS_SUCCESS;
3406 }
3407
3408 /* we are connected
3409 prepare our callback context */
3410 init_completion(&context.completion);
3411 context.pAdapter = pAdapter;
3412 context.magic = STATS_CONTEXT_MAGIC;
3413
3414 /* query only for Summary & Class A statistics */
3415 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3416 eCSR_HDD,
3417 SME_SUMMARY_STATS |
3418 SME_GLOBAL_CLASSA_STATS,
3419 hdd_get_station_statisticsCB,
3420 0, // not periodic
3421 FALSE, //non-cached results
3422 pHddStaCtx->conn_info.staId[0],
3423 &context);
3424 if (eHAL_STATUS_SUCCESS != hstatus)
3425 {
3426 hddLog(VOS_TRACE_LEVEL_ERROR,
3427 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003428 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003429 /* we'll return with cached values */
3430 }
3431 else
3432 {
3433 /* request was sent -- wait for the response */
3434 lrc = wait_for_completion_interruptible_timeout(&context.completion,
3435 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08003436
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003437 if (lrc <= 0)
3438 {
3439 hddLog(VOS_TRACE_LEVEL_ERROR,
3440 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003441 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003442 }
3443 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003444
3445 /* either we never sent a request, we sent a request and received a
3446 response or we sent a request and timed out. if we never sent a
3447 request or if we sent a request and got a response, we want to
3448 clear the magic out of paranoia. if we timed out there is a
3449 race condition such that the callback function could be
3450 executing at the same time we are. of primary concern is if the
3451 callback function had already verified the "magic" but had not
3452 yet set the completion variable when a timeout occurred. we
3453 serialize these activities by invalidating the magic while
3454 holding a shared spinlock which will cause us to block if the
3455 callback is currently executing */
3456 spin_lock(&hdd_context_lock);
3457 context.magic = 0;
3458 spin_unlock(&hdd_context_lock);
3459
3460 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07003461 return VOS_STATUS_SUCCESS;
3462}
3463
3464
Jeff Johnson295189b2012-06-20 16:38:30 -07003465/*
3466 * Support for the LINKSPEED private command
3467 * Per the WiFi framework the response must be of the form
3468 * "LinkSpeed xx"
3469 */
3470static int iw_get_linkspeed(struct net_device *dev,
3471 struct iw_request_info *info,
3472 union iwreq_data *wrqu, char *extra)
3473{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303474 hdd_adapter_t *pAdapter;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303475 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303477 int len = sizeof(v_U32_t) + 1;
3478 v_U32_t link_speed;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303479 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303480 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303481 int rc, valid = 0;
3482
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303483 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303484 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3485 if (NULL == pAdapter)
3486 {
3487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3488 "%s: Adapter is NULL",__func__);
3489 return -EINVAL;
3490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003491
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303492 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303493 valid = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303494 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003495 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303496 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003497 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303498 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3499 if (NULL == pHddStaCtx)
3500 {
3501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3502 "%s: STA Context is NULL",__func__);
3503 return -EINVAL;
3504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
3506 {
3507 /* we are not connected so we don't have a classAstats */
3508 link_speed = 0;
3509 }
3510 else
3511 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303512 status = wlan_hdd_get_classAstats(pAdapter);
3513
3514 if (!VOS_IS_STATUS_SUCCESS(status ))
3515 {
3516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
3517 return -EINVAL;
3518 }
3519
3520 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
3521 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
3522 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
3523 &link_speed);
3524
3525 link_speed = link_speed / 10;
3526
3527 if (0 == link_speed)
3528 {
3529 /* The linkspeed returned by HAL is in units of 500kbps.
3530 * converting it to mbps.
3531 * This is required to support legacy firmware which does
3532 * not return link capacity.
3533 */
3534 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
3535 }
3536
Jeff Johnson295189b2012-06-20 16:38:30 -07003537 }
3538
3539 wrqu->data.length = len;
3540 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07003541 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 if ((rc < 0) || (rc >= len))
3543 {
3544 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05303545 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 return -EIO;
3547 }
3548
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303549 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003551 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003552}
3553
Arif Hussain695279c2014-03-24 14:06:07 -07003554/*
3555 * Helper function to return correct value for WLAN_GET_LINK_SPEED
3556 *
3557 */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303558static int __iw_get_linkspeed_priv(struct net_device *dev,
Arif Hussain695279c2014-03-24 14:06:07 -07003559 struct iw_request_info *info,
3560 union iwreq_data *wrqu, char *extra)
3561{
3562 int rc;
3563
3564 rc = iw_get_linkspeed(dev, info, wrqu, extra);
3565
3566 if (rc < 0)
3567 return rc;
3568
3569 /* a value is being successfully returned */
3570 return 0;
3571}
Jeff Johnson295189b2012-06-20 16:38:30 -07003572
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05303573static int iw_get_linkspeed_priv(struct net_device *dev,
3574 struct iw_request_info *info,
3575 union iwreq_data *wrqu, char *extra)
3576{
3577 int ret;
3578
3579 vos_ssr_protect(__func__);
3580 ret = __iw_get_linkspeed_priv(dev, info, wrqu, extra);
3581 vos_ssr_unprotect(__func__);
3582
3583 return ret;
3584}
3585
Jeff Johnson295189b2012-06-20 16:38:30 -07003586/*
3587 * Support for the RSSI & RSSI-APPROX private commands
3588 * Per the WiFi framework the response must be of the form
3589 * "<ssid> rssi <xx>"
3590 * unless we are not associated, in which case the response is
3591 * "OK"
3592 */
3593static int iw_get_rssi(struct net_device *dev,
3594 struct iw_request_info *info,
3595 union iwreq_data *wrqu, char *extra)
3596{
3597 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003598 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 int len = wrqu->data.length;
3600 v_S7_t s7Rssi = 0;
3601 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3602 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
3603 VOS_STATUS vosStatus;
3604 int rc;
3605
3606 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
3607 (0 == ssidlen) || (ssidlen >= len))
3608 {
3609 /* we are not connected or our SSID is too long
3610 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003611 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 }
3613 else
3614 {
3615 /* we are connected with a valid SSID
3616 so we can write the SSID into the return buffer
3617 (note that it is not NUL-terminated) */
3618 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
3619
3620 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
3621
3622 if (VOS_STATUS_SUCCESS == vosStatus)
3623 {
3624 /* append the rssi to the ssid in the format required by
3625 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07003626 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05303627 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 }
3629 else
3630 {
3631 rc = -1;
3632 }
3633 }
3634
3635 /* verify that we wrote a valid response */
3636 if ((rc < 0) || (rc >= len))
3637 {
3638 // encoding or length error?
3639 hddLog(VOS_TRACE_LEVEL_ERROR,
3640 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003641 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 return -EIO;
3643 }
3644
3645 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08003646 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003647}
3648
3649/*
3650 * Support for SoftAP channel range private command
3651 */
3652static int iw_softap_set_channel_range( struct net_device *dev,
3653 int startChannel,
3654 int endChannel,
3655 int band)
3656{
Jeff Johnson43971f52012-07-17 12:26:56 -07003657 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 int ret = 0;
3659 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
3660 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003661 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
3662
Jeff Johnson295189b2012-06-20 16:38:30 -07003663
3664 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
3665 if (VOS_STATUS_SUCCESS != status)
3666 {
3667 ret = -EINVAL;
3668 }
Yathish9f22e662012-12-10 14:21:35 -08003669 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 return ret;
3671}
3672
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303673static uint8 chartohex(char c)
3674{
3675 uint8 val = 0;
3676 if (c >= '0' && c <= '9')
3677 val = c - '0';
3678 else if (c >= 'a' && c <= 'f')
3679 val = c - 'a' + 10;
3680 else if (c >= 'A' && c <= 'F')
3681 val = c - 'A' + 10;
3682 else
3683 hddLog(VOS_TRACE_LEVEL_ERROR, "Not a valid hex char");
3684
3685 return val;
3686}
3687
3688uint8 getByte(char **buf)
3689{
3690 uint8 byte = 0;
3691 char *temp = *buf;
3692 byte = chartohex(*temp) * 16;
3693 temp++;
3694 byte += chartohex(*temp);
3695 temp++;
3696 *buf = temp;
3697 return byte;
3698}
3699
3700static void parse_Bufferforpkt(tSirpkt80211 *pkt, u8 *pBuffer, u16 len)
3701{
3702 tSir80211Header *macHeader;
3703 int i = 0, j = 0, length = 0;
3704 uint8 byte = 0;
3705 char *temp = pBuffer;
3706 uint16 fragNum = 0;
Srinivas Dasari2382de62015-01-22 15:00:04 +05303707 char *pHeader;
3708 tSir80211Header header;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303709
3710 macHeader = &pkt->macHeader;
3711
3712 pkt->encParams.keyParams.key[0].keyId = *temp - '0';
3713
3714 temp++;
3715
3716 hddLog(VOS_TRACE_LEVEL_ERROR, "Input Message to encrypt");
3717 hddLog(VOS_TRACE_LEVEL_ERROR, "Key Id : %d",
3718 pkt->encParams.keyParams.key[0].keyId);
3719
3720 for (i = 0; i< 16; i++) {
3721 pkt->encParams.keyParams.key[0].key[i]
3722 = getByte(&temp);
3723 }
3724
3725 print_hex_dump(KERN_INFO, "Key : ", DUMP_PREFIX_NONE, 16, 1,
3726 &pkt->encParams.keyParams.key[0].key[0], 16, 0);
3727
3728 for (i = 0; i< 6; i++) {
3729 pkt->encParams.pn[i]
3730 = getByte(&temp);
3731 }
3732
3733 print_hex_dump(KERN_INFO, "PN : ", DUMP_PREFIX_NONE, 16, 1,
3734 &pkt->encParams.pn[0], 6, 0);
3735
3736 for (i = 0, j= 5; i< 3; i++, j--) {
3737 byte = pkt->encParams.pn[i];
3738 pkt->encParams.pn[i] = pkt->encParams.pn[j];
3739 pkt->encParams.pn[j] = byte;
3740 }
3741
3742 length = getByte(&temp);
Hema Aparna Medicharla2db83312015-03-09 15:58:21 +05303743 if (length > sizeof(tSir80211Header))
3744 length = sizeof(tSir80211Header);
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303745
Srinivas Dasari2382de62015-01-22 15:00:04 +05303746 pHeader = temp;
3747 vos_mem_zero(&header, sizeof(tSir80211Header));
3748 for (i = 0; i < length; i++) {
3749 *((uint8 *)&header + i) = getByte(&pHeader);
3750 }
3751
3752 print_hex_dump(KERN_INFO, "Header : ", DUMP_PREFIX_NONE, 16, 1,
3753 (char *)&header, length, 0);
3754
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303755 byte = getByte(&temp);
3756
3757 macHeader->frameCtrl.protVer = byte & 0x3;
3758 macHeader->frameCtrl.type = (byte >> 2) & 0x3;
3759 macHeader->frameCtrl.subType = (byte >> 4) & 0xF;
3760
3761 byte = getByte(&temp);
3762 macHeader->frameCtrl.toDS = (byte) & 0x1;
3763 macHeader->frameCtrl.fromDS = (byte >> 1) & 0x1;
3764 macHeader->frameCtrl.moreFrag = (byte >> 2) & 0x1;
3765 macHeader->frameCtrl.retry = (byte >> 3) & 0x1;
3766 macHeader->frameCtrl.powerMgmt = (byte >> 4) & 0x1;
3767 macHeader->frameCtrl.moreData = (byte >> 5) & 0x1;
3768 macHeader->frameCtrl.wep = (byte >> 6) & 0x1;
3769 macHeader->frameCtrl.order = (byte >> 7) & 0x1;
3770
3771 hddLog(VOS_TRACE_LEVEL_INFO, "macHeader->frameCtrl.protVer : %x "
3772 "macHeader->frameCtrl.type : %x "
3773 "macHeader->frameCtrl.subType : %x "
3774 "macHeader->frameCtrl.toDS : %x "
3775 "macHeader->frameCtrl.fromDS : %x "
3776 "macHeader->frameCtrl.moreFrag : %x "
3777 "macHeader->frameCtrl.retry : %x "
3778 "macHeader->frameCtrl.powerMgmt : %x "
3779 "macHeader->frameCtrl.MoreData : %x "
3780 "macHeader->frameCtrl.wep : %x "
3781 "macHeader->frameCtrl.order : %x "
3782 , macHeader->frameCtrl.protVer
3783 , macHeader->frameCtrl.type
3784 , macHeader->frameCtrl.subType
3785 , macHeader->frameCtrl.toDS
3786 , macHeader->frameCtrl.fromDS
3787 , macHeader->frameCtrl.moreFrag
3788 , macHeader->frameCtrl.retry
3789 , macHeader->frameCtrl.powerMgmt
3790 , macHeader->frameCtrl.moreData
3791 , macHeader->frameCtrl.wep
3792 , macHeader->frameCtrl.order);
3793
3794
3795 macHeader->usDurationId = getByte(&temp);
3796 macHeader->usDurationId += getByte(&temp) << 8;
3797
3798 macHeader->vA1[0] = getByte(&temp);
3799 macHeader->vA1[1] = getByte(&temp);
3800 macHeader->vA1[2] = getByte(&temp);
3801 macHeader->vA1[3] = getByte(&temp);
3802 macHeader->vA1[4] = getByte(&temp);
3803 macHeader->vA1[5] = getByte(&temp);
3804
3805 macHeader->vA2[0] = getByte(&temp);
3806 macHeader->vA2[1] = getByte(&temp);
3807 macHeader->vA2[2] = getByte(&temp);
3808 macHeader->vA2[3] = getByte(&temp);
3809 macHeader->vA2[4] = getByte(&temp);
3810 macHeader->vA2[5] = getByte(&temp);
3811
3812 macHeader->vA3[0] = getByte(&temp);
3813 macHeader->vA3[1] = getByte(&temp);
3814 macHeader->vA3[2] = getByte(&temp);
3815 macHeader->vA3[3] = getByte(&temp);
3816 macHeader->vA3[4] = getByte(&temp);
3817 macHeader->vA3[5] = getByte(&temp);
3818
3819 macHeader->sSeqCtrl = getByte(&temp);
3820 fragNum = macHeader->sSeqCtrl & 0xF;
3821 macHeader->sSeqCtrl >>= 4;
3822
3823 macHeader->sSeqCtrl += getByte(&temp) << 4;
3824
3825 macHeader->sSeqCtrl |= fragNum << 12;
3826
3827 if (length == 30 || length == 32) {
3828 macHeader->optvA4[0] = getByte(&temp);
3829 macHeader->optvA4[1] = getByte(&temp);
3830 macHeader->optvA4[2] = getByte(&temp);
3831 macHeader->optvA4[3] = getByte(&temp);
3832 macHeader->optvA4[4] = getByte(&temp);
3833 macHeader->optvA4[5] = getByte(&temp);
3834 }
3835
3836 if (length == 26 || length == 32) {
3837 macHeader->usQosCtrl = getByte(&temp);
3838 macHeader->usQosCtrl += getByte(&temp) << 8;
3839 }
3840
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05303841 //parse payload
3842 length = getByte(&temp);
3843 length += getByte(&temp) << 8;
3844 hddLog(VOS_TRACE_LEVEL_INFO,"Payload length : %d", length);
3845
3846 pkt->data.length = length;
3847
3848 for (i = 0; i< length; i++) {
3849 pkt->data.data[i] = getByte(&temp);
3850 }
3851
3852 print_hex_dump(KERN_INFO, "Data : ", DUMP_PREFIX_NONE, 16, 1,
3853 &pkt->data.data[0], pkt->data.length, 0);
3854}
3855
3856/**---------------------------------------------------------------------------
3857
3858 \brief hdd_encrypt_msg_cb() - Callback function for DISA
3859 encrypt message request
3860 This is an asynchronous callback function from SME when the encrypted data
3861 is received
3862
3863 \pEncInfoRsp -> Encrypted data info
3864
3865 \return - 0 for success non-zero for failure
3866 --------------------------------------------------------------------------*/
3867static void
3868hdd_encrypt_msg_cb(v_VOID_t *pUserData, v_VOID_t *pEncInfoRsp)
3869{
3870 tpSetEncryptedDataRspParams pEncryptedDataRsp;
3871
3872 pEncryptedDataRsp = (tpSetEncryptedDataRspParams)pEncInfoRsp;
3873
3874 hddLog(VOS_TRACE_LEVEL_ERROR, "Encrypted Message");
3875 hddLog(VOS_TRACE_LEVEL_ERROR, "Length : %d",
3876 pEncryptedDataRsp->encryptedPayload.length);
3877 hddLog(VOS_TRACE_LEVEL_ERROR, " Encrypted Data: ");
3878 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1,
3879 pEncryptedDataRsp->encryptedPayload.data,
3880 pEncryptedDataRsp->encryptedPayload.length, 0);
3881}
3882
Jeff Johnson295189b2012-06-20 16:38:30 -07003883VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
3884{
3885 struct statsContext context;
3886 eHalStatus status;
3887 hdd_context_t *pHddCtx;
3888
3889 if (NULL == pAdapter)
3890 {
3891 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
3892 return VOS_STATUS_E_FAULT;
3893 }
3894
3895 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
3896 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05303897 if (pHddCtx->isLogpInProgress) {
3898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3899 "%s:LOGP in Progress. Ignore!!!", __func__);
3900 return VOS_STATUS_E_FAILURE;
3901 }
3902
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 init_completion(&context.completion);
3904
3905 context.pAdapter = pAdapter;
3906 context.magic = POWER_CONTEXT_MAGIC;
3907
3908 if (DRIVER_POWER_MODE_ACTIVE == mode)
3909 {
3910 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
3911 "Full Power", __func__);
3912 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3913 iw_power_callback_fn, &context,
3914 eSME_FULL_PWR_NEEDED_BY_HDD);
3915 // Enter Full power command received from GUI this means we are disconnected
3916 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
3917 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
3918 if (eHAL_STATUS_PMC_PENDING == status)
3919 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003920 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 int lrc = wait_for_completion_interruptible_timeout(
3922 &context.completion,
3923 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08003924
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 if (lrc <= 0)
3926 {
3927 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003928 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 }
3930 }
3931 }
3932 else if (DRIVER_POWER_MODE_AUTO == mode)
3933 {
3934 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3935 {
3936 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
3937 __func__);
3938 // Enter BMPS command received from GUI this means DHCP is completed
3939 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
3940 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
3941 FALSE);
3942 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
3943 iw_power_callback_fn, &context);
3944 if (eHAL_STATUS_PMC_PENDING == status)
3945 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003946 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 int lrc = wait_for_completion_interruptible_timeout(
3948 &context.completion,
3949 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 if (lrc <= 0)
3951 {
Jeff Johnson72a40512013-12-19 10:14:15 -08003952 hddLog(VOS_TRACE_LEVEL_ERROR,
3953 "%s: SME %s while requesting BMPS",
3954 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 }
3956 }
3957 }
3958 else
3959 {
3960 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
3961 "enabled in the cfg");
3962 }
3963 }
Jeff Johnson72a40512013-12-19 10:14:15 -08003964
3965 /* either we never sent a request, we sent a request and received a
3966 response or we sent a request and timed out. if we never sent a
3967 request or if we sent a request and got a response, we want to
3968 clear the magic out of paranoia. if we timed out there is a
3969 race condition such that the callback function could be
3970 executing at the same time we are. of primary concern is if the
3971 callback function had already verified the "magic" but had not
3972 yet set the completion variable when a timeout occurred. we
3973 serialize these activities by invalidating the magic while
3974 holding a shared spinlock which will cause us to block if the
3975 callback is currently executing */
3976 spin_lock(&hdd_context_lock);
3977 context.magic = 0;
3978 spin_unlock(&hdd_context_lock);
3979
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 return VOS_STATUS_SUCCESS;
3981}
3982
3983VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
3984 hdd_adapter_t *pAdapter)
3985{
3986 VOS_STATUS vos_Status;
3987
3988 if ((NULL == pAdapter) || (NULL == pHddCtx))
3989 {
3990 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
3991 return VOS_STATUS_E_FAULT;
3992 }
3993
3994 /**Exit from Deep sleep or standby if we get the driver
3995 START cmd from android GUI
3996 */
3997 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3998 {
3999 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4000 "from Stand by",__func__);
4001 vos_Status = hdd_exit_standby(pHddCtx);
4002 }
4003 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
4004 {
4005 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
4006 "from deep sleep",__func__);
4007 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
4008 }
4009 else
4010 {
4011 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
4012 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
4013 vos_Status = VOS_STATUS_SUCCESS;
4014 }
4015
4016 return vos_Status;
4017}
4018
4019VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
4020{
4021 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
4022
4023 if (NULL == pHddCtx)
4024 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304025 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 return VOS_STATUS_E_FAULT;
4027 }
4028
4029 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
4030 {
4031 //Execute standby procedure.
4032 //Executing standby procedure will cause the STA to
4033 //disassociate first and then the chip will be put into standby.
4034 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
4035 vos_Status = hdd_enter_standby(pHddCtx);
4036 }
4037 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
4038 pHddCtx->cfg_ini->nEnableDriverStop)
4039 {
4040 //Execute deep sleep procedure
4041 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004042 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 //Deep sleep not supported
4044 vos_Status = hdd_enter_standby(pHddCtx);
4045 }
4046 else
4047 {
4048 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
4049 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
4050 vos_Status = VOS_STATUS_SUCCESS;
4051 }
4052
4053 return vos_Status;
4054}
4055
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004056
4057void* wlan_hdd_change_country_code_callback(void *pAdapter)
4058{
4059
4060 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004061 complete(&call_back_pAdapter->change_country_code);
4062
4063 return NULL;
4064}
4065
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304066static int __iw_set_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 struct iw_request_info *info,
4068 union iwreq_data *wrqu, char *extra)
4069{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304070 hdd_adapter_t *pAdapter;
Arif Hussain24bfa702014-01-22 13:51:30 -08004071 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 int cmd_len = wrqu->data.length;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304073 int rc = 0, ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08004074 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
4075
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304076 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004077
4078 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304079
4080 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4081 if (NULL == pAdapter)
4082 {
4083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4084 "mem_alloc_copy_from_user_helper fail");
4085 return -EINVAL;
4086 }
4087 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4088 rc = wlan_hdd_validate_context(pHddCtx);
4089 if (0 != rc)
4090 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304091 return rc;
4092 }
4093
Arif Hussain24bfa702014-01-22 13:51:30 -08004094 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4095 wrqu->data.length);
4096 if (NULL == cmd)
4097 {
4098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4099 "mem_alloc_copy_from_user_helper fail");
4100 return -ENOMEM;
4101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004102
4103 if (ioctl_debug)
4104 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004105 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 }
4107
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004108 hddLog(VOS_TRACE_LEVEL_INFO_MED,
4109 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004110
Arif Hussain24bfa702014-01-22 13:51:30 -08004111 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004113 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
4114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4115 "%s: Error in iw_set_scan!", __func__);
4116 rc = -EINVAL;
4117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 }
4119 else if( strcasecmp(cmd, "start") == 0 ) {
4120
Arif Hussain6d2a3322013-11-17 19:50:10 -08004121 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004123
Arif Hussain24bfa702014-01-22 13:51:30 -08004124 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
4125 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 {
4127 union iwreq_data wrqu;
4128 char buf[10];
4129
4130 memset(&wrqu, 0, sizeof(wrqu));
4131 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
4132 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4133 }
4134 else
4135 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004136 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
4137 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 }
4139 goto done;
4140 }
4141 else if( strcasecmp(cmd, "stop") == 0 )
4142 {
4143 union iwreq_data wrqu;
4144 char buf[10];
4145
Arif Hussain6d2a3322013-11-17 19:50:10 -08004146 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004147
4148 wlan_hdd_enter_lowpower(pHddCtx);
4149 memset(&wrqu, 0, sizeof(wrqu));
4150 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
4151 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 goto done;
4153 }
4154 else if (strcasecmp(cmd, "macaddr") == 0)
4155 {
4156 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
4157 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
4158 }
4159 else if (strcasecmp(cmd, "scan-active") == 0)
4160 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304161 hddLog(VOS_TRACE_LEVEL_ERROR,
4162 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004163 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 ret = snprintf(cmd, cmd_len, "OK");
4165 }
4166 else if (strcasecmp(cmd, "scan-passive") == 0)
4167 {
c_hpothudbefd3e2014-04-28 15:59:47 +05304168 hddLog(VOS_TRACE_LEVEL_ERROR,
4169 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004170 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 ret = snprintf(cmd, cmd_len, "OK");
4172 }
4173 else if( strcasecmp(cmd, "scan-mode") == 0 )
4174 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004175 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 }
4177 else if( strcasecmp(cmd, "linkspeed") == 0 )
4178 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004179 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 }
4181 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
4182 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004183 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08004184 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004185
4186 country_code = cmd + 8;
4187
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004188 init_completion(&pAdapter->change_country_code);
4189
Arif Hussain24bfa702014-01-22 13:51:30 -08004190 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004191 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 country_code,
4193 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304194 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304195 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304196 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004197
4198 /* Wait for completion */
4199 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
4200 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4201
4202 if (lrc <= 0)
4203 {
4204 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08004205 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004206 }
4207
Arif Hussain24bfa702014-01-22 13:51:30 -08004208 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004210 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08004211 "%s: SME Change Country code fail", __func__);
4212 kfree(cmd);
4213 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 }
4215 }
4216 else if( strncasecmp(cmd, "rssi", 4) == 0 )
4217 {
Arif Hussain24bfa702014-01-22 13:51:30 -08004218 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 }
4220 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
4221 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07004222 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004223
Wilson Yang1be3e652013-10-09 15:18:31 -07004224 if (9 < cmd_len)
4225 {
4226 ptr = (char*)(cmd + 9);
4227
4228 }else{
4229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4230 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004231 kfree(cmd);
4232 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004233 }
4234
4235 if (1 != sscanf(ptr,"%d",&mode))
4236 {
4237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4238 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004239 kfree(cmd);
4240 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004241 }
4242
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 wlan_hdd_enter_bmps(pAdapter, mode);
4244 /*TODO:Set the power mode*/
4245 }
4246 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
4247 v_U32_t pmc_state;
4248 v_U16_t value;
4249
4250 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
4251 if(pmc_state == BMPS) {
4252 value = DRIVER_POWER_MODE_AUTO;
4253 }
4254 else {
4255 value = DRIVER_POWER_MODE_ACTIVE;
4256 }
4257 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
4258 }
4259 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004260 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 /*TODO: set the btcoexmode*/
4262 }
4263 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
4264
Arif Hussain6d2a3322013-11-17 19:50:10 -08004265 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 /*TODO: Return the btcoex status*/
4267 }
4268 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
4269
Arif Hussain6d2a3322013-11-17 19:50:10 -08004270 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004271
4272 /*TODO: Enable Rx data Filter*/
4273 }
4274 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
4275
Arif Hussain6d2a3322013-11-17 19:50:10 -08004276 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004277
4278 /*TODO: Disable Rx data Filter*/
4279 }
4280 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
4281
Arif Hussain6d2a3322013-11-17 19:50:10 -08004282 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 /*TODO: rxfilter-statistics*/
4284 }
4285 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
4286
Arif Hussain6d2a3322013-11-17 19:50:10 -08004287 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 /*TODO: rxfilter-add*/
4289 }
4290 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
4291
Arif Hussain6d2a3322013-11-17 19:50:10 -08004292 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 /*TODO: rxfilter-remove*/
4294 }
4295#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07004296 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
4297 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
4298 /*TODO: support pnosetup*/
4299 }
4300 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
4301 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
4302 /*TODO: support pnoforce*/
4303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 else if( strncasecmp(cmd, "pno",3) == 0 ) {
4305
Arif Hussain6d2a3322013-11-17 19:50:10 -08004306 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08004307 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
4308 kfree(cmd);
4309 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 }
4311 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004312 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08004313 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
4314 kfree(cmd);
4315 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 }
4317#endif /*FEATURE_WLAN_SCAN_PNO*/
4318 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004319 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08004320 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
4321 kfree(cmd);
4322 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 }
4324 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
4325 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07004326 char *ptr;
4327
4328 if (18 < cmd_len)
4329 {
4330 ptr = (char*)(cmd + 18);
4331 }else{
4332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4333 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08004334 kfree(cmd);
4335 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07004336 }
4337
Jeff Johnson02797792013-10-26 19:17:13 -07004338 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07004339 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
4340 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
4341 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
4342 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
4343 {
4344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4345 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08004346 kfree(cmd);
4347 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07004348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004349
4350 // parameters checking
4351 // period has to be larger than 0
4352 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
4353 {
4354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08004355 kfree(cmd);
4356 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 }
4358
4359 // use default value 5 is the input is not reasonable. in unit of 10%
4360 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
4361 {
4362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
4363 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
4364 }
4365
4366 // default is 5
4367 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
4368 {
4369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
4370 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
4371 }
4372
Arif Hussain24bfa702014-01-22 13:51:30 -08004373 if (eHAL_STATUS_SUCCESS !=
4374 sme_SetTxPerTracking(pHddCtx->hHal,
4375 hdd_tx_per_hit_cb,
4376 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08004378 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 }
4380 }
4381 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07004382 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
4383 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 }
4385done:
4386 /* many of the commands write information back into the command
4387 string using snprintf(). check the return value here in one
4388 place */
4389 if ((ret < 0) || (ret >= cmd_len))
4390 {
4391 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08004392 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08004394 else if (ret > 0)
4395 {
4396 if (copy_to_user(wrqu->data.pointer, cmd, ret))
4397 {
4398 hddLog(VOS_TRACE_LEVEL_ERROR,
4399 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08004400 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08004401 return -EFAULT;
4402 }
4403 wrqu->data.length = ret;
4404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004405
4406 if (ioctl_debug)
4407 {
4408 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08004409 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 }
Arif Hussain24bfa702014-01-22 13:51:30 -08004411 kfree(cmd);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304412 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08004413 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07004414}
4415
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304416static int iw_set_priv(struct net_device *dev,
4417 struct iw_request_info *info,
4418 union iwreq_data *wrqu, char *extra)
4419{
4420 int ret;
4421 vos_ssr_protect(__func__);
4422 ret = __iw_set_priv(dev, info, wrqu, extra);
4423 vos_ssr_unprotect(__func__);
4424
4425 return ret;
4426}
4427
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304428static int __iw_set_nick(struct net_device *dev,
4429 struct iw_request_info *info,
4430 union iwreq_data *wrqu, char *extra)
4431{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304432 hdd_adapter_t *pAdapter;
4433 hdd_context_t *pHddCtx;
4434 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304435
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304436 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304437
4438 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4439 if (NULL == pAdapter)
4440 {
4441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4442 "%s: Adapter is NULL",__func__);
4443 return -EINVAL;
4444 }
4445
4446 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4447 ret = wlan_hdd_validate_context(pHddCtx);
4448 if (0 != ret)
4449 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304450 return ret;
4451 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304452 EXIT();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304453 return 0;
4454}
4455
Jeff Johnson295189b2012-06-20 16:38:30 -07004456static int iw_set_nick(struct net_device *dev,
4457 struct iw_request_info *info,
4458 union iwreq_data *wrqu, char *extra)
4459{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304460 int ret;
4461
4462 vos_ssr_protect(__func__);
4463 ret = __iw_set_nick(dev, info, wrqu, extra);
4464 vos_ssr_unprotect(__func__);
4465
4466 return ret;
4467}
4468
4469static int __iw_get_nick(struct net_device *dev,
4470 struct iw_request_info *info,
4471 union iwreq_data *wrqu, char *extra)
4472{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304473 hdd_adapter_t *pAdapter;
4474 hdd_context_t *pHddCtx;
4475 int ret = 0;
4476
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304478
4479 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4480 if (NULL == pAdapter)
4481 {
4482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4483 "%s: Adapter is NULL",__func__);
4484 return -EINVAL;
4485 }
4486
4487 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4488 ret = wlan_hdd_validate_context(pHddCtx);
4489 if (0 != ret)
4490 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304491 return ret;
4492 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304493 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 return 0;
4495}
4496
4497static int iw_get_nick(struct net_device *dev,
4498 struct iw_request_info *info,
4499 union iwreq_data *wrqu, char *extra)
4500{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304501 int ret;
4502
4503 vos_ssr_protect(__func__);
4504 ret = __iw_get_nick(dev, info, wrqu, extra);
4505 vos_ssr_unprotect(__func__);
4506
4507 return ret;
4508}
4509
4510static struct iw_statistics * __get_wireless_stats(struct net_device *dev)
4511{
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 ENTER();
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304513 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004514}
4515
4516static struct iw_statistics *get_wireless_stats(struct net_device *dev)
4517{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304518
4519 struct iw_statistics *stats;
4520
4521 vos_ssr_protect(__func__);
4522 stats = __get_wireless_stats(dev);
4523 vos_ssr_unprotect(__func__);
4524
4525 return stats;
Jeff Johnson295189b2012-06-20 16:38:30 -07004526}
4527
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304528static int __iw_set_encode(struct net_device *dev,
4529 struct iw_request_info *info,
4530 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004531
4532{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304533 hdd_adapter_t *pAdapter;
4534 hdd_station_ctx_t *pHddStaCtx;
4535 hdd_wext_state_t *pWextState;
4536 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 struct iw_point *encoderq = &(wrqu->encoding);
4538 v_U32_t keyId;
4539 v_U8_t key_length;
4540 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4541 v_BOOL_t fKeyPresent = 0;
4542 int i;
4543 eHalStatus status = eHAL_STATUS_SUCCESS;
4544
4545
4546 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304547 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4548 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4551 "%s: Adapter is NULL",__func__);
4552 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 }
4554
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304555 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4556 status = wlan_hdd_validate_context(pHddCtx);
4557 if (0 != status)
4558 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304559 return status;
4560 }
4561 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4562 if (NULL == pWextState)
4563 {
4564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4565 "%s: pWextState is NULL ",__func__);
4566 return -EINVAL;
4567 }
4568 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4569 if (NULL == pHddStaCtx)
4570 {
4571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4572 "%s: STA Context is NULL",__func__);
4573 return -EINVAL;
4574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004575
4576 keyId = encoderq->flags & IW_ENCODE_INDEX;
4577
4578 if(keyId)
4579 {
4580 if(keyId > MAX_WEP_KEYS)
4581 {
4582 return -EINVAL;
4583 }
4584
4585 fKeyPresent = 1;
4586 keyId--;
4587 }
4588 else
4589 {
4590 fKeyPresent = 0;
4591 }
4592
4593
4594 if(wrqu->data.flags & IW_ENCODE_DISABLED)
4595 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 if(!fKeyPresent) {
4598
4599 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
4600
4601 if(pWextState->roamProfile.Keys.KeyMaterial[i])
4602 pWextState->roamProfile.Keys.KeyLength[i] = 0;
4603 }
4604 }
4605 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4606 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4607 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4608 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4609
4610 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4611 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4612
4613 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
4614 {
4615 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4616 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07004617 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304618 {
4619 long ret;
4620 ret = wait_for_completion_interruptible_timeout(
4621 &pAdapter->disconnect_comp_var,
4622 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4623 if (ret <= 0)
4624 hddLog(VOS_TRACE_LEVEL_ERROR,
4625 FL("failed wait on disconnect_comp_var %ld"), ret);
4626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 }
4628
4629 return status;
4630
4631 }
4632
4633 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
4634 {
4635 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
4636
4637 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
4638
4639 }
4640
4641
4642 if(wrqu->data.length > 0)
4643 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004644 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004645
4646 key_length = wrqu->data.length;
4647
4648 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
4649
4650 if(5 == key_length)
4651 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004652 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004653
4654 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4655 {
4656 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4657 }
4658 else
4659 {
4660 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4661 }
4662 }
4663 else if(13 == key_length)
4664 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004665 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004666
4667 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4668 {
4669 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4670 }
4671 else
4672 {
4673 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4674 }
4675 }
4676 else
4677 {
4678 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004679 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 return -EINVAL;
4681 }
4682
4683 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4684 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4685 pWextState->roamProfile.EncryptionType.numEntries = 1;
4686 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4687 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4688 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4689
4690 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
4691 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
4692 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
4693 {
4694
4695 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
4696
4697 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
4698 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
4699
4700 return status;
4701 }
4702 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304703 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 return 0;
4705}
4706
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304707static int iw_set_encode(struct net_device *dev,
4708 struct iw_request_info *info,
4709 union iwreq_data *wrqu,char *extra)
4710{
4711 int ret;
4712
4713 vos_ssr_protect(__func__);
4714 ret = __iw_set_encode(dev, info, wrqu, extra);
4715 vos_ssr_unprotect(__func__);
4716
4717 return ret;
4718}
4719
4720static int __iw_get_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 struct iw_request_info *info,
4722 struct iw_point *dwrq,
4723 char *extra)
4724{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304725 hdd_adapter_t *pAdapter;
4726 hdd_wext_state_t *pWextState;
4727 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 int keyId;
4729 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4730 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304731 int i, ret = 0;
4732 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004733
4734 ENTER();
4735
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304736 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4737 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004738 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4740 "%s: Adapter is NULL",__func__);
4741 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004742 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304743 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4744 ret = wlan_hdd_validate_context(pHddCtx);
4745 if (0 != ret)
4746 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304747 return ret;
4748 }
4749 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4750 if (NULL == pWextState)
4751 {
4752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4753 "%s: pWextState is NULL",__func__);
4754 return -EINVAL;
4755 }
4756 pRoamProfile = &(pWextState->roamProfile);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004757
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 keyId = pRoamProfile->Keys.defaultIndex;
4759
4760 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
4761 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004762 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 return -EINVAL;
4764 }
4765
4766 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
4767 {
4768 dwrq->flags |= IW_ENCODE_ENABLED;
4769 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05304770 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
4771 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 }
4773 else
4774 {
4775 dwrq->flags |= IW_ENCODE_DISABLED;
4776 }
4777
4778 for(i=0; i < MAX_WEP_KEYS; i++)
4779 {
4780 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
4781 {
4782 continue;
4783 }
4784 else
4785 {
4786 break;
4787 }
4788 }
4789
4790 if(MAX_WEP_KEYS == i)
4791 {
4792 dwrq->flags |= IW_ENCODE_NOKEY;
4793 }
4794 else
4795 {
4796 dwrq->flags |= IW_ENCODE_ENABLED;
4797 }
4798
4799 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4800
4801 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
4802 {
4803 dwrq->flags |= IW_ENCODE_DISABLED;
4804 }
4805
4806 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4807
4808 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
4809 {
4810 dwrq->flags |= IW_ENCODE_OPEN;
4811 }
4812 else
4813 {
4814 dwrq->flags |= IW_ENCODE_RESTRICTED;
4815 }
4816 EXIT();
4817 return 0;
4818
4819}
4820
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05304821static int iw_get_encodeext(struct net_device *dev,
4822 struct iw_request_info *info,
4823 struct iw_point *dwrq,
4824 char *extra)
4825{
4826 int ret;
4827 vos_ssr_protect(__func__);
4828 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4829 vos_ssr_unprotect(__func__);
4830
4831 return ret;
4832}
4833
4834static int __iw_set_encodeext(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 struct iw_request_info *info,
4836 union iwreq_data *wrqu, char *extra)
4837{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304838 hdd_adapter_t *pAdapter;
4839 hdd_station_ctx_t *pHddStaCtx;
4840 hdd_wext_state_t *pWextState;
4841 hdd_context_t *pHddCtx;
4842 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004843
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304844 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 v_U32_t status = 0;
4846
4847 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
4848
4849 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4850
4851 int key_index;
4852 struct iw_point *encoding = &wrqu->encoding;
4853 tCsrRoamSetKey setKey;
4854 v_U32_t roamId= 0xFF;
4855 VOS_STATUS vos_status;
4856
4857 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304858 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4859 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004860 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4862 "%s: Adapter is NULL",__func__);
4863 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304865 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4866 status = wlan_hdd_validate_context(pHddCtx);
4867 if (0 != status)
4868 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304869 return status;
4870 }
4871 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4872 if (NULL == pHddStaCtx)
4873 {
4874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4875 "%s: STA Context is NULL",__func__);
4876 return -EINVAL;
4877 }
4878 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4879 if (NULL == pWextState)
4880 {
4881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4882 "%s: pWextState is NULL",__func__);
4883 return -EINVAL;
4884 }
4885 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 key_index = encoding->flags & IW_ENCODE_INDEX;
4887
4888 if(key_index > 0) {
4889
4890 /*Convert from 1-based to 0-based keying*/
4891 key_index--;
4892 }
4893 if(!ext->key_len) {
4894
4895 /*Set the encrytion type to NONE*/
4896 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
4897 return status;
4898 }
4899
4900 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4901 (IW_ENCODE_ALG_WEP == ext->alg))
4902 {
4903 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4904
Agarwal Ashish971c2882013-10-30 20:11:12 +05304905 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4906 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 return -EINVAL;
4908 }
4909 else {
4910 /*Static wep, update the roam profile with the keys */
4911 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4912 key_index < CSR_MAX_NUM_KEY) {
4913 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
4914 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
4915
4916 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4917 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
4918
4919 }
4920 }
4921 return status;
4922 }
4923
4924 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
4925
4926 setKey.keyId = key_index;
4927 setKey.keyLength = ext->key_len;
4928
4929 if(ext->key_len <= CSR_MAX_KEY_LEN) {
4930 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
4931 }
4932
4933 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4934 /*Key direction for group is RX only*/
4935 setKey.keyDirection = eSIR_RX_ONLY;
4936 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
4937 }
4938 else {
4939
4940 setKey.keyDirection = eSIR_TX_RX;
4941 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
4942 }
4943
4944 /*For supplicant pae role is zero*/
4945 setKey.paeRole = 0;
4946
4947 switch(ext->alg)
4948 {
4949 case IW_ENCODE_ALG_NONE:
4950 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4951 break;
4952
4953 case IW_ENCODE_ALG_WEP:
4954 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
4955 break;
4956
4957 case IW_ENCODE_ALG_TKIP:
4958 {
4959 v_U8_t *pKey = &setKey.Key[0];
4960
4961 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4962
4963 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
4964
4965 /*Supplicant sends the 32bytes key in this order
4966
4967 |--------------|----------|----------|
4968 | Tk1 |TX-MIC | RX Mic |
4969 |--------------|----------|----------|
4970 <---16bytes---><--8bytes--><--8bytes-->
4971
4972 */
4973 /*Sme expects the 32 bytes key to be in the below order
4974
4975 |--------------|----------|----------|
4976 | Tk1 |RX-MIC | TX Mic |
4977 |--------------|----------|----------|
4978 <---16bytes---><--8bytes--><--8bytes-->
4979 */
4980 /* Copy the Temporal Key 1 (TK1) */
4981 vos_mem_copy(pKey,ext->key,16);
4982
4983 /*Copy the rx mic first*/
4984 vos_mem_copy(&pKey[16],&ext->key[24],8);
4985
4986 /*Copy the tx mic */
4987 vos_mem_copy(&pKey[24],&ext->key[16],8);
4988
4989 }
4990 break;
4991
4992 case IW_ENCODE_ALG_CCMP:
4993 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4994 break;
4995
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004996#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004997#define IW_ENCODE_ALG_KRK 6
4998 case IW_ENCODE_ALG_KRK:
4999 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5000 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005001#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005002
5003 default:
5004 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5005 break;
5006 }
5007
5008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005009 ("%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 -07005010
5011#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305012 /* The supplicant may attempt to set the PTK once pre-authentication
5013 is done. Save the key in the UMAC and include it in the ADD
5014 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305016 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305018 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5019 "%s: Update PreAuth Key success", __func__);
5020 return 0;
5021 }
5022 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5023 {
5024 hddLog(VOS_TRACE_LEVEL_ERROR,
5025 "%s: Update PreAuth Key failed", __func__);
5026 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 }
5028#endif /* WLAN_FEATURE_VOWIFI_11R */
5029
5030 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5031
5032 vos_status = wlan_hdd_check_ula_done(pAdapter);
5033 if ( vos_status != VOS_STATUS_SUCCESS )
5034 {
5035 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5036 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5037 __LINE__, vos_status );
5038
5039 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5040 }
5041
5042 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
5043
5044 if ( halStatus != eHAL_STATUS_SUCCESS )
5045 {
5046 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5047 "[%4d] sme_RoamSetKey returned ERROR status= %d",
5048 __LINE__, halStatus );
5049
5050 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5051 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305052 EXIT();
5053 return halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005054}
5055
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305056static int iw_set_encodeext(struct net_device *dev,
5057 struct iw_request_info *info,
5058 union iwreq_data *wrqu, char *extra)
5059{
5060 int ret;
5061
5062 vos_ssr_protect(__func__);
5063 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5064 vos_ssr_unprotect(__func__);
5065
5066 return ret;
5067}
5068
5069static int __iw_set_retry(struct net_device *dev,
5070 struct iw_request_info *info,
5071 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005072{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305073 hdd_adapter_t *pAdapter;
5074 tHalHandle hHal;
5075 hdd_context_t *pHddCtx;
5076 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005077
5078 ENTER();
5079
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305080 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5081 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005082 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305083 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5084 "%s: Adapter is NULL",__func__);
5085 return -EINVAL;
5086 }
5087
5088 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5089 ret = wlan_hdd_validate_context(pHddCtx);
5090 if (0 != ret)
5091 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305092 return ret;
5093 }
5094
5095 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5096 if (NULL == hHal)
5097 {
5098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5099 "%s: Hal Context is NULL",__func__);
5100 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005101 }
5102
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5104 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5105
Arif Hussain6d2a3322013-11-17 19:50:10 -08005106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005107
5108 return -EINVAL;
5109 }
5110
5111 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
5112
5113 if((wrqu->retry.flags & IW_RETRY_LONG))
5114 {
5115 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5116 {
c_hpothub8245442013-11-20 23:41:09 +05305117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5118 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 return -EIO;
5120 }
5121 }
5122 else if((wrqu->retry.flags & IW_RETRY_SHORT))
5123 {
5124 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
5125 {
c_hpothub8245442013-11-20 23:41:09 +05305126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5127 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 return -EIO;
5129 }
5130 }
5131 }
5132 else
5133 {
5134 return -EOPNOTSUPP;
5135 }
5136
Arif Hussain6d2a3322013-11-17 19:50:10 -08005137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005138
5139 EXIT();
5140
5141 return 0;
5142
5143}
5144
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305145static int iw_set_retry(struct net_device *dev,
5146 struct iw_request_info *info,
5147 union iwreq_data *wrqu, char *extra)
5148{
5149 int ret;
5150
5151 vos_ssr_protect(__func__);
5152 ret = __iw_set_retry(dev, info, wrqu, extra);
5153 vos_ssr_unprotect(__func__);
5154
5155 return ret;
5156}
5157
5158static int __iw_get_retry(struct net_device *dev,
5159 struct iw_request_info *info,
5160 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005161{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305162 hdd_adapter_t *pAdapter;
5163 hdd_context_t *pHddCtx;
5164 tHalHandle hHal;
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 v_U32_t retry = 0;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305166 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005167
5168 ENTER();
5169
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305170 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5171 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005172 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5174 "%s: Adapter is NULL",__func__);
5175 return -EINVAL;
5176 }
5177
5178 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5179 ret = wlan_hdd_validate_context(pHddCtx);
5180 if (0 != ret)
5181 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305182 return ret;
5183 }
5184
5185 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5186 if (NULL == hHal)
5187 {
5188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5189 "%s: Hal Context is NULL",__func__);
5190 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005191 }
5192
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 if((wrqu->retry.flags & IW_RETRY_LONG))
5194 {
5195 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5196
5197 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5198 {
c_hpothub8245442013-11-20 23:41:09 +05305199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5200 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 return -EIO;
5202 }
5203
5204 wrqu->retry.value = retry;
5205 }
5206 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
5207 {
5208 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5209
5210 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
5211 {
c_hpothub8245442013-11-20 23:41:09 +05305212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
5213 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005214 return -EIO;
5215 }
5216
5217 wrqu->retry.value = retry;
5218 }
5219 else {
5220 return -EOPNOTSUPP;
5221 }
5222
Arif Hussain6d2a3322013-11-17 19:50:10 -08005223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07005224
5225 EXIT();
5226
5227 return 0;
5228}
5229
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305230static int iw_get_retry(struct net_device *dev,
5231 struct iw_request_info *info,
5232 union iwreq_data *wrqu, char *extra)
5233{
5234 int ret;
5235
5236 vos_ssr_protect(__func__);
5237 ret = __iw_get_retry(dev, info, wrqu, extra);
5238 vos_ssr_unprotect(__func__);
5239
5240 return ret;
5241}
5242
5243static int __iw_set_mlme(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 struct iw_request_info *info,
5245 union iwreq_data *wrqu,
5246 char *extra)
5247{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305248 hdd_adapter_t *pAdapter;
5249 hdd_context_t *pHddCtx;
5250 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005251 struct iw_mlme *mlme = (struct iw_mlme *)extra;
5252 eHalStatus status = eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305253 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005254
5255 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305256 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5257 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005258 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5260 "%s:Adapter is NULL",__func__);
5261 return -EINVAL;
5262 }
5263 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5264 ret = wlan_hdd_validate_context(pHddCtx);
5265 if (0 != ret)
5266 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305267 return ret;
5268 }
5269 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5270 if (NULL == pHddStaCtx)
5271 {
5272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5273 "%s:STA context is NULL",__func__);
5274 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 }
5276
5277 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
5278 switch (mlme->cmd) {
5279 case IW_MLME_DISASSOC:
5280 case IW_MLME_DEAUTH:
5281
5282 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
5283 {
5284 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5285
5286 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
5287 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5288
5289 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5290 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
5291
Jeff Johnson43971f52012-07-17 12:26:56 -07005292 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05305293 {
5294 long ret;
5295 ret = wait_for_completion_interruptible_timeout(
5296 &pAdapter->disconnect_comp_var,
5297 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5298 if (ret <= 0)
5299 hddLog(VOS_TRACE_LEVEL_ERROR,
5300 FL("failed wait on disconnect_comp_var %ld"), ret);
5301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08005303 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005304 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005305
5306 /* Resetting authKeyMgmt */
5307 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
5308
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05305309 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 netif_tx_disable(dev);
5311 netif_carrier_off(dev);
5312
5313 }
5314 else
5315 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005316 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 -07005317 }
5318 break;
5319 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005320 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005321 return -EINVAL;
5322 }//end of switch
5323
5324 EXIT();
5325
5326 return status;
5327
5328}
5329
Mahesh A Saptasagarc06673e2014-08-13 15:55:42 +05305330static int iw_set_mlme(struct net_device *dev,
5331 struct iw_request_info *info,
5332 union iwreq_data *wrqu,
5333 char *extra)
5334{
5335 int ret;
5336
5337 vos_ssr_protect(__func__);
5338 ret = __iw_set_mlme(dev, info, wrqu, extra);
5339 vos_ssr_unprotect(__func__);
5340
5341 return ret;
5342}
5343
Jeff Johnson295189b2012-06-20 16:38:30 -07005344/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305345static int __iw_setint_getnone(struct net_device *dev,
5346 struct iw_request_info *info,
5347 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005348{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305349 hdd_adapter_t *pAdapter;
5350 tHalHandle hHal;
5351 hdd_wext_state_t *pWextState;
5352 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 int *value = (int *)extra;
5354 int sub_cmd = value[0];
5355 int set_value = value[1];
5356 int ret = 0; /* success */
5357 int enable_pbm, enable_mp;
5358#ifdef CONFIG_HAS_EARLYSUSPEND
5359 v_U8_t nEnableSuspendOld;
5360#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005361
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305362 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305363 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5364 if (NULL == pAdapter)
5365 {
5366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5367 "%s: Adapter is NULL",__func__);
5368 return -EINVAL;
5369 }
5370 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5371 ret = wlan_hdd_validate_context(pHddCtx);
5372 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005373 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305374 return ret;
5375 }
5376 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5377 if (NULL == hHal)
5378 {
5379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5380 "%s: Hal Context is NULL",__func__);
5381 return -EINVAL;
5382 }
5383 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5384 if (NULL == pWextState)
5385 {
5386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5387 "%s: pWextState is NULL",__func__);
5388 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005389 }
5390
c_hpothu4a298be2014-12-22 21:12:51 +05305391 INIT_COMPLETION(pWextState->completion_var);
5392
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 switch(sub_cmd)
5394 {
5395 case WE_SET_11D_STATE:
5396 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07005397 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07005398 memset(&smeConfig, 0x00, sizeof(smeConfig));
5399
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
5401
5402 sme_GetConfigParam(hHal,&smeConfig);
5403 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
5404
Arif Hussain6d2a3322013-11-17 19:50:10 -08005405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005406
5407 sme_UpdateConfig(hHal,&smeConfig);
5408 }
5409 else {
5410 return -EINVAL;
5411 }
5412 break;
5413 }
5414
5415 case WE_WOWL:
5416 {
5417 switch (set_value)
5418 {
5419 case 0x00:
c_hpothu01484c02014-05-16 14:05:15 +05305420 hdd_exit_wowl(pAdapter, eWOWL_EXIT_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 break;
5422 case 0x01:
5423 case 0x02:
5424 case 0x03:
5425 enable_mp = (set_value & 0x01) ? 1 : 0;
5426 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08005427 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
5429 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5430 break;
5431 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005432 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 ret = -EINVAL;
5434 break;
5435 }
5436
5437 break;
5438 }
5439 case WE_SET_POWER:
5440 {
5441 switch (set_value)
5442 {
5443 case 0: //Full Power
5444 {
5445 struct statsContext context;
5446 eHalStatus status;
5447
5448 init_completion(&context.completion);
5449
5450 context.pAdapter = pAdapter;
5451 context.magic = POWER_CONTEXT_MAGIC;
5452
5453 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
5454 iw_power_callback_fn, &context,
5455 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08005456 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 {
5458 int lrc = wait_for_completion_interruptible_timeout(
5459 &context.completion,
5460 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08005461
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 if (lrc <= 0)
5463 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005464 hddLog(VOS_TRACE_LEVEL_ERROR,
5465 "%s: SME %s while requesting fullpower",
5466 __func__, (0 == lrc) ?
5467 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 }
5469 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005470 /* either we have a response or we timed out. if we timed
5471 out there is a race condition such that the callback
5472 function could be executing at the same time we are. of
5473 primary concern is if the callback function had already
5474 verified the "magic" but had not yet set the completion
5475 variable when a timeout occurred. we serialize these
5476 activities by invalidating the magic while holding a
5477 shared spinlock which will cause us to block if the
5478 callback is currently executing */
5479 spin_lock(&hdd_context_lock);
5480 context.magic = 0;
5481 spin_unlock(&hdd_context_lock);
5482
Arif Hussain6d2a3322013-11-17 19:50:10 -08005483 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 break;
5485 }
5486 case 1: //Enable BMPS
5487 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5488 break;
5489 case 2: //Disable BMPS
5490 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
5491 break;
5492 case 3: //Request Bmps
5493 {
5494 struct statsContext context;
5495 eHalStatus status;
5496
5497 init_completion(&context.completion);
5498
5499 context.pAdapter = pAdapter;
5500 context.magic = POWER_CONTEXT_MAGIC;
5501
5502 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
5503 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08005504 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005505 {
5506 int lrc = wait_for_completion_interruptible_timeout(
5507 &context.completion,
5508 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 if (lrc <= 0)
5510 {
Jeff Johnson72a40512013-12-19 10:14:15 -08005511 hddLog(VOS_TRACE_LEVEL_ERROR,
5512 "%s: SME %s while requesting BMPS",
5513 __func__, (0 == lrc) ? "timeout" :
5514 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 }
5516 }
Jeff Johnson72a40512013-12-19 10:14:15 -08005517 /* either we have a response or we timed out. if we
5518 timed out there is a race condition such that the
5519 callback function could be executing at the same
5520 time we are. of primary concern is if the callback
5521 function had already verified the "magic" but had
5522 not yet set the completion variable when a timeout
5523 occurred. we serialize these activities by
5524 invalidating the magic while holding a shared
5525 spinlock which will cause us to block if the
5526 callback is currently executing */
5527 spin_lock(&hdd_context_lock);
5528 context.magic = 0;
5529 spin_unlock(&hdd_context_lock);
5530
Arif Hussain6d2a3322013-11-17 19:50:10 -08005531 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 break;
5533 }
5534 case 4: //Enable IMPS
5535 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5536 break;
5537 case 5: //Disable IMPS
5538 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
5539 break;
5540 case 6: //Enable Standby
5541 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5542 break;
5543 case 7: //Disable Standby
5544 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
5545 break;
5546 case 8: //Request Standby
5547#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005548#endif
5549 break;
5550 case 9: //Start Auto Bmps Timer
5551 sme_StartAutoBmpsTimer(hHal);
5552 break;
5553 case 10://Stop Auto BMPS Timer
5554 sme_StopAutoBmpsTimer(hHal);
5555 break;
5556#ifdef CONFIG_HAS_EARLYSUSPEND
5557 case 11://suspend to standby
5558#ifdef CONFIG_HAS_EARLYSUSPEND
5559 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5560 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5562#endif
5563 break;
5564 case 12://suspend to deep sleep
5565#ifdef CONFIG_HAS_EARLYSUSPEND
5566 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
5567 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
5569#endif
5570 break;
5571 case 13://resume from suspend
5572#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07005573#endif
5574 break;
5575#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005577 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 ret = -EINVAL;
5579 break;
5580 }
5581 break;
5582 }
5583
5584 case WE_SET_MAX_ASSOC:
5585 {
5586 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5587 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
5588 {
5589 ret = -EINVAL;
5590 }
5591 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5592 set_value, NULL, eANI_BOOLEAN_FALSE)
5593 != eHAL_STATUS_SUCCESS )
5594 {
c_hpothub8245442013-11-20 23:41:09 +05305595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5596 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 ret = -EIO;
5598 }
5599 break;
5600 }
5601
5602 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5603 {
5604 if( 0 == set_value )
5605 {
5606 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
5607 }
5608 else if ( 1 == set_value )
5609 {
5610 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
5611 }
5612 else
5613 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005614 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 ret = -EINVAL;
5616 }
5617 break;
5618 }
5619
5620 case WE_SET_DATA_INACTIVITY_TO:
5621 {
5622 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5623 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5624 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5625 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
5626 set_value,
5627 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
5628 {
5629 hddLog(LOGE,"Failure: Could not pass on "
5630 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005631 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 ret = -EINVAL;
5633 }
5634 break;
5635 }
5636 case WE_SET_MAX_TX_POWER:
5637 {
5638 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5639 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5640
5641 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
5642 __func__, set_value);
5643 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
5644 eHAL_STATUS_SUCCESS )
5645 {
5646 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5647 __func__);
5648 return -EIO;
5649 }
5650
5651 break;
5652 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07005653 case WE_SET_MAX_TX_POWER_2_4:
5654 {
5655 hddLog(VOS_TRACE_LEVEL_INFO,
5656 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
5657 __func__, set_value);
5658 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
5659 eHAL_STATUS_SUCCESS)
5660 {
5661 hddLog(VOS_TRACE_LEVEL_ERROR,
5662 "%s: Setting maximum tx power failed for 2.4 GHz band",
5663 __func__);
5664 return -EIO;
5665 }
5666
5667 break;
5668 }
5669 case WE_SET_MAX_TX_POWER_5_0:
5670 {
5671 hddLog(VOS_TRACE_LEVEL_INFO,
5672 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
5673 __func__, set_value);
5674 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
5675 eHAL_STATUS_SUCCESS)
5676 {
5677 hddLog(VOS_TRACE_LEVEL_ERROR,
5678 "%s: Setting maximum tx power failed for 5.0 GHz band",
5679 __func__);
5680 return -EIO;
5681 }
5682
5683 break;
5684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 case WE_SET_HIGHER_DTIM_TRANSITION:
5686 {
5687 if(!((set_value == eANI_BOOLEAN_FALSE) ||
5688 (set_value == eANI_BOOLEAN_TRUE)))
5689 {
5690 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
5691 ret = -EINVAL;
5692 }
5693 else
5694 {
5695 if(pAdapter->higherDtimTransition != set_value)
5696 {
5697 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005698 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 }
5700 }
5701
5702 break;
5703 }
5704
5705 case WE_SET_TM_LEVEL:
5706 {
5707 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005708 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
5710
5711 break;
5712 }
5713
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305714 case WE_ENABLE_STRICT_FCC_REG:
5715 {
5716 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
5717 struct wiphy *wiphy = NULL;
5718 long lrc;
5719 int status;
5720
5721 wiphy = hddCtxt->wiphy;
5722 if(wiphy == NULL)
5723 {
5724 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
5725 break;
5726 }
5727 init_completion(&hddCtxt->wiphy_channel_update_event);
5728
5729 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
5730
5731 status = regulatory_hint(wiphy, "00");
5732 if(status < 0)
5733 {
5734 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
5735 break;
5736 }
5737
5738 /* Wait for completion */
5739 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
5740 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
5741 if (lrc <= 0)
5742 {
5743 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
5744 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
5745 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
5746 }
5747 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
5748
5749 break;
5750 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08005751 case WE_SET_DEBUG_LOG:
5752 {
5753 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5754 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
5755 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
5756 break;
5757 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05305758#ifdef FEATURE_WLAN_TDLS
5759 case WE_SET_TDLS_OFF_CHAN:
5760 {
5761 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
5763 __func__, set_value);
5764 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
5765 break;
5766 }
5767 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
5768 {
5769 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
5771 __func__, set_value);
5772 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
5773 break;
5774 }
5775 case WE_SET_TDLS_OFF_CHAN_MODE:
5776 {
5777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
5778 __func__, set_value);
5779 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
5780 break;
5781 }
5782#endif
Peng Xu2446a892014-09-05 17:21:18 +05305783 case WE_SET_SCAN_BAND_PREFERENCE:
5784 {
5785 tSmeConfigParams smeConfig;
5786 memset(&smeConfig, 0x00, sizeof(smeConfig));
5787 if(pAdapter->device_mode != WLAN_HDD_INFRA_STATION) {
5788 ret = -EINVAL;
5789 break;
5790 }
5791 hddLog(LOG1, "WE_SET_BAND_PREFERRENCE val %d ", set_value);
5792
5793 if (eCSR_BAND_ALL == set_value ||
5794 eCSR_BAND_24 == set_value || eCSR_BAND_5G == set_value) {
5795 sme_GetConfigParam(hHal, &smeConfig);
5796 smeConfig.csrConfig.scanBandPreference = set_value;
5797
5798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5799 "set band scan preference = %d\n",
5800 smeConfig.csrConfig.scanBandPreference);
5801
5802 sme_UpdateConfig(hHal, &smeConfig);
5803 }
5804 else {
5805 ret = -EINVAL;
5806 }
5807 break;
5808 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305809 /* The WE_SET_MIRACAST_VENDOR_CONFIG IOCTL should be set before the
5810 * connection happens so that the params can take effect during
5811 * association. Also this should not be used in STA+p2p concurrency
5812 * as the param will also effect the STA mode.
5813 */
5814 case WE_SET_MIRACAST_VENDOR_CONFIG:
5815 {
5816 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kiet Lam46b8e4e2013-11-06 21:49:53 +05305817
Abhishek Singh01c73d12015-03-12 15:13:44 +05305818 hddLog(LOG1, FL(
5819 "Set Miracast vendor tuning %d"), set_value);
5820
5821 if (1 == set_value || 0 == set_value)
5822 {
5823 if (eHAL_STATUS_SUCCESS != sme_SetMiracastVendorConfig(pHddCtx->hHal,
5824 pHddCtx->cfg_ini->numBuffAdvert, set_value))
5825 {
5826 hddLog( LOGE, FL("set vendor miracast config failed"));
5827 ret = -EIO;
5828 }
5829 }
5830 else
5831 {
5832 hddLog(LOGE,
5833 FL("Invalid value %d in WE_SET_MIRACAST_VENDOR_CONFIG IOCTL"), set_value);
5834 ret = -EINVAL;
5835 }
5836
5837 break;
5838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 default:
5840 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005841 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 sub_cmd, set_value);
5843 break;
5844 }
5845 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305846 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 return ret;
5848}
5849
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305850static int iw_setint_getnone(struct net_device *dev,
5851 struct iw_request_info *info,
5852 union iwreq_data *wrqu, char *extra)
5853{
5854 int ret;
5855
5856 vos_ssr_protect(__func__);
5857 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5858 vos_ssr_unprotect(__func__);
5859
5860 return 0;
5861}
Jeff Johnson295189b2012-06-20 16:38:30 -07005862/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305863static int __iw_setchar_getnone(struct net_device *dev,
5864 struct iw_request_info *info,
5865 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005866{
5867 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305868 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005870 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305871 hdd_adapter_t *pAdapter;
5872 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005873#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305874 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005875#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305876 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305877 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005878
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305879 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305880 pAdapter = (netdev_priv(dev));
5881 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005882 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5884 "%s: Adapter is NULL",__func__);
5885 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005886 }
5887
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305888 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5889 ret = wlan_hdd_validate_context(pHddCtx);
5890 if (0 != ret)
5891 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305892 return ret;
5893 }
5894#ifdef WLAN_FEATURE_VOWIFI
5895 pConfig = pHddCtx->cfg_ini;
5896#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305897 /* helper function to get iwreq_data with compat handling. */
5898 if (hdd_priv_get_data(&s_priv_data, wrqu))
5899 {
5900 return -EINVAL;
5901 }
5902
5903 /* make sure all params are correctly passed to function */
5904 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5905 {
5906 return -EINVAL;
5907 }
5908
5909 sub_cmd = s_priv_data.flags;
5910
Arif Hussain0273cba2014-01-07 20:58:29 -08005911 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305912 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5913 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005914 if (NULL == pBuffer)
5915 {
5916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5917 "mem_alloc_copy_from_user_helper fail");
5918 return -ENOMEM;
5919 }
5920
5921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305922 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5924 "%s: Received data %s", __func__, pBuffer);
5925
Jeff Johnson295189b2012-06-20 16:38:30 -07005926 switch(sub_cmd)
5927 {
5928 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005930 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 break;
5932 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005934 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005935 break;
5936#if defined WLAN_FEATURE_VOWIFI
5937 case WE_NEIGHBOR_REPORT_REQUEST:
5938 {
5939 tRrmNeighborReq neighborReq;
5940 tRrmNeighborRspCallbackInfo callbackInfo;
5941
5942 if (pConfig->fRrmEnable)
5943 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305945 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 if( !neighborReq.no_ssid )
5947 {
Girish Gowli552fc072014-06-14 18:26:16 +05305948 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005949 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 }
5951
5952 callbackInfo.neighborRspCallback = NULL;
5953 callbackInfo.neighborRspCallbackContext = NULL;
5954 callbackInfo.timeout = 5000; //5 seconds
5955 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5956 }
5957 else
5958 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005959 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 ret = -EINVAL;
5961 }
5962 }
5963 break;
5964#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 case WE_SET_AP_WPS_IE:
5966 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05305967 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08005970 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 if (VOS_STATUS_SUCCESS != vstatus)
5972 {
5973 ret = -EINVAL;
5974 }
5975 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305976 case WE_SET_ENCRYPT_MSG:
5977 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
5978 if (NULL == pkt)
5979 {
5980 hddLog(VOS_TRACE_LEVEL_ERROR,
5981 "%s: vos_mem_alloc failed", __func__);
5982 return -ENOMEM;
5983 }
5984
5985 memset(pkt, 0, sizeof(tSirpkt80211));
5986
5987 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
5988 hddLog(VOS_TRACE_LEVEL_ERROR,
5989 FL("Firmware is not DISA capable"));
5990 ret = -EINVAL;
5991 vos_mem_free(pkt);
5992 break;
5993 }
5994
5995 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
5996
5997 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
5998 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
5999 if (eHAL_STATUS_SUCCESS != ret) {
6000 hddLog(VOS_TRACE_LEVEL_ERROR,
6001 FL("SENDEncryptMSG: fail to post WDA cmd"));
6002 ret = -EINVAL;
6003 }
6004 vos_mem_free(pkt);
6005
6006 break;
6007
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 default:
6009 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006010 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 ret = -EINVAL;
6012 break;
6013 }
6014 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006015 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306016
6017 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 return ret;
6019}
6020
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306021static int iw_setchar_getnone(struct net_device *dev,
6022 struct iw_request_info *info,
6023 union iwreq_data *wrqu, char *extra)
6024{
6025 int ret;
6026
6027 vos_ssr_protect(__func__);
6028 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6029 vos_ssr_unprotect(__func__);
6030
6031 return ret;
6032}
6033
Jeff Johnson295189b2012-06-20 16:38:30 -07006034/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306035static int __iw_setnone_getint(struct net_device *dev,
6036 struct iw_request_info *info,
6037 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006038{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306039 hdd_adapter_t *pAdapter;
6040 tHalHandle hHal;
6041 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 int *value = (int *)extra;
6043 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05306044 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006045
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306046 ENTER();
6047
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306048 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6049 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006050 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6052 "%s: Adapter is NULL",__func__);
6053 return -EINVAL;
6054 }
6055 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6056 ret = wlan_hdd_validate_context(pHddCtx);
6057 if (0 != ret)
6058 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306059 return ret;
6060 }
6061 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6062 if (NULL == hHal)
6063 {
6064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6065 "%s: Hal Context is NULL",__func__);
6066 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006068
6069 switch (value[0])
6070 {
6071 case WE_GET_11D_STATE:
6072 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006073 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306075
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6077
Arif Hussain6d2a3322013-11-17 19:50:10 -08006078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006079
6080 break;
6081 }
6082
6083 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 break;
6086
6087 case WE_PMC_STATE:
6088 {
6089 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006090 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 break;
6092 }
6093 case WE_GET_WLAN_DBG:
6094 {
6095 vos_trace_display();
6096 *value = 0;
6097 break;
6098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 case WE_GET_MAX_ASSOC:
6100 {
6101 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6102 {
c_hpothub8245442013-11-20 23:41:09 +05306103 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6104 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 ret = -EIO;
6106 }
Girish Gowli385be612014-09-18 11:17:20 +05306107#ifdef WLAN_SOFTAP_VSTA_FEATURE
6108 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6109 {
6110 if (*value > VSTA_NUM_ASSOC_STA)
6111 {
6112 *value = VSTA_NUM_ASSOC_STA;
6113 }
6114 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6115 (*value > (VSTA_NUM_ASSOC_STA -
6116 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6117 {
6118 *value = (VSTA_NUM_ASSOC_STA -
6119 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6120 }
6121 }
6122 else
6123#endif
6124 {
6125 if (*value > NUM_ASSOC_STA)
6126 {
6127 *value = NUM_ASSOC_STA;
6128 }
6129 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6130 (*value > (NUM_ASSOC_STA -
6131 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6132 {
6133 *value = (NUM_ASSOC_STA -
6134 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6135 }
6136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 break;
6138 }
6139
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 case WE_GET_WDI_DBG:
6141 {
6142 wpalTraceDisplay();
6143 *value = 0;
6144 break;
6145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006146
6147 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6148 {
6149 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6150 break;
6151 }
6152 case WE_GET_CONCURRENCY_MODE:
6153 {
6154 *value = hdd_get_concurrency_mode ( );
6155
Arif Hussain6d2a3322013-11-17 19:50:10 -08006156 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 break;
6158 }
6159
Peng Xu2446a892014-09-05 17:21:18 +05306160 case WE_GET_SCAN_BAND_PREFERENCE:
6161 {
6162 sme_GetConfigParam(hHal, &smeConfig);
6163 *value = smeConfig.csrConfig.scanBandPreference;
6164
6165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6166 "scanBandPreference = %d\n", *value);
6167 break;
6168 }
6169
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 default:
6171 {
6172 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6173 break;
6174 }
6175 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306176 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 return ret;
6178}
6179
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306180static int iw_setnone_getint(struct net_device *dev,
6181 struct iw_request_info *info,
6182 union iwreq_data *wrqu, char *extra)
6183{
6184 int ret;
6185
6186 vos_ssr_protect(__func__);
6187 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6188 vos_ssr_unprotect(__func__);
6189
6190 return ret;
6191
6192}
Jeff Johnson295189b2012-06-20 16:38:30 -07006193/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306194int __iw_set_three_ints_getnone(struct net_device *dev,
6195 struct iw_request_info *info,
6196 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006197{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306198 hdd_adapter_t *pAdapter;
6199 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 int *value = (int *)extra;
6201 int sub_cmd = value[0];
6202 int ret = 0;
6203
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306204 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306205 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6206 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006207 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6209 "%s: Adapter is NULL",__func__);
6210 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006211 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306212 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6213 ret = wlan_hdd_validate_context(pHddCtx);
6214 if (0 != ret)
6215 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306216 return ret;
6217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 switch(sub_cmd)
6219 {
6220 case WE_SET_WLAN_DBG:
6221 {
6222 vos_trace_setValue( value[1], value[2], value[3]);
6223 break;
6224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 case WE_SET_WDI_DBG:
6226 {
6227 wpalTraceSetLevel( value[1], value[2], value[3]);
6228 break;
6229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 case WE_SET_SAP_CHANNELS:
6231 {
6232 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6233 break;
6234 }
6235
6236 default:
6237 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006238 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006239 break;
6240 }
6241 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306242 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 return ret;
6244}
6245
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306246int iw_set_three_ints_getnone(struct net_device *dev,
6247 struct iw_request_info *info,
6248 union iwreq_data *wrqu, char *extra)
6249{
6250 int ret;
6251
6252 vos_ssr_protect(__func__);
6253 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6254 vos_ssr_unprotect(__func__);
6255
6256 return ret;
6257}
6258
6259static int __iw_get_char_setnone(struct net_device *dev,
6260 struct iw_request_info *info,
6261 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006262{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306263 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306265 hdd_context_t *pHddCtx;
6266 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006267#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006268 hdd_wext_state_t *pWextState;
6269#endif
6270
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306271 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306272 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006273 if (pAdapter == NULL)
6274 {
6275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6276 "%s: pAdapter is NULL!", __func__);
6277 return -EINVAL;
6278 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306279 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6280 ret = wlan_hdd_validate_context(pHddCtx);
6281 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006282 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306283 return ret;
6284 }
6285#ifdef WLAN_FEATURE_11W
6286 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6287 if (NULL == pWextState)
6288 {
6289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6290 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006291 return -EINVAL;
6292 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306293#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006294
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 switch(sub_cmd)
6296 {
6297 case WE_WLAN_VERSION:
6298 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006299 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 break;
6301 }
6302
6303 case WE_GET_STATS:
6304 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306305 tHalHandle hHal = NULL;
6306 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6308 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6309 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6310
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306311
Jeff Johnson295189b2012-06-20 16:38:30 -07006312 snprintf(extra, WE_MAX_STR_LEN,
6313 "\nTransmit"
6314 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6315 "\n dropped BK %u, BE %u, VI %u, VO %u"
6316 "\n classified BK %u, BE %u, VI %u, VO %u"
6317 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6318 "\n queued BK %u, BE %u, VI %u, VO %u"
6319 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006320 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 "\n fetched BK %u, BE %u, VI %u, VO %u"
6322 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6323 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006324 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 "\n flushed BK %u, BE %u, VI %u, VO %u"
6326 "\n\nReceive"
6327 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6328 "\n\nResetsStats"
6329 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6330 "\n",
6331 pStats->txXmitCalled,
6332 pStats->txXmitDropped,
6333 pStats->txXmitBackPressured,
6334 pStats->txXmitQueued,
6335
6336 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6337 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6338 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6339 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6340
6341 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6342 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6343 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6344 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6345
6346 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6347 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6348 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6349 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6350
6351 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6352 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6353 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6354 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6355
6356 pStats->txFetched,
6357 pStats->txFetchEmpty,
6358 pStats->txFetchLowResources,
6359 pStats->txFetchDequeueError,
6360
6361 pStats->txFetchDequeued,
6362 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006363 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 pStats->txCompleted,
6365 pStats->txFlushed,
6366
6367 pStats->txFetchedAC[WLANTL_AC_BK],
6368 pStats->txFetchedAC[WLANTL_AC_BE],
6369 pStats->txFetchedAC[WLANTL_AC_VI],
6370 pStats->txFetchedAC[WLANTL_AC_VO],
6371
6372 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6373 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6374 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6375 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6376
6377 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6378 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6379 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6380 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6381
Ravi Joshi41914632013-10-21 23:02:21 -07006382 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6383 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6384 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6385 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6386
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 pStats->txFlushedAC[WLANTL_AC_BK],
6388 pStats->txFlushedAC[WLANTL_AC_BE],
6389 pStats->txFlushedAC[WLANTL_AC_VI],
6390 pStats->txFlushedAC[WLANTL_AC_VO],
6391
6392 pStats->rxChains,
6393 pStats->rxPackets,
6394 pStats->rxDropped,
6395 pStats->rxDelivered,
6396 pStats->rxRefused,
6397
6398 pResetStats->totalLogpResets,
6399 pResetStats->totalCMD53Failures,
6400 pResetStats->totalMutexReadFailures,
6401 pResetStats->totalMIFErrorFailures,
6402 pResetStats->totalFWHearbeatFailures,
6403 pResetStats->totalUnknownExceptions
6404 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306405 wrqu->data.length = strlen(extra);
6406
6407 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6408
6409 if (hHal)
6410 pMac = PMAC_STRUCT( hHal );
6411
6412 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6413 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6414 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306415 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6416 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6417 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6418 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306419 "\n",
6420 pMac->pmm.BmpscntSleep,
6421 pMac->pmm.BmpscntAwake,
6422 pMac->pmm.BmpsSleeReqFailCnt,
6423 pMac->pmm.BmpsWakeupReqFailCnt,
6424 pMac->pmm.ImpsCntSleep,
6425 pMac->pmm.ImpsCntAwake,
6426 pMac->pmm.ImpsSleepErrCnt,
6427 pMac->pmm.ImpsWakeupErrCnt,
6428 pMac->pmm.ImpsLastErr
6429 );
6430 }
6431
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 wrqu->data.length = strlen(extra)+1;
6433 break;
6434 }
6435
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306436/* The case prints the current state of the HDD, SME, CSR, PE, TL
6437 *it can be extended for WDI Global State as well.
6438 *And currently it only checks P2P_CLIENT adapter.
6439 *P2P_DEVICE and P2P_GO have not been added as of now.
6440*/
6441 case WE_GET_STATES:
6442 {
6443 int buf = 0, len = 0;
6444 int adapter_num = 0;
6445 int count = 0, check = 1;
6446
6447 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006448 tHalHandle hHal = NULL;
6449 tpAniSirGlobal pMac = NULL;
6450 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306451
6452 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6453 hdd_adapter_t *useAdapter = NULL;
6454
6455 /* Print wlan0 or p2p0 states based on the adapter_num
6456 *by using the correct adapter
6457 */
6458 while ( adapter_num < 2 )
6459 {
6460 if ( WLAN_ADAPTER == adapter_num )
6461 {
6462 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006463 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306464 "\n\n wlan0 States:-");
6465 len += buf;
6466 }
6467 else if ( P2P_ADAPTER == adapter_num )
6468 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006469 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306470 "\n\n p2p0 States:-");
6471 len += buf;
6472
6473 if( !pHddCtx )
6474 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006475 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306476 "\n pHddCtx is NULL");
6477 len += buf;
6478 break;
6479 }
6480
6481 /*Printing p2p0 states only in the case when the device is
6482 configured as a p2p_client*/
6483 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6484 if ( !useAdapter )
6485 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006486 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306487 "\n Device not configured as P2P_CLIENT.");
6488 len += buf;
6489 break;
6490 }
6491 }
6492
6493 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006494 if (!hHal) {
6495 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6496 "\n pMac is NULL");
6497 len += buf;
6498 break;
6499 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306500 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006501 if (!pMac) {
6502 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6503 "\n pMac is NULL");
6504 len += buf;
6505 break;
6506 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306507 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6508 if( !pHddStaCtx )
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 pHddStaCtx is NULL");
6512 len += buf;
6513 break;
6514 }
6515
6516 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6517
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006518 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306519 "\n HDD Conn State - %s "
6520 "\n \n SME State:"
6521 "\n Neighbour Roam State - %s"
6522 "\n CSR State - %s"
6523 "\n CSR Substate - %s"
6524 "\n \n TL STA %d State: %s",
6525 macTraceGetHDDWlanConnState(
6526 pHddStaCtx->conn_info.connState),
6527 macTraceGetNeighbourRoamState(
6528 pMac->roam.neighborRoamInfo.neighborRoamState),
6529 macTraceGetcsrRoamState(
6530 pMac->roam.curState[useAdapter->sessionId]),
6531 macTraceGetcsrRoamSubState(
6532 pMac->roam.curSubState[useAdapter->sessionId]),
6533 pHddStaCtx->conn_info.staId[0],
6534 macTraceGetTLState(tlState)
6535 );
6536 len += buf;
6537 adapter_num++;
6538 }
6539
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006540 if (pMac) {
6541 /* Printing Lim State starting with global lim states */
6542 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6543 "\n \n LIM STATES:-"
6544 "\n Global Sme State - %s "\
6545 "\n Global mlm State - %s "\
6546 "\n",
6547 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6548 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6549 );
6550 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306551
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006552 /*printing the PE Sme and Mlm states for valid lim sessions*/
6553 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306554 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006555 if ( pMac->lim.gpSession[count].valid )
6556 {
6557 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6558 "\n Lim Valid Session %d:-"
6559 "\n PE Sme State - %s "
6560 "\n PE Mlm State - %s "
6561 "\n",
6562 check,
6563 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6564 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6565 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306566
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006567 len += buf;
6568 check++;
6569 }
6570 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306571 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306572 }
6573
6574 wrqu->data.length = strlen(extra)+1;
6575 break;
6576 }
6577
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 case WE_GET_CFG:
6579 {
6580 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6581 wrqu->data.length = strlen(extra)+1;
6582 break;
6583 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006584#ifdef WLAN_FEATURE_11AC
6585 case WE_GET_RSSI:
6586 {
6587 v_S7_t s7Rssi = 0;
6588 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6589 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6590 wrqu->data.length = strlen(extra)+1;
6591 break;
6592 }
6593#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306594
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006595#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006596 case WE_GET_ROAM_RSSI:
6597 {
6598 v_S7_t s7Rssi = 0;
6599 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6600 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6601 wrqu->data.length = strlen(extra)+1;
6602 break;
6603 }
6604#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 case WE_GET_WMM_STATUS:
6606 {
6607 snprintf(extra, WE_MAX_STR_LEN,
6608 "\nDir: 0=up, 1=down, 3=both\n"
6609 "|------------------------|\n"
6610 "|AC | ACM |Admitted| Dir |\n"
6611 "|------------------------|\n"
6612 "|VO | %d | %3s | %d |\n"
6613 "|VI | %d | %3s | %d |\n"
6614 "|BE | %d | %3s | %d |\n"
6615 "|BK | %d | %3s | %d |\n"
6616 "|------------------------|\n",
6617 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6618 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6619 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6620 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6621 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6622 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6623 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6624 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6625 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6626 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6627 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6628 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6629
Jeff Johnsone7245742012-09-05 17:12:55 -07006630
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 wrqu->data.length = strlen(extra)+1;
6632 break;
6633 }
6634 case WE_GET_CHANNEL_LIST:
6635 {
6636 VOS_STATUS status;
6637 v_U8_t i, len;
6638 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306639 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6640 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6641 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 tChannelListInfo channel_list;
6643
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006644 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006646 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006647 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006648 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 return -EINVAL;
6650 }
6651 buf = extra;
6652
6653 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006654 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6655 * needed = 5 * number of channels. Check ifsufficient
6656 * buffer is available and then proceed to fill the buffer.
6657 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6659 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006660 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006661 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006662 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 return -EINVAL;
6664 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006665 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6666 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306667 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6668 {
6669 //Printing Country code in getChannelList
6670 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6671 {
6672 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6673 "%c ", pBuf[i]);
6674 }
6675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 for(i = 0 ; i < channel_list.num_channels; i++)
6677 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006678 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 }
6681 wrqu->data.length = strlen(extra)+1;
6682
6683 break;
6684 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006685#ifdef FEATURE_WLAN_TDLS
6686 case WE_GET_TDLS_PEERS:
6687 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006688 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006689 break;
6690 }
6691#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006692#ifdef WLAN_FEATURE_11W
6693 case WE_GET_11W_INFO:
6694 {
6695 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6696
6697 snprintf(extra, WE_MAX_STR_LEN,
6698 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6699 "\n Number of Unprotected Disassocs %d"
6700 "\n Number of Unprotected Deauths %d",
6701 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6702 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6703 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6704 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6705 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6706
6707 wrqu->data.length = strlen(extra)+1;
6708 break;
6709 }
6710#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306711 case WE_GET_SNR:
6712 {
6713 v_S7_t s7snr = 0;
6714 int status = 0;
6715 hdd_context_t *pHddCtx;
6716 hdd_station_ctx_t *pHddStaCtx;
6717
6718 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6719 status = wlan_hdd_validate_context(pHddCtx);
6720 if (0 != status)
6721 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306722 return status;
6723 }
6724
6725 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6726
6727 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6728 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6729 {
6730 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6731 " ConnectionState-%d", __func__,
6732 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6733 pHddStaCtx->conn_info.connState);
6734 return -ENONET;
6735 }
6736
6737 /*update the stats in TL*/
6738 wlan_hdd_get_station_stats(pAdapter);
6739 wlan_hdd_get_snr(pAdapter, &s7snr);
6740 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6741 wrqu->data.length = strlen(extra) + 1;
6742 break;
6743 }
6744
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306745 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006747 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 break;
6749 }
6750 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306751 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006752 return 0;
6753}
6754
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306755static int iw_get_char_setnone(struct net_device *dev,
6756 struct iw_request_info *info,
6757 union iwreq_data *wrqu, char *extra)
6758{
6759 int ret;
6760
6761 vos_ssr_protect(__func__);
6762 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6763 vos_ssr_unprotect(__func__);
6764
6765 return ret;
6766}
6767
Jeff Johnson295189b2012-06-20 16:38:30 -07006768/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306769static int __iw_setnone_getnone(struct net_device *dev,
6770 struct iw_request_info *info,
6771 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006772{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306773 hdd_adapter_t *pAdapter;
6774 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306775 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006776 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306777 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006778
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306779 ENTER();
6780
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306781 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6782 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006783 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6785 "%s: Adapter is NULL",__func__);
6786 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006787 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306788 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6789 ret = wlan_hdd_validate_context(pHddCtx);
6790 if (0 != ret)
6791 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306792 return ret;
6793 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306794 /* helper function to get iwreq_data with compat handling. */
6795 if (hdd_priv_get_data(&s_priv_data, wrqu))
6796 {
6797 return -EINVAL;
6798 }
6799
6800 sub_cmd = s_priv_data.flags;
6801
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 switch (sub_cmd)
6803 {
6804 case WE_CLEAR_STATS:
6805 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6808 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6809 break;
6810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006811 case WE_INIT_AP:
6812 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306813 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6814
6815 /* As Soft AP mode might been changed to STA already with
6816 * killing of Hostapd, need to find the adpater by name
6817 * rather than mode */
6818 hdd_adapter_t* pAdapter_to_stop =
6819 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6820 if( pAdapter_to_stop )
6821 {
6822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6823 "Adapter with name softap.0 already "
6824 "exist, ignoring the request.\nRemove the "
6825 "adapter and try again\n");
6826 break;
6827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006828 pr_info("Init AP trigger\n");
6829 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6830 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6831 break;
6832 }
6833 case WE_STOP_AP:
6834 {
6835 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6836 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6837 * this is a dead code and need to find the adpater by name rather than mode */
6838 hdd_adapter_t* pAdapter_to_stop =
6839 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6840 if( pAdapter_to_stop )
6841 {
6842 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6843
6844 pr_info("Stopping AP mode\n");
6845
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306846 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6847 {
6848 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6849 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6850 }
6851
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306853 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306854 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6856
6857 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6858 pAdapter_to_stop->macAddressCurrent.bytes);
6859 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6860 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306861
6862 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6863 {
6864 /* put the device back into BMPS */
6865 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006867 }
6868 else
6869 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006870 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 }
6872
6873 break;
6874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006875#ifdef WLAN_BTAMP_FEATURE
6876 case WE_ENABLE_AMP:
6877 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 WLANBAP_RegisterWithHCI(pAdapter);
6880 break;
6881 }
6882 case WE_DISABLE_AMP:
6883 {
6884 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6885 VOS_STATUS status;
6886
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006887 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006888
6889 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6890 status = WLANBAP_StopAmp();
6891 if(VOS_STATUS_SUCCESS != status )
6892 {
6893 pHddCtx->isAmpAllowed = VOS_TRUE;
6894 hddLog(VOS_TRACE_LEVEL_FATAL,
6895 "%s: Failed to stop AMP", __func__);
6896 }
6897 else
6898 {
6899 //a state m/c implementation in PAL is TBD to avoid this delay
6900 msleep(500);
6901 pHddCtx->isAmpAllowed = VOS_FALSE;
6902 WLANBAP_DeregisterFromHCI();
6903 }
6904
6905 break;
6906 }
6907#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006908 case WE_ENABLE_DXE_STALL_DETECT:
6909 {
schang6295e542013-03-12 15:31:23 -07006910 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6911 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006912 break;
6913 }
6914 case WE_DISPLAY_DXE_SNAP_SHOT:
6915 {
schang6295e542013-03-12 15:31:23 -07006916 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6917 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006918 break;
6919 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306920 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6921 {
6922 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6923 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306924 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306925 break;
6926 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306927
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306928 case WE_SET_REASSOC_TRIGGER:
6929 {
6930 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6931 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6932 v_U32_t roamId = 0;
6933 tCsrRoamModifyProfileFields modProfileFields;
6934 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6935 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6936 return 0;
6937 }
6938
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306939 case WE_STOP_OBSS_SCAN:
6940 {
6941 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6942 2.OBSS scan is stopped by Firmware during the disassociation
6943 3.OBSS stop comamnd is added for debugging purpose*/
6944 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6945 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006946
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306947 if (pAdapter == NULL)
6948 {
6949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6950 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306951 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306952 }
6953 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6954 if (pMac == NULL)
6955 {
6956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6957 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306958 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306959 }
6960 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6961 }
6962 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306963 case WE_DUMP_ROAM_TIMER_LOG:
6964 {
6965 vos_dump_roam_time_log_service();
6966 break;
6967 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306968
Mukul Sharma84f27252014-07-14 18:11:42 +05306969 case WE_RESET_ROAM_TIMER_LOG:
6970 {
6971 vos_reset_roam_timer_log();
6972 break;
6973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 default:
6975 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006976 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 break;
6978 }
6979 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306980 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 return ret;
6982}
6983
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306984static int iw_setnone_getnone(struct net_device *dev,
6985 struct iw_request_info *info,
6986 union iwreq_data *wrqu, char *extra)
6987{
6988 int ret;
6989
6990 vos_ssr_protect(__func__);
6991 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
6992 vos_ssr_unprotect(__func__);
6993
6994 return ret;
6995}
6996
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306997void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
6998{
6999 /*
7000 * Function to display HDD WMM information
7001 * for Tx Queues.
7002 * Prints globala as well as per client depending
7003 * whether the clients are registered or not.
7004 */
7005 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307006 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7007 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307008 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7009 hdd_ibss_peer_info_t *pPeerInfo;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307010
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307011 for ( i=0; i< NUM_TX_QUEUES; i++)
7012 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307013 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307014
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007015 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307016 i, pAdapter->wmm_tx_queue[i].count,
7017 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307018 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307019 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307020 if(pSapCtx == NULL){
7021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7022 FL("psapCtx is NULL"));
7023 return;
7024 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307025
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307026 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307027 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7028 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307029 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307030 {
7031 hddLog(LOGE, "******STAIndex: %d*********", i);
7032 for ( j=0; j< NUM_TX_QUEUES; j++)
7033 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307034 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007035 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307036 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
7037 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
7038 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
7039 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307040 }
7041 }
7042 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307043 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307044
Katya Nigam1fd24402015-02-16 14:52:19 +05307045 if(pHddStaCtx == NULL){
7046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7047 FL("pHddStaCtx is NULL"));
7048 return;
7049 }
7050
7051 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7052 if(pPeerInfo == NULL){
7053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7054 FL("ppeerinfo is NULL"));
7055 return;
7056 }
7057
7058 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7059 {
7060 if(pPeerInfo->ibssStaInfo[i].isUsed)
7061 {
7062 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7063 for ( j=0; j< NUM_TX_QUEUES; j++)
7064 {
7065 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7066 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7067 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7068 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7069 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7070 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7071 }
7072 }
7073 }
7074
7075
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307076}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307077static int __iw_set_var_ints_getnone(struct net_device *dev,
7078 struct iw_request_info *info,
7079 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007080{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307081 hdd_adapter_t *pAdapter;
7082 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307083 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307084 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007085 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307086 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007087 hdd_ap_ctx_t *pAPCtx = NULL;
7088 int cmd = 0;
7089 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307090 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007091
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307092 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307093 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307094 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7096 "%s: NULL extra buffer pointer", __func__);
7097 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307098 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307099 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7100 if (NULL == pAdapter)
7101 {
7102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7103 "%s: Adapter is NULL",__func__);
7104 return -EINVAL;
7105 }
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307106 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7107 ret = wlan_hdd_validate_context(pHddCtx);
7108 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007109 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307110 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007111 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307112 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7113 if (NULL == hHal)
7114 {
7115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7116 "%s: Hal Context is NULL",__func__);
7117 return -EINVAL;
7118 }
7119 sub_cmd = wrqu->data.flags;
7120
7121 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7122
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007123
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007124 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7125 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7126 {
7127 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7128 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7129 {
7130 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7131 staId = pStaCtx->conn_info.staId[0];
7132 }
7133 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7134 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7135 {
7136 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7137 staId = pAPCtx->uBCStaId;
7138 }
7139 else
7140 {
7141 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7142 return 0;
7143 }
7144 }
7145
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 switch (sub_cmd)
7147 {
7148 case WE_LOG_DUMP_CMD:
7149 {
7150 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007151 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007152 apps_args[3], apps_args[4]);
7153
7154 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7155 apps_args[3], apps_args[4]);
7156
7157 }
7158 break;
7159
Jeff Johnson295189b2012-06-20 16:38:30 -07007160 case WE_P2P_NOA_CMD:
7161 {
7162 p2p_app_setP2pPs_t p2pNoA;
7163
7164 p2pNoA.opp_ps = apps_args[0];
7165 p2pNoA.ctWindow = apps_args[1];
7166 p2pNoA.duration = apps_args[2];
7167 p2pNoA.interval = apps_args[3];
7168 p2pNoA.count = apps_args[4];
7169 p2pNoA.single_noa_duration = apps_args[5];
7170 p2pNoA.psSelection = apps_args[6];
7171
7172 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7173 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007174 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7176
7177 hdd_setP2pPs(dev, &p2pNoA);
7178
7179 }
7180 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007181
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307182 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7183 {
7184 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7185 __func__, apps_args[0], apps_args[1]);
7186 vosTraceEnable(apps_args[0], apps_args[1]);
7187 }
7188 break;
7189
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007190 case WE_MTRACE_DUMP_CMD:
7191 {
7192 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7193 "bitmask_of_module %d ",
7194 __func__, apps_args[0], apps_args[1], apps_args[2],
7195 apps_args[3]);
7196 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7197 apps_args[2], apps_args[3]);
7198
7199 }
7200 break;
7201
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007202 case WE_MCC_CONFIG_CREDENTIAL :
7203 {
7204 cmd = 287; //Command should be updated if there is any change
7205 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007206 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007207 {
7208 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7209 }
7210 else
7211 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007212 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007213 return 0;
7214 }
7215 }
7216 break;
7217
7218 case WE_MCC_CONFIG_PARAMS :
7219 {
7220 cmd = 288; //command Should be updated if there is any change
7221 // in the Riva dump command
7222 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7223 }
7224 break;
7225
Chilam NG571c65a2013-01-19 12:27:36 +05307226#ifdef FEATURE_WLAN_TDLS
7227 case WE_TDLS_CONFIG_PARAMS :
7228 {
7229 tdls_config_params_t tdlsParams;
7230
Chilam Ng01120412013-02-19 18:32:21 -08007231 tdlsParams.tdls = apps_args[0];
7232 tdlsParams.tx_period_t = apps_args[1];
7233 tdlsParams.tx_packet_n = apps_args[2];
7234 tdlsParams.discovery_period_t = apps_args[3];
7235 tdlsParams.discovery_tries_n = apps_args[4];
7236 tdlsParams.idle_timeout_t = apps_args[5];
7237 tdlsParams.idle_packet_n = apps_args[6];
7238 tdlsParams.rssi_hysteresis = apps_args[7];
7239 tdlsParams.rssi_trigger_threshold = apps_args[8];
7240 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307241
Chilam Ng01120412013-02-19 18:32:21 -08007242 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307243 }
7244 break;
7245#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 default:
7247 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007248 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7249 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 }
7251 break;
7252 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307253 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 return 0;
7255}
7256
Girish Gowlifb9758e2014-11-19 15:19:17 +05307257static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7258 struct iw_request_info *info,
7259 union iwreq_data *wrqu, char *extra)
7260{
7261 int ret;
7262 union iwreq_data u_priv_wrqu;
7263 int apps_args[MAX_VAR_ARGS] = {0};
7264 int num_args;
7265
7266 /* helper function to get iwreq_data with compat handling. */
7267 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7268 {
7269 return -EINVAL;
7270 }
7271
7272 if (NULL == u_priv_wrqu.data.pointer)
7273 {
7274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7275 "%s: NULL data pointer", __func__);
7276 return -EINVAL;
7277 }
7278
7279 num_args = u_priv_wrqu.data.length;
7280 if (num_args > MAX_VAR_ARGS)
7281 {
7282 num_args = MAX_VAR_ARGS;
7283 }
7284
7285 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7286 (sizeof(int)) * num_args))
7287 {
7288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7289 "%s: failed to copy data from user buffer", __func__);
7290 return -EFAULT;
7291 }
7292
7293 vos_ssr_protect(__func__);
7294 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7295 (char *)&apps_args);
7296 vos_ssr_unprotect(__func__);
7297
7298 return ret;
7299}
7300
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307301int iw_set_var_ints_getnone(struct net_device *dev,
7302 struct iw_request_info *info,
7303 union iwreq_data *wrqu, char *extra)
7304{
7305 int ret;
7306 vos_ssr_protect(__func__);
7307 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7308 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007309
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307310 return ret;
7311}
7312
7313static int __iw_add_tspec(struct net_device *dev,
7314 struct iw_request_info *info,
7315 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007316{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307317 hdd_adapter_t *pAdapter;
7318 hdd_station_ctx_t *pHddStaCtx;
7319 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007320 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7321 int params[HDD_WLAN_WMM_PARAM_COUNT];
7322 sme_QosWmmTspecInfo tSpec;
7323 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307324 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307325 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007326
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307327 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307328 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7329 if (NULL == pAdapter)
7330 {
7331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7332 "%s: Adapter is NULL",__func__);
7333 return -EINVAL;
7334 }
7335 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7336 ret = wlan_hdd_validate_context(pHddCtx);
7337 if (0 != ret)
7338 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307339 return ret;
7340 }
7341 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7342 if (NULL == pHddStaCtx)
7343 {
7344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7345 "%s: STA Context is NULL",__func__);
7346 return -EINVAL;
7347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 // make sure the application is sufficiently priviledged
7349 // note that the kernel will do this for "set" ioctls, but since
7350 // this ioctl wants to return status to user space it must be
7351 // defined as a "get" ioctl
7352 if (!capable(CAP_NET_ADMIN))
7353 {
7354 return -EPERM;
7355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 // we must be associated in order to add a tspec
7357 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7358 {
7359 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7360 return 0;
7361 }
7362
7363 // since we are defined to be a "get" ioctl, and since the number
7364 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307365 // will pass down in the iwreq_data, we must copy the "set" params.
7366 // We must handle the compat for iwreq_data in 32U/64K environment.
7367
7368 // helper fucntion to get iwreq_data with compat handling.
7369 if (hdd_priv_get_data(&s_priv_data, wrqu))
7370 {
7371 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7372 return 0;
7373 }
7374
7375 // make sure all params are correctly passed to function
7376 if ((NULL == s_priv_data.pointer) ||
7377 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7378 {
7379 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7380 return 0;
7381 }
7382
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307384 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 {
7386 // hmmm, can't get them
7387 return -EIO;
7388 }
7389
7390 // clear the tspec
7391 memset(&tSpec, 0, sizeof(tSpec));
7392
7393 // validate the handle
7394 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7395 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7396 {
7397 // that one is reserved
7398 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7399 return 0;
7400 }
7401
7402 // validate the TID
7403 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7404 {
7405 // out of range
7406 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7407 return 0;
7408 }
7409 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7410
7411 // validate the direction
7412 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7413 {
7414 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7415 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7416 break;
7417
7418 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7419 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7420 break;
7421
7422 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7423 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7424 break;
7425
7426 default:
7427 // unknown
7428 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7429 return 0;
7430 }
7431
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307432 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7433
Jeff Johnson295189b2012-06-20 16:38:30 -07007434 // validate the user priority
7435 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7436 {
7437 // out of range
7438 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7439 return 0;
7440 }
7441 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307442 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7443 {
7444 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7445 return 0;
7446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007447
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7449 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7450 tSpec.ts_info.psb, tSpec.ts_info.up);
7451
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7453 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7454 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7455 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7456 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7457 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7458 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7459 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7460 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7461 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7462 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7463 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7464
7465 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7466
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307467 // Save the expected UAPSD settings by application, this will be needed
7468 // when re-negotiating UAPSD settings during BT Coex cases.
7469 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7470
Jeff Johnson295189b2012-06-20 16:38:30 -07007471 // validate the ts info ack policy
7472 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7473 {
7474 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7475 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7476 break;
7477
7478 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7479 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7480 break;
7481
7482 default:
7483 // unknown
7484 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7485 return 0;
7486 }
7487
7488 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307489
7490 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007491 return 0;
7492}
7493
7494
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307495static int iw_add_tspec(struct net_device *dev,
7496 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 union iwreq_data *wrqu, char *extra)
7498{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307499 int ret;
7500
7501 vos_ssr_protect(__func__);
7502 ret = __iw_add_tspec(dev, info, wrqu, extra);
7503 vos_ssr_unprotect(__func__);
7504
7505 return ret;
7506}
7507
7508static int __iw_del_tspec(struct net_device *dev,
7509 struct iw_request_info *info,
7510 union iwreq_data *wrqu, char *extra)
7511{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307512 hdd_adapter_t *pAdapter;
7513 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007514 int *params = (int *)extra;
7515 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7516 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307517 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007518
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307519 ENTER();
7520
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307521 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7522 if (NULL == pAdapter)
7523 {
7524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7525 "%s: Adapter is NULL",__func__);
7526 return -EINVAL;
7527 }
7528
7529 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7530 ret = wlan_hdd_validate_context(pHddCtx);
7531 if (0 != ret)
7532 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307533 return ret;
7534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 // make sure the application is sufficiently priviledged
7536 // note that the kernel will do this for "set" ioctls, but since
7537 // this ioctl wants to return status to user space it must be
7538 // defined as a "get" ioctl
7539 if (!capable(CAP_NET_ADMIN))
7540 {
7541 return -EPERM;
7542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007543 // although we are defined to be a "get" ioctl, the params we require
7544 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7545 // is no need to copy the params from user space
7546
7547 // validate the handle
7548 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7549 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7550 {
7551 // that one is reserved
7552 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7553 return 0;
7554 }
7555
7556 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307557
7558 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007559 return 0;
7560}
7561
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307562static int iw_del_tspec(struct net_device *dev,
7563 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007564 union iwreq_data *wrqu, char *extra)
7565{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307566 int ret;
7567
7568 vos_ssr_protect(__func__);
7569 ret = __iw_del_tspec(dev, info, wrqu, extra);
7570 vos_ssr_unprotect(__func__);
7571
7572 return ret;
7573}
7574
7575
7576static int __iw_get_tspec(struct net_device *dev,
7577 struct iw_request_info *info,
7578 union iwreq_data *wrqu, char *extra)
7579{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307580 hdd_adapter_t *pAdapter;
7581 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 int *params = (int *)extra;
7583 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7584 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307585 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007586
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307587 ENTER();
7588
Jeff Johnson295189b2012-06-20 16:38:30 -07007589 // although we are defined to be a "get" ioctl, the params we require
7590 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7591 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307592 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7593 if (NULL == pAdapter)
7594 {
7595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7596 "%s: Adapter is NULL",__func__);
7597 return -EINVAL;
7598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007599
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307600 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7601 ret = wlan_hdd_validate_context(pHddCtx);
7602 if (0 != ret)
7603 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307604 return ret;
7605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007606 // validate the handle
7607 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7608 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7609 {
7610 // that one is reserved
7611 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7612 return 0;
7613 }
7614
7615 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307616 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 return 0;
7618}
7619
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307620static int iw_get_tspec(struct net_device *dev,
7621 struct iw_request_info *info,
7622 union iwreq_data *wrqu, char *extra)
7623{
7624 int ret;
7625
7626 vos_ssr_protect(__func__);
7627 ret = __iw_get_tspec(dev, info, wrqu, extra);
7628 vos_ssr_unprotect(__func__);
7629
7630 return ret;
7631}
7632
Jeff Johnson295189b2012-06-20 16:38:30 -07007633#ifdef WLAN_FEATURE_VOWIFI_11R
7634//
7635//
7636// Each time the supplicant has the auth_request or reassoc request
7637// IEs ready. This is pushed to the driver. The driver will inturn use
7638// it to send out the auth req and reassoc req for 11r FT Assoc.
7639//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307640static int __iw_set_fties(struct net_device *dev,
7641 struct iw_request_info *info,
7642 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007643{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307644 hdd_adapter_t *pAdapter;
7645 hdd_station_ctx_t *pHddStaCtx;
7646 hdd_context_t *pHddCtx;
7647 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007648 //v_CONTEXT_t pVosContext;
7649
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307650 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307651 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7652 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007653 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7655 "%s: Adapter is NULL",__func__);
7656 return -EINVAL;
7657 }
7658 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7659 ret = wlan_hdd_validate_context(pHddCtx);
7660 if (0 != ret)
7661 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307662 return ret;
7663 }
7664 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7665 if (NULL == pHddStaCtx)
7666 {
7667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7668 "%s: STA Context is NULL",__func__);
7669 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 if (!wrqu->data.length)
7672 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007673 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 return -EINVAL;
7675 }
7676 if (wrqu->data.pointer == NULL)
7677 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007678 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007679 return -EINVAL;
7680 }
7681
7682 // Added for debug on reception of Re-assoc Req.
7683 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7684 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007685 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007686 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007687 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007688 }
7689
7690#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007691 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007692#endif
7693
7694 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007695 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007696 wrqu->data.length);
7697
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307698 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007699 return 0;
7700}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307701
7702static int iw_set_fties(struct net_device *dev,
7703 struct iw_request_info *info,
7704 union iwreq_data *wrqu, char *extra)
7705{
7706 int ret;
7707
7708 vos_ssr_protect(__func__);
7709 ret = __iw_set_fties(dev, info, wrqu, extra);
7710 vos_ssr_unprotect(__func__);
7711
7712 return ret;
7713}
Jeff Johnson295189b2012-06-20 16:38:30 -07007714#endif
7715
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307716static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007717 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007719{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307720 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007721 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307722 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007723 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307724 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007725 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7726 int idx;
7727 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007728
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307729 ENTER();
7730
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307731 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7732 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007733 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7735 "%s: Adapter is NULL",__func__);
7736 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007737 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307738 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7739 ret_val = wlan_hdd_validate_context(pHddCtx);
7740 if (0 != ret_val)
7741 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307742 return ret_val;
7743 }
7744 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7745 if (NULL == hHal)
7746 {
7747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7748 "%s: Hal Context is NULL",__func__);
7749 return -EINVAL;
7750 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307751 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7752 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307753#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007754
Amar Singhalf3a6e762013-02-19 15:06:50 -08007755 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7756 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007757 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007758 hddLog(VOS_TRACE_LEVEL_ERROR,
7759 "%s: vos_mem_alloc failed", __func__);
7760 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007761 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007762
7763 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7764
7765 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7766 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7767
7768 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7769 mc_addr_list_ptr->ulMulticastAddrCnt);
7770
7771 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007772 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007773 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7774 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7775
7776 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7777 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007778 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007779
Amar Singhalf3a6e762013-02-19 15:06:50 -08007780 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7781 vos_mem_free(mc_addr_list_ptr);
7782 if (eHAL_STATUS_SUCCESS != ret_val)
7783 {
7784 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7785 __func__);
7786 return -EINVAL;
7787 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307788#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307789 }
7790 else
7791 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007792
Amar Singhalf3a6e762013-02-19 15:06:50 -08007793 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7794 "%s: Set MC BC Filter Config request: %d suspend %d",
7795 __func__, pRequest->mcastBcastFilterSetting,
7796 pHddCtx->hdd_wlan_suspended);
7797
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307798 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007799
7800 if (pHddCtx->hdd_wlan_suspended)
7801 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007802 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7803 if (NULL == wlanRxpFilterParam)
7804 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307805 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007806 "%s: vos_mem_alloc failed", __func__);
7807 return -EINVAL;
7808 }
7809
Amar Singhalf3a6e762013-02-19 15:06:50 -08007810 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7811 pRequest->mcastBcastFilterSetting;
7812 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7813
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307814 hdd_conf_hostoffload(pAdapter, TRUE);
7815 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7816 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007817
7818 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7819 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307820 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007821 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7822 wlanRxpFilterParam->setMcstBcstFilter);
7823
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307824 if (eHAL_STATUS_SUCCESS !=
7825 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7826 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007827 {
7828 hddLog(VOS_TRACE_LEVEL_ERROR,
7829 "%s: Failure to execute set HW MC/BC Filter request",
7830 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007831 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007832 return -EINVAL;
7833 }
7834
c_hpothud3ce76d2014-10-28 10:34:13 +05307835 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7836 {
7837 pHddCtx->sus_res_mcastbcast_filter =
7838 pRequest->mcastBcastFilterSetting;
7839 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007840 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007842
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307843 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 return 0;
7845}
7846
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307847static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7848 struct iw_request_info *info,
7849 union iwreq_data *wrqu, char *extra)
7850{
7851 int ret;
7852
7853 vos_ssr_protect(__func__);
7854 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
7855 vos_ssr_unprotect(__func__);
7856
7857 return ret;
7858}
7859
7860static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7861 struct iw_request_info *info,
7862 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007863{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307864 hdd_adapter_t *pAdapter;
7865 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307866 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307867 int ret = 0;
7868
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307869 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007870
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307871 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7872 if (NULL == pAdapter)
7873 {
7874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7875 "%s: Adapter is NULL",__func__);
7876 return -EINVAL;
7877 }
7878
7879 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7880 ret = wlan_hdd_validate_context(pHddCtx);
7881 if (0 != ret)
7882 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307883 return ret;
7884 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307885 //Reset the filter to INI value as we have to clear the dynamic filter
7886 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07007887
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307888 //Configure FW with new setting
7889 if (pHddCtx->hdd_wlan_suspended)
7890 {
7891 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7892 if (NULL == wlanRxpFilterParam)
7893 {
7894 hddLog(VOS_TRACE_LEVEL_ERROR,
7895 "%s: vos_mem_alloc failed", __func__);
7896 return -EINVAL;
7897 }
7898
7899 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7900 pHddCtx->configuredMcastBcastFilter;
7901 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7902
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307903 hdd_conf_hostoffload(pAdapter, TRUE);
7904 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7905 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307906
7907 if (eHAL_STATUS_SUCCESS !=
7908 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7909 wlanRxpFilterParam))
7910 {
7911 hddLog(VOS_TRACE_LEVEL_ERROR,
7912 "%s: Failure to execute set HW MC/BC Filter request",
7913 __func__);
7914 vos_mem_free(wlanRxpFilterParam);
7915 return -EINVAL;
7916 }
c_hpothud3ce76d2014-10-28 10:34:13 +05307917
7918 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7919 {
7920 pHddCtx->sus_res_mcastbcast_filter =
7921 pHddCtx->cfg_ini->mcastBcastFilterSetting;
7922 }
7923
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307924 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307925 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007926 return 0;
7927}
7928
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307929
7930static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7931 struct iw_request_info *info,
7932 union iwreq_data *wrqu, char *extra)
7933{
7934 int ret;
7935
7936 vos_ssr_protect(__func__);
7937 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
7938 vos_ssr_unprotect(__func__);
7939
7940 return ret;
7941}
7942
7943static int __iw_set_host_offload(struct net_device *dev,
7944 struct iw_request_info *info,
7945 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007946{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307947 hdd_adapter_t *pAdapter;
7948 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007949 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007950 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307951 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007952
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307953 ENTER();
7954
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307955 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7956 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007957 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7959 "%s: Adapter is NULL",__func__);
7960 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007961 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307962 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7963 ret = wlan_hdd_validate_context(pHddCtx);
7964 if (0 != ret)
7965 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307966 return ret;
7967 }
7968
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 /* Debug display of request components. */
7970 switch (pRequest->offloadType)
7971 {
7972 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007973 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007974 switch (pRequest->enableOrDisable)
7975 {
7976 case WLAN_OFFLOAD_DISABLE:
7977 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
7978 break;
7979 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
7980 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
7981 case WLAN_OFFLOAD_ENABLE:
7982 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
7983 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
7984 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
7985 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
7986 }
7987 break;
7988
7989 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08007990 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007991 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007992 switch (pRequest->enableOrDisable)
7993 {
7994 case WLAN_OFFLOAD_DISABLE:
7995 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
7996 break;
7997 case WLAN_OFFLOAD_ENABLE:
7998 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
7999 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8000 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8001 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8002 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8003 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8004 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8005 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8006 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8007 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8008 }
8009 }
8010
8011 /* Execute offload request. The reason that we can copy the request information
8012 from the ioctl structure to the SME structure is that they are laid out
8013 exactly the same. Otherwise, each piece of information would have to be
8014 copied individually. */
8015 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008016 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8017 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008018 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008019 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008020 __func__);
8021 return -EINVAL;
8022 }
8023
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308024 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 return 0;
8026}
8027
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308028static int iw_set_host_offload(struct net_device *dev,
8029 struct iw_request_info *info,
8030 union iwreq_data *wrqu, char *extra)
8031{
8032 int ret;
8033
8034 vos_ssr_protect(__func__);
8035 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8036 vos_ssr_unprotect(__func__);
8037
8038 return ret;
8039}
8040
8041static int __iw_set_keepalive_params(struct net_device *dev,
8042 struct iw_request_info *info,
8043 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008044{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308045 hdd_adapter_t *pAdapter;
8046 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008047 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308049 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008050
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308051 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308052 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8053 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008054 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8056 "%s: Adapter is NULL",__func__);
8057 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008058 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308059 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8060 ret = wlan_hdd_validate_context(pHddCtx);
8061 if (0 != ret)
8062 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308063 return ret;
8064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008066 hddLog(VOS_TRACE_LEVEL_INFO,
8067 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8068 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008069
8070 switch (pRequest->packetType)
8071 {
8072 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008073 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008074 break;
8075
8076 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8077
Arif Hussain6d2a3322013-11-17 19:50:10 -08008078 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008079 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008080
8081 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8082 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8083 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8084
8085 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8086 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8087 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8088
8089 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8090 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8091 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8092 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8093 break;
8094
8095 }
8096
8097 /* Execute keep alive request. The reason that we can copy the request information
8098 from the ioctl structure to the SME structure is that they are laid out
8099 exactly the same. Otherwise, each piece of information would have to be
8100 copied individually. */
8101 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8102
Arif Hussain6d2a3322013-11-17 19:50:10 -08008103 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008104
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008105 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008106 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008107 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008108 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008109 __func__);
8110 return -EINVAL;
8111 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308112 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 return 0;
8114}
8115
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308116static int iw_set_keepalive_params(struct net_device *dev,
8117 struct iw_request_info *info,
8118 union iwreq_data *wrqu, char *extra)
8119{
8120 int ret;
8121 vos_ssr_protect(__func__);
8122 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8123 vos_ssr_unprotect(__func__);
8124
8125 return ret;
8126}
8127
Jeff Johnson295189b2012-06-20 16:38:30 -07008128#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008129int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008130 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008131{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008132 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8133 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 int i=0;
8135
8136 if (pHddCtx->cfg_ini->disablePacketFilter)
8137 {
8138 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008139 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008140 return 0;
8141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008142 /* Debug display of request components. */
8143 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008144 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008145
8146 switch (pRequest->filterAction)
8147 {
8148 case HDD_RCV_FILTER_SET:
8149 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008150 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008151
8152 packetFilterSetReq.filterId = pRequest->filterId;
8153 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8154 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008155 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 __func__, pRequest->numParams);
8157 return -EINVAL;
8158 }
8159 packetFilterSetReq.numFieldParams = pRequest->numParams;
8160 packetFilterSetReq.coalesceTime = 0;
8161 packetFilterSetReq.filterType = 1;
8162 for (i=0; i < pRequest->numParams; i++)
8163 {
8164 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8165 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8166 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8167 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8168 packetFilterSetReq.paramsData[i].reserved = 0;
8169
Arif Hussain6d2a3322013-11-17 19:50:10 -08008170 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008171 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8172 packetFilterSetReq.filterType);
8173
Arif Hussain6d2a3322013-11-17 19:50:10 -08008174 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8176
8177 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8178 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8179 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8180 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8181
Arif Hussain6d2a3322013-11-17 19:50:10 -08008182 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8184 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8185 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8186
Arif Hussain6d2a3322013-11-17 19:50:10 -08008187 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008188 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8189 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8190 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8191 }
8192
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008193 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008194 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008195 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 __func__);
8197 return -EINVAL;
8198 }
8199
8200 break;
8201
8202 case HDD_RCV_FILTER_CLEAR:
8203
Arif Hussain6d2a3322013-11-17 19:50:10 -08008204 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008205 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008206 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008207 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008208 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008209 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008210 __func__);
8211 return -EINVAL;
8212 }
8213 break;
8214
8215 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008216 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008217 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 return -EINVAL;
8219 }
8220 return 0;
8221}
8222
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308223int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8224 tANI_U8 sessionId)
8225{
8226 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8227 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8228
8229 if (NULL == pHddCtx)
8230 {
8231 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8232 return -EINVAL;
8233 }
8234
8235 if (pHddCtx->isLogpInProgress)
8236 {
8237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8238 "%s:LOGP in Progress. Ignore!!!", __func__);
8239 return -EBUSY;
8240 }
8241
8242 if (pHddCtx->cfg_ini->disablePacketFilter)
8243 {
8244 hddLog(VOS_TRACE_LEVEL_ERROR,
8245 "%s: Packet Filtering Disabled. Returning ",
8246 __func__ );
8247 return -EINVAL;
8248 }
8249
8250 switch (filterType)
8251 {
8252 /* For setting IPV6 MC and UC Filter we need to configure
8253 * 2 filters, one for MC and one for UC.
8254 * The Filter ID shouldn't be swapped, which results in making
8255 * UC Filter ineffective.
8256 * We have Hardcode all the values
8257 *
8258 * Reason for a seperate UC filter is because, driver need to
8259 * specify the FW that the specific filter is for unicast
8260 * otherwise FW will not pass the unicast frames by default
8261 * through the filter. This is required to avoid any performance
8262 * hits when no unicast filter is set and only MC/BC are set.
8263 * The way driver informs host is by using the MAC protocol
8264 * layer, CMP flag set to MAX, CMP Data set to 1.
8265 */
8266
8267 case HDD_FILTER_IPV6_MC_UC:
8268 /* Setting IPV6 MC Filter below
8269 */
8270 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8271 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8272 packetFilterSetReq.numFieldParams = 2;
8273 packetFilterSetReq.paramsData[0].protocolLayer =
8274 HDD_FILTER_PROTO_TYPE_MAC;
8275 packetFilterSetReq.paramsData[0].cmpFlag =
8276 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8277 packetFilterSetReq.paramsData[0].dataOffset =
8278 WLAN_HDD_80211_FRM_DA_OFFSET;
8279 packetFilterSetReq.paramsData[0].dataLength = 1;
8280 packetFilterSetReq.paramsData[0].compareData[0] =
8281 HDD_IPV6_MC_CMP_DATA;
8282
8283 packetFilterSetReq.paramsData[1].protocolLayer =
8284 HDD_FILTER_PROTO_TYPE_ARP;
8285 packetFilterSetReq.paramsData[1].cmpFlag =
8286 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8287 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8288 packetFilterSetReq.paramsData[1].dataLength = 2;
8289 packetFilterSetReq.paramsData[1].compareData[0] =
8290 HDD_IPV6_CMP_DATA_0;
8291 packetFilterSetReq.paramsData[1].compareData[1] =
8292 HDD_IPV6_CMP_DATA_1;
8293
8294
8295 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8296 &packetFilterSetReq, sessionId))
8297 {
8298 hddLog(VOS_TRACE_LEVEL_ERROR,
8299 "%s: Failure to execute Set IPv6 Mulicast Filter",
8300 __func__);
8301 return -EINVAL;
8302 }
8303
8304 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8305
8306 /*
8307 * Setting IPV6 UC Filter below
8308 */
8309 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8310 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8311 packetFilterSetReq.numFieldParams = 2;
8312 packetFilterSetReq.paramsData[0].protocolLayer =
8313 HDD_FILTER_PROTO_TYPE_MAC;
8314 packetFilterSetReq.paramsData[0].cmpFlag =
8315 HDD_FILTER_CMP_TYPE_MAX;
8316 packetFilterSetReq.paramsData[0].dataOffset = 0;
8317 packetFilterSetReq.paramsData[0].dataLength = 1;
8318 packetFilterSetReq.paramsData[0].compareData[0] =
8319 HDD_IPV6_UC_CMP_DATA;
8320
8321 packetFilterSetReq.paramsData[1].protocolLayer =
8322 HDD_FILTER_PROTO_TYPE_ARP;
8323 packetFilterSetReq.paramsData[1].cmpFlag =
8324 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8325 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8326 packetFilterSetReq.paramsData[1].dataLength = 2;
8327 packetFilterSetReq.paramsData[1].compareData[0] =
8328 HDD_IPV6_CMP_DATA_0;
8329 packetFilterSetReq.paramsData[1].compareData[1] =
8330 HDD_IPV6_CMP_DATA_1;
8331
8332 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8333 &packetFilterSetReq, sessionId))
8334 {
8335 hddLog(VOS_TRACE_LEVEL_ERROR,
8336 "%s: Failure to execute Set IPv6 Unicast Filter",
8337 __func__);
8338 return -EINVAL;
8339 }
8340
8341 break;
8342
8343 case HDD_FILTER_IPV6_MC:
8344 /*
8345 * IPV6 UC Filter might be already set,
8346 * clear the UC Filter. As the Filter
8347 * IDs are static, we can directly clear it.
8348 */
8349 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8350 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8351 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8352 &packetFilterClrReq, sessionId))
8353 {
8354 hddLog(VOS_TRACE_LEVEL_ERROR,
8355 "%s: Failure to execute Clear IPv6 Unicast Filter",
8356 __func__);
8357 return -EINVAL;
8358 }
8359
8360 /*
8361 * Setting IPV6 MC Filter below
8362 */
8363 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8364 packetFilterSetReq.numFieldParams = 2;
8365 packetFilterSetReq.paramsData[0].protocolLayer =
8366 HDD_FILTER_PROTO_TYPE_MAC;
8367 packetFilterSetReq.paramsData[0].cmpFlag =
8368 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8369 packetFilterSetReq.paramsData[0].dataOffset =
8370 WLAN_HDD_80211_FRM_DA_OFFSET;
8371 packetFilterSetReq.paramsData[0].dataLength = 1;
8372 packetFilterSetReq.paramsData[0].compareData[0] =
8373 HDD_IPV6_MC_CMP_DATA;
8374
8375 packetFilterSetReq.paramsData[1].protocolLayer =
8376 HDD_FILTER_PROTO_TYPE_ARP;
8377 packetFilterSetReq.paramsData[1].cmpFlag =
8378 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8379 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8380 packetFilterSetReq.paramsData[1].dataLength = 2;
8381 packetFilterSetReq.paramsData[1].compareData[0] =
8382 HDD_IPV6_CMP_DATA_0;
8383 packetFilterSetReq.paramsData[1].compareData[1] =
8384 HDD_IPV6_CMP_DATA_1;
8385
8386
8387 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8388 &packetFilterSetReq, sessionId))
8389 {
8390 hddLog(VOS_TRACE_LEVEL_ERROR,
8391 "%s: Failure to execute Set IPv6 Multicast Filter",
8392 __func__);
8393 return -EINVAL;
8394 }
8395 break;
8396
8397 default :
8398 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8399 "%s: Packet Filter Request: Invalid",
8400 __func__);
8401 return -EINVAL;
8402 }
8403 return 0;
8404}
8405
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308406void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008407{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308408 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308409 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008410 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308411 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008412
Yue Ma3ede6052013-08-29 00:33:26 -07008413 if (NULL == pHddCtx)
8414 {
8415 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8416 return;
8417 }
8418
8419 hHal = pHddCtx->hHal;
8420
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308421 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008422 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308423 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8424 return;
8425 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308426
8427 /* Check if INI is enabled or not, other wise just return
8428 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308429 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308430 {
8431 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8432 if (NULL == pMulticastAddrs)
8433 {
8434 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8435 return;
8436 }
8437
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 if (set)
8439 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308440 /* Following pre-conditions should be satisfied before wei
8441 * configure the MC address list.
8442 */
8443 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8444 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8445 && pAdapter->mc_addr_list.mc_cnt
8446 && (eConnectionState_Associated ==
8447 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8448 {
8449 pMulticastAddrs->ulMulticastAddrCnt =
8450 pAdapter->mc_addr_list.mc_cnt;
8451 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8452 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008453 memcpy(pMulticastAddrs->multicastAddr[i],
8454 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308455 sizeof(pAdapter->mc_addr_list.addr[i]));
8456 hddLog(VOS_TRACE_LEVEL_INFO,
8457 "%s: %s multicast filter: addr ="
8458 MAC_ADDRESS_STR,
8459 __func__, set ? "setting" : "clearing",
8460 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8461 }
8462 /* Set multicast filter */
8463 sme_8023MulticastList(hHal, pAdapter->sessionId,
8464 pMulticastAddrs);
8465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308467 else
8468 {
8469 /* Need to clear only if it was previously configured
8470 */
8471 if (pAdapter->mc_addr_list.isFilterApplied)
8472 {
8473 pMulticastAddrs->ulMulticastAddrCnt = 0;
8474 sme_8023MulticastList(hHal, pAdapter->sessionId,
8475 pMulticastAddrs);
8476 }
8477
8478 }
8479 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008480 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308482 else
8483 {
8484 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308485 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308486 }
8487 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008488}
8489
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308490static int __iw_set_packet_filter_params(struct net_device *dev,
8491 struct iw_request_info *info,
8492 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308493{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308494 hdd_adapter_t *pAdapter;
8495 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008496 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308497 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308498 struct iw_point s_priv_data;
8499
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308500 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308501 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8502 if (NULL == pAdapter)
8503 {
8504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8505 "%s: Adapter is NULL",__func__);
8506 return -EINVAL;
8507 }
8508 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8509 ret = wlan_hdd_validate_context(pHddCtx);
8510 if (0 != ret)
8511 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308512 return ret;
8513 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308514 if (hdd_priv_get_data(&s_priv_data, wrqu))
8515 {
8516 return -EINVAL;
8517 }
8518
8519 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8520 {
8521 return -EINVAL;
8522 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008523
Arif Hussain0273cba2014-01-07 20:58:29 -08008524 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308525 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8526 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008527 if (NULL == pRequest)
8528 {
8529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8530 "mem_alloc_copy_from_user_helper fail");
8531 return -ENOMEM;
8532 }
8533
8534 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8535 kfree(pRequest);
8536
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308537 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008538 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008539}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308540
8541static int iw_set_packet_filter_params(struct net_device *dev,
8542 struct iw_request_info *info,
8543 union iwreq_data *wrqu, char *extra)
8544{
8545 int ret;
8546
8547 vos_ssr_protect(__func__);
8548 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8549 vos_ssr_unprotect(__func__);
8550
8551 return ret;
8552}
Jeff Johnson295189b2012-06-20 16:38:30 -07008553#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308554static int __iw_get_statistics(struct net_device *dev,
8555 struct iw_request_info *info,
8556 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008557{
8558
8559 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8560 eHalStatus status = eHAL_STATUS_SUCCESS;
8561 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308562 hdd_adapter_t *pAdapter;
8563 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308565 int tlen = 0, ret = 0;
8566 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008567
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308568 tCsrGlobalClassAStatsInfo *aStats;
8569 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008570
8571 ENTER();
8572
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308573 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8574 if (NULL == pAdapter)
8575 {
8576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8577 "%s: Adapter is NULL",__func__);
8578 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008579 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308580 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8581 ret = wlan_hdd_validate_context(pHddCtx);
8582 if (0 != ret)
8583 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308584 return ret;
8585 }
8586 pStats = &(pAdapter->hdd_stats.summary_stat);
8587 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8588 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008589 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8590
8591 wrqu->txpower.value = 0;
8592 }
8593 else {
8594 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8595 SME_SUMMARY_STATS |
8596 SME_GLOBAL_CLASSA_STATS |
8597 SME_GLOBAL_CLASSB_STATS |
8598 SME_GLOBAL_CLASSC_STATS |
8599 SME_GLOBAL_CLASSD_STATS |
8600 SME_PER_STA_STATS,
8601 hdd_StatisticsCB, 0, FALSE,
8602 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8603
8604 if (eHAL_STATUS_SUCCESS != status)
8605 {
8606 hddLog(VOS_TRACE_LEVEL_ERROR,
8607 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008608 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 return -EINVAL;
8610 }
8611
8612 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308613 if (NULL == pWextState)
8614 {
8615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8616 "%s: pWextState is NULL",__func__);
8617 return -EINVAL;
8618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008619
8620 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8621 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8622 {
8623 hddLog(VOS_TRACE_LEVEL_ERROR,
8624 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008625 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008626 /*Remove the SME statistics list by passing NULL in callback argument*/
8627 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8628 SME_SUMMARY_STATS |
8629 SME_GLOBAL_CLASSA_STATS |
8630 SME_GLOBAL_CLASSB_STATS |
8631 SME_GLOBAL_CLASSC_STATS |
8632 SME_GLOBAL_CLASSD_STATS |
8633 SME_PER_STA_STATS,
8634 NULL, 0, FALSE,
8635 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8636
8637 return -EINVAL;
8638 }
8639 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8640 (tANI_U8) sizeof (pStats->retry_cnt),
8641 (char*) &(pStats->retry_cnt[0]),
8642 tlen);
8643
8644 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8645 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8646 (char*) &(pStats->multiple_retry_cnt[0]),
8647 tlen);
8648
8649 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8650 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8651 (char*) &(pStats->tx_frm_cnt[0]),
8652 tlen);
8653
8654 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8655 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8656 (char*) &(pStats->rx_frm_cnt),
8657 tlen);
8658
8659 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8660 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8661 (char*) &(pStats->frm_dup_cnt),
8662 tlen);
8663
8664 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8665 (tANI_U8) sizeof (pStats->fail_cnt),
8666 (char*) &(pStats->fail_cnt[0]),
8667 tlen);
8668
8669 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8670 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8671 (char*) &(pStats->rts_fail_cnt),
8672 tlen);
8673
8674 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8675 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8676 (char*) &(pStats->ack_fail_cnt),
8677 tlen);
8678
8679 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8680 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8681 (char*) &(pStats->rts_succ_cnt),
8682 tlen);
8683
8684 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8685 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8686 (char*) &(pStats->rx_discard_cnt),
8687 tlen);
8688
8689 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8690 (tANI_U8) sizeof (pStats->rx_error_cnt),
8691 (char*) &(pStats->rx_error_cnt),
8692 tlen);
8693
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008694 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008695 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008696 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008697 tlen);
8698
8699 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8700 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8701 (char*) &(dStats->rx_byte_cnt),
8702 tlen);
8703
8704 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8705 (tANI_U8) sizeof (dStats->rx_rate),
8706 (char*) &(dStats->rx_rate),
8707 tlen);
8708
8709 /* Transmit rate, in units of 500 kbit/sec */
8710 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8711 (tANI_U8) sizeof (aStats->tx_rate),
8712 (char*) &(aStats->tx_rate),
8713 tlen);
8714
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008715 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8716 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8717 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008718 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008719 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8720 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8721 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008722 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008723 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8724 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8725 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008726 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008727 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8728 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8729 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008730 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008731 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8732 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8733 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008734 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008735 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8736 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8737 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008738 tlen);
8739
Jeff Johnson295189b2012-06-20 16:38:30 -07008740 wrqu->data.length = tlen;
8741
8742 }
8743
8744 EXIT();
8745
8746 return 0;
8747}
8748
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308749static int iw_get_statistics(struct net_device *dev,
8750 struct iw_request_info *info,
8751 union iwreq_data *wrqu, char *extra)
8752{
8753 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008754
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308755 vos_ssr_protect(__func__);
8756 ret = __iw_get_statistics(dev, info, wrqu, extra);
8757 vos_ssr_unprotect(__func__);
8758
8759 return ret;
8760}
Jeff Johnson295189b2012-06-20 16:38:30 -07008761#ifdef FEATURE_WLAN_SCAN_PNO
8762
8763/*Max Len for PNO notification*/
8764#define MAX_PNO_NOTIFY_LEN 100
8765void found_pref_network_cb (void *callbackContext,
8766 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8767{
8768 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8769 union iwreq_data wrqu;
8770 char buf[MAX_PNO_NOTIFY_LEN+1];
8771
8772 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8773 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8774
8775 // create the event
8776 memset(&wrqu, 0, sizeof(wrqu));
8777 memset(buf, 0, sizeof(buf));
8778
8779 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8780 pPrefNetworkFoundInd->ssId.ssId,
8781 (unsigned int)pPrefNetworkFoundInd->rssi);
8782
8783 wrqu.data.pointer = buf;
8784 wrqu.data.length = strlen(buf);
8785
8786 // send the event
8787
8788 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8789
8790}
8791
8792
8793/*string based input*/
8794VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8795 union iwreq_data *wrqu, char *extra, int nOffset)
8796{
8797 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308798 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008799 /* pnoRequest is a large struct, so we make it static to avoid stack
8800 overflow. This API is only invoked via ioctl, so it is
8801 serialized by the kernel rtnl_lock and hence does not need to be
8802 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308803 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 char *ptr;
8805 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308806 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8808
8809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8810 "PNO data len %d data %s",
8811 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008812 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008813
8814 if (wrqu->data.length <= nOffset )
8815 {
8816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8817 return VOS_STATUS_E_FAILURE;
8818 }
8819
8820 pnoRequest.enable = 0;
8821 pnoRequest.ucNetworksCount = 0;
8822 /*-----------------------------------------------------------------------
8823 Input is string based and expected to be like this:
8824
8825 <enabled> <netw_count>
8826 for each network:
8827 <ssid_len> <ssid> <authentication> <encryption>
8828 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8829 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8830
8831 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008832 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 -07008833
8834 this translates into:
8835 -----------------------------
8836 enable PNO
8837 look for 2 networks:
8838 test - with authentication type 0 and encryption type 0,
8839 that can be found on 3 channels: 1 6 and 11 ,
8840 SSID bcast type is unknown (directed probe will be sent if AP not found)
8841 and must meet -40dBm RSSI
8842
8843 test2 - with auth and enrytption type 4/4
8844 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
8845 bcast type is non-bcast (directed probe will be sent)
8846 and must not meet any RSSI threshold
8847
Jeff Johnson8301aa12013-03-28 14:27:29 -07008848 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08008850 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008851
Wilson Yang623f6592013-10-08 16:33:37 -07008852 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
8853 {
8854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8855 "PNO enable input is not valid %s",ptr);
8856 return VOS_STATUS_E_FAILURE;
8857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008858
8859 if ( 0 == pnoRequest.enable )
8860 {
8861 /*Disable PNO*/
8862 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05308863 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8864 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008865 pAdapter->sessionId,
8866 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308867 if (eHAL_STATUS_SUCCESS != status)
8868 {
8869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8870 "%s: failed to disable PNO", __func__);
8871 return VOS_STATUS_E_FAILURE;
8872 }
8873 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008874 return VOS_STATUS_SUCCESS;
8875 }
8876
c_hpothu37f21312014-04-09 21:49:54 +05308877 if (TRUE == pHddCtx->isPnoEnable)
8878 {
8879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8880 FL("already PNO is enabled"));
8881 return -EBUSY;
8882 }
8883 pHddCtx->isPnoEnable = TRUE;
8884
Jeff Johnson295189b2012-06-20 16:38:30 -07008885 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07008886
8887 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
8888 {
8889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8890 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308891 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008893
8894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8895 "PNO enable %d networks count %d offset %d",
8896 pnoRequest.enable,
8897 pnoRequest.ucNetworksCount,
8898 nOffset);
8899
8900 /* Parameters checking:
8901 ucNetworksCount has to be larger than 0*/
8902 if (( 0 == pnoRequest.ucNetworksCount ) ||
8903 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8904 {
8905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05308906 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 }
8908
8909 ptr += nOffset;
8910
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308911 pnoRequest.aNetworks =
8912 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8913 if (pnoRequest.aNetworks == NULL)
8914 {
8915 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8916 FL("failed to allocate memory aNetworks %u"),
8917 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8918 goto error;
8919 }
8920 vos_mem_zero(pnoRequest.aNetworks,
8921 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8922
Jeff Johnson295189b2012-06-20 16:38:30 -07008923 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
8924 {
8925
8926 pnoRequest.aNetworks[i].ssId.length = 0;
8927
Wilson Yang623f6592013-10-08 16:33:37 -07008928 ucParams = sscanf(ptr,"%hhu %n",
8929 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
8930
8931 if (1 != ucParams)
8932 {
8933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8934 "PNO ssid length input is not valid %s",ptr);
8935 return VOS_STATUS_E_FAILURE;
8936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008937
8938 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
8939 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
8940 {
8941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8942 "SSID Len %d is not correct for network %d",
8943 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05308944 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008945 }
8946
8947 /*Advance to SSID*/
8948 ptr += nOffset;
8949
Jeff Johnson8301aa12013-03-28 14:27:29 -07008950 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08008951 pnoRequest.aNetworks[i].ssId.length);
8952 ptr += pnoRequest.aNetworks[i].ssId.length;
8953
Jeff Johnson02797792013-10-26 19:17:13 -07008954 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08008955 &(pnoRequest.aNetworks[i].authentication),
8956 &(pnoRequest.aNetworks[i].encryption),
8957 &(pnoRequest.aNetworks[i].ucChannelCount),
8958 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008959
Wilson Yang623f6592013-10-08 16:33:37 -07008960 if ( 3 != ucParams )
8961 {
8962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8963 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308964 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008965 }
8966
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008968 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08008969 "auth %d encry %d channel count %d offset %d",
8970 pnoRequest.aNetworks[i].ssId.length,
8971 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
8972 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
8973 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
8974 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
8975 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
8976 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
8977 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
8978 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
8979 pnoRequest.aNetworks[i].authentication,
8980 pnoRequest.aNetworks[i].encryption,
8981 pnoRequest.aNetworks[i].ucChannelCount,
8982 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07008983
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 /*Advance to channel list*/
8985 ptr += nOffset;
8986
Wilson Yang623f6592013-10-08 16:33:37 -07008987 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 {
8989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8990 "Incorrect number of channels");
8991 return VOS_STATUS_E_FAILURE;
8992 }
8993
8994 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
8995 {
8996 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
8997 {
Wilson Yang623f6592013-10-08 16:33:37 -07008998 if (1 != sscanf(ptr,"%hhu %n",
8999 &(pnoRequest.aNetworks[i].aChannels[j]),
9000 &nOffset))
9001 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9002 "PNO network channel input is not valid %s",ptr);
9003 return VOS_STATUS_E_FAILURE;
9004 }
9005 /*Advance to next channel number*/
9006 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009007 }
9008 }
9009
Jeff Johnson02797792013-10-26 19:17:13 -07009010 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009011 &(pnoRequest.aNetworks[i].bcastNetwType),
9012 &nOffset))
9013 {
9014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9015 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309016 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009018
9019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9020 "PNO bcastNetwType %d offset %d",
9021 pnoRequest.aNetworks[i].bcastNetwType,
9022 nOffset );
9023
9024 /*Advance to rssi Threshold*/
9025 ptr += nOffset;
9026
Wilson Yang623f6592013-10-08 16:33:37 -07009027 if (1 != sscanf(ptr,"%hhu %n",
9028 &(pnoRequest.aNetworks[i].rssiThreshold),
9029 &nOffset))
9030 {
9031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9032 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309033 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009035
9036 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9037 "PNO rssi %d offset %d",
9038 pnoRequest.aNetworks[i].rssiThreshold,
9039 nOffset );
9040 /*Advance to next network*/
9041 ptr += nOffset;
9042 }/*For ucNetworkCount*/
9043
9044 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009045 &(pnoRequest.scanTimers.ucScanTimersCount),
9046 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009047
9048 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009049 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 {
9051 ptr += nOffset;
9052
Jeff Johnson8301aa12013-03-28 14:27:29 -07009053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9054 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009055 pnoRequest.scanTimers.ucScanTimersCount,
9056 nOffset );
9057
9058 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9059 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009061 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309062 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 }
9064
9065 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9066 {
Jeff Johnson02797792013-10-26 19:17:13 -07009067 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009068 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9069 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9070 &nOffset);
9071
Wilson Yang623f6592013-10-08 16:33:37 -07009072 if (2 != ucParams)
9073 {
9074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9075 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309076 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009077 }
9078
Jeff Johnson8301aa12013-03-28 14:27:29 -07009079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9080 "PNO Timer value %d Timer repeat %d offset %d",
9081 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009082 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9083 nOffset );
9084
Jeff Johnson295189b2012-06-20 16:38:30 -07009085 ptr += nOffset;
9086 }
9087
9088 }
9089 else
9090 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9092 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009093 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9094
9095 /*Scan timers defaults to 5 minutes*/
9096 pnoRequest.scanTimers.ucScanTimersCount = 1;
9097 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9098 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9099 }
9100
Wilson Yang623f6592013-10-08 16:33:37 -07009101 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009102
9103 pnoRequest.modePNO = ucMode;
9104 /*for LA we just expose suspend option*/
9105 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9106 {
9107 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9108 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309109 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9110 if (pnoRequest.p24GProbeTemplate == NULL){
9111 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9112 FL("failed to allocate memory p24GProbeTemplate %u"),
9113 SIR_PNO_MAX_PB_REQ_SIZE);
9114 goto error;
9115 }
9116
9117 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9118 if (pnoRequest.p5GProbeTemplate == NULL){
9119 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9120 FL("failed to allocate memory p5GProbeTemplate %u"),
9121 SIR_PNO_MAX_PB_REQ_SIZE);
9122 goto error;
9123 }
9124
9125 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9126 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009127
c_hpothu37f21312014-04-09 21:49:54 +05309128 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 pAdapter->sessionId,
9130 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309131 if (eHAL_STATUS_SUCCESS == status)
9132 {
9133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9134 "%s: PNO enabled", __func__);
9135 return VOS_STATUS_SUCCESS;
9136 }
9137error:
9138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9139 "%s: Failed to enable PNO", __func__);
9140 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309141 if (pnoRequest.aNetworks)
9142 vos_mem_free(pnoRequest.aNetworks);
9143 if (pnoRequest.p24GProbeTemplate)
9144 vos_mem_free(pnoRequest.p24GProbeTemplate);
9145 if (pnoRequest.p5GProbeTemplate)
9146 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309147 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009148}/*iw_set_pno*/
9149
9150VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9151 union iwreq_data *wrqu, char *extra, int nOffset)
9152{
9153 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9154 v_U8_t rssiThreshold = 0;
9155 v_U8_t nRead;
9156
Arif Hussain7adce1b2013-11-11 22:59:34 -08009157 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 &rssiThreshold);
9159
9160 if ( 1 != nRead )
9161 {
9162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9163 "Incorrect format");
9164 return VOS_STATUS_E_FAILURE;
9165 }
9166
9167 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9168 return VOS_STATUS_SUCCESS;
9169}
9170
9171
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309172static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009173 struct iw_request_info *info,
9174 union iwreq_data *wrqu, char *extra)
9175{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309176 hdd_adapter_t *pAdapter;
9177 hdd_context_t *pHddCtx;
9178 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309179 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309180
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309181 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309182 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9183 if (NULL == pAdapter)
9184 {
9185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9186 "%s: Adapter is NULL",__func__);
9187 return -EINVAL;
9188 }
9189
9190 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9191 ret = wlan_hdd_validate_context(pHddCtx);
9192 if (0 != ret)
9193 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309194 return ret;
9195 }
9196
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009197
9198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009199 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009200
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309201 status = iw_set_pno(dev,info,wrqu,extra,0);
9202
9203 EXIT();
9204 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009205}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309206
9207static int iw_set_pno_priv(struct net_device *dev,
9208 struct iw_request_info *info,
9209 union iwreq_data *wrqu, char *extra)
9210{
9211 int ret;
9212
9213 vos_ssr_protect(__func__);
9214 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9215 vos_ssr_unprotect(__func__);
9216
9217 return ret;
9218}
Jeff Johnson295189b2012-06-20 16:38:30 -07009219#endif /*FEATURE_WLAN_SCAN_PNO*/
9220
9221//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309222int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009223{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309224 hdd_adapter_t *pAdapter;
9225 tHalHandle hHal;
9226 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309227 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309228 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309229 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309231 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309232 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309233 tpAniSirGlobal pMac;
9234 int retval = 0;
9235
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309236 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309237 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9238 if (NULL == pAdapter)
9239 {
9240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9241 "%s: Adapter is NULL",__func__);
9242 return -EINVAL;
9243 }
9244 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9245 retval = wlan_hdd_validate_context(pHddCtx);
9246 if (0 != retval)
9247 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309248 return retval;
9249 }
9250 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9251 if (NULL == hHal)
9252 {
9253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9254 "%s: Hal Context is NULL",__func__);
9255 return -EINVAL;
9256 }
9257 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009258
Atul Mittal54378cb2014-04-02 16:51:50 +05309259 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009260 {
9261 case WLAN_HDD_UI_BAND_AUTO:
9262 band = eCSR_BAND_ALL;
9263 break;
9264 case WLAN_HDD_UI_BAND_5_GHZ:
9265 band = eCSR_BAND_5G;
9266 break;
9267 case WLAN_HDD_UI_BAND_2_4_GHZ:
9268 band = eCSR_BAND_24;
9269 break;
9270 default:
9271 band = eCSR_BAND_MAX;
9272 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309273 connectedBand =
9274 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009275
Atul Mittal54378cb2014-04-02 16:51:50 +05309276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009277 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009278
9279 if (band == eCSR_BAND_MAX)
9280 {
9281 /* Received change band request with invalid band value */
9282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309283 "%s: Invalid band value %u", __func__, ui_band);
9284 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 }
9286
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309287 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
9288 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
9289 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
9290 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009292 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009293 band, pHddCtx->cfg_ini->nBandCapability);
9294 return -EIO;
9295 }
9296
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9298 {
9299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9300 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009301 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009302 return -EIO;
9303 }
9304
9305 if (currBand != band)
9306 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309307 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309308 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309309 /* Return failure if current country code is world regulatory domain*/
9310 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9311 pMac->scan.countryCodeCurrent[1] == '0') )
9312 {
9313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9314 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309315 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309316 return -EAGAIN;
9317 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309318 }
9319
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 /* Change band request received.
9321 * Abort pending scan requests, flush the existing scan results,
9322 * and change the band capability
9323 */
9324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9325 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009326 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009327
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309328 /* We need to change the band and flush the scan results here itself
9329 * as we may get timeout for disconnection in which we will return
9330 * with out doing any of these
9331 */
9332 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9333 {
9334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9335 "%s: failed to set the band value to %u ",
9336 __func__, band);
9337 return -EINVAL;
9338 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309339 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9340 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309341 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309342 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9343 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309344 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309345 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9346 * information available in NV so to get the channel information from kernel
9347 * we need to send regulatory hint for the currunt country
9348 * And to set the same country again we need to set the dummy country
9349 * first and then the actual country.
9350 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309351#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9352 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9353#else
9354 regulatory_hint_user("00");
9355#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309356 wait_result = wait_for_completion_interruptible_timeout(
9357 &pHddCtx->linux_reg_req,
9358 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9359
9360 /* if the country information does not exist with the kernel,
9361 then the driver callback would not be called */
9362
9363 if (wait_result >= 0)
9364 {
9365 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9366 "runtime country code is found in kernel db");
9367 }
9368 else
9369 {
9370 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9371 "runtime country code is not found"
9372 " in kernel db");
9373 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309374
9375 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309376
9377 /*
9378 * Update 11dcountry and current country here as the hint
9379 * with 00 results in 11d and current country with 00
9380 */
9381 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9382 WNI_CFG_COUNTRY_CODE_LEN);
9383 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9384 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309385#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9386 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9387#else
9388 regulatory_hint_user(curr_country);
9389#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309390 wait_result = wait_for_completion_interruptible_timeout(
9391 &pHddCtx->linux_reg_req,
9392 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9393
9394 /* if the country information does not exist with the kernel,
9395 then the driver callback would not be called */
9396 if (wait_result >= 0)
9397 {
9398 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9399 "runtime country code is found in kernel db");
9400 }
9401 else
9402 {
9403 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9404 "runtime country code is not found"
9405 " in kernel db");
9406 }
9407
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309408 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
9409 }
9410 else
9411 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309412#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309413 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9414 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309415#else
9416 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9417#endif
9418
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309419 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309420 pScanInfo = &pHddCtx->scan_info;
9421 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9422 {
9423 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9424 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9425 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309426 sme_FilterScanResults(hHal, pAdapter->sessionId);
9427
9428 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309429 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9430 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 eHalStatus status = eHAL_STATUS_SUCCESS;
9433 long lrc;
9434
9435 /* STA already connected on current band, So issue disconnect first,
9436 * then change the band*/
9437
9438 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309439 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309440 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009441
Jeff Johnson295189b2012-06-20 16:38:30 -07009442 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9443
9444 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9445 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9446
Jeff Johnson43971f52012-07-17 12:26:56 -07009447 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009448 {
9449 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009450 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 __func__, (int)status );
9452 return -EINVAL;
9453 }
9454
9455 lrc = wait_for_completion_interruptible_timeout(
9456 &pAdapter->disconnect_comp_var,
9457 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9458
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309459 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009460
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009461 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009462 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009463
9464 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9465 }
9466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309468 EXIT();
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309469 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009470}
9471
Atul Mittal54378cb2014-04-02 16:51:50 +05309472int hdd_setBand_helper(struct net_device *dev, const char *command)
9473{
9474 u8 band;
9475
9476 /*convert the band value from ascii to integer*/
9477 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9478
9479 return hdd_setBand(dev, band);
9480
9481}
9482
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309483static int __iw_set_band_config(struct net_device *dev,
9484 struct iw_request_info *info,
9485 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009486{
Atul Mittal54378cb2014-04-02 16:51:50 +05309487 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009488
Arif Hussain0273cba2014-01-07 20:58:29 -08009489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009490
Atul Mittal54378cb2014-04-02 16:51:50 +05309491 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009492}
9493
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309494static int iw_set_band_config(struct net_device *dev,
9495 struct iw_request_info *info,
9496 union iwreq_data *wrqu, char *extra)
9497{
9498 int ret;
9499
9500 vos_ssr_protect(__func__);
9501 ret = __iw_set_band_config(dev, info, wrqu, extra);
9502 vos_ssr_unprotect(__func__);
9503
9504 return ret;
9505}
9506
9507static int __iw_set_power_params_priv(struct net_device *dev,
9508 struct iw_request_info *info,
9509 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009510{
Arif Hussain0273cba2014-01-07 20:58:29 -08009511 int ret;
9512 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9514 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009515 /* ODD number is used for set, copy data using copy_from_user */
9516 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9517 wrqu->data.length);
9518 if (NULL == ptr)
9519 {
9520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9521 "mem_alloc_copy_from_user_helper fail");
9522 return -ENOMEM;
9523 }
9524
9525 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9526 kfree(ptr);
9527 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009528}
9529
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309530static int iw_set_power_params_priv(struct net_device *dev,
9531 struct iw_request_info *info,
9532 union iwreq_data *wrqu, char *extra)
9533{
9534 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009535
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309536 vos_ssr_protect(__func__);
9537 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9538 vos_ssr_unprotect(__func__);
9539
9540 return ret;
9541}
Jeff Johnson295189b2012-06-20 16:38:30 -07009542
9543/*string based input*/
9544VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9545 union iwreq_data *wrqu, char *extra, int nOffset)
9546{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309547 hdd_adapter_t *pAdapter;
9548 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 tSirSetPowerParamsReq powerRequest;
9550 char *ptr;
9551 v_U8_t ucType;
9552 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309553 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009554
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309555 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309556 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9557 if (NULL == pAdapter)
9558 {
9559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9560 "%s: Adapter is NULL",__func__);
9561 return -EINVAL;
9562 }
9563
9564 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9565 ret = wlan_hdd_validate_context(pHddCtx);
9566 if (0 != ret)
9567 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309568 return ret;
9569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9571 "Power Params data len %d data %s",
9572 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009573 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009574
9575 if (wrqu->data.length <= nOffset )
9576 {
9577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9578 return VOS_STATUS_E_FAILURE;
9579 }
9580
9581 uTotalSize = wrqu->data.length - nOffset;
9582
9583 /*-----------------------------------------------------------------------
9584 Input is string based and expected to be like this:
9585
9586 <param_type> <param_value> <param_type> <param_value> ...
9587
9588 e.g:
9589 1 2 2 3 3 0 4 1 5 1
9590
9591 e.g. setting just a few:
9592 1 2 4 1
9593
9594 parameter types:
9595 -----------------------------
9596 1 - Ignore DTIM
9597 2 - Listen Interval
9598 3 - Broadcast Multicas Filter
9599 4 - Beacon Early Termination
9600 5 - Beacon Early Termination Interval
9601 -----------------------------------------------------------------------*/
9602 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9603 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9604 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9605 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9606 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9607
Arif Hussain7adce1b2013-11-11 22:59:34 -08009608 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009609
9610 while ( uTotalSize )
9611 {
Wilson Yang6f971452013-10-08 15:00:00 -07009612 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9613 {
9614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9615 "Invalid input parameter type %s",ptr);
9616 return VOS_STATUS_E_FAILURE;
9617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009618
9619 uTotalSize -= nOffset;
9620
9621 if (!uTotalSize)
9622 {
9623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009624 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 ucType, nOffset);
9626 return VOS_STATUS_E_FAILURE;
9627 }
9628
9629 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009630
Jeff Johnson02797792013-10-26 19:17:13 -07009631 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009632 {
9633 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9634 "Invalid input parameter value %s",ptr);
9635 return VOS_STATUS_E_FAILURE;
9636 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009637
9638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9639 "Power request parameter %d value %d offset %d",
9640 ucType, uValue, nOffset);
9641
9642 switch (ucType)
9643 {
9644 case eSIR_IGNORE_DTIM:
9645 powerRequest.uIgnoreDTIM = uValue;
9646 break;
9647 case eSIR_LISTEN_INTERVAL:
9648 powerRequest.uListenInterval = uValue;
9649 break;
9650 case eSIR_MCAST_BCAST_FILTER:
9651 powerRequest.uBcastMcastFilter = uValue;
9652 break;
9653 case eSIR_ENABLE_BET:
9654 powerRequest.uEnableBET = uValue;
9655 break;
9656 case eSIR_BET_INTERVAL:
9657 powerRequest.uBETInterval = uValue;
9658 break;
9659 default:
9660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009661 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009662 ucType, uValue, nOffset);
9663 return VOS_STATUS_E_FAILURE;
9664 }
9665
9666 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9668 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009669 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009670 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009671 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009672 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009673 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9674 {
9675 uTotalSize = 0;
9676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009677
9678 }/*Go for as long as we have a valid string*/
9679
9680 /* put the device into full power*/
9681 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9682
9683 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009684 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009685
9686 /* put the device back to power save*/
9687 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9688
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309689 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 return VOS_STATUS_SUCCESS;
9691}/*iw_set_power_params*/
9692
Atul Mittalc0f739f2014-07-31 13:47:47 +05309693// tdlsoffchan
9694#ifdef FEATURE_WLAN_TDLS
9695
Atul Mittal87ec2422014-09-24 13:12:50 +05309696int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309697{
9698 if (offchannel < 0 || offchannel > 165)
9699 {
9700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9701 __func__, offchannel);
9702 return -1;
9703
9704 }
9705
9706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9707 __func__, tdlsOffCh, offchannel);
9708
9709 tdlsOffCh = offchannel;
9710 return 0;
9711}
9712
Atul Mittal87ec2422014-09-24 13:12:50 +05309713int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309714{
9715 if (offchanoffset == 0)
9716 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309717 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9719 __func__, tdlsOffChBwOffset);
9720
9721 return 0;
9722
9723 }
9724
9725 if ( offchanoffset == 40 )
9726 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309727 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9729 __func__, tdlsOffChBwOffset);
9730
9731 return 0;
9732
9733 }
9734 if (offchanoffset == -40)
9735 {
9736 tdlsOffChBwOffset = 3;
9737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9738 __func__, tdlsOffChBwOffset);
9739
9740 return 0;
9741
9742 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +05309743
9744 if ((offchanoffset == 80) &&
9745 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
9746 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
9747 {
9748 tdlsOffChBwOffset = 4;
9749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9750 "%s: change tdls secondary off channel offset to %u",
9751 __func__, tdlsOffChBwOffset);
9752
9753 return 0;
9754 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05309755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9756 __func__, offchanoffset);
9757 return -1;
9758}
9759
Atul Mittal87ec2422014-09-24 13:12:50 +05309760int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309761{
9762 hddTdlsPeer_t *connPeer = NULL;
9763 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9764 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9765
9766 if (offchanmode < 0 || offchanmode > 4)
9767 {
9768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9769 "%s: Invalid tdls off channel mode %d",
9770 __func__, offchanmode);
9771 return -1;
9772 }
9773
9774 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9775 {
9776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9777 "%s: tdls off channel mode req in not associated state %d",
9778 __func__, offchanmode);
9779 return -1;
9780 }
9781
9782 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9783 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9784 {
9785 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309786 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309787 if (NULL == connPeer) {
9788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9789 "%s: No TDLS Connected Peer", __func__);
9790 return -1;
9791 }
9792 }
9793 else
9794 {
9795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9796 "%s: TDLS Connection not supported", __func__);
9797 return -1;
9798 }
9799
9800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9801 ("%s: TDLS Channel Switch in swmode=%d"),
9802 __func__, offchanmode);
9803
9804 switch (offchanmode)
9805 {
9806 case 1:/*Enable*/
9807 case 2:/*Disable*/
9808 {
9809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9810 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9811 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9812 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9813 {
9814
9815 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9816 pAdapter->sessionId, connPeer->peerMac,
9817 tdlsOffCh, tdlsOffChBwOffset,
9818 offchanmode);
9819 }
9820 else
9821 {
9822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9823 "%s: TDLS Off Channel not supported", __func__);
9824 return -1;
9825 }
9826 break;
9827 }
9828 case 3:
9829 {
9830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9831 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
9832 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9833
9834 break;
9835 }
9836 case 4:
9837 {
9838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9839 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
9840 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9841 break;
9842 }
9843 default:
9844 {
9845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9846 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
9847 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9848 break;
9849 }
9850
9851 }
9852
9853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
9854 __func__, offchanmode);
9855 return 0;
9856}
Atul Mittalc0f739f2014-07-31 13:47:47 +05309857#endif
9858
Jeff Johnson295189b2012-06-20 16:38:30 -07009859
9860// Define the Wireless Extensions to the Linux Network Device structure
9861// A number of these routines are NULL (meaning they are not implemented.)
9862
9863static const iw_handler we_handler[] =
9864{
9865 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9866 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9867 (iw_handler) NULL, /* SIOCSIWNWID */
9868 (iw_handler) NULL, /* SIOCGIWNWID */
9869 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9870 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9871 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9872 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9873 (iw_handler) NULL, /* SIOCSIWSENS */
9874 (iw_handler) NULL, /* SIOCGIWSENS */
9875 (iw_handler) NULL, /* SIOCSIWRANGE */
9876 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9877 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
9878 (iw_handler) NULL, /* SIOCGIWPRIV */
9879 (iw_handler) NULL, /* SIOCSIWSTATS */
9880 (iw_handler) NULL, /* SIOCGIWSTATS */
9881 iw_handler_set_spy, /* SIOCSIWSPY */
9882 iw_handler_get_spy, /* SIOCGIWSPY */
9883 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
9884 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
9885 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9886 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9887 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9888 (iw_handler) NULL, /* SIOCGIWAPLIST */
9889 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9890 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9891 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9892 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9893 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9894 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9895 (iw_handler) NULL, /* -- hole -- */
9896 (iw_handler) NULL, /* -- hole -- */
9897 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9898 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9899 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
9900 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
9901 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9902 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9903 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9904 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9905 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9906 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9907 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9908 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9909 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9910 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9911 (iw_handler) NULL, /* -- hole -- */
9912 (iw_handler) NULL, /* -- hole -- */
9913 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9914 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9915 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9916 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9917 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9918 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9919 (iw_handler) NULL, /* SIOCSIWPMKSA */
9920};
9921
9922static const iw_handler we_private[] = {
9923
9924 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
9925 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
9926 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
9927 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
9928 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9929 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +05309930 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07009931 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9932 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9933 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07009934#ifdef FEATURE_OEM_DATA_SUPPORT
9935 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
9936 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
9937#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009938
Jeff Johnson295189b2012-06-20 16:38:30 -07009939#ifdef WLAN_FEATURE_VOWIFI_11R
9940 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
9941#endif
9942 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9943 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9944 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
9945#ifdef WLAN_FEATURE_PACKET_FILTERING
9946 ,
9947 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
9948#endif
9949#ifdef FEATURE_WLAN_SCAN_PNO
9950 ,
9951 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
9952#endif
9953 ,
9954 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9955 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
9956 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
9957 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07009958 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07009959};
9960
9961/*Maximum command length can be only 15 */
9962static const struct iw_priv_args we_private_args[] = {
9963
9964 /* handlers for main ioctl */
9965 { WLAN_PRIV_SET_INT_GET_NONE,
9966 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9967 0,
9968 "" },
9969
9970 /* handlers for sub-ioctl */
9971 { WE_SET_11D_STATE,
9972 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9973 0,
9974 "set11Dstate" },
9975
9976 { WE_WOWL,
9977 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9978 0,
9979 "wowl" },
9980
9981 { WE_SET_POWER,
9982 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9983 0,
9984 "setPower" },
9985
9986 { WE_SET_MAX_ASSOC,
9987 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9988 0,
9989 "setMaxAssoc" },
9990
9991 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
9992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9993 0,
9994 "setAutoChannel" },
9995
9996 { WE_SET_DATA_INACTIVITY_TO,
9997 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9998 0,
9999 "inactivityTO" },
10000
10001 { WE_SET_MAX_TX_POWER,
10002 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10003 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010004 "setMaxTxPower" },
10005
10006 { WE_SET_MAX_TX_POWER_2_4,
10007 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10008 0,
10009 "setTxMaxPower2G" },
10010
10011 { WE_SET_MAX_TX_POWER_5_0,
10012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10013 0,
10014 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010015
10016 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10017 * as well to keep same syntax as in SAP. Now onwards, STA
10018 * will support both */
10019 { WE_SET_MAX_TX_POWER,
10020 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10021 0,
10022 "setTxMaxPower" },
10023
Jeff Johnson295189b2012-06-20 16:38:30 -070010024 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10025 * 1 = enable and 0 = disable */
10026 {
10027 WE_SET_HIGHER_DTIM_TRANSITION,
10028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10029 0,
10030 "setHDtimTransn" },
10031
10032 { WE_SET_TM_LEVEL,
10033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010034 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 "setTmLevel" },
10036
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010037 { WE_ENABLE_STRICT_FCC_REG,
10038 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10039 0,
10040 "setStrictFCCreg" },
10041
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010042 { WE_SET_DEBUG_LOG,
10043 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10044 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010045#ifdef FEATURE_WLAN_TDLS
10046 {
10047 WE_SET_TDLS_OFF_CHAN,
10048 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10049 0,
10050 "tdlsoffchan" },
10051 {
10052 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10053 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10054 0,
10055 "tdlsecchnoffst" },
10056 {
10057 WE_SET_TDLS_OFF_CHAN_MODE,
10058 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10059 0,
10060 "tdlsoffchnmode" },
10061#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010062
Peng Xu2446a892014-09-05 17:21:18 +053010063 { WE_SET_SCAN_BAND_PREFERENCE,
10064 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10065 0, "set_scan_pref" },
10066
Abhishek Singh01c73d12015-03-12 15:13:44 +053010067 { WE_SET_MIRACAST_VENDOR_CONFIG,
10068 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10069 0, "setMiracstConf" },
10070
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 /* handlers for main ioctl */
10072 { WLAN_PRIV_SET_NONE_GET_INT,
10073 0,
10074 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10075 "" },
10076
10077 /* handlers for sub-ioctl */
10078 { WE_GET_11D_STATE,
10079 0,
10080 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10081 "get11Dstate" },
10082
10083 { WE_IBSS_STATUS,
10084 0,
10085 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10086 "getAdhocStatus" },
10087
10088 { WE_PMC_STATE,
10089 0,
10090 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10091 "pmcState" },
10092
10093 { WE_GET_WLAN_DBG,
10094 0,
10095 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10096 "getwlandbg" },
10097
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 { WE_GET_MAX_ASSOC,
10099 0,
10100 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10101 "getMaxAssoc" },
10102
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 { WE_GET_WDI_DBG,
10104 0,
10105 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10106 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010107
10108 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10109 0,
10110 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10111 "getAutoChannel" },
10112
10113 { WE_GET_CONCURRENCY_MODE,
10114 0,
10115 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10116 "getconcurrency" },
10117
Peng Xu2446a892014-09-05 17:21:18 +053010118 { WE_GET_SCAN_BAND_PREFERENCE,
10119 0,
10120 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10121 "get_scan_pref"},
10122
Jeff Johnson295189b2012-06-20 16:38:30 -070010123 /* handlers for main ioctl */
10124 { WLAN_PRIV_SET_CHAR_GET_NONE,
10125 IW_PRIV_TYPE_CHAR| 512,
10126 0,
10127 "" },
10128
10129 /* handlers for sub-ioctl */
10130 { WE_WOWL_ADD_PTRN,
10131 IW_PRIV_TYPE_CHAR| 512,
10132 0,
10133 "wowlAddPtrn" },
10134
10135 { WE_WOWL_DEL_PTRN,
10136 IW_PRIV_TYPE_CHAR| 512,
10137 0,
10138 "wowlDelPtrn" },
10139
10140#if defined WLAN_FEATURE_VOWIFI
10141 /* handlers for sub-ioctl */
10142 { WE_NEIGHBOR_REPORT_REQUEST,
10143 IW_PRIV_TYPE_CHAR | 512,
10144 0,
10145 "neighbor" },
10146#endif
10147 { WE_SET_AP_WPS_IE,
10148 IW_PRIV_TYPE_CHAR| 512,
10149 0,
10150 "set_ap_wps_ie" },
10151
10152 { WE_SET_CONFIG,
10153 IW_PRIV_TYPE_CHAR| 512,
10154 0,
10155 "setConfig" },
10156
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010157 { WE_SET_ENCRYPT_MSG,
10158 IW_PRIV_TYPE_CHAR| 512,
10159 0,
10160 "encryptMsg" },
10161
10162
Jeff Johnson295189b2012-06-20 16:38:30 -070010163 /* handlers for main ioctl */
10164 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10166 0,
10167 "" },
10168
10169 /* handlers for sub-ioctl */
10170 { WE_SET_WLAN_DBG,
10171 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10172 0,
10173 "setwlandbg" },
10174
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 { WE_SET_WDI_DBG,
10176 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10177 0,
10178 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010179
10180 { WE_SET_SAP_CHANNELS,
10181 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10182 0,
10183 "setsapchannels" },
10184
10185 /* handlers for main ioctl */
10186 { WLAN_PRIV_GET_CHAR_SET_NONE,
10187 0,
10188 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10189 "" },
10190
10191 /* handlers for sub-ioctl */
10192 { WE_WLAN_VERSION,
10193 0,
10194 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10195 "version" },
10196 { WE_GET_STATS,
10197 0,
10198 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10199 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010200 { WE_GET_STATES,
10201 0,
10202 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10203 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010204 { WE_GET_CFG,
10205 0,
10206 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10207 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010208#ifdef WLAN_FEATURE_11AC
10209 { WE_GET_RSSI,
10210 0,
10211 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10212 "getRSSI" },
10213#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010214#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010215 { WE_GET_ROAM_RSSI,
10216 0,
10217 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10218 "getRoamRSSI" },
10219#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010220 { WE_GET_WMM_STATUS,
10221 0,
10222 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10223 "getWmmStatus" },
10224 {
10225 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010226 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010227 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10228 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010229#ifdef FEATURE_WLAN_TDLS
10230 {
10231 WE_GET_TDLS_PEERS,
10232 0,
10233 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10234 "getTdlsPeers" },
10235#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010236#ifdef WLAN_FEATURE_11W
10237 {
10238 WE_GET_11W_INFO,
10239 0,
10240 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10241 "getPMFInfo" },
10242#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010243 { WE_GET_SNR,
10244 0,
10245 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10246 "getSNR" },
10247
Jeff Johnson295189b2012-06-20 16:38:30 -070010248 /* handlers for main ioctl */
10249 { WLAN_PRIV_SET_NONE_GET_NONE,
10250 0,
10251 0,
10252 "" },
10253
10254 /* handlers for sub-ioctl */
10255 { WE_CLEAR_STATS,
10256 0,
10257 0,
10258 "clearStats" },
10259 { WE_INIT_AP,
10260 0,
10261 0,
10262 "initAP" },
10263 { WE_STOP_AP,
10264 0,
10265 0,
10266 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010267#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 { WE_ENABLE_AMP,
10269 0,
10270 0,
10271 "enableAMP" },
10272 { WE_DISABLE_AMP,
10273 0,
10274 0,
10275 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010276#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010277 { WE_ENABLE_DXE_STALL_DETECT,
10278 0,
10279 0,
10280 "dxeStallDetect" },
10281 { WE_DISPLAY_DXE_SNAP_SHOT,
10282 0,
10283 0,
10284 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010285 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10286 0,
10287 0,
10288 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010289 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010290 WE_SET_REASSOC_TRIGGER,
10291 0,
10292 0,
10293 "reassoc" },
10294 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010295 WE_STOP_OBSS_SCAN,
10296 0,
10297 0,
10298 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010299 {
10300 WE_DUMP_ROAM_TIMER_LOG,
10301 0,
10302 0,
10303 "dumpRoamDelay" },
10304 {
10305 WE_RESET_ROAM_TIMER_LOG,
10306 0,
10307 0,
10308 "resetRoamDelay" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010309 /* handlers for main ioctl */
10310 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10311 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10312 0,
10313 "" },
10314
10315 /* handlers for sub-ioctl */
10316 { WE_LOG_DUMP_CMD,
10317 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10318 0,
10319 "dump" },
10320
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010321 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010322 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10323 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10324 0,
10325 "setdumplog" },
10326
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010327 { WE_MTRACE_DUMP_CMD,
10328 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10329 0,
10330 "dumplog" },
10331
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010332 /* handlers for sub ioctl */
10333 {
10334 WE_MCC_CONFIG_CREDENTIAL,
10335 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10336 0,
10337 "setMccCrdnl" },
10338
10339 /* handlers for sub ioctl */
10340 {
10341 WE_MCC_CONFIG_PARAMS,
10342 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10343 0,
10344 "setMccConfig" },
10345
Chilam NG571c65a2013-01-19 12:27:36 +053010346#ifdef FEATURE_WLAN_TDLS
10347 /* handlers for sub ioctl */
10348 {
10349 WE_TDLS_CONFIG_PARAMS,
10350 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10351 0,
10352 "setTdlsConfig" },
10353#endif
10354
Jeff Johnson295189b2012-06-20 16:38:30 -070010355 /* handlers for main ioctl */
10356 { WLAN_PRIV_ADD_TSPEC,
10357 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10358 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10359 "addTspec" },
10360
10361 /* handlers for main ioctl */
10362 { WLAN_PRIV_DEL_TSPEC,
10363 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10364 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10365 "delTspec" },
10366
10367 /* handlers for main ioctl */
10368 { WLAN_PRIV_GET_TSPEC,
10369 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10370 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10371 "getTspec" },
10372
Jeff Johnsone7245742012-09-05 17:12:55 -070010373#ifdef FEATURE_OEM_DATA_SUPPORT
10374 /* handlers for main ioctl - OEM DATA */
10375 {
10376 WLAN_PRIV_SET_OEM_DATA_REQ,
10377 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10378 0,
10379 "set_oem_data_req" },
10380
10381 /* handlers for main ioctl - OEM DATA */
10382 {
10383 WLAN_PRIV_GET_OEM_DATA_RSP,
10384 0,
10385 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10386 "get_oem_data_rsp" },
10387#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010388
Jeff Johnson295189b2012-06-20 16:38:30 -070010389 /* handlers for main ioctl - host offload */
10390 {
10391 WLAN_PRIV_SET_HOST_OFFLOAD,
10392 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10393 0,
10394 "setHostOffload" },
10395
10396 {
10397 WLAN_GET_WLAN_STATISTICS,
10398 0,
10399 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10400 "getWlanStats" },
10401
10402 {
10403 WLAN_SET_KEEPALIVE_PARAMS,
10404 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10405 0,
10406 "setKeepAlive" },
10407#ifdef WLAN_FEATURE_PACKET_FILTERING
10408 {
10409 WLAN_SET_PACKET_FILTER_PARAMS,
10410 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10411 0,
10412 "setPktFilter" },
10413#endif
10414#ifdef FEATURE_WLAN_SCAN_PNO
10415 {
10416 WLAN_SET_PNO,
10417 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10418 0,
10419 "setpno" },
10420#endif
10421 {
10422 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010423 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010424 0,
10425 "SETBAND" },
10426 /* handlers for dynamic MC BC ioctl */
10427 {
10428 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010429 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010430 0,
10431 "setMCBCFilter" },
10432 {
10433 WLAN_PRIV_CLEAR_MCBC_FILTER,
10434 0,
10435 0,
10436 "clearMCBCFilter" },
10437 {
10438 WLAN_SET_POWER_PARAMS,
10439 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10440 0,
10441 "setpowerparams" },
10442 {
10443 WLAN_GET_LINK_SPEED,
10444 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010445 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010446};
10447
10448
10449
10450const struct iw_handler_def we_handler_def = {
10451 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10452 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10453 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10454
10455 .standard = (iw_handler *)we_handler,
10456 .private = (iw_handler *)we_private,
10457 .private_args = we_private_args,
10458 .get_wireless_stats = get_wireless_stats,
10459};
10460
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010461int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10462{
10463 v_U32_t cmd = 288; //Command to RIVA
10464 hdd_context_t *pHddCtx = NULL;
10465 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10466 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10467 /*
10468 *configMccParam : specify the bit which needs to be modified
10469 *allowed to update based on wlan_qcom_cfg.ini
10470 * configuration
10471 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10472 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10473 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10474 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10475 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10476 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10477 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10478 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10479 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10480 * Bit 9 : Reserved
10481 */
10482 switch (arg1)
10483 {
10484 //Update MCC SCHEDULE_TIME_SLICE parameter
10485 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10486 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10487 {
10488 if((arg2 >= 5) && (arg2 <= 20))
10489 {
10490 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10491 }
10492 else
10493 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010494 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010495 return 0;
10496 }
10497 }
10498 break;
10499
10500 //Update MCC MAX_NULL_SEND_TIME parameter
10501 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10502 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10503 {
10504 if((arg2 >= 1) && (arg2 <= 10))
10505 {
10506 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10507 }
10508 else
10509 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010510 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010511 return 0;
10512 }
10513 }
10514 break;
10515
10516 //Update MCC TX_EARLY_STOP_TIME parameter
10517 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10518 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10519 {
10520 if((arg2 >= 1) && (arg2 <= 10))
10521 {
10522 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10523 }
10524 else
10525 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010526 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010527 return 0;
10528 }
10529 }
10530 break;
10531
10532 //Update MCC RX_DRAIN_TIME parameter
10533 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10534 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10535 {
10536 if((arg2 >= 1) && (arg2 <= 10))
10537 {
10538 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10539 }
10540 else
10541 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010542 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010543 return 0;
10544 }
10545 }
10546 break;
10547
10548 //Update MCC CHANNEL_SWITCH_TIME parameter
10549 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10550 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10551 {
10552 if((arg2 >= 1) && (arg2 <= 20))
10553 {
10554 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10555 }
10556 else
10557 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010558 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010559 return 0;
10560 }
10561 }
10562 break;
10563
10564 //Update MCC MIN_CHANNEL_TIME parameter
10565 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10566 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10567 {
10568 if((arg2 >= 5) && (arg2 <= 20))
10569 {
10570 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10571 }
10572 else
10573 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010574 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010575 return 0;
10576 }
10577 }
10578 break;
10579
10580 //Update MCC PARK_BEFORE_TBTT parameter
10581 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10582 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10583 {
10584 if((arg2 >= 1) && (arg2 <= 5))
10585 {
10586 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10587 }
10588 else
10589 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010590 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010591 return 0;
10592 }
10593 }
10594 break;
10595
10596 //Update MCC MIN_AFTER_DTIM parameter
10597 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10598 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10599 {
10600 if((arg2 >= 5) && (arg2 <= 15))
10601 {
10602 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10603 }
10604 else
10605 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010606 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010607 return 0;
10608 }
10609 }
10610 break;
10611
10612 //Update MCC TOO_CLOSE_MARGIN parameter
10613 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10614 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10615 {
10616 if((arg2 >= 1) && (arg2 <= 3))
10617 {
10618 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10619 }
10620 else
10621 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010622 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010623 return 0;
10624 }
10625 }
10626 break;
10627
10628 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010629 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010630 __FUNCTION__,arg1);
10631 break;
10632 }
10633 return 0;
10634}
10635
Jeff Johnson295189b2012-06-20 16:38:30 -070010636int hdd_set_wext(hdd_adapter_t *pAdapter)
10637{
10638 hdd_wext_state_t *pwextBuf;
10639 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010640 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010641
10642 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10643
10644 // Now configure the roaming profile links. To SSID and bssid.
10645 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10646 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10647
10648 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10649 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10650
10651 /*Set the numOfChannels to zero to scan all the channels*/
10652 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10653 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10654
10655 /* Default is no encryption */
10656 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10657 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10658
10659 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10660 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10661
10662 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10663
10664 /* Default is no authentication */
10665 pwextBuf->roamProfile.AuthType.numEntries = 1;
10666 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10667
10668 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10669 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10670
10671 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010672 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010673
10674 hdd_clearRoamProfileIe(pAdapter);
10675
10676 return VOS_STATUS_SUCCESS;
10677
10678 }
10679
10680int hdd_register_wext(struct net_device *dev)
10681 {
10682 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10683 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10684 VOS_STATUS status;
10685
10686 ENTER();
10687
10688 // Zero the memory. This zeros the profile structure.
10689 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10690
10691 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10692
10693
10694 status = hdd_set_wext(pAdapter);
10695
10696 if(!VOS_IS_STATUS_SUCCESS(status)) {
10697
Arif Hussain6d2a3322013-11-17 19:50:10 -080010698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010699 return eHAL_STATUS_FAILURE;
10700 }
10701
10702 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10703 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010705 return eHAL_STATUS_FAILURE;
10706 }
10707
10708 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10709 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010711 return eHAL_STATUS_FAILURE;
10712 }
10713
10714 // Register as a wireless device
10715 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10716
10717 EXIT();
10718 return 0;
10719}
10720
10721int hdd_UnregisterWext(struct net_device *dev)
10722{
c_hpothu2a13bc32015-01-21 12:48:54 +053010723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10724 if (dev != NULL)
10725 {
10726 rtnl_lock();
10727 dev->wireless_handlers = NULL;
10728 rtnl_unlock();
10729 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010730
Jeff Johnson295189b2012-06-20 16:38:30 -070010731 return 0;
10732}
10733
10734