blob: b4db7c392351343694da78fea1a9077b767d2dbd [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
c_hpothu002231a2015-02-05 14:58:51 +05302 * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------ *
32 ------------------------------------------------------------------------ *
33
34
35 \file wlan_hdd_wext.c
36
37 \brief Airgo Linux Wireless Extensions Common Control Plane Types and
38 interfaces.
39
40 $Id: wlan_hdd_wext.c,v 1.34 2007/04/14 01:49:23 jimz Exp jimz $
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042 This file defines all of the types that are utilized by the CCP module
43 of the "Portable" HDD. This file also includes the underlying Linux
44 Wireless Extensions Data types referred to by CCP.
45
46 ======================================================================== */
47
48#include <linux/version.h>
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/init.h>
52#include <linux/wireless.h>
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053053#include <macTrace.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include <wlan_hdd_includes.h>
55#include <wlan_btc_svc.h>
56#include <wlan_nlink_common.h>
57#ifdef WLAN_BTAMP_FEATURE
58#include <bap_hdd_main.h>
59#endif
60#include <vos_api.h>
61#include <net/arp.h>
62#include "ccmApi.h"
63#include "sirParams.h"
64#include "csrApi.h"
65#include "csrInsideApi.h"
66#if defined WLAN_FEATURE_VOWIFI
67#include "smeRrmInternal.h"
68#endif
69#include <aniGlobal.h>
70#include "dot11f.h"
71#include <wlan_hdd_wowl.h>
72#include <wlan_hdd_cfg.h>
73#include <wlan_hdd_wmm.h>
74#include "utilsApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070075#include "wlan_hdd_p2p.h"
Chilam NG571c65a2013-01-19 12:27:36 +053076#ifdef FEATURE_WLAN_TDLS
77#include "wlan_hdd_tdls.h"
78#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070079
80#ifdef CONFIG_HAS_EARLYSUSPEND
81#include <linux/earlysuspend.h>
82#endif
83#include "wlan_hdd_power.h"
84#include "qwlan_version.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070085#include "wlan_hdd_host_offload.h"
86#include "wlan_hdd_keep_alive.h"
87#ifdef WLAN_FEATURE_PACKET_FILTERING
88#include "wlan_hdd_packet_filtering.h"
89#endif
90
Jeff Johnson295189b2012-06-20 16:38:30 -070091#include <linux/wireless.h>
92#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070093#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053094#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96#include "wlan_hdd_misc.h"
97#include "bap_hdd_misc.h"
98
99#include "wlan_hdd_dev_pwr.h"
100#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530101#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700102#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530103#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
Mukul Sharma84f27252014-07-14 18:11:42 +0530105#include "vos_utils.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +0530106#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +0530107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#ifdef CONFIG_HAS_EARLYSUSPEND
109extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
110extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
111#endif
112
Jeff Johnsone7245742012-09-05 17:12:55 -0700113#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800114#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700115#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700116
117#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530118#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700119
Jeff Johnson295189b2012-06-20 16:38:30 -0700120
Atul Mittalc0f739f2014-07-31 13:47:47 +0530121// tdlsoffchan
122#ifdef FEATURE_WLAN_TDLS
Atul Mittalc0f739f2014-07-31 13:47:47 +0530123static int tdlsOffCh = 1;
124static int tdlsOffChBwOffset = 0;
125#endif
Abhishek Singh678227a2014-11-04 10:52:38 +0530126
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700127static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
129
Jeff Johnson295189b2012-06-20 16:38:30 -0700130/* To Validate Channel against the Frequency and Vice-Versa */
131static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
132 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
133 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
134 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
135 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
136 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
137 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
138 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800139 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
140 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700141
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800142#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700143
144/* Private ioctls and their sub-ioctls */
145#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
146#define WE_SET_11D_STATE 1
147#define WE_WOWL 2
148#define WE_SET_POWER 3
149#define WE_SET_MAX_ASSOC 4
150#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
151#define WE_SET_DATA_INACTIVITY_TO 6
152#define WE_SET_MAX_TX_POWER 7
153#define WE_SET_HIGHER_DTIM_TRANSITION 8
154#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530155#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700156#define WE_SET_MAX_TX_POWER_2_4 11
157#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800158/* Private IOCTL for debug connection issues */
159#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530160// tdlsoffchan
161#ifdef FEATURE_WLAN_TDLS
162#define WE_SET_TDLS_OFF_CHAN 14
163#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
164#define WE_SET_TDLS_OFF_CHAN_MODE 16
165#endif
Peng Xu2446a892014-09-05 17:21:18 +0530166#define WE_SET_SCAN_BAND_PREFERENCE 17
Abhishek Singh01c73d12015-03-12 15:13:44 +0530167#define WE_SET_MIRACAST_VENDOR_CONFIG 18
Siddharth Bhal678a9342015-02-27 01:12:56 +0530168#define WE_GET_FRAME_LOG 19
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 }
Abhishek Singh01c73d12015-03-12 15:13:44 +05305836 break;
5837 }
Siddharth Bhal678a9342015-02-27 01:12:56 +05305838
5839 case WE_GET_FRAME_LOG:
5840 {
5841 if (wlan_hdd_get_frame_logs(pAdapter, set_value)
5842 != VOS_STATUS_SUCCESS)
5843 {
5844 ret = -EINVAL;
5845 }
5846 break;
5847 }
5848
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 default:
5850 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005851 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 sub_cmd, set_value);
5853 break;
5854 }
5855 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305856 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 return ret;
5858}
5859
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305860static int iw_setint_getnone(struct net_device *dev,
5861 struct iw_request_info *info,
5862 union iwreq_data *wrqu, char *extra)
5863{
5864 int ret;
5865
5866 vos_ssr_protect(__func__);
5867 ret = __iw_setint_getnone(dev, info, wrqu, extra);
5868 vos_ssr_unprotect(__func__);
5869
5870 return 0;
5871}
Jeff Johnson295189b2012-06-20 16:38:30 -07005872/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05305873static int __iw_setchar_getnone(struct net_device *dev,
5874 struct iw_request_info *info,
5875 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005876{
5877 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05305878 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08005880 char *pBuffer = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305881 hdd_adapter_t *pAdapter;
5882 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005883#ifdef WLAN_FEATURE_VOWIFI
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305884 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005885#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05305886 struct iw_point s_priv_data;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305887 tSirpkt80211 *pkt;
Jeff Johnson295189b2012-06-20 16:38:30 -07005888
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305889 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305890 pAdapter = (netdev_priv(dev));
5891 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005892 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5894 "%s: Adapter is NULL",__func__);
5895 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005896 }
5897
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305898 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5899 ret = wlan_hdd_validate_context(pHddCtx);
5900 if (0 != ret)
5901 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305902 return ret;
5903 }
5904#ifdef WLAN_FEATURE_VOWIFI
5905 pConfig = pHddCtx->cfg_ini;
5906#endif
Girish Gowli552fc072014-06-14 18:26:16 +05305907 /* helper function to get iwreq_data with compat handling. */
5908 if (hdd_priv_get_data(&s_priv_data, wrqu))
5909 {
5910 return -EINVAL;
5911 }
5912
5913 /* make sure all params are correctly passed to function */
5914 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
5915 {
5916 return -EINVAL;
5917 }
5918
5919 sub_cmd = s_priv_data.flags;
5920
Arif Hussain0273cba2014-01-07 20:58:29 -08005921 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05305922 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5923 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005924 if (NULL == pBuffer)
5925 {
5926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5927 "mem_alloc_copy_from_user_helper fail");
5928 return -ENOMEM;
5929 }
5930
5931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05305932 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08005933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5934 "%s: Received data %s", __func__, pBuffer);
5935
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 switch(sub_cmd)
5937 {
5938 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005940 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 break;
5942 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08005943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08005944 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 break;
5946#if defined WLAN_FEATURE_VOWIFI
5947 case WE_NEIGHBOR_REPORT_REQUEST:
5948 {
5949 tRrmNeighborReq neighborReq;
5950 tRrmNeighborRspCallbackInfo callbackInfo;
5951
5952 if (pConfig->fRrmEnable)
5953 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05305955 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 if( !neighborReq.no_ssid )
5957 {
Girish Gowli552fc072014-06-14 18:26:16 +05305958 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08005959 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 }
5961
5962 callbackInfo.neighborRspCallback = NULL;
5963 callbackInfo.neighborRspCallbackContext = NULL;
5964 callbackInfo.timeout = 5000; //5 seconds
5965 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
5966 }
5967 else
5968 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005969 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 ret = -EINVAL;
5971 }
5972 }
5973 break;
5974#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 case WE_SET_AP_WPS_IE:
5976 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05305977 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08005980 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 if (VOS_STATUS_SUCCESS != vstatus)
5982 {
5983 ret = -EINVAL;
5984 }
5985 break;
Srinivas Dasarib8fdd422014-11-27 10:44:20 +05305986 case WE_SET_ENCRYPT_MSG:
5987 pkt = vos_mem_malloc(sizeof(tSirpkt80211));
5988 if (NULL == pkt)
5989 {
5990 hddLog(VOS_TRACE_LEVEL_ERROR,
5991 "%s: vos_mem_alloc failed", __func__);
5992 return -ENOMEM;
5993 }
5994
5995 memset(pkt, 0, sizeof(tSirpkt80211));
5996
5997 if (FALSE == sme_IsFeatureSupportedByFW(DISA)) {
5998 hddLog(VOS_TRACE_LEVEL_ERROR,
5999 FL("Firmware is not DISA capable"));
6000 ret = -EINVAL;
6001 vos_mem_free(pkt);
6002 break;
6003 }
6004
6005 parse_Bufferforpkt(pkt, pBuffer, wrqu->data.length);
6006
6007 ret = sme_Encryptmsgsend(pHddCtx->hHal, (u8 *)pkt,
6008 sizeof(tSirpkt80211), hdd_encrypt_msg_cb);
6009 if (eHAL_STATUS_SUCCESS != ret) {
6010 hddLog(VOS_TRACE_LEVEL_ERROR,
6011 FL("SENDEncryptMSG: fail to post WDA cmd"));
6012 ret = -EINVAL;
6013 }
6014 vos_mem_free(pkt);
6015
6016 break;
6017
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 default:
6019 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006020 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 ret = -EINVAL;
6022 break;
6023 }
6024 }
Arif Hussain0273cba2014-01-07 20:58:29 -08006025 kfree(pBuffer);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306026
6027 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 return ret;
6029}
6030
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306031static int iw_setchar_getnone(struct net_device *dev,
6032 struct iw_request_info *info,
6033 union iwreq_data *wrqu, char *extra)
6034{
6035 int ret;
6036
6037 vos_ssr_protect(__func__);
6038 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6039 vos_ssr_unprotect(__func__);
6040
6041 return ret;
6042}
6043
Jeff Johnson295189b2012-06-20 16:38:30 -07006044/* get param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306045static int __iw_setnone_getint(struct net_device *dev,
6046 struct iw_request_info *info,
6047 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006048{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306049 hdd_adapter_t *pAdapter;
6050 tHalHandle hHal;
6051 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 int *value = (int *)extra;
6053 int ret = 0; /* success */
Peng Xu2446a892014-09-05 17:21:18 +05306054 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006055
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306056 ENTER();
6057
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306058 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6059 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006060 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6062 "%s: Adapter is NULL",__func__);
6063 return -EINVAL;
6064 }
6065 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6066 ret = wlan_hdd_validate_context(pHddCtx);
6067 if (0 != ret)
6068 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306069 return ret;
6070 }
6071 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6072 if (NULL == hHal)
6073 {
6074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6075 "%s: Hal Context is NULL",__func__);
6076 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006078
6079 switch (value[0])
6080 {
6081 case WE_GET_11D_STATE:
6082 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07006083 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306085
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6087
Arif Hussain6d2a3322013-11-17 19:50:10 -08006088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006089
6090 break;
6091 }
6092
6093 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 break;
6096
6097 case WE_PMC_STATE:
6098 {
6099 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08006100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 break;
6102 }
6103 case WE_GET_WLAN_DBG:
6104 {
6105 vos_trace_display();
6106 *value = 0;
6107 break;
6108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 case WE_GET_MAX_ASSOC:
6110 {
6111 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
6112 {
c_hpothub8245442013-11-20 23:41:09 +05306113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6114 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 ret = -EIO;
6116 }
Girish Gowli385be612014-09-18 11:17:20 +05306117#ifdef WLAN_SOFTAP_VSTA_FEATURE
6118 if (pHddCtx->cfg_ini->fEnableVSTASupport)
6119 {
6120 if (*value > VSTA_NUM_ASSOC_STA)
6121 {
6122 *value = VSTA_NUM_ASSOC_STA;
6123 }
6124 if ((pHddCtx->hddAdapters.count > VSTA_NUM_RESV_SELFSTA) &&
6125 (*value > (VSTA_NUM_ASSOC_STA -
6126 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA))))
6127 {
6128 *value = (VSTA_NUM_ASSOC_STA -
6129 (pHddCtx->hddAdapters.count - VSTA_NUM_RESV_SELFSTA));
6130 }
6131 }
6132 else
6133#endif
6134 {
6135 if (*value > NUM_ASSOC_STA)
6136 {
6137 *value = NUM_ASSOC_STA;
6138 }
6139 if ((pHddCtx->hddAdapters.count > NUM_RESV_SELFSTA) &&
6140 (*value > (NUM_ASSOC_STA -
6141 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA))))
6142 {
6143 *value = (NUM_ASSOC_STA -
6144 (pHddCtx->hddAdapters.count - NUM_RESV_SELFSTA));
6145 }
6146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 break;
6148 }
6149
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 case WE_GET_WDI_DBG:
6151 {
6152 wpalTraceDisplay();
6153 *value = 0;
6154 break;
6155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006156
6157 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6158 {
6159 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
6160 break;
6161 }
6162 case WE_GET_CONCURRENCY_MODE:
6163 {
6164 *value = hdd_get_concurrency_mode ( );
6165
Arif Hussain6d2a3322013-11-17 19:50:10 -08006166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 break;
6168 }
6169
Peng Xu2446a892014-09-05 17:21:18 +05306170 case WE_GET_SCAN_BAND_PREFERENCE:
6171 {
6172 sme_GetConfigParam(hHal, &smeConfig);
6173 *value = smeConfig.csrConfig.scanBandPreference;
6174
6175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6176 "scanBandPreference = %d\n", *value);
6177 break;
6178 }
6179
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 default:
6181 {
6182 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
6183 break;
6184 }
6185 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306186 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 return ret;
6188}
6189
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306190static int iw_setnone_getint(struct net_device *dev,
6191 struct iw_request_info *info,
6192 union iwreq_data *wrqu, char *extra)
6193{
6194 int ret;
6195
6196 vos_ssr_protect(__func__);
6197 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6198 vos_ssr_unprotect(__func__);
6199
6200 return ret;
6201
6202}
Jeff Johnson295189b2012-06-20 16:38:30 -07006203/* set param sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306204int __iw_set_three_ints_getnone(struct net_device *dev,
6205 struct iw_request_info *info,
6206 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006207{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306208 hdd_adapter_t *pAdapter;
6209 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 int *value = (int *)extra;
6211 int sub_cmd = value[0];
6212 int ret = 0;
6213
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306214 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306215 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6216 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006217 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6219 "%s: Adapter is NULL",__func__);
6220 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006221 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306222 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6223 ret = wlan_hdd_validate_context(pHddCtx);
6224 if (0 != ret)
6225 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306226 return ret;
6227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 switch(sub_cmd)
6229 {
6230 case WE_SET_WLAN_DBG:
6231 {
6232 vos_trace_setValue( value[1], value[2], value[3]);
6233 break;
6234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 case WE_SET_WDI_DBG:
6236 {
6237 wpalTraceSetLevel( value[1], value[2], value[3]);
6238 break;
6239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 case WE_SET_SAP_CHANNELS:
6241 {
6242 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
6243 break;
6244 }
6245
6246 default:
6247 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006248 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006249 break;
6250 }
6251 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306252 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 return ret;
6254}
6255
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306256int iw_set_three_ints_getnone(struct net_device *dev,
6257 struct iw_request_info *info,
6258 union iwreq_data *wrqu, char *extra)
6259{
6260 int ret;
6261
6262 vos_ssr_protect(__func__);
6263 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
6264 vos_ssr_unprotect(__func__);
6265
6266 return ret;
6267}
6268
6269static int __iw_get_char_setnone(struct net_device *dev,
6270 struct iw_request_info *info,
6271 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006272{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306273 hdd_adapter_t *pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 int sub_cmd = wrqu->data.flags;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306275 hdd_context_t *pHddCtx;
6276 int ret = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07006277#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006278 hdd_wext_state_t *pWextState;
6279#endif
6280
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306281 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306282 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006283 if (pAdapter == NULL)
6284 {
6285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6286 "%s: pAdapter is NULL!", __func__);
6287 return -EINVAL;
6288 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306289 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6290 ret = wlan_hdd_validate_context(pHddCtx);
6291 if (0 != ret)
Yue Ma3ede6052013-08-29 00:33:26 -07006292 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306293 return ret;
6294 }
6295#ifdef WLAN_FEATURE_11W
6296 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6297 if (NULL == pWextState)
6298 {
6299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6300 "%s: pWextState is NULL",__func__);
Yue Ma3ede6052013-08-29 00:33:26 -07006301 return -EINVAL;
6302 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306303#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006304
Jeff Johnson295189b2012-06-20 16:38:30 -07006305 switch(sub_cmd)
6306 {
6307 case WE_WLAN_VERSION:
6308 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08006309 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 break;
6311 }
6312
6313 case WE_GET_STATS:
6314 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306315 tHalHandle hHal = NULL;
6316 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006317 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6318 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
6319 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
6320
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306321
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 snprintf(extra, WE_MAX_STR_LEN,
6323 "\nTransmit"
6324 "\ncalled %u, dropped %u, backpressured %u, queued %u"
6325 "\n dropped BK %u, BE %u, VI %u, VO %u"
6326 "\n classified BK %u, BE %u, VI %u, VO %u"
6327 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
6328 "\n queued BK %u, BE %u, VI %u, VO %u"
6329 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006330 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 "\n fetched BK %u, BE %u, VI %u, VO %u"
6332 "\n dequeued BK %u, BE %u, VI %u, VO %u"
6333 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07006334 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 "\n flushed BK %u, BE %u, VI %u, VO %u"
6336 "\n\nReceive"
6337 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
6338 "\n\nResetsStats"
6339 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
6340 "\n",
6341 pStats->txXmitCalled,
6342 pStats->txXmitDropped,
6343 pStats->txXmitBackPressured,
6344 pStats->txXmitQueued,
6345
6346 pStats->txXmitDroppedAC[WLANTL_AC_BK],
6347 pStats->txXmitDroppedAC[WLANTL_AC_BE],
6348 pStats->txXmitDroppedAC[WLANTL_AC_VI],
6349 pStats->txXmitDroppedAC[WLANTL_AC_VO],
6350
6351 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
6352 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
6353 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
6354 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
6355
6356 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
6357 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
6358 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
6359 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
6360
6361 pStats->txXmitQueuedAC[WLANTL_AC_BK],
6362 pStats->txXmitQueuedAC[WLANTL_AC_BE],
6363 pStats->txXmitQueuedAC[WLANTL_AC_VI],
6364 pStats->txXmitQueuedAC[WLANTL_AC_VO],
6365
6366 pStats->txFetched,
6367 pStats->txFetchEmpty,
6368 pStats->txFetchLowResources,
6369 pStats->txFetchDequeueError,
6370
6371 pStats->txFetchDequeued,
6372 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07006373 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 pStats->txCompleted,
6375 pStats->txFlushed,
6376
6377 pStats->txFetchedAC[WLANTL_AC_BK],
6378 pStats->txFetchedAC[WLANTL_AC_BE],
6379 pStats->txFetchedAC[WLANTL_AC_VI],
6380 pStats->txFetchedAC[WLANTL_AC_VO],
6381
6382 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
6383 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
6384 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
6385 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
6386
6387 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
6388 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
6389 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
6390 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
6391
Ravi Joshi41914632013-10-21 23:02:21 -07006392 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
6393 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
6394 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
6395 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
6396
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 pStats->txFlushedAC[WLANTL_AC_BK],
6398 pStats->txFlushedAC[WLANTL_AC_BE],
6399 pStats->txFlushedAC[WLANTL_AC_VI],
6400 pStats->txFlushedAC[WLANTL_AC_VO],
6401
6402 pStats->rxChains,
6403 pStats->rxPackets,
6404 pStats->rxDropped,
6405 pStats->rxDelivered,
6406 pStats->rxRefused,
6407
6408 pResetStats->totalLogpResets,
6409 pResetStats->totalCMD53Failures,
6410 pResetStats->totalMutexReadFailures,
6411 pResetStats->totalMIFErrorFailures,
6412 pResetStats->totalFWHearbeatFailures,
6413 pResetStats->totalUnknownExceptions
6414 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306415 wrqu->data.length = strlen(extra);
6416
6417 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
6418
6419 if (hHal)
6420 pMac = PMAC_STRUCT( hHal );
6421
6422 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
6423 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
6424 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05306425 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
6426 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
6427 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
6428 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05306429 "\n",
6430 pMac->pmm.BmpscntSleep,
6431 pMac->pmm.BmpscntAwake,
6432 pMac->pmm.BmpsSleeReqFailCnt,
6433 pMac->pmm.BmpsWakeupReqFailCnt,
6434 pMac->pmm.ImpsCntSleep,
6435 pMac->pmm.ImpsCntAwake,
6436 pMac->pmm.ImpsSleepErrCnt,
6437 pMac->pmm.ImpsWakeupErrCnt,
6438 pMac->pmm.ImpsLastErr
6439 );
6440 }
6441
Jeff Johnson295189b2012-06-20 16:38:30 -07006442 wrqu->data.length = strlen(extra)+1;
6443 break;
6444 }
6445
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306446/* The case prints the current state of the HDD, SME, CSR, PE, TL
6447 *it can be extended for WDI Global State as well.
6448 *And currently it only checks P2P_CLIENT adapter.
6449 *P2P_DEVICE and P2P_GO have not been added as of now.
6450*/
6451 case WE_GET_STATES:
6452 {
6453 int buf = 0, len = 0;
6454 int adapter_num = 0;
6455 int count = 0, check = 1;
6456
6457 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006458 tHalHandle hHal = NULL;
6459 tpAniSirGlobal pMac = NULL;
6460 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306461
6462 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6463 hdd_adapter_t *useAdapter = NULL;
6464
6465 /* Print wlan0 or p2p0 states based on the adapter_num
6466 *by using the correct adapter
6467 */
6468 while ( adapter_num < 2 )
6469 {
6470 if ( WLAN_ADAPTER == adapter_num )
6471 {
6472 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006473 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306474 "\n\n wlan0 States:-");
6475 len += buf;
6476 }
6477 else if ( P2P_ADAPTER == adapter_num )
6478 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006479 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306480 "\n\n p2p0 States:-");
6481 len += buf;
6482
6483 if( !pHddCtx )
6484 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006485 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306486 "\n pHddCtx is NULL");
6487 len += buf;
6488 break;
6489 }
6490
6491 /*Printing p2p0 states only in the case when the device is
6492 configured as a p2p_client*/
6493 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
6494 if ( !useAdapter )
6495 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006496 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306497 "\n Device not configured as P2P_CLIENT.");
6498 len += buf;
6499 break;
6500 }
6501 }
6502
6503 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006504 if (!hHal) {
6505 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6506 "\n pMac is NULL");
6507 len += buf;
6508 break;
6509 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306510 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006511 if (!pMac) {
6512 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6513 "\n pMac is NULL");
6514 len += buf;
6515 break;
6516 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306517 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
6518 if( !pHddStaCtx )
6519 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006520 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306521 "\n pHddStaCtx is NULL");
6522 len += buf;
6523 break;
6524 }
6525
6526 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
6527
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006528 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306529 "\n HDD Conn State - %s "
6530 "\n \n SME State:"
6531 "\n Neighbour Roam State - %s"
6532 "\n CSR State - %s"
6533 "\n CSR Substate - %s"
6534 "\n \n TL STA %d State: %s",
6535 macTraceGetHDDWlanConnState(
6536 pHddStaCtx->conn_info.connState),
6537 macTraceGetNeighbourRoamState(
6538 pMac->roam.neighborRoamInfo.neighborRoamState),
6539 macTraceGetcsrRoamState(
6540 pMac->roam.curState[useAdapter->sessionId]),
6541 macTraceGetcsrRoamSubState(
6542 pMac->roam.curSubState[useAdapter->sessionId]),
6543 pHddStaCtx->conn_info.staId[0],
6544 macTraceGetTLState(tlState)
6545 );
6546 len += buf;
6547 adapter_num++;
6548 }
6549
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006550 if (pMac) {
6551 /* Printing Lim State starting with global lim states */
6552 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6553 "\n \n LIM STATES:-"
6554 "\n Global Sme State - %s "\
6555 "\n Global mlm State - %s "\
6556 "\n",
6557 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
6558 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
6559 );
6560 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306561
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006562 /*printing the PE Sme and Mlm states for valid lim sessions*/
6563 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306564 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006565 if ( pMac->lim.gpSession[count].valid )
6566 {
6567 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6568 "\n Lim Valid Session %d:-"
6569 "\n PE Sme State - %s "
6570 "\n PE Mlm State - %s "
6571 "\n",
6572 check,
6573 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
6574 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
6575 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306576
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006577 len += buf;
6578 check++;
6579 }
6580 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306581 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306582 }
6583
6584 wrqu->data.length = strlen(extra)+1;
6585 break;
6586 }
6587
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 case WE_GET_CFG:
6589 {
6590 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
6591 wrqu->data.length = strlen(extra)+1;
6592 break;
6593 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006594#ifdef WLAN_FEATURE_11AC
6595 case WE_GET_RSSI:
6596 {
6597 v_S7_t s7Rssi = 0;
6598 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
6599 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
6600 wrqu->data.length = strlen(extra)+1;
6601 break;
6602 }
6603#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306604
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006605#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006606 case WE_GET_ROAM_RSSI:
6607 {
6608 v_S7_t s7Rssi = 0;
6609 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
6610 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6611 wrqu->data.length = strlen(extra)+1;
6612 break;
6613 }
6614#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 case WE_GET_WMM_STATUS:
6616 {
6617 snprintf(extra, WE_MAX_STR_LEN,
6618 "\nDir: 0=up, 1=down, 3=both\n"
6619 "|------------------------|\n"
6620 "|AC | ACM |Admitted| Dir |\n"
6621 "|------------------------|\n"
6622 "|VO | %d | %3s | %d |\n"
6623 "|VI | %d | %3s | %d |\n"
6624 "|BE | %d | %3s | %d |\n"
6625 "|BK | %d | %3s | %d |\n"
6626 "|------------------------|\n",
6627 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
6628 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
6629 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
6630 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
6631 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
6632 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
6633 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
6634 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
6635 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
6636 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
6637 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
6638 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
6639
Jeff Johnsone7245742012-09-05 17:12:55 -07006640
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 wrqu->data.length = strlen(extra)+1;
6642 break;
6643 }
6644 case WE_GET_CHANNEL_LIST:
6645 {
6646 VOS_STATUS status;
6647 v_U8_t i, len;
6648 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05306649 tANI_U8 pBuf[COUNTRY_CODE_LEN];
6650 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
6651 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 tChannelListInfo channel_list;
6653
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006654 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006656 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006657 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006658 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 return -EINVAL;
6660 }
6661 buf = extra;
6662
6663 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006664 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
6665 * needed = 5 * number of channels. Check ifsufficient
6666 * buffer is available and then proceed to fill the buffer.
6667 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
6669 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006670 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006671 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006672 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 return -EINVAL;
6674 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006675 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
6676 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05306677 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
6678 {
6679 //Printing Country code in getChannelList
6680 for(i= 0; i < COUNTRY_CODE_LEN; i++)
6681 {
6682 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
6683 "%c ", pBuf[i]);
6684 }
6685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006686 for(i = 0 ; i < channel_list.num_channels; i++)
6687 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07006688 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006689 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 }
6691 wrqu->data.length = strlen(extra)+1;
6692
6693 break;
6694 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006695#ifdef FEATURE_WLAN_TDLS
6696 case WE_GET_TDLS_PEERS:
6697 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006698 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08006699 break;
6700 }
6701#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006702#ifdef WLAN_FEATURE_11W
6703 case WE_GET_11W_INFO:
6704 {
6705 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
6706
6707 snprintf(extra, WE_MAX_STR_LEN,
6708 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
6709 "\n Number of Unprotected Disassocs %d"
6710 "\n Number of Unprotected Deauths %d",
6711 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
6712 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
6713 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
6714 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
6715 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
6716
6717 wrqu->data.length = strlen(extra)+1;
6718 break;
6719 }
6720#endif
Girish Gowlidab72f12014-09-04 15:34:43 +05306721 case WE_GET_SNR:
6722 {
6723 v_S7_t s7snr = 0;
6724 int status = 0;
6725 hdd_context_t *pHddCtx;
6726 hdd_station_ctx_t *pHddStaCtx;
6727
6728 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6729 status = wlan_hdd_validate_context(pHddCtx);
6730 if (0 != status)
6731 {
Girish Gowlidab72f12014-09-04 15:34:43 +05306732 return status;
6733 }
6734
6735 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6736
6737 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
6738 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
6739 {
6740 hddLog(LOGE, "%s: getSNR failed: Enable SNR Monitoring-%d,"
6741 " ConnectionState-%d", __func__,
6742 pHddCtx->cfg_ini->fEnableSNRMonitoring,
6743 pHddStaCtx->conn_info.connState);
6744 return -ENONET;
6745 }
6746
6747 /*update the stats in TL*/
6748 wlan_hdd_get_station_stats(pAdapter);
6749 wlan_hdd_get_snr(pAdapter, &s7snr);
6750 snprintf(extra, WE_MAX_STR_LEN, "snr=%d",s7snr);
6751 wrqu->data.length = strlen(extra) + 1;
6752 break;
6753 }
6754
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306755 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 {
Jeff Johnson11e77032014-02-14 13:22:22 -08006757 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 break;
6759 }
6760 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306761 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006762 return 0;
6763}
6764
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306765static int iw_get_char_setnone(struct net_device *dev,
6766 struct iw_request_info *info,
6767 union iwreq_data *wrqu, char *extra)
6768{
6769 int ret;
6770
6771 vos_ssr_protect(__func__);
6772 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
6773 vos_ssr_unprotect(__func__);
6774
6775 return ret;
6776}
6777
Jeff Johnson295189b2012-06-20 16:38:30 -07006778/* action sub-ioctls */
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306779static int __iw_setnone_getnone(struct net_device *dev,
6780 struct iw_request_info *info,
6781 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07006782{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306783 hdd_adapter_t *pAdapter;
6784 hdd_context_t *pHddCtx;
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306785 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08006786 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306787 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07006788
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306789 ENTER();
6790
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306791 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6792 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006793 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6795 "%s: Adapter is NULL",__func__);
6796 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006797 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306798 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6799 ret = wlan_hdd_validate_context(pHddCtx);
6800 if (0 != ret)
6801 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05306802 return ret;
6803 }
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05306804 /* helper function to get iwreq_data with compat handling. */
6805 if (hdd_priv_get_data(&s_priv_data, wrqu))
6806 {
6807 return -EINVAL;
6808 }
6809
6810 sub_cmd = s_priv_data.flags;
6811
Jeff Johnson295189b2012-06-20 16:38:30 -07006812 switch (sub_cmd)
6813 {
6814 case WE_CLEAR_STATS:
6815 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6818 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
6819 break;
6820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 case WE_INIT_AP:
6822 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05306823 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6824
6825 /* As Soft AP mode might been changed to STA already with
6826 * killing of Hostapd, need to find the adpater by name
6827 * rather than mode */
6828 hdd_adapter_t* pAdapter_to_stop =
6829 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6830 if( pAdapter_to_stop )
6831 {
6832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6833 "Adapter with name softap.0 already "
6834 "exist, ignoring the request.\nRemove the "
6835 "adapter and try again\n");
6836 break;
6837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 pr_info("Init AP trigger\n");
6839 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
6840 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
6841 break;
6842 }
6843 case WE_STOP_AP:
6844 {
6845 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
6846 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
6847 * this is a dead code and need to find the adpater by name rather than mode */
6848 hdd_adapter_t* pAdapter_to_stop =
6849 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
6850 if( pAdapter_to_stop )
6851 {
6852 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6853
6854 pr_info("Stopping AP mode\n");
6855
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306856 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6857 {
6858 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
6859 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
6860 }
6861
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306863 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
c_hpothu002231a2015-02-05 14:58:51 +05306864 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
6866
6867 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
6868 pAdapter_to_stop->macAddressCurrent.bytes);
6869 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
6870 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05306871
6872 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
6873 {
6874 /* put the device back into BMPS */
6875 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
6876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 }
6878 else
6879 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006880 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07006881 }
6882
6883 break;
6884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006885#ifdef WLAN_BTAMP_FEATURE
6886 case WE_ENABLE_AMP:
6887 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006889 WLANBAP_RegisterWithHCI(pAdapter);
6890 break;
6891 }
6892 case WE_DISABLE_AMP:
6893 {
6894 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6895 VOS_STATUS status;
6896
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006898
6899 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6900 status = WLANBAP_StopAmp();
6901 if(VOS_STATUS_SUCCESS != status )
6902 {
6903 pHddCtx->isAmpAllowed = VOS_TRUE;
6904 hddLog(VOS_TRACE_LEVEL_FATAL,
6905 "%s: Failed to stop AMP", __func__);
6906 }
6907 else
6908 {
6909 //a state m/c implementation in PAL is TBD to avoid this delay
6910 msleep(500);
6911 pHddCtx->isAmpAllowed = VOS_FALSE;
6912 WLANBAP_DeregisterFromHCI();
6913 }
6914
6915 break;
6916 }
6917#endif
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006918 case WE_ENABLE_DXE_STALL_DETECT:
6919 {
schang6295e542013-03-12 15:31:23 -07006920 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6921 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006922 break;
6923 }
6924 case WE_DISPLAY_DXE_SNAP_SHOT:
6925 {
schang6295e542013-03-12 15:31:23 -07006926 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6927 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006928 break;
6929 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306930 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
6931 {
6932 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
6933 hdd_wmm_tx_snapshot(pAdapter);
Mihir Shete327c2ab2014-11-13 15:17:02 +05306934 WLANTL_TLDebugMessage(WLANTL_DEBUG_TX_SNAPSHOT);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05306935 break;
6936 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05306937
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306938 case WE_SET_REASSOC_TRIGGER:
6939 {
6940 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6941 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6942 v_U32_t roamId = 0;
6943 tCsrRoamModifyProfileFields modProfileFields;
6944 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
6945 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
6946 return 0;
6947 }
6948
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306949 case WE_STOP_OBSS_SCAN:
6950 {
6951 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
6952 2.OBSS scan is stopped by Firmware during the disassociation
6953 3.OBSS stop comamnd is added for debugging purpose*/
6954 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6955 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07006956
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306957 if (pAdapter == NULL)
6958 {
6959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6960 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306961 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306962 }
6963 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
6964 if (pMac == NULL)
6965 {
6966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6967 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05306968 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05306969 }
6970 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
6971 }
6972 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05306973 case WE_DUMP_ROAM_TIMER_LOG:
6974 {
6975 vos_dump_roam_time_log_service();
6976 break;
6977 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05306978
Mukul Sharma84f27252014-07-14 18:11:42 +05306979 case WE_RESET_ROAM_TIMER_LOG:
6980 {
6981 vos_reset_roam_timer_log();
6982 break;
6983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 default:
6985 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006986 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07006987 break;
6988 }
6989 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05306990 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 return ret;
6992}
6993
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05306994static int iw_setnone_getnone(struct net_device *dev,
6995 struct iw_request_info *info,
6996 union iwreq_data *wrqu, char *extra)
6997{
6998 int ret;
6999
7000 vos_ssr_protect(__func__);
7001 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7002 vos_ssr_unprotect(__func__);
7003
7004 return ret;
7005}
7006
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307007void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
7008{
7009 /*
7010 * Function to display HDD WMM information
7011 * for Tx Queues.
7012 * Prints globala as well as per client depending
7013 * whether the clients are registered or not.
7014 */
7015 int i = 0, j = 0;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307016 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
7017 ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext);
Katya Nigam1fd24402015-02-16 14:52:19 +05307018 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7019 hdd_ibss_peer_info_t *pPeerInfo;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307020
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307021 for ( i=0; i< NUM_TX_QUEUES; i++)
7022 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307023 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307024
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007025 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307026 i, pAdapter->wmm_tx_queue[i].count,
7027 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05307028 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307029 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307030 if(pSapCtx == NULL){
7031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7032 FL("psapCtx is NULL"));
7033 return;
7034 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307035
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307036 spin_lock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307037 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
7038 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307039 if(pSapCtx->aStaInfo[i].isUsed)
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307040 {
7041 hddLog(LOGE, "******STAIndex: %d*********", i);
7042 for ( j=0; j< NUM_TX_QUEUES; j++)
7043 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307044 spin_lock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007045 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05307046 j, pSapCtx->aStaInfo[i].wmm_tx_queue[j].count,
7047 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
7048 pSapCtx->aStaInfo[i].wmm_tx_queue[j].anchor.next);
7049 spin_unlock_bh(&pSapCtx->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307050 }
7051 }
7052 }
Vinay Krishna Eranna17f60662015-02-23 13:17:28 +05307053 spin_unlock_bh(&pSapCtx->staInfo_lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307054
Katya Nigam1fd24402015-02-16 14:52:19 +05307055 if(pHddStaCtx == NULL){
7056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7057 FL("pHddStaCtx is NULL"));
7058 return;
7059 }
7060
7061 pPeerInfo = &pHddStaCtx->ibss_peer_info;
7062 if(pPeerInfo == NULL){
7063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7064 FL("ppeerinfo is NULL"));
7065 return;
7066 }
7067
7068 for(i =0; i< HDD_MAX_NUM_IBSS_STA; i++)
7069 {
7070 if(pPeerInfo->ibssStaInfo[i].isUsed)
7071 {
7072 hddLog(LOGE, "******IBSS STAIndex: %d*********", i);
7073 for ( j=0; j< NUM_TX_QUEUES; j++)
7074 {
7075 spin_lock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7076 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
7077 j, pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].count,
7078 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.prev,
7079 pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].anchor.next);
7080 spin_unlock_bh(&pPeerInfo->ibssStaInfo[i].wmm_tx_queue[j].lock);
7081 }
7082 }
7083 }
7084
7085
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05307086}
Girish Gowlifb9758e2014-11-19 15:19:17 +05307087static int __iw_set_var_ints_getnone(struct net_device *dev,
7088 struct iw_request_info *info,
7089 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007090{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307091 hdd_adapter_t *pAdapter;
7092 tHalHandle hHal;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307093 int sub_cmd;
Girish Gowlifb9758e2014-11-19 15:19:17 +05307094 int *apps_args = (int *) extra;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007095 hdd_station_ctx_t *pStaCtx = NULL ;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307096 hdd_context_t *pHddCtx = NULL;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007097 hdd_ap_ctx_t *pAPCtx = NULL;
7098 int cmd = 0;
7099 int staId = 0;
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307100 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007101
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307102 ENTER();
Girish Gowlifb9758e2014-11-19 15:19:17 +05307103 if (extra == NULL)
Girish Gowlid4522fd2014-06-14 17:20:27 +05307104 {
Girish Gowlifb9758e2014-11-19 15:19:17 +05307105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7106 "%s: NULL extra buffer pointer", __func__);
7107 return -EINVAL;
Girish Gowlid4522fd2014-06-14 17:20:27 +05307108 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307109 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7110 if (NULL == pAdapter)
7111 {
7112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7113 "%s: Adapter is NULL",__func__);
7114 return -EINVAL;
7115 }
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307116 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7117 ret = wlan_hdd_validate_context(pHddCtx);
7118 if (0 != ret)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007119 {
Mahesh A Saptasagar178ab1d2014-09-08 15:11:05 +05307120 return ret;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007121 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307122 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7123 if (NULL == hHal)
7124 {
7125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7126 "%s: Hal Context is NULL",__func__);
7127 return -EINVAL;
7128 }
7129 sub_cmd = wrqu->data.flags;
7130
7131 hddLog(LOG1, "%s: Received length %d", __func__, wrqu->data.length);
7132
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007133
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007134 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
7135 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
7136 {
7137 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
7138 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
7139 {
7140 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7141 staId = pStaCtx->conn_info.staId[0];
7142 }
7143 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
7144 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
7145 {
7146 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7147 staId = pAPCtx->uBCStaId;
7148 }
7149 else
7150 {
7151 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
7152 return 0;
7153 }
7154 }
7155
Jeff Johnson295189b2012-06-20 16:38:30 -07007156 switch (sub_cmd)
7157 {
7158 case WE_LOG_DUMP_CMD:
7159 {
7160 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007161 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 apps_args[3], apps_args[4]);
7163
7164 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
7165 apps_args[3], apps_args[4]);
7166
7167 }
7168 break;
7169
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 case WE_P2P_NOA_CMD:
7171 {
7172 p2p_app_setP2pPs_t p2pNoA;
7173
7174 p2pNoA.opp_ps = apps_args[0];
7175 p2pNoA.ctWindow = apps_args[1];
7176 p2pNoA.duration = apps_args[2];
7177 p2pNoA.interval = apps_args[3];
7178 p2pNoA.count = apps_args[4];
7179 p2pNoA.single_noa_duration = apps_args[5];
7180 p2pNoA.psSelection = apps_args[6];
7181
7182 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
7183 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007184 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
7186
7187 hdd_setP2pPs(dev, &p2pNoA);
7188
7189 }
7190 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007191
Katya Nigamc2f29dc2014-01-20 19:29:30 +05307192 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7193 {
7194 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7195 __func__, apps_args[0], apps_args[1]);
7196 vosTraceEnable(apps_args[0], apps_args[1]);
7197 }
7198 break;
7199
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07007200 case WE_MTRACE_DUMP_CMD:
7201 {
7202 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
7203 "bitmask_of_module %d ",
7204 __func__, apps_args[0], apps_args[1], apps_args[2],
7205 apps_args[3]);
7206 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
7207 apps_args[2], apps_args[3]);
7208
7209 }
7210 break;
7211
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007212 case WE_MCC_CONFIG_CREDENTIAL :
7213 {
7214 cmd = 287; //Command should be updated if there is any change
7215 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08007216 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007217 {
7218 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
7219 }
7220 else
7221 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007222 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08007223 return 0;
7224 }
7225 }
7226 break;
7227
7228 case WE_MCC_CONFIG_PARAMS :
7229 {
7230 cmd = 288; //command Should be updated if there is any change
7231 // in the Riva dump command
7232 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
7233 }
7234 break;
7235
Chilam NG571c65a2013-01-19 12:27:36 +05307236#ifdef FEATURE_WLAN_TDLS
7237 case WE_TDLS_CONFIG_PARAMS :
7238 {
7239 tdls_config_params_t tdlsParams;
7240
Chilam Ng01120412013-02-19 18:32:21 -08007241 tdlsParams.tdls = apps_args[0];
7242 tdlsParams.tx_period_t = apps_args[1];
7243 tdlsParams.tx_packet_n = apps_args[2];
7244 tdlsParams.discovery_period_t = apps_args[3];
7245 tdlsParams.discovery_tries_n = apps_args[4];
7246 tdlsParams.idle_timeout_t = apps_args[5];
7247 tdlsParams.idle_packet_n = apps_args[6];
7248 tdlsParams.rssi_hysteresis = apps_args[7];
7249 tdlsParams.rssi_trigger_threshold = apps_args[8];
7250 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05307251
Chilam Ng01120412013-02-19 18:32:21 -08007252 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05307253 }
7254 break;
7255#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 default:
7257 {
Jeff Johnson11e77032014-02-14 13:22:22 -08007258 hddLog(LOGE, "%s: Invalid IOCTL command %d",
7259 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 }
7261 break;
7262 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307263 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007264 return 0;
7265}
7266
Girish Gowlifb9758e2014-11-19 15:19:17 +05307267static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7268 struct iw_request_info *info,
7269 union iwreq_data *wrqu, char *extra)
7270{
7271 int ret;
7272 union iwreq_data u_priv_wrqu;
7273 int apps_args[MAX_VAR_ARGS] = {0};
7274 int num_args;
7275
7276 /* helper function to get iwreq_data with compat handling. */
7277 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7278 {
7279 return -EINVAL;
7280 }
7281
7282 if (NULL == u_priv_wrqu.data.pointer)
7283 {
7284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7285 "%s: NULL data pointer", __func__);
7286 return -EINVAL;
7287 }
7288
7289 num_args = u_priv_wrqu.data.length;
7290 if (num_args > MAX_VAR_ARGS)
7291 {
7292 num_args = MAX_VAR_ARGS;
7293 }
7294
7295 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7296 (sizeof(int)) * num_args))
7297 {
7298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7299 "%s: failed to copy data from user buffer", __func__);
7300 return -EFAULT;
7301 }
7302
7303 vos_ssr_protect(__func__);
7304 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7305 (char *)&apps_args);
7306 vos_ssr_unprotect(__func__);
7307
7308 return ret;
7309}
7310
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307311int iw_set_var_ints_getnone(struct net_device *dev,
7312 struct iw_request_info *info,
7313 union iwreq_data *wrqu, char *extra)
7314{
7315 int ret;
7316 vos_ssr_protect(__func__);
7317 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7318 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007319
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307320 return ret;
7321}
7322
7323static int __iw_add_tspec(struct net_device *dev,
7324 struct iw_request_info *info,
7325 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007326{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307327 hdd_adapter_t *pAdapter;
7328 hdd_station_ctx_t *pHddStaCtx;
7329 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007330 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7331 int params[HDD_WLAN_WMM_PARAM_COUNT];
7332 sme_QosWmmTspecInfo tSpec;
7333 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05307334 struct iw_point s_priv_data;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307335 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007336
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307337 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307338 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7339 if (NULL == pAdapter)
7340 {
7341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7342 "%s: Adapter is NULL",__func__);
7343 return -EINVAL;
7344 }
7345 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7346 ret = wlan_hdd_validate_context(pHddCtx);
7347 if (0 != ret)
7348 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307349 return ret;
7350 }
7351 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7352 if (NULL == pHddStaCtx)
7353 {
7354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7355 "%s: STA Context is NULL",__func__);
7356 return -EINVAL;
7357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 // make sure the application is sufficiently priviledged
7359 // note that the kernel will do this for "set" ioctls, but since
7360 // this ioctl wants to return status to user space it must be
7361 // defined as a "get" ioctl
7362 if (!capable(CAP_NET_ADMIN))
7363 {
7364 return -EPERM;
7365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 // we must be associated in order to add a tspec
7367 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7368 {
7369 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7370 return 0;
7371 }
7372
7373 // since we are defined to be a "get" ioctl, and since the number
7374 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05307375 // will pass down in the iwreq_data, we must copy the "set" params.
7376 // We must handle the compat for iwreq_data in 32U/64K environment.
7377
7378 // helper fucntion to get iwreq_data with compat handling.
7379 if (hdd_priv_get_data(&s_priv_data, wrqu))
7380 {
7381 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7382 return 0;
7383 }
7384
7385 // make sure all params are correctly passed to function
7386 if ((NULL == s_priv_data.pointer) ||
7387 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
7388 {
7389 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7390 return 0;
7391 }
7392
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05307394 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007395 {
7396 // hmmm, can't get them
7397 return -EIO;
7398 }
7399
7400 // clear the tspec
7401 memset(&tSpec, 0, sizeof(tSpec));
7402
7403 // validate the handle
7404 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7405 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7406 {
7407 // that one is reserved
7408 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7409 return 0;
7410 }
7411
7412 // validate the TID
7413 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
7414 {
7415 // out of range
7416 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7417 return 0;
7418 }
7419 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7420
7421 // validate the direction
7422 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
7423 {
7424 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7425 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7426 break;
7427
7428 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7429 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7430 break;
7431
7432 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7433 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7434 break;
7435
7436 default:
7437 // unknown
7438 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7439 return 0;
7440 }
7441
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05307442 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7443
Jeff Johnson295189b2012-06-20 16:38:30 -07007444 // validate the user priority
7445 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
7446 {
7447 // out of range
7448 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7449 return 0;
7450 }
7451 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05307452 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
7453 {
7454 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
7455 return 0;
7456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007457
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05307458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
7459 "%s:TS_INFO PSB %d UP %d !!!", __func__,
7460 tSpec.ts_info.psb, tSpec.ts_info.up);
7461
Jeff Johnson295189b2012-06-20 16:38:30 -07007462 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7463 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7464 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7465 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7466 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7467 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7468 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7469 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7470 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7471 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7472 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7473 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7474
7475 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7476
Kanchanapally, Vidyullatha23cea3c2014-11-04 13:05:20 +05307477 // Save the expected UAPSD settings by application, this will be needed
7478 // when re-negotiating UAPSD settings during BT Coex cases.
7479 tSpec.expec_psb_byapp = params[HDD_WLAN_WMM_PARAM_APSD];
7480
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 // validate the ts info ack policy
7482 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
7483 {
7484 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
7485 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7486 break;
7487
7488 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7489 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7490 break;
7491
7492 default:
7493 // unknown
7494 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7495 return 0;
7496 }
7497
7498 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307499
7500 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 return 0;
7502}
7503
7504
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307505static int iw_add_tspec(struct net_device *dev,
7506 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 union iwreq_data *wrqu, char *extra)
7508{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307509 int ret;
7510
7511 vos_ssr_protect(__func__);
7512 ret = __iw_add_tspec(dev, info, wrqu, extra);
7513 vos_ssr_unprotect(__func__);
7514
7515 return ret;
7516}
7517
7518static int __iw_del_tspec(struct net_device *dev,
7519 struct iw_request_info *info,
7520 union iwreq_data *wrqu, char *extra)
7521{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307522 hdd_adapter_t *pAdapter;
7523 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007524 int *params = (int *)extra;
7525 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7526 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307527 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007528
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307529 ENTER();
7530
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307531 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7532 if (NULL == pAdapter)
7533 {
7534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7535 "%s: Adapter is NULL",__func__);
7536 return -EINVAL;
7537 }
7538
7539 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7540 ret = wlan_hdd_validate_context(pHddCtx);
7541 if (0 != ret)
7542 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307543 return ret;
7544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 // make sure the application is sufficiently priviledged
7546 // note that the kernel will do this for "set" ioctls, but since
7547 // this ioctl wants to return status to user space it must be
7548 // defined as a "get" ioctl
7549 if (!capable(CAP_NET_ADMIN))
7550 {
7551 return -EPERM;
7552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 // although we are defined to be a "get" ioctl, the params we require
7554 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7555 // is no need to copy the params from user space
7556
7557 // validate the handle
7558 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7559 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7560 {
7561 // that one is reserved
7562 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7563 return 0;
7564 }
7565
7566 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307567
7568 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 return 0;
7570}
7571
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307572static int iw_del_tspec(struct net_device *dev,
7573 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 union iwreq_data *wrqu, char *extra)
7575{
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307576 int ret;
7577
7578 vos_ssr_protect(__func__);
7579 ret = __iw_del_tspec(dev, info, wrqu, extra);
7580 vos_ssr_unprotect(__func__);
7581
7582 return ret;
7583}
7584
7585
7586static int __iw_get_tspec(struct net_device *dev,
7587 struct iw_request_info *info,
7588 union iwreq_data *wrqu, char *extra)
7589{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307590 hdd_adapter_t *pAdapter;
7591 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 int *params = (int *)extra;
7593 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
7594 v_U32_t handle;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307595 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007596
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307597 ENTER();
7598
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 // although we are defined to be a "get" ioctl, the params we require
7600 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
7601 // is no need to copy the params from user space
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307602 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7603 if (NULL == pAdapter)
7604 {
7605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7606 "%s: Adapter is NULL",__func__);
7607 return -EINVAL;
7608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007609
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307610 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7611 ret = wlan_hdd_validate_context(pHddCtx);
7612 if (0 != ret)
7613 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307614 return ret;
7615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 // validate the handle
7617 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7618 if (HDD_WMM_HANDLE_IMPLICIT == handle)
7619 {
7620 // that one is reserved
7621 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7622 return 0;
7623 }
7624
7625 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307626 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007627 return 0;
7628}
7629
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307630static int iw_get_tspec(struct net_device *dev,
7631 struct iw_request_info *info,
7632 union iwreq_data *wrqu, char *extra)
7633{
7634 int ret;
7635
7636 vos_ssr_protect(__func__);
7637 ret = __iw_get_tspec(dev, info, wrqu, extra);
7638 vos_ssr_unprotect(__func__);
7639
7640 return ret;
7641}
7642
Jeff Johnson295189b2012-06-20 16:38:30 -07007643#ifdef WLAN_FEATURE_VOWIFI_11R
7644//
7645//
7646// Each time the supplicant has the auth_request or reassoc request
7647// IEs ready. This is pushed to the driver. The driver will inturn use
7648// it to send out the auth req and reassoc req for 11r FT Assoc.
7649//
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307650static int __iw_set_fties(struct net_device *dev,
7651 struct iw_request_info *info,
7652 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007653{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307654 hdd_adapter_t *pAdapter;
7655 hdd_station_ctx_t *pHddStaCtx;
7656 hdd_context_t *pHddCtx;
7657 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007658 //v_CONTEXT_t pVosContext;
7659
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307660 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307661 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7662 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007663 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7665 "%s: Adapter is NULL",__func__);
7666 return -EINVAL;
7667 }
7668 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7669 ret = wlan_hdd_validate_context(pHddCtx);
7670 if (0 != ret)
7671 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307672 return ret;
7673 }
7674 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7675 if (NULL == pHddStaCtx)
7676 {
7677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7678 "%s: STA Context is NULL",__func__);
7679 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007681 if (!wrqu->data.length)
7682 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007683 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007684 return -EINVAL;
7685 }
7686 if (wrqu->data.pointer == NULL)
7687 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007688 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007689 return -EINVAL;
7690 }
7691
7692 // Added for debug on reception of Re-assoc Req.
7693 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7694 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007695 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007696 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08007697 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 }
7699
7700#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08007701 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07007702#endif
7703
7704 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08007705 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 wrqu->data.length);
7707
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307708 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 return 0;
7710}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307711
7712static int iw_set_fties(struct net_device *dev,
7713 struct iw_request_info *info,
7714 union iwreq_data *wrqu, char *extra)
7715{
7716 int ret;
7717
7718 vos_ssr_protect(__func__);
7719 ret = __iw_set_fties(dev, info, wrqu, extra);
7720 vos_ssr_unprotect(__func__);
7721
7722 return ret;
7723}
Jeff Johnson295189b2012-06-20 16:38:30 -07007724#endif
7725
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307726static int __iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007727 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07007728 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08007729{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307730 hdd_adapter_t *pAdapter;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007731 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307732 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007733 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307734 tHalHandle hHal;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007735 tpSirRcvFltMcAddrList mc_addr_list_ptr;
7736 int idx;
7737 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07007738
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307739 ENTER();
7740
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307741 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7742 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007743 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7745 "%s: Adapter is NULL",__func__);
7746 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007747 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7749 ret_val = wlan_hdd_validate_context(pHddCtx);
7750 if (0 != ret_val)
7751 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307752 return ret_val;
7753 }
7754 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7755 if (NULL == hHal)
7756 {
7757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7758 "%s: Hal Context is NULL",__func__);
7759 return -EINVAL;
7760 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307761 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
7762 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307763#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07007764
Amar Singhalf3a6e762013-02-19 15:06:50 -08007765 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
7766 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007767 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007768 hddLog(VOS_TRACE_LEVEL_ERROR,
7769 "%s: vos_mem_alloc failed", __func__);
7770 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007771 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007772
7773 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
7774
7775 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
7776 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
7777
7778 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
7779 mc_addr_list_ptr->ulMulticastAddrCnt);
7780
7781 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007782 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08007783 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
7784 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
7785
7786 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
7787 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007788 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007789
Amar Singhalf3a6e762013-02-19 15:06:50 -08007790 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
7791 vos_mem_free(mc_addr_list_ptr);
7792 if (eHAL_STATUS_SUCCESS != ret_val)
7793 {
7794 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
7795 __func__);
7796 return -EINVAL;
7797 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307798#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307799 }
7800 else
7801 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007802
Amar Singhalf3a6e762013-02-19 15:06:50 -08007803 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7804 "%s: Set MC BC Filter Config request: %d suspend %d",
7805 __func__, pRequest->mcastBcastFilterSetting,
7806 pHddCtx->hdd_wlan_suspended);
7807
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307808 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007809
7810 if (pHddCtx->hdd_wlan_suspended)
7811 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007812 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7813 if (NULL == wlanRxpFilterParam)
7814 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307815 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07007816 "%s: vos_mem_alloc failed", __func__);
7817 return -EINVAL;
7818 }
7819
Amar Singhalf3a6e762013-02-19 15:06:50 -08007820 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7821 pRequest->mcastBcastFilterSetting;
7822 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7823
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307824 hdd_conf_hostoffload(pAdapter, TRUE);
7825 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7826 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08007827
7828 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
7829 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307830 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08007831 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
7832 wlanRxpFilterParam->setMcstBcstFilter);
7833
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307834 if (eHAL_STATUS_SUCCESS !=
7835 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7836 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08007837 {
7838 hddLog(VOS_TRACE_LEVEL_ERROR,
7839 "%s: Failure to execute set HW MC/BC Filter request",
7840 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07007841 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08007842 return -EINVAL;
7843 }
7844
c_hpothud3ce76d2014-10-28 10:34:13 +05307845 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7846 {
7847 pHddCtx->sus_res_mcastbcast_filter =
7848 pRequest->mcastBcastFilterSetting;
7849 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08007850 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07007851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007852
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307853 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 return 0;
7855}
7856
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307857static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7858 struct iw_request_info *info,
7859 union iwreq_data *wrqu, char *extra)
7860{
7861 int ret;
7862
7863 vos_ssr_protect(__func__);
7864 ret = __iw_set_dynamic_mcbc_filter(dev, info, wrqu, extra);
7865 vos_ssr_unprotect(__func__);
7866
7867 return ret;
7868}
7869
7870static int __iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7871 struct iw_request_info *info,
7872 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007873{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307874 hdd_adapter_t *pAdapter;
7875 hdd_context_t *pHddCtx;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307876 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307877 int ret = 0;
7878
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307879 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007880
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307881 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7882 if (NULL == pAdapter)
7883 {
7884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7885 "%s: Adapter is NULL",__func__);
7886 return -EINVAL;
7887 }
7888
7889 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7890 ret = wlan_hdd_validate_context(pHddCtx);
7891 if (0 != ret)
7892 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307893 return ret;
7894 }
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307895 //Reset the filter to INI value as we have to clear the dynamic filter
7896 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07007897
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307898 //Configure FW with new setting
7899 if (pHddCtx->hdd_wlan_suspended)
7900 {
7901 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
7902 if (NULL == wlanRxpFilterParam)
7903 {
7904 hddLog(VOS_TRACE_LEVEL_ERROR,
7905 "%s: vos_mem_alloc failed", __func__);
7906 return -EINVAL;
7907 }
7908
7909 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7910 pHddCtx->configuredMcastBcastFilter;
7911 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
7912
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307913 hdd_conf_hostoffload(pAdapter, TRUE);
7914 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
7915 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307916
7917 if (eHAL_STATUS_SUCCESS !=
7918 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
7919 wlanRxpFilterParam))
7920 {
7921 hddLog(VOS_TRACE_LEVEL_ERROR,
7922 "%s: Failure to execute set HW MC/BC Filter request",
7923 __func__);
7924 vos_mem_free(wlanRxpFilterParam);
7925 return -EINVAL;
7926 }
c_hpothud3ce76d2014-10-28 10:34:13 +05307927
7928 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid)
7929 {
7930 pHddCtx->sus_res_mcastbcast_filter =
7931 pHddCtx->cfg_ini->mcastBcastFilterSetting;
7932 }
7933
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05307934 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307935 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007936 return 0;
7937}
7938
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05307939
7940static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
7941 struct iw_request_info *info,
7942 union iwreq_data *wrqu, char *extra)
7943{
7944 int ret;
7945
7946 vos_ssr_protect(__func__);
7947 ret = __iw_clear_dynamic_mcbc_filter(dev, info, wrqu, extra);
7948 vos_ssr_unprotect(__func__);
7949
7950 return ret;
7951}
7952
7953static int __iw_set_host_offload(struct net_device *dev,
7954 struct iw_request_info *info,
7955 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07007956{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307957 hdd_adapter_t *pAdapter;
7958 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08007959 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 tSirHostOffloadReq offloadRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307961 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007962
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307963 ENTER();
7964
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307965 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7966 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007967 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7969 "%s: Adapter is NULL",__func__);
7970 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007971 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307972 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7973 ret = wlan_hdd_validate_context(pHddCtx);
7974 if (0 != ret)
7975 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05307976 return ret;
7977 }
7978
Jeff Johnson295189b2012-06-20 16:38:30 -07007979 /* Debug display of request components. */
7980 switch (pRequest->offloadType)
7981 {
7982 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007983 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007984 switch (pRequest->enableOrDisable)
7985 {
7986 case WLAN_OFFLOAD_DISABLE:
7987 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
7988 break;
7989 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
7990 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
7991 case WLAN_OFFLOAD_ENABLE:
7992 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
7993 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
7994 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
7995 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
7996 }
7997 break;
7998
7999 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08008000 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008001 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008002 switch (pRequest->enableOrDisable)
8003 {
8004 case WLAN_OFFLOAD_DISABLE:
8005 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
8006 break;
8007 case WLAN_OFFLOAD_ENABLE:
8008 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
8009 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
8010 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
8011 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
8012 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
8013 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
8014 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
8015 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
8016 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
8017 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
8018 }
8019 }
8020
8021 /* Execute offload request. The reason that we can copy the request information
8022 from the ioctl structure to the SME structure is that they are laid out
8023 exactly the same. Otherwise, each piece of information would have to be
8024 copied individually. */
8025 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07008026 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8027 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008028 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008029 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07008030 __func__);
8031 return -EINVAL;
8032 }
8033
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308034 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008035 return 0;
8036}
8037
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308038static int iw_set_host_offload(struct net_device *dev,
8039 struct iw_request_info *info,
8040 union iwreq_data *wrqu, char *extra)
8041{
8042 int ret;
8043
8044 vos_ssr_protect(__func__);
8045 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8046 vos_ssr_unprotect(__func__);
8047
8048 return ret;
8049}
8050
8051static int __iw_set_keepalive_params(struct net_device *dev,
8052 struct iw_request_info *info,
8053 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008054{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308055 hdd_adapter_t *pAdapter;
8056 hdd_context_t *pHddCtx;
Arif Hussain7adce1b2013-11-11 22:59:34 -08008057 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07008058 tSirKeepAliveReq keepaliveRequest;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308059 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008060
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308061 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308062 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8063 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8066 "%s: Adapter is NULL",__func__);
8067 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008068 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308069 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8070 ret = wlan_hdd_validate_context(pHddCtx);
8071 if (0 != ret)
8072 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308073 return ret;
8074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08008076 hddLog(VOS_TRACE_LEVEL_INFO,
8077 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
8078 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07008079
8080 switch (pRequest->packetType)
8081 {
8082 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008083 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008084 break;
8085
8086 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
8087
Arif Hussain6d2a3322013-11-17 19:50:10 -08008088 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008089 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008090
8091 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
8092 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
8093 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
8094
8095 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
8096 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
8097 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
8098
8099 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
8100 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
8101 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
8102 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
8103 break;
8104
8105 }
8106
8107 /* Execute keep alive request. The reason that we can copy the request information
8108 from the ioctl structure to the SME structure is that they are laid out
8109 exactly the same. Otherwise, each piece of information would have to be
8110 copied individually. */
8111 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
8112
Arif Hussain6d2a3322013-11-17 19:50:10 -08008113 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07008114
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008115 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07008116 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008118 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 __func__);
8120 return -EINVAL;
8121 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308122 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008123 return 0;
8124}
8125
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308126static int iw_set_keepalive_params(struct net_device *dev,
8127 struct iw_request_info *info,
8128 union iwreq_data *wrqu, char *extra)
8129{
8130 int ret;
8131 vos_ssr_protect(__func__);
8132 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8133 vos_ssr_unprotect(__func__);
8134
8135 return ret;
8136}
8137
Jeff Johnson295189b2012-06-20 16:38:30 -07008138#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008139int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07008140 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008141{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07008142 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8143 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 int i=0;
8145
8146 if (pHddCtx->cfg_ini->disablePacketFilter)
8147 {
8148 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008149 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008150 return 0;
8151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 /* Debug display of request components. */
8153 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008154 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07008155
8156 switch (pRequest->filterAction)
8157 {
8158 case HDD_RCV_FILTER_SET:
8159 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008160 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008161
8162 packetFilterSetReq.filterId = pRequest->filterId;
8163 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
8164 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008165 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 __func__, pRequest->numParams);
8167 return -EINVAL;
8168 }
8169 packetFilterSetReq.numFieldParams = pRequest->numParams;
8170 packetFilterSetReq.coalesceTime = 0;
8171 packetFilterSetReq.filterType = 1;
8172 for (i=0; i < pRequest->numParams; i++)
8173 {
8174 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
8175 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
8176 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
8177 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
8178 packetFilterSetReq.paramsData[i].reserved = 0;
8179
Arif Hussain6d2a3322013-11-17 19:50:10 -08008180 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008181 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
8182 packetFilterSetReq.filterType);
8183
Arif Hussain6d2a3322013-11-17 19:50:10 -08008184 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
8186
8187 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8188 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
8189 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8190 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
8191
Arif Hussain6d2a3322013-11-17 19:50:10 -08008192 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008193 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
8194 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
8195 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
8196
Arif Hussain6d2a3322013-11-17 19:50:10 -08008197 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
8199 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
8200 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
8201 }
8202
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008203 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008204 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008205 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008206 __func__);
8207 return -EINVAL;
8208 }
8209
8210 break;
8211
8212 case HDD_RCV_FILTER_CLEAR:
8213
Arif Hussain6d2a3322013-11-17 19:50:10 -08008214 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008215 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07008217 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008219 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 __func__);
8221 return -EINVAL;
8222 }
8223 break;
8224
8225 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008226 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008227 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 return -EINVAL;
8229 }
8230 return 0;
8231}
8232
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05308233int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
8234 tANI_U8 sessionId)
8235{
8236 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8237 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8238
8239 if (NULL == pHddCtx)
8240 {
8241 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
8242 return -EINVAL;
8243 }
8244
8245 if (pHddCtx->isLogpInProgress)
8246 {
8247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8248 "%s:LOGP in Progress. Ignore!!!", __func__);
8249 return -EBUSY;
8250 }
8251
8252 if (pHddCtx->cfg_ini->disablePacketFilter)
8253 {
8254 hddLog(VOS_TRACE_LEVEL_ERROR,
8255 "%s: Packet Filtering Disabled. Returning ",
8256 __func__ );
8257 return -EINVAL;
8258 }
8259
8260 switch (filterType)
8261 {
8262 /* For setting IPV6 MC and UC Filter we need to configure
8263 * 2 filters, one for MC and one for UC.
8264 * The Filter ID shouldn't be swapped, which results in making
8265 * UC Filter ineffective.
8266 * We have Hardcode all the values
8267 *
8268 * Reason for a seperate UC filter is because, driver need to
8269 * specify the FW that the specific filter is for unicast
8270 * otherwise FW will not pass the unicast frames by default
8271 * through the filter. This is required to avoid any performance
8272 * hits when no unicast filter is set and only MC/BC are set.
8273 * The way driver informs host is by using the MAC protocol
8274 * layer, CMP flag set to MAX, CMP Data set to 1.
8275 */
8276
8277 case HDD_FILTER_IPV6_MC_UC:
8278 /* Setting IPV6 MC Filter below
8279 */
8280 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8281 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8282 packetFilterSetReq.numFieldParams = 2;
8283 packetFilterSetReq.paramsData[0].protocolLayer =
8284 HDD_FILTER_PROTO_TYPE_MAC;
8285 packetFilterSetReq.paramsData[0].cmpFlag =
8286 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8287 packetFilterSetReq.paramsData[0].dataOffset =
8288 WLAN_HDD_80211_FRM_DA_OFFSET;
8289 packetFilterSetReq.paramsData[0].dataLength = 1;
8290 packetFilterSetReq.paramsData[0].compareData[0] =
8291 HDD_IPV6_MC_CMP_DATA;
8292
8293 packetFilterSetReq.paramsData[1].protocolLayer =
8294 HDD_FILTER_PROTO_TYPE_ARP;
8295 packetFilterSetReq.paramsData[1].cmpFlag =
8296 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8297 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8298 packetFilterSetReq.paramsData[1].dataLength = 2;
8299 packetFilterSetReq.paramsData[1].compareData[0] =
8300 HDD_IPV6_CMP_DATA_0;
8301 packetFilterSetReq.paramsData[1].compareData[1] =
8302 HDD_IPV6_CMP_DATA_1;
8303
8304
8305 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8306 &packetFilterSetReq, sessionId))
8307 {
8308 hddLog(VOS_TRACE_LEVEL_ERROR,
8309 "%s: Failure to execute Set IPv6 Mulicast Filter",
8310 __func__);
8311 return -EINVAL;
8312 }
8313
8314 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
8315
8316 /*
8317 * Setting IPV6 UC Filter below
8318 */
8319 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8320 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
8321 packetFilterSetReq.numFieldParams = 2;
8322 packetFilterSetReq.paramsData[0].protocolLayer =
8323 HDD_FILTER_PROTO_TYPE_MAC;
8324 packetFilterSetReq.paramsData[0].cmpFlag =
8325 HDD_FILTER_CMP_TYPE_MAX;
8326 packetFilterSetReq.paramsData[0].dataOffset = 0;
8327 packetFilterSetReq.paramsData[0].dataLength = 1;
8328 packetFilterSetReq.paramsData[0].compareData[0] =
8329 HDD_IPV6_UC_CMP_DATA;
8330
8331 packetFilterSetReq.paramsData[1].protocolLayer =
8332 HDD_FILTER_PROTO_TYPE_ARP;
8333 packetFilterSetReq.paramsData[1].cmpFlag =
8334 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8335 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8336 packetFilterSetReq.paramsData[1].dataLength = 2;
8337 packetFilterSetReq.paramsData[1].compareData[0] =
8338 HDD_IPV6_CMP_DATA_0;
8339 packetFilterSetReq.paramsData[1].compareData[1] =
8340 HDD_IPV6_CMP_DATA_1;
8341
8342 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8343 &packetFilterSetReq, sessionId))
8344 {
8345 hddLog(VOS_TRACE_LEVEL_ERROR,
8346 "%s: Failure to execute Set IPv6 Unicast Filter",
8347 __func__);
8348 return -EINVAL;
8349 }
8350
8351 break;
8352
8353 case HDD_FILTER_IPV6_MC:
8354 /*
8355 * IPV6 UC Filter might be already set,
8356 * clear the UC Filter. As the Filter
8357 * IDs are static, we can directly clear it.
8358 */
8359 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8360 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
8361 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
8362 &packetFilterClrReq, sessionId))
8363 {
8364 hddLog(VOS_TRACE_LEVEL_ERROR,
8365 "%s: Failure to execute Clear IPv6 Unicast Filter",
8366 __func__);
8367 return -EINVAL;
8368 }
8369
8370 /*
8371 * Setting IPV6 MC Filter below
8372 */
8373 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
8374 packetFilterSetReq.numFieldParams = 2;
8375 packetFilterSetReq.paramsData[0].protocolLayer =
8376 HDD_FILTER_PROTO_TYPE_MAC;
8377 packetFilterSetReq.paramsData[0].cmpFlag =
8378 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8379 packetFilterSetReq.paramsData[0].dataOffset =
8380 WLAN_HDD_80211_FRM_DA_OFFSET;
8381 packetFilterSetReq.paramsData[0].dataLength = 1;
8382 packetFilterSetReq.paramsData[0].compareData[0] =
8383 HDD_IPV6_MC_CMP_DATA;
8384
8385 packetFilterSetReq.paramsData[1].protocolLayer =
8386 HDD_FILTER_PROTO_TYPE_ARP;
8387 packetFilterSetReq.paramsData[1].cmpFlag =
8388 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
8389 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
8390 packetFilterSetReq.paramsData[1].dataLength = 2;
8391 packetFilterSetReq.paramsData[1].compareData[0] =
8392 HDD_IPV6_CMP_DATA_0;
8393 packetFilterSetReq.paramsData[1].compareData[1] =
8394 HDD_IPV6_CMP_DATA_1;
8395
8396
8397 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
8398 &packetFilterSetReq, sessionId))
8399 {
8400 hddLog(VOS_TRACE_LEVEL_ERROR,
8401 "%s: Failure to execute Set IPv6 Multicast Filter",
8402 __func__);
8403 return -EINVAL;
8404 }
8405 break;
8406
8407 default :
8408 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8409 "%s: Packet Filter Request: Invalid",
8410 __func__);
8411 return -EINVAL;
8412 }
8413 return 0;
8414}
8415
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308416void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07008417{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05308418 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308419 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07008420 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308421 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008422
Yue Ma3ede6052013-08-29 00:33:26 -07008423 if (NULL == pHddCtx)
8424 {
8425 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
8426 return;
8427 }
8428
8429 hHal = pHddCtx->hHal;
8430
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308431 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308433 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
8434 return;
8435 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308436
8437 /* Check if INI is enabled or not, other wise just return
8438 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308439 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308440 {
8441 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
8442 if (NULL == pMulticastAddrs)
8443 {
8444 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
8445 return;
8446 }
8447
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 if (set)
8449 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308450 /* Following pre-conditions should be satisfied before wei
8451 * configure the MC address list.
8452 */
8453 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
8454 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
8455 && pAdapter->mc_addr_list.mc_cnt
8456 && (eConnectionState_Associated ==
8457 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8458 {
8459 pMulticastAddrs->ulMulticastAddrCnt =
8460 pAdapter->mc_addr_list.mc_cnt;
8461 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
8462 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008463 memcpy(pMulticastAddrs->multicastAddr[i],
8464 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308465 sizeof(pAdapter->mc_addr_list.addr[i]));
8466 hddLog(VOS_TRACE_LEVEL_INFO,
8467 "%s: %s multicast filter: addr ="
8468 MAC_ADDRESS_STR,
8469 __func__, set ? "setting" : "clearing",
8470 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
8471 }
8472 /* Set multicast filter */
8473 sme_8023MulticastList(hHal, pAdapter->sessionId,
8474 pMulticastAddrs);
8475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308477 else
8478 {
8479 /* Need to clear only if it was previously configured
8480 */
8481 if (pAdapter->mc_addr_list.isFilterApplied)
8482 {
8483 pMulticastAddrs->ulMulticastAddrCnt = 0;
8484 sme_8023MulticastList(hHal, pAdapter->sessionId,
8485 pMulticastAddrs);
8486 }
8487
8488 }
8489 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07008490 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07008491 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308492 else
8493 {
8494 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05308495 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308496 }
8497 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008498}
8499
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308500static int __iw_set_packet_filter_params(struct net_device *dev,
8501 struct iw_request_info *info,
8502 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05308503{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308504 hdd_adapter_t *pAdapter;
8505 hdd_context_t *pHddCtx;
Arif Hussain0273cba2014-01-07 20:58:29 -08008506 tpPacketFilterCfg pRequest = NULL;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308507 int ret = 0;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308508 struct iw_point s_priv_data;
8509
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308510 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308511 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8512 if (NULL == pAdapter)
8513 {
8514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8515 "%s: Adapter is NULL",__func__);
8516 return -EINVAL;
8517 }
8518 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8519 ret = wlan_hdd_validate_context(pHddCtx);
8520 if (0 != ret)
8521 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308522 return ret;
8523 }
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308524 if (hdd_priv_get_data(&s_priv_data, wrqu))
8525 {
8526 return -EINVAL;
8527 }
8528
8529 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
8530 {
8531 return -EINVAL;
8532 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008533
Arif Hussain0273cba2014-01-07 20:58:29 -08008534 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05308535 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8536 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08008537 if (NULL == pRequest)
8538 {
8539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8540 "mem_alloc_copy_from_user_helper fail");
8541 return -ENOMEM;
8542 }
8543
8544 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
8545 kfree(pRequest);
8546
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308547 EXIT();
Arif Hussain0273cba2014-01-07 20:58:29 -08008548 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008549}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308550
8551static int iw_set_packet_filter_params(struct net_device *dev,
8552 struct iw_request_info *info,
8553 union iwreq_data *wrqu, char *extra)
8554{
8555 int ret;
8556
8557 vos_ssr_protect(__func__);
8558 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
8559 vos_ssr_unprotect(__func__);
8560
8561 return ret;
8562}
Jeff Johnson295189b2012-06-20 16:38:30 -07008563#endif
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308564static int __iw_get_statistics(struct net_device *dev,
8565 struct iw_request_info *info,
8566 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07008567{
8568
8569 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
8570 eHalStatus status = eHAL_STATUS_SUCCESS;
8571 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308572 hdd_adapter_t *pAdapter;
8573 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008574 char *p = extra;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308575 int tlen = 0, ret = 0;
8576 tCsrSummaryStatsInfo *pStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008577
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308578 tCsrGlobalClassAStatsInfo *aStats;
8579 tCsrGlobalClassDStatsInfo *dStats;
Jeff Johnson295189b2012-06-20 16:38:30 -07008580
8581 ENTER();
8582
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308583 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8584 if (NULL == pAdapter)
8585 {
8586 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8587 "%s: Adapter is NULL",__func__);
8588 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008589 }
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308590 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8591 ret = wlan_hdd_validate_context(pHddCtx);
8592 if (0 != ret)
8593 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308594 return ret;
8595 }
8596 pStats = &(pAdapter->hdd_stats.summary_stat);
8597 aStats = &(pAdapter->hdd_stats.ClassA_stat);
8598 dStats = &(pAdapter->hdd_stats.ClassD_stat);
Jeff Johnson295189b2012-06-20 16:38:30 -07008599 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
8600
8601 wrqu->txpower.value = 0;
8602 }
8603 else {
8604 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8605 SME_SUMMARY_STATS |
8606 SME_GLOBAL_CLASSA_STATS |
8607 SME_GLOBAL_CLASSB_STATS |
8608 SME_GLOBAL_CLASSC_STATS |
8609 SME_GLOBAL_CLASSD_STATS |
8610 SME_PER_STA_STATS,
8611 hdd_StatisticsCB, 0, FALSE,
8612 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8613
8614 if (eHAL_STATUS_SUCCESS != status)
8615 {
8616 hddLog(VOS_TRACE_LEVEL_ERROR,
8617 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008618 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 return -EINVAL;
8620 }
8621
8622 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05308623 if (NULL == pWextState)
8624 {
8625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8626 "%s: pWextState is NULL",__func__);
8627 return -EINVAL;
8628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008629
8630 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
8631 if (!VOS_IS_STATUS_SUCCESS(vos_status))
8632 {
8633 hddLog(VOS_TRACE_LEVEL_ERROR,
8634 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008635 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 /*Remove the SME statistics list by passing NULL in callback argument*/
8637 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
8638 SME_SUMMARY_STATS |
8639 SME_GLOBAL_CLASSA_STATS |
8640 SME_GLOBAL_CLASSB_STATS |
8641 SME_GLOBAL_CLASSC_STATS |
8642 SME_GLOBAL_CLASSD_STATS |
8643 SME_PER_STA_STATS,
8644 NULL, 0, FALSE,
8645 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
8646
8647 return -EINVAL;
8648 }
8649 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
8650 (tANI_U8) sizeof (pStats->retry_cnt),
8651 (char*) &(pStats->retry_cnt[0]),
8652 tlen);
8653
8654 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
8655 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
8656 (char*) &(pStats->multiple_retry_cnt[0]),
8657 tlen);
8658
8659 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
8660 (tANI_U8) sizeof (pStats->tx_frm_cnt),
8661 (char*) &(pStats->tx_frm_cnt[0]),
8662 tlen);
8663
8664 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
8665 (tANI_U8) sizeof (pStats->rx_frm_cnt),
8666 (char*) &(pStats->rx_frm_cnt),
8667 tlen);
8668
8669 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
8670 (tANI_U8) sizeof (pStats->frm_dup_cnt),
8671 (char*) &(pStats->frm_dup_cnt),
8672 tlen);
8673
8674 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
8675 (tANI_U8) sizeof (pStats->fail_cnt),
8676 (char*) &(pStats->fail_cnt[0]),
8677 tlen);
8678
8679 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
8680 (tANI_U8) sizeof (pStats->rts_fail_cnt),
8681 (char*) &(pStats->rts_fail_cnt),
8682 tlen);
8683
8684 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
8685 (tANI_U8) sizeof (pStats->ack_fail_cnt),
8686 (char*) &(pStats->ack_fail_cnt),
8687 tlen);
8688
8689 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
8690 (tANI_U8) sizeof (pStats->rts_succ_cnt),
8691 (char*) &(pStats->rts_succ_cnt),
8692 tlen);
8693
8694 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
8695 (tANI_U8) sizeof (pStats->rx_discard_cnt),
8696 (char*) &(pStats->rx_discard_cnt),
8697 tlen);
8698
8699 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
8700 (tANI_U8) sizeof (pStats->rx_error_cnt),
8701 (char*) &(pStats->rx_error_cnt),
8702 tlen);
8703
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008704 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07008705 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008706 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 tlen);
8708
8709 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
8710 (tANI_U8) sizeof (dStats->rx_byte_cnt),
8711 (char*) &(dStats->rx_byte_cnt),
8712 tlen);
8713
8714 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
8715 (tANI_U8) sizeof (dStats->rx_rate),
8716 (char*) &(dStats->rx_rate),
8717 tlen);
8718
8719 /* Transmit rate, in units of 500 kbit/sec */
8720 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
8721 (tANI_U8) sizeof (aStats->tx_rate),
8722 (char*) &(aStats->tx_rate),
8723 tlen);
8724
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008725 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
8726 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
8727 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008728 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008729 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
8730 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
8731 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008732 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008733 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
8734 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
8735 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008736 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008737 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
8738 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
8739 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07008740 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008741 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
8742 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
8743 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008744 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08008745 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
8746 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
8747 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07008748 tlen);
8749
Jeff Johnson295189b2012-06-20 16:38:30 -07008750 wrqu->data.length = tlen;
8751
8752 }
8753
8754 EXIT();
8755
8756 return 0;
8757}
8758
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308759static int iw_get_statistics(struct net_device *dev,
8760 struct iw_request_info *info,
8761 union iwreq_data *wrqu, char *extra)
8762{
8763 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008764
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05308765 vos_ssr_protect(__func__);
8766 ret = __iw_get_statistics(dev, info, wrqu, extra);
8767 vos_ssr_unprotect(__func__);
8768
8769 return ret;
8770}
Jeff Johnson295189b2012-06-20 16:38:30 -07008771#ifdef FEATURE_WLAN_SCAN_PNO
8772
8773/*Max Len for PNO notification*/
8774#define MAX_PNO_NOTIFY_LEN 100
8775void found_pref_network_cb (void *callbackContext,
8776 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8777{
8778 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
8779 union iwreq_data wrqu;
8780 char buf[MAX_PNO_NOTIFY_LEN+1];
8781
8782 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
8783 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
8784
8785 // create the event
8786 memset(&wrqu, 0, sizeof(wrqu));
8787 memset(buf, 0, sizeof(buf));
8788
8789 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
8790 pPrefNetworkFoundInd->ssId.ssId,
8791 (unsigned int)pPrefNetworkFoundInd->rssi);
8792
8793 wrqu.data.pointer = buf;
8794 wrqu.data.length = strlen(buf);
8795
8796 // send the event
8797
8798 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
8799
8800}
8801
8802
8803/*string based input*/
8804VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
8805 union iwreq_data *wrqu, char *extra, int nOffset)
8806{
8807 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05308808 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07008809 /* pnoRequest is a large struct, so we make it static to avoid stack
8810 overflow. This API is only invoked via ioctl, so it is
8811 serialized by the kernel rtnl_lock and hence does not need to be
8812 reentrant */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308813 tSirPNOScanReq pnoRequest = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07008814 char *ptr;
8815 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05308816 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008817 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8818
8819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8820 "PNO data len %d data %s",
8821 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08008822 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07008823
8824 if (wrqu->data.length <= nOffset )
8825 {
8826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
8827 return VOS_STATUS_E_FAILURE;
8828 }
8829
8830 pnoRequest.enable = 0;
8831 pnoRequest.ucNetworksCount = 0;
8832 /*-----------------------------------------------------------------------
8833 Input is string based and expected to be like this:
8834
8835 <enabled> <netw_count>
8836 for each network:
8837 <ssid_len> <ssid> <authentication> <encryption>
8838 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8839 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
8840
8841 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07008842 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 -07008843
8844 this translates into:
8845 -----------------------------
8846 enable PNO
8847 look for 2 networks:
8848 test - with authentication type 0 and encryption type 0,
8849 that can be found on 3 channels: 1 6 and 11 ,
8850 SSID bcast type is unknown (directed probe will be sent if AP not found)
8851 and must meet -40dBm RSSI
8852
8853 test2 - with auth and enrytption type 4/4
8854 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
8855 bcast type is non-bcast (directed probe will be sent)
8856 and must not meet any RSSI threshold
8857
Jeff Johnson8301aa12013-03-28 14:27:29 -07008858 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07008859 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08008860 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07008861
Wilson Yang623f6592013-10-08 16:33:37 -07008862 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
8863 {
8864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8865 "PNO enable input is not valid %s",ptr);
8866 return VOS_STATUS_E_FAILURE;
8867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008868
8869 if ( 0 == pnoRequest.enable )
8870 {
8871 /*Disable PNO*/
8872 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05308873 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
8874 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 pAdapter->sessionId,
8876 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05308877 if (eHAL_STATUS_SUCCESS != status)
8878 {
8879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8880 "%s: failed to disable PNO", __func__);
8881 return VOS_STATUS_E_FAILURE;
8882 }
8883 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 return VOS_STATUS_SUCCESS;
8885 }
8886
c_hpothu37f21312014-04-09 21:49:54 +05308887 if (TRUE == pHddCtx->isPnoEnable)
8888 {
8889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8890 FL("already PNO is enabled"));
8891 return -EBUSY;
8892 }
8893 pHddCtx->isPnoEnable = TRUE;
8894
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07008896
8897 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
8898 {
8899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8900 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308901 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008903
8904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8905 "PNO enable %d networks count %d offset %d",
8906 pnoRequest.enable,
8907 pnoRequest.ucNetworksCount,
8908 nOffset);
8909
8910 /* Parameters checking:
8911 ucNetworksCount has to be larger than 0*/
8912 if (( 0 == pnoRequest.ucNetworksCount ) ||
8913 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
8914 {
8915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05308916 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 }
8918
8919 ptr += nOffset;
8920
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05308921 pnoRequest.aNetworks =
8922 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8923 if (pnoRequest.aNetworks == NULL)
8924 {
8925 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8926 FL("failed to allocate memory aNetworks %u"),
8927 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8928 goto error;
8929 }
8930 vos_mem_zero(pnoRequest.aNetworks,
8931 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
8932
Jeff Johnson295189b2012-06-20 16:38:30 -07008933 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
8934 {
8935
8936 pnoRequest.aNetworks[i].ssId.length = 0;
8937
Wilson Yang623f6592013-10-08 16:33:37 -07008938 ucParams = sscanf(ptr,"%hhu %n",
8939 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
8940
8941 if (1 != ucParams)
8942 {
8943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8944 "PNO ssid length input is not valid %s",ptr);
8945 return VOS_STATUS_E_FAILURE;
8946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008947
8948 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
8949 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
8950 {
8951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8952 "SSID Len %d is not correct for network %d",
8953 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05308954 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07008955 }
8956
8957 /*Advance to SSID*/
8958 ptr += nOffset;
8959
Jeff Johnson8301aa12013-03-28 14:27:29 -07008960 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08008961 pnoRequest.aNetworks[i].ssId.length);
8962 ptr += pnoRequest.aNetworks[i].ssId.length;
8963
Jeff Johnson02797792013-10-26 19:17:13 -07008964 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08008965 &(pnoRequest.aNetworks[i].authentication),
8966 &(pnoRequest.aNetworks[i].encryption),
8967 &(pnoRequest.aNetworks[i].ucChannelCount),
8968 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07008969
Wilson Yang623f6592013-10-08 16:33:37 -07008970 if ( 3 != ucParams )
8971 {
8972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8973 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05308974 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07008975 }
8976
Jeff Johnson295189b2012-06-20 16:38:30 -07008977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008978 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08008979 "auth %d encry %d channel count %d offset %d",
8980 pnoRequest.aNetworks[i].ssId.length,
8981 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
8982 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
8983 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
8984 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
8985 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
8986 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
8987 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
8988 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
8989 pnoRequest.aNetworks[i].authentication,
8990 pnoRequest.aNetworks[i].encryption,
8991 pnoRequest.aNetworks[i].ucChannelCount,
8992 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07008993
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 /*Advance to channel list*/
8995 ptr += nOffset;
8996
Wilson Yang623f6592013-10-08 16:33:37 -07008997 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07008998 {
8999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9000 "Incorrect number of channels");
9001 return VOS_STATUS_E_FAILURE;
9002 }
9003
9004 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
9005 {
9006 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
9007 {
Wilson Yang623f6592013-10-08 16:33:37 -07009008 if (1 != sscanf(ptr,"%hhu %n",
9009 &(pnoRequest.aNetworks[i].aChannels[j]),
9010 &nOffset))
9011 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9012 "PNO network channel input is not valid %s",ptr);
9013 return VOS_STATUS_E_FAILURE;
9014 }
9015 /*Advance to next channel number*/
9016 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009017 }
9018 }
9019
Jeff Johnson02797792013-10-26 19:17:13 -07009020 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009021 &(pnoRequest.aNetworks[i].bcastNetwType),
9022 &nOffset))
9023 {
9024 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9025 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309026 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009028
9029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9030 "PNO bcastNetwType %d offset %d",
9031 pnoRequest.aNetworks[i].bcastNetwType,
9032 nOffset );
9033
9034 /*Advance to rssi Threshold*/
9035 ptr += nOffset;
9036
Wilson Yang623f6592013-10-08 16:33:37 -07009037 if (1 != sscanf(ptr,"%hhu %n",
9038 &(pnoRequest.aNetworks[i].rssiThreshold),
9039 &nOffset))
9040 {
9041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9042 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05309043 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009045
9046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9047 "PNO rssi %d offset %d",
9048 pnoRequest.aNetworks[i].rssiThreshold,
9049 nOffset );
9050 /*Advance to next network*/
9051 ptr += nOffset;
9052 }/*For ucNetworkCount*/
9053
9054 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07009055 &(pnoRequest.scanTimers.ucScanTimersCount),
9056 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009057
9058 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07009059 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 {
9061 ptr += nOffset;
9062
Jeff Johnson8301aa12013-03-28 14:27:29 -07009063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9064 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009065 pnoRequest.scanTimers.ucScanTimersCount,
9066 nOffset );
9067
9068 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
9069 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05309072 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07009073 }
9074
9075 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
9076 {
Jeff Johnson02797792013-10-26 19:17:13 -07009077 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
9079 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
9080 &nOffset);
9081
Wilson Yang623f6592013-10-08 16:33:37 -07009082 if (2 != ucParams)
9083 {
9084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9085 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05309086 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07009087 }
9088
Jeff Johnson8301aa12013-03-28 14:27:29 -07009089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9090 "PNO Timer value %d Timer repeat %d offset %d",
9091 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
9093 nOffset );
9094
Jeff Johnson295189b2012-06-20 16:38:30 -07009095 ptr += nOffset;
9096 }
9097
9098 }
9099 else
9100 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07009101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9102 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
9104
9105 /*Scan timers defaults to 5 minutes*/
9106 pnoRequest.scanTimers.ucScanTimersCount = 1;
9107 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
9108 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
9109 }
9110
Wilson Yang623f6592013-10-08 16:33:37 -07009111 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07009112
9113 pnoRequest.modePNO = ucMode;
9114 /*for LA we just expose suspend option*/
9115 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
9116 {
9117 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9118 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309119 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9120 if (pnoRequest.p24GProbeTemplate == NULL){
9121 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9122 FL("failed to allocate memory p24GProbeTemplate %u"),
9123 SIR_PNO_MAX_PB_REQ_SIZE);
9124 goto error;
9125 }
9126
9127 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
9128 if (pnoRequest.p5GProbeTemplate == NULL){
9129 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9130 FL("failed to allocate memory p5GProbeTemplate %u"),
9131 SIR_PNO_MAX_PB_REQ_SIZE);
9132 goto error;
9133 }
9134
9135 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
9136 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009137
c_hpothu37f21312014-04-09 21:49:54 +05309138 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 pAdapter->sessionId,
9140 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05309141 if (eHAL_STATUS_SUCCESS == status)
9142 {
9143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9144 "%s: PNO enabled", __func__);
9145 return VOS_STATUS_SUCCESS;
9146 }
9147error:
9148 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9149 "%s: Failed to enable PNO", __func__);
9150 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +05309151 if (pnoRequest.aNetworks)
9152 vos_mem_free(pnoRequest.aNetworks);
9153 if (pnoRequest.p24GProbeTemplate)
9154 vos_mem_free(pnoRequest.p24GProbeTemplate);
9155 if (pnoRequest.p5GProbeTemplate)
9156 vos_mem_free(pnoRequest.p5GProbeTemplate);
c_hpothu37f21312014-04-09 21:49:54 +05309157 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009158}/*iw_set_pno*/
9159
9160VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
9161 union iwreq_data *wrqu, char *extra, int nOffset)
9162{
9163 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9164 v_U8_t rssiThreshold = 0;
9165 v_U8_t nRead;
9166
Arif Hussain7adce1b2013-11-11 22:59:34 -08009167 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07009168 &rssiThreshold);
9169
9170 if ( 1 != nRead )
9171 {
9172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9173 "Incorrect format");
9174 return VOS_STATUS_E_FAILURE;
9175 }
9176
9177 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
9178 return VOS_STATUS_SUCCESS;
9179}
9180
9181
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309182static int __iw_set_pno_priv(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 struct iw_request_info *info,
9184 union iwreq_data *wrqu, char *extra)
9185{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309186 hdd_adapter_t *pAdapter;
9187 hdd_context_t *pHddCtx;
9188 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309189 VOS_STATUS status;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309190
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309191 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309192 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9193 if (NULL == pAdapter)
9194 {
9195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9196 "%s: Adapter is NULL",__func__);
9197 return -EINVAL;
9198 }
9199
9200 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9201 ret = wlan_hdd_validate_context(pHddCtx);
9202 if (0 != ret)
9203 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309204 return ret;
9205 }
9206
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009207
9208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009209 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08009210
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309211 status = iw_set_pno(dev,info,wrqu,extra,0);
9212
9213 EXIT();
9214 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009215}
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309216
9217static int iw_set_pno_priv(struct net_device *dev,
9218 struct iw_request_info *info,
9219 union iwreq_data *wrqu, char *extra)
9220{
9221 int ret;
9222
9223 vos_ssr_protect(__func__);
9224 ret = __iw_set_pno_priv(dev, info, wrqu, extra);
9225 vos_ssr_unprotect(__func__);
9226
9227 return ret;
9228}
Jeff Johnson295189b2012-06-20 16:38:30 -07009229#endif /*FEATURE_WLAN_SCAN_PNO*/
9230
9231//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05309232int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009233{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309234 hdd_adapter_t *pAdapter;
9235 tHalHandle hHal;
9236 hdd_context_t *pHddCtx;
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309237 hdd_scaninfo_t *pScanInfo = NULL;
Atul Mittal54378cb2014-04-02 16:51:50 +05309238 eCsrBand band;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309239 int wait_result;
Jeff Johnson295189b2012-06-20 16:38:30 -07009240 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309241 eCsrBand connectedBand;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309242 v_U8_t ret = SEND_CHANNEL_CHANGE_EVENT;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309243 tpAniSirGlobal pMac;
9244 int retval = 0;
9245
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309246 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309247 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9248 if (NULL == pAdapter)
9249 {
9250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9251 "%s: Adapter is NULL",__func__);
9252 return -EINVAL;
9253 }
9254 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9255 retval = wlan_hdd_validate_context(pHddCtx);
9256 if (0 != retval)
9257 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309258 return retval;
9259 }
9260 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9261 if (NULL == hHal)
9262 {
9263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9264 "%s: Hal Context is NULL",__func__);
9265 return -EINVAL;
9266 }
9267 pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07009268
Atul Mittal54378cb2014-04-02 16:51:50 +05309269 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07009270 {
9271 case WLAN_HDD_UI_BAND_AUTO:
9272 band = eCSR_BAND_ALL;
9273 break;
9274 case WLAN_HDD_UI_BAND_5_GHZ:
9275 band = eCSR_BAND_5G;
9276 break;
9277 case WLAN_HDD_UI_BAND_2_4_GHZ:
9278 band = eCSR_BAND_24;
9279 break;
9280 default:
9281 band = eCSR_BAND_MAX;
9282 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309283 connectedBand =
9284 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07009285
Atul Mittal54378cb2014-04-02 16:51:50 +05309286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009287 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009288
9289 if (band == eCSR_BAND_MAX)
9290 {
9291 /* Received change band request with invalid band value */
9292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05309293 "%s: Invalid band value %u", __func__, ui_band);
9294 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009295 }
9296
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309297 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
Sushant Kaushik1165f872015-03-30 20:25:27 +05309298 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) )
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05309299 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009301 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009302 band, pHddCtx->cfg_ini->nBandCapability);
9303 return -EIO;
9304 }
9305
Sushant Kaushik1165f872015-03-30 20:25:27 +05309306 if (band == eCSR_BAND_ALL)
9307 {
9308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, FL("Auto Band "
9309 "received. Setting band same as ini value %d"),
9310 pHddCtx->cfg_ini->nBandCapability);
9311 band = pHddCtx->cfg_ini->nBandCapability;
9312 }
9313
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
9315 {
9316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9317 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009318 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009319 return -EIO;
9320 }
9321
9322 if (currBand != band)
9323 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309324 if ( band == eCSR_BAND_5G )
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309325 {
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309326 /* Return failure if current country code is world regulatory domain*/
9327 if( (pMac->scan.countryCodeCurrent[0] == '0' &&
9328 pMac->scan.countryCodeCurrent[1] == '0') )
9329 {
9330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9331 "%s: failed to set the band value to %u as country code is 00",
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309332 __func__, band);
Deepthi Gowri00ed0b92015-01-21 16:04:47 +05309333 return -EAGAIN;
9334 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309335 }
9336
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 /* Change band request received.
9338 * Abort pending scan requests, flush the existing scan results,
9339 * and change the band capability
9340 */
9341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9342 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009343 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009344
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309345 /* We need to change the band and flush the scan results here itself
9346 * as we may get timeout for disconnection in which we will return
9347 * with out doing any of these
9348 */
9349 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
9350 {
9351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9352 "%s: failed to set the band value to %u ",
9353 __func__, band);
9354 return -EINVAL;
9355 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309356 if(currBand == eCSR_BAND_24 || currBand == eCSR_BAND_5G)
9357 {
Sachin Ahuja120bf632015-02-24 18:06:34 +05309358 tANI_U8 curr_country[WNI_CFG_COUNTRY_CODE_LEN];
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309359 curr_country[0]=pMac->scan.countryCodeCurrent[0];
9360 curr_country[1]=pMac->scan.countryCodeCurrent[1];
Sachin Ahuja120bf632015-02-24 18:06:34 +05309361 INIT_COMPLETION(pHddCtx->linux_reg_req);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309362 /* As currunt band is already set to 2.4Ghz/5Ghz we dont have all channel
9363 * information available in NV so to get the channel information from kernel
9364 * we need to send regulatory hint for the currunt country
9365 * And to set the same country again we need to set the dummy country
9366 * first and then the actual country.
9367 */
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309368#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9369 regulatory_hint_user("00", NL80211_USER_REG_HINT_USER);
9370#else
9371 regulatory_hint_user("00");
9372#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309373 wait_result = wait_for_completion_interruptible_timeout(
9374 &pHddCtx->linux_reg_req,
9375 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9376
9377 /* if the country information does not exist with the kernel,
9378 then the driver callback would not be called */
9379
9380 if (wait_result >= 0)
9381 {
9382 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9383 "runtime country code is found in kernel db");
9384 }
9385 else
9386 {
9387 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9388 "runtime country code is not found"
9389 " in kernel db");
9390 }
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309391
9392 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_TRUE;
Sachin Ahuja120bf632015-02-24 18:06:34 +05309393
9394 /*
9395 * Update 11dcountry and current country here as the hint
9396 * with 00 results in 11d and current country with 00
9397 */
9398 vos_mem_copy(pMac->scan.countryCode11d, curr_country,
9399 WNI_CFG_COUNTRY_CODE_LEN);
9400 vos_mem_copy(pMac->scan.countryCodeCurrent, curr_country,
9401 WNI_CFG_COUNTRY_CODE_LEN);
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309402#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9403 regulatory_hint_user(curr_country, NL80211_USER_REG_HINT_USER);
9404#else
9405 regulatory_hint_user(curr_country);
9406#endif
Sachin Ahuja120bf632015-02-24 18:06:34 +05309407 wait_result = wait_for_completion_interruptible_timeout(
9408 &pHddCtx->linux_reg_req,
9409 msecs_to_jiffies(LINUX_REG_WAIT_TIME));
9410
9411 /* if the country information does not exist with the kernel,
9412 then the driver callback would not be called */
9413 if (wait_result >= 0)
9414 {
9415 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9416 "runtime country code is found in kernel db");
9417 }
9418 else
9419 {
9420 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
9421 "runtime country code is not found"
9422 " in kernel db");
9423 }
9424
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309425 ret = DO_NOT_SEND_CHANNEL_CHANGE_EVENT;
9426 }
9427 else
9428 {
Abhishek Singh678227a2014-11-04 10:52:38 +05309429#ifdef CONFIG_ENABLE_LINUX_REG
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309430 vos_update_nv_table_from_wiphy_band((void *)pHddCtx,
9431 (void *)pHddCtx->wiphy, (eCsrBand)band);
Abhishek Singh678227a2014-11-04 10:52:38 +05309432#else
9433 wlan_hdd_cfg80211_update_band( pHddCtx->wiphy, (eCsrBand)band );
9434#endif
9435
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309436 }
Kaushik, Sushant4975a572014-10-21 16:07:48 +05309437 pScanInfo = &pHddCtx->scan_info;
9438 if ((pScanInfo != NULL) && pHddCtx->scan_info.mScanPending)
9439 {
9440 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
9441 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9442 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05309443 sme_FilterScanResults(hHal, pAdapter->sessionId);
9444
9445 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05309446 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
9447 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07009448 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009449 eHalStatus status = eHAL_STATUS_SUCCESS;
9450 long lrc;
9451
9452 /* STA already connected on current band, So issue disconnect first,
9453 * then change the band*/
9454
9455 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05309456 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
Agarwal Ashish2496e872014-10-01 19:04:29 +05309457 , __func__, csrGetCurrentBand(hHal), band);
Jeff Johnson295189b2012-06-20 16:38:30 -07009458
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9460
9461 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
9462 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
9463
Jeff Johnson43971f52012-07-17 12:26:56 -07009464 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 {
9466 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009467 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009468 __func__, (int)status );
9469 return -EINVAL;
9470 }
9471
9472 lrc = wait_for_completion_interruptible_timeout(
9473 &pAdapter->disconnect_comp_var,
9474 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
9475
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05309476 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07009477
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07009478 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009479 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07009480
9481 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
9482 }
9483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009484 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309485 EXIT();
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05309486 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009487}
9488
Atul Mittal54378cb2014-04-02 16:51:50 +05309489int hdd_setBand_helper(struct net_device *dev, const char *command)
9490{
9491 u8 band;
9492
9493 /*convert the band value from ascii to integer*/
9494 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
9495
9496 return hdd_setBand(dev, band);
9497
9498}
9499
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309500static int __iw_set_band_config(struct net_device *dev,
9501 struct iw_request_info *info,
9502 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009503{
Atul Mittal54378cb2014-04-02 16:51:50 +05309504 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07009505
Arif Hussain0273cba2014-01-07 20:58:29 -08009506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009507
Atul Mittal54378cb2014-04-02 16:51:50 +05309508 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009509}
9510
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309511static int iw_set_band_config(struct net_device *dev,
9512 struct iw_request_info *info,
9513 union iwreq_data *wrqu, char *extra)
9514{
9515 int ret;
9516
9517 vos_ssr_protect(__func__);
9518 ret = __iw_set_band_config(dev, info, wrqu, extra);
9519 vos_ssr_unprotect(__func__);
9520
9521 return ret;
9522}
9523
9524static int __iw_set_power_params_priv(struct net_device *dev,
9525 struct iw_request_info *info,
9526 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07009527{
Arif Hussain0273cba2014-01-07 20:58:29 -08009528 int ret;
9529 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9531 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08009532 /* ODD number is used for set, copy data using copy_from_user */
9533 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
9534 wrqu->data.length);
9535 if (NULL == ptr)
9536 {
9537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9538 "mem_alloc_copy_from_user_helper fail");
9539 return -ENOMEM;
9540 }
9541
9542 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
9543 kfree(ptr);
9544 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009545}
9546
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309547static int iw_set_power_params_priv(struct net_device *dev,
9548 struct iw_request_info *info,
9549 union iwreq_data *wrqu, char *extra)
9550{
9551 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07009552
Mahesh A Saptasagar97a9f812014-08-13 13:15:05 +05309553 vos_ssr_protect(__func__);
9554 ret = __iw_set_power_params_priv(dev, info, wrqu, extra);
9555 vos_ssr_unprotect(__func__);
9556
9557 return ret;
9558}
Jeff Johnson295189b2012-06-20 16:38:30 -07009559
9560/*string based input*/
9561VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
9562 union iwreq_data *wrqu, char *extra, int nOffset)
9563{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309564 hdd_adapter_t *pAdapter;
9565 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 tSirSetPowerParamsReq powerRequest;
9567 char *ptr;
9568 v_U8_t ucType;
9569 v_U32_t uTotalSize, uValue;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309570 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009571
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309572 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309573 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9574 if (NULL == pAdapter)
9575 {
9576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9577 "%s: Adapter is NULL",__func__);
9578 return -EINVAL;
9579 }
9580
9581 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9582 ret = wlan_hdd_validate_context(pHddCtx);
9583 if (0 != ret)
9584 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05309585 return ret;
9586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9588 "Power Params data len %d data %s",
9589 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08009590 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07009591
9592 if (wrqu->data.length <= nOffset )
9593 {
9594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
9595 return VOS_STATUS_E_FAILURE;
9596 }
9597
9598 uTotalSize = wrqu->data.length - nOffset;
9599
9600 /*-----------------------------------------------------------------------
9601 Input is string based and expected to be like this:
9602
9603 <param_type> <param_value> <param_type> <param_value> ...
9604
9605 e.g:
9606 1 2 2 3 3 0 4 1 5 1
9607
9608 e.g. setting just a few:
9609 1 2 4 1
9610
9611 parameter types:
9612 -----------------------------
9613 1 - Ignore DTIM
9614 2 - Listen Interval
9615 3 - Broadcast Multicas Filter
9616 4 - Beacon Early Termination
9617 5 - Beacon Early Termination Interval
9618 -----------------------------------------------------------------------*/
9619 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
9620 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
9621 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
9622 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
9623 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
9624
Arif Hussain7adce1b2013-11-11 22:59:34 -08009625 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07009626
9627 while ( uTotalSize )
9628 {
Wilson Yang6f971452013-10-08 15:00:00 -07009629 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
9630 {
9631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9632 "Invalid input parameter type %s",ptr);
9633 return VOS_STATUS_E_FAILURE;
9634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009635
9636 uTotalSize -= nOffset;
9637
9638 if (!uTotalSize)
9639 {
9640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009641 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 ucType, nOffset);
9643 return VOS_STATUS_E_FAILURE;
9644 }
9645
9646 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07009647
Jeff Johnson02797792013-10-26 19:17:13 -07009648 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07009649 {
9650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9651 "Invalid input parameter value %s",ptr);
9652 return VOS_STATUS_E_FAILURE;
9653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009654
9655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9656 "Power request parameter %d value %d offset %d",
9657 ucType, uValue, nOffset);
9658
9659 switch (ucType)
9660 {
9661 case eSIR_IGNORE_DTIM:
9662 powerRequest.uIgnoreDTIM = uValue;
9663 break;
9664 case eSIR_LISTEN_INTERVAL:
9665 powerRequest.uListenInterval = uValue;
9666 break;
9667 case eSIR_MCAST_BCAST_FILTER:
9668 powerRequest.uBcastMcastFilter = uValue;
9669 break;
9670 case eSIR_ENABLE_BET:
9671 powerRequest.uEnableBET = uValue;
9672 break;
9673 case eSIR_BET_INTERVAL:
9674 powerRequest.uBETInterval = uValue;
9675 break;
9676 default:
9677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08009678 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009679 ucType, uValue, nOffset);
9680 return VOS_STATUS_E_FAILURE;
9681 }
9682
9683 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9685 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07009686 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07009688 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08009689 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07009690 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
9691 {
9692 uTotalSize = 0;
9693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009694
9695 }/*Go for as long as we have a valid string*/
9696
9697 /* put the device into full power*/
9698 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
9699
9700 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08009701 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009702
9703 /* put the device back to power save*/
9704 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
9705
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309706 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009707 return VOS_STATUS_SUCCESS;
9708}/*iw_set_power_params*/
9709
Atul Mittalc0f739f2014-07-31 13:47:47 +05309710// tdlsoffchan
9711#ifdef FEATURE_WLAN_TDLS
9712
Atul Mittal87ec2422014-09-24 13:12:50 +05309713int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309714{
9715 if (offchannel < 0 || offchannel > 165)
9716 {
9717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
9718 __func__, offchannel);
9719 return -1;
9720
9721 }
9722
9723 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
9724 __func__, tdlsOffCh, offchannel);
9725
9726 tdlsOffCh = offchannel;
9727 return 0;
9728}
9729
Atul Mittal87ec2422014-09-24 13:12:50 +05309730int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309731{
9732 if (offchanoffset == 0)
9733 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309734 tdlsOffChBwOffset = 1;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9736 __func__, tdlsOffChBwOffset);
9737
9738 return 0;
9739
9740 }
9741
9742 if ( offchanoffset == 40 )
9743 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309744 tdlsOffChBwOffset = 2;
Atul Mittalc0f739f2014-07-31 13:47:47 +05309745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9746 __func__, tdlsOffChBwOffset);
9747
9748 return 0;
9749
9750 }
9751 if (offchanoffset == -40)
9752 {
9753 tdlsOffChBwOffset = 3;
9754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
9755 __func__, tdlsOffChBwOffset);
9756
9757 return 0;
9758
9759 }
Pradeep Reddy POTTETI91566c92015-03-25 14:05:22 +05309760
9761 if ((offchanoffset == 80) &&
9762 (TRUE == sme_IsFeatureSupportedByFW(DOT11AC)) &&
9763 (TRUE == sme_IsFeatureSupportedByDriver(DOT11AC)))
9764 {
9765 tdlsOffChBwOffset = 4;
9766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9767 "%s: change tdls secondary off channel offset to %u",
9768 __func__, tdlsOffChBwOffset);
9769
9770 return 0;
9771 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05309772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
9773 __func__, offchanoffset);
9774 return -1;
9775}
9776
Atul Mittal87ec2422014-09-24 13:12:50 +05309777int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
Atul Mittalc0f739f2014-07-31 13:47:47 +05309778{
9779 hddTdlsPeer_t *connPeer = NULL;
9780 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9781 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9782
9783 if (offchanmode < 0 || offchanmode > 4)
9784 {
9785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9786 "%s: Invalid tdls off channel mode %d",
9787 __func__, offchanmode);
9788 return -1;
9789 }
9790
9791 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9792 {
9793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9794 "%s: tdls off channel mode req in not associated state %d",
9795 __func__, offchanmode);
9796 return -1;
9797 }
9798
9799 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
9800 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
9801 {
9802 /* Send TDLS Channel Switch Request to connected peer */
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05309803 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Atul Mittalc0f739f2014-07-31 13:47:47 +05309804 if (NULL == connPeer) {
9805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9806 "%s: No TDLS Connected Peer", __func__);
9807 return -1;
9808 }
9809 }
9810 else
9811 {
9812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9813 "%s: TDLS Connection not supported", __func__);
9814 return -1;
9815 }
9816
9817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9818 ("%s: TDLS Channel Switch in swmode=%d"),
9819 __func__, offchanmode);
9820
9821 switch (offchanmode)
9822 {
9823 case 1:/*Enable*/
9824 case 2:/*Disable*/
9825 {
9826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9827 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
9828 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9829 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
9830 {
9831
9832 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
9833 pAdapter->sessionId, connPeer->peerMac,
9834 tdlsOffCh, tdlsOffChBwOffset,
9835 offchanmode);
9836 }
9837 else
9838 {
9839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9840 "%s: TDLS Off Channel not supported", __func__);
9841 return -1;
9842 }
9843 break;
9844 }
9845 case 3:
9846 {
9847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9848 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
9849 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9850
9851 break;
9852 }
9853 case 4:
9854 {
9855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9856 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
9857 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9858 break;
9859 }
9860 default:
9861 {
9862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9863 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
9864 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
9865 break;
9866 }
9867
9868 }
9869
9870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
9871 __func__, offchanmode);
9872 return 0;
9873}
Atul Mittalc0f739f2014-07-31 13:47:47 +05309874#endif
9875
Jeff Johnson295189b2012-06-20 16:38:30 -07009876
9877// Define the Wireless Extensions to the Linux Network Device structure
9878// A number of these routines are NULL (meaning they are not implemented.)
9879
9880static const iw_handler we_handler[] =
9881{
9882 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9883 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9884 (iw_handler) NULL, /* SIOCSIWNWID */
9885 (iw_handler) NULL, /* SIOCGIWNWID */
9886 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9887 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9888 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9889 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9890 (iw_handler) NULL, /* SIOCSIWSENS */
9891 (iw_handler) NULL, /* SIOCGIWSENS */
9892 (iw_handler) NULL, /* SIOCSIWRANGE */
9893 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9894 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
9895 (iw_handler) NULL, /* SIOCGIWPRIV */
9896 (iw_handler) NULL, /* SIOCSIWSTATS */
9897 (iw_handler) NULL, /* SIOCGIWSTATS */
9898 iw_handler_set_spy, /* SIOCSIWSPY */
9899 iw_handler_get_spy, /* SIOCGIWSPY */
9900 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
9901 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
9902 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9903 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9904 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9905 (iw_handler) NULL, /* SIOCGIWAPLIST */
9906 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9907 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9908 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9909 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9910 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9911 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9912 (iw_handler) NULL, /* -- hole -- */
9913 (iw_handler) NULL, /* -- hole -- */
9914 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9915 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9916 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
9917 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
9918 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9919 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9920 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9921 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9922 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9923 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9924 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9925 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9926 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9927 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9928 (iw_handler) NULL, /* -- hole -- */
9929 (iw_handler) NULL, /* -- hole -- */
9930 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9931 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9932 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9933 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9934 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9935 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9936 (iw_handler) NULL, /* SIOCSIWPMKSA */
9937};
9938
9939static const iw_handler we_private[] = {
9940
9941 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
9942 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
9943 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
9944 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
9945 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9946 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
Girish Gowlifb9758e2014-11-19 15:19:17 +05309947 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_hdd_set_var_ints_getnone,
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9949 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9950 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07009951#ifdef FEATURE_OEM_DATA_SUPPORT
9952 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
9953 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
9954#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009955
Jeff Johnson295189b2012-06-20 16:38:30 -07009956#ifdef WLAN_FEATURE_VOWIFI_11R
9957 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
9958#endif
9959 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9960 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9961 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
9962#ifdef WLAN_FEATURE_PACKET_FILTERING
9963 ,
9964 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
9965#endif
9966#ifdef FEATURE_WLAN_SCAN_PNO
9967 ,
9968 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
9969#endif
9970 ,
9971 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9972 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
9973 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
9974 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07009975 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07009976};
9977
9978/*Maximum command length can be only 15 */
9979static const struct iw_priv_args we_private_args[] = {
9980
9981 /* handlers for main ioctl */
9982 { WLAN_PRIV_SET_INT_GET_NONE,
9983 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9984 0,
9985 "" },
9986
9987 /* handlers for sub-ioctl */
9988 { WE_SET_11D_STATE,
9989 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9990 0,
9991 "set11Dstate" },
9992
9993 { WE_WOWL,
9994 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9995 0,
9996 "wowl" },
9997
9998 { WE_SET_POWER,
9999 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10000 0,
10001 "setPower" },
10002
10003 { WE_SET_MAX_ASSOC,
10004 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10005 0,
10006 "setMaxAssoc" },
10007
10008 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10009 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10010 0,
10011 "setAutoChannel" },
10012
10013 { WE_SET_DATA_INACTIVITY_TO,
10014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10015 0,
10016 "inactivityTO" },
10017
10018 { WE_SET_MAX_TX_POWER,
10019 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10020 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -070010021 "setMaxTxPower" },
10022
10023 { WE_SET_MAX_TX_POWER_2_4,
10024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10025 0,
10026 "setTxMaxPower2G" },
10027
10028 { WE_SET_MAX_TX_POWER_5_0,
10029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10030 0,
10031 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -070010032
10033 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10034 * as well to keep same syntax as in SAP. Now onwards, STA
10035 * will support both */
10036 { WE_SET_MAX_TX_POWER,
10037 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10038 0,
10039 "setTxMaxPower" },
10040
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10042 * 1 = enable and 0 = disable */
10043 {
10044 WE_SET_HIGHER_DTIM_TRANSITION,
10045 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10046 0,
10047 "setHDtimTransn" },
10048
10049 { WE_SET_TM_LEVEL,
10050 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080010051 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010052 "setTmLevel" },
10053
Kiet Lam46b8e4e2013-11-06 21:49:53 +053010054 { WE_ENABLE_STRICT_FCC_REG,
10055 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10056 0,
10057 "setStrictFCCreg" },
10058
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010059 { WE_SET_DEBUG_LOG,
10060 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10061 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +053010062#ifdef FEATURE_WLAN_TDLS
10063 {
10064 WE_SET_TDLS_OFF_CHAN,
10065 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10066 0,
10067 "tdlsoffchan" },
10068 {
10069 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
10070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10071 0,
10072 "tdlsecchnoffst" },
10073 {
10074 WE_SET_TDLS_OFF_CHAN_MODE,
10075 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10076 0,
10077 "tdlsoffchnmode" },
10078#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -080010079
Peng Xu2446a892014-09-05 17:21:18 +053010080 { WE_SET_SCAN_BAND_PREFERENCE,
10081 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10082 0, "set_scan_pref" },
Siddharth Bhal678a9342015-02-27 01:12:56 +053010083 {
10084 WE_GET_FRAME_LOG,
10085 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10086 0,
10087 "getFrameLogs" },
Peng Xu2446a892014-09-05 17:21:18 +053010088
Abhishek Singh01c73d12015-03-12 15:13:44 +053010089 { WE_SET_MIRACAST_VENDOR_CONFIG,
10090 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10091 0, "setMiracstConf" },
10092
Jeff Johnson295189b2012-06-20 16:38:30 -070010093 /* handlers for main ioctl */
10094 { WLAN_PRIV_SET_NONE_GET_INT,
10095 0,
10096 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10097 "" },
10098
10099 /* handlers for sub-ioctl */
10100 { WE_GET_11D_STATE,
10101 0,
10102 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10103 "get11Dstate" },
10104
10105 { WE_IBSS_STATUS,
10106 0,
10107 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10108 "getAdhocStatus" },
10109
10110 { WE_PMC_STATE,
10111 0,
10112 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10113 "pmcState" },
10114
10115 { WE_GET_WLAN_DBG,
10116 0,
10117 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10118 "getwlandbg" },
10119
Jeff Johnson295189b2012-06-20 16:38:30 -070010120 { WE_GET_MAX_ASSOC,
10121 0,
10122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10123 "getMaxAssoc" },
10124
Jeff Johnson295189b2012-06-20 16:38:30 -070010125 { WE_GET_WDI_DBG,
10126 0,
10127 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10128 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010129
10130 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10131 0,
10132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10133 "getAutoChannel" },
10134
10135 { WE_GET_CONCURRENCY_MODE,
10136 0,
10137 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10138 "getconcurrency" },
10139
Peng Xu2446a892014-09-05 17:21:18 +053010140 { WE_GET_SCAN_BAND_PREFERENCE,
10141 0,
10142 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10143 "get_scan_pref"},
10144
Jeff Johnson295189b2012-06-20 16:38:30 -070010145 /* handlers for main ioctl */
10146 { WLAN_PRIV_SET_CHAR_GET_NONE,
10147 IW_PRIV_TYPE_CHAR| 512,
10148 0,
10149 "" },
10150
10151 /* handlers for sub-ioctl */
10152 { WE_WOWL_ADD_PTRN,
10153 IW_PRIV_TYPE_CHAR| 512,
10154 0,
10155 "wowlAddPtrn" },
10156
10157 { WE_WOWL_DEL_PTRN,
10158 IW_PRIV_TYPE_CHAR| 512,
10159 0,
10160 "wowlDelPtrn" },
10161
10162#if defined WLAN_FEATURE_VOWIFI
10163 /* handlers for sub-ioctl */
10164 { WE_NEIGHBOR_REPORT_REQUEST,
10165 IW_PRIV_TYPE_CHAR | 512,
10166 0,
10167 "neighbor" },
10168#endif
10169 { WE_SET_AP_WPS_IE,
10170 IW_PRIV_TYPE_CHAR| 512,
10171 0,
10172 "set_ap_wps_ie" },
10173
10174 { WE_SET_CONFIG,
10175 IW_PRIV_TYPE_CHAR| 512,
10176 0,
10177 "setConfig" },
10178
Srinivas Dasarib8fdd422014-11-27 10:44:20 +053010179 { WE_SET_ENCRYPT_MSG,
10180 IW_PRIV_TYPE_CHAR| 512,
10181 0,
10182 "encryptMsg" },
10183
10184
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 /* handlers for main ioctl */
10186 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
10187 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10188 0,
10189 "" },
10190
10191 /* handlers for sub-ioctl */
10192 { WE_SET_WLAN_DBG,
10193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10194 0,
10195 "setwlandbg" },
10196
Jeff Johnson295189b2012-06-20 16:38:30 -070010197 { WE_SET_WDI_DBG,
10198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10199 0,
10200 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010201
10202 { WE_SET_SAP_CHANNELS,
10203 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10204 0,
10205 "setsapchannels" },
10206
10207 /* handlers for main ioctl */
10208 { WLAN_PRIV_GET_CHAR_SET_NONE,
10209 0,
10210 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10211 "" },
10212
10213 /* handlers for sub-ioctl */
10214 { WE_WLAN_VERSION,
10215 0,
10216 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10217 "version" },
10218 { WE_GET_STATS,
10219 0,
10220 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10221 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010222 { WE_GET_STATES,
10223 0,
10224 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10225 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 { WE_GET_CFG,
10227 0,
10228 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10229 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -070010230#ifdef WLAN_FEATURE_11AC
10231 { WE_GET_RSSI,
10232 0,
10233 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10234 "getRSSI" },
10235#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010236#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010237 { WE_GET_ROAM_RSSI,
10238 0,
10239 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10240 "getRoamRSSI" },
10241#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010242 { WE_GET_WMM_STATUS,
10243 0,
10244 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10245 "getWmmStatus" },
10246 {
10247 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053010248 0,
Jeff Johnson295189b2012-06-20 16:38:30 -070010249 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10250 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -080010251#ifdef FEATURE_WLAN_TDLS
10252 {
10253 WE_GET_TDLS_PEERS,
10254 0,
10255 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10256 "getTdlsPeers" },
10257#endif
Chet Lanctot186b5732013-03-18 10:26:30 -070010258#ifdef WLAN_FEATURE_11W
10259 {
10260 WE_GET_11W_INFO,
10261 0,
10262 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10263 "getPMFInfo" },
10264#endif
Girish Gowlidab72f12014-09-04 15:34:43 +053010265 { WE_GET_SNR,
10266 0,
10267 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10268 "getSNR" },
10269
Jeff Johnson295189b2012-06-20 16:38:30 -070010270 /* handlers for main ioctl */
10271 { WLAN_PRIV_SET_NONE_GET_NONE,
10272 0,
10273 0,
10274 "" },
10275
10276 /* handlers for sub-ioctl */
10277 { WE_CLEAR_STATS,
10278 0,
10279 0,
10280 "clearStats" },
10281 { WE_INIT_AP,
10282 0,
10283 0,
10284 "initAP" },
10285 { WE_STOP_AP,
10286 0,
10287 0,
10288 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010289#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -070010290 { WE_ENABLE_AMP,
10291 0,
10292 0,
10293 "enableAMP" },
10294 { WE_DISABLE_AMP,
10295 0,
10296 0,
10297 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +053010298#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -070010299 { WE_ENABLE_DXE_STALL_DETECT,
10300 0,
10301 0,
10302 "dxeStallDetect" },
10303 { WE_DISPLAY_DXE_SNAP_SHOT,
10304 0,
10305 0,
10306 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053010307 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
10308 0,
10309 0,
10310 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -070010311 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +053010312 WE_SET_REASSOC_TRIGGER,
10313 0,
10314 0,
10315 "reassoc" },
10316 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +053010317 WE_STOP_OBSS_SCAN,
10318 0,
10319 0,
10320 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +053010321 {
10322 WE_DUMP_ROAM_TIMER_LOG,
10323 0,
10324 0,
10325 "dumpRoamDelay" },
10326 {
10327 WE_RESET_ROAM_TIMER_LOG,
10328 0,
10329 0,
10330 "resetRoamDelay" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010331 /* handlers for main ioctl */
10332 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
10333 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10334 0,
10335 "" },
10336
10337 /* handlers for sub-ioctl */
10338 { WE_LOG_DUMP_CMD,
10339 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10340 0,
10341 "dump" },
10342
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010343 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +053010344 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10345 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10346 0,
10347 "setdumplog" },
10348
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -070010349 { WE_MTRACE_DUMP_CMD,
10350 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10351 0,
10352 "dumplog" },
10353
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010354 /* handlers for sub ioctl */
10355 {
10356 WE_MCC_CONFIG_CREDENTIAL,
10357 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10358 0,
10359 "setMccCrdnl" },
10360
10361 /* handlers for sub ioctl */
10362 {
10363 WE_MCC_CONFIG_PARAMS,
10364 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10365 0,
10366 "setMccConfig" },
10367
Chilam NG571c65a2013-01-19 12:27:36 +053010368#ifdef FEATURE_WLAN_TDLS
10369 /* handlers for sub ioctl */
10370 {
10371 WE_TDLS_CONFIG_PARAMS,
10372 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10373 0,
10374 "setTdlsConfig" },
10375#endif
10376
Jeff Johnson295189b2012-06-20 16:38:30 -070010377 /* handlers for main ioctl */
10378 { WLAN_PRIV_ADD_TSPEC,
10379 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
10380 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10381 "addTspec" },
10382
10383 /* handlers for main ioctl */
10384 { WLAN_PRIV_DEL_TSPEC,
10385 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10386 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10387 "delTspec" },
10388
10389 /* handlers for main ioctl */
10390 { WLAN_PRIV_GET_TSPEC,
10391 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10392 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10393 "getTspec" },
10394
Jeff Johnsone7245742012-09-05 17:12:55 -070010395#ifdef FEATURE_OEM_DATA_SUPPORT
10396 /* handlers for main ioctl - OEM DATA */
10397 {
10398 WLAN_PRIV_SET_OEM_DATA_REQ,
10399 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
10400 0,
10401 "set_oem_data_req" },
10402
10403 /* handlers for main ioctl - OEM DATA */
10404 {
10405 WLAN_PRIV_GET_OEM_DATA_RSP,
10406 0,
10407 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
10408 "get_oem_data_rsp" },
10409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010410
Jeff Johnson295189b2012-06-20 16:38:30 -070010411 /* handlers for main ioctl - host offload */
10412 {
10413 WLAN_PRIV_SET_HOST_OFFLOAD,
10414 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
10415 0,
10416 "setHostOffload" },
10417
10418 {
10419 WLAN_GET_WLAN_STATISTICS,
10420 0,
10421 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
10422 "getWlanStats" },
10423
10424 {
10425 WLAN_SET_KEEPALIVE_PARAMS,
10426 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
10427 0,
10428 "setKeepAlive" },
10429#ifdef WLAN_FEATURE_PACKET_FILTERING
10430 {
10431 WLAN_SET_PACKET_FILTER_PARAMS,
10432 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
10433 0,
10434 "setPktFilter" },
10435#endif
10436#ifdef FEATURE_WLAN_SCAN_PNO
10437 {
10438 WLAN_SET_PNO,
10439 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10440 0,
10441 "setpno" },
10442#endif
10443 {
10444 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +053010445 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -070010446 0,
10447 "SETBAND" },
10448 /* handlers for dynamic MC BC ioctl */
10449 {
10450 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -080010451 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -070010452 0,
10453 "setMCBCFilter" },
10454 {
10455 WLAN_PRIV_CLEAR_MCBC_FILTER,
10456 0,
10457 0,
10458 "clearMCBCFilter" },
10459 {
10460 WLAN_SET_POWER_PARAMS,
10461 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
10462 0,
10463 "setpowerparams" },
10464 {
10465 WLAN_GET_LINK_SPEED,
10466 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053010467 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -070010468};
10469
10470
10471
10472const struct iw_handler_def we_handler_def = {
10473 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
10474 .num_private = sizeof(we_private) / sizeof(we_private[0]),
10475 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
10476
10477 .standard = (iw_handler *)we_handler,
10478 .private = (iw_handler *)we_private,
10479 .private_args = we_private_args,
10480 .get_wireless_stats = get_wireless_stats,
10481};
10482
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010483int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
10484{
10485 v_U32_t cmd = 288; //Command to RIVA
10486 hdd_context_t *pHddCtx = NULL;
10487 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10488 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10489 /*
10490 *configMccParam : specify the bit which needs to be modified
10491 *allowed to update based on wlan_qcom_cfg.ini
10492 * configuration
10493 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
10494 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
10495 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
10496 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
10497 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
10498 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
10499 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
10500 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
10501 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
10502 * Bit 9 : Reserved
10503 */
10504 switch (arg1)
10505 {
10506 //Update MCC SCHEDULE_TIME_SLICE parameter
10507 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
10508 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
10509 {
10510 if((arg2 >= 5) && (arg2 <= 20))
10511 {
10512 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10513 }
10514 else
10515 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010516 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010517 return 0;
10518 }
10519 }
10520 break;
10521
10522 //Update MCC MAX_NULL_SEND_TIME parameter
10523 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
10524 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
10525 {
10526 if((arg2 >= 1) && (arg2 <= 10))
10527 {
10528 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10529 }
10530 else
10531 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010532 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010533 return 0;
10534 }
10535 }
10536 break;
10537
10538 //Update MCC TX_EARLY_STOP_TIME parameter
10539 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
10540 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
10541 {
10542 if((arg2 >= 1) && (arg2 <= 10))
10543 {
10544 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10545 }
10546 else
10547 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010548 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010549 return 0;
10550 }
10551 }
10552 break;
10553
10554 //Update MCC RX_DRAIN_TIME parameter
10555 case MCC_RX_DRAIN_TIME_CFG_PARAM :
10556 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
10557 {
10558 if((arg2 >= 1) && (arg2 <= 10))
10559 {
10560 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10561 }
10562 else
10563 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010564 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010565 return 0;
10566 }
10567 }
10568 break;
10569
10570 //Update MCC CHANNEL_SWITCH_TIME parameter
10571 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
10572 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
10573 {
10574 if((arg2 >= 1) && (arg2 <= 20))
10575 {
10576 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10577 }
10578 else
10579 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010580 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010581 return 0;
10582 }
10583 }
10584 break;
10585
10586 //Update MCC MIN_CHANNEL_TIME parameter
10587 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
10588 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
10589 {
10590 if((arg2 >= 5) && (arg2 <= 20))
10591 {
10592 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10593 }
10594 else
10595 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010596 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010597 return 0;
10598 }
10599 }
10600 break;
10601
10602 //Update MCC PARK_BEFORE_TBTT parameter
10603 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
10604 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
10605 {
10606 if((arg2 >= 1) && (arg2 <= 5))
10607 {
10608 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10609 }
10610 else
10611 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010612 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010613 return 0;
10614 }
10615 }
10616 break;
10617
10618 //Update MCC MIN_AFTER_DTIM parameter
10619 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
10620 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
10621 {
10622 if((arg2 >= 5) && (arg2 <= 15))
10623 {
10624 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10625 }
10626 else
10627 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010628 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010629 return 0;
10630 }
10631 }
10632 break;
10633
10634 //Update MCC TOO_CLOSE_MARGIN parameter
10635 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
10636 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
10637 {
10638 if((arg2 >= 1) && (arg2 <= 3))
10639 {
10640 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
10641 }
10642 else
10643 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010644 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010645 return 0;
10646 }
10647 }
10648 break;
10649
10650 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -080010651 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -080010652 __FUNCTION__,arg1);
10653 break;
10654 }
10655 return 0;
10656}
10657
Jeff Johnson295189b2012-06-20 16:38:30 -070010658int hdd_set_wext(hdd_adapter_t *pAdapter)
10659{
10660 hdd_wext_state_t *pwextBuf;
10661 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010662 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010663
10664 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10665
10666 // Now configure the roaming profile links. To SSID and bssid.
10667 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
10668 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
10669
10670 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
10671 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
10672
10673 /*Set the numOfChannels to zero to scan all the channels*/
10674 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
10675 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
10676
10677 /* Default is no encryption */
10678 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
10679 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10680
10681 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
10682 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
10683
10684 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
10685
10686 /* Default is no authentication */
10687 pwextBuf->roamProfile.AuthType.numEntries = 1;
10688 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
10689
10690 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
10691 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
10692
10693 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010694 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010695
10696 hdd_clearRoamProfileIe(pAdapter);
10697
10698 return VOS_STATUS_SUCCESS;
10699
10700 }
10701
10702int hdd_register_wext(struct net_device *dev)
10703 {
10704 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10705 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10706 VOS_STATUS status;
10707
10708 ENTER();
10709
10710 // Zero the memory. This zeros the profile structure.
10711 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
10712
10713 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
10714
10715
10716 status = hdd_set_wext(pAdapter);
10717
10718 if(!VOS_IS_STATUS_SUCCESS(status)) {
10719
Arif Hussain6d2a3322013-11-17 19:50:10 -080010720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 return eHAL_STATUS_FAILURE;
10722 }
10723
10724 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
10725 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010727 return eHAL_STATUS_FAILURE;
10728 }
10729
10730 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
10731 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010733 return eHAL_STATUS_FAILURE;
10734 }
10735
10736 // Register as a wireless device
10737 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
10738
10739 EXIT();
10740 return 0;
10741}
10742
10743int hdd_UnregisterWext(struct net_device *dev)
10744{
c_hpothu2a13bc32015-01-21 12:48:54 +053010745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"In %s %p", __func__, dev);
10746 if (dev != NULL)
10747 {
10748 rtnl_lock();
10749 dev->wireless_handlers = NULL;
10750 rtnl_unlock();
10751 }
c_hpothu5f0b6eb2014-09-15 13:36:50 +053010752
Jeff Johnson295189b2012-06-20 16:38:30 -070010753 return 0;
10754}
10755
10756