blob: 0fb765b86c0e403ed9e4c153c156afff94c5225a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
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"
85#include <vos_power.h>
86#include "wlan_hdd_host_offload.h"
87#include "wlan_hdd_keep_alive.h"
88#ifdef WLAN_FEATURE_PACKET_FILTERING
89#include "wlan_hdd_packet_filtering.h"
90#endif
91
Jeff Johnson295189b2012-06-20 16:38:30 -070092#include <linux/wireless.h>
93#include <net/cfg80211.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070094#include "wlan_qct_pal_trace.h"
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +053095#include "wlan_qct_tl.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070096
97#include "wlan_hdd_misc.h"
98#include "bap_hdd_misc.h"
99
100#include "wlan_hdd_dev_pwr.h"
101#include "qc_sap_ioctl.h"
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +0530102#include "sme_Api.h"
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700103#include "vos_trace.h"
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530104#include "wlan_hdd_assoc.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
Mukul Sharma84f27252014-07-14 18:11:42 +0530106#ifdef DEBUG_ROAM_DELAY
107#include "vos_utils.h"
108#endif
109
Jeff Johnson295189b2012-06-20 16:38:30 -0700110#ifdef CONFIG_HAS_EARLYSUSPEND
111extern void hdd_suspend_wlan(struct early_suspend *wlan_suspend);
112extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
113#endif
114
Jeff Johnsone7245742012-09-05 17:12:55 -0700115#ifdef FEATURE_OEM_DATA_SUPPORT
Madan Mohan Koyyalamudi7a4d9312012-12-04 17:21:36 -0800116#define MAX_OEM_DATA_RSP_LEN 2047
Jeff Johnsone7245742012-09-05 17:12:55 -0700117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700118
119#define HDD_FINISH_ULA_TIME_OUT 800
Sushant Kaushik10315f92014-04-29 11:30:25 +0530120#define COUNTRY_CODE_LEN 2
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700123
Atul Mittalc0f739f2014-07-31 13:47:47 +0530124// tdlsoffchan
125#ifdef FEATURE_WLAN_TDLS
126static int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel);
127static int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset);
128static int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode);
129static int tdlsOffCh = 1;
130static int tdlsOffChBwOffset = 0;
131#endif
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -0700132static int ioctl_debug;
Jeff Johnson295189b2012-06-20 16:38:30 -0700133module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
134
Jeff Johnson295189b2012-06-20 16:38:30 -0700135/* To Validate Channel against the Frequency and Vice-Versa */
136static const hdd_freq_chan_map_t freq_chan_map[] = { {2412, 1}, {2417, 2},
137 {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6}, {2442, 7}, {2447, 8},
138 {2452, 9}, {2457, 10}, {2462, 11}, {2467 ,12}, {2472, 13},
139 {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248}, {4980, 252},
140 {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36}, {5200, 40}, {5220, 44},
141 {5240, 48}, {5260, 52}, {5280, 56}, {5300, 60}, {5320, 64}, {5500, 100},
142 {5520, 104}, {5540, 108}, {5560, 112}, {5580, 116}, {5600, 120},
143 {5620, 124}, {5640, 128}, {5660, 132}, {5680, 136}, {5700, 140},
Manjunathappa Prakash009dcb42014-03-07 15:29:22 -0800144 {5720, 144}, {5745, 149}, {5765, 153}, {5785, 157}, {5805, 161},
145 {5825, 165} };
Jeff Johnson295189b2012-06-20 16:38:30 -0700146
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800147#define FREQ_CHAN_MAP_TABLE_SIZE (sizeof(freq_chan_map)/sizeof(freq_chan_map[0]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700148
149/* Private ioctls and their sub-ioctls */
150#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
151#define WE_SET_11D_STATE 1
152#define WE_WOWL 2
153#define WE_SET_POWER 3
154#define WE_SET_MAX_ASSOC 4
155#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 5
156#define WE_SET_DATA_INACTIVITY_TO 6
157#define WE_SET_MAX_TX_POWER 7
158#define WE_SET_HIGHER_DTIM_TRANSITION 8
159#define WE_SET_TM_LEVEL 9
Kiet Lam46b8e4e2013-11-06 21:49:53 +0530160#define WE_ENABLE_STRICT_FCC_REG 10
Arif Hussaina5ebce02013-08-09 15:09:58 -0700161#define WE_SET_MAX_TX_POWER_2_4 11
162#define WE_SET_MAX_TX_POWER_5_0 12
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -0800163/* Private IOCTL for debug connection issues */
164#define WE_SET_DEBUG_LOG 13
Atul Mittalc0f739f2014-07-31 13:47:47 +0530165// tdlsoffchan
166#ifdef FEATURE_WLAN_TDLS
167#define WE_SET_TDLS_OFF_CHAN 14
168#define WE_SET_TDLS_SEC_OFF_CHAN_OFFSET 15
169#define WE_SET_TDLS_OFF_CHAN_MODE 16
170#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700171
172/* Private ioctls and their sub-ioctls */
173#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
174#define WE_GET_11D_STATE 1
175#define WE_IBSS_STATUS 2
176#define WE_PMC_STATE 3
177#define WE_GET_WLAN_DBG 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700178#define WE_GET_MAX_ASSOC 6
179#define WE_GET_WDI_DBG 7
180#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
181#define WE_GET_CONCURRENCY_MODE 9
182/* Private ioctls and their sub-ioctls */
183#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
184
185/* Private ioctls and their sub-ioctls */
186#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
187#define WE_WOWL_ADD_PTRN 1
188#define WE_WOWL_DEL_PTRN 2
189#if defined WLAN_FEATURE_VOWIFI
190#define WE_NEIGHBOR_REPORT_REQUEST 3
191#endif
192#define WE_SET_AP_WPS_IE 4 //This is called in station mode to set probe rsp ie.
193#define WE_SET_CONFIG 5
194
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
Jeff Johnson295189b2012-06-20 16:38:30 -0700219
220/* Private ioctls and their sub-ioctls */
221#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
222#define WE_CLEAR_STATS 1
223#define WE_INIT_AP 2
224#define WE_STOP_AP 3
Girish Gowli345bff82014-06-09 20:05:24 +0530225#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -0700226#define WE_ENABLE_AMP 4
227#define WE_DISABLE_AMP 5
Girish Gowli345bff82014-06-09 20:05:24 +0530228#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -0700229#define WE_ENABLE_DXE_STALL_DETECT 6
230#define WE_DISPLAY_DXE_SNAP_SHOT 7
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -0700231#define WE_SET_REASSOC_TRIGGER 8
Sandeep Puligillaa3e76952014-06-23 15:53:11 +0530232#define WE_DISPLAY_DATAPATH_SNAP_SHOT 9
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +0530233#define WE_STOP_OBSS_SCAN 11
Jeff Johnson295189b2012-06-20 16:38:30 -0700234
Mukul Sharma84f27252014-07-14 18:11:42 +0530235#ifdef DEBUG_ROAM_DELAY
236#define WE_DUMP_ROAM_TIMER_LOG 12
237#define WE_RESET_ROAM_TIMER_LOG 13
238#endif
239
Jeff Johnson295189b2012-06-20 16:38:30 -0700240/* Private ioctls and their sub-ioctls */
241#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
242#define WE_LOG_DUMP_CMD 1
243
Jeff Johnson295189b2012-06-20 16:38:30 -0700244#define WE_P2P_NOA_CMD 2
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800245//IOCTL to configure MCC params
246#define WE_MCC_CONFIG_CREDENTIAL 3
247#define WE_MCC_CONFIG_PARAMS 4
Jeff Johnson295189b2012-06-20 16:38:30 -0700248
Chilam NG571c65a2013-01-19 12:27:36 +0530249#ifdef FEATURE_WLAN_TDLS
250#define WE_TDLS_CONFIG_PARAMS 5
251#endif
252
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700253#define WE_MTRACE_DUMP_CMD 8
Katya Nigamc2f29dc2014-01-20 19:29:30 +0530254#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -0700255
Chilam Ng01120412013-02-19 18:32:21 -0800256#ifdef FEATURE_WLAN_TDLS
257#undef MAX_VAR_ARGS
258#define MAX_VAR_ARGS 10
259#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700260#define MAX_VAR_ARGS 7
Chilam Ng01120412013-02-19 18:32:21 -0800261#endif
262
Jeff Johnson295189b2012-06-20 16:38:30 -0700263/* Private ioctls (with no sub-ioctls) */
264/* note that they must be odd so that they have "get" semantics */
265#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
266#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
267#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
268
Girish Gowli464c9c82014-06-09 19:47:53 +0530269/* (SIOCIWFIRSTPRIV + 8) is currently unused */
270/* (SIOCIWFIRSTPRIV + 16) is currently unused */
271/* (SIOCIWFIRSTPRIV + 10) is currently unused */
272/* (SIOCIWFIRSTPRIV + 12) is currently unused */
273/* (SIOCIWFIRSTPRIV + 14) is currently unused */
274/* (SIOCIWFIRSTPRIV + 15) is currently unused */
Jeff Johnson295189b2012-06-20 16:38:30 -0700275
Jeff Johnsone7245742012-09-05 17:12:55 -0700276#ifdef FEATURE_OEM_DATA_SUPPORT
277/* Private ioctls for setting the measurement configuration */
278#define WLAN_PRIV_SET_OEM_DATA_REQ (SIOCIWFIRSTPRIV + 17)
279#define WLAN_PRIV_GET_OEM_DATA_RSP (SIOCIWFIRSTPRIV + 19)
280#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700281
282#ifdef WLAN_FEATURE_VOWIFI_11R
283#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
284#endif
285
286/* Private ioctl for setting the host offload feature */
287#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
288
289/* Private ioctl to get the statistics */
290#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
291
292/* Private ioctl to set the Keep Alive Params */
293#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
294#ifdef WLAN_FEATURE_PACKET_FILTERING
295/* Private ioctl to set the Packet Filtering Params */
296#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
297#endif
298
299#ifdef FEATURE_WLAN_SCAN_PNO
300/* Private ioctl to get the statistics */
301#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
302#endif
303
304#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25) /*Don't change this number*/
305
306#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
307#define WLAN_PRIV_CLEAR_MCBC_FILTER (SIOCIWFIRSTPRIV + 27)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700308/* Private ioctl to trigger reassociation */
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700309
Jeff Johnson295189b2012-06-20 16:38:30 -0700310#define WLAN_SET_POWER_PARAMS (SIOCIWFIRSTPRIV + 29)
311#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
312
313#define WLAN_STATS_INVALID 0
314#define WLAN_STATS_RETRY_CNT 1
315#define WLAN_STATS_MUL_RETRY_CNT 2
316#define WLAN_STATS_TX_FRM_CNT 3
317#define WLAN_STATS_RX_FRM_CNT 4
318#define WLAN_STATS_FRM_DUP_CNT 5
319#define WLAN_STATS_FAIL_CNT 6
320#define WLAN_STATS_RTS_FAIL_CNT 7
321#define WLAN_STATS_ACK_FAIL_CNT 8
322#define WLAN_STATS_RTS_SUC_CNT 9
323#define WLAN_STATS_RX_DISCARD_CNT 10
324#define WLAN_STATS_RX_ERROR_CNT 11
325#define WLAN_STATS_TX_BYTE_CNT 12
326
327#define WLAN_STATS_RX_BYTE_CNT 13
328#define WLAN_STATS_RX_RATE 14
329#define WLAN_STATS_TX_RATE 15
330
Jeff Johnsone7245742012-09-05 17:12:55 -0700331#define WLAN_STATS_RX_UC_BYTE_CNT 16
332#define WLAN_STATS_RX_MC_BYTE_CNT 17
333#define WLAN_STATS_RX_BC_BYTE_CNT 18
334#define WLAN_STATS_TX_UC_BYTE_CNT 19
335#define WLAN_STATS_TX_MC_BYTE_CNT 20
336#define WLAN_STATS_TX_BC_BYTE_CNT 21
337
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800338#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
339 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) \
340 { \
341 *__p++ = __type; \
342 *__p++ = __size; \
343 memcpy(__p, __val, __size); \
344 __p += __size; \
345 __tlen += __size + 2; \
346 } \
347 else \
348 { \
Arif Hussain6d2a3322013-11-17 19:50:10 -0800349 hddLog(VOS_TRACE_LEVEL_ERROR, "FILL_TLV Failed!!!"); \
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800350 } \
351 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700352
353#define VERSION_VALUE_MAX_LEN 32
354
355#define TX_PER_TRACKING_DEFAULT_RATIO 5
356#define TX_PER_TRACKING_MAX_RATIO 10
357#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
358
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +0530359#define WLAN_ADAPTER 0
360#define P2P_ADAPTER 1
361
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -0800362/*MCC Configuration parameters */
363enum {
364 MCC_SCHEDULE_TIME_SLICE_CFG_PARAM = 1,
365 MCC_MAX_NULL_SEND_TIME_CFG_PARAM,
366 MCC_TX_EARLY_STOP_TIME_CFG_PARAM,
367 MCC_RX_DRAIN_TIME_CFG_PARAM,
368 MCC_CHANNEL_SWITCH_TIME_CFG_PARAM,
369 MCC_MIN_CHANNEL_TIME_CFG_PARAM,
370 MCC_PARK_BEFORE_TBTT_CFG_PARAM,
371 MCC_MIN_AFTER_DTIM_CFG_PARAM,
372 MCC_TOO_CLOSE_MARGIN_CFG_PARAM,
373};
374
375int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId,
376 v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3);
377
Jeff Johnson295189b2012-06-20 16:38:30 -0700378#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -0800379int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -0700380 v_U8_t sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700381#endif
382
Jeff Johnson295189b2012-06-20 16:38:30 -0700383/**---------------------------------------------------------------------------
384
Arif Hussain0273cba2014-01-07 20:58:29 -0800385 \brief mem_alloc_copy_from_user_helper -
386
387 Helper function to allocate buffer and copy user data.
388
389 \param - wrqu - Pointer to IOCTL Data.
390 len - size
391
392 \return - On Success pointer to buffer, On failure NULL
393
394 --------------------------------------------------------------------------*/
Girish Gowli86c471e2014-06-17 19:28:05 +0530395void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len)
Arif Hussain0273cba2014-01-07 20:58:29 -0800396{
397 u8 *ptr = NULL;
398
399 /* in order to protect the code, an extra byte is post appended to the buffer
400 * and the null termination is added. However, when allocating (len+1) byte
401 * of memory, we need to make sure that there is no uint overflow when doing
402 * addition. In theory check len < UINT_MAX protects the uint overflow. For
403 * wlan private ioctl, the buffer size is much less than UINT_MAX, as a good
404 * guess, now, it is assumed that the private command buffer size is no
405 * greater than 4K (4096 bytes). So we use 4096 as the upper boundary for now.
406 */
407 if (len > MAX_USER_COMMAND_SIZE)
408 {
409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
410 "Invalid length");
411 return NULL;
412 }
413
414 ptr = kmalloc(len + 1, GFP_KERNEL);
415 if (NULL == ptr)
416 {
417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
418 "unable to allocate memory");
419 return NULL;
420 }
421
422 if (copy_from_user(ptr, wrqu_data, len))
423 {
424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
425 "%s: failed to copy data to user buffer", __func__);
426 kfree(ptr);
427 return NULL;
428 }
429 ptr[len] = '\0';
430 return ptr;
431}
432
Girish Gowli488ef492014-06-12 18:44:33 +0530433// Function to handle and get compatible struct iw_point passed to ioctl.
434int hdd_priv_get_data(struct iw_point *p_priv_data,
435 union iwreq_data *wrqu)
436{
437 if ((NULL == p_priv_data) || (NULL == wrqu))
438 {
439 return -EINVAL;
440 }
441
442#ifdef CONFIG_COMPAT
443 if (is_compat_task())
444 {
445 struct compat_iw_point *p_compat_priv_data;
446
447 // Compat task: typecast to campat structure and copy the members.
448 p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
449
450 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
451 p_priv_data->length = p_compat_priv_data->length;
452 p_priv_data->flags = p_compat_priv_data->flags;
453 }//if(is_compat_task())
454 else
455 {
456#endif //#ifdef CONFIG_COMPAT
457
458 // Non compat task: directly copy the structure.
459 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
460
461#ifdef CONFIG_COMPAT
462 }//else of - if(is_compat_task())
463#endif //#ifdef CONFIG_COMPAT
464
465 return 0;
466}
467
Arif Hussain0273cba2014-01-07 20:58:29 -0800468/**---------------------------------------------------------------------------
469
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 \brief hdd_wlan_get_version() -
471
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800472 This function use to get Wlan Driver, Firmware, & Hardware Version.
Jeff Johnson295189b2012-06-20 16:38:30 -0700473
474 \param - pAdapter Pointer to the adapter.
475 wrqu - Pointer to IOCTL REQUEST Data.
476 extra - Pointer to char
477
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800478 \return - none
Jeff Johnson295189b2012-06-20 16:38:30 -0700479
480 --------------------------------------------------------------------------*/
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800481void hdd_wlan_get_version(hdd_adapter_t *pAdapter, union iwreq_data *wrqu,
482 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -0700483{
484 VOS_STATUS status;
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800485 tSirVersionString wcnss_SW_version;
486 tSirVersionString wcnss_HW_version;
487 char *pSWversion;
488 char *pHWversion;
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700490
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800491 status = sme_GetWcnssSoftwareVersion(hHal, wcnss_SW_version,
492 sizeof(wcnss_SW_version));
493 if (VOS_IS_STATUS_SUCCESS(status))
494 {
495 pSWversion = wcnss_SW_version;
496 }
497 else
498 {
499 pSWversion = "Unknown";
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 }
501
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800502 status = sme_GetWcnssHardwareVersion(hHal, wcnss_HW_version,
503 sizeof(wcnss_HW_version));
504 if (VOS_IS_STATUS_SUCCESS(status))
505 {
506 pHWversion = wcnss_HW_version;
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 }
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800508 else
509 {
510 pHWversion = "Unknown";
511 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700512
Sameer Thalappilb0a30232013-09-27 15:37:48 -0700513 wrqu->data.length = scnprintf(extra, WE_MAX_STR_LEN,
Jeff Johnson4824d4c2013-02-12 14:23:57 -0800514 "Host SW:%s, FW:%s, HW:%s",
515 QWLAN_VERSIONSTR,
516 pSWversion,
517 pHWversion);
518
519 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700520}
521
Jeff Johnson295189b2012-06-20 16:38:30 -0700522int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
523{
524 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
525 v_U32_t threshold = 0,status = 0;
526
527 ENTER();
528
Agarwal Ashish971c2882013-10-30 20:11:12 +0530529 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
530 {
531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 "%s:LOGP in Progress. Ignore!!!",__func__);
533 return status;
534 }
535
536 if ( eHAL_STATUS_SUCCESS !=
537 ccmCfgGetInt(hHal, WNI_CFG_RTS_THRESHOLD, &threshold) )
538 {
c_hpothub8245442013-11-20 23:41:09 +0530539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
540 FL("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 return -EIO;
542 }
543 wrqu->rts.value = threshold;
544
545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800546 ("Rts-Threshold=%d!!"), wrqu->rts.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547
548 EXIT();
549
550 return 0;
551}
552
553int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
554{
555 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
556 v_U32_t threshold = 0,status = 0;
557
558 ENTER();
559
Agarwal Ashish971c2882013-10-30 20:11:12 +0530560 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
561 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
563 "%s:LOGP in Progress. Ignore!!!",__func__);
564 return status;
565 }
566
567 if ( ccmCfgGetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
568 != eHAL_STATUS_SUCCESS )
569 {
c_hpothub8245442013-11-20 23:41:09 +0530570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
571 FL("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 return -EIO;
573 }
574 wrqu->frag.value = threshold;
575
576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800577 ("Frag-Threshold=%d!!"), wrqu->frag.value);
Jeff Johnson295189b2012-06-20 16:38:30 -0700578
579 EXIT();
580
581 return 0;
582}
583
584int hdd_wlan_get_freq(v_U32_t channel, v_U32_t *pfreq)
585{
Jeff Johnsone7245742012-09-05 17:12:55 -0700586 int i;
587 if (channel > 0)
588 {
589 for (i=0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++)
590 {
591 if (channel == freq_chan_map[i].chan)
592 {
593 *pfreq = freq_chan_map[i].freq;
594 return 1;
595 }
596 }
597 }
598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800599 ("Invalid channel no=%d!!"), channel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700600 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700601}
602
603static v_BOOL_t
604hdd_IsAuthTypeRSN( tHalHandle halHandle, eCsrAuthType authType)
605{
606 v_BOOL_t rsnType = VOS_FALSE;
607 // is the authType supported?
608 switch (authType)
609 {
610 case eCSR_AUTH_TYPE_NONE: //never used
611 rsnType = eANI_BOOLEAN_FALSE;
612 break;
613 // MAC layer authentication types
614 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
615 rsnType = eANI_BOOLEAN_FALSE;
616 break;
617 case eCSR_AUTH_TYPE_SHARED_KEY:
618 rsnType = eANI_BOOLEAN_FALSE;
619 break;
620 case eCSR_AUTH_TYPE_AUTOSWITCH:
621 rsnType = eANI_BOOLEAN_FALSE;
622 break;
623
624 // Upper layer authentication types
625 case eCSR_AUTH_TYPE_WPA:
626 rsnType = eANI_BOOLEAN_TRUE;
627 break;
628 case eCSR_AUTH_TYPE_WPA_PSK:
629 rsnType = eANI_BOOLEAN_TRUE;
630 break;
631 case eCSR_AUTH_TYPE_WPA_NONE:
632 rsnType = eANI_BOOLEAN_TRUE;
633 break;
634#ifdef WLAN_FEATURE_VOWIFI_11R
635 case eCSR_AUTH_TYPE_FT_RSN:
636#endif
637 case eCSR_AUTH_TYPE_RSN:
638 rsnType = eANI_BOOLEAN_TRUE;
639 break;
640#ifdef WLAN_FEATURE_VOWIFI_11R
641 case eCSR_AUTH_TYPE_FT_RSN_PSK:
642#endif
643 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700644#ifdef WLAN_FEATURE_11W
645 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
646#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 rsnType = eANI_BOOLEAN_TRUE;
648 break;
649 //case eCSR_AUTH_TYPE_FAILED:
650 case eCSR_AUTH_TYPE_UNKNOWN:
651 rsnType = eANI_BOOLEAN_FALSE;
652 break;
653 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -0800654 hddLog(LOGE, FL("%s called with unknown authType - default to Open, None"),
655 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 rsnType = eANI_BOOLEAN_FALSE;
657 break;
658 }
Arif Hussain6d2a3322013-11-17 19:50:10 -0800659 hddLog(LOGE, FL("%s called with authType: %d, returned: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700660 __func__, authType, rsnType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 return rsnType;
662}
663
664static void hdd_GetRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
665{
666 struct statsContext *pStatsContext;
667 hdd_adapter_t *pAdapter;
668
669 if (ioctl_debug)
670 {
671 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700672 __func__, (int)rssi, (int)staId, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 }
674
675 if (NULL == pContext)
676 {
677 hddLog(VOS_TRACE_LEVEL_ERROR,
678 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700679 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 return;
681 }
682
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 pStatsContext = pContext;
684 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800685
686 /* there is a race condition that exists between this callback
687 function and the caller since the caller could time out either
688 before or while this code is executing. we use a spinlock to
689 serialize these actions */
690 spin_lock(&hdd_context_lock);
691
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
693 {
694 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800695 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 hddLog(VOS_TRACE_LEVEL_WARN,
697 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700698 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 if (ioctl_debug)
700 {
701 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700702 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 }
704 return;
705 }
706
Jeff Johnson72a40512013-12-19 10:14:15 -0800707 /* context is valid so caller is still waiting */
708
709 /* paranoia: invalidate the magic */
710 pStatsContext->magic = 0;
711
712 /* copy over the rssi */
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 pAdapter->rssi = rssi;
714
Jeff Johnson72a40512013-12-19 10:14:15 -0800715 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800717
718 /* serialization is complete */
719 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720}
721
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530722static void hdd_GetSnrCB(tANI_S8 snr, tANI_U32 staId, void *pContext)
723{
724 struct statsContext *pStatsContext;
725 hdd_adapter_t *pAdapter;
726
727 if (ioctl_debug)
728 {
729 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
730 __func__, (int)snr, (int)staId, pContext);
731 }
732
733 if (NULL == pContext)
734 {
735 hddLog(VOS_TRACE_LEVEL_ERROR,
736 "%s: Bad param, pContext [%p]",
737 __func__, pContext);
738 return;
739 }
740
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530741 pStatsContext = pContext;
742 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800743
744 /* there is a race condition that exists between this callback
745 function and the caller since the caller could time out either
746 before or while this code is executing. we use a spinlock to
747 serialize these actions */
748 spin_lock(&hdd_context_lock);
749
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530750 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic))
751 {
752 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800753 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530754 hddLog(VOS_TRACE_LEVEL_WARN,
755 "%s: Invalid context, pAdapter [%p] magic [%08x]",
756 __func__, pAdapter, pStatsContext->magic);
757 if (ioctl_debug)
758 {
759 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
760 __func__, pAdapter, pStatsContext->magic);
761 }
762 return;
763 }
764
Jeff Johnson72a40512013-12-19 10:14:15 -0800765 /* context is valid so caller is still waiting */
766
767 /* paranoia: invalidate the magic */
768 pStatsContext->magic = 0;
769
770 /* copy over the snr */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530771 pAdapter->snr = snr;
772
Jeff Johnson72a40512013-12-19 10:14:15 -0800773 /* notify the caller */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530774 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800775
776 /* serialization is complete */
777 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530778}
779
Jeff Johnson295189b2012-06-20 16:38:30 -0700780VOS_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
781{
782 struct statsContext context;
783 hdd_context_t *pHddCtx;
784 hdd_station_ctx_t *pHddStaCtx;
785 eHalStatus hstatus;
786 long lrc;
787
788 if (NULL == pAdapter)
789 {
790 hddLog(VOS_TRACE_LEVEL_WARN,
791 "%s: Invalid context, pAdapter", __func__);
792 return VOS_STATUS_E_FAULT;
793 }
794 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
795 {
796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
797 /* return a cached value */
798 *rssi_value = pAdapter->rssi;
799 return VOS_STATUS_SUCCESS;
800 }
801
802 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
803 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
804
805 init_completion(&context.completion);
806 context.pAdapter = pAdapter;
807 context.magic = RSSI_CONTEXT_MAGIC;
808
809 hstatus = sme_GetRssi(pHddCtx->hHal, hdd_GetRssiCB,
810 pHddStaCtx->conn_info.staId[ 0 ],
811 pHddStaCtx->conn_info.bssId,
812 &context, pHddCtx->pvosContext);
813 if (eHAL_STATUS_SUCCESS != hstatus)
814 {
815 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700816 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 /* we'll returned a cached value below */
818 }
819 else
820 {
821 /* request was sent -- wait for the response */
822 lrc = wait_for_completion_interruptible_timeout(&context.completion,
823 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 if (lrc <= 0)
825 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800826 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving RSSI",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700827 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 /* we'll now returned a cached value below */
829 }
830 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800831
832 /* either we never sent a request, we sent a request and received a
833 response or we sent a request and timed out. if we never sent a
834 request or if we sent a request and got a response, we want to
835 clear the magic out of paranoia. if we timed out there is a
836 race condition such that the callback function could be
837 executing at the same time we are. of primary concern is if the
838 callback function had already verified the "magic" but had not
839 yet set the completion variable when a timeout occurred. we
840 serialize these activities by invalidating the magic while
841 holding a shared spinlock which will cause us to block if the
842 callback is currently executing */
843 spin_lock(&hdd_context_lock);
844 context.magic = 0;
845 spin_unlock(&hdd_context_lock);
846
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 *rssi_value = pAdapter->rssi;
848
849 return VOS_STATUS_SUCCESS;
850}
851
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530852VOS_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, v_S7_t *snr)
853{
854 struct statsContext context;
855 hdd_context_t *pHddCtx;
856 hdd_station_ctx_t *pHddStaCtx;
857 eHalStatus hstatus;
858 long lrc;
859 int valid;
860
861 if (NULL == pAdapter)
862 {
863 hddLog(VOS_TRACE_LEVEL_ERROR,
864 "%s: Invalid context, pAdapter", __func__);
865 return VOS_STATUS_E_FAULT;
866 }
867
868 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
869
870 valid = wlan_hdd_validate_context(pHddCtx);
871 if (0 != valid)
872 {
873 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
874 return VOS_STATUS_E_FAULT;
875 }
876
877 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
878 if (NULL == pHddStaCtx)
879 {
880 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is not valid"));
881 return VOS_STATUS_E_FAULT;
882 }
883
884 init_completion(&context.completion);
885 context.pAdapter = pAdapter;
886 context.magic = SNR_CONTEXT_MAGIC;
887
888 hstatus = sme_GetSnr(pHddCtx->hHal, hdd_GetSnrCB,
889 pHddStaCtx->conn_info.staId[ 0 ],
890 pHddStaCtx->conn_info.bssId,
891 &context);
892 if (eHAL_STATUS_SUCCESS != hstatus)
893 {
894 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
895 __func__);
896 /* we'll returned a cached value below */
897 }
898 else
899 {
900 /* request was sent -- wait for the response */
901 lrc = wait_for_completion_interruptible_timeout(&context.completion,
902 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530903 if (lrc <= 0)
904 {
Jeff Johnson72a40512013-12-19 10:14:15 -0800905 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME %s while retrieving SNR",
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530906 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530907 /* we'll now returned a cached value below */
908 }
909 }
Jeff Johnson72a40512013-12-19 10:14:15 -0800910
911 /* either we never sent a request, we sent a request and received a
912 response or we sent a request and timed out. if we never sent a
913 request or if we sent a request and got a response, we want to
914 clear the magic out of paranoia. if we timed out there is a
915 race condition such that the callback function could be
916 executing at the same time we are. of primary concern is if the
917 callback function had already verified the "magic" but had not
918 yet set the completion variable when a timeout occurred. we
919 serialize these activities by invalidating the magic while
920 holding a shared spinlock which will cause us to block if the
921 callback is currently executing */
922 spin_lock(&hdd_context_lock);
923 context.magic = 0;
924 spin_unlock(&hdd_context_lock);
925
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +0530926 *snr = pAdapter->snr;
927
928 return VOS_STATUS_SUCCESS;
929}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800930#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800931
932static void hdd_GetRoamRssiCB( v_S7_t rssi, tANI_U32 staId, void *pContext )
933{
934 struct statsContext *pStatsContext;
935 hdd_adapter_t *pAdapter;
936 if (ioctl_debug)
937 {
938 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
939 __func__, (int)rssi, (int)staId, pContext);
940 }
941
942 if (NULL == pContext)
943 {
944 hddLog(VOS_TRACE_LEVEL_ERROR,
945 "%s: Bad param, pContext [%p]",
946 __func__, pContext);
947 return;
948 }
949
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800950 pStatsContext = pContext;
951 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -0800952
953 /* there is a race condition that exists between this callback
954 function and the caller since the caller could time out either
955 before or while this code is executing. we use a spinlock to
956 serialize these actions */
957 spin_lock(&hdd_context_lock);
958
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800959 if ((NULL == pAdapter) || (RSSI_CONTEXT_MAGIC != pStatsContext->magic))
960 {
961 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -0800962 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800963 hddLog(VOS_TRACE_LEVEL_WARN,
964 "%s: Invalid context, pAdapter [%p] magic [%08x]",
965 __func__, pAdapter, pStatsContext->magic);
966 if (ioctl_debug)
967 {
968 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
969 __func__, pAdapter, pStatsContext->magic);
970 }
971 return;
972 }
973
Jeff Johnson72a40512013-12-19 10:14:15 -0800974 /* context is valid so caller is still waiting */
975
976 /* paranoia: invalidate the magic */
977 pStatsContext->magic = 0;
978
979 /* copy over the rssi */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800980 pAdapter->rssi = rssi;
981
Jeff Johnson72a40512013-12-19 10:14:15 -0800982 /* notify the caller */
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800983 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -0800984
985 /* serialization is complete */
986 spin_unlock(&hdd_context_lock);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800987}
988
989
990
991VOS_STATUS wlan_hdd_get_roam_rssi(hdd_adapter_t *pAdapter, v_S7_t *rssi_value)
992{
993 struct statsContext context;
994 hdd_context_t *pHddCtx = NULL;
995 hdd_station_ctx_t *pHddStaCtx = NULL;
996 eHalStatus hstatus;
997 long lrc;
998
999 if (NULL == pAdapter)
1000 {
1001 hddLog(VOS_TRACE_LEVEL_WARN,
1002 "%s: Invalid context, pAdapter", __func__);
1003 return VOS_STATUS_E_FAULT;
1004 }
1005 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1006 {
1007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
1008 /* return a cached value */
1009 *rssi_value = pAdapter->rssi;
1010 return VOS_STATUS_SUCCESS;
1011 }
1012
1013 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1014 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1015
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301016 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001017 {
1018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__);
1019 /* return a cached value */
1020 *rssi_value = 0;
1021 return VOS_STATUS_SUCCESS;
1022 }
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05301023
1024 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
1025 {
1026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1027 "%s: Roaming in progress, hence return last cached RSSI", __func__);
1028 *rssi_value = pAdapter->rssi;
1029 return VOS_STATUS_SUCCESS;
1030 }
1031
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001032 init_completion(&context.completion);
1033 context.pAdapter = pAdapter;
1034 context.magic = RSSI_CONTEXT_MAGIC;
1035
1036 hstatus = sme_GetRoamRssi(pHddCtx->hHal, hdd_GetRoamRssiCB,
1037 pHddStaCtx->conn_info.staId[ 0 ],
1038 pHddStaCtx->conn_info.bssId,
1039 &context, pHddCtx->pvosContext);
1040 if (eHAL_STATUS_SUCCESS != hstatus)
1041 {
1042 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Unable to retrieve RSSI",
1043 __func__);
1044 /* we'll returned a cached value below */
1045 }
1046 else
1047 {
1048 /* request was sent -- wait for the response */
1049 lrc = wait_for_completion_interruptible_timeout(&context.completion,
1050 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001051 if (lrc <= 0)
1052 {
Jeff Johnson72a40512013-12-19 10:14:15 -08001053 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while retrieving RSSI",
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001054 __func__, (0 == lrc) ? "timeout" : "interrupt");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001055 /* we'll now returned a cached value below */
1056 }
1057 }
Jeff Johnson72a40512013-12-19 10:14:15 -08001058
1059 /* either we never sent a request, we sent a request and received a
1060 response or we sent a request and timed out. if we never sent a
1061 request or if we sent a request and got a response, we want to
1062 clear the magic out of paranoia. if we timed out there is a
1063 race condition such that the callback function could be
1064 executing at the same time we are. of primary concern is if the
1065 callback function had already verified the "magic" but had not
1066 yet set the completion variable when a timeout occurred. we
1067 serialize these activities by invalidating the magic while
1068 holding a shared spinlock which will cause us to block if the
1069 callback is currently executing */
1070 spin_lock(&hdd_context_lock);
1071 context.magic = 0;
1072 spin_unlock(&hdd_context_lock);
1073
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08001074 *rssi_value = pAdapter->rssi;
1075
1076 return VOS_STATUS_SUCCESS;
1077}
1078#endif
1079
1080
Jeff Johnson295189b2012-06-20 16:38:30 -07001081void hdd_StatisticsCB( void *pStats, void *pContext )
1082{
1083 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
1084 hdd_stats_t *pStatsCache = NULL;
1085 hdd_wext_state_t *pWextState;
1086 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1087
1088 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1089 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1090 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1091 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1092 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1093 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1094
1095 if (pAdapter!= NULL)
1096 pStatsCache = &pAdapter->hdd_stats;
1097
1098
1099 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
1100 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
1101 pClassBStats = (tCsrGlobalClassBStatsInfo *)( pClassAStats + 1 );
1102 pClassCStats = (tCsrGlobalClassCStatsInfo *)( pClassBStats + 1 );
1103 pClassDStats = (tCsrGlobalClassDStatsInfo *)( pClassCStats + 1 );
1104 pPerStaStats = (tCsrPerStaStatsInfo *)( pClassDStats + 1 );
1105
1106 if (pStatsCache!=NULL)
1107 {
1108 // and copy the stats into the cache we keep in the adapter instance structure
1109 vos_mem_copy( &pStatsCache->summary_stat, pSummaryStats, sizeof( pStatsCache->summary_stat ) );
1110 vos_mem_copy( &pStatsCache->ClassA_stat, pClassAStats, sizeof( pStatsCache->ClassA_stat ) );
1111 vos_mem_copy( &pStatsCache->ClassB_stat, pClassBStats, sizeof( pStatsCache->ClassB_stat ) );
1112 vos_mem_copy( &pStatsCache->ClassC_stat, pClassCStats, sizeof( pStatsCache->ClassC_stat ) );
1113 vos_mem_copy( &pStatsCache->ClassD_stat, pClassDStats, sizeof( pStatsCache->ClassD_stat ) );
1114 vos_mem_copy( &pStatsCache->perStaStats, pPerStaStats, sizeof( pStatsCache->perStaStats ) );
1115 }
1116
1117 if(pAdapter)
1118 {
1119 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1120 if(pWextState)
1121 {
1122 vos_status = vos_event_set(&pWextState->vosevent);
1123 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1124 {
1125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001126 "%s: vos_event_set failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 return;
1128 }
1129 }
1130 }
1131}
1132
1133void ccmCfgSetCallback(tHalHandle halHandle, tANI_S32 result)
1134{
1135 v_CONTEXT_t pVosContext;
1136 hdd_context_t *pHddCtx;
1137 VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx );
1138#if 0
1139 hdd_wext_state_t *pWextState;
1140 v_U32_t roamId;
1141#endif
1142
1143 ENTER();
1144
1145 pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS,NULL);
1146
1147 pHddCtx = (hdd_context_t*) vos_get_context(VOS_MODULE_ID_HDD,pVosContext);
1148 if (NULL == pHddCtx)
1149 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001150 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid pHddCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 return;
1152 }
1153#if 0
1154 pWextState = pAdapter->pWextState;
1155#endif
1156
1157 if (WNI_CFG_NEED_RESTART == result || WNI_CFG_NEED_RELOAD == result)
1158 {
1159 //TODO Verify is this is really used. If yes need to fix it.
1160 hdd_reconnect_all_adapters( pHddCtx );
1161#if 0
1162 pAdapter->conn_info.connState = eConnectionState_NotConnected;
1163 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1164 vosStatus = sme_RoamDisconnect(halHandle, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1165
1166 if(VOS_STATUS_SUCCESS == vosStatus)
1167 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
1168 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1169
1170 sme_RoamConnect(halHandle,
1171 pAdapter->sessionId, &(pWextState->roamProfile),
1172 &roamId);
1173#endif
1174 }
1175
1176 EXIT();
1177
1178}
1179
1180void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter)
1181{
1182 int i = 0;
1183 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1184
1185 /* clear WPA/RSN/WSC IE information in the profile */
1186 pWextState->roamProfile.nWPAReqIELength = 0;
1187 pWextState->roamProfile.pWPAReqIE = (tANI_U8 *)NULL;
1188 pWextState->roamProfile.nRSNReqIELength = 0;
1189 pWextState->roamProfile.pRSNReqIE = (tANI_U8 *)NULL;
1190
Chet Lanctot186b5732013-03-18 10:26:30 -07001191#ifdef FEATURE_WLAN_WAPI
1192 pWextState->roamProfile.nWAPIReqIELength = 0;
1193 pWextState->roamProfile.pWAPIReqIE = (tANI_U8 *)NULL;
1194#endif
1195
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07001197 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 pWextState->roamProfile.nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05301199 memset(pWextState->roamProfile.addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 pWextState->roamProfile.pAddIEAssoc = (tANI_U8 *)NULL;
1201 pWextState->roamProfile.nAddIEAssocLength = 0;
1202
1203 pWextState->roamProfile.EncryptionType.numEntries = 1;
1204 pWextState->roamProfile.EncryptionType.encryptionType[0]
1205 = eCSR_ENCRYPT_TYPE_NONE;
1206
1207 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1208 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1209 = eCSR_ENCRYPT_TYPE_NONE;
1210
1211 pWextState->roamProfile.AuthType.numEntries = 1;
1212 pWextState->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1213
Chet Lanctot186b5732013-03-18 10:26:30 -07001214#ifdef WLAN_FEATURE_11W
1215 pWextState->roamProfile.MFPEnabled = eANI_BOOLEAN_FALSE;
1216 pWextState->roamProfile.MFPRequired = 0;
1217 pWextState->roamProfile.MFPCapable = 0;
1218#endif
1219
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 pWextState->authKeyMgmt = 0;
1221
1222 for (i=0; i < CSR_MAX_NUM_KEY; i++)
1223 {
1224 if (pWextState->roamProfile.Keys.KeyMaterial[i])
1225 {
1226 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1227 }
1228 }
1229#ifdef FEATURE_WLAN_WAPI
1230 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1231 pAdapter->wapi_info.nWapiMode = 0;
1232#endif
1233
1234 vos_mem_zero((void *)(pWextState->req_bssId), WNI_CFG_BSSID_LEN);
1235
1236}
1237
1238void wlan_hdd_ula_done_cb(v_VOID_t *callbackContext)
1239{
1240 hdd_adapter_t *pAdapter = (hdd_adapter_t*)callbackContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001241
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001242 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
1243 {
1244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1245 "%s: Invalid pAdapter magic", __func__);
1246 }
1247 else
1248 {
1249 complete(&pAdapter->ula_complete);
1250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001251}
1252
1253VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter)
1254{
1255 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 VOS_STATUS vos_status;
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001257 unsigned long rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001258
1259 if (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)
1260 {
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001261 INIT_COMPLETION(pAdapter->ula_complete);
Jeff Johnson295189b2012-06-20 16:38:30 -07001262
1263 /*To avoid race condition between the set key and the last EAPOL
1264 packet, notify TL to finish upper layer authentication incase if the
1265 last EAPOL packet pending in the TL queue.*/
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001266 vos_status = WLANTL_Finish_ULA(wlan_hdd_ula_done_cb, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001267
1268 if ( vos_status != VOS_STATUS_SUCCESS )
1269 {
1270 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1271 "[%4d] WLANTL_Finish_ULA returned ERROR status= %d",
1272 __LINE__, vos_status );
1273 return vos_status;
1274
1275 }
1276
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001277 rc = wait_for_completion_timeout(&pAdapter->ula_complete,
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 msecs_to_jiffies(HDD_FINISH_ULA_TIME_OUT));
c_hpothub8245442013-11-20 23:41:09 +05301279 if (rc <= 0)
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001280 {
1281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothub8245442013-11-20 23:41:09 +05301282 FL("failure wait on ULA to complete %ld"), rc);
Jeff Johnson9efb9aa2013-03-15 13:59:27 -07001283 /* we'll still fall through and return success since the
1284 * connection may still get established but is just taking
1285 * too long for us to wait */
1286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001287 }
1288 return VOS_STATUS_SUCCESS;
1289}
1290
1291v_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)
1292{
1293
1294 int left = ie_len;
1295 v_U8_t *ptr = ie;
1296 v_U8_t elem_id,elem_len;
1297 v_U8_t eid = 0xDD;
1298
1299 if ( NULL == ie || 0 == ie_len )
1300 return NULL;
1301
1302 while(left >= 2)
1303 {
1304 elem_id = ptr[0];
1305 elem_len = ptr[1];
1306 left -= 2;
1307 if(elem_len > left)
1308 {
1309 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001310 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 eid,elem_len,left);
1312 return NULL;
1313 }
1314 if (elem_id == eid)
1315 {
1316 if(memcmp( &ptr[2], oui, oui_size)==0)
1317 return ptr;
1318 }
1319
1320 left -= elem_len;
1321 ptr += (elem_len + 2);
1322 }
1323 return NULL;
1324}
1325
1326static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1327 union iwreq_data *wrqu, char *extra)
1328{
Arif Hussain6d2a3322013-11-17 19:50:10 -08001329 hddLog( LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 /* Do nothing for now */
1331 return 0;
1332}
1333
1334static int iw_get_name(struct net_device *dev,
1335 struct iw_request_info *info,
1336 char *wrqu, char *extra)
1337{
1338
1339 ENTER();
1340 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1341 EXIT();
1342 return 0;
1343}
1344
1345static int iw_set_mode(struct net_device *dev,
1346 struct iw_request_info *info,
1347 union iwreq_data *wrqu, char *extra)
1348{
1349 hdd_wext_state_t *pWextState;
1350 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1351 tCsrRoamProfile *pRoamProfile;
1352 eCsrRoamBssType LastBSSType;
1353 eMib_dot11DesiredBssType connectedBssType;
1354 hdd_config_t *pConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 struct wireless_dev *wdev;
Jeff Johnson295189b2012-06-20 16:38:30 -07001356
1357 ENTER();
1358
1359 if (NULL == pAdapter)
1360 {
1361 hddLog(VOS_TRACE_LEVEL_WARN,
1362 "%s: Invalid context, pAdapter", __func__);
1363 return 0;
1364 }
1365
1366 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1368 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001369 return 0;
1370 }
1371
1372 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1373 if (pWextState == NULL)
1374 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301375 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 return -EINVAL;
1377 }
1378
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 pRoamProfile = &pWextState->roamProfile;
1381 LastBSSType = pRoamProfile->BSSType;
1382
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301383 hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001384
1385 switch (wrqu->mode)
1386 {
1387 case IW_MODE_ADHOC:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301388 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
1390 // Set the phymode correctly for IBSS.
1391 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1392 pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001393 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001394 wdev->iftype = NL80211_IFTYPE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 break;
1396 case IW_MODE_INFRA:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301397 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001398 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 wdev->iftype = NL80211_IFTYPE_STATION;
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 break;
1401 case IW_MODE_AUTO:
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301402 hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
1404 break;
1405 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05301406 hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 return -EOPNOTSUPP;
1408 }
1409
1410 if ( LastBSSType != pRoamProfile->BSSType )
1411 {
1412 //the BSS mode changed
1413 // We need to issue disconnect if connected or in IBSS disconnect state
1414 if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
1415 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
1416 {
1417 VOS_STATUS vosStatus;
1418 // need to issue a disconnect to CSR.
1419 INIT_COMPLETION(pAdapter->disconnect_comp_var);
1420 vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1421 pAdapter->sessionId,
1422 eCSR_DISCONNECT_REASON_IBSS_LEAVE );
1423 if(VOS_STATUS_SUCCESS == vosStatus)
c_hpothub8245442013-11-20 23:41:09 +05301424 {
1425 long ret;
1426 ret = wait_for_completion_interruptible_timeout(
1427 &pAdapter->disconnect_comp_var,
1428 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
1429 if (ret <= 0)
1430 hddLog(VOS_TRACE_LEVEL_ERROR,
1431 FL("failed wait on disconnect_comp_var %ld"), ret);
1432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 }
1434 }
1435
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 EXIT();
1437 return 0;
1438}
1439
1440
1441static int iw_get_mode(struct net_device *dev,
1442 struct iw_request_info *info,
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301443 union iwreq_data *wrqu,
1444 char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07001445{
1446
1447 hdd_wext_state_t *pWextState;
1448 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1449
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301450 hddLog(LOG1, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001451
1452 if (NULL == pAdapter)
1453 {
1454 hddLog(VOS_TRACE_LEVEL_WARN,
1455 "%s: Invalid context, pAdapter", __func__);
1456 return 0;
1457 }
1458
1459 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1461 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 return 0;
1463 }
1464
1465 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1466 if (pWextState == NULL)
1467 {
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301468 hddLog(LOGE, "%s ERROR: Data Storage Corruption", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 return -EINVAL;
1470 }
1471
1472 switch (pWextState->roamProfile.BSSType)
1473 {
1474 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001475 hddLog(LOG1, "%s returns IW_MODE_INFRA", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301476 wrqu->mode = IW_MODE_INFRA;
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 break;
1478 case eCSR_BSS_TYPE_IBSS:
1479 case eCSR_BSS_TYPE_START_IBSS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001480 hddLog(LOG1, "%s returns IW_MODE_ADHOC", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301481 wrqu->mode = IW_MODE_ADHOC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001482 break;
1483 case eCSR_BSS_TYPE_ANY:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001484 hddLog(LOG1, "%s returns IW_MODE_AUTO", __func__);
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301485 wrqu->mode = IW_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 break;
1487 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08001488 hddLog(LOG1, "%s returns APMODE_UNKNOWN", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 break;
1490 }
Madan Mohan Koyyalamudi0c2ba1b2013-10-01 19:47:50 +05301491
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 return 0;
1493}
1494
1495static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
1496 union iwreq_data *wrqu, char *extra)
1497{
1498 v_U32_t numChans = 0;
1499 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1500 v_U32_t indx = 0;
1501 v_U32_t status = 0;
1502
1503 hdd_wext_state_t *pWextState;
1504 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1505 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1506 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1507 tCsrRoamProfile * pRoamProfile;
1508 ENTER();
1509
1510 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1511 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1512 return status;
1513 }
1514
1515 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1516
1517 pRoamProfile = &pWextState->roamProfile;
1518
Arif Hussain6d2a3322013-11-17 19:50:10 -08001519 hddLog(LOG1,"setCHANNEL ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001520
1521 /* Link is up then return cant set channel*/
1522 if(eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
1523 eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1524 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001525 hddLog( LOGE, "IBSS Associated");
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 return -EOPNOTSUPP;
1527 }
1528
1529 /* Settings by Frequency as input */
1530 if((wrqu->freq.e == 1) && (wrqu->freq.m >= (tANI_U32)2.412e8) &&
1531 (wrqu->freq.m <= (tANI_U32)5.825e8))
1532 {
1533 tANI_U32 freq = wrqu->freq.m / 100000;
1534
1535 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE) && (freq != freq_chan_map[indx].freq))
1536 indx++;
1537 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
1538 {
1539 return -EINVAL;
1540 }
1541 wrqu->freq.e = 0;
1542 wrqu->freq.m = freq_chan_map[indx].chan;
1543
1544 }
1545
1546 if (wrqu->freq.e == 0)
1547 {
1548 if((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
1549 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX))
1550 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08001551 hddLog(LOG1,"%s: Channel [%d] is outside valid range from %d to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001552 __func__, wrqu->freq.m, WNI_CFG_CURRENT_CHANNEL_STAMIN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1554 return -EINVAL;
1555 }
1556
1557 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1558
1559 if (ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1560 validChan, &numChans) != eHAL_STATUS_SUCCESS){
c_hpothub8245442013-11-20 23:41:09 +05301561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1562 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 return -EIO;
1564 }
1565
1566 for (indx = 0; indx < numChans; indx++) {
1567 if (wrqu->freq.m == validChan[indx]){
1568 break;
1569 }
1570 }
1571 }
1572 else{
1573
1574 return -EINVAL;
1575 }
1576
1577 if(indx >= numChans)
1578 {
1579 return -EINVAL;
1580 }
1581
1582 /* Set the Operational Channel */
1583 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
1584 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
1585 pRoamProfile->ChannelInfo.ChannelList = &pHddStaCtx->conn_info.operationChannel;
1586
Arif Hussain6d2a3322013-11-17 19:50:10 -08001587 hddLog(LOG1,"pRoamProfile->operationChannel = %d", wrqu->freq.m);
Jeff Johnson295189b2012-06-20 16:38:30 -07001588
1589 EXIT();
1590
1591 return status;
1592}
1593
1594static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
1595 struct iw_freq *fwrq, char *extra)
1596{
Jeff Johnsone7245742012-09-05 17:12:55 -07001597 v_U32_t status = FALSE, channel = 0, freq = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1599 tHalHandle hHal;
1600 hdd_wext_state_t *pWextState;
1601 tCsrRoamProfile * pRoamProfile;
1602 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1603
1604 ENTER();
1605
1606 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1608 return status;
1609 }
1610
1611 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1612 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1613
1614 pRoamProfile = &pWextState->roamProfile;
1615
1616 if( pHddStaCtx->conn_info.connState== eConnectionState_Associated )
1617 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001618 if (sme_GetOperationChannel(hHal, &channel, pAdapter->sessionId) != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 {
c_hpothub8245442013-11-20 23:41:09 +05301620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1621 FL("failed to get operating channel %u"), pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 return -EIO;
1623 }
1624 else
1625 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001626 status = hdd_wlan_get_freq(channel, &freq);
1627 if( TRUE == status )
1628 {
1629 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1630 * iwlist & iwconfig command shows frequency into proper
1631 * format (2.412 GHz instead of 246.2 MHz)*/
1632 fwrq->m = freq;
1633 fwrq->e = MHZ;
1634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 }
1636 }
1637 else
1638 {
Madan Mohan Koyyalamudi99f9c662012-10-11 17:00:31 -07001639 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
1640 * iwlist & iwconfig command shows frequency into proper
1641 * format (2.412 GHz instead of 246.2 MHz)*/
1642 fwrq->m = 0;
1643 fwrq->e = MHZ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001644 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001645 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001646}
1647
1648static int iw_get_tx_power(struct net_device *dev,
1649 struct iw_request_info *info,
1650 union iwreq_data *wrqu, char *extra)
1651{
1652
1653 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1654 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1655 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1656
1657 if (pHddCtx->isLogpInProgress)
1658 {
1659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1660 "%s:LOGP in Progress. Ignore!!!",__func__);
1661 return -EBUSY;
1662 }
1663
1664 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1665 {
1666 wrqu->txpower.value = 0;
1667 return 0;
1668 }
1669 wlan_hdd_get_classAstats(pAdapter);
1670 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
1671
1672 return 0;
1673}
1674
1675static int iw_set_tx_power(struct net_device *dev,
1676 struct iw_request_info *info,
1677 union iwreq_data *wrqu, char *extra)
1678{
1679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1680 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1681
1682 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1683 {
1684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1685 return 0;
1686 }
1687
1688 ENTER();
1689
1690 if ( ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, wrqu->txpower.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
1691 {
c_hpothub8245442013-11-20 23:41:09 +05301692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1693 FL("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 return -EIO;
1695 }
1696
1697 EXIT();
1698
1699 return 0;
1700}
1701
1702static int iw_get_bitrate(struct net_device *dev,
1703 struct iw_request_info *info,
1704 union iwreq_data *wrqu, char *extra)
1705{
1706 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
1707 eHalStatus status = eHAL_STATUS_SUCCESS;
1708 hdd_wext_state_t *pWextState;
1709 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1710 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1711
1712 ENTER();
1713
1714 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1716 return status;
1717 }
1718
1719 if(eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1720 wrqu->bitrate.value = 0;
1721 }
1722 else {
1723 status = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_HDD,
1724 SME_SUMMARY_STATS |
1725 SME_GLOBAL_CLASSA_STATS |
1726 SME_GLOBAL_CLASSB_STATS |
1727 SME_GLOBAL_CLASSC_STATS |
1728 SME_GLOBAL_CLASSD_STATS |
1729 SME_PER_STA_STATS,
1730 hdd_StatisticsCB, 0, FALSE,
1731 pHddStaCtx->conn_info.staId[0], pAdapter );
1732
1733 if(eHAL_STATUS_SUCCESS != status)
1734 {
1735 hddLog(VOS_TRACE_LEVEL_ERROR,
1736 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001737 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 return status;
1739 }
1740
1741 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1742
1743 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
1744
1745 if (!VOS_IS_STATUS_SUCCESS(vos_status))
1746 {
1747 hddLog(VOS_TRACE_LEVEL_ERROR,
1748 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001749 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 return VOS_STATUS_E_FAILURE;
1751 }
1752
1753 wrqu->bitrate.value = pAdapter->hdd_stats.ClassA_stat.tx_rate*500*1000;
1754 }
1755
1756 EXIT();
1757
1758 return vos_status;
1759}
1760/* ccm call back function */
1761
1762static int iw_set_bitrate(struct net_device *dev,
1763 struct iw_request_info *info,
1764 union iwreq_data *wrqu,
1765 char *extra)
1766{
1767 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1768 hdd_wext_state_t *pWextState;
1769 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1770 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
1771 v_U32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1772 v_U32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1773 v_U32_t i, rate;
1774 v_U32_t valid_rate = FALSE, active_phy_mode = 0;
1775
1776 ENTER();
1777
1778 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1779 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1780 return 0;
1781 }
1782
1783 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1784
1785 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
1786 {
1787 return -ENXIO ;
1788 }
1789
1790 rate = wrqu->bitrate.value;
1791
1792 if (rate == -1)
1793 {
1794 rate = WNI_CFG_FIXED_RATE_AUTO;
1795 valid_rate = TRUE;
1796 }
1797 else if (ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1798 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
1799 {
1800 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G
1801 || active_phy_mode == WNI_CFG_DOT11_MODE_11B)
1802 {
1803 if ((ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1804 WNI_CFG_SUPPORTED_RATES_11A,
1805 supp_rates, &a_len) == eHAL_STATUS_SUCCESS) &&
1806 (ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
1807 WNI_CFG_SUPPORTED_RATES_11B,
1808 supp_rates, &b_len) == eHAL_STATUS_SUCCESS))
1809 {
1810 for (i = 0; i < (b_len + a_len); ++i)
1811 {
1812 /* supported rates returned is double the actual rate so we divide it by 2 */
1813 if ((supp_rates[i]&0x7F)/2 == rate)
1814 {
1815 valid_rate = TRUE;
1816 rate = i + WNI_CFG_FIXED_RATE_1MBPS;
1817 break;
1818 }
1819 }
1820 }
1821 }
1822 }
1823 if (valid_rate != TRUE)
1824 {
1825 return -EINVAL;
1826 }
1827 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
1828 WNI_CFG_FIXED_RATE, rate,
1829 ccmCfgSetCallback,eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS)
1830 {
c_hpothub8245442013-11-20 23:41:09 +05301831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1832 FL("failed to set ini parameter, WNI_CFG_FIXED_RATE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 return -EIO;
1834 }
1835 return 0;
1836}
1837
1838
1839static int iw_set_genie(struct net_device *dev,
1840 struct iw_request_info *info,
1841 union iwreq_data *wrqu,
1842 char *extra)
1843{
1844 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1845 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Arif Hussain24bfa702014-01-22 13:51:30 -08001846 u_int8_t *genie = NULL;
1847 u_int8_t *base_genie = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 v_U16_t remLen;
1849
1850 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001851
1852 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08001853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1854 "%s:LOGP in Progress. Ignore!!!", __func__);
1855 return 0;
1856 }
1857
1858 if (!wrqu->data.length) {
1859 hdd_clearRoamProfileIe(pAdapter);
1860 EXIT();
1861 return 0;
1862 }
1863
1864 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
1865 wrqu->data.length);
1866 if (NULL == base_genie)
1867 {
1868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1869 "mem_alloc_copy_from_user_helper fail");
1870 return -ENOMEM;
1871 }
1872
1873 genie = base_genie;
Jeff Johnson295189b2012-06-20 16:38:30 -07001874
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 remLen = wrqu->data.length;
1876
Arif Hussain6d2a3322013-11-17 19:50:10 -08001877 hddLog(LOG1,"iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0], genie[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001878
1879 /* clear any previous genIE before this call */
1880 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
1881
1882 while (remLen >= 2)
1883 {
1884 v_U16_t eLen = 0;
1885 v_U8_t elementId;
1886 elementId = *genie++;
1887 eLen = *genie++;
1888 remLen -= 2;
1889
Arif Hussain6d2a3322013-11-17 19:50:10 -08001890 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 __func__, elementId, eLen);
1892
1893 switch ( elementId )
1894 {
1895 case IE_EID_VENDOR:
1896 if ((IE_LEN_SIZE+IE_EID_SIZE+IE_VENDOR_OUI_SIZE) > eLen) /* should have at least OUI */
Arif Hussain24bfa702014-01-22 13:51:30 -08001897 {
1898 kfree(base_genie);
1899 return -EINVAL;
1900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001901
1902 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
1903 {
1904 v_U16_t curGenIELen = pWextState->genIE.length;
1905 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
1906 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1907
1908 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1909 {
1910 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001911 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001913 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 return -ENOMEM;
1915 }
1916 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1917 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1918 pWextState->genIE.length += eLen + 2;
1919 }
1920 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
1921 {
1922 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
1923 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1924 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1925 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
1926 pWextState->roamProfile.nWPAReqIELength = eLen + 2;
1927 }
1928 else /* any vendorId except WPA IE should be accumulated to genIE */
1929 {
1930 v_U16_t curGenIELen = pWextState->genIE.length;
1931 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OUI(%02x %02x %02x %02x) IE(len %d)",
1932 __func__, genie[0], genie[1], genie[2], genie[3], eLen + 2);
1933
1934 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->genIE.length + eLen) )
1935 {
1936 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate genIE. "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001937 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 VOS_ASSERT(0);
Arif Hussain24bfa702014-01-22 13:51:30 -08001939 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 return -ENOMEM;
1941 }
1942 // save to Additional IE ; it should be accumulated to handle WPS IE + other IE
1943 memcpy( pWextState->genIE.addIEdata + curGenIELen, genie - 2, eLen + 2);
1944 pWextState->genIE.length += eLen + 2;
1945 }
1946 break;
1947 case DOT11F_EID_RSN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001948 hddLog (LOG1, "%s Set RSN IE (len %d)",__func__, eLen+2);
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
1950 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2));
1951 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
1952 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
1953 break;
1954
1955 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001956 hddLog (LOGE, "%s Set UNKNOWN IE %X",__func__, elementId);
Arif Hussain24bfa702014-01-22 13:51:30 -08001957 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 return 0;
1959 }
1960 genie += eLen;
1961 remLen -= eLen;
1962 }
1963 EXIT();
Arif Hussain24bfa702014-01-22 13:51:30 -08001964 kfree(base_genie);
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 return 0;
1966}
1967
1968static int iw_get_genie(struct net_device *dev,
1969 struct iw_request_info *info,
1970 union iwreq_data *wrqu,
1971 char *extra)
1972{
1973 hdd_wext_state_t *pWextState;
1974 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1975 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1976 eHalStatus status;
1977 v_U32_t length = DOT11F_IE_RSN_MAX_LEN;
1978 v_U8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
1979
1980 ENTER();
1981
1982 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
1983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1984 return 0;
1985 }
1986
1987
Arif Hussain6d2a3322013-11-17 19:50:10 -08001988 hddLog(LOG1,"getGEN_IE ioctl");
Jeff Johnson295189b2012-06-20 16:38:30 -07001989
1990 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1991
1992 if( pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
1993 {
1994 return -ENXIO;
1995 }
1996
1997 // Return something ONLY if we are associated with an RSN or WPA network
1998 if ( VOS_TRUE != hdd_IsAuthTypeRSN(WLAN_HDD_GET_HAL_CTX(pAdapter),
1999 pWextState->roamProfile.negotiatedAuthType))
2000 {
2001 return -ENXIO;
2002 }
2003
2004 // Actually retrieve the RSN IE from CSR. (We previously sent it down in the CSR Roam Profile.)
2005 status = csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2006 pAdapter->sessionId,
2007 &length,
2008 genIeBytes);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002009 length = VOS_MIN((u_int16_t) length, DOT11F_IE_RSN_MAX_LEN);
2010 if (wrqu->data.length < length)
2011 {
2012 hddLog(LOG1, "%s: failed to copy data to user buffer", __func__);
2013 return -EFAULT;
2014 }
Arif Hussain9f05be02014-02-05 12:06:53 -08002015 vos_mem_copy( extra, (v_VOID_t*)genIeBytes, length);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002016 wrqu->data.length = length;
Jeff Johnson295189b2012-06-20 16:38:30 -07002017
Arif Hussain6d2a3322013-11-17 19:50:10 -08002018 hddLog(LOG1,"%s: RSN IE of %d bytes returned", __func__, wrqu->data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07002019
2020 EXIT();
2021
2022 return 0;
2023}
2024
2025static int iw_get_encode(struct net_device *dev,
2026 struct iw_request_info *info,
2027 struct iw_point *dwrq, char *extra)
2028{
2029 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2030 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2031 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2032 int keyId;
2033 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
2034 int i;
2035
2036 ENTER();
2037
2038 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress) {
2039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
2040 return 0;
2041 }
2042
2043 keyId = pRoamProfile->Keys.defaultIndex;
2044
2045 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
2046 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002047 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 return -EINVAL;
2049 }
2050
2051 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
2052 {
2053 dwrq->flags |= IW_ENCODE_ENABLED;
2054 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
2055 vos_mem_copy(extra,&(pRoamProfile->Keys.KeyMaterial[keyId][0]),pRoamProfile->Keys.KeyLength[keyId]);
2056
2057 dwrq->flags |= (keyId + 1);
2058
2059 }
2060 else
2061 {
2062 dwrq->flags |= IW_ENCODE_DISABLED;
2063 }
2064
2065 for(i=0; i < MAX_WEP_KEYS; i++)
2066 {
2067 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
2068 {
2069 continue;
2070 }
2071 else
2072 {
2073 break;
2074 }
2075 }
2076
2077 if(MAX_WEP_KEYS == i)
2078 {
2079 dwrq->flags |= IW_ENCODE_NOKEY;
2080 }
2081
2082 authType = ((hdd_station_ctx_t*)WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2083
2084 if(eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
2085 {
2086 dwrq->flags |= IW_ENCODE_OPEN;
2087 }
2088 else
2089 {
2090 dwrq->flags |= IW_ENCODE_RESTRICTED;
2091 }
2092 EXIT();
2093 return 0;
2094}
2095
2096#define PAE_ROLE_AUTHENTICATOR 1 // =1 for authenticator,
2097#define PAE_ROLE_SUPPLICANT 0 // =0 for supplicant
2098
2099
2100/*
2101 * This function sends a single 'key' to LIM at all time.
2102 */
2103
2104static int iw_get_rts_threshold(struct net_device *dev,
2105 struct iw_request_info *info,
2106 union iwreq_data *wrqu, char *extra)
2107{
2108 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2109 v_U32_t status = 0;
2110
2111 status = hdd_wlan_get_rts_threshold(pAdapter,wrqu);
2112
2113 return status;
2114}
2115
2116static int iw_set_rts_threshold(struct net_device *dev,
2117 struct iw_request_info *info,
2118 union iwreq_data *wrqu, char *extra)
2119{
2120 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2121 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2122
2123 ENTER();
2124
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002125 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2126 {
2127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2128 "%s:LOGP in Progress. Ignore!!!", __func__);
2129 return -EAGAIN;
2130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 if ( wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX )
2132 {
2133 return -EINVAL;
2134 }
2135
2136 if ( ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2137 {
c_hpothub8245442013-11-20 23:41:09 +05302138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2139 FL("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 return -EIO;
2141 }
2142
2143 EXIT();
2144
2145 return 0;
2146}
2147
2148static int iw_get_frag_threshold(struct net_device *dev,
2149 struct iw_request_info *info,
2150 union iwreq_data *wrqu, char *extra)
2151{
2152 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2153 v_U32_t status = 0;
2154
2155 status = hdd_wlan_get_frag_threshold(pAdapter,wrqu);
2156
2157 return status;
2158}
2159
2160static int iw_set_frag_threshold(struct net_device *dev,
2161 struct iw_request_info *info,
2162 union iwreq_data *wrqu, char *extra)
2163{
2164 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2165 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2166
2167 ENTER();
2168
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002169 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2170 {
2171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2172 "%s:LOGP in Progress. Ignore!!!", __func__);
2173 return -EBUSY;
2174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 if ( wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX )
2176 {
2177 return -EINVAL;
2178 }
2179
2180 if ( ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
2181 {
c_hpothub8245442013-11-20 23:41:09 +05302182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2183 FL("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 return -EIO;
2185 }
2186
2187 EXIT();
2188
2189 return 0;
2190}
2191
2192static int iw_get_power_mode(struct net_device *dev,
2193 struct iw_request_info *info,
2194 union iwreq_data *wrqu, char *extra)
2195{
2196 ENTER();
2197 return -EOPNOTSUPP;
2198}
2199
2200static int iw_set_power_mode(struct net_device *dev,
2201 struct iw_request_info *info,
2202 union iwreq_data *wrqu, char *extra)
2203{
2204 ENTER();
2205 return -EOPNOTSUPP;
2206}
2207
2208static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
2209 union iwreq_data *wrqu, char *extra)
2210{
2211 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2212 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2213 struct iw_range *range = (struct iw_range *) extra;
2214
2215 v_U8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2216
2217 v_U32_t num_channels = sizeof(channels);
2218 v_U8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2219 v_U32_t a_len;
2220 v_U32_t b_len;
2221 v_U32_t active_phy_mode = 0;
2222 v_U8_t index = 0, i;
2223
2224 ENTER();
2225
2226 wrqu->data.length = sizeof(struct iw_range);
2227 memset(range, 0, sizeof(struct iw_range));
2228
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002229 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2230 {
2231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2232 "%s:LOGP in Progress. Ignore!!!", __func__);
2233 return -EBUSY;
2234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002235
2236 /*Get the phy mode*/
2237 if (ccmCfgGetInt(hHal,
2238 WNI_CFG_DOT11_MODE, &active_phy_mode) == eHAL_STATUS_SUCCESS)
2239 {
2240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002241 "active_phy_mode = %d", active_phy_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002242
2243 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A || active_phy_mode == WNI_CFG_DOT11_MODE_11G)
2244 {
2245 /*Get the supported rates for 11G band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002246 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 if (ccmCfgGetStr(hHal,
2248 WNI_CFG_SUPPORTED_RATES_11A,
2249 supp_rates, &a_len) == eHAL_STATUS_SUCCESS)
2250 {
2251 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
2252 {
2253 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2254 }
2255 for (i = 0; i < a_len; i++)
2256 {
2257 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2258 }
2259 range->num_bitrates = a_len;
2260 }
2261 else
2262 {
2263 return -EIO;
2264 }
2265 }
2266 else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B)
2267 {
2268 /*Get the supported rates for 11B band*/
Jeff Johnson1611e582013-04-03 10:43:16 -07002269 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 if (ccmCfgGetStr(hHal,
2271 WNI_CFG_SUPPORTED_RATES_11B,
2272 supp_rates, &b_len) == eHAL_STATUS_SUCCESS)
2273 {
2274 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
2275 {
2276 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2277 }
2278 for (i = 0; i < b_len; i++)
2279 {
2280 range->bitrate[i] = ((supp_rates[i] & 0x7F) / 2) * 1000000;
2281 }
2282 range->num_bitrates = b_len;
2283 }
2284 else
2285 {
2286 return -EIO;
2287 }
2288 }
2289 }
2290
2291 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
2292 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
2293 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
2294
2295 range->encoding_size[0] = 5;
2296 range->encoding_size[1] = 13;
2297 range->num_encoding_sizes = 2;
2298 range->max_encoding_tokens = MAX_WEP_KEYS;
2299
2300 // we support through Wireless Extensions 22
2301 range->we_version_compiled = WIRELESS_EXT;
2302 range->we_version_source = 22;
2303
2304 /*Supported Channels and Frequencies*/
2305 if (ccmCfgGetStr((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels, &num_channels) != eHAL_STATUS_SUCCESS)
2306 {
c_hpothub8245442013-11-20 23:41:09 +05302307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2308 FL("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 return -EIO;
2310 }
2311 if (num_channels > IW_MAX_FREQUENCIES)
2312 {
2313 num_channels = IW_MAX_FREQUENCIES;
2314 }
2315
2316 range->num_channels = num_channels;
2317 range->num_frequency = num_channels;
2318
2319 for (index=0; index < num_channels; index++)
2320 {
2321 v_U32_t frq_indx = 0;
2322
2323 range->freq[index].i = channels[index];
2324 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE)
2325 {
2326 if(channels[index] == freq_chan_map[frq_indx].chan)
2327 {
2328 range->freq[index].m = freq_chan_map[frq_indx].freq * 100000;
2329 range->freq[index].e = 1;
2330 break;
2331 }
2332 frq_indx++;
2333 }
2334 }
2335
2336 /* Event capability (kernel + driver) */
2337 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
2338 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
2339 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
2340 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2341
2342 /*Encryption capability*/
2343 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
2344 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
2345
2346 /* Txpower capability */
2347 range->txpower_capa = IW_TXPOW_MWATT;
2348
2349 /*Scanning capability*/
2350 #if WIRELESS_EXT >= 22
2351 range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
2352 #endif
2353
2354 EXIT();
2355 return 0;
2356}
2357
2358/* Callback function registered with PMC to know status of PMC request */
2359static void iw_power_callback_fn (void *pContext, eHalStatus status)
2360{
2361 struct statsContext *pStatsContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002362
2363 if (NULL == pContext)
2364 {
2365 hddLog(VOS_TRACE_LEVEL_ERROR,
2366 "%s: Bad param, pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002367 __func__, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 return;
2369 }
2370
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 pStatsContext = (struct statsContext *)pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002372
Jeff Johnson72a40512013-12-19 10:14:15 -08002373 /* there is a race condition that exists between this callback
2374 function and the caller since the caller could time out either
2375 before or while this code is executing. we use a spinlock to
2376 serialize these actions */
2377 spin_lock(&hdd_context_lock);
2378
2379 if (POWER_CONTEXT_MAGIC != pStatsContext->magic)
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 {
2381 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002382 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 hddLog(VOS_TRACE_LEVEL_WARN,
Jeff Johnson72a40512013-12-19 10:14:15 -08002384 "%s: Invalid context, magic [%08x]",
2385 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002386
2387 if (ioctl_debug)
2388 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002389 pr_info("%s: Invalid context, magic [%08x]\n",
2390 __func__, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 }
2392 return;
2393 }
2394
Jeff Johnson72a40512013-12-19 10:14:15 -08002395 /* context is valid so caller is still waiting */
2396
2397 /* paranoia: invalidate the magic */
2398 pStatsContext->magic = 0;
2399
2400 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002402
2403 /* serialization is complete */
2404 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002405}
2406
2407/* Callback function for tx per hit */
2408void hdd_tx_per_hit_cb (void *pCallbackContext)
2409{
2410 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCallbackContext;
2411 unsigned char tx_fail[16];
2412 union iwreq_data wrqu;
2413
Kaushik, Sushantc78ee812014-08-01 12:21:19 +05302414 if (NULL == pAdapter || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08002416 hddLog(LOGE, "hdd_tx_per_hit_cb: pAdapter is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 return;
2418 }
2419 memset(&wrqu, 0, sizeof(wrqu));
2420 wrqu.data.length = strlcpy(tx_fail, "TX_FAIL", sizeof(tx_fail));
2421 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, tx_fail);
2422}
2423
2424void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
2425{
2426 struct statsContext *pStatsContext;
2427 tCsrGlobalClassAStatsInfo *pClassAStats;
2428 hdd_adapter_t *pAdapter;
2429
2430 if (ioctl_debug)
2431 {
2432 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002433 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 }
2435
2436 if ((NULL == pStats) || (NULL == pContext))
2437 {
2438 hddLog(VOS_TRACE_LEVEL_ERROR,
2439 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002440 __func__, pStats, pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 return;
2442 }
2443
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 pClassAStats = pStats;
2445 pStatsContext = pContext;
2446 pAdapter = pStatsContext->pAdapter;
Jeff Johnson72a40512013-12-19 10:14:15 -08002447
2448 /* there is a race condition that exists between this callback
2449 function and the caller since the caller could time out either
2450 before or while this code is executing. we use a spinlock to
2451 serialize these actions */
2452 spin_lock(&hdd_context_lock);
2453
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2455 {
2456 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002457 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 hddLog(VOS_TRACE_LEVEL_WARN,
2459 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002460 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 if (ioctl_debug)
2462 {
2463 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002464 __func__, pAdapter, pStatsContext->magic);
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 }
2466 return;
2467 }
2468
Jeff Johnson72a40512013-12-19 10:14:15 -08002469 /* context is valid so caller is still waiting */
2470
2471 /* paranoia: invalidate the magic */
2472 pStatsContext->magic = 0;
2473
2474 /* copy over the stats. do so as a struct copy */
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2476
Jeff Johnson72a40512013-12-19 10:14:15 -08002477 /* notify the caller */
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002479
2480 /* serialization is complete */
2481 spin_unlock(&hdd_context_lock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002482}
2483
2484VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
2485{
2486 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2487 eHalStatus hstatus;
2488 long lrc;
2489 struct statsContext context;
2490
2491 if (NULL == pAdapter)
2492 {
2493 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2494 return VOS_STATUS_E_FAULT;
2495 }
2496 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
2497 {
2498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:LOGP in Progress. Ignore!!!",__func__);
2499 return VOS_STATUS_SUCCESS;
2500 }
2501
2502 /* we are connected
2503 prepare our callback context */
2504 init_completion(&context.completion);
2505 context.pAdapter = pAdapter;
2506 context.magic = STATS_CONTEXT_MAGIC;
2507 /* query only for Class A statistics (which include link speed) */
2508 hstatus = sme_GetStatistics( WLAN_HDD_GET_HAL_CTX(pAdapter),
2509 eCSR_HDD,
2510 SME_GLOBAL_CLASSA_STATS,
2511 hdd_GetClassA_statisticsCB,
2512 0, // not periodic
2513 FALSE, //non-cached results
2514 pHddStaCtx->conn_info.staId[0],
2515 &context);
2516 if (eHAL_STATUS_SUCCESS != hstatus)
2517 {
2518 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson72a40512013-12-19 10:14:15 -08002519 "%s: Unable to retrieve Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002520 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 /* we'll returned a cached value below */
2522 }
2523 else
2524 {
2525 /* request was sent -- wait for the response */
2526 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2527 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 if (lrc <= 0)
2529 {
2530 hddLog(VOS_TRACE_LEVEL_ERROR,
2531 "%s: SME %s while retrieving Class A statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002532 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 }
2534 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002535
2536 /* either we never sent a request, we sent a request and received a
2537 response or we sent a request and timed out. if we never sent a
2538 request or if we sent a request and got a response, we want to
2539 clear the magic out of paranoia. if we timed out there is a
2540 race condition such that the callback function could be
2541 executing at the same time we are. of primary concern is if the
2542 callback function had already verified the "magic" but had not
2543 yet set the completion variable when a timeout occurred. we
2544 serialize these activities by invalidating the magic while
2545 holding a shared spinlock which will cause us to block if the
2546 callback is currently executing */
2547 spin_lock(&hdd_context_lock);
2548 context.magic = 0;
2549 spin_unlock(&hdd_context_lock);
2550
2551 /* either callback updated pAdapter stats or it has cached data */
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 return VOS_STATUS_SUCCESS;
2553}
2554
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002555static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
2556{
2557 struct statsContext *pStatsContext;
2558 tCsrSummaryStatsInfo *pSummaryStats;
2559 tCsrGlobalClassAStatsInfo *pClassAStats;
2560 hdd_adapter_t *pAdapter;
2561
2562 if (ioctl_debug)
2563 {
2564 pr_info("%s: pStats [%p] pContext [%p]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002565 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002566 }
2567
2568 if ((NULL == pStats) || (NULL == pContext))
2569 {
2570 hddLog(VOS_TRACE_LEVEL_ERROR,
2571 "%s: Bad param, pStats [%p] pContext [%p]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002572 __func__, pStats, pContext);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002573 return;
2574 }
2575
Jeff Johnson72a40512013-12-19 10:14:15 -08002576 /* there is a race condition that exists between this callback
2577 function and the caller since the caller could time out either
2578 before or while this code is executing. we use a spinlock to
2579 serialize these actions */
2580 spin_lock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002581
2582 pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
2583 pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
2584 pStatsContext = pContext;
2585 pAdapter = pStatsContext->pAdapter;
2586 if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic))
2587 {
2588 /* the caller presumably timed out so there is nothing we can do */
Jeff Johnson72a40512013-12-19 10:14:15 -08002589 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002590 hddLog(VOS_TRACE_LEVEL_WARN,
2591 "%s: Invalid context, pAdapter [%p] magic [%08x]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002592 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002593 if (ioctl_debug)
2594 {
2595 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002596 __func__, pAdapter, pStatsContext->magic);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002597 }
2598 return;
2599 }
2600
Jeff Johnson72a40512013-12-19 10:14:15 -08002601 /* context is valid so caller is still waiting */
2602
2603 /* paranoia: invalidate the magic */
2604 pStatsContext->magic = 0;
2605
2606 /* copy over the stats. do so as a struct copy */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002607 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
2608 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
2609
Jeff Johnson72a40512013-12-19 10:14:15 -08002610 /* notify the caller */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002611 complete(&pStatsContext->completion);
Jeff Johnson72a40512013-12-19 10:14:15 -08002612
2613 /* serialization is complete */
2614 spin_unlock(&hdd_context_lock);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002615}
2616
2617VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
2618{
2619 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2620 eHalStatus hstatus;
2621 long lrc;
2622 struct statsContext context;
2623
2624 if (NULL == pAdapter)
2625 {
2626 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Padapter is NULL", __func__);
2627 return VOS_STATUS_SUCCESS;
2628 }
2629
2630 /* we are connected
2631 prepare our callback context */
2632 init_completion(&context.completion);
2633 context.pAdapter = pAdapter;
2634 context.magic = STATS_CONTEXT_MAGIC;
2635
2636 /* query only for Summary & Class A statistics */
2637 hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2638 eCSR_HDD,
2639 SME_SUMMARY_STATS |
2640 SME_GLOBAL_CLASSA_STATS,
2641 hdd_get_station_statisticsCB,
2642 0, // not periodic
2643 FALSE, //non-cached results
2644 pHddStaCtx->conn_info.staId[0],
2645 &context);
2646 if (eHAL_STATUS_SUCCESS != hstatus)
2647 {
2648 hddLog(VOS_TRACE_LEVEL_ERROR,
2649 "%s: Unable to retrieve statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002650 __func__);
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002651 /* we'll return with cached values */
2652 }
2653 else
2654 {
2655 /* request was sent -- wait for the response */
2656 lrc = wait_for_completion_interruptible_timeout(&context.completion,
2657 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
Jeff Johnson72a40512013-12-19 10:14:15 -08002658
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002659 if (lrc <= 0)
2660 {
2661 hddLog(VOS_TRACE_LEVEL_ERROR,
2662 "%s: SME %s while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002663 __func__, (0 == lrc) ? "timeout" : "interrupt");
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002664 }
2665 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002666
2667 /* either we never sent a request, we sent a request and received a
2668 response or we sent a request and timed out. if we never sent a
2669 request or if we sent a request and got a response, we want to
2670 clear the magic out of paranoia. if we timed out there is a
2671 race condition such that the callback function could be
2672 executing at the same time we are. of primary concern is if the
2673 callback function had already verified the "magic" but had not
2674 yet set the completion variable when a timeout occurred. we
2675 serialize these activities by invalidating the magic while
2676 holding a shared spinlock which will cause us to block if the
2677 callback is currently executing */
2678 spin_lock(&hdd_context_lock);
2679 context.magic = 0;
2680 spin_unlock(&hdd_context_lock);
2681
2682 /* either callback updated pAdapter stats or it has cached data */
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07002683 return VOS_STATUS_SUCCESS;
2684}
2685
2686
Jeff Johnson295189b2012-06-20 16:38:30 -07002687/*
2688 * Support for the LINKSPEED private command
2689 * Per the WiFi framework the response must be of the form
2690 * "LinkSpeed xx"
2691 */
2692static int iw_get_linkspeed(struct net_device *dev,
2693 struct iw_request_info *info,
2694 union iwreq_data *wrqu, char *extra)
2695{
2696 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302697 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 char *pLinkSpeed = (char*)extra;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302699 int len = sizeof(v_U32_t) + 1;
2700 v_U32_t link_speed;
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302702 VOS_STATUS status;
2703 int rc, valid;
Jeff Johnson295189b2012-06-20 16:38:30 -07002704
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302705 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2706
2707 valid = wlan_hdd_validate_context(pHddCtx);
2708
2709 if (0 != valid)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002710 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302711 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2712 return valid;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08002713 }
2714
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
2716 {
2717 /* we are not connected so we don't have a classAstats */
2718 link_speed = 0;
2719 }
2720 else
2721 {
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302722 status = wlan_hdd_get_classAstats(pAdapter);
2723
2724 if (!VOS_IS_STATUS_SUCCESS(status ))
2725 {
2726 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve SME statistics"));
2727 return -EINVAL;
2728 }
2729
2730 /* Unit of link capacity is obtained from the TL API is MbpsX10 */
2731 WLANTL_GetSTALinkCapacity(WLAN_HDD_GET_CTX(pAdapter)->pvosContext,
2732 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2733 &link_speed);
2734
2735 link_speed = link_speed / 10;
2736
2737 if (0 == link_speed)
2738 {
2739 /* The linkspeed returned by HAL is in units of 500kbps.
2740 * converting it to mbps.
2741 * This is required to support legacy firmware which does
2742 * not return link capacity.
2743 */
2744 link_speed = pAdapter->hdd_stats.ClassA_stat.tx_rate/2;
2745 }
2746
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 }
2748
2749 wrqu->data.length = len;
2750 // return the linkspeed in the format required by the WiFi Framework
Jeff Johnson02797792013-10-26 19:17:13 -07002751 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
Jeff Johnson295189b2012-06-20 16:38:30 -07002752 if ((rc < 0) || (rc >= len))
2753 {
2754 // encoding or length error?
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05302755 hddLog(VOS_TRACE_LEVEL_ERROR,FL("Unable to encode link speed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 return -EIO;
2757 }
2758
2759 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002760 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002761}
2762
Arif Hussain695279c2014-03-24 14:06:07 -07002763/*
2764 * Helper function to return correct value for WLAN_GET_LINK_SPEED
2765 *
2766 */
2767static int iw_get_linkspeed_priv(struct net_device *dev,
2768 struct iw_request_info *info,
2769 union iwreq_data *wrqu, char *extra)
2770{
2771 int rc;
2772
2773 rc = iw_get_linkspeed(dev, info, wrqu, extra);
2774
2775 if (rc < 0)
2776 return rc;
2777
2778 /* a value is being successfully returned */
2779 return 0;
2780}
Jeff Johnson295189b2012-06-20 16:38:30 -07002781
2782/*
2783 * Support for the RSSI & RSSI-APPROX private commands
2784 * Per the WiFi framework the response must be of the form
2785 * "<ssid> rssi <xx>"
2786 * unless we are not associated, in which case the response is
2787 * "OK"
2788 */
2789static int iw_get_rssi(struct net_device *dev,
2790 struct iw_request_info *info,
2791 union iwreq_data *wrqu, char *extra)
2792{
2793 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08002794 char *cmd = extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 int len = wrqu->data.length;
2796 v_S7_t s7Rssi = 0;
2797 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2798 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
2799 VOS_STATUS vosStatus;
2800 int rc;
2801
2802 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
2803 (0 == ssidlen) || (ssidlen >= len))
2804 {
2805 /* we are not connected or our SSID is too long
2806 so we cannot report an rssi */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002807 rc = scnprintf(cmd, len, "OK");
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 }
2809 else
2810 {
2811 /* we are connected with a valid SSID
2812 so we can write the SSID into the return buffer
2813 (note that it is not NUL-terminated) */
2814 memcpy(cmd, pHddStaCtx->conn_info.SSID.SSID.ssId, ssidlen );
2815
2816 vosStatus = wlan_hdd_get_rssi(pAdapter, &s7Rssi);
2817
2818 if (VOS_STATUS_SUCCESS == vosStatus)
2819 {
2820 /* append the rssi to the ssid in the format required by
2821 the WiFI Framework */
Sameer Thalappilb0a30232013-09-27 15:37:48 -07002822 rc = scnprintf(&cmd[ssidlen], len - ssidlen, " rssi %d", s7Rssi);
c_hpothu72afb282014-02-17 12:55:36 +05302823 rc += ssidlen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 }
2825 else
2826 {
2827 rc = -1;
2828 }
2829 }
2830
2831 /* verify that we wrote a valid response */
2832 if ((rc < 0) || (rc >= len))
2833 {
2834 // encoding or length error?
2835 hddLog(VOS_TRACE_LEVEL_ERROR,
2836 "%s: Unable to encode RSSI, got [%s]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002837 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 return -EIO;
2839 }
2840
2841 /* a value is being successfully returned */
Arif Hussain24bfa702014-01-22 13:51:30 -08002842 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07002843}
2844
2845/*
2846 * Support for SoftAP channel range private command
2847 */
2848static int iw_softap_set_channel_range( struct net_device *dev,
2849 int startChannel,
2850 int endChannel,
2851 int band)
2852{
Jeff Johnson43971f52012-07-17 12:26:56 -07002853 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 int ret = 0;
2855 hdd_adapter_t *pHostapdAdapter = (netdev_priv(dev));
2856 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08002857 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
2858
Jeff Johnson295189b2012-06-20 16:38:30 -07002859
2860 status = WLANSAP_SetChannelRange(hHal, startChannel, endChannel, band);
2861 if (VOS_STATUS_SUCCESS != status)
2862 {
2863 ret = -EINVAL;
2864 }
Yathish9f22e662012-12-10 14:21:35 -08002865 pHddCtx->is_dynamic_channel_range_set = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 return ret;
2867}
2868
2869VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
2870{
2871 struct statsContext context;
2872 eHalStatus status;
2873 hdd_context_t *pHddCtx;
2874
2875 if (NULL == pAdapter)
2876 {
2877 hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL");
2878 return VOS_STATUS_E_FAULT;
2879 }
2880
2881 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode);
2882 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal6cd329b2014-03-19 20:39:13 +05302883 if (pHddCtx->isLogpInProgress) {
2884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2885 "%s:LOGP in Progress. Ignore!!!", __func__);
2886 return VOS_STATUS_E_FAILURE;
2887 }
2888
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 init_completion(&context.completion);
2890
2891 context.pAdapter = pAdapter;
2892 context.magic = POWER_CONTEXT_MAGIC;
2893
2894 if (DRIVER_POWER_MODE_ACTIVE == mode)
2895 {
2896 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering "
2897 "Full Power", __func__);
2898 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2899 iw_power_callback_fn, &context,
2900 eSME_FULL_PWR_NEEDED_BY_HDD);
2901 // Enter Full power command received from GUI this means we are disconnected
2902 // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC
2903 sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE);
2904 if (eHAL_STATUS_PMC_PENDING == status)
2905 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002906 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 int lrc = wait_for_completion_interruptible_timeout(
2908 &context.completion,
2909 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08002910
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 if (lrc <= 0)
2912 {
2913 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while requesting fullpower ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002914 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 }
2916 }
2917 }
2918 else if (DRIVER_POWER_MODE_AUTO == mode)
2919 {
2920 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2921 {
2922 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ",
2923 __func__);
2924 // Enter BMPS command received from GUI this means DHCP is completed
2925 // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry
2926 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter),
2927 FALSE);
2928 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
2929 iw_power_callback_fn, &context);
2930 if (eHAL_STATUS_PMC_PENDING == status)
2931 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002932 /* request was sent -- wait for the response */
Jeff Johnson295189b2012-06-20 16:38:30 -07002933 int lrc = wait_for_completion_interruptible_timeout(
2934 &context.completion,
2935 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002936 if (lrc <= 0)
2937 {
Jeff Johnson72a40512013-12-19 10:14:15 -08002938 hddLog(VOS_TRACE_LEVEL_ERROR,
2939 "%s: SME %s while requesting BMPS",
2940 __func__, (0 == lrc) ? "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 }
2942 }
2943 }
2944 else
2945 {
2946 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not "
2947 "enabled in the cfg");
2948 }
2949 }
Jeff Johnson72a40512013-12-19 10:14:15 -08002950
2951 /* either we never sent a request, we sent a request and received a
2952 response or we sent a request and timed out. if we never sent a
2953 request or if we sent a request and got a response, we want to
2954 clear the magic out of paranoia. if we timed out there is a
2955 race condition such that the callback function could be
2956 executing at the same time we are. of primary concern is if the
2957 callback function had already verified the "magic" but had not
2958 yet set the completion variable when a timeout occurred. we
2959 serialize these activities by invalidating the magic while
2960 holding a shared spinlock which will cause us to block if the
2961 callback is currently executing */
2962 spin_lock(&hdd_context_lock);
2963 context.magic = 0;
2964 spin_unlock(&hdd_context_lock);
2965
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 return VOS_STATUS_SUCCESS;
2967}
2968
2969VOS_STATUS wlan_hdd_exit_lowpower(hdd_context_t *pHddCtx,
2970 hdd_adapter_t *pAdapter)
2971{
2972 VOS_STATUS vos_Status;
2973
2974 if ((NULL == pAdapter) || (NULL == pHddCtx))
2975 {
2976 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid pointer");
2977 return VOS_STATUS_E_FAULT;
2978 }
2979
2980 /**Exit from Deep sleep or standby if we get the driver
2981 START cmd from android GUI
2982 */
2983 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
2984 {
2985 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2986 "from Stand by",__func__);
2987 vos_Status = hdd_exit_standby(pHddCtx);
2988 }
2989 else if (eHDD_SUSPEND_DEEP_SLEEP == pHddCtx->hdd_ps_state)
2990 {
2991 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: WLAN being exit "
2992 "from deep sleep",__func__);
2993 vos_Status = hdd_exit_deep_sleep(pHddCtx, pAdapter);
2994 }
2995 else
2996 {
2997 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Not in standby or deep sleep. "
2998 "Ignore start cmd %d", __func__, pHddCtx->hdd_ps_state);
2999 vos_Status = VOS_STATUS_SUCCESS;
3000 }
3001
3002 return vos_Status;
3003}
3004
3005VOS_STATUS wlan_hdd_enter_lowpower(hdd_context_t *pHddCtx)
3006{
3007 VOS_STATUS vos_Status = VOS_STATUS_E_FAILURE;
3008
3009 if (NULL == pHddCtx)
3010 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303011 hddLog(VOS_TRACE_LEVEL_ERROR, "HDD context NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 return VOS_STATUS_E_FAULT;
3013 }
3014
3015 if (WLAN_MAP_DRIVER_STOP_TO_STANDBY == pHddCtx->cfg_ini->nEnableDriverStop)
3016 {
3017 //Execute standby procedure.
3018 //Executing standby procedure will cause the STA to
3019 //disassociate first and then the chip will be put into standby.
3020 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering Stand by mode");
3021 vos_Status = hdd_enter_standby(pHddCtx);
3022 }
3023 else if (WLAN_MAP_DRIVER_STOP_TO_DEEP_SLEEP ==
3024 pHddCtx->cfg_ini->nEnableDriverStop)
3025 {
3026 //Execute deep sleep procedure
3027 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Wlan driver entering "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003028 "deep sleep mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 //Deep sleep not supported
3030 vos_Status = hdd_enter_standby(pHddCtx);
3031 }
3032 else
3033 {
3034 hddLog(VOS_TRACE_LEVEL_INFO_LOW, "%s: Driver stop is not enabled %d",
3035 __func__, pHddCtx->cfg_ini->nEnableDriverStop);
3036 vos_Status = VOS_STATUS_SUCCESS;
3037 }
3038
3039 return vos_Status;
3040}
3041
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003042
3043void* wlan_hdd_change_country_code_callback(void *pAdapter)
3044{
3045
3046 hdd_adapter_t *call_back_pAdapter = pAdapter;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003047 complete(&call_back_pAdapter->change_country_code);
3048
3049 return NULL;
3050}
3051
Jeff Johnson295189b2012-06-20 16:38:30 -07003052static int iw_set_priv(struct net_device *dev,
3053 struct iw_request_info *info,
3054 union iwreq_data *wrqu, char *extra)
3055{
3056 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain24bfa702014-01-22 13:51:30 -08003057 char *cmd = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 int cmd_len = wrqu->data.length;
3059 int ret = 0;
Arif Hussain24bfa702014-01-22 13:51:30 -08003060 int rc = 0;
3061 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
3062
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3064
3065 ENTER();
Arif Hussain24bfa702014-01-22 13:51:30 -08003066 cmd = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3067 wrqu->data.length);
3068 if (NULL == cmd)
3069 {
3070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3071 "mem_alloc_copy_from_user_helper fail");
3072 return -ENOMEM;
3073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003074
3075 if (ioctl_debug)
3076 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003077 pr_info("%s: req [%s] len [%d]\n", __func__, cmd, cmd_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 }
3079
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003080 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3081 "%s: ***Received %s cmd from Wi-Fi GUI***", __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003082
3083 if (pHddCtx->isLogpInProgress) {
Arif Hussain24bfa702014-01-22 13:51:30 -08003084 if (ioctl_debug)
3085 {
3086 pr_info("%s: RESTART in progress\n", __func__);
3087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003088
Arif Hussain24bfa702014-01-22 13:51:30 -08003089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 "%s:LOGP in Progress. Ignore!!!",__func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003091 kfree(cmd);
3092 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 }
3094
Arif Hussain24bfa702014-01-22 13:51:30 -08003095 if (strncmp(cmd, "CSCAN", 5) == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003097 if (eHAL_STATUS_SUCCESS != iw_set_cscan(dev, info, wrqu, cmd)) {
3098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3099 "%s: Error in iw_set_scan!", __func__);
3100 rc = -EINVAL;
3101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 }
3103 else if( strcasecmp(cmd, "start") == 0 ) {
3104
Arif Hussain6d2a3322013-11-17 19:50:10 -08003105 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 /*Exit from Deep sleep or standby if we get the driver START cmd from android GUI*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003107
Arif Hussain24bfa702014-01-22 13:51:30 -08003108 vos_status = wlan_hdd_exit_lowpower(pHddCtx, pAdapter);
3109 if (vos_status == VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 {
3111 union iwreq_data wrqu;
3112 char buf[10];
3113
3114 memset(&wrqu, 0, sizeof(wrqu));
3115 wrqu.data.length = strlcpy(buf, "START", sizeof(buf));
3116 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3117 }
3118 else
3119 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003120 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: START CMD Status %d", __func__, vos_status);
3121 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 }
3123 goto done;
3124 }
3125 else if( strcasecmp(cmd, "stop") == 0 )
3126 {
3127 union iwreq_data wrqu;
3128 char buf[10];
3129
Arif Hussain6d2a3322013-11-17 19:50:10 -08003130 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003131
3132 wlan_hdd_enter_lowpower(pHddCtx);
3133 memset(&wrqu, 0, sizeof(wrqu));
3134 wrqu.data.length = strlcpy(buf, "STOP", sizeof(buf));
3135 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 goto done;
3137 }
3138 else if (strcasecmp(cmd, "macaddr") == 0)
3139 {
3140 ret = snprintf(cmd, cmd_len, "Macaddr = " MAC_ADDRESS_STR,
3141 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes));
3142 }
3143 else if (strcasecmp(cmd, "scan-active") == 0)
3144 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303145 hddLog(VOS_TRACE_LEVEL_ERROR,
3146 FL("making default scan to active"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003147 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 ret = snprintf(cmd, cmd_len, "OK");
3149 }
3150 else if (strcasecmp(cmd, "scan-passive") == 0)
3151 {
c_hpothudbefd3e2014-04-28 15:59:47 +05303152 hddLog(VOS_TRACE_LEVEL_ERROR,
3153 FL("making default scan to passive"));
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003154 pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 ret = snprintf(cmd, cmd_len, "OK");
3156 }
3157 else if( strcasecmp(cmd, "scan-mode") == 0 )
3158 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003159 ret = snprintf(cmd, cmd_len, "ScanMode = %u", pHddCtx->scan_info.scan_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 }
3161 else if( strcasecmp(cmd, "linkspeed") == 0 )
3162 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003163 ret = iw_get_linkspeed(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 }
3165 else if( strncasecmp(cmd, "COUNTRY", 7) == 0 ) {
3166 char *country_code;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003167 long lrc;
Arif Hussain24bfa702014-01-22 13:51:30 -08003168 eHalStatus eHal_status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003169
3170 country_code = cmd + 8;
3171
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003172 init_completion(&pAdapter->change_country_code);
3173
Arif Hussain24bfa702014-01-22 13:51:30 -08003174 eHal_status = sme_ChangeCountryCode(pHddCtx->hHal,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003175 (void *)(tSmeChangeCountryCallback)wlan_hdd_change_country_code_callback,
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 country_code,
3177 pAdapter,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303178 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05303179 eSIR_TRUE,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05303180 eSIR_TRUE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003181
3182 /* Wait for completion */
3183 lrc = wait_for_completion_interruptible_timeout(&pAdapter->change_country_code,
3184 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3185
3186 if (lrc <= 0)
3187 {
3188 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting country code ",
Arif Hussain24bfa702014-01-22 13:51:30 -08003189 __func__, "Timed out");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003190 }
3191
Arif Hussain24bfa702014-01-22 13:51:30 -08003192 if (eHAL_STATUS_SUCCESS != eHal_status)
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003194 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bfa702014-01-22 13:51:30 -08003195 "%s: SME Change Country code fail", __func__);
3196 kfree(cmd);
3197 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 }
3199 }
3200 else if( strncasecmp(cmd, "rssi", 4) == 0 )
3201 {
Arif Hussain24bfa702014-01-22 13:51:30 -08003202 ret = iw_get_rssi(dev, info, wrqu, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 }
3204 else if( strncasecmp(cmd, "powermode", 9) == 0 ) {
3205 int mode;
Wilson Yang1be3e652013-10-09 15:18:31 -07003206 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003207
Wilson Yang1be3e652013-10-09 15:18:31 -07003208 if (9 < cmd_len)
3209 {
3210 ptr = (char*)(cmd + 9);
3211
3212 }else{
3213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3214 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003215 kfree(cmd);
3216 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003217 }
3218
3219 if (1 != sscanf(ptr,"%d",&mode))
3220 {
3221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3222 "powermode input %s is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003223 kfree(cmd);
3224 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003225 }
3226
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 wlan_hdd_enter_bmps(pAdapter, mode);
3228 /*TODO:Set the power mode*/
3229 }
3230 else if (strncasecmp(cmd, "getpower", 8) == 0 ) {
3231 v_U32_t pmc_state;
3232 v_U16_t value;
3233
3234 pmc_state = pmcGetPmcState(WLAN_HDD_GET_HAL_CTX(pAdapter));
3235 if(pmc_state == BMPS) {
3236 value = DRIVER_POWER_MODE_AUTO;
3237 }
3238 else {
3239 value = DRIVER_POWER_MODE_ACTIVE;
3240 }
3241 ret = snprintf(cmd, cmd_len, "powermode = %u", value);
3242 }
3243 else if( strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003244 hddLog( VOS_TRACE_LEVEL_INFO, "btcoexmode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 /*TODO: set the btcoexmode*/
3246 }
3247 else if( strcasecmp(cmd, "btcoexstat") == 0 ) {
3248
Arif Hussain6d2a3322013-11-17 19:50:10 -08003249 hddLog(VOS_TRACE_LEVEL_INFO, "BtCoex Status");
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 /*TODO: Return the btcoex status*/
3251 }
3252 else if( strcasecmp(cmd, "rxfilter-start") == 0 ) {
3253
Arif Hussain6d2a3322013-11-17 19:50:10 -08003254 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Start command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003255
3256 /*TODO: Enable Rx data Filter*/
3257 }
3258 else if( strcasecmp(cmd, "rxfilter-stop") == 0 ) {
3259
Arif Hussain6d2a3322013-11-17 19:50:10 -08003260 hddLog(VOS_TRACE_LEVEL_INFO, "Rx Data Filter Stop command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003261
3262 /*TODO: Disable Rx data Filter*/
3263 }
3264 else if( strcasecmp(cmd, "rxfilter-statistics") == 0 ) {
3265
Arif Hussain6d2a3322013-11-17 19:50:10 -08003266 hddLog( VOS_TRACE_LEVEL_INFO, "Rx Data Filter Statistics command");
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 /*TODO: rxfilter-statistics*/
3268 }
3269 else if( strncasecmp(cmd, "rxfilter-add", 12) == 0 ) {
3270
Arif Hussain6d2a3322013-11-17 19:50:10 -08003271 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-add");
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 /*TODO: rxfilter-add*/
3273 }
3274 else if( strncasecmp(cmd, "rxfilter-remove",15) == 0 ) {
3275
Arif Hussain6d2a3322013-11-17 19:50:10 -08003276 hddLog( VOS_TRACE_LEVEL_INFO, "rxfilter-remove");
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 /*TODO: rxfilter-remove*/
3278 }
3279#ifdef FEATURE_WLAN_SCAN_PNO
Madan Mohan Koyyalamudi03978e12012-10-30 17:52:55 -07003280 else if( strncasecmp(cmd, "pnosetup", 8) == 0 ) {
3281 hddLog( VOS_TRACE_LEVEL_INFO, "pnosetup");
3282 /*TODO: support pnosetup*/
3283 }
3284 else if( strncasecmp(cmd, "pnoforce", 8) == 0 ) {
3285 hddLog( VOS_TRACE_LEVEL_INFO, "pnoforce");
3286 /*TODO: support pnoforce*/
3287 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 else if( strncasecmp(cmd, "pno",3) == 0 ) {
3289
Arif Hussain6d2a3322013-11-17 19:50:10 -08003290 hddLog( VOS_TRACE_LEVEL_INFO, "pno");
Arif Hussain24bfa702014-01-22 13:51:30 -08003291 vos_status = iw_set_pno(dev, info, wrqu, cmd, 3);
3292 kfree(cmd);
3293 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 }
3295 else if( strncasecmp(cmd, "rssifilter",10) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003296 hddLog( VOS_TRACE_LEVEL_INFO, "rssifilter");
Arif Hussain24bfa702014-01-22 13:51:30 -08003297 vos_status = iw_set_rssi_filter(dev, info, wrqu, cmd, 10);
3298 kfree(cmd);
3299 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 }
3301#endif /*FEATURE_WLAN_SCAN_PNO*/
3302 else if( strncasecmp(cmd, "powerparams",11) == 0 ) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003303 hddLog( VOS_TRACE_LEVEL_INFO, "powerparams");
Arif Hussain24bfa702014-01-22 13:51:30 -08003304 vos_status = iw_set_power_params(dev, info, wrqu, cmd, 11);
3305 kfree(cmd);
3306 return (vos_status == VOS_STATUS_SUCCESS) ? 0 : -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 }
3308 else if( 0 == strncasecmp(cmd, "CONFIG-TX-TRACKING", 18) ) {
3309 tSirTxPerTrackingParam tTxPerTrackingParam;
Wilson Yang1be3e652013-10-09 15:18:31 -07003310 char *ptr;
3311
3312 if (18 < cmd_len)
3313 {
3314 ptr = (char*)(cmd + 18);
3315 }else{
3316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3317 "CMD LENGTH %d is not correct",cmd_len);
Arif Hussain24bfa702014-01-22 13:51:30 -08003318 kfree(cmd);
3319 return -EINVAL;
Wilson Yang1be3e652013-10-09 15:18:31 -07003320 }
3321
Jeff Johnson02797792013-10-26 19:17:13 -07003322 if (4 != sscanf(ptr,"%hhu %hhu %hhu %u",
Wilson Yang1be3e652013-10-09 15:18:31 -07003323 &(tTxPerTrackingParam.ucTxPerTrackingEnable),
3324 &(tTxPerTrackingParam.ucTxPerTrackingPeriod),
3325 &(tTxPerTrackingParam.ucTxPerTrackingRatio),
3326 &(tTxPerTrackingParam.uTxPerTrackingWatermark)))
3327 {
3328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3329 "CONFIG-TX-TRACKING %s input is not correct",ptr);
Arif Hussain24bfa702014-01-22 13:51:30 -08003330 kfree(cmd);
3331 return -EIO;
Wilson Yang1be3e652013-10-09 15:18:31 -07003332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003333
3334 // parameters checking
3335 // period has to be larger than 0
3336 if (0 == tTxPerTrackingParam.ucTxPerTrackingPeriod)
3337 {
3338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Period input is not correct");
Arif Hussain24bfa702014-01-22 13:51:30 -08003339 kfree(cmd);
3340 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 }
3342
3343 // use default value 5 is the input is not reasonable. in unit of 10%
3344 if ((tTxPerTrackingParam.ucTxPerTrackingRatio > TX_PER_TRACKING_MAX_RATIO) || (0 == tTxPerTrackingParam.ucTxPerTrackingRatio))
3345 {
3346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Ratio input is not good. use default 5");
3347 tTxPerTrackingParam.ucTxPerTrackingRatio = TX_PER_TRACKING_DEFAULT_RATIO;
3348 }
3349
3350 // default is 5
3351 if (0 == tTxPerTrackingParam.uTxPerTrackingWatermark)
3352 {
3353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx Packet number input is not good. use default 5");
3354 tTxPerTrackingParam.uTxPerTrackingWatermark = TX_PER_TRACKING_DEFAULT_WATERMARK;
3355 }
3356
Arif Hussain24bfa702014-01-22 13:51:30 -08003357 if (eHAL_STATUS_SUCCESS !=
3358 sme_SetTxPerTracking(pHddCtx->hHal,
3359 hdd_tx_per_hit_cb,
3360 (void*)pAdapter, &tTxPerTrackingParam)) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Set Tx PER Tracking Failed!");
Arif Hussain24bfa702014-01-22 13:51:30 -08003362 rc = -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 }
3364 }
3365 else {
Madan Mohan Koyyalamudif9bdd4e2012-10-30 18:05:03 -07003366 hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s",
3367 __func__, cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 }
3369done:
3370 /* many of the commands write information back into the command
3371 string using snprintf(). check the return value here in one
3372 place */
3373 if ((ret < 0) || (ret >= cmd_len))
3374 {
3375 /* there was an encoding error or overflow */
Arif Hussain24bfa702014-01-22 13:51:30 -08003376 rc = -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 }
Arif Hussain7adce1b2013-11-11 22:59:34 -08003378 else if (ret > 0)
3379 {
3380 if (copy_to_user(wrqu->data.pointer, cmd, ret))
3381 {
3382 hddLog(VOS_TRACE_LEVEL_ERROR,
3383 "%s: failed to copy data to user buffer", __func__);
Arif Hussain24bfa702014-01-22 13:51:30 -08003384 kfree(cmd);
Arif Hussain7adce1b2013-11-11 22:59:34 -08003385 return -EFAULT;
3386 }
3387 wrqu->data.length = ret;
3388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003389
3390 if (ioctl_debug)
3391 {
3392 pr_info("%s: rsp [%s] len [%d] status %d\n",
Arif Hussain24bfa702014-01-22 13:51:30 -08003393 __func__, cmd, wrqu->data.length, rc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 }
Arif Hussain24bfa702014-01-22 13:51:30 -08003395 kfree(cmd);
3396 return rc;
Jeff Johnson295189b2012-06-20 16:38:30 -07003397}
3398
3399static int iw_set_nick(struct net_device *dev,
3400 struct iw_request_info *info,
3401 union iwreq_data *wrqu, char *extra)
3402{
3403 ENTER();
3404 return 0;
3405}
3406
3407static int iw_get_nick(struct net_device *dev,
3408 struct iw_request_info *info,
3409 union iwreq_data *wrqu, char *extra)
3410{
3411 ENTER();
3412 return 0;
3413}
3414
3415static struct iw_statistics *get_wireless_stats(struct net_device *dev)
3416{
3417 ENTER();
3418 return NULL;
3419}
3420
3421static int iw_set_encode(struct net_device *dev,struct iw_request_info *info,
3422 union iwreq_data *wrqu,char *extra)
3423
3424{
3425 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3426 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3427 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3428 struct iw_point *encoderq = &(wrqu->encoding);
3429 v_U32_t keyId;
3430 v_U8_t key_length;
3431 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3432 v_BOOL_t fKeyPresent = 0;
3433 int i;
3434 eHalStatus status = eHAL_STATUS_SUCCESS;
3435
3436
3437 ENTER();
3438
3439 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3440 {
3441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3442 "%s:LOGP in Progress. Ignore!!!",__func__);
3443 return 0;
3444 }
3445
3446
3447 keyId = encoderq->flags & IW_ENCODE_INDEX;
3448
3449 if(keyId)
3450 {
3451 if(keyId > MAX_WEP_KEYS)
3452 {
3453 return -EINVAL;
3454 }
3455
3456 fKeyPresent = 1;
3457 keyId--;
3458 }
3459 else
3460 {
3461 fKeyPresent = 0;
3462 }
3463
3464
3465 if(wrqu->data.flags & IW_ENCODE_DISABLED)
3466 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****iwconfig wlan0 key off*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 if(!fKeyPresent) {
3469
3470 for(i=0;i < CSR_MAX_NUM_KEY; i++) {
3471
3472 if(pWextState->roamProfile.Keys.KeyMaterial[i])
3473 pWextState->roamProfile.Keys.KeyLength[i] = 0;
3474 }
3475 }
3476 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3477 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
3478 pWextState->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3479 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3480
3481 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3482 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3483
3484 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)
3485 {
3486 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3487 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
Jeff Johnson43971f52012-07-17 12:26:56 -07003488 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05303489 {
3490 long ret;
3491 ret = wait_for_completion_interruptible_timeout(
3492 &pAdapter->disconnect_comp_var,
3493 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3494 if (ret <= 0)
3495 hddLog(VOS_TRACE_LEVEL_ERROR,
3496 FL("failed wait on disconnect_comp_var %ld"), ret);
3497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 }
3499
3500 return status;
3501
3502 }
3503
3504 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED))
3505 {
3506 hddLog(VOS_TRACE_LEVEL_INFO, "iwconfig wlan0 key on");
3507
3508 pHddStaCtx->conn_info.authType = (encoderq->flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY : eCSR_AUTH_TYPE_OPEN_SYSTEM;
3509
3510 }
3511
3512
3513 if(wrqu->data.length > 0)
3514 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003515 hddLog(VOS_TRACE_LEVEL_INFO, "%s : wrqu->data.length : %d",__func__,wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003516
3517 key_length = wrqu->data.length;
3518
3519 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued.*/
3520
3521 if(5 == key_length)
3522 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003523 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Call with WEP40,key_len=%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003524
3525 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3526 {
3527 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
3528 }
3529 else
3530 {
3531 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3532 }
3533 }
3534 else if(13 == key_length)
3535 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003536 hddLog(VOS_TRACE_LEVEL_INFO, "%s:Call with WEP104,key_len:%d",__func__,key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003537
3538 if((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3539 {
3540 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3541 }
3542 else
3543 {
3544 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3545 }
3546 }
3547 else
3548 {
3549 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Invalid WEP key length :%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003550 __func__, key_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 return -EINVAL;
3552 }
3553
3554 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
3555 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
3556 pWextState->roamProfile.EncryptionType.numEntries = 1;
3557 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
3558 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3559 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
3560
3561 if((eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) &&
3562 ((eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) ||
3563 (eCSR_AUTH_TYPE_SHARED_KEY == pHddStaCtx->conn_info.authType)))
3564 {
3565
3566 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[keyId][0],extra,key_length);
3567
3568 pWextState->roamProfile.Keys.KeyLength[keyId] = (v_U8_t)key_length;
3569 pWextState->roamProfile.Keys.defaultIndex = (v_U8_t)keyId;
3570
3571 return status;
3572 }
3573 }
3574
3575 return 0;
3576}
3577
3578static int iw_get_encodeext(struct net_device *dev,
3579 struct iw_request_info *info,
3580 struct iw_point *dwrq,
3581 char *extra)
3582{
3583 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3584 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3585 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3586 int keyId;
3587 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
3588 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3589 int i;
3590
3591 ENTER();
3592
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003593 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3594 {
3595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3596 "%s:LOGP in Progress. Ignore!!!", __func__);
3597 return -EBUSY;
3598 }
3599
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 keyId = pRoamProfile->Keys.defaultIndex;
3601
3602 if(keyId < 0 || keyId >= MAX_WEP_KEYS)
3603 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003604 hddLog(LOG1,"%s: Invalid keyId : %d",__func__,keyId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 return -EINVAL;
3606 }
3607
3608 if(pRoamProfile->Keys.KeyLength[keyId] > 0)
3609 {
3610 dwrq->flags |= IW_ENCODE_ENABLED;
3611 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +05303612 vos_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
3613 pRoamProfile->Keys.KeyLength[keyId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 }
3615 else
3616 {
3617 dwrq->flags |= IW_ENCODE_DISABLED;
3618 }
3619
3620 for(i=0; i < MAX_WEP_KEYS; i++)
3621 {
3622 if(pRoamProfile->Keys.KeyMaterial[i] == NULL)
3623 {
3624 continue;
3625 }
3626 else
3627 {
3628 break;
3629 }
3630 }
3631
3632 if(MAX_WEP_KEYS == i)
3633 {
3634 dwrq->flags |= IW_ENCODE_NOKEY;
3635 }
3636 else
3637 {
3638 dwrq->flags |= IW_ENCODE_ENABLED;
3639 }
3640
3641 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
3642
3643 if(eCSR_ENCRYPT_TYPE_NONE == encryptionType)
3644 {
3645 dwrq->flags |= IW_ENCODE_DISABLED;
3646 }
3647
3648 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3649
3650 if(IW_AUTH_ALG_OPEN_SYSTEM == authType)
3651 {
3652 dwrq->flags |= IW_ENCODE_OPEN;
3653 }
3654 else
3655 {
3656 dwrq->flags |= IW_ENCODE_RESTRICTED;
3657 }
3658 EXIT();
3659 return 0;
3660
3661}
3662
3663static int iw_set_encodeext(struct net_device *dev,
3664 struct iw_request_info *info,
3665 union iwreq_data *wrqu, char *extra)
3666{
3667 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3668 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3669 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3670 eHalStatus halStatus= eHAL_STATUS_SUCCESS;
3671
3672 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3673 v_U32_t status = 0;
3674
3675 struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
3676
3677 v_U8_t groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3678
3679 int key_index;
3680 struct iw_point *encoding = &wrqu->encoding;
3681 tCsrRoamSetKey setKey;
3682 v_U32_t roamId= 0xFF;
3683 VOS_STATUS vos_status;
3684
3685 ENTER();
3686
3687 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3688 {
3689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3690 "%s:LOGP in Progress. Ignore!!!",__func__);
3691 return 0;
3692 }
3693
3694 key_index = encoding->flags & IW_ENCODE_INDEX;
3695
3696 if(key_index > 0) {
3697
3698 /*Convert from 1-based to 0-based keying*/
3699 key_index--;
3700 }
3701 if(!ext->key_len) {
3702
3703 /*Set the encrytion type to NONE*/
3704 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
3705 return status;
3706 }
3707
3708 if(eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
3709 (IW_ENCODE_ALG_WEP == ext->alg))
3710 {
3711 if(IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
3712
Agarwal Ashish971c2882013-10-30 20:11:12 +05303713 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3714 ("Invalid Configuration:%s"),__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 return -EINVAL;
3716 }
3717 else {
3718 /*Static wep, update the roam profile with the keys */
3719 if(ext->key && (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
3720 key_index < CSR_MAX_NUM_KEY) {
3721 vos_mem_copy(&pRoamProfile->Keys.KeyMaterial[key_index][0],ext->key,ext->key_len);
3722 pRoamProfile->Keys.KeyLength[key_index] = (v_U8_t)ext->key_len;
3723
3724 if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
3725 pRoamProfile->Keys.defaultIndex = (v_U8_t)key_index;
3726
3727 }
3728 }
3729 return status;
3730 }
3731
3732 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3733
3734 setKey.keyId = key_index;
3735 setKey.keyLength = ext->key_len;
3736
3737 if(ext->key_len <= CSR_MAX_KEY_LEN) {
3738 vos_mem_copy(&setKey.Key[0],ext->key,ext->key_len);
3739 }
3740
3741 if(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
3742 /*Key direction for group is RX only*/
3743 setKey.keyDirection = eSIR_RX_ONLY;
3744 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3745 }
3746 else {
3747
3748 setKey.keyDirection = eSIR_TX_RX;
3749 vos_mem_copy(setKey.peerMac,ext->addr.sa_data,WNI_CFG_BSSID_LEN);
3750 }
3751
3752 /*For supplicant pae role is zero*/
3753 setKey.paeRole = 0;
3754
3755 switch(ext->alg)
3756 {
3757 case IW_ENCODE_ALG_NONE:
3758 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3759 break;
3760
3761 case IW_ENCODE_ALG_WEP:
3762 setKey.encType = (ext->key_len== 5) ? eCSR_ENCRYPT_TYPE_WEP40:eCSR_ENCRYPT_TYPE_WEP104;
3763 break;
3764
3765 case IW_ENCODE_ALG_TKIP:
3766 {
3767 v_U8_t *pKey = &setKey.Key[0];
3768
3769 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3770
3771 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3772
3773 /*Supplicant sends the 32bytes key in this order
3774
3775 |--------------|----------|----------|
3776 | Tk1 |TX-MIC | RX Mic |
3777 |--------------|----------|----------|
3778 <---16bytes---><--8bytes--><--8bytes-->
3779
3780 */
3781 /*Sme expects the 32 bytes key to be in the below order
3782
3783 |--------------|----------|----------|
3784 | Tk1 |RX-MIC | TX Mic |
3785 |--------------|----------|----------|
3786 <---16bytes---><--8bytes--><--8bytes-->
3787 */
3788 /* Copy the Temporal Key 1 (TK1) */
3789 vos_mem_copy(pKey,ext->key,16);
3790
3791 /*Copy the rx mic first*/
3792 vos_mem_copy(&pKey[16],&ext->key[24],8);
3793
3794 /*Copy the tx mic */
3795 vos_mem_copy(&pKey[24],&ext->key[16],8);
3796
3797 }
3798 break;
3799
3800 case IW_ENCODE_ALG_CCMP:
3801 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3802 break;
3803
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003804#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003805#define IW_ENCODE_ALG_KRK 6
3806 case IW_ENCODE_ALG_KRK:
3807 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3808 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003809#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003810
3811 default:
3812 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3813 break;
3814 }
3815
3816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003817 ("%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 -07003818
3819#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303820 /* The supplicant may attempt to set the PTK once pre-authentication
3821 is done. Save the key in the UMAC and include it in the ADD
3822 BSS request */
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303824 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303826 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3827 "%s: Update PreAuth Key success", __func__);
3828 return 0;
3829 }
3830 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3831 {
3832 hddLog(VOS_TRACE_LEVEL_ERROR,
3833 "%s: Update PreAuth Key failed", __func__);
3834 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 }
3836#endif /* WLAN_FEATURE_VOWIFI_11R */
3837
3838 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3839
3840 vos_status = wlan_hdd_check_ula_done(pAdapter);
3841 if ( vos_status != VOS_STATUS_SUCCESS )
3842 {
3843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3844 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3845 __LINE__, vos_status );
3846
3847 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3848 }
3849
3850 halStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),pAdapter->sessionId, &setKey, &roamId );
3851
3852 if ( halStatus != eHAL_STATUS_SUCCESS )
3853 {
3854 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3855 "[%4d] sme_RoamSetKey returned ERROR status= %d",
3856 __LINE__, halStatus );
3857
3858 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3859 }
3860
3861 return halStatus;
3862}
3863
3864static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
3865 union iwreq_data *wrqu, char *extra)
3866{
3867 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3868 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3869
3870 ENTER();
3871
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003872 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3873 {
3874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3875 "%s:LOGP in Progress. Ignore!!!", __func__);
3876 return -EBUSY;
3877 }
3878
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 if(wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
3880 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
3881
Arif Hussain6d2a3322013-11-17 19:50:10 -08003882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("Invalid Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003883
3884 return -EINVAL;
3885 }
3886
3887 if(wrqu->retry.flags & IW_RETRY_LIMIT) {
3888
3889 if((wrqu->retry.flags & IW_RETRY_LONG))
3890 {
3891 if ( ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3892 {
c_hpothub8245442013-11-20 23:41:09 +05303893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3894 FL("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 return -EIO;
3896 }
3897 }
3898 else if((wrqu->retry.flags & IW_RETRY_SHORT))
3899 {
3900 if ( ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, wrqu->retry.value, ccmCfgSetCallback, eANI_BOOLEAN_TRUE) != eHAL_STATUS_SUCCESS )
3901 {
c_hpothub8245442013-11-20 23:41:09 +05303902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3903 FL("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 return -EIO;
3905 }
3906 }
3907 }
3908 else
3909 {
3910 return -EOPNOTSUPP;
3911 }
3912
Arif Hussain6d2a3322013-11-17 19:50:10 -08003913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Set Retry-Limit=%d!!"),wrqu->retry.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003914
3915 EXIT();
3916
3917 return 0;
3918
3919}
3920
3921static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
3922 union iwreq_data *wrqu, char *extra)
3923{
3924 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3925 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3926 v_U32_t retry = 0;
3927
3928 ENTER();
3929
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003930 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3931 {
3932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3933 "%s:LOGP in Progress. Ignore!!!", __func__);
3934 return -EBUSY;
3935 }
3936
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 if((wrqu->retry.flags & IW_RETRY_LONG))
3938 {
3939 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3940
3941 if ( ccmCfgGetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3942 {
c_hpothub8245442013-11-20 23:41:09 +05303943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3944 FL("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 return -EIO;
3946 }
3947
3948 wrqu->retry.value = retry;
3949 }
3950 else if ((wrqu->retry.flags & IW_RETRY_SHORT))
3951 {
3952 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
3953
3954 if ( ccmCfgGetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) != eHAL_STATUS_SUCCESS )
3955 {
c_hpothub8245442013-11-20 23:41:09 +05303956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3957 FL("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 return -EIO;
3959 }
3960
3961 wrqu->retry.value = retry;
3962 }
3963 else {
3964 return -EOPNOTSUPP;
3965 }
3966
Arif Hussain6d2a3322013-11-17 19:50:10 -08003967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("Retry-Limit=%d!!"),retry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003968
3969 EXIT();
3970
3971 return 0;
3972}
3973
3974static int iw_set_mlme(struct net_device *dev,
3975 struct iw_request_info *info,
3976 union iwreq_data *wrqu,
3977 char *extra)
3978{
3979 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3980 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3981 struct iw_mlme *mlme = (struct iw_mlme *)extra;
3982 eHalStatus status = eHAL_STATUS_SUCCESS;
3983
3984 ENTER();
3985
3986 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3987 {
3988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3989 "%s:LOGP in Progress. Ignore!!!",__func__);
3990 return 0;
3991 }
3992
3993 //reason_code is unused. By default it is set to eCSR_DISCONNECT_REASON_UNSPECIFIED
3994 switch (mlme->cmd) {
3995 case IW_MLME_DISASSOC:
3996 case IW_MLME_DEAUTH:
3997
3998 if( pHddStaCtx->conn_info.connState == eConnectionState_Associated )
3999 {
4000 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4001
4002 if( mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE )
4003 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4004
4005 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4006 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,reason);
4007
Jeff Johnson43971f52012-07-17 12:26:56 -07004008 if(eHAL_STATUS_SUCCESS == status)
c_hpothub8245442013-11-20 23:41:09 +05304009 {
4010 long ret;
4011 ret = wait_for_completion_interruptible_timeout(
4012 &pAdapter->disconnect_comp_var,
4013 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4014 if (ret <= 0)
4015 hddLog(VOS_TRACE_LEVEL_ERROR,
4016 FL("failed wait on disconnect_comp_var %ld"), ret);
4017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 else
Arif Hussain6d2a3322013-11-17 19:50:10 -08004019 hddLog(LOGE,"%s %d Command Disassociate/Deauthenticate : csrRoamDisconnect failure returned %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004020 __func__, (int)mlme->cmd, (int)status );
Jeff Johnson295189b2012-06-20 16:38:30 -07004021
4022 /* Resetting authKeyMgmt */
4023 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt = 0;
4024
4025 netif_tx_disable(dev);
4026 netif_carrier_off(dev);
4027
4028 }
4029 else
4030 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004031 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 -07004032 }
4033 break;
4034 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004035 hddLog(LOGE,"%s %d Command should be Disassociate/Deauthenticate", __func__, (int)mlme->cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 return -EINVAL;
4037 }//end of switch
4038
4039 EXIT();
4040
4041 return status;
4042
4043}
4044
4045/* set param sub-ioctls */
4046static int iw_setint_getnone(struct net_device *dev, struct iw_request_info *info,
4047 union iwreq_data *wrqu, char *extra)
4048{
4049 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4050 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4051 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4052 int *value = (int *)extra;
4053 int sub_cmd = value[0];
4054 int set_value = value[1];
4055 int ret = 0; /* success */
4056 int enable_pbm, enable_mp;
4057#ifdef CONFIG_HAS_EARLYSUSPEND
4058 v_U8_t nEnableSuspendOld;
4059#endif
4060 INIT_COMPLETION(pWextState->completion_var);
4061
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004062 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4063 {
4064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4065 "%s:LOGP in Progress. Ignore!!!", __func__);
4066 return -EBUSY;
4067 }
4068
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 switch(sub_cmd)
4070 {
4071 case WE_SET_11D_STATE:
4072 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004073 tSmeConfigParams smeConfig;
Wilson Yang00256342013-10-10 23:13:38 -07004074 memset(&smeConfig, 0x00, sizeof(smeConfig));
4075
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 if((ENABLE_11D == set_value) || (DISABLE_11D == set_value)) {
4077
4078 sme_GetConfigParam(hHal,&smeConfig);
4079 smeConfig.csrConfig.Is11dSupportEnabled = (v_BOOL_t)set_value;
4080
Arif Hussain6d2a3322013-11-17 19:50:10 -08004081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),smeConfig.csrConfig.Is11dSupportEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07004082
4083 sme_UpdateConfig(hHal,&smeConfig);
4084 }
4085 else {
4086 return -EINVAL;
4087 }
4088 break;
4089 }
4090
4091 case WE_WOWL:
4092 {
4093 switch (set_value)
4094 {
4095 case 0x00:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004096 hdd_exit_wowl(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 break;
4098 case 0x01:
4099 case 0x02:
4100 case 0x03:
4101 enable_mp = (set_value & 0x01) ? 1 : 0;
4102 enable_pbm = (set_value & 0x02) ? 1 : 0;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004103 hddLog(LOGE, "magic packet ? = %s pattern byte matching ? = %s",
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 (enable_mp ? "YES":"NO"), (enable_pbm ? "YES":"NO"));
4105 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
4106 break;
4107 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004108 hddLog(LOGE, "Invalid arg %d in WE_WOWL IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 ret = -EINVAL;
4110 break;
4111 }
4112
4113 break;
4114 }
4115 case WE_SET_POWER:
4116 {
4117 switch (set_value)
4118 {
4119 case 0: //Full Power
4120 {
4121 struct statsContext context;
4122 eHalStatus status;
4123
4124 init_completion(&context.completion);
4125
4126 context.pAdapter = pAdapter;
4127 context.magic = POWER_CONTEXT_MAGIC;
4128
4129 status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4130 iw_power_callback_fn, &context,
4131 eSME_FULL_PWR_NEEDED_BY_HDD);
Jeff Johnson72a40512013-12-19 10:14:15 -08004132 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 {
4134 int lrc = wait_for_completion_interruptible_timeout(
4135 &context.completion,
4136 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson72a40512013-12-19 10:14:15 -08004137
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 if (lrc <= 0)
4139 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004140 hddLog(VOS_TRACE_LEVEL_ERROR,
4141 "%s: SME %s while requesting fullpower",
4142 __func__, (0 == lrc) ?
4143 "timeout" : "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 }
4145 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004146 /* either we have a response or we timed out. if we timed
4147 out there is a race condition such that the callback
4148 function could be executing at the same time we are. of
4149 primary concern is if the callback function had already
4150 verified the "magic" but had not yet set the completion
4151 variable when a timeout occurred. we serialize these
4152 activities by invalidating the magic while holding a
4153 shared spinlock which will cause us to block if the
4154 callback is currently executing */
4155 spin_lock(&hdd_context_lock);
4156 context.magic = 0;
4157 spin_unlock(&hdd_context_lock);
4158
Arif Hussain6d2a3322013-11-17 19:50:10 -08004159 hddLog(LOGE, "iwpriv Full Power completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 break;
4161 }
4162 case 1: //Enable BMPS
4163 sme_EnablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4164 break;
4165 case 2: //Disable BMPS
4166 sme_DisablePowerSave(hHal, ePMC_BEACON_MODE_POWER_SAVE);
4167 break;
4168 case 3: //Request Bmps
4169 {
4170 struct statsContext context;
4171 eHalStatus status;
4172
4173 init_completion(&context.completion);
4174
4175 context.pAdapter = pAdapter;
4176 context.magic = POWER_CONTEXT_MAGIC;
4177
4178 status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
4179 iw_power_callback_fn, &context);
Jeff Johnson72a40512013-12-19 10:14:15 -08004180 if (eHAL_STATUS_PMC_PENDING == status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 {
4182 int lrc = wait_for_completion_interruptible_timeout(
4183 &context.completion,
4184 msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 if (lrc <= 0)
4186 {
Jeff Johnson72a40512013-12-19 10:14:15 -08004187 hddLog(VOS_TRACE_LEVEL_ERROR,
4188 "%s: SME %s while requesting BMPS",
4189 __func__, (0 == lrc) ? "timeout" :
4190 "interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 }
4192 }
Jeff Johnson72a40512013-12-19 10:14:15 -08004193 /* either we have a response or we timed out. if we
4194 timed out there is a race condition such that the
4195 callback function could be executing at the same
4196 time we are. of primary concern is if the callback
4197 function had already verified the "magic" but had
4198 not yet set the completion variable when a timeout
4199 occurred. we serialize these activities by
4200 invalidating the magic while holding a shared
4201 spinlock which will cause us to block if the
4202 callback is currently executing */
4203 spin_lock(&hdd_context_lock);
4204 context.magic = 0;
4205 spin_unlock(&hdd_context_lock);
4206
Arif Hussain6d2a3322013-11-17 19:50:10 -08004207 hddLog(LOGE, "iwpriv Request BMPS completed");
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 break;
4209 }
4210 case 4: //Enable IMPS
4211 sme_EnablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4212 break;
4213 case 5: //Disable IMPS
4214 sme_DisablePowerSave(hHal, ePMC_IDLE_MODE_POWER_SAVE);
4215 break;
4216 case 6: //Enable Standby
4217 sme_EnablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4218 break;
4219 case 7: //Disable Standby
4220 sme_DisablePowerSave(hHal, ePMC_STANDBY_MODE_POWER_SAVE);
4221 break;
4222 case 8: //Request Standby
4223#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004224#endif
4225 break;
4226 case 9: //Start Auto Bmps Timer
4227 sme_StartAutoBmpsTimer(hHal);
4228 break;
4229 case 10://Stop Auto BMPS Timer
4230 sme_StopAutoBmpsTimer(hHal);
4231 break;
4232#ifdef CONFIG_HAS_EARLYSUSPEND
4233 case 11://suspend to standby
4234#ifdef CONFIG_HAS_EARLYSUSPEND
4235 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4236 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4238#endif
4239 break;
4240 case 12://suspend to deep sleep
4241#ifdef CONFIG_HAS_EARLYSUSPEND
4242 nEnableSuspendOld = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend;
4243 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->nEnableSuspend = nEnableSuspendOld;
4245#endif
4246 break;
4247 case 13://resume from suspend
4248#ifdef CONFIG_HAS_EARLYSUSPEND
Jeff Johnson295189b2012-06-20 16:38:30 -07004249#endif
4250 break;
4251#endif
4252 case 14://reset wlan (power down/power up)
4253 vos_chipReset(NULL, VOS_FALSE, NULL, NULL, VOS_CHIP_RESET_UNKNOWN_EXCEPTION);
4254 break;
4255 default:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004256 hddLog(LOGE, "Invalid arg %d in WE_SET_POWER IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 ret = -EINVAL;
4258 break;
4259 }
4260 break;
4261 }
4262
4263 case WE_SET_MAX_ASSOC:
4264 {
4265 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
4266 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value))
4267 {
4268 ret = -EINVAL;
4269 }
4270 else if ( ccmCfgSetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT,
4271 set_value, NULL, eANI_BOOLEAN_FALSE)
4272 != eHAL_STATUS_SUCCESS )
4273 {
c_hpothub8245442013-11-20 23:41:09 +05304274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4275 FL("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 ret = -EIO;
4277 }
4278 break;
4279 }
4280
4281 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
4282 {
4283 if( 0 == set_value )
4284 {
4285 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 0;
4286 }
4287 else if ( 1 == set_value )
4288 {
4289 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection = 1;
4290 }
4291 else
4292 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004293 hddLog(LOGE, "Invalid arg %d in WE_SET_SAP_AUTO_CHANNEL_SELECTION IOCTL", set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 ret = -EINVAL;
4295 }
4296 break;
4297 }
4298
4299 case WE_SET_DATA_INACTIVITY_TO:
4300 {
4301 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
4302 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
4303 (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
4304 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
4305 set_value,
4306 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE))
4307 {
4308 hddLog(LOGE,"Failure: Could not pass on "
4309 "WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info "
Arif Hussain6d2a3322013-11-17 19:50:10 -08004310 "to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 ret = -EINVAL;
4312 }
4313 break;
4314 }
4315 case WE_SET_MAX_TX_POWER:
4316 {
4317 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4318 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
4319
4320 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Setting maximum tx power %d dBm",
4321 __func__, set_value);
4322 if( sme_SetMaxTxPower(hHal, bssid, selfMac, set_value) !=
4323 eHAL_STATUS_SUCCESS )
4324 {
4325 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
4326 __func__);
4327 return -EIO;
4328 }
4329
4330 break;
4331 }
Arif Hussaina5ebce02013-08-09 15:09:58 -07004332 case WE_SET_MAX_TX_POWER_2_4:
4333 {
4334 hddLog(VOS_TRACE_LEVEL_INFO,
4335 "%s: Setting maximum tx power %d dBm for 2.4 GHz band",
4336 __func__, set_value);
4337 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_24, set_value) !=
4338 eHAL_STATUS_SUCCESS)
4339 {
4340 hddLog(VOS_TRACE_LEVEL_ERROR,
4341 "%s: Setting maximum tx power failed for 2.4 GHz band",
4342 __func__);
4343 return -EIO;
4344 }
4345
4346 break;
4347 }
4348 case WE_SET_MAX_TX_POWER_5_0:
4349 {
4350 hddLog(VOS_TRACE_LEVEL_INFO,
4351 "%s: Setting maximum tx power %d dBm for 5.0 GHz band",
4352 __func__, set_value);
4353 if (sme_SetMaxTxPowerPerBand(eCSR_BAND_5G, set_value) !=
4354 eHAL_STATUS_SUCCESS)
4355 {
4356 hddLog(VOS_TRACE_LEVEL_ERROR,
4357 "%s: Setting maximum tx power failed for 5.0 GHz band",
4358 __func__);
4359 return -EIO;
4360 }
4361
4362 break;
4363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004364 case WE_SET_HIGHER_DTIM_TRANSITION:
4365 {
4366 if(!((set_value == eANI_BOOLEAN_FALSE) ||
4367 (set_value == eANI_BOOLEAN_TRUE)))
4368 {
4369 hddLog(LOGE, "Dynamic DTIM Incorrect data:%d", set_value);
4370 ret = -EINVAL;
4371 }
4372 else
4373 {
4374 if(pAdapter->higherDtimTransition != set_value)
4375 {
4376 pAdapter->higherDtimTransition = set_value;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004377 hddLog(LOG1, "%s: higherDtimTransition set to :%d", __func__, pAdapter->higherDtimTransition);
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 }
4379 }
4380
4381 break;
4382 }
4383
4384 case WE_SET_TM_LEVEL:
4385 {
4386 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004387 hddLog(VOS_TRACE_LEVEL_INFO, "Set Thermal Mitigation Level %d", (int)set_value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 hddDevTmLevelChangedHandler(hddCtxt->parent_dev, set_value);
4389
4390 break;
4391 }
4392
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304393 case WE_ENABLE_STRICT_FCC_REG:
4394 {
4395 hdd_context_t *hddCtxt = WLAN_HDD_GET_CTX(pAdapter);
4396 struct wiphy *wiphy = NULL;
4397 long lrc;
4398 int status;
4399
4400 wiphy = hddCtxt->wiphy;
4401 if(wiphy == NULL)
4402 {
4403 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy is NULL ", __func__);
4404 break;
4405 }
4406 init_completion(&hddCtxt->wiphy_channel_update_event);
4407
4408 hddCtxt->nEnableStrictRegulatoryForFCC = set_value;
4409
4410 status = regulatory_hint(wiphy, "00");
4411 if(status < 0)
4412 {
4413 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failure in setting regulatory rule ", __func__);
4414 break;
4415 }
4416
4417 /* Wait for completion */
4418 lrc = wait_for_completion_interruptible_timeout(&hddCtxt->wiphy_channel_update_event,
4419 msecs_to_jiffies(WLAN_WAIT_TIME_CHANNEL_UPDATE));
4420 if (lrc <= 0)
4421 {
4422 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: SME %s while setting strict FCC regulatory rule ",
4423 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
4424 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
4425 }
4426 hddLog(VOS_TRACE_LEVEL_INFO,"%s: SUCCESS in setting strict FCC regulatory rule", __func__);
4427
4428 break;
4429 }
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08004430 case WE_SET_DEBUG_LOG:
4431 {
4432 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4433 pHddCtx->cfg_ini->gEnableDebugLog = set_value;
4434 sme_UpdateConnectDebug(pHddCtx->hHal, set_value);
4435 break;
4436 }
Atul Mittalc0f739f2014-07-31 13:47:47 +05304437#ifdef FEATURE_WLAN_TDLS
4438 case WE_SET_TDLS_OFF_CHAN:
4439 {
4440 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel num %d",
4442 __func__, set_value);
4443 ret = iw_set_tdlsoffchannel(pHddCtx, set_value);
4444 break;
4445 }
4446 case WE_SET_TDLS_SEC_OFF_CHAN_OFFSET:
4447 {
4448 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls sec offchan offset %d",
4450 __func__, set_value);
4451 ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value);
4452 break;
4453 }
4454 case WE_SET_TDLS_OFF_CHAN_MODE:
4455 {
4456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: Tdls offchannel mode %d",
4457 __func__, set_value);
4458 ret = iw_set_tdlsoffchannelmode(pAdapter, set_value);
4459 break;
4460 }
4461#endif
Kiet Lam46b8e4e2013-11-06 21:49:53 +05304462
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 default:
4464 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004465 hddLog(LOGE, "Invalid IOCTL setvalue command %d value %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 sub_cmd, set_value);
4467 break;
4468 }
4469 }
4470
4471 return ret;
4472}
4473
4474/* set param sub-ioctls */
4475static int iw_setchar_getnone(struct net_device *dev, struct iw_request_info *info,
4476 union iwreq_data *wrqu, char *extra)
4477{
4478 VOS_STATUS vstatus;
Girish Gowli552fc072014-06-14 18:26:16 +05304479 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 int ret = 0; /* success */
Arif Hussain0273cba2014-01-07 20:58:29 -08004481 char *pBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 hdd_adapter_t *pAdapter = (netdev_priv(dev));
4483 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4484#ifdef WLAN_FEATURE_VOWIFI
4485 hdd_config_t *pConfig = pHddCtx->cfg_ini;
4486#endif /* WLAN_FEATURE_VOWIFI */
Girish Gowli552fc072014-06-14 18:26:16 +05304487 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07004488
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004489 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4490 {
4491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4492 "%s:LOGP in Progress. Ignore!!!", __func__);
4493 return -EBUSY;
4494 }
4495
Girish Gowli552fc072014-06-14 18:26:16 +05304496 /* helper function to get iwreq_data with compat handling. */
4497 if (hdd_priv_get_data(&s_priv_data, wrqu))
4498 {
4499 return -EINVAL;
4500 }
4501
4502 /* make sure all params are correctly passed to function */
4503 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
4504 {
4505 return -EINVAL;
4506 }
4507
4508 sub_cmd = s_priv_data.flags;
4509
Arif Hussain0273cba2014-01-07 20:58:29 -08004510 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowli552fc072014-06-14 18:26:16 +05304511 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
4512 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004513 if (NULL == pBuffer)
4514 {
4515 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4516 "mem_alloc_copy_from_user_helper fail");
4517 return -ENOMEM;
4518 }
4519
4520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Girish Gowli552fc072014-06-14 18:26:16 +05304521 "%s: Received length %d", __func__, s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08004522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4523 "%s: Received data %s", __func__, pBuffer);
4524
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 switch(sub_cmd)
4526 {
4527 case WE_WOWL_ADD_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "ADD_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004529 hdd_add_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 break;
4531 case WE_WOWL_DEL_PTRN:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "DEL_PTRN");
Arif Hussain0273cba2014-01-07 20:58:29 -08004533 hdd_del_wowl_ptrn(pAdapter, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 break;
4535#if defined WLAN_FEATURE_VOWIFI
4536 case WE_NEIGHBOR_REPORT_REQUEST:
4537 {
4538 tRrmNeighborReq neighborReq;
4539 tRrmNeighborRspCallbackInfo callbackInfo;
4540
4541 if (pConfig->fRrmEnable)
4542 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Neighbor Request");
Girish Gowli552fc072014-06-14 18:26:16 +05304544 neighborReq.no_ssid = (s_priv_data.length - 1) ? false : true ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 if( !neighborReq.no_ssid )
4546 {
Girish Gowli552fc072014-06-14 18:26:16 +05304547 neighborReq.ssid.length = (s_priv_data.length - 1) > 32 ? 32 : (s_priv_data.length - 1) ;
Arif Hussain0273cba2014-01-07 20:58:29 -08004548 vos_mem_copy( neighborReq.ssid.ssId, pBuffer, neighborReq.ssid.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 }
4550
4551 callbackInfo.neighborRspCallback = NULL;
4552 callbackInfo.neighborRspCallbackContext = NULL;
4553 callbackInfo.timeout = 5000; //5 seconds
4554 sme_NeighborReportRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &neighborReq, &callbackInfo );
4555 }
4556 else
4557 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004558 hddLog(LOGE, "%s: Ignoring neighbor request as RRM is not enabled", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 ret = -EINVAL;
4560 }
4561 }
4562 break;
4563#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 case WE_SET_AP_WPS_IE:
4565 hddLog( LOGE, "Received WE_SET_AP_WPS_IE" );
Girish Gowli552fc072014-06-14 18:26:16 +05304566 sme_updateP2pIe( WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer, s_priv_data.length );
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 case WE_SET_CONFIG:
Arif Hussain0273cba2014-01-07 20:58:29 -08004569 vstatus = hdd_execute_config_command(pHddCtx, pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 if (VOS_STATUS_SUCCESS != vstatus)
4571 {
4572 ret = -EINVAL;
4573 }
4574 break;
4575 default:
4576 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004577 hddLog(LOGE, "%s: Invalid sub command %d",__func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 ret = -EINVAL;
4579 break;
4580 }
4581 }
Arif Hussain0273cba2014-01-07 20:58:29 -08004582 kfree(pBuffer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 return ret;
4584}
4585
4586/* get param sub-ioctls */
4587static int iw_setnone_getint(struct net_device *dev, struct iw_request_info *info,
4588 union iwreq_data *wrqu, char *extra)
4589{
4590 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4591 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4592 int *value = (int *)extra;
4593 int ret = 0; /* success */
4594
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004595 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4596 {
4597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4598 "%s:LOGP in Progress. Ignore!!!", __func__);
4599 return -EBUSY;
4600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004601
4602 switch (value[0])
4603 {
4604 case WE_GET_11D_STATE:
4605 {
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004606 tSmeConfigParams smeConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 sme_GetConfigParam(hHal,&smeConfig);
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304608
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 *value = smeConfig.csrConfig.Is11dSupportEnabled;
4610
Arif Hussain6d2a3322013-11-17 19:50:10 -08004611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("11D state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004612
4613 break;
4614 }
4615
4616 case WE_IBSS_STATUS:
Arif Hussain6d2a3322013-11-17 19:50:10 -08004617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "****Return IBSS Status*****");
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 break;
4619
4620 case WE_PMC_STATE:
4621 {
4622 *value = pmcGetPmcState(hHal);
Arif Hussain6d2a3322013-11-17 19:50:10 -08004623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("PMC state=%d!!"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 break;
4625 }
4626 case WE_GET_WLAN_DBG:
4627 {
4628 vos_trace_display();
4629 *value = 0;
4630 break;
4631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 case WE_GET_MAX_ASSOC:
4633 {
4634 if (ccmCfgGetInt(hHal, WNI_CFG_ASSOC_STA_LIMIT, (tANI_U32 *)value) != eHAL_STATUS_SUCCESS)
4635 {
c_hpothub8245442013-11-20 23:41:09 +05304636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4637 FL("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 ret = -EIO;
4639 }
4640 break;
4641 }
4642
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 case WE_GET_WDI_DBG:
4644 {
4645 wpalTraceDisplay();
4646 *value = 0;
4647 break;
4648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004649
4650 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
4651 {
4652 *value = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->apAutoChannelSelection;
4653 break;
4654 }
4655 case WE_GET_CONCURRENCY_MODE:
4656 {
4657 *value = hdd_get_concurrency_mode ( );
4658
Arif Hussain6d2a3322013-11-17 19:50:10 -08004659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, ("concurrency mode=%d"),*value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 break;
4661 }
4662
4663 default:
4664 {
4665 hddLog(LOGE, "Invalid IOCTL get_value command %d ",value[0]);
4666 break;
4667 }
4668 }
4669
4670 return ret;
4671}
4672
4673/* set param sub-ioctls */
4674int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
4675 union iwreq_data *wrqu, char *extra)
4676{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004677 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 int *value = (int *)extra;
4679 int sub_cmd = value[0];
4680 int ret = 0;
4681
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004682 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4683 {
4684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4685 "%s:LOGP in Progress. Ignore!!!", __func__);
4686 return -EBUSY;
4687 }
4688
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 switch(sub_cmd)
4690 {
4691 case WE_SET_WLAN_DBG:
4692 {
4693 vos_trace_setValue( value[1], value[2], value[3]);
4694 break;
4695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 case WE_SET_WDI_DBG:
4697 {
4698 wpalTraceSetLevel( value[1], value[2], value[3]);
4699 break;
4700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 case WE_SET_SAP_CHANNELS:
4702 {
4703 ret = iw_softap_set_channel_range( dev, value[1], value[2], value[3]);
4704 break;
4705 }
4706
4707 default:
4708 {
Jeff Johnson11e77032014-02-14 13:22:22 -08004709 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 break;
4711 }
4712 }
4713 return ret;
4714}
4715
4716static int iw_get_char_setnone(struct net_device *dev, struct iw_request_info *info,
4717 union iwreq_data *wrqu, char *extra)
4718{
4719 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4720 int sub_cmd = wrqu->data.flags;
Chet Lanctot186b5732013-03-18 10:26:30 -07004721#ifdef WLAN_FEATURE_11W
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004722 hdd_wext_state_t *pWextState;
4723#endif
4724
4725 if (pAdapter == NULL)
4726 {
4727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4728 "%s: pAdapter is NULL!", __func__);
4729 return -EINVAL;
4730 }
4731#ifdef WLAN_FEATURE_11W
4732 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Chet Lanctot186b5732013-03-18 10:26:30 -07004733#endif
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004734
Yue Ma3ede6052013-08-29 00:33:26 -07004735 if (NULL == WLAN_HDD_GET_CTX(pAdapter))
4736 {
4737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4738 "%s: HDD Context is NULL!", __func__);
4739
4740 return -EINVAL;
4741 }
4742
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004743 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4744 {
4745 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4746 "%s:LOGP in Progress. Ignore!!!", __func__);
4747 return -EBUSY;
4748 }
4749
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 switch(sub_cmd)
4751 {
4752 case WE_WLAN_VERSION:
4753 {
Jeff Johnson4824d4c2013-02-12 14:23:57 -08004754 hdd_wlan_get_version(pAdapter, wrqu, extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 break;
4756 }
4757
4758 case WE_GET_STATS:
4759 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304760 tHalHandle hHal = NULL;
4761 tpAniSirGlobal pMac = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4763 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
4764 hdd_chip_reset_stats_t *pResetStats = &pHddCtx->hddChipResetStats;
4765
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304766
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 snprintf(extra, WE_MAX_STR_LEN,
4768 "\nTransmit"
4769 "\ncalled %u, dropped %u, backpressured %u, queued %u"
4770 "\n dropped BK %u, BE %u, VI %u, VO %u"
4771 "\n classified BK %u, BE %u, VI %u, VO %u"
4772 "\nbackpressured BK %u, BE %u, VI %u, VO %u"
4773 "\n queued BK %u, BE %u, VI %u, VO %u"
4774 "\nfetched %u, empty %u, lowres %u, deqerr %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004775 "\ndequeued %u, depressured %u, deque-depressured %u, completed %u, flushed %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 "\n fetched BK %u, BE %u, VI %u, VO %u"
4777 "\n dequeued BK %u, BE %u, VI %u, VO %u"
4778 "\n depressured BK %u, BE %u, VI %u, VO %u"
Ravi Joshi41914632013-10-21 23:02:21 -07004779 "\nDeque depressured BK %u, BE %u, VI %u, VO %u"
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 "\n flushed BK %u, BE %u, VI %u, VO %u"
4781 "\n\nReceive"
4782 "\nchains %u, packets %u, dropped %u, delivered %u, refused %u"
4783 "\n\nResetsStats"
4784 "\n TotalLogp %u Cmd53 %u MutexRead %u MIF-Error %u FW-Heartbeat %u Others %u"
4785 "\n",
4786 pStats->txXmitCalled,
4787 pStats->txXmitDropped,
4788 pStats->txXmitBackPressured,
4789 pStats->txXmitQueued,
4790
4791 pStats->txXmitDroppedAC[WLANTL_AC_BK],
4792 pStats->txXmitDroppedAC[WLANTL_AC_BE],
4793 pStats->txXmitDroppedAC[WLANTL_AC_VI],
4794 pStats->txXmitDroppedAC[WLANTL_AC_VO],
4795
4796 pStats->txXmitClassifiedAC[WLANTL_AC_BK],
4797 pStats->txXmitClassifiedAC[WLANTL_AC_BE],
4798 pStats->txXmitClassifiedAC[WLANTL_AC_VI],
4799 pStats->txXmitClassifiedAC[WLANTL_AC_VO],
4800
4801 pStats->txXmitBackPressuredAC[WLANTL_AC_BK],
4802 pStats->txXmitBackPressuredAC[WLANTL_AC_BE],
4803 pStats->txXmitBackPressuredAC[WLANTL_AC_VI],
4804 pStats->txXmitBackPressuredAC[WLANTL_AC_VO],
4805
4806 pStats->txXmitQueuedAC[WLANTL_AC_BK],
4807 pStats->txXmitQueuedAC[WLANTL_AC_BE],
4808 pStats->txXmitQueuedAC[WLANTL_AC_VI],
4809 pStats->txXmitQueuedAC[WLANTL_AC_VO],
4810
4811 pStats->txFetched,
4812 pStats->txFetchEmpty,
4813 pStats->txFetchLowResources,
4814 pStats->txFetchDequeueError,
4815
4816 pStats->txFetchDequeued,
4817 pStats->txFetchDePressured,
Ravi Joshi41914632013-10-21 23:02:21 -07004818 pStats->txDequeDePressured,
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 pStats->txCompleted,
4820 pStats->txFlushed,
4821
4822 pStats->txFetchedAC[WLANTL_AC_BK],
4823 pStats->txFetchedAC[WLANTL_AC_BE],
4824 pStats->txFetchedAC[WLANTL_AC_VI],
4825 pStats->txFetchedAC[WLANTL_AC_VO],
4826
4827 pStats->txFetchDequeuedAC[WLANTL_AC_BK],
4828 pStats->txFetchDequeuedAC[WLANTL_AC_BE],
4829 pStats->txFetchDequeuedAC[WLANTL_AC_VI],
4830 pStats->txFetchDequeuedAC[WLANTL_AC_VO],
4831
4832 pStats->txFetchDePressuredAC[WLANTL_AC_BK],
4833 pStats->txFetchDePressuredAC[WLANTL_AC_BE],
4834 pStats->txFetchDePressuredAC[WLANTL_AC_VI],
4835 pStats->txFetchDePressuredAC[WLANTL_AC_VO],
4836
Ravi Joshi41914632013-10-21 23:02:21 -07004837 pStats->txDequeDePressuredAC[WLANTL_AC_BK],
4838 pStats->txDequeDePressuredAC[WLANTL_AC_BE],
4839 pStats->txDequeDePressuredAC[WLANTL_AC_VI],
4840 pStats->txDequeDePressuredAC[WLANTL_AC_VO],
4841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 pStats->txFlushedAC[WLANTL_AC_BK],
4843 pStats->txFlushedAC[WLANTL_AC_BE],
4844 pStats->txFlushedAC[WLANTL_AC_VI],
4845 pStats->txFlushedAC[WLANTL_AC_VO],
4846
4847 pStats->rxChains,
4848 pStats->rxPackets,
4849 pStats->rxDropped,
4850 pStats->rxDelivered,
4851 pStats->rxRefused,
4852
4853 pResetStats->totalLogpResets,
4854 pResetStats->totalCMD53Failures,
4855 pResetStats->totalMutexReadFailures,
4856 pResetStats->totalMIFErrorFailures,
4857 pResetStats->totalFWHearbeatFailures,
4858 pResetStats->totalUnknownExceptions
4859 );
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304860 wrqu->data.length = strlen(extra);
4861
4862 hHal = WLAN_HDD_GET_HAL_CTX( pAdapter );
4863
4864 if (hHal)
4865 pMac = PMAC_STRUCT( hHal );
4866
4867 if (pMac && (wrqu->data.length < WE_MAX_STR_LEN)) {
4868 __u32 pmmStatsLength = WE_MAX_STR_LEN - wrqu->data.length;
4869 snprintf(extra+wrqu->data.length, pmmStatsLength,
Rajesh Babu Prathipati6aa7cb82014-06-02 09:56:59 +05304870 "\n BMPS sleepcnt %lld, BMPS awakecnt %lld"
4871 "\n BMPS sleepreqfailcnt %lld, BMPS wakeupreqfailcnt %lld"
4872 "\n IMPS sleepcnt %lld, IMPS awakecnt %lld"
4873 "\n IMPS sleepreqfailcnt %lld, IMPS wakeupreqfailcnt %lld, IMPS lasterr %lld"
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05304874 "\n",
4875 pMac->pmm.BmpscntSleep,
4876 pMac->pmm.BmpscntAwake,
4877 pMac->pmm.BmpsSleeReqFailCnt,
4878 pMac->pmm.BmpsWakeupReqFailCnt,
4879 pMac->pmm.ImpsCntSleep,
4880 pMac->pmm.ImpsCntAwake,
4881 pMac->pmm.ImpsSleepErrCnt,
4882 pMac->pmm.ImpsWakeupErrCnt,
4883 pMac->pmm.ImpsLastErr
4884 );
4885 }
4886
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 wrqu->data.length = strlen(extra)+1;
4888 break;
4889 }
4890
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304891/* The case prints the current state of the HDD, SME, CSR, PE, TL
4892 *it can be extended for WDI Global State as well.
4893 *And currently it only checks P2P_CLIENT adapter.
4894 *P2P_DEVICE and P2P_GO have not been added as of now.
4895*/
4896 case WE_GET_STATES:
4897 {
4898 int buf = 0, len = 0;
4899 int adapter_num = 0;
4900 int count = 0, check = 1;
4901
4902 tANI_U16 tlState;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004903 tHalHandle hHal = NULL;
4904 tpAniSirGlobal pMac = NULL;
4905 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304906
4907 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4908 hdd_adapter_t *useAdapter = NULL;
4909
4910 /* Print wlan0 or p2p0 states based on the adapter_num
4911 *by using the correct adapter
4912 */
4913 while ( adapter_num < 2 )
4914 {
4915 if ( WLAN_ADAPTER == adapter_num )
4916 {
4917 useAdapter = pAdapter;
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004918 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304919 "\n\n wlan0 States:-");
4920 len += buf;
4921 }
4922 else if ( P2P_ADAPTER == adapter_num )
4923 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004924 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304925 "\n\n p2p0 States:-");
4926 len += buf;
4927
4928 if( !pHddCtx )
4929 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004930 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304931 "\n pHddCtx is NULL");
4932 len += buf;
4933 break;
4934 }
4935
4936 /*Printing p2p0 states only in the case when the device is
4937 configured as a p2p_client*/
4938 useAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT);
4939 if ( !useAdapter )
4940 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004941 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304942 "\n Device not configured as P2P_CLIENT.");
4943 len += buf;
4944 break;
4945 }
4946 }
4947
4948 hHal = WLAN_HDD_GET_HAL_CTX( useAdapter );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004949 if (!hHal) {
4950 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4951 "\n pMac is NULL");
4952 len += buf;
4953 break;
4954 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304955 pMac = PMAC_STRUCT( hHal );
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004956 if (!pMac) {
4957 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4958 "\n pMac is NULL");
4959 len += buf;
4960 break;
4961 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304962 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR( useAdapter );
4963 if( !pHddStaCtx )
4964 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004965 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304966 "\n pHddStaCtx is NULL");
4967 len += buf;
4968 break;
4969 }
4970
4971 tlState = smeGetTLSTAState(hHal, pHddStaCtx->conn_info.staId[0]);
4972
Sameer Thalappilb0a30232013-09-27 15:37:48 -07004973 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304974 "\n HDD Conn State - %s "
4975 "\n \n SME State:"
4976 "\n Neighbour Roam State - %s"
4977 "\n CSR State - %s"
4978 "\n CSR Substate - %s"
4979 "\n \n TL STA %d State: %s",
4980 macTraceGetHDDWlanConnState(
4981 pHddStaCtx->conn_info.connState),
4982 macTraceGetNeighbourRoamState(
4983 pMac->roam.neighborRoamInfo.neighborRoamState),
4984 macTraceGetcsrRoamState(
4985 pMac->roam.curState[useAdapter->sessionId]),
4986 macTraceGetcsrRoamSubState(
4987 pMac->roam.curSubState[useAdapter->sessionId]),
4988 pHddStaCtx->conn_info.staId[0],
4989 macTraceGetTLState(tlState)
4990 );
4991 len += buf;
4992 adapter_num++;
4993 }
4994
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08004995 if (pMac) {
4996 /* Printing Lim State starting with global lim states */
4997 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
4998 "\n \n LIM STATES:-"
4999 "\n Global Sme State - %s "\
5000 "\n Global mlm State - %s "\
5001 "\n",
5002 macTraceGetLimSmeState(pMac->lim.gLimSmeState),
5003 macTraceGetLimMlmState(pMac->lim.gLimMlmState)
5004 );
5005 len += buf;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305006
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005007 /*printing the PE Sme and Mlm states for valid lim sessions*/
5008 while ( check < 3 && count < 255)
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305009 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005010 if ( pMac->lim.gpSession[count].valid )
5011 {
5012 buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
5013 "\n Lim Valid Session %d:-"
5014 "\n PE Sme State - %s "
5015 "\n PE Mlm State - %s "
5016 "\n",
5017 check,
5018 macTraceGetLimSmeState(pMac->lim.gpSession[count].limSmeState),
5019 macTraceGetLimMlmState(pMac->lim.gpSession[count].limMlmState)
5020 );
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305021
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005022 len += buf;
5023 check++;
5024 }
5025 count++;
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305026 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305027 }
5028
5029 wrqu->data.length = strlen(extra)+1;
5030 break;
5031 }
5032
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 case WE_GET_CFG:
5034 {
5035 hdd_cfg_get_config(WLAN_HDD_GET_CTX(pAdapter), extra, WE_MAX_STR_LEN);
5036 wrqu->data.length = strlen(extra)+1;
5037 break;
5038 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005039#ifdef WLAN_FEATURE_11AC
5040 case WE_GET_RSSI:
5041 {
5042 v_S7_t s7Rssi = 0;
5043 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
5044 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d",s7Rssi);
5045 wrqu->data.length = strlen(extra)+1;
5046 break;
5047 }
5048#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305049
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005050#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005051 case WE_GET_ROAM_RSSI:
5052 {
5053 v_S7_t s7Rssi = 0;
5054 wlan_hdd_get_roam_rssi(pAdapter, &s7Rssi);
5055 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
5056 wrqu->data.length = strlen(extra)+1;
5057 break;
5058 }
5059#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005060 case WE_GET_WMM_STATUS:
5061 {
5062 snprintf(extra, WE_MAX_STR_LEN,
5063 "\nDir: 0=up, 1=down, 3=both\n"
5064 "|------------------------|\n"
5065 "|AC | ACM |Admitted| Dir |\n"
5066 "|------------------------|\n"
5067 "|VO | %d | %3s | %d |\n"
5068 "|VI | %d | %3s | %d |\n"
5069 "|BE | %d | %3s | %d |\n"
5070 "|BK | %d | %3s | %d |\n"
5071 "|------------------------|\n",
5072 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessRequired,
5073 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcAccessAllowed?"YES":"NO",
5074 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VO].wmmAcTspecInfo.ts_info.direction,
5075 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessRequired,
5076 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcAccessAllowed?"YES":"NO",
5077 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_VI].wmmAcTspecInfo.ts_info.direction,
5078 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessRequired,
5079 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcAccessAllowed?"YES":"NO",
5080 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BE].wmmAcTspecInfo.ts_info.direction,
5081 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessRequired,
5082 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcAccessAllowed?"YES":"NO",
5083 pAdapter->hddWmmStatus.wmmAcStatus[WLANTL_AC_BK].wmmAcTspecInfo.ts_info.direction);
5084
Jeff Johnsone7245742012-09-05 17:12:55 -07005085
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 wrqu->data.length = strlen(extra)+1;
5087 break;
5088 }
5089 case WE_GET_CHANNEL_LIST:
5090 {
5091 VOS_STATUS status;
5092 v_U8_t i, len;
5093 char* buf ;
Sushant Kaushik10315f92014-04-29 11:30:25 +05305094 tANI_U8 pBuf[COUNTRY_CODE_LEN];
5095 tANI_U8 uBufLen = COUNTRY_CODE_LEN;
5096 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 tChannelListInfo channel_list;
5098
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005099 memset(&channel_list, 0, sizeof(channel_list));
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 status = iw_softap_get_channel_list(dev, info, wrqu, (char *)&channel_list);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08005101 if ( !VOS_IS_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005102 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s GetChannelList Failed!!!",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 return -EINVAL;
5105 }
5106 buf = extra;
5107
5108 /**
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005109 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN. Maximum buffer
5110 * needed = 5 * number of channels. Check ifsufficient
5111 * buffer is available and then proceed to fill the buffer.
5112 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005113 if(WE_MAX_STR_LEN < (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN))
5114 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005115 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005116 "%s Insufficient Buffer to populate channel list",
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005117 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 return -EINVAL;
5119 }
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005120 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
5121 channel_list.num_channels);
Sushant Kaushik10315f92014-04-29 11:30:25 +05305122 if( eHAL_STATUS_SUCCESS == sme_GetCountryCode(pHddCtx->hHal, pBuf, &uBufLen))
5123 {
5124 //Printing Country code in getChannelList
5125 for(i= 0; i < COUNTRY_CODE_LEN; i++)
5126 {
5127 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
5128 "%c ", pBuf[i]);
5129 }
5130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 for(i = 0 ; i < channel_list.num_channels; i++)
5132 {
Sameer Thalappilb0a30232013-09-27 15:37:48 -07005133 len += scnprintf(buf + len, WE_MAX_STR_LEN - len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 "%u ", channel_list.channels[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 }
5136 wrqu->data.length = strlen(extra)+1;
5137
5138 break;
5139 }
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005140#ifdef FEATURE_WLAN_TDLS
5141 case WE_GET_TDLS_PEERS:
5142 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005143 wrqu->data.length = wlan_hdd_tdls_get_all_peers(pAdapter, extra, WE_MAX_STR_LEN)+1;
Chilam Ng16a2a1c2013-01-29 01:27:29 -08005144 break;
5145 }
5146#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005147#ifdef WLAN_FEATURE_11W
5148 case WE_GET_11W_INFO:
5149 {
5150 hddLog(LOGE, "WE_GET_11W_ENABLED = %d", pWextState->roamProfile.MFPEnabled );
5151
5152 snprintf(extra, WE_MAX_STR_LEN,
5153 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
5154 "\n Number of Unprotected Disassocs %d"
5155 "\n Number of Unprotected Deauths %d",
5156 (*pWextState->roamProfile.BSSIDs.bssid)[0], (*pWextState->roamProfile.BSSIDs.bssid)[1],
5157 (*pWextState->roamProfile.BSSIDs.bssid)[2], (*pWextState->roamProfile.BSSIDs.bssid)[3],
5158 (*pWextState->roamProfile.BSSIDs.bssid)[4], (*pWextState->roamProfile.BSSIDs.bssid)[5],
5159 pWextState->roamProfile.MFPEnabled, pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx,
5160 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx);
5161
5162 wrqu->data.length = strlen(extra)+1;
5163 break;
5164 }
5165#endif
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305166 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005168 hddLog(LOGE, "%s: Invalid IOCTL command %d", __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 break;
5170 }
5171 }
5172
5173 return 0;
5174}
5175
5176/* action sub-ioctls */
5177static int iw_setnone_getnone(struct net_device *dev, struct iw_request_info *info,
5178 union iwreq_data *wrqu, char *extra)
5179{
5180 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305181 int sub_cmd;
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005182 int ret = 0; /* success */
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305183 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005184
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005185 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5186 {
5187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5188 "%s:LOGP in Progress. Ignore!!!", __func__);
5189 return -EBUSY;
5190 }
5191
Girish Gowlibaf3f2b2014-06-14 18:02:54 +05305192 /* helper function to get iwreq_data with compat handling. */
5193 if (hdd_priv_get_data(&s_priv_data, wrqu))
5194 {
5195 return -EINVAL;
5196 }
5197
5198 sub_cmd = s_priv_data.flags;
5199
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 switch (sub_cmd)
5201 {
5202 case WE_CLEAR_STATS:
5203 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: clearing", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5206 memset(&pAdapter->hdd_stats, 0, sizeof(pAdapter->hdd_stats));
5207 break;
5208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 case WE_INIT_AP:
5210 {
Abhishek Singh98d2f802014-02-10 15:47:55 +05305211 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5212
5213 /* As Soft AP mode might been changed to STA already with
5214 * killing of Hostapd, need to find the adpater by name
5215 * rather than mode */
5216 hdd_adapter_t* pAdapter_to_stop =
5217 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5218 if( pAdapter_to_stop )
5219 {
5220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5221 "Adapter with name softap.0 already "
5222 "exist, ignoring the request.\nRemove the "
5223 "adapter and try again\n");
5224 break;
5225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 pr_info("Init AP trigger\n");
5227 hdd_open_adapter( WLAN_HDD_GET_CTX(pAdapter), WLAN_HDD_SOFTAP, "softap.%d",
5228 wlan_hdd_get_intf_addr( WLAN_HDD_GET_CTX(pAdapter) ),TRUE);
5229 break;
5230 }
5231 case WE_STOP_AP:
5232 {
5233 /*FIX ME: Need to be revisited if multiple SAPs to be supported */
5234 /* As Soft AP mode has been changed to STA already with killing of Hostapd,
5235 * this is a dead code and need to find the adpater by name rather than mode */
5236 hdd_adapter_t* pAdapter_to_stop =
5237 hdd_get_adapter_by_name(WLAN_HDD_GET_CTX(pAdapter), "softap.0");
5238 if( pAdapter_to_stop )
5239 {
5240 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5241
5242 pr_info("Stopping AP mode\n");
5243
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305244 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5245 {
5246 /* EXIT BMPS as fw cannot handle DEL_STA when its in BMPS */
5247 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
5248 }
5249
Jeff Johnson295189b2012-06-20 16:38:30 -07005250 /*Make sure that pAdapter cleaned properly*/
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05305251 hdd_stop_adapter( pHddCtx, pAdapter_to_stop, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005252 hdd_deinit_adapter( pHddCtx, pAdapter_to_stop );
5253 memset(&pAdapter_to_stop->sessionCtx, 0, sizeof(pAdapter_to_stop->sessionCtx));
5254
5255 wlan_hdd_release_intf_addr(WLAN_HDD_GET_CTX(pAdapter),
5256 pAdapter_to_stop->macAddressCurrent.bytes);
5257 hdd_close_adapter(WLAN_HDD_GET_CTX(pAdapter), pAdapter_to_stop,
5258 TRUE);
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05305259
5260 if (FALSE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
5261 {
5262 /* put the device back into BMPS */
5263 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
5264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005265 }
5266 else
5267 {
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005268 printk(KERN_ERR"SAP adapter not found to stop it!\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 }
5270
5271 break;
5272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005273#ifdef WLAN_BTAMP_FEATURE
5274 case WE_ENABLE_AMP:
5275 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005276 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: enabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 WLANBAP_RegisterWithHCI(pAdapter);
5278 break;
5279 }
5280 case WE_DISABLE_AMP:
5281 {
5282 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5283 VOS_STATUS status;
5284
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005286
5287 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
5288 status = WLANBAP_StopAmp();
5289 if(VOS_STATUS_SUCCESS != status )
5290 {
5291 pHddCtx->isAmpAllowed = VOS_TRUE;
5292 hddLog(VOS_TRACE_LEVEL_FATAL,
5293 "%s: Failed to stop AMP", __func__);
5294 }
5295 else
5296 {
5297 //a state m/c implementation in PAL is TBD to avoid this delay
5298 msleep(500);
5299 pHddCtx->isAmpAllowed = VOS_FALSE;
5300 WLANBAP_DeregisterFromHCI();
5301 }
5302
5303 break;
5304 }
5305#endif
5306
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005307 case WE_ENABLE_DXE_STALL_DETECT:
5308 {
schang6295e542013-03-12 15:31:23 -07005309 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5310 sme_transportDebug(hHal, VOS_FALSE, VOS_TRUE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005311 break;
5312 }
5313 case WE_DISPLAY_DXE_SNAP_SHOT:
5314 {
schang6295e542013-03-12 15:31:23 -07005315 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5316 sme_transportDebug(hHal, VOS_TRUE, VOS_FALSE);
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005317 break;
5318 }
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305319 case WE_DISPLAY_DATAPATH_SNAP_SHOT:
5320 {
5321 hddLog(LOGE, "%s: called %d",__func__, sub_cmd);
5322 hdd_wmm_tx_snapshot(pAdapter);
5323 WLANTL_TLDebugMessage(VOS_TRUE);
5324 break;
5325 }
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05305326
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305327 case WE_SET_REASSOC_TRIGGER:
5328 {
5329 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5330 tpAniSirGlobal pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5331 v_U32_t roamId = 0;
5332 tCsrRoamModifyProfileFields modProfileFields;
5333 sme_GetModifyProfileFields(pMac, pAdapter->sessionId, &modProfileFields);
5334 sme_RoamReassoc(pMac, pAdapter->sessionId, NULL, modProfileFields, &roamId, 1);
5335 return 0;
5336 }
5337
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305338 case WE_STOP_OBSS_SCAN:
5339 {
5340 /* 1.OBSS Scan is mandatory while operating in 2.4GHz
5341 2.OBSS scan is stopped by Firmware during the disassociation
5342 3.OBSS stop comamnd is added for debugging purpose*/
5343 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5344 tpAniSirGlobal pMac;
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07005345
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305346 if (pAdapter == NULL)
5347 {
5348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5349 " pAdapter is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305350 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305351 }
5352 pMac = WLAN_HDD_GET_HAL_CTX(pAdapter);
5353 if (pMac == NULL)
5354 {
5355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5356 " pMac is NULL ");
Kaushik, Sushantdf30db22014-05-05 12:14:33 +05305357 return -EINVAL;
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05305358 }
5359 sme_HT40StopOBSSScan(pMac, pAdapter->sessionId);
5360 }
5361 break;
Mukul Sharma84f27252014-07-14 18:11:42 +05305362#ifdef DEBUG_ROAM_DELAY
5363 case WE_DUMP_ROAM_TIMER_LOG:
5364 {
5365 vos_dump_roam_time_log_service();
5366 break;
5367 }
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05305368
Mukul Sharma84f27252014-07-14 18:11:42 +05305369 case WE_RESET_ROAM_TIMER_LOG:
5370 {
5371 vos_reset_roam_timer_log();
5372 break;
5373 }
5374#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 default:
5376 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005377 hddLog(LOGE, "%s: unknown ioctl %d", __func__, sub_cmd);
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 break;
5379 }
5380 }
5381
5382 return ret;
5383}
5384
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305385void hdd_wmm_tx_snapshot(hdd_adapter_t *pAdapter)
5386{
5387 /*
5388 * Function to display HDD WMM information
5389 * for Tx Queues.
5390 * Prints globala as well as per client depending
5391 * whether the clients are registered or not.
5392 */
5393 int i = 0, j = 0;
5394 for ( i=0; i< NUM_TX_QUEUES; i++)
5395 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305396 spin_lock_bh(&pAdapter->wmm_tx_queue[i].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005397 hddLog(LOGE, "HDD WMM TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305398 i, pAdapter->wmm_tx_queue[i].count,
5399 pAdapter->wmm_tx_queue[i].anchor.prev, pAdapter->wmm_tx_queue[i].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305400 spin_unlock_bh(&pAdapter->wmm_tx_queue[i].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305401 }
5402
5403 for(i =0; i<WLAN_MAX_STA_COUNT; i++)
5404 {
5405 if(pAdapter->aStaInfo[i].isUsed)
5406 {
5407 hddLog(LOGE, "******STAIndex: %d*********", i);
5408 for ( j=0; j< NUM_TX_QUEUES; j++)
5409 {
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305410 spin_lock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005411 hddLog(LOGE, "HDD TxQueue Info For AC: %d Count: %d PrevAdress:%p, NextAddress:%p",
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305412 j, pAdapter->aStaInfo[i].wmm_tx_queue[j].count,
5413 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.prev,
5414 pAdapter->aStaInfo[i].wmm_tx_queue[j].anchor.next);
Madan Mohan Koyyalamudi2be9f0c2013-07-25 16:30:37 +05305415 spin_unlock_bh(&pAdapter->aStaInfo[i].wmm_tx_queue[j].lock);
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05305416 }
5417 }
5418 }
5419
5420}
Jeff Johnson295189b2012-06-20 16:38:30 -07005421int iw_set_var_ints_getnone(struct net_device *dev, struct iw_request_info *info,
5422 union iwreq_data *wrqu, char *extra)
5423{
5424 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5425 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Girish Gowlid4522fd2014-06-14 17:20:27 +05305426 int sub_cmd;
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 int apps_args[MAX_VAR_ARGS] = {0};
Girish Gowlid4522fd2014-06-14 17:20:27 +05305428 int num_args;
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005429 hdd_station_ctx_t *pStaCtx = NULL ;
5430 hdd_ap_ctx_t *pAPCtx = NULL;
5431 int cmd = 0;
5432 int staId = 0;
Girish Gowlid4522fd2014-06-14 17:20:27 +05305433 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005434
Girish Gowlid4522fd2014-06-14 17:20:27 +05305435 /* helper function to get iwreq_data with compat handling. */
5436 if (hdd_priv_get_data(&s_priv_data, wrqu))
5437 {
5438 return -EINVAL;
5439 }
5440
5441 if (NULL == s_priv_data.pointer)
5442 {
5443 return -EINVAL;
5444 }
5445
5446 sub_cmd = s_priv_data.flags;
5447 num_args = s_priv_data.length;
5448
5449 hddLog(LOG1, "%s: Received length %d", __func__, s_priv_data.length);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005450
5451 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5452 {
5453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5454 "%s:LOGP in Progress. Ignore!!!", __func__);
5455 return -EBUSY;
5456 }
5457
Jeff Johnson295189b2012-06-20 16:38:30 -07005458 if (num_args > MAX_VAR_ARGS)
5459 {
5460 num_args = MAX_VAR_ARGS;
5461 }
Arif Hussain0273cba2014-01-07 20:58:29 -08005462
5463 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlid4522fd2014-06-14 17:20:27 +05305464 if (copy_from_user(apps_args, s_priv_data.pointer, (sizeof(int)) * num_args))
Arif Hussain0273cba2014-01-07 20:58:29 -08005465 {
5466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5467 "%s: failed to copy data to user buffer", __func__);
5468 return -EFAULT;
5469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005470
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005471 if(( sub_cmd == WE_MCC_CONFIG_CREDENTIAL ) ||
5472 (sub_cmd == WE_MCC_CONFIG_PARAMS ))
5473 {
5474 if(( pAdapter->device_mode == WLAN_HDD_INFRA_STATION )||
5475 ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT ))
5476 {
5477 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5478 staId = pStaCtx->conn_info.staId[0];
5479 }
5480 else if (( pAdapter->device_mode == WLAN_HDD_P2P_GO ) ||
5481 ( pAdapter->device_mode == WLAN_HDD_SOFTAP ))
5482 {
5483 pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5484 staId = pAPCtx->uBCStaId;
5485 }
5486 else
5487 {
5488 hddLog(LOGE, "%s: Device mode %d not recognised", __FUNCTION__, pAdapter->device_mode);
5489 return 0;
5490 }
5491 }
5492
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 switch (sub_cmd)
5494 {
5495 case WE_LOG_DUMP_CMD:
5496 {
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305497 vos_ssr_protect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 hddLog(LOG1, "%s: LOG_DUMP %d arg1 %d arg2 %d arg3 %d arg4 %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005499 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 apps_args[3], apps_args[4]);
5501
5502 logPrintf(hHal, apps_args[0], apps_args[1], apps_args[2],
5503 apps_args[3], apps_args[4]);
Mahesh A Saptasagar2e908622014-06-12 20:22:33 +05305504 vos_ssr_unprotect(__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005505
5506 }
5507 break;
5508
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 case WE_P2P_NOA_CMD:
5510 {
5511 p2p_app_setP2pPs_t p2pNoA;
5512
5513 p2pNoA.opp_ps = apps_args[0];
5514 p2pNoA.ctWindow = apps_args[1];
5515 p2pNoA.duration = apps_args[2];
5516 p2pNoA.interval = apps_args[3];
5517 p2pNoA.count = apps_args[4];
5518 p2pNoA.single_noa_duration = apps_args[5];
5519 p2pNoA.psSelection = apps_args[6];
5520
5521 hddLog(LOG1, "%s: P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d "
5522 "interval %d count %d single noa duration %d PsSelection %x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005523 __func__, apps_args[0], apps_args[1], apps_args[2],
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 apps_args[3], apps_args[4], apps_args[5], apps_args[6]);
5525
5526 hdd_setP2pPs(dev, &p2pNoA);
5527
5528 }
5529 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005530
Katya Nigamc2f29dc2014-01-20 19:29:30 +05305531 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
5532 {
5533 hddLog(LOG1, "%s: SELECTIVE_MODULE_LOG %d arg1 %d arg2",
5534 __func__, apps_args[0], apps_args[1]);
5535 vosTraceEnable(apps_args[0], apps_args[1]);
5536 }
5537 break;
5538
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07005539 case WE_MTRACE_DUMP_CMD:
5540 {
5541 hddLog(LOG1, "%s: MTRACE_DUMP code %d session %d count %d "
5542 "bitmask_of_module %d ",
5543 __func__, apps_args[0], apps_args[1], apps_args[2],
5544 apps_args[3]);
5545 vosTraceDumpAll((void*)hHal , apps_args[0], apps_args[1],
5546 apps_args[2], apps_args[3]);
5547
5548 }
5549 break;
5550
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005551 case WE_MCC_CONFIG_CREDENTIAL :
5552 {
5553 cmd = 287; //Command should be updated if there is any change
5554 // in the Riva dump command
Kumar Anand90ca3dd2013-01-18 15:24:47 -08005555 if((apps_args[0] >= 40 ) && (apps_args[0] <= 160 ))
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005556 {
5557 logPrintf(hHal, cmd, staId, apps_args[0], apps_args[1], apps_args[2]);
5558 }
5559 else
5560 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005561 hddLog(LOGE, "%s : Enter valid MccCredential value between MIN :40 and MAX:160", __func__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08005562 return 0;
5563 }
5564 }
5565 break;
5566
5567 case WE_MCC_CONFIG_PARAMS :
5568 {
5569 cmd = 288; //command Should be updated if there is any change
5570 // in the Riva dump command
5571 hdd_validate_mcc_config(pAdapter, staId, apps_args[0], apps_args[1],apps_args[2]);
5572 }
5573 break;
5574
Chilam NG571c65a2013-01-19 12:27:36 +05305575#ifdef FEATURE_WLAN_TDLS
5576 case WE_TDLS_CONFIG_PARAMS :
5577 {
5578 tdls_config_params_t tdlsParams;
5579
Chilam Ng01120412013-02-19 18:32:21 -08005580 tdlsParams.tdls = apps_args[0];
5581 tdlsParams.tx_period_t = apps_args[1];
5582 tdlsParams.tx_packet_n = apps_args[2];
5583 tdlsParams.discovery_period_t = apps_args[3];
5584 tdlsParams.discovery_tries_n = apps_args[4];
5585 tdlsParams.idle_timeout_t = apps_args[5];
5586 tdlsParams.idle_packet_n = apps_args[6];
5587 tdlsParams.rssi_hysteresis = apps_args[7];
5588 tdlsParams.rssi_trigger_threshold = apps_args[8];
5589 tdlsParams.rssi_teardown_threshold = apps_args[9];
Chilam NG571c65a2013-01-19 12:27:36 +05305590
Chilam Ng01120412013-02-19 18:32:21 -08005591 wlan_hdd_tdls_set_params(dev, &tdlsParams);
Chilam NG571c65a2013-01-19 12:27:36 +05305592 }
5593 break;
5594#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 default:
5596 {
Jeff Johnson11e77032014-02-14 13:22:22 -08005597 hddLog(LOGE, "%s: Invalid IOCTL command %d",
5598 __func__, sub_cmd );
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 }
5600 break;
5601 }
5602
5603 return 0;
5604}
5605
5606
5607static int iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
5608 union iwreq_data *wrqu, char *extra)
5609{
5610 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5611 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5612 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5613 int params[HDD_WLAN_WMM_PARAM_COUNT];
5614 sme_QosWmmTspecInfo tSpec;
5615 v_U32_t handle;
Girish Gowli19993982014-06-12 20:05:32 +05305616 struct iw_point s_priv_data;
Jeff Johnson295189b2012-06-20 16:38:30 -07005617
5618 // make sure the application is sufficiently priviledged
5619 // note that the kernel will do this for "set" ioctls, but since
5620 // this ioctl wants to return status to user space it must be
5621 // defined as a "get" ioctl
5622 if (!capable(CAP_NET_ADMIN))
5623 {
5624 return -EPERM;
5625 }
5626
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005627 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5628 {
5629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5630 "%s:LOGP in Progress. Ignore!!!", __func__);
5631 return -EBUSY;
5632 }
5633
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 // we must be associated in order to add a tspec
5635 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5636 {
5637 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5638 return 0;
5639 }
5640
5641 // since we are defined to be a "get" ioctl, and since the number
5642 // of params exceeds the number of params that wireless extensions
Girish Gowli19993982014-06-12 20:05:32 +05305643 // will pass down in the iwreq_data, we must copy the "set" params.
5644 // We must handle the compat for iwreq_data in 32U/64K environment.
5645
5646 // helper fucntion to get iwreq_data with compat handling.
5647 if (hdd_priv_get_data(&s_priv_data, wrqu))
5648 {
5649 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5650 return 0;
5651 }
5652
5653 // make sure all params are correctly passed to function
5654 if ((NULL == s_priv_data.pointer) ||
5655 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length))
5656 {
5657 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5658 return 0;
5659 }
5660
Jeff Johnson295189b2012-06-20 16:38:30 -07005661 // from user space ourselves
Girish Gowli19993982014-06-12 20:05:32 +05305662 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 {
5664 // hmmm, can't get them
5665 return -EIO;
5666 }
5667
5668 // clear the tspec
5669 memset(&tSpec, 0, sizeof(tSpec));
5670
5671 // validate the handle
5672 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5673 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5674 {
5675 // that one is reserved
5676 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5677 return 0;
5678 }
5679
5680 // validate the TID
5681 if (params[HDD_WLAN_WMM_PARAM_TID] > 7)
5682 {
5683 // out of range
5684 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5685 return 0;
5686 }
5687 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
5688
5689 // validate the direction
5690 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION])
5691 {
5692 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
5693 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
5694 break;
5695
5696 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
5697 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
5698 break;
5699
5700 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
5701 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
5702 break;
5703
5704 default:
5705 // unknown
5706 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5707 return 0;
5708 }
5709
Madan Mohan Koyyalamudia5643d62013-09-25 14:37:55 +05305710 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
5711
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 // validate the user priority
5713 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX)
5714 {
5715 // out of range
5716 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5717 return 0;
5718 }
5719 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
Kiet Lamc6bef882013-11-11 17:07:36 +05305720 if(0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up)
5721 {
5722 hddLog(VOS_TRACE_LEVEL_ERROR,"***ts_info.up out of bounds***");
5723 return 0;
5724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005725
Madan Mohan Koyyalamudic0c62382013-08-16 23:46:14 +05305726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5727 "%s:TS_INFO PSB %d UP %d !!!", __func__,
5728 tSpec.ts_info.psb, tSpec.ts_info.up);
5729
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
5731 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
5732 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
5733 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
5734 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
5735 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
5736 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
5737 tSpec.surplus_bw_allowance = params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
5738 tSpec.min_service_interval = params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
5739 tSpec.max_service_interval = params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
5740 tSpec.suspension_interval = params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
5741 tSpec.inactivity_interval = params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
5742
5743 tSpec.ts_info.burst_size_defn = params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
5744
5745 // validate the ts info ack policy
5746 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY])
5747 {
5748 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
5749 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
5750 break;
5751
5752 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
5753 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
5754 break;
5755
5756 default:
5757 // unknown
5758 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5759 return 0;
5760 }
5761
5762 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
5763 return 0;
5764}
5765
5766
5767static int iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
5768 union iwreq_data *wrqu, char *extra)
5769{
5770 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5771 int *params = (int *)extra;
5772 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5773 v_U32_t handle;
5774
5775 // make sure the application is sufficiently priviledged
5776 // note that the kernel will do this for "set" ioctls, but since
5777 // this ioctl wants to return status to user space it must be
5778 // defined as a "get" ioctl
5779 if (!capable(CAP_NET_ADMIN))
5780 {
5781 return -EPERM;
5782 }
5783
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005784 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5785 {
5786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5787 "%s:LOGP in Progress. Ignore!!!", __func__);
5788 return -EBUSY;
5789 }
5790
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 // although we are defined to be a "get" ioctl, the params we require
5792 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5793 // is no need to copy the params from user space
5794
5795 // validate the handle
5796 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5797 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5798 {
5799 // that one is reserved
5800 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5801 return 0;
5802 }
5803
5804 *pStatus = hdd_wmm_delts(pAdapter, handle);
5805 return 0;
5806}
5807
5808
5809static int iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
5810 union iwreq_data *wrqu, char *extra)
5811{
5812 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5813 int *params = (int *)extra;
5814 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *)extra;
5815 v_U32_t handle;
5816
5817 // although we are defined to be a "get" ioctl, the params we require
5818 // will fit in the iwreq_data, therefore unlike iw_add_tspec() there
5819 // is no need to copy the params from user space
5820
5821 // validate the handle
5822 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
5823 if (HDD_WMM_HANDLE_IMPLICIT == handle)
5824 {
5825 // that one is reserved
5826 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
5827 return 0;
5828 }
5829
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005830 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5831 {
5832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5833 "%s:LOGP in Progress. Ignore!!!", __func__);
5834 return -EBUSY;
5835 }
5836
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 *pStatus = hdd_wmm_checkts(pAdapter, handle);
5838 return 0;
5839}
5840
Jeff Johnson295189b2012-06-20 16:38:30 -07005841#ifdef WLAN_FEATURE_VOWIFI_11R
5842//
5843//
5844// Each time the supplicant has the auth_request or reassoc request
5845// IEs ready. This is pushed to the driver. The driver will inturn use
5846// it to send out the auth req and reassoc req for 11r FT Assoc.
5847//
5848static int iw_set_fties(struct net_device *dev, struct iw_request_info *info,
5849 union iwreq_data *wrqu, char *extra)
5850{
5851 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5852 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5853 //v_CONTEXT_t pVosContext;
5854
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005855 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
5856 {
5857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5858 "%s:LOGP in Progress. Ignore!!!", __func__);
5859 return -EBUSY;
5860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 if (!wrqu->data.length)
5862 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005863 hddLog(LOGE, FL("called with 0 length IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 return -EINVAL;
5865 }
5866 if (wrqu->data.pointer == NULL)
5867 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005868 hddLog(LOGE, FL("called with NULL IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 return -EINVAL;
5870 }
5871
5872 // Added for debug on reception of Re-assoc Req.
5873 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
5874 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005875 hddLog(LOGE, FL("Called with Ie of length = %d when not associated"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 wrqu->data.length);
Arif Hussain6d2a3322013-11-17 19:50:10 -08005877 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 }
5879
5880#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08005881 hddLog(LOGE, FL("%s called with Ie of length = %d"), __func__, wrqu->data.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005882#endif
5883
5884 // Pass the received FT IEs to SME
Arif Hussain7adce1b2013-11-11 22:59:34 -08005885 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, extra,
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 wrqu->data.length);
5887
5888 return 0;
5889}
5890#endif
5891
Amar Singhalf3a6e762013-02-19 15:06:50 -08005892static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005893 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 union iwreq_data *wrqu, char *extra)
Amar Singhalf3a6e762013-02-19 15:06:50 -08005895{
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08005897 tpRcvFltMcAddrList pRequest = (tpRcvFltMcAddrList)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005899 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005900 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005901 tpSirRcvFltMcAddrList mc_addr_list_ptr;
5902 int idx;
5903 eHalStatus ret_val;
Jeff Johnson295189b2012-06-20 16:38:30 -07005904
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005905 if (pHddCtx->isLogpInProgress)
5906 {
5907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5908 "%s:LOGP in Progress. Ignore!!!", __func__);
5909 return -EBUSY;
5910 }
5911
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305912 if (HDD_MULTICAST_FILTER_LIST == pRequest->mcastBcastFilterSetting)
5913 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305914#ifdef WLAN_FEATURE_PACKET_FILTERING
Jeff Johnson295189b2012-06-20 16:38:30 -07005915
Amar Singhalf3a6e762013-02-19 15:06:50 -08005916 mc_addr_list_ptr = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
5917 if (NULL == mc_addr_list_ptr)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005918 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005919 hddLog(VOS_TRACE_LEVEL_ERROR,
5920 "%s: vos_mem_alloc failed", __func__);
5921 return -ENOMEM;
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005922 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08005923
5924 mc_addr_list_ptr->ulMulticastAddrCnt = pRequest->mcast_addr_cnt;
5925
5926 if (mc_addr_list_ptr->ulMulticastAddrCnt > HDD_MAX_NUM_MULTICAST_ADDRESS)
5927 mc_addr_list_ptr->ulMulticastAddrCnt = HDD_MAX_NUM_MULTICAST_ADDRESS;
5928
5929 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr List Cnt %d", __func__,
5930 mc_addr_list_ptr->ulMulticastAddrCnt);
5931
5932 for (idx = 0; idx < mc_addr_list_ptr->ulMulticastAddrCnt; idx++)
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005933 {
Amar Singhalf3a6e762013-02-19 15:06:50 -08005934 memcpy(&mc_addr_list_ptr->multicastAddr[idx],
5935 pRequest->multicastAddr[idx], HDD_WLAN_MAC_ADDR_LEN);
5936
5937 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s MC Addr for Idx %d ="MAC_ADDRESS_STR, __func__,
5938 idx, MAC_ADDR_ARRAY(mc_addr_list_ptr->multicastAddr[idx]));
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005939 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005940
Amar Singhalf3a6e762013-02-19 15:06:50 -08005941 ret_val = sme_8023MulticastList(hHal, pAdapter->sessionId, mc_addr_list_ptr);
5942 vos_mem_free(mc_addr_list_ptr);
5943 if (eHAL_STATUS_SUCCESS != ret_val)
5944 {
5945 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to Set MC Address List",
5946 __func__);
5947 return -EINVAL;
5948 }
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305949#endif //WLAN_FEATURE_PACKET_FILTERING
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305950 }
5951 else
5952 {
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005953
Amar Singhalf3a6e762013-02-19 15:06:50 -08005954 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5955 "%s: Set MC BC Filter Config request: %d suspend %d",
5956 __func__, pRequest->mcastBcastFilterSetting,
5957 pHddCtx->hdd_wlan_suspended);
5958
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305959 pHddCtx->configuredMcastBcastFilter = pRequest->mcastBcastFilterSetting;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005960
5961 if (pHddCtx->hdd_wlan_suspended)
5962 {
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005963 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
5964 if (NULL == wlanRxpFilterParam)
5965 {
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305966 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce3d75e2013-04-05 22:34:54 -07005967 "%s: vos_mem_alloc failed", __func__);
5968 return -EINVAL;
5969 }
5970
Amar Singhalf3a6e762013-02-19 15:06:50 -08005971 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5972 pRequest->mcastBcastFilterSetting;
5973 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
5974
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05305975 hdd_conf_hostoffload(pAdapter, TRUE);
5976 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
5977 pHddCtx->configuredMcastBcastFilter;
Amar Singhalf3a6e762013-02-19 15:06:50 -08005978
5979 hddLog(VOS_TRACE_LEVEL_INFO, "%s:MC/BC changed Req %d Set %d En %d",
5980 __func__,
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305981 pHddCtx->configuredMcastBcastFilter,
Amar Singhalf3a6e762013-02-19 15:06:50 -08005982 wlanRxpFilterParam->configuredMcstBcstFilterSetting,
5983 wlanRxpFilterParam->setMcstBcstFilter);
5984
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05305985 if (eHAL_STATUS_SUCCESS !=
5986 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
5987 wlanRxpFilterParam))
Amar Singhalf3a6e762013-02-19 15:06:50 -08005988 {
5989 hddLog(VOS_TRACE_LEVEL_ERROR,
5990 "%s: Failure to execute set HW MC/BC Filter request",
5991 __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005992 vos_mem_free(wlanRxpFilterParam);
Amar Singhalf3a6e762013-02-19 15:06:50 -08005993 return -EINVAL;
5994 }
5995
Amar Singhalf3a6e762013-02-19 15:06:50 -08005996 }
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07005997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005998
5999 return 0;
6000}
6001
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006002static int iw_clear_dynamic_mcbc_filter(struct net_device *dev,
Madan Mohan Koyyalamudif55e62a2012-09-24 11:14:27 -07006003 struct iw_request_info *info,
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 union iwreq_data *wrqu, char *extra)
6005{
6006 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6007 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306008 tpSirWlanSetRxpFilters wlanRxpFilterParam;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006009 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006010
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306011 //Reset the filter to INI value as we have to clear the dynamic filter
6012 pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting;
Jeff Johnson295189b2012-06-20 16:38:30 -07006013
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306014 //Configure FW with new setting
6015 if (pHddCtx->hdd_wlan_suspended)
6016 {
6017 wlanRxpFilterParam = vos_mem_malloc(sizeof(tSirWlanSetRxpFilters));
6018 if (NULL == wlanRxpFilterParam)
6019 {
6020 hddLog(VOS_TRACE_LEVEL_ERROR,
6021 "%s: vos_mem_alloc failed", __func__);
6022 return -EINVAL;
6023 }
6024
6025 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6026 pHddCtx->configuredMcastBcastFilter;
6027 wlanRxpFilterParam->setMcstBcstFilter = TRUE;
6028
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306029 hdd_conf_hostoffload(pAdapter, TRUE);
6030 wlanRxpFilterParam->configuredMcstBcstFilterSetting =
6031 pHddCtx->configuredMcastBcastFilter;
Gopichand Nakkalab8f0f1a2013-05-23 18:19:48 +05306032
6033 if (eHAL_STATUS_SUCCESS !=
6034 sme_ConfigureRxpFilter(WLAN_HDD_GET_HAL_CTX(pAdapter),
6035 wlanRxpFilterParam))
6036 {
6037 hddLog(VOS_TRACE_LEVEL_ERROR,
6038 "%s: Failure to execute set HW MC/BC Filter request",
6039 __func__);
6040 vos_mem_free(wlanRxpFilterParam);
6041 return -EINVAL;
6042 }
6043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 return 0;
6045}
6046
6047static int iw_set_host_offload(struct net_device *dev, struct iw_request_info *info,
6048 union iwreq_data *wrqu, char *extra)
6049{
6050 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006051 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 tSirHostOffloadReq offloadRequest;
6053
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006054 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6055 {
6056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6057 "%s:LOGP in Progress. Ignore!!!", __func__);
6058 return -EBUSY;
6059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 /* Debug display of request components. */
6061 switch (pRequest->offloadType)
6062 {
6063 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006064 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Host offload request: ARP reply", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 switch (pRequest->enableOrDisable)
6066 {
6067 case WLAN_OFFLOAD_DISABLE:
6068 hddLog(VOS_TRACE_LEVEL_WARN, " disable");
6069 break;
6070 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
6071 hddLog(VOS_TRACE_LEVEL_WARN, " BC Filtering enable");
6072 case WLAN_OFFLOAD_ENABLE:
6073 hddLog(VOS_TRACE_LEVEL_WARN, " ARP offload enable");
6074 hddLog(VOS_TRACE_LEVEL_WARN, " IP address: %d.%d.%d.%d",
6075 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
6076 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
6077 }
6078 break;
6079
6080 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Arif Hussain6d2a3322013-11-17 19:50:10 -08006081 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Host offload request: neighbor discovery",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006082 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 switch (pRequest->enableOrDisable)
6084 {
6085 case WLAN_OFFLOAD_DISABLE:
6086 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " disable");
6087 break;
6088 case WLAN_OFFLOAD_ENABLE:
6089 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " enable");
6090 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, " IP address: %x:%x:%x:%x:%x:%x:%x:%x",
6091 *(v_U16_t *)(pRequest->params.hostIpv6Addr),
6092 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 2),
6093 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 4),
6094 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 6),
6095 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 8),
6096 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 10),
6097 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 12),
6098 *(v_U16_t *)(pRequest->params.hostIpv6Addr + 14));
6099 }
6100 }
6101
6102 /* Execute offload request. The reason that we can copy the request information
6103 from the ioctl structure to the SME structure is that they are laid out
6104 exactly the same. Otherwise, each piece of information would have to be
6105 copied individually. */
6106 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Jeff Johnsone7245742012-09-05 17:12:55 -07006107 if (eHAL_STATUS_SUCCESS != sme_SetHostOffload(WLAN_HDD_GET_HAL_CTX(pAdapter),
6108 pAdapter->sessionId, &offloadRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006110 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute host offload request",
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 __func__);
6112 return -EINVAL;
6113 }
6114
6115 return 0;
6116}
6117
6118static int iw_set_keepalive_params(struct net_device *dev, struct iw_request_info *info,
6119 union iwreq_data *wrqu, char *extra)
6120{
6121 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain7adce1b2013-11-11 22:59:34 -08006122 tpKeepAliveRequest pRequest = (tpKeepAliveRequest) extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 tSirKeepAliveReq keepaliveRequest;
6124
6125 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
6126 {
6127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006128 "%s:LOGP in Progress. Ignore!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 return 0;
6130 }
6131
6132 /* Debug display of request components. */
Jeff Johnson59a121e2013-11-30 09:46:08 -08006133 hddLog(VOS_TRACE_LEVEL_INFO,
6134 "%s: Set Keep Alive Request : TimePeriod %d size %zu",
6135 __func__, pRequest->timePeriod, sizeof(tKeepAliveRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07006136
6137 switch (pRequest->packetType)
6138 {
6139 case WLAN_KEEP_ALIVE_NULL_PKT:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006140 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Keep Alive Request: Tx NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 break;
6142
6143 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
6144
Arif Hussain6d2a3322013-11-17 19:50:10 -08006145 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Keep Alive Request: Tx UnSolicited ARP RSP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006146 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006147
6148 hddLog(VOS_TRACE_LEVEL_WARN, " Host IP address: %d.%d.%d.%d",
6149 pRequest->hostIpv4Addr[0], pRequest->hostIpv4Addr[1],
6150 pRequest->hostIpv4Addr[2], pRequest->hostIpv4Addr[3]);
6151
6152 hddLog(VOS_TRACE_LEVEL_WARN, " Dest IP address: %d.%d.%d.%d",
6153 pRequest->destIpv4Addr[0], pRequest->destIpv4Addr[1],
6154 pRequest->destIpv4Addr[2], pRequest->destIpv4Addr[3]);
6155
6156 hddLog(VOS_TRACE_LEVEL_WARN, " Dest MAC address: %d:%d:%d:%d:%d:%d",
6157 pRequest->destMacAddr[0], pRequest->destMacAddr[1],
6158 pRequest->destMacAddr[2], pRequest->destMacAddr[3],
6159 pRequest->destMacAddr[4], pRequest->destMacAddr[5]);
6160 break;
6161
6162 }
6163
6164 /* Execute keep alive request. The reason that we can copy the request information
6165 from the ioctl structure to the SME structure is that they are laid out
6166 exactly the same. Otherwise, each piece of information would have to be
6167 copied individually. */
6168 memcpy(&keepaliveRequest, pRequest, wrqu->data.length);
6169
Arif Hussain6d2a3322013-11-17 19:50:10 -08006170 hddLog(VOS_TRACE_LEVEL_ERROR, "set Keep: TP before SME %d", keepaliveRequest.timePeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07006171
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006172 if (eHAL_STATUS_SUCCESS != sme_SetKeepAlive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsone7245742012-09-05 17:12:55 -07006173 pAdapter->sessionId, &keepaliveRequest))
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006175 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Keep Alive",
Jeff Johnson295189b2012-06-20 16:38:30 -07006176 __func__);
6177 return -EINVAL;
6178 }
6179
6180 return 0;
6181}
6182
6183#ifdef WLAN_FEATURE_PACKET_FILTERING
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006184int wlan_hdd_set_filter(hdd_context_t *pHddCtx, tpPacketFilterCfg pRequest,
Jeff Johnsone7245742012-09-05 17:12:55 -07006185 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006186{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006187 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6188 tSirRcvFltPktClearParam packetFilterClrReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 int i=0;
6190
6191 if (pHddCtx->cfg_ini->disablePacketFilter)
6192 {
6193 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Packet Filtering Disabled. Returning ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006194 __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 return 0;
6196 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006197 if (pHddCtx->isLogpInProgress)
6198 {
6199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6200 "%s:LOGP in Progress. Ignore!!!", __func__);
6201 return -EBUSY;
6202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 /* Debug display of request components. */
6204 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Packet Filter Request : FA %d params %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006205 __func__, pRequest->filterAction, pRequest->numParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07006206
6207 switch (pRequest->filterAction)
6208 {
6209 case HDD_RCV_FILTER_SET:
6210 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006211 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006212
6213 packetFilterSetReq.filterId = pRequest->filterId;
6214 if ( pRequest->numParams >= HDD_MAX_CMP_PER_PACKET_FILTER)
6215 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006216 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Number of Params exceed Max limit %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 __func__, pRequest->numParams);
6218 return -EINVAL;
6219 }
6220 packetFilterSetReq.numFieldParams = pRequest->numParams;
6221 packetFilterSetReq.coalesceTime = 0;
6222 packetFilterSetReq.filterType = 1;
6223 for (i=0; i < pRequest->numParams; i++)
6224 {
6225 packetFilterSetReq.paramsData[i].protocolLayer = pRequest->paramsData[i].protocolLayer;
6226 packetFilterSetReq.paramsData[i].cmpFlag = pRequest->paramsData[i].cmpFlag;
6227 packetFilterSetReq.paramsData[i].dataOffset = pRequest->paramsData[i].dataOffset;
6228 packetFilterSetReq.paramsData[i].dataLength = pRequest->paramsData[i].dataLength;
6229 packetFilterSetReq.paramsData[i].reserved = 0;
6230
Arif Hussain6d2a3322013-11-17 19:50:10 -08006231 hddLog(VOS_TRACE_LEVEL_INFO, "Proto %d Comp Flag %d Filter Type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 pRequest->paramsData[i].protocolLayer, pRequest->paramsData[i].cmpFlag,
6233 packetFilterSetReq.filterType);
6234
Arif Hussain6d2a3322013-11-17 19:50:10 -08006235 hddLog(VOS_TRACE_LEVEL_INFO, "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 pRequest->paramsData[i].dataOffset, pRequest->paramsData[i].dataLength);
6237
6238 memcpy(&packetFilterSetReq.paramsData[i].compareData,
6239 pRequest->paramsData[i].compareData, pRequest->paramsData[i].dataLength);
6240 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
6241 pRequest->paramsData[i].dataMask, pRequest->paramsData[i].dataLength);
6242
Arif Hussain6d2a3322013-11-17 19:50:10 -08006243 hddLog(VOS_TRACE_LEVEL_INFO, "CData %d CData %d CData %d CData %d CData %d CData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 pRequest->paramsData[i].compareData[0], pRequest->paramsData[i].compareData[1],
6245 pRequest->paramsData[i].compareData[2], pRequest->paramsData[i].compareData[3],
6246 pRequest->paramsData[i].compareData[4], pRequest->paramsData[i].compareData[5]);
6247
Arif Hussain6d2a3322013-11-17 19:50:10 -08006248 hddLog(VOS_TRACE_LEVEL_INFO, "MData %d MData %d MData %d MData %d MData %d MData %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006249 pRequest->paramsData[i].dataMask[0], pRequest->paramsData[i].dataMask[1],
6250 pRequest->paramsData[i].dataMask[2], pRequest->paramsData[i].dataMask[3],
6251 pRequest->paramsData[i].dataMask[4], pRequest->paramsData[i].dataMask[5]);
6252 }
6253
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006254 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal, &packetFilterSetReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006256 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Set Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 __func__);
6258 return -EINVAL;
6259 }
6260
6261 break;
6262
6263 case HDD_RCV_FILTER_CLEAR:
6264
Arif Hussain6d2a3322013-11-17 19:50:10 -08006265 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Clear Packet Filter Request for Id: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006266 __func__, pRequest->filterId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 packetFilterClrReq.filterId = pRequest->filterId;
Madan Mohan Koyyalamudi59a40c92012-09-24 14:13:16 -07006268 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal, &packetFilterClrReq, sessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006270 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failure to execute Clear Filter",
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 __func__);
6272 return -EINVAL;
6273 }
6274 break;
6275
6276 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08006277 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Packet Filter Request: Invalid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006278 __func__, pRequest->filterAction);
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 return -EINVAL;
6280 }
6281 return 0;
6282}
6283
Gopichand Nakkala227c7f32013-06-26 22:44:57 +05306284int wlan_hdd_setIPv6Filter(hdd_context_t *pHddCtx, tANI_U8 filterType,
6285 tANI_U8 sessionId)
6286{
6287 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
6288 tSirRcvFltPktClearParam packetFilterClrReq = {0};
6289
6290 if (NULL == pHddCtx)
6291 {
6292 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" NULL HDD Context Passed"));
6293 return -EINVAL;
6294 }
6295
6296 if (pHddCtx->isLogpInProgress)
6297 {
6298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6299 "%s:LOGP in Progress. Ignore!!!", __func__);
6300 return -EBUSY;
6301 }
6302
6303 if (pHddCtx->cfg_ini->disablePacketFilter)
6304 {
6305 hddLog(VOS_TRACE_LEVEL_ERROR,
6306 "%s: Packet Filtering Disabled. Returning ",
6307 __func__ );
6308 return -EINVAL;
6309 }
6310
6311 switch (filterType)
6312 {
6313 /* For setting IPV6 MC and UC Filter we need to configure
6314 * 2 filters, one for MC and one for UC.
6315 * The Filter ID shouldn't be swapped, which results in making
6316 * UC Filter ineffective.
6317 * We have Hardcode all the values
6318 *
6319 * Reason for a seperate UC filter is because, driver need to
6320 * specify the FW that the specific filter is for unicast
6321 * otherwise FW will not pass the unicast frames by default
6322 * through the filter. This is required to avoid any performance
6323 * hits when no unicast filter is set and only MC/BC are set.
6324 * The way driver informs host is by using the MAC protocol
6325 * layer, CMP flag set to MAX, CMP Data set to 1.
6326 */
6327
6328 case HDD_FILTER_IPV6_MC_UC:
6329 /* Setting IPV6 MC Filter below
6330 */
6331 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6332 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6333 packetFilterSetReq.numFieldParams = 2;
6334 packetFilterSetReq.paramsData[0].protocolLayer =
6335 HDD_FILTER_PROTO_TYPE_MAC;
6336 packetFilterSetReq.paramsData[0].cmpFlag =
6337 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6338 packetFilterSetReq.paramsData[0].dataOffset =
6339 WLAN_HDD_80211_FRM_DA_OFFSET;
6340 packetFilterSetReq.paramsData[0].dataLength = 1;
6341 packetFilterSetReq.paramsData[0].compareData[0] =
6342 HDD_IPV6_MC_CMP_DATA;
6343
6344 packetFilterSetReq.paramsData[1].protocolLayer =
6345 HDD_FILTER_PROTO_TYPE_ARP;
6346 packetFilterSetReq.paramsData[1].cmpFlag =
6347 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6348 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6349 packetFilterSetReq.paramsData[1].dataLength = 2;
6350 packetFilterSetReq.paramsData[1].compareData[0] =
6351 HDD_IPV6_CMP_DATA_0;
6352 packetFilterSetReq.paramsData[1].compareData[1] =
6353 HDD_IPV6_CMP_DATA_1;
6354
6355
6356 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6357 &packetFilterSetReq, sessionId))
6358 {
6359 hddLog(VOS_TRACE_LEVEL_ERROR,
6360 "%s: Failure to execute Set IPv6 Mulicast Filter",
6361 __func__);
6362 return -EINVAL;
6363 }
6364
6365 memset( &packetFilterSetReq, 0, sizeof(tSirRcvPktFilterCfgType));
6366
6367 /*
6368 * Setting IPV6 UC Filter below
6369 */
6370 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6371 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_UC;
6372 packetFilterSetReq.numFieldParams = 2;
6373 packetFilterSetReq.paramsData[0].protocolLayer =
6374 HDD_FILTER_PROTO_TYPE_MAC;
6375 packetFilterSetReq.paramsData[0].cmpFlag =
6376 HDD_FILTER_CMP_TYPE_MAX;
6377 packetFilterSetReq.paramsData[0].dataOffset = 0;
6378 packetFilterSetReq.paramsData[0].dataLength = 1;
6379 packetFilterSetReq.paramsData[0].compareData[0] =
6380 HDD_IPV6_UC_CMP_DATA;
6381
6382 packetFilterSetReq.paramsData[1].protocolLayer =
6383 HDD_FILTER_PROTO_TYPE_ARP;
6384 packetFilterSetReq.paramsData[1].cmpFlag =
6385 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6386 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6387 packetFilterSetReq.paramsData[1].dataLength = 2;
6388 packetFilterSetReq.paramsData[1].compareData[0] =
6389 HDD_IPV6_CMP_DATA_0;
6390 packetFilterSetReq.paramsData[1].compareData[1] =
6391 HDD_IPV6_CMP_DATA_1;
6392
6393 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6394 &packetFilterSetReq, sessionId))
6395 {
6396 hddLog(VOS_TRACE_LEVEL_ERROR,
6397 "%s: Failure to execute Set IPv6 Unicast Filter",
6398 __func__);
6399 return -EINVAL;
6400 }
6401
6402 break;
6403
6404 case HDD_FILTER_IPV6_MC:
6405 /*
6406 * IPV6 UC Filter might be already set,
6407 * clear the UC Filter. As the Filter
6408 * IDs are static, we can directly clear it.
6409 */
6410 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
6411 packetFilterClrReq.filterId = HDD_FILTER_ID_IPV6_UC;
6412 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterClearFilter(pHddCtx->hHal,
6413 &packetFilterClrReq, sessionId))
6414 {
6415 hddLog(VOS_TRACE_LEVEL_ERROR,
6416 "%s: Failure to execute Clear IPv6 Unicast Filter",
6417 __func__);
6418 return -EINVAL;
6419 }
6420
6421 /*
6422 * Setting IPV6 MC Filter below
6423 */
6424 packetFilterSetReq.filterId = HDD_FILTER_ID_IPV6_MC;
6425 packetFilterSetReq.numFieldParams = 2;
6426 packetFilterSetReq.paramsData[0].protocolLayer =
6427 HDD_FILTER_PROTO_TYPE_MAC;
6428 packetFilterSetReq.paramsData[0].cmpFlag =
6429 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6430 packetFilterSetReq.paramsData[0].dataOffset =
6431 WLAN_HDD_80211_FRM_DA_OFFSET;
6432 packetFilterSetReq.paramsData[0].dataLength = 1;
6433 packetFilterSetReq.paramsData[0].compareData[0] =
6434 HDD_IPV6_MC_CMP_DATA;
6435
6436 packetFilterSetReq.paramsData[1].protocolLayer =
6437 HDD_FILTER_PROTO_TYPE_ARP;
6438 packetFilterSetReq.paramsData[1].cmpFlag =
6439 HDD_FILTER_CMP_TYPE_NOT_EQUAL;
6440 packetFilterSetReq.paramsData[1].dataOffset = ETH_ALEN;
6441 packetFilterSetReq.paramsData[1].dataLength = 2;
6442 packetFilterSetReq.paramsData[1].compareData[0] =
6443 HDD_IPV6_CMP_DATA_0;
6444 packetFilterSetReq.paramsData[1].compareData[1] =
6445 HDD_IPV6_CMP_DATA_1;
6446
6447
6448 if (eHAL_STATUS_SUCCESS != sme_ReceiveFilterSetFilter(pHddCtx->hHal,
6449 &packetFilterSetReq, sessionId))
6450 {
6451 hddLog(VOS_TRACE_LEVEL_ERROR,
6452 "%s: Failure to execute Set IPv6 Multicast Filter",
6453 __func__);
6454 return -EINVAL;
6455 }
6456 break;
6457
6458 default :
6459 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6460 "%s: Packet Filter Request: Invalid",
6461 __func__);
6462 return -EINVAL;
6463 }
6464 return 0;
6465}
6466
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306467void wlan_hdd_set_mc_addr_list(hdd_adapter_t *pAdapter, v_U8_t set)
Jeff Johnson295189b2012-06-20 16:38:30 -07006468{
Gopichand Nakkala0f276812013-02-24 14:45:51 +05306469 v_U8_t i;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306470 tpSirRcvFltMcAddrList pMulticastAddrs = NULL;
Yue Ma3ede6052013-08-29 00:33:26 -07006471 tHalHandle hHal = NULL;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306472 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006473
Yue Ma3ede6052013-08-29 00:33:26 -07006474 if (NULL == pHddCtx)
6475 {
6476 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD CTX is NULL"));
6477 return;
6478 }
6479
6480 hHal = pHddCtx->hHal;
6481
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306482 if (NULL == hHal)
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306484 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HAL Handle is NULL"));
6485 return;
6486 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306487
6488 /* Check if INI is enabled or not, other wise just return
6489 */
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306490 if (pHddCtx->cfg_ini->fEnableMCAddrList)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306491 {
6492 pMulticastAddrs = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6493 if (NULL == pMulticastAddrs)
6494 {
6495 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Could not allocate Memory"));
6496 return;
6497 }
6498
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 if (set)
6500 {
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306501 /* Following pre-conditions should be satisfied before wei
6502 * configure the MC address list.
6503 */
6504 if (((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
6505 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT))
6506 && pAdapter->mc_addr_list.mc_cnt
6507 && (eConnectionState_Associated ==
6508 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6509 {
6510 pMulticastAddrs->ulMulticastAddrCnt =
6511 pAdapter->mc_addr_list.mc_cnt;
6512 for (i = 0; i < pAdapter->mc_addr_list.mc_cnt; i++)
6513 {
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006514 memcpy(pMulticastAddrs->multicastAddr[i],
6515 pAdapter->mc_addr_list.addr[i],
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306516 sizeof(pAdapter->mc_addr_list.addr[i]));
6517 hddLog(VOS_TRACE_LEVEL_INFO,
6518 "%s: %s multicast filter: addr ="
6519 MAC_ADDRESS_STR,
6520 __func__, set ? "setting" : "clearing",
6521 MAC_ADDR_ARRAY(pMulticastAddrs->multicastAddr[i]));
6522 }
6523 /* Set multicast filter */
6524 sme_8023MulticastList(hHal, pAdapter->sessionId,
6525 pMulticastAddrs);
6526 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306528 else
6529 {
6530 /* Need to clear only if it was previously configured
6531 */
6532 if (pAdapter->mc_addr_list.isFilterApplied)
6533 {
6534 pMulticastAddrs->ulMulticastAddrCnt = 0;
6535 sme_8023MulticastList(hHal, pAdapter->sessionId,
6536 pMulticastAddrs);
6537 }
6538
6539 }
6540 pAdapter->mc_addr_list.isFilterApplied = set ? TRUE : FALSE;
Sameer Thalappilb492efd2013-10-23 14:21:51 -07006541 vos_mem_free(pMulticastAddrs);
Jeff Johnson295189b2012-06-20 16:38:30 -07006542 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306543 else
6544 {
6545 hddLog(VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudiac94c7e2013-08-12 09:37:34 +05306546 FL("gMCAddrListEnable is not enabled in INI"));
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306547 }
6548 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07006549}
6550
6551static int iw_set_packet_filter_params(struct net_device *dev, struct iw_request_info *info,
6552 union iwreq_data *wrqu, char *extra)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05306553{
Jeff Johnson295189b2012-06-20 16:38:30 -07006554 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Arif Hussain0273cba2014-01-07 20:58:29 -08006555 tpPacketFilterCfg pRequest = NULL;
6556 int ret;
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306557 struct iw_point s_priv_data;
6558
6559 if (hdd_priv_get_data(&s_priv_data, wrqu))
6560 {
6561 return -EINVAL;
6562 }
6563
6564 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
6565 {
6566 return -EINVAL;
6567 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08006568
Arif Hussain0273cba2014-01-07 20:58:29 -08006569 /* ODD number is used for set, copy data using copy_from_user */
Girish Gowlidfdf85e2014-06-12 21:01:35 +05306570 pRequest = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6571 s_priv_data.length);
Arif Hussain0273cba2014-01-07 20:58:29 -08006572 if (NULL == pRequest)
6573 {
6574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6575 "mem_alloc_copy_from_user_helper fail");
6576 return -ENOMEM;
6577 }
6578
6579 ret = wlan_hdd_set_filter(WLAN_HDD_GET_CTX(pAdapter), pRequest, pAdapter->sessionId);
6580 kfree(pRequest);
6581
6582 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006583}
6584#endif
6585static int iw_get_statistics(struct net_device *dev,
6586 struct iw_request_info *info,
6587 union iwreq_data *wrqu, char *extra)
6588{
6589
6590 VOS_STATUS vos_status = VOS_STATUS_SUCCESS;
6591 eHalStatus status = eHAL_STATUS_SUCCESS;
6592 hdd_wext_state_t *pWextState;
6593 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6594 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6595 char *p = extra;
6596 int tlen = 0;
6597 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
6598
6599 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
6600 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
6601
6602 ENTER();
6603
6604 if (pHddCtx->isLogpInProgress) {
6605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
6606 return -EINVAL;
6607 }
6608
6609 if (eConnectionState_Associated != (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
6610
6611 wrqu->txpower.value = 0;
6612 }
6613 else {
6614 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6615 SME_SUMMARY_STATS |
6616 SME_GLOBAL_CLASSA_STATS |
6617 SME_GLOBAL_CLASSB_STATS |
6618 SME_GLOBAL_CLASSC_STATS |
6619 SME_GLOBAL_CLASSD_STATS |
6620 SME_PER_STA_STATS,
6621 hdd_StatisticsCB, 0, FALSE,
6622 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6623
6624 if (eHAL_STATUS_SUCCESS != status)
6625 {
6626 hddLog(VOS_TRACE_LEVEL_ERROR,
6627 "%s: Unable to retrieve SME statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006628 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 return -EINVAL;
6630 }
6631
6632 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6633
6634 vos_status = vos_wait_single_event(&pWextState->vosevent, WLAN_WAIT_TIME_STATS);
6635 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6636 {
6637 hddLog(VOS_TRACE_LEVEL_ERROR,
6638 "%s: SME timeout while retrieving statistics",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006639 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 /*Remove the SME statistics list by passing NULL in callback argument*/
6641 status = sme_GetStatistics( pHddCtx->hHal, eCSR_HDD,
6642 SME_SUMMARY_STATS |
6643 SME_GLOBAL_CLASSA_STATS |
6644 SME_GLOBAL_CLASSB_STATS |
6645 SME_GLOBAL_CLASSC_STATS |
6646 SME_GLOBAL_CLASSD_STATS |
6647 SME_PER_STA_STATS,
6648 NULL, 0, FALSE,
6649 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0], pAdapter );
6650
6651 return -EINVAL;
6652 }
6653 FILL_TLV(p, (tANI_U8)WLAN_STATS_RETRY_CNT,
6654 (tANI_U8) sizeof (pStats->retry_cnt),
6655 (char*) &(pStats->retry_cnt[0]),
6656 tlen);
6657
6658 FILL_TLV(p, (tANI_U8)WLAN_STATS_MUL_RETRY_CNT,
6659 (tANI_U8) sizeof (pStats->multiple_retry_cnt),
6660 (char*) &(pStats->multiple_retry_cnt[0]),
6661 tlen);
6662
6663 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_FRM_CNT,
6664 (tANI_U8) sizeof (pStats->tx_frm_cnt),
6665 (char*) &(pStats->tx_frm_cnt[0]),
6666 tlen);
6667
6668 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_FRM_CNT,
6669 (tANI_U8) sizeof (pStats->rx_frm_cnt),
6670 (char*) &(pStats->rx_frm_cnt),
6671 tlen);
6672
6673 FILL_TLV(p, (tANI_U8)WLAN_STATS_FRM_DUP_CNT,
6674 (tANI_U8) sizeof (pStats->frm_dup_cnt),
6675 (char*) &(pStats->frm_dup_cnt),
6676 tlen);
6677
6678 FILL_TLV(p, (tANI_U8)WLAN_STATS_FAIL_CNT,
6679 (tANI_U8) sizeof (pStats->fail_cnt),
6680 (char*) &(pStats->fail_cnt[0]),
6681 tlen);
6682
6683 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_FAIL_CNT,
6684 (tANI_U8) sizeof (pStats->rts_fail_cnt),
6685 (char*) &(pStats->rts_fail_cnt),
6686 tlen);
6687
6688 FILL_TLV(p, (tANI_U8)WLAN_STATS_ACK_FAIL_CNT,
6689 (tANI_U8) sizeof (pStats->ack_fail_cnt),
6690 (char*) &(pStats->ack_fail_cnt),
6691 tlen);
6692
6693 FILL_TLV(p, (tANI_U8)WLAN_STATS_RTS_SUC_CNT,
6694 (tANI_U8) sizeof (pStats->rts_succ_cnt),
6695 (char*) &(pStats->rts_succ_cnt),
6696 tlen);
6697
6698 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_DISCARD_CNT,
6699 (tANI_U8) sizeof (pStats->rx_discard_cnt),
6700 (char*) &(pStats->rx_discard_cnt),
6701 tlen);
6702
6703 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_ERROR_CNT,
6704 (tANI_U8) sizeof (pStats->rx_error_cnt),
6705 (char*) &(pStats->rx_error_cnt),
6706 tlen);
6707
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006708 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BYTE_CNT,
Jeff Johnsone7245742012-09-05 17:12:55 -07006709 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006710 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnson295189b2012-06-20 16:38:30 -07006711 tlen);
6712
6713 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BYTE_CNT,
6714 (tANI_U8) sizeof (dStats->rx_byte_cnt),
6715 (char*) &(dStats->rx_byte_cnt),
6716 tlen);
6717
6718 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_RATE,
6719 (tANI_U8) sizeof (dStats->rx_rate),
6720 (char*) &(dStats->rx_rate),
6721 tlen);
6722
6723 /* Transmit rate, in units of 500 kbit/sec */
6724 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_RATE,
6725 (tANI_U8) sizeof (aStats->tx_rate),
6726 (char*) &(aStats->tx_rate),
6727 tlen);
6728
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006729 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_UC_BYTE_CNT,
6730 (tANI_U8) sizeof (dStats->rx_uc_byte_cnt[0]),
6731 (char*) &(dStats->rx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006732 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006733 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_MC_BYTE_CNT,
6734 (tANI_U8) sizeof (dStats->rx_mc_byte_cnt),
6735 (char*) &(dStats->rx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006736 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006737 FILL_TLV(p, (tANI_U8)WLAN_STATS_RX_BC_BYTE_CNT,
6738 (tANI_U8) sizeof (dStats->rx_bc_byte_cnt),
6739 (char*) &(dStats->rx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006740 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006741 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_UC_BYTE_CNT,
6742 (tANI_U8) sizeof (dStats->tx_uc_byte_cnt[0]),
6743 (char*) &(dStats->tx_uc_byte_cnt[0]),
Jeff Johnsone7245742012-09-05 17:12:55 -07006744 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006745 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_MC_BYTE_CNT,
6746 (tANI_U8) sizeof (dStats->tx_mc_byte_cnt),
6747 (char*) &(dStats->tx_mc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006748 tlen);
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08006749 FILL_TLV(p, (tANI_U8)WLAN_STATS_TX_BC_BYTE_CNT,
6750 (tANI_U8) sizeof (dStats->tx_bc_byte_cnt),
6751 (char*) &(dStats->tx_bc_byte_cnt),
Jeff Johnsone7245742012-09-05 17:12:55 -07006752 tlen);
6753
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 wrqu->data.length = tlen;
6755
6756 }
6757
6758 EXIT();
6759
6760 return 0;
6761}
6762
6763
6764#ifdef FEATURE_WLAN_SCAN_PNO
6765
6766/*Max Len for PNO notification*/
6767#define MAX_PNO_NOTIFY_LEN 100
6768void found_pref_network_cb (void *callbackContext,
6769 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
6770{
6771 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
6772 union iwreq_data wrqu;
6773 char buf[MAX_PNO_NOTIFY_LEN+1];
6774
6775 hddLog(VOS_TRACE_LEVEL_WARN, "A preferred network was found: %s with rssi: -%d",
6776 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
6777
6778 // create the event
6779 memset(&wrqu, 0, sizeof(wrqu));
6780 memset(buf, 0, sizeof(buf));
6781
6782 snprintf(buf, MAX_PNO_NOTIFY_LEN, "QCOM: Found preferred network: %s with RSSI of -%u",
6783 pPrefNetworkFoundInd->ssId.ssId,
6784 (unsigned int)pPrefNetworkFoundInd->rssi);
6785
6786 wrqu.data.pointer = buf;
6787 wrqu.data.length = strlen(buf);
6788
6789 // send the event
6790
6791 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6792
6793}
6794
6795
6796/*string based input*/
6797VOS_STATUS iw_set_pno(struct net_device *dev, struct iw_request_info *info,
6798 union iwreq_data *wrqu, char *extra, int nOffset)
6799{
6800 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
c_hpothu37f21312014-04-09 21:49:54 +05306801 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi729972c2012-10-21 12:39:24 -07006802 /* pnoRequest is a large struct, so we make it static to avoid stack
6803 overflow. This API is only invoked via ioctl, so it is
6804 serialized by the kernel rtnl_lock and hence does not need to be
6805 reentrant */
6806 static tSirPNOScanReq pnoRequest;
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 char *ptr;
6808 v_U8_t i,j, ucParams, ucMode;
c_hpothu37f21312014-04-09 21:49:54 +05306809 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
6811
6812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6813 "PNO data len %d data %s",
6814 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08006815 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07006816
6817 if (wrqu->data.length <= nOffset )
6818 {
6819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "PNO input is not correct");
6820 return VOS_STATUS_E_FAILURE;
6821 }
6822
6823 pnoRequest.enable = 0;
6824 pnoRequest.ucNetworksCount = 0;
6825 /*-----------------------------------------------------------------------
6826 Input is string based and expected to be like this:
6827
6828 <enabled> <netw_count>
6829 for each network:
6830 <ssid_len> <ssid> <authentication> <encryption>
6831 <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
6832 <scan_timers> <scan_time> <scan_repeat> <scan_time> <scan_repeat>
6833
6834 e.g:
Jeff Johnson8301aa12013-03-28 14:27:29 -07006835 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 -07006836
6837 this translates into:
6838 -----------------------------
6839 enable PNO
6840 look for 2 networks:
6841 test - with authentication type 0 and encryption type 0,
6842 that can be found on 3 channels: 1 6 and 11 ,
6843 SSID bcast type is unknown (directed probe will be sent if AP not found)
6844 and must meet -40dBm RSSI
6845
6846 test2 - with auth and enrytption type 4/4
6847 that can be found on 6 channels 1, 2, 3, 4, 5 and 6
6848 bcast type is non-bcast (directed probe will be sent)
6849 and must not meet any RSSI threshold
6850
Jeff Johnson8301aa12013-03-28 14:27:29 -07006851 scan every 5 seconds 2 times, scan every 300 seconds until stopped
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 -----------------------------------------------------------------------*/
Arif Hussain7adce1b2013-11-11 22:59:34 -08006853 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006854
Wilson Yang623f6592013-10-08 16:33:37 -07006855 if (1 != sscanf(ptr,"%hhu%n", &(pnoRequest.enable), &nOffset))
6856 {
6857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6858 "PNO enable input is not valid %s",ptr);
6859 return VOS_STATUS_E_FAILURE;
6860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006861
6862 if ( 0 == pnoRequest.enable )
6863 {
6864 /*Disable PNO*/
6865 memset(&pnoRequest, 0, sizeof(pnoRequest));
c_hpothu37f21312014-04-09 21:49:54 +05306866 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
6867 &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 pAdapter->sessionId,
6869 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05306870 if (eHAL_STATUS_SUCCESS != status)
6871 {
6872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6873 "%s: failed to disable PNO", __func__);
6874 return VOS_STATUS_E_FAILURE;
6875 }
6876 pHddCtx->isPnoEnable = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 return VOS_STATUS_SUCCESS;
6878 }
6879
c_hpothu37f21312014-04-09 21:49:54 +05306880 if (TRUE == pHddCtx->isPnoEnable)
6881 {
6882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6883 FL("already PNO is enabled"));
6884 return -EBUSY;
6885 }
6886 pHddCtx->isPnoEnable = TRUE;
6887
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 ptr += nOffset;
Wilson Yang623f6592013-10-08 16:33:37 -07006889
6890 if (1 != sscanf(ptr,"%hhu %n", &(pnoRequest.ucNetworksCount), &nOffset))
6891 {
6892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6893 "PNO count input not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05306894 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07006895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006896
6897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6898 "PNO enable %d networks count %d offset %d",
6899 pnoRequest.enable,
6900 pnoRequest.ucNetworksCount,
6901 nOffset);
6902
6903 /* Parameters checking:
6904 ucNetworksCount has to be larger than 0*/
6905 if (( 0 == pnoRequest.ucNetworksCount ) ||
6906 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
6907 {
6908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Network input is not correct");
c_hpothu37f21312014-04-09 21:49:54 +05306909 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 }
6911
6912 ptr += nOffset;
6913
6914 for ( i = 0; i < pnoRequest.ucNetworksCount; i++ )
6915 {
6916
6917 pnoRequest.aNetworks[i].ssId.length = 0;
6918
Wilson Yang623f6592013-10-08 16:33:37 -07006919 ucParams = sscanf(ptr,"%hhu %n",
6920 &(pnoRequest.aNetworks[i].ssId.length),&nOffset);
6921
6922 if (1 != ucParams)
6923 {
6924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6925 "PNO ssid length input is not valid %s",ptr);
6926 return VOS_STATUS_E_FAILURE;
6927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006928
6929 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
6930 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
6931 {
6932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6933 "SSID Len %d is not correct for network %d",
6934 pnoRequest.aNetworks[i].ssId.length, i);
c_hpothu37f21312014-04-09 21:49:54 +05306935 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 }
6937
6938 /*Advance to SSID*/
6939 ptr += nOffset;
6940
Jeff Johnson8301aa12013-03-28 14:27:29 -07006941 memcpy(pnoRequest.aNetworks[i].ssId.ssId, ptr,
Amar Singhal751e6072013-01-24 16:02:56 -08006942 pnoRequest.aNetworks[i].ssId.length);
6943 ptr += pnoRequest.aNetworks[i].ssId.length;
6944
Jeff Johnson02797792013-10-26 19:17:13 -07006945 ucParams = sscanf(ptr,"%u %u %hhu %n",
Amar Singhal751e6072013-01-24 16:02:56 -08006946 &(pnoRequest.aNetworks[i].authentication),
6947 &(pnoRequest.aNetworks[i].encryption),
6948 &(pnoRequest.aNetworks[i].ucChannelCount),
6949 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07006950
Wilson Yang623f6592013-10-08 16:33:37 -07006951 if ( 3 != ucParams )
6952 {
6953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6954 "Incorrect cmd %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05306955 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07006956 }
6957
Jeff Johnson295189b2012-06-20 16:38:30 -07006958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006959 "PNO len %d ssid 0x%08x%08x%08x%08x%08x%08x%08x%08x"
Amar Singhal751e6072013-01-24 16:02:56 -08006960 "auth %d encry %d channel count %d offset %d",
6961 pnoRequest.aNetworks[i].ssId.length,
6962 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[0]),
6963 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[4]),
6964 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[8]),
6965 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[12]),
6966 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[16]),
6967 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[20]),
6968 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[24]),
6969 *((v_U32_t *) &pnoRequest.aNetworks[i].ssId.ssId[28]),
6970 pnoRequest.aNetworks[i].authentication,
6971 pnoRequest.aNetworks[i].encryption,
6972 pnoRequest.aNetworks[i].ucChannelCount,
6973 nOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -07006974
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 /*Advance to channel list*/
6976 ptr += nOffset;
6977
Wilson Yang623f6592013-10-08 16:33:37 -07006978 if (SIR_PNO_MAX_NETW_CHANNELS < pnoRequest.aNetworks[i].ucChannelCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07006979 {
6980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6981 "Incorrect number of channels");
6982 return VOS_STATUS_E_FAILURE;
6983 }
6984
6985 if ( 0 != pnoRequest.aNetworks[i].ucChannelCount)
6986 {
6987 for ( j = 0; j < pnoRequest.aNetworks[i].ucChannelCount; j++)
6988 {
Wilson Yang623f6592013-10-08 16:33:37 -07006989 if (1 != sscanf(ptr,"%hhu %n",
6990 &(pnoRequest.aNetworks[i].aChannels[j]),
6991 &nOffset))
6992 { VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6993 "PNO network channel input is not valid %s",ptr);
6994 return VOS_STATUS_E_FAILURE;
6995 }
6996 /*Advance to next channel number*/
6997 ptr += nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07006998 }
6999 }
7000
Jeff Johnson02797792013-10-26 19:17:13 -07007001 if (1 != sscanf(ptr,"%u %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007002 &(pnoRequest.aNetworks[i].bcastNetwType),
7003 &nOffset))
7004 {
7005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7006 "PNO broadcast network type input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307007 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007009
7010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7011 "PNO bcastNetwType %d offset %d",
7012 pnoRequest.aNetworks[i].bcastNetwType,
7013 nOffset );
7014
7015 /*Advance to rssi Threshold*/
7016 ptr += nOffset;
7017
Wilson Yang623f6592013-10-08 16:33:37 -07007018 if (1 != sscanf(ptr,"%hhu %n",
7019 &(pnoRequest.aNetworks[i].rssiThreshold),
7020 &nOffset))
7021 {
7022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7023 "PNO rssi threshold input is not valid %s",ptr);
c_hpothu37f21312014-04-09 21:49:54 +05307024 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007026
7027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7028 "PNO rssi %d offset %d",
7029 pnoRequest.aNetworks[i].rssiThreshold,
7030 nOffset );
7031 /*Advance to next network*/
7032 ptr += nOffset;
7033 }/*For ucNetworkCount*/
7034
7035 ucParams = sscanf(ptr,"%hhu %n",
Wilson Yang623f6592013-10-08 16:33:37 -07007036 &(pnoRequest.scanTimers.ucScanTimersCount),
7037 &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007038
7039 /*Read the scan timers*/
Jeff Johnson8301aa12013-03-28 14:27:29 -07007040 if (( 1 == ucParams ) && ( pnoRequest.scanTimers.ucScanTimersCount > 0 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 {
7042 ptr += nOffset;
7043
Jeff Johnson8301aa12013-03-28 14:27:29 -07007044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7045 "Scan timer count %d offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 pnoRequest.scanTimers.ucScanTimersCount,
7047 nOffset );
7048
7049 if ( SIR_PNO_MAX_SCAN_TIMERS < pnoRequest.scanTimers.ucScanTimersCount )
7050 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 "Incorrect cmd - too many scan timers");
c_hpothu37f21312014-04-09 21:49:54 +05307053 goto error;
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 }
7055
7056 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++ )
7057 {
Jeff Johnson02797792013-10-26 19:17:13 -07007058 ucParams = sscanf(ptr,"%u %u %n",
Jeff Johnson295189b2012-06-20 16:38:30 -07007059 &(pnoRequest.scanTimers.aTimerValues[i].uTimerValue),
7060 &( pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat),
7061 &nOffset);
7062
Wilson Yang623f6592013-10-08 16:33:37 -07007063 if (2 != ucParams)
7064 {
7065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7066 "Incorrect cmd - diff params then expected %d", ucParams);
c_hpothu37f21312014-04-09 21:49:54 +05307067 goto error;
Wilson Yang623f6592013-10-08 16:33:37 -07007068 }
7069
Jeff Johnson8301aa12013-03-28 14:27:29 -07007070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7071 "PNO Timer value %d Timer repeat %d offset %d",
7072 pnoRequest.scanTimers.aTimerValues[i].uTimerValue,
Jeff Johnson295189b2012-06-20 16:38:30 -07007073 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat,
7074 nOffset );
7075
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 ptr += nOffset;
7077 }
7078
7079 }
7080 else
7081 {
Jeff Johnson8301aa12013-03-28 14:27:29 -07007082 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7083 "No scan timers provided param count %d scan timers %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 ucParams, pnoRequest.scanTimers.ucScanTimersCount );
7085
7086 /*Scan timers defaults to 5 minutes*/
7087 pnoRequest.scanTimers.ucScanTimersCount = 1;
7088 pnoRequest.scanTimers.aTimerValues[0].uTimerValue = 60;
7089 pnoRequest.scanTimers.aTimerValues[0].uTimerRepeat = 0;
7090 }
7091
Wilson Yang623f6592013-10-08 16:33:37 -07007092 ucParams = sscanf(ptr,"%hhu %n",&(ucMode), &nOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07007093
7094 pnoRequest.modePNO = ucMode;
7095 /*for LA we just expose suspend option*/
7096 if (( 1 != ucParams )||( ucMode >= SIR_PNO_MODE_MAX ))
7097 {
7098 pnoRequest.modePNO = SIR_PNO_MODE_ON_SUSPEND;
7099 }
7100
c_hpothu37f21312014-04-09 21:49:54 +05307101 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), &pnoRequest,
Jeff Johnson295189b2012-06-20 16:38:30 -07007102 pAdapter->sessionId,
7103 found_pref_network_cb, pAdapter);
c_hpothu37f21312014-04-09 21:49:54 +05307104 if (eHAL_STATUS_SUCCESS == status)
7105 {
7106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7107 "%s: PNO enabled", __func__);
7108 return VOS_STATUS_SUCCESS;
7109 }
7110error:
7111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7112 "%s: Failed to enable PNO", __func__);
7113 pHddCtx->isPnoEnable = FALSE;
7114 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007115}/*iw_set_pno*/
7116
7117VOS_STATUS iw_set_rssi_filter(struct net_device *dev, struct iw_request_info *info,
7118 union iwreq_data *wrqu, char *extra, int nOffset)
7119{
7120 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7121 v_U8_t rssiThreshold = 0;
7122 v_U8_t nRead;
7123
Arif Hussain7adce1b2013-11-11 22:59:34 -08007124 nRead = sscanf(extra + nOffset,"%hhu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007125 &rssiThreshold);
7126
7127 if ( 1 != nRead )
7128 {
7129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7130 "Incorrect format");
7131 return VOS_STATUS_E_FAILURE;
7132 }
7133
7134 sme_SetRSSIFilter(WLAN_HDD_GET_HAL_CTX(pAdapter), rssiThreshold);
7135 return VOS_STATUS_SUCCESS;
7136}
7137
7138
7139static int iw_set_pno_priv(struct net_device *dev,
7140 struct iw_request_info *info,
7141 union iwreq_data *wrqu, char *extra)
7142{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007143 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7144
7145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 "Set PNO Private");
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007147
7148 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7149 {
7150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7151 "%s:LOGP in Progress. Ignore!!!", __func__);
7152 return -EBUSY;
7153 }
7154 return iw_set_pno(dev,info,wrqu,extra,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007155}
7156#endif /*FEATURE_WLAN_SCAN_PNO*/
7157
7158//Common function to SetBand
Atul Mittal54378cb2014-04-02 16:51:50 +05307159int hdd_setBand(struct net_device *dev, u8 ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007160{
7161 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7162 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7163 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal54378cb2014-04-02 16:51:50 +05307164 eCsrBand band;
Jeff Johnson295189b2012-06-20 16:38:30 -07007165 eCsrBand currBand = eCSR_BAND_MAX;
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307166 eCsrBand connectedBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007167
Atul Mittal54378cb2014-04-02 16:51:50 +05307168 switch(ui_band)
Jeff Johnson295189b2012-06-20 16:38:30 -07007169 {
7170 case WLAN_HDD_UI_BAND_AUTO:
7171 band = eCSR_BAND_ALL;
7172 break;
7173 case WLAN_HDD_UI_BAND_5_GHZ:
7174 band = eCSR_BAND_5G;
7175 break;
7176 case WLAN_HDD_UI_BAND_2_4_GHZ:
7177 band = eCSR_BAND_24;
7178 break;
7179 default:
7180 band = eCSR_BAND_MAX;
7181 }
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307182 connectedBand =
7183 hdd_connGetConnectedBand(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07007184
Atul Mittal54378cb2014-04-02 16:51:50 +05307185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007186 __func__, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007187
7188 if (band == eCSR_BAND_MAX)
7189 {
7190 /* Received change band request with invalid band value */
7191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Atul Mittal54378cb2014-04-02 16:51:50 +05307192 "%s: Invalid band value %u", __func__, ui_band);
7193 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 }
7195
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307196 if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
7197 (band == eCSR_BAND_5G && pHddCtx->cfg_ini->nBandCapability==1) ||
7198 (band == eCSR_BAND_ALL && pHddCtx->cfg_ini->nBandCapability!=0))
7199 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05307200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007201 "%s: band value %u violate INI settings %u", __func__,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007202 band, pHddCtx->cfg_ini->nBandCapability);
7203 return -EIO;
7204 }
7205
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 if (eHAL_STATUS_SUCCESS != sme_GetFreqBand(hHal, &currBand))
7207 {
7208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7209 "%s: Failed to get current band config",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007210 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 return -EIO;
7212 }
7213
7214 if (currBand != band)
7215 {
7216 /* Change band request received.
7217 * Abort pending scan requests, flush the existing scan results,
7218 * and change the band capability
7219 */
7220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7221 "%s: Current band value = %u, new setting %u ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007222 __func__, currBand, band);
Jeff Johnson295189b2012-06-20 16:38:30 -07007223
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307224 /* We need to change the band and flush the scan results here itself
7225 * as we may get timeout for disconnection in which we will return
7226 * with out doing any of these
7227 */
7228 if (eHAL_STATUS_SUCCESS != sme_SetFreqBand(hHal, (eCsrBand)band))
7229 {
7230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7231 "%s: failed to set the band value to %u ",
7232 __func__, band);
7233 return -EINVAL;
7234 }
7235 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand)band);
7236 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
7237 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
7238 sme_FilterScanResults(hHal, pAdapter->sessionId);
7239
7240 if (band != eCSR_BAND_ALL &&
Agarwal Ashish450ffde2014-04-08 19:53:00 +05307241 hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)) &&
7242 (connectedBand != band))
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 {
7244 hdd_station_ctx_t *pHddStaCtx = &(pAdapter)->sessionCtx.station;
7245 eHalStatus status = eHAL_STATUS_SUCCESS;
7246 long lrc;
7247
7248 /* STA already connected on current band, So issue disconnect first,
7249 * then change the band*/
7250
7251 hddLog(VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05307252 "%s STA connected in band %u, Changing band to %u, Issuing Disconnect."
7253 " Set HDD connState to eConnectionState_NotConnected",
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 __func__, csrGetCurrentBand(hHal), band);
7255
7256 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
7257 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7258
7259 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7260 pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7261
Jeff Johnson43971f52012-07-17 12:26:56 -07007262 if ( eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 {
7264 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007265 "%s csrRoamDisconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 __func__, (int)status );
7267 return -EINVAL;
7268 }
7269
7270 lrc = wait_for_completion_interruptible_timeout(
7271 &pAdapter->disconnect_comp_var,
7272 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7273
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05307274 if (lrc <= 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -07007275
Srinivas Girigowdacb4c6412013-07-02 10:19:12 -07007276 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: %s while waiting for csrRoamDisconnect ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007277 __func__, (0 == lrc) ? "Timeout" : "Interrupt");
Jeff Johnson295189b2012-06-20 16:38:30 -07007278
7279 return (0 == lrc) ? -ETIMEDOUT : -EINTR;
7280 }
7281 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007282 }
7283 return 0;
7284}
7285
Atul Mittal54378cb2014-04-02 16:51:50 +05307286int hdd_setBand_helper(struct net_device *dev, const char *command)
7287{
7288 u8 band;
7289
7290 /*convert the band value from ascii to integer*/
7291 band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
7292
7293 return hdd_setBand(dev, band);
7294
7295}
7296
Jeff Johnson295189b2012-06-20 16:38:30 -07007297static int iw_set_band_config(struct net_device *dev,
7298 struct iw_request_info *info,
7299 union iwreq_data *wrqu, char *extra)
7300{
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007301 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Atul Mittal54378cb2014-04-02 16:51:50 +05307302 int *value = (int *)extra;
Jeff Johnson295189b2012-06-20 16:38:30 -07007303
Arif Hussain0273cba2014-01-07 20:58:29 -08007304 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007305
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007306 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7307 {
7308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7309 "%s:LOGP in Progress. Ignore!!!", __func__);
7310 return -EBUSY;
7311 }
7312
Atul Mittal54378cb2014-04-02 16:51:50 +05307313 return hdd_setBand(dev, value[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007314}
7315
7316static int iw_set_power_params_priv(struct net_device *dev,
7317 struct iw_request_info *info,
7318 union iwreq_data *wrqu, char *extra)
7319{
Arif Hussain0273cba2014-01-07 20:58:29 -08007320 int ret;
7321 char *ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07007322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7323 "Set power params Private");
Arif Hussain0273cba2014-01-07 20:58:29 -08007324 /* ODD number is used for set, copy data using copy_from_user */
7325 ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
7326 wrqu->data.length);
7327 if (NULL == ptr)
7328 {
7329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7330 "mem_alloc_copy_from_user_helper fail");
7331 return -ENOMEM;
7332 }
7333
7334 ret = iw_set_power_params(dev, info, wrqu, ptr, 0);
7335 kfree(ptr);
7336 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007337}
7338
7339
7340
7341/*string based input*/
7342VOS_STATUS iw_set_power_params(struct net_device *dev, struct iw_request_info *info,
7343 union iwreq_data *wrqu, char *extra, int nOffset)
7344{
7345 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7346 tSirSetPowerParamsReq powerRequest;
7347 char *ptr;
7348 v_U8_t ucType;
7349 v_U32_t uTotalSize, uValue;
7350 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
7351
7352 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7353 "Power Params data len %d data %s",
7354 wrqu->data.length,
Arif Hussain7adce1b2013-11-11 22:59:34 -08007355 extra);
Jeff Johnson295189b2012-06-20 16:38:30 -07007356
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007357 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
7358 {
7359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7360 "%s:LOGP in Progress. Ignore!!!", __func__);
7361 return -EBUSY;
7362 }
7363
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 if (wrqu->data.length <= nOffset )
7365 {
7366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "set power param input is not correct");
7367 return VOS_STATUS_E_FAILURE;
7368 }
7369
7370 uTotalSize = wrqu->data.length - nOffset;
7371
7372 /*-----------------------------------------------------------------------
7373 Input is string based and expected to be like this:
7374
7375 <param_type> <param_value> <param_type> <param_value> ...
7376
7377 e.g:
7378 1 2 2 3 3 0 4 1 5 1
7379
7380 e.g. setting just a few:
7381 1 2 4 1
7382
7383 parameter types:
7384 -----------------------------
7385 1 - Ignore DTIM
7386 2 - Listen Interval
7387 3 - Broadcast Multicas Filter
7388 4 - Beacon Early Termination
7389 5 - Beacon Early Termination Interval
7390 -----------------------------------------------------------------------*/
7391 powerRequest.uIgnoreDTIM = SIR_NOCHANGE_POWER_VALUE;
7392 powerRequest.uListenInterval = SIR_NOCHANGE_POWER_VALUE;
7393 powerRequest.uBcastMcastFilter = SIR_NOCHANGE_POWER_VALUE;
7394 powerRequest.uEnableBET = SIR_NOCHANGE_POWER_VALUE;
7395 powerRequest.uBETInterval = SIR_NOCHANGE_POWER_VALUE;
7396
Arif Hussain7adce1b2013-11-11 22:59:34 -08007397 ptr = extra + nOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07007398
7399 while ( uTotalSize )
7400 {
Wilson Yang6f971452013-10-08 15:00:00 -07007401 if (1 != sscanf(ptr,"%hhu %n", &(ucType), &nOffset))
7402 {
7403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7404 "Invalid input parameter type %s",ptr);
7405 return VOS_STATUS_E_FAILURE;
7406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007407
7408 uTotalSize -= nOffset;
7409
7410 if (!uTotalSize)
7411 {
7412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007413 "Invalid input parameter type : %d with no value at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007414 ucType, nOffset);
7415 return VOS_STATUS_E_FAILURE;
7416 }
7417
7418 ptr += nOffset;
Wilson Yang6f971452013-10-08 15:00:00 -07007419
Jeff Johnson02797792013-10-26 19:17:13 -07007420 if (1 != sscanf(ptr,"%u %n", &(uValue), &nOffset))
Wilson Yang6f971452013-10-08 15:00:00 -07007421 {
7422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7423 "Invalid input parameter value %s",ptr);
7424 return VOS_STATUS_E_FAILURE;
7425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007426
7427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7428 "Power request parameter %d value %d offset %d",
7429 ucType, uValue, nOffset);
7430
7431 switch (ucType)
7432 {
7433 case eSIR_IGNORE_DTIM:
7434 powerRequest.uIgnoreDTIM = uValue;
7435 break;
7436 case eSIR_LISTEN_INTERVAL:
7437 powerRequest.uListenInterval = uValue;
7438 break;
7439 case eSIR_MCAST_BCAST_FILTER:
7440 powerRequest.uBcastMcastFilter = uValue;
7441 break;
7442 case eSIR_ENABLE_BET:
7443 powerRequest.uEnableBET = uValue;
7444 break;
7445 case eSIR_BET_INTERVAL:
7446 powerRequest.uBETInterval = uValue;
7447 break;
7448 default:
7449 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsona8a1a482012-12-12 16:49:33 -08007450 "Invalid input parameter type : %d with value: %d at offset %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007451 ucType, uValue, nOffset);
7452 return VOS_STATUS_E_FAILURE;
7453 }
7454
7455 uTotalSize -= nOffset;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7457 "Power request parameter %d Total size",
Jeff Johnsone7245742012-09-05 17:12:55 -07007458 uTotalSize);
Jeff Johnson295189b2012-06-20 16:38:30 -07007459 ptr += nOffset;
Jeff Johnsone7245742012-09-05 17:12:55 -07007460 /* This is added for dynamic Tele LI enable (0xF1) /disable (0xF0)*/
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007461 if(!(uTotalSize - nOffset) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07007462 (powerRequest.uListenInterval != SIR_NOCHANGE_POWER_VALUE))
7463 {
7464 uTotalSize = 0;
7465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007466
7467 }/*Go for as long as we have a valid string*/
7468
7469 /* put the device into full power*/
7470 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
7471
7472 /* Apply the power save params*/
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08007473 sme_SetPowerParams( WLAN_HDD_GET_HAL_CTX(pAdapter), &powerRequest, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007474
7475 /* put the device back to power save*/
7476 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
7477
7478 return VOS_STATUS_SUCCESS;
7479}/*iw_set_power_params*/
7480
Atul Mittalc0f739f2014-07-31 13:47:47 +05307481// tdlsoffchan
7482#ifdef FEATURE_WLAN_TDLS
7483
7484static int iw_set_tdlsoffchannel(hdd_context_t *pHddCtx, int offchannel)
7485{
7486 if (offchannel < 0 || offchannel > 165)
7487 {
7488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls off channel %u",
7489 __func__, offchannel);
7490 return -1;
7491
7492 }
7493
7494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel from %d to %d",
7495 __func__, tdlsOffCh, offchannel);
7496
7497 tdlsOffCh = offchannel;
7498 return 0;
7499}
7500
7501static int iw_set_tdlssecoffchanneloffset(hdd_context_t *pHddCtx, int offchanoffset)
7502{
7503 if (offchanoffset == 0)
7504 {
7505 tdlsOffChBwOffset = 0;
7506 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
7507 __func__, tdlsOffChBwOffset);
7508
7509 return 0;
7510
7511 }
7512
7513 if ( offchanoffset == 40 )
7514 {
7515 tdlsOffChBwOffset = 1;
7516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
7517 __func__, tdlsOffChBwOffset);
7518
7519 return 0;
7520
7521 }
7522 if (offchanoffset == -40)
7523 {
7524 tdlsOffChBwOffset = 3;
7525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls secondary off channel offset to %u",
7526 __func__, tdlsOffChBwOffset);
7527
7528 return 0;
7529
7530 }
7531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s: Invalid tdls secondary off channel offset %d",
7532 __func__, offchanoffset);
7533 return -1;
7534}
7535
7536static int iw_set_tdlsoffchannelmode(hdd_adapter_t *pAdapter, int offchanmode)
7537{
7538 hddTdlsPeer_t *connPeer = NULL;
7539 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7540 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7541
7542 if (offchanmode < 0 || offchanmode > 4)
7543 {
7544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7545 "%s: Invalid tdls off channel mode %d",
7546 __func__, offchanmode);
7547 return -1;
7548 }
7549
7550 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7551 {
7552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7553 "%s: tdls off channel mode req in not associated state %d",
7554 __func__, offchanmode);
7555 return -1;
7556 }
7557
7558 if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode ||
7559 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == pHddCtx->tdls_mode)
7560 {
7561 /* Send TDLS Channel Switch Request to connected peer */
7562 connPeer = wlan_hdd_tdls_get_first_connected_peer(pAdapter);
7563 if (NULL == connPeer) {
7564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7565 "%s: No TDLS Connected Peer", __func__);
7566 return -1;
7567 }
7568 }
7569 else
7570 {
7571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7572 "%s: TDLS Connection not supported", __func__);
7573 return -1;
7574 }
7575
7576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7577 ("%s: TDLS Channel Switch in swmode=%d"),
7578 __func__, offchanmode);
7579
7580 switch (offchanmode)
7581 {
7582 case 1:/*Enable*/
7583 case 2:/*Disable*/
7584 {
7585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7586 "%s: change tdls off channel mode %d tdls_off_channel %d offchanoffset %d ",
7587 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
7588 if (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel)
7589 {
7590
7591 sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
7592 pAdapter->sessionId, connPeer->peerMac,
7593 tdlsOffCh, tdlsOffChBwOffset,
7594 offchanmode);
7595 }
7596 else
7597 {
7598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7599 "%s: TDLS Off Channel not supported", __func__);
7600 return -1;
7601 }
7602 break;
7603 }
7604 case 3:
7605 {
7606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7607 "%s: change tdls off channel mode %d REJREQ 3 tdls_off_channel %d offchanoffset %d ",
7608 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
7609
7610 break;
7611 }
7612 case 4:
7613 {
7614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7615 "%s: change tdls off channel mode %d UNSOLRESP 4 tdls_off_channel %d offchanoffset %d ",
7616 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
7617 break;
7618 }
7619 default:
7620 {
7621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7622 "%s: change tdls off channel mode %d Not SET 0 tdls_off_channel %d offchanoffset %d ",
7623 __func__, offchanmode, tdlsOffCh, tdlsOffChBwOffset);
7624 break;
7625 }
7626
7627 }
7628
7629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change tdls off channel mode to %u",
7630 __func__, offchanmode);
7631 return 0;
7632}
7633
7634#endif
7635
Jeff Johnson295189b2012-06-20 16:38:30 -07007636
7637// Define the Wireless Extensions to the Linux Network Device structure
7638// A number of these routines are NULL (meaning they are not implemented.)
7639
7640static const iw_handler we_handler[] =
7641{
7642 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
7643 (iw_handler) iw_get_name, /* SIOCGIWNAME */
7644 (iw_handler) NULL, /* SIOCSIWNWID */
7645 (iw_handler) NULL, /* SIOCGIWNWID */
7646 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
7647 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
7648 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
7649 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
7650 (iw_handler) NULL, /* SIOCSIWSENS */
7651 (iw_handler) NULL, /* SIOCGIWSENS */
7652 (iw_handler) NULL, /* SIOCSIWRANGE */
7653 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
7654 (iw_handler) iw_set_priv, /* SIOCSIWPRIV */
7655 (iw_handler) NULL, /* SIOCGIWPRIV */
7656 (iw_handler) NULL, /* SIOCSIWSTATS */
7657 (iw_handler) NULL, /* SIOCGIWSTATS */
7658 iw_handler_set_spy, /* SIOCSIWSPY */
7659 iw_handler_get_spy, /* SIOCGIWSPY */
7660 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
7661 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
7662 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
7663 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
7664 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
7665 (iw_handler) NULL, /* SIOCGIWAPLIST */
7666 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
7667 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
7668 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
7669 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
7670 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
7671 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
7672 (iw_handler) NULL, /* -- hole -- */
7673 (iw_handler) NULL, /* -- hole -- */
7674 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
7675 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
7676 (iw_handler) iw_set_rts_threshold,/* SIOCSIWRTS */
7677 (iw_handler) iw_get_rts_threshold,/* SIOCGIWRTS */
7678 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
7679 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
7680 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
7681 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
7682 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
7683 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
7684 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
7685 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
7686 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
7687 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
7688 (iw_handler) NULL, /* -- hole -- */
7689 (iw_handler) NULL, /* -- hole -- */
7690 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
7691 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
7692 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
7693 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
7694 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
7695 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
7696 (iw_handler) NULL, /* SIOCSIWPMKSA */
7697};
7698
7699static const iw_handler we_private[] = {
7700
7701 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, //set priv ioctl
7702 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, //get priv ioctl
7703 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, //get priv ioctl
7704 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_three_ints_getnone,
7705 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
7706 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, //action priv ioctl
7707 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_set_var_ints_getnone,
7708 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
7709 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
7710 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Jeff Johnsone7245742012-09-05 17:12:55 -07007711#ifdef FEATURE_OEM_DATA_SUPPORT
7712 [WLAN_PRIV_SET_OEM_DATA_REQ - SIOCIWFIRSTPRIV] = iw_set_oem_data_req, //oem data req Specifc
7713 [WLAN_PRIV_GET_OEM_DATA_RSP - SIOCIWFIRSTPRIV] = iw_get_oem_data_rsp, //oem data req Specifc
7714#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007715
Jeff Johnson295189b2012-06-20 16:38:30 -07007716#ifdef WLAN_FEATURE_VOWIFI_11R
7717 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
7718#endif
7719 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
7720 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
7721 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] = iw_set_keepalive_params
7722#ifdef WLAN_FEATURE_PACKET_FILTERING
7723 ,
7724 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_packet_filter_params
7725#endif
7726#ifdef FEATURE_WLAN_SCAN_PNO
7727 ,
7728 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno_priv
7729#endif
7730 ,
7731 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
7732 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_set_dynamic_mcbc_filter,
7733 [WLAN_PRIV_CLEAR_MCBC_FILTER - SIOCIWFIRSTPRIV] = iw_clear_dynamic_mcbc_filter,
7734 [WLAN_SET_POWER_PARAMS - SIOCIWFIRSTPRIV] = iw_set_power_params_priv,
Arif Hussain695279c2014-03-24 14:06:07 -07007735 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed_priv,
Jeff Johnson295189b2012-06-20 16:38:30 -07007736};
7737
7738/*Maximum command length can be only 15 */
7739static const struct iw_priv_args we_private_args[] = {
7740
7741 /* handlers for main ioctl */
7742 { WLAN_PRIV_SET_INT_GET_NONE,
7743 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7744 0,
7745 "" },
7746
7747 /* handlers for sub-ioctl */
7748 { WE_SET_11D_STATE,
7749 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7750 0,
7751 "set11Dstate" },
7752
7753 { WE_WOWL,
7754 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7755 0,
7756 "wowl" },
7757
7758 { WE_SET_POWER,
7759 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7760 0,
7761 "setPower" },
7762
7763 { WE_SET_MAX_ASSOC,
7764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7765 0,
7766 "setMaxAssoc" },
7767
7768 { WE_SET_SAP_AUTO_CHANNEL_SELECTION,
7769 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7770 0,
7771 "setAutoChannel" },
7772
7773 { WE_SET_DATA_INACTIVITY_TO,
7774 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7775 0,
7776 "inactivityTO" },
7777
7778 { WE_SET_MAX_TX_POWER,
7779 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7780 0,
Arif Hussaina5ebce02013-08-09 15:09:58 -07007781 "setMaxTxPower" },
7782
7783 { WE_SET_MAX_TX_POWER_2_4,
7784 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7785 0,
7786 "setTxMaxPower2G" },
7787
7788 { WE_SET_MAX_TX_POWER_5_0,
7789 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7790 0,
7791 "setTxMaxPower5G" },
Rajesh Chauhanf22af962013-07-16 18:50:29 -07007792
7793 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
7794 * as well to keep same syntax as in SAP. Now onwards, STA
7795 * will support both */
7796 { WE_SET_MAX_TX_POWER,
7797 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7798 0,
7799 "setTxMaxPower" },
7800
Jeff Johnson295189b2012-06-20 16:38:30 -07007801 /* set Higher DTIM Transition (DTIM1 to DTIM3)
7802 * 1 = enable and 0 = disable */
7803 {
7804 WE_SET_HIGHER_DTIM_TRANSITION,
7805 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7806 0,
7807 "setHDtimTransn" },
7808
7809 { WE_SET_TM_LEVEL,
7810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08007811 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007812 "setTmLevel" },
7813
Kiet Lam46b8e4e2013-11-06 21:49:53 +05307814 { WE_ENABLE_STRICT_FCC_REG,
7815 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7816 0,
7817 "setStrictFCCreg" },
7818
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007819 { WE_SET_DEBUG_LOG,
7820 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7821 0, "setDbgLvl" },
Atul Mittalc0f739f2014-07-31 13:47:47 +05307822#ifdef FEATURE_WLAN_TDLS
7823 {
7824 WE_SET_TDLS_OFF_CHAN,
7825 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7826 0,
7827 "tdlsoffchan" },
7828 {
7829 WE_SET_TDLS_SEC_OFF_CHAN_OFFSET,
7830 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7831 0,
7832 "tdlsecchnoffst" },
7833 {
7834 WE_SET_TDLS_OFF_CHAN_MODE,
7835 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7836 0,
7837 "tdlsoffchnmode" },
7838#endif
Tushnim Bhattacharyyaa3ba5a52014-01-30 11:37:33 -08007839
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 /* handlers for main ioctl */
7841 { WLAN_PRIV_SET_NONE_GET_INT,
7842 0,
7843 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7844 "" },
7845
7846 /* handlers for sub-ioctl */
7847 { WE_GET_11D_STATE,
7848 0,
7849 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7850 "get11Dstate" },
7851
7852 { WE_IBSS_STATUS,
7853 0,
7854 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7855 "getAdhocStatus" },
7856
7857 { WE_PMC_STATE,
7858 0,
7859 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7860 "pmcState" },
7861
7862 { WE_GET_WLAN_DBG,
7863 0,
7864 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7865 "getwlandbg" },
7866
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 { WE_GET_MAX_ASSOC,
7868 0,
7869 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7870 "getMaxAssoc" },
7871
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 { WE_GET_WDI_DBG,
7873 0,
7874 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7875 "getwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007876
7877 { WE_GET_SAP_AUTO_CHANNEL_SELECTION,
7878 0,
7879 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7880 "getAutoChannel" },
7881
7882 { WE_GET_CONCURRENCY_MODE,
7883 0,
7884 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
7885 "getconcurrency" },
7886
7887 /* handlers for main ioctl */
7888 { WLAN_PRIV_SET_CHAR_GET_NONE,
7889 IW_PRIV_TYPE_CHAR| 512,
7890 0,
7891 "" },
7892
7893 /* handlers for sub-ioctl */
7894 { WE_WOWL_ADD_PTRN,
7895 IW_PRIV_TYPE_CHAR| 512,
7896 0,
7897 "wowlAddPtrn" },
7898
7899 { WE_WOWL_DEL_PTRN,
7900 IW_PRIV_TYPE_CHAR| 512,
7901 0,
7902 "wowlDelPtrn" },
7903
7904#if defined WLAN_FEATURE_VOWIFI
7905 /* handlers for sub-ioctl */
7906 { WE_NEIGHBOR_REPORT_REQUEST,
7907 IW_PRIV_TYPE_CHAR | 512,
7908 0,
7909 "neighbor" },
7910#endif
7911 { WE_SET_AP_WPS_IE,
7912 IW_PRIV_TYPE_CHAR| 512,
7913 0,
7914 "set_ap_wps_ie" },
7915
7916 { WE_SET_CONFIG,
7917 IW_PRIV_TYPE_CHAR| 512,
7918 0,
7919 "setConfig" },
7920
7921 /* handlers for main ioctl */
7922 { WLAN_PRIV_SET_THREE_INT_GET_NONE,
7923 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7924 0,
7925 "" },
7926
7927 /* handlers for sub-ioctl */
7928 { WE_SET_WLAN_DBG,
7929 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7930 0,
7931 "setwlandbg" },
7932
Jeff Johnson295189b2012-06-20 16:38:30 -07007933 { WE_SET_WDI_DBG,
7934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7935 0,
7936 "setwdidbg" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007937
7938 { WE_SET_SAP_CHANNELS,
7939 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
7940 0,
7941 "setsapchannels" },
7942
7943 /* handlers for main ioctl */
7944 { WLAN_PRIV_GET_CHAR_SET_NONE,
7945 0,
7946 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7947 "" },
7948
7949 /* handlers for sub-ioctl */
7950 { WE_WLAN_VERSION,
7951 0,
7952 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7953 "version" },
7954 { WE_GET_STATS,
7955 0,
7956 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7957 "getStats" },
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307958 { WE_GET_STATES,
7959 0,
7960 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7961 "getHostStates" },
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 { WE_GET_CFG,
7963 0,
7964 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7965 "getConfig" },
Jeff Johnsone7245742012-09-05 17:12:55 -07007966#ifdef WLAN_FEATURE_11AC
7967 { WE_GET_RSSI,
7968 0,
7969 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7970 "getRSSI" },
7971#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007972#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08007973 { WE_GET_ROAM_RSSI,
7974 0,
7975 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7976 "getRoamRSSI" },
7977#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007978 { WE_GET_WMM_STATUS,
7979 0,
7980 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7981 "getWmmStatus" },
7982 {
7983 WE_GET_CHANNEL_LIST,
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05307984 0,
Jeff Johnson295189b2012-06-20 16:38:30 -07007985 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7986 "getChannelList" },
Chilam Ng16a2a1c2013-01-29 01:27:29 -08007987#ifdef FEATURE_WLAN_TDLS
7988 {
7989 WE_GET_TDLS_PEERS,
7990 0,
7991 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7992 "getTdlsPeers" },
7993#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007994#ifdef WLAN_FEATURE_11W
7995 {
7996 WE_GET_11W_INFO,
7997 0,
7998 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
7999 "getPMFInfo" },
8000#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 /* handlers for main ioctl */
8002 { WLAN_PRIV_SET_NONE_GET_NONE,
8003 0,
8004 0,
8005 "" },
8006
8007 /* handlers for sub-ioctl */
8008 { WE_CLEAR_STATS,
8009 0,
8010 0,
8011 "clearStats" },
8012 { WE_INIT_AP,
8013 0,
8014 0,
8015 "initAP" },
8016 { WE_STOP_AP,
8017 0,
8018 0,
8019 "exitAP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308020#ifdef WLAN_BTAMP_FEATURE
Jeff Johnson295189b2012-06-20 16:38:30 -07008021 { WE_ENABLE_AMP,
8022 0,
8023 0,
8024 "enableAMP" },
8025 { WE_DISABLE_AMP,
8026 0,
8027 0,
8028 "disableAMP" },
Girish Gowli345bff82014-06-09 20:05:24 +05308029#endif /* WLAN_BTAMP_FEATURE */
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07008030 { WE_ENABLE_DXE_STALL_DETECT,
8031 0,
8032 0,
8033 "dxeStallDetect" },
8034 { WE_DISPLAY_DXE_SNAP_SHOT,
8035 0,
8036 0,
8037 "dxeSnapshot" },
Madan Mohan Koyyalamudia96f5442013-05-10 11:32:06 +05308038 { WE_DISPLAY_DATAPATH_SNAP_SHOT,
8039 0,
8040 0,
8041 "dataSnapshot"},
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07008042 {
Sandeep Puligillaa3e76952014-06-23 15:53:11 +05308043 WE_SET_REASSOC_TRIGGER,
8044 0,
8045 0,
8046 "reassoc" },
8047 {
Sandeep Puligilla04bb8fd2014-02-03 23:21:47 +05308048 WE_STOP_OBSS_SCAN,
8049 0,
8050 0,
8051 "stopOBSSScan" },
Mukul Sharma84f27252014-07-14 18:11:42 +05308052#ifdef DEBUG_ROAM_DELAY
8053 {
8054 WE_DUMP_ROAM_TIMER_LOG,
8055 0,
8056 0,
8057 "dumpRoamDelay" },
8058 {
8059 WE_RESET_ROAM_TIMER_LOG,
8060 0,
8061 0,
8062 "resetRoamDelay" },
8063#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 /* handlers for main ioctl */
8065 { WLAN_PRIV_SET_VAR_INT_GET_NONE,
8066 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8067 0,
8068 "" },
8069
8070 /* handlers for sub-ioctl */
8071 { WE_LOG_DUMP_CMD,
8072 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8073 0,
8074 "dump" },
8075
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008076 /* handlers for sub-ioctl */
Katya Nigamc2f29dc2014-01-20 19:29:30 +05308077 { WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
8078 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8079 0,
8080 "setdumplog" },
8081
Leela Venkata Kiran Kumar Reddy Chirala57af2692013-04-10 22:39:51 -07008082 { WE_MTRACE_DUMP_CMD,
8083 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8084 0,
8085 "dumplog" },
8086
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008087 /* handlers for sub ioctl */
8088 {
8089 WE_MCC_CONFIG_CREDENTIAL,
8090 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8091 0,
8092 "setMccCrdnl" },
8093
8094 /* handlers for sub ioctl */
8095 {
8096 WE_MCC_CONFIG_PARAMS,
8097 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8098 0,
8099 "setMccConfig" },
8100
Chilam NG571c65a2013-01-19 12:27:36 +05308101#ifdef FEATURE_WLAN_TDLS
8102 /* handlers for sub ioctl */
8103 {
8104 WE_TDLS_CONFIG_PARAMS,
8105 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8106 0,
8107 "setTdlsConfig" },
8108#endif
8109
Jeff Johnson295189b2012-06-20 16:38:30 -07008110 /* handlers for main ioctl */
8111 { WLAN_PRIV_ADD_TSPEC,
8112 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
8113 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8114 "addTspec" },
8115
8116 /* handlers for main ioctl */
8117 { WLAN_PRIV_DEL_TSPEC,
8118 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8120 "delTspec" },
8121
8122 /* handlers for main ioctl */
8123 { WLAN_PRIV_GET_TSPEC,
8124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8125 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8126 "getTspec" },
8127
Jeff Johnsone7245742012-09-05 17:12:55 -07008128#ifdef FEATURE_OEM_DATA_SUPPORT
8129 /* handlers for main ioctl - OEM DATA */
8130 {
8131 WLAN_PRIV_SET_OEM_DATA_REQ,
8132 IW_PRIV_TYPE_BYTE | sizeof(struct iw_oem_data_req) | IW_PRIV_SIZE_FIXED,
8133 0,
8134 "set_oem_data_req" },
8135
8136 /* handlers for main ioctl - OEM DATA */
8137 {
8138 WLAN_PRIV_GET_OEM_DATA_RSP,
8139 0,
8140 IW_PRIV_TYPE_BYTE | MAX_OEM_DATA_RSP_LEN,
8141 "get_oem_data_rsp" },
8142#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008143
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 /* handlers for main ioctl - host offload */
8145 {
8146 WLAN_PRIV_SET_HOST_OFFLOAD,
8147 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
8148 0,
8149 "setHostOffload" },
8150
8151 {
8152 WLAN_GET_WLAN_STATISTICS,
8153 0,
8154 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
8155 "getWlanStats" },
8156
8157 {
8158 WLAN_SET_KEEPALIVE_PARAMS,
8159 IW_PRIV_TYPE_BYTE | sizeof(tKeepAliveRequest),
8160 0,
8161 "setKeepAlive" },
8162#ifdef WLAN_FEATURE_PACKET_FILTERING
8163 {
8164 WLAN_SET_PACKET_FILTER_PARAMS,
8165 IW_PRIV_TYPE_BYTE | sizeof(tPacketFilterCfg),
8166 0,
8167 "setPktFilter" },
8168#endif
8169#ifdef FEATURE_WLAN_SCAN_PNO
8170 {
8171 WLAN_SET_PNO,
8172 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8173 0,
8174 "setpno" },
8175#endif
8176 {
8177 WLAN_SET_BAND_CONFIG,
Atul Mittal54378cb2014-04-02 16:51:50 +05308178 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 0,
8180 "SETBAND" },
8181 /* handlers for dynamic MC BC ioctl */
8182 {
8183 WLAN_PRIV_SET_MCBC_FILTER,
Amar Singhalf3a6e762013-02-19 15:06:50 -08008184 IW_PRIV_TYPE_BYTE | sizeof(tRcvFltMcAddrList),
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 0,
8186 "setMCBCFilter" },
8187 {
8188 WLAN_PRIV_CLEAR_MCBC_FILTER,
8189 0,
8190 0,
8191 "clearMCBCFilter" },
8192 {
8193 WLAN_SET_POWER_PARAMS,
8194 IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
8195 0,
8196 "setpowerparams" },
8197 {
8198 WLAN_GET_LINK_SPEED,
8199 IW_PRIV_TYPE_CHAR | 18,
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +05308200 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed" },
Jeff Johnson295189b2012-06-20 16:38:30 -07008201};
8202
8203
8204
8205const struct iw_handler_def we_handler_def = {
8206 .num_standard = sizeof(we_handler) / sizeof(we_handler[0]),
8207 .num_private = sizeof(we_private) / sizeof(we_private[0]),
8208 .num_private_args = sizeof(we_private_args) / sizeof(we_private_args[0]),
8209
8210 .standard = (iw_handler *)we_handler,
8211 .private = (iw_handler *)we_private,
8212 .private_args = we_private_args,
8213 .get_wireless_stats = get_wireless_stats,
8214};
8215
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008216int hdd_validate_mcc_config(hdd_adapter_t *pAdapter, v_UINT_t staId, v_UINT_t arg1, v_UINT_t arg2, v_UINT_t arg3)
8217{
8218 v_U32_t cmd = 288; //Command to RIVA
8219 hdd_context_t *pHddCtx = NULL;
8220 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8221 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8222 /*
8223 *configMccParam : specify the bit which needs to be modified
8224 *allowed to update based on wlan_qcom_cfg.ini
8225 * configuration
8226 * Bit 0 : SCHEDULE_TIME_SLICE MIN : 5 MAX : 20
8227 * Bit 1 : MAX_NULL_SEND_TIME MIN : 1 MAX : 10
8228 * Bit 2 : TX_EARLY_STOP_TIME MIN : 1 MAX : 10
8229 * Bit 3 : RX_DRAIN_TIME MIN : 1 MAX : 10
8230 * Bit 4 : CHANNEL_SWITCH_TIME MIN : 1 MAX : 20
8231 * Bit 5 : MIN_CHANNEL_TIME MIN : 5 MAX : 20
8232 * Bit 6 : PARK_BEFORE_TBTT MIN : 1 MAX : 5
8233 * Bit 7 : MIN_AFTER_DTIM MIN : 5 MAX : 15
8234 * Bit 8 : TOO_CLOSE_MARGIN MIN : 1 MAX : 3
8235 * Bit 9 : Reserved
8236 */
8237 switch (arg1)
8238 {
8239 //Update MCC SCHEDULE_TIME_SLICE parameter
8240 case MCC_SCHEDULE_TIME_SLICE_CFG_PARAM :
8241 if( pHddCtx->cfg_ini->configMccParam & 0x0001)
8242 {
8243 if((arg2 >= 5) && (arg2 <= 20))
8244 {
8245 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8246 }
8247 else
8248 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008249 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008250 return 0;
8251 }
8252 }
8253 break;
8254
8255 //Update MCC MAX_NULL_SEND_TIME parameter
8256 case MCC_MAX_NULL_SEND_TIME_CFG_PARAM :
8257 if( pHddCtx->cfg_ini->configMccParam & 0x0002)
8258 {
8259 if((arg2 >= 1) && (arg2 <= 10))
8260 {
8261 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8262 }
8263 else
8264 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008265 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008266 return 0;
8267 }
8268 }
8269 break;
8270
8271 //Update MCC TX_EARLY_STOP_TIME parameter
8272 case MCC_TX_EARLY_STOP_TIME_CFG_PARAM :
8273 if( pHddCtx->cfg_ini->configMccParam & 0x0004)
8274 {
8275 if((arg2 >= 1) && (arg2 <= 10))
8276 {
8277 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8278 }
8279 else
8280 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008281 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008282 return 0;
8283 }
8284 }
8285 break;
8286
8287 //Update MCC RX_DRAIN_TIME parameter
8288 case MCC_RX_DRAIN_TIME_CFG_PARAM :
8289 if( pHddCtx->cfg_ini->configMccParam & 0x0008)
8290 {
8291 if((arg2 >= 1) && (arg2 <= 10))
8292 {
8293 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8294 }
8295 else
8296 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008297 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008298 return 0;
8299 }
8300 }
8301 break;
8302
8303 //Update MCC CHANNEL_SWITCH_TIME parameter
8304 case MCC_CHANNEL_SWITCH_TIME_CFG_PARAM :
8305 if( pHddCtx->cfg_ini->configMccParam & 0x0010)
8306 {
8307 if((arg2 >= 1) && (arg2 <= 20))
8308 {
8309 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8310 }
8311 else
8312 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008313 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008314 return 0;
8315 }
8316 }
8317 break;
8318
8319 //Update MCC MIN_CHANNEL_TIME parameter
8320 case MCC_MIN_CHANNEL_TIME_CFG_PARAM :
8321 if( pHddCtx->cfg_ini->configMccParam & 0x0020)
8322 {
8323 if((arg2 >= 5) && (arg2 <= 20))
8324 {
8325 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8326 }
8327 else
8328 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008329 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008330 return 0;
8331 }
8332 }
8333 break;
8334
8335 //Update MCC PARK_BEFORE_TBTT parameter
8336 case MCC_PARK_BEFORE_TBTT_CFG_PARAM :
8337 if( pHddCtx->cfg_ini->configMccParam & 0x0040)
8338 {
8339 if((arg2 >= 1) && (arg2 <= 5))
8340 {
8341 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8342 }
8343 else
8344 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008345 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008346 return 0;
8347 }
8348 }
8349 break;
8350
8351 //Update MCC MIN_AFTER_DTIM parameter
8352 case MCC_MIN_AFTER_DTIM_CFG_PARAM :
8353 if( pHddCtx->cfg_ini->configMccParam & 0x0080)
8354 {
8355 if((arg2 >= 5) && (arg2 <= 15))
8356 {
8357 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8358 }
8359 else
8360 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008361 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008362 return 0;
8363 }
8364 }
8365 break;
8366
8367 //Update MCC TOO_CLOSE_MARGIN parameter
8368 case MCC_TOO_CLOSE_MARGIN_CFG_PARAM :
8369 if( pHddCtx->cfg_ini->configMccParam & 0x0100)
8370 {
8371 if((arg2 >= 1) && (arg2 <= 3))
8372 {
8373 logPrintf(hHal, cmd, staId, arg1, arg2, arg3);
8374 }
8375 else
8376 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008377 hddLog(LOGE, "%s : Enter a valid MCC configuration value",__FUNCTION__);
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008378 return 0;
8379 }
8380 }
8381 break;
8382
8383 default :
Arif Hussain6d2a3322013-11-17 19:50:10 -08008384 hddLog(LOGE, "%s : Uknown / Not allowed to configure parameter : %d",
Madan Mohan Koyyalamudid5f04ca2012-11-06 15:51:26 -08008385 __FUNCTION__,arg1);
8386 break;
8387 }
8388 return 0;
8389}
8390
Jeff Johnson295189b2012-06-20 16:38:30 -07008391int hdd_set_wext(hdd_adapter_t *pAdapter)
8392{
8393 hdd_wext_state_t *pwextBuf;
8394 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008395 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008396
8397 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8398
8399 // Now configure the roaming profile links. To SSID and bssid.
8400 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
8401 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
8402
8403 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
8404 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
8405
8406 /*Set the numOfChannels to zero to scan all the channels*/
8407 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
8408 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
8409
8410 /* Default is no encryption */
8411 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
8412 pwextBuf->roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8413
8414 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
8415 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8416
8417 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
8418
8419 /* Default is no authentication */
8420 pwextBuf->roamProfile.AuthType.numEntries = 1;
8421 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
8422
8423 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_TAURUS;
8424 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
8425
8426 /*Set the default scan mode*/
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008427 pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008428
8429 hdd_clearRoamProfileIe(pAdapter);
8430
8431 return VOS_STATUS_SUCCESS;
8432
8433 }
8434
8435int hdd_register_wext(struct net_device *dev)
8436 {
8437 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8438 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8439 VOS_STATUS status;
8440
8441 ENTER();
8442
8443 // Zero the memory. This zeros the profile structure.
8444 memset(pwextBuf, 0,sizeof(hdd_wext_state_t));
8445
8446 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->completion_var);
8447
8448
8449 status = hdd_set_wext(pAdapter);
8450
8451 if(!VOS_IS_STATUS_SUCCESS(status)) {
8452
Arif Hussain6d2a3322013-11-17 19:50:10 -08008453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: hdd_set_wext failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 return eHAL_STATUS_FAILURE;
8455 }
8456
8457 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->vosevent)))
8458 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD vos event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008460 return eHAL_STATUS_FAILURE;
8461 }
8462
8463 if (!VOS_IS_STATUS_SUCCESS(vos_event_init(&pwextBuf->scanevent)))
8464 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, ("ERROR: HDD scan event init failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 return eHAL_STATUS_FAILURE;
8467 }
8468
8469 // Register as a wireless device
8470 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
8471
8472 EXIT();
8473 return 0;
8474}
8475
8476int hdd_UnregisterWext(struct net_device *dev)
8477{
8478#if 0
8479 hdd_wext_state_t *wextBuf;
8480 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8481
8482 ENTER();
8483 // Set up the pointer to the Wireless Extensions state structure
8484 wextBuf = pAdapter->pWextState;
8485
8486 // De-allocate the Wireless Extensions state structure
8487 kfree(wextBuf);
8488
8489 // Clear out the pointer to the Wireless Extensions state structure
8490 pAdapter->pWextState = NULL;
8491
8492 EXIT();
8493#endif
8494 dev->wireless_handlers = NULL;
8495 return 0;
8496}
8497
8498